{"version":3,"file":"ngrx-traits-signals.mjs","sources":["../../../../../libs/ngrx-traits/signals/src/lib/with-all-call-status/with-all-call-status.util.ts","../../../../../libs/ngrx-traits/signals/src/lib/util.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-event-handler/with-event-handler.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-feature-factory/with-feature-factory.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-feature-factory/with-feature-factory.model.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-event-handler/with-event-handler.util.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-call-status/with-call-status.util.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-call-status/with-call-status.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-filter/with-entities-filter.util.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-filter/with-entities-local-filter.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-filter/with-entities-remote-filter.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-filter/with-entities-hybrid-filter.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-link/with-link.util.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-link/with-link.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-filter/with-link-entities-filter.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-sort/with-entities-sort.util.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-sort/with-entities-local-sort.util.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-pagination/with-entities-local-pagination.util.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-pagination/with-entities-local-pagination.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-sort/with-entities-remote-sort.util.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-pagination/with-entities-remote-pagination.util.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-pagination/with-entities-remote-pagination.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-pagination/with-entities-remote-scroll-pagination.util.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-pagination/with-entities-remote-scroll-pagination.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-pagination/signal-infinite-datasource.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-sort/with-entities-local-sort.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-sort/with-entities-remote-sort.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-sort/with-link-entities-sort.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-selection/with-entities-single-selection.util.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-selection/with-entities-single-selection.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-selection/with-entities-multi-selection.util.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-selection/with-entities-multi-selection.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-selection/with-link-entities-single-selection.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-selection/with-link-entities-multi-selection.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-loading-call/with-entities-loading-call.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-logger/with-logger.util.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-logger/with-logger.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-calls/with-calls.util.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-calls/with-calls.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-call-status-map/with-call-status-map.util.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-call-status-map/with-call-status-map.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-calls/call-config.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-sync-to-web-storage/with-sync-to-web-storage.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-server-state-transfer/with-server-state-transfer.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-sync-to-route-query-params/with-sync-to-route-query-params.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-sync-to-route-query-params/with-entities-sync-to-route-query-params.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-sync-to-route-query-params/with-sync-to-route-query-params.util.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-route/with-route.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-route-params/with-route-params.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-input-bindings/with-input-bindings.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-all-call-status/with-all-call-status.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-calls/with-entities-calls.util.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-calls/with-entities-calls.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-entities-calls/entity-call-config.ts","../../../../../libs/ngrx-traits/signals/src/lib/cache/cache.utils.ts","../../../../../libs/ngrx-traits/signals/src/lib/cache/cache-store.ts","../../../../../libs/ngrx-traits/signals/src/lib/cache/global-cache.ts","../../../../../libs/ngrx-traits/signals/src/lib/with-state-setter/with-state-setter.ts","../../../../../libs/ngrx-traits/signals/src/ngrx-traits-signals.ts"],"sourcesContent":["import { Signal } from '@angular/core';\n\nimport { CallStatus } from './with-all-call-status.model';\n\nexport function registerCallState(\n  store: Record<string, any>,\n  callStatus: CallStatus,\n) {\n  if ('_registerCallStatus' in store) {\n    (\n      store as { _registerCallStatus: (callStatus: CallStatus) => void }\n    )._registerCallStatus(callStatus);\n  }\n}\n","export function capitalize(name: string) {\n  return name.charAt(0).toUpperCase() + name.slice(1);\n}\n\nexport function getWithEntitiesKeys(config?: { collection?: string }) {\n  const collection = config?.collection;\n  return {\n    idsKey: collection ? `${config.collection}Ids` : 'ids',\n    entitiesKey: collection ? `${config.collection}Entities` : 'entities',\n    entityMapKey: collection ? `${config.collection}EntityMap` : 'entityMap',\n  };\n}\nexport function toMap(a: Array<string | number>) {\n  return a.reduce((acum: { [key: string]: boolean }, value) => {\n    acum[value] = true;\n    return acum;\n  }, {});\n}\nexport function insertIf<T>(condition: any, getElement: () => T): [T] {\n  return (condition ? [getElement()] : []) as [T];\n}\n\nexport type OverridableFunction = {\n  (...args: any[]): void;\n  impl?: (...args: unknown[]) => void;\n};\n\nexport function combineFunctions(\n  previous?: OverridableFunction,\n  next?: (...args: any[]) => void,\n): OverridableFunction {\n  if (previous && !next) {\n    return previous;\n  }\n  const previousImplementation = previous?.impl;\n  const fun: OverridableFunction =\n    previous ??\n    ((...args: any[]) => {\n      fun.impl?.(...args);\n    });\n  fun.impl = next\n    ? (...args: any[]) => {\n        previousImplementation?.(...args);\n        next(...args);\n      }\n    : undefined;\n  return fun;\n}\n\n/**\n * Combines the implementation of a function defined in the store with\n * a new implementation of the same type\n * the resulting call will execute both functions when called,\n * @param param\n * @param store\n */\nexport function combineFunctionsInObject<\n  T extends Record<string | symbol, Function | undefined>,\n>(param: T, store: Record<string | symbol, unknown>): T {\n  const replaceProps = (\n    acc: Record<string | symbol, Function>,\n    key: string | symbol,\n  ) => {\n    let value = param[key];\n    value = combineFunctions(\n      store[key] as OverridableFunction,\n      value as (...args: any[]) => void,\n    );\n    if (!store[key]) acc[key] = value;\n    return acc;\n  };\n  let result = Object.keys(param).reduce(\n    replaceProps,\n    {} as Record<string | symbol, Function>,\n  );\n  result = Object.getOwnPropertySymbols(param).reduce(replaceProps, result);\n  return result as T;\n}\n","import {\n  Prettify,\n  SignalStoreFeature,\n  signalStoreFeature,\n  SignalStoreFeatureResult,\n  StateSignals,\n  withMethods,\n  WritableStateSource,\n} from '@ngrx/signals';\n\nimport {\n  combineFunctions,\n  combineFunctionsInObject,\n  OverridableFunction,\n} from '../util';\nimport { Event, EventCreator, EventType } from './with-event-handler.model';\n\nconst ON_EVENT = '__onEvent';\n\n/**\n * @experimental\n * Adds an event handler to the store, allowing the store to listen to events and react to them.\n * This helps with the communications between different store feature functions, normally a store feature can only\n * call methods generated by other store featured if it is declared before. With event handlers, you can send events\n * to other store features, and they can react to them regardless of the order of declaration. This is useful for example between\n * the filter and pagination store features, filter fires an event when the filter is changed and the pagination store\n * feature can listen to it and reset the current page back to 0, by using  withEventHandler pagination avoids creating a dependency\n * on the filter store feature, and the order in which they get declared won't affect the communication .\n *\n * @param eventHandlerFactory\n *\n * @example\n *\n *     const increment = createEvent('[Counter] Increment');\n *     const decrement = createEvent('[Counter] Decrement');\n *     const add = createEvent('[Counter] Add', props<{ value: number }>());\n *     const Store = signalStore(\n *       withState({ count: 0 }),\n *       withEventHandler((state) => [\n *         onEvent(increment, () => {\n *           patchState(state, { count: state.count() + 1 });\n *         }),\n *         onEvent(decrement, () => {\n *           patchState(state, { count: state.count() - 1 });\n *         }),\n *       ]),\n *       withMethods((state) => {\n *         return {\n *           // this test we can send events to things defined after this method\n *           add5: () => broadcast(state, add({ value: 5 })),\n *         };\n *       }),\n *       withEventHandler((state) => [\n *         onEvent(add, ({ value }) => {\n *           patchState(state, { count: state.count() + value });\n *         }),\n *       ]),\n *       withMethods((state) => {\n *         return {\n *           increment: () => broadcast(state, increment()),\n *           decrement: () => broadcast(state, decrement()),\n *         };\n *       }),\n *     );\n */\nexport function withEventHandler<Input extends SignalStoreFeatureResult>(\n  eventHandlerFactory?: (\n    store: Prettify<\n      StateSignals<Input['state']> &\n        Input['props'] &\n        Input['methods'] &\n        WritableStateSource<Prettify<Input['state']>>\n    >,\n  ) => EventHandlersTypes<any>[],\n): SignalStoreFeature<Input, Input> {\n  return signalStoreFeature(\n    withMethods((store) => {\n      const handlersArray = eventHandlerFactory?.(store as any);\n      const eventHandler = handlersArray\n        ? (event: Event) => {\n            handlersArray.forEach((h) => {\n              h.types.includes(event.type) && h.handlers(event);\n            });\n          }\n        : undefined;\n\n      return combineFunctionsInObject(\n        {\n          [ON_EVENT]: eventHandler,\n        },\n        store,\n      ) as any;\n    }),\n  ) as any;\n}\nexport function broadcast<A extends Event>(\n  store: Record<string | symbol, unknown>,\n  event: A,\n) {\n  if (!store[ON_EVENT]) {\n    throw new Error(\n      'No event handler found, you must add withEventHandler to use broadcast',\n    );\n  }\n  (store[ON_EVENT] as OverridableFunction)(event);\n}\n\nexport interface OnEvent<Creators extends readonly EventCreator[]> {\n  (event: EventType<Creators[number]>): void;\n}\nexport interface EventHandlersTypes<Creators extends readonly EventCreator[]> {\n  handlers: OnEvent<Creators>;\n  types: ExtractEventTypes<Creators>;\n}\ntype ExtractEventTypes<Creators extends readonly EventCreator[]> = {\n  [Key in keyof Creators]: Creators[Key] extends EventCreator<infer T>\n    ? T\n    : never;\n};\nexport function onEvent<\n  // Event creators\n  Creators extends readonly EventCreator[],\n>(\n  ...args: [...creators: Creators, handler: OnEvent<Creators>]\n): EventHandlersTypes<Creators> {\n  const handlers = args.pop() as unknown as OnEvent<Creators>;\n  const types = (args as unknown as Creators).map(\n    (creator) => creator.type,\n  ) as unknown as ExtractEventTypes<Creators>;\n  return { handlers, types };\n}\n","import { SignalStoreFeature, SignalStoreFeatureResult } from '@ngrx/signals';\n\nimport { StoreSource } from './with-feature-factory.model';\n\n/**\n * This store feature allows access to the store's state, methods, computed signals, to store features that don't have a config factory that\n * can access the store. This can be useful for creating store features that need to access the store's state, methods, computed signals, etc. or to wrap store\n * features that don't have a config factory that can access the store.\n * @param featureFactory\n *\n * @example\n * // Use case 1: allow a custome store feature that receives a plain config object to access the store's state, methods, computed signals.\n * function withCustomFeature(config: { fooValue: string }) {\n * ...// create a custom store feature\n * }\n * const Store = signalStore(\n *       withState({ foo: 'foo' }),\n *       // 👇use previous state to configure custom feature\n *       withFeatureFactory(({ foo }) => withCustomFeature({ fooValue: foo() })),\n *       // you can also use a signalStoreFeature inside withFeatureFactory\n *       withFeatureFactory(({ foo }) =>\n *         signalStoreFeature(\n *           withState({ foo2: foo() }),\n *           // ... other store features,\n *         ),\n *       ),\n *     );\n *\n * // Use case 2: use withFeatureFactory inside a custom feature to create a store whose config can be a factory that receives the store\n *   function withCustomFeature2<Input extends SignalStoreFeatureResult>(\n *       configFactory: FeatureConfigFactory<Input, { foo: string }>,\n *     ): SignalStoreFeature<\n *       Input,\n *       {\n *         state: { foo: string };\n *         computed: { bar: Signal<string> };\n *         methods: { baz: () => number };\n *       }\n *     > {\n *       return withFeatureFactory((store: StoreSource<Input>) => {\n *         const config = getFeatureConfig(configFactory, store);\n *         return signalStoreFeature(\n *           withState<{ foo: string }>({ foo: config.fooValue }),\n *           withComputed(({ foo }) => ({ bar: computed(() => foo() + 1) })),\n *           withMethods(({ foo, bar }) => ({\n *             baz: () => foo() + bar() + 2,\n *           })),\n *         );\n *       }) as any;\n *     }\n *\n *     // now withCustomFeature2 can be used like :\n *     const Store = signalStore(\n *       // withCustomFeature2({ fooValue: 'foo' }), // usual way with a plain object\n *       withState({ fooValue: 'foo' }),\n *       // or with a factory that receives the store\n *       withCustomFeature2(({ fooValue }) => ({ fooValue: fooValue() })),\n *     );\n */\nexport function withFeatureFactory<\n  Input extends SignalStoreFeatureResult,\n  Feature extends SignalStoreFeature<any, any>,\n>(\n  featureFactory: (store: StoreSource<Input>) => Feature,\n): SignalStoreFeature<\n  Input & (Feature extends SignalStoreFeature<infer In, any> ? In : never),\n  Feature extends SignalStoreFeature<any, infer Out> ? Out : never\n> {\n  return ((store) => {\n    const { stateSignals, methods, props, hooks, ...rest } = store;\n    return featureFactory({\n      ...stateSignals,\n      ...props,\n      ...methods,\n      ...rest,\n    } as StoreSource<Input>)(store);\n  }) as Feature;\n}\n","import {\n  Prettify,\n  SignalStoreFeature,\n  SignalStoreFeatureResult,\n  StateSignals,\n  WritableStateSource,\n} from '@ngrx/signals';\n\nexport type FeatureConfigFactory<\n  Input extends SignalStoreFeatureResult,\n  Config extends Record<string, any>,\n  FactoryConfig extends Record<string, any> = Config,\n> = Config | ((store: StoreSource<Input>) => FactoryConfig);\n\nexport type StoreSource<Input extends SignalStoreFeatureResult> = Prettify<\n  StateSignals<Input['state']> &\n    Input['props'] &\n    Input['methods'] &\n    WritableStateSource<Input['state']>\n>;\nexport function getFeatureConfig<\n  Input extends SignalStoreFeatureResult,\n  Config extends Record<string, any>,\n>(config: FeatureConfigFactory<Input, Config>, store: StoreSource<Input>) {\n  return typeof config === 'function' ? config(store) : config;\n}\nexport type ExtractStoreFeatureOutput<\n  Result extends (...args: any[]) => SignalStoreFeature<any, any>,\n> =\n  ReturnType<Result> extends SignalStoreFeature<infer In, infer Out>\n    ? In & Out\n    : never;\n","import {\n  Creator,\n  EventCreator,\n  EventCreatorProps,\n  FunctionWithParametersType,\n  NotAllowedCheck,\n  NotAllowedInPropsCheck,\n  TypedEvent,\n} from './with-event-handler.model';\n\n// Event creators taken from ngrx and ts-event library and modified a bit to better\n// fit current ngrx-traits/signals usage. Thank you Ngrx team and Nicholas Jamieson (@cartant).\n\nexport function createEvent<T extends string>(\n  type: T,\n): EventCreator<T, () => TypedEvent<T>>;\nexport function createEvent<T extends string, P extends object>(\n  type: T,\n  config: EventCreatorProps<P> & NotAllowedCheck<P>,\n): EventCreator<T, (props: P & NotAllowedCheck<P>) => P & TypedEvent<T>>;\nexport function createEvent<\n  T extends string,\n  P extends any[],\n  R extends object,\n>(\n  type: T,\n  creator: Creator<P, R & NotAllowedCheck<R>>,\n): FunctionWithParametersType<P, R & TypedEvent<T>> & TypedEvent<T>;\n/**\n * @description\n * Creates a configured `Creator` function that, when called, returns an object in the shape of the `Event` interface.\n *\n * Event creators reduce the explicitness of class-based event creators.\n *\n * @param type Describes the event that will be dispatched\n * @param config Additional metadata needed for the handling of the event.  See {@link createEvent#usage-notes Usage Notes}.\n *\n * @usageNotes\n *\n * **Declaring an event creator**\n *\n * Without additional metadata:\n * ```ts\n * export const increment = createEvent('[Counter] Increment');\n * ```\n * With additional metadata:\n * ```ts\n * export const loginSuccess = createEvent(\n *   '[Auth/API] Login Success',\n *   props<{ user: User }>()\n * );\n * ```\n * With a function:\n * ```ts\n * export const loginSuccess = createEvent(\n *   '[Auth/API] Login Success',\n *   (response: Response) => response.user\n * );\n * ```\n *\n * **Dispatching an event**\n *\n * Without additional metadata:\n * ```ts\n * store.dispatch(increment());\n * ```\n * With additional metadata:\n * ```ts\n * store.dispatch(loginSuccess({ user: newUser }));\n * ```\n *\n * **Referencing an event in a reducer**\n *\n * Using a switch statement:\n * ```ts\n * switch (event.type) {\n *   // ...\n *   case AuthApiEvents.loginSuccess.type: {\n *     return {\n *       ...state,\n *       user: event.user\n *     };\n *   }\n * }\n * ```\n * Using a reducer creator:\n * ```ts\n * on(AuthApiEvents.loginSuccess, (state, { user }) => ({ ...state, user }))\n * ```\n *\n *  **Referencing an event in an effect**\n * ```ts\n * effectName$ = createEffect(\n *   () => this.events$.pipe(\n *     ofType(AuthApiEvents.loginSuccess),\n *     // ...\n *   )\n * );\n * ```\n */\nexport function createEvent<T extends string, C extends Creator>(\n  type: T,\n  config?: { _as: 'props' } | C,\n): EventCreator<T> {\n  if (typeof config === 'function') {\n    return defineType(type, (...args: any[]) => ({\n      ...config(...args),\n      type,\n    }));\n  }\n  const as = config ? config._as : 'empty';\n  switch (as) {\n    case 'empty':\n      return defineType(type, () => ({ type }));\n    case 'props':\n      return defineType(type, (props: object) => ({\n        ...props,\n        type,\n      }));\n    default:\n      throw new Error('Unexpected config.');\n  }\n}\n\nexport function props<\n  P extends SafeProps,\n  SafeProps = NotAllowedInPropsCheck<P>,\n>(): EventCreatorProps<P> {\n  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n  return { _as: 'props', _p: undefined! };\n}\n\nexport function union<\n  C extends { [key: string]: EventCreator<string, Creator> },\n>(creators: C): ReturnType<C[keyof C]> {\n  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n  return undefined!;\n}\n\nfunction defineType<T extends string>(\n  type: T,\n  creator: Creator,\n): EventCreator<T> {\n  return Object.defineProperty(creator, 'type', {\n    value: type,\n    writable: false,\n  }) as EventCreator<T>;\n}\n","import { capitalize } from '../util';\nimport {\n  createEvent,\n  props,\n} from '../with-event-handler/with-event-handler.util';\n\nexport function getWithCallStatusKeys(config?: {\n  prop?: string;\n  collection?: string;\n  supportPrivate?: boolean;\n}) {\n  const isCollection = config?.collection !== undefined;\n  let prop = config?.prop ?? config?.collection;\n  let prefix = '';\n\n  if (config?.supportPrivate && prop?.startsWith('_')) {\n    prop = prop.slice(1);\n    prefix = '_';\n  }\n\n  const capitalizedProp = prop && capitalize(prop);\n\n  return {\n    callStatusKey: prop ? `${prefix}${prop}CallStatus` : `${prefix}callStatus`,\n    loadingKey: prop && isCollection\n      ? `${prefix}is${capitalizedProp}EntitiesLoading`\n      : prop ? `${prefix}is${capitalizedProp}Loading` : `${prefix}isLoading`,\n    loadedKey: prop && isCollection\n      ? `${prefix}is${capitalizedProp}EntitiesLoaded`\n      : prop ? `${prefix}is${capitalizedProp}Loaded` : `${prefix}isLoaded`,\n    errorKey: prop && isCollection\n      ? `${prefix}${prop}EntitiesError`\n      : prop ? `${prefix}${prop}Error` : `${prefix}error`,\n    setLoadingKey: prop && isCollection\n      ? `${prefix}set${capitalizedProp}EntitiesLoading`\n      : prop ? `${prefix}set${capitalizedProp}Loading` : `${prefix}setLoading`,\n    setLoadedKey: prop && isCollection\n      ? `${prefix}set${capitalizedProp}EntitiesLoaded`\n      : prop ? `${prefix}set${capitalizedProp}Loaded` : `${prefix}setLoaded`,\n    setErrorKey: prop && isCollection\n      ? `${prefix}set${capitalizedProp}EntitiesError`\n      : prop ? `${prefix}set${capitalizedProp}Error` : `${prefix}setError`,\n  };\n}\n\nexport function getWithCallStatusEvents(config?: { prop?: string }) {\n  const collection = config?.prop;\n  return {\n    callLoading: createEvent(`${collection}.callLoading`),\n    callLoaded: createEvent(`${collection}.callLoaded`),\n    callError: createEvent(\n      `${collection}.callError`,\n      props<{ error: unknown }>(),\n    ),\n  };\n}\n","import { computed, Signal } from '@angular/core';\nimport {\n  patchState,\n  SignalStoreFeature,\n  signalStoreFeature,\n  SignalStoreFeatureResult,\n  withComputed,\n  withMethods,\n  withState,\n} from '@ngrx/signals';\n\nimport { registerCallState } from '../with-all-call-status/with-all-call-status.util';\nimport {\n  broadcast,\n  withEventHandler,\n} from '../with-event-handler/with-event-handler';\nimport { withFeatureFactory } from '../with-feature-factory/with-feature-factory';\nimport {\n  FeatureConfigFactory,\n  getFeatureConfig,\n  StoreSource,\n} from '../with-feature-factory/with-feature-factory.model';\nimport {\n  CallStatus,\n  CallStatusComputed,\n  CallStatusMethods,\n  CallStatusState,\n  NamedCallStatusComputed,\n  NamedCallStatusMethods,\n  NamedCallStatusState,\n} from './with-call-status.model';\nimport {\n  getWithCallStatusEvents,\n  getWithCallStatusKeys,\n} from './with-call-status.util';\n\n/**\n * Generates necessary state, computed and methods for call progress status to the store\n * @param configFactory - The configuration object for the feature or a factory function that receives the store and returns the configuration object\n * @param configFactory.prop - The name of the property for which this represents the call status\n * @param configFactory.initialValue - The initial value of the call status\n * @param configFactory.collection - The name of the collection for which this represents the call status is an alias to prop param\n * @param configFactory.errorType - The type of the error\n * they do the same thing\n *\n * prop or collection is required\n * @example\n * const store = signalStore(\n *  withCallStatus({ collection: 'user', })\n *  // other valid configurations\n *  // withCallStatus()\n *  // withCallStatus({ collection: 'user', initialValue: 'loading' , errorType: type<string>()})\n *  )\n *\n *  // generates the following signals\n *  store.userEntitiesCallStatus // 'init' | 'loading' | 'loaded' | { error: unknown }\n *  // generates the following computed signals\n *  store.isUserEntitiesLoading // boolean\n *  store.isUserEntitiesLoaded // boolean\n *  store.userEntitiesError // unknown | null\n *  // generates the following methods\n *  store.setUserEntitiesLoading // () => void\n *  store.setUserEntitiesLoaded // () => void\n *  store.setUserEntitiesError // (error?: unknown) => void\n */\n\n// Overload for collection param\nexport function withCallStatus<\n  Input extends SignalStoreFeatureResult,\n  Prop extends string,\n  Error = unknown,\n>(\n  configFactory: FeatureConfigFactory<\n    Input,\n    {\n      collection: Prop;\n      initialValue?: CallStatus;\n      errorType?: Error;\n    }\n  >,\n): SignalStoreFeature<\n  Input & { state: {}; props: {}; methods: {} },\n  {\n    state: NamedCallStatusState<`${Prop}Entities`>;\n    props: NamedCallStatusComputed<`${Prop}Entities`, Error>;\n    methods: NamedCallStatusMethods<`${Prop}Entities`, Error>;\n  }\n>;\n\n// Overload for prop param\nexport function withCallStatus<\n  Input extends SignalStoreFeatureResult,\n  Prop extends string,\n  Error = unknown,\n>(\n  configFactory: FeatureConfigFactory<\n    Input,\n    {\n      prop: Prop;\n      initialValue?: CallStatus;\n      errorType?: Error;\n    }\n  >,\n): SignalStoreFeature<\n  Input & { state: {}; props: {}; methods: {} },\n  {\n    state: NamedCallStatusState<Prop>;\n    props: NamedCallStatusComputed<Prop, Error>;\n    methods: NamedCallStatusMethods<Prop, Error>;\n  }\n>;\n\n// Overload for no params\nexport function withCallStatus<\n  Input extends SignalStoreFeatureResult,\n  Error = unknown,\n>(\n  configFactory?: FeatureConfigFactory<\n    Input,\n    {\n      initialValue?: CallStatus;\n      errorType?: Error;\n    }\n  >,\n): SignalStoreFeature<\n  Input & { state: {}; props: {}; methods: {} },\n  {\n    state: CallStatusState;\n    props: CallStatusComputed<Error>;\n    methods: CallStatusMethods<Error>;\n  }\n>;\n\n// Implementation\nexport function withCallStatus<\n  Input extends SignalStoreFeatureResult,\n  Prop extends string = '',\n  Error = unknown,\n>(\n  configFactory: FeatureConfigFactory<\n    Input,\n    {\n      prop?: Prop;\n      collection?: Prop;\n      initialValue?: CallStatus;\n      errorType?: Error;\n    }\n  > = {},\n): any {\n  return withFeatureFactory((store: StoreSource<Input>) => {\n    const config = getFeatureConfig(configFactory, store);\n\n    const isCollection = 'collection' in config;\n    const prop = 'prop' in config ? config.prop : config.collection;\n    const keysResult = getWithCallStatusKeys({\n      ...(isCollection ? { collection: prop } : { prop }),\n    });\n\n    const {\n      callStatusKey,\n      errorKey,\n      loadedKey,\n      loadingKey,\n      setLoadingKey,\n      setLoadedKey,\n      setErrorKey,\n    } = keysResult as any;\n\n    const { callLoaded, callLoading, callError } = getWithCallStatusEvents({\n      prop,\n    });\n    return signalStoreFeature(\n      withState({ [callStatusKey]: config.initialValue ?? 'init' }),\n      withComputed((state: Record<string, Signal<unknown>>) => {\n        const callState = state[callStatusKey] as Signal<CallStatus>;\n\n        const isLoading = computed(() => {\n          return callState() === 'loading';\n        });\n        const isLoaded = computed(() => callState() === 'loaded');\n        const error = computed(() => {\n          const v = callState();\n          return typeof v === 'object' ? v.error : undefined;\n        });\n        registerCallState(store, { loading: isLoading, error });\n        return {\n          [loadingKey]: isLoading,\n          [loadedKey]: isLoaded,\n          [errorKey]: error,\n        };\n      }),\n      withEventHandler(),\n      withMethods((store) => ({\n        [setLoadingKey]: () => {\n          patchState(store, { [callStatusKey]: 'loading' });\n          broadcast(store, callLoading());\n        },\n        [setLoadedKey]: () => {\n          patchState(store, { [callStatusKey]: 'loaded' });\n          broadcast(store, callLoaded());\n        },\n        [setErrorKey]: (error?: unknown) => {\n          patchState(store, { [callStatusKey]: { error } });\n          broadcast(store, callError({ error }));\n        },\n      })),\n    );\n  }) as any;\n}\n","import { computed, Signal } from '@angular/core';\nimport { Params } from '@angular/router';\nimport {\n  concatMap,\n  debounce,\n  distinctUntilChanged,\n  of,\n  pipe,\n  timer,\n} from 'rxjs';\n\nimport { capitalize } from '../util';\nimport {\n  createEvent,\n  props,\n} from '../with-event-handler/with-event-handler.util';\nimport { QueryMapper } from '../with-sync-to-route-query-params/with-sync-to-route-query-params.util';\nimport { EntitiesRemoteFilterMethods } from './with-entities-remote-filter.model';\n\nexport function getWithEntitiesFilterKeys(config?: { collection?: string }) {\n  const collection = config?.collection;\n  const capitalizedProp = collection && capitalize(collection);\n  return {\n    filterKey: collection\n      ? `${config.collection}EntitiesFilter`\n      : 'entitiesFilter',\n    filterEntitiesKey: collection\n      ? `filter${capitalizedProp}Entities`\n      : 'filterEntities',\n    isEntitiesFilterChangedKey: collection\n      ? `is${capitalizedProp}EntitiesFilterChanged`\n      : 'isEntitiesFilterChanged',\n    resetEntitiesFilterKey: collection\n      ? `reset${capitalizedProp}EntitiesFilter`\n      : 'resetEntitiesFilter',\n    defaultFilterKey: collection\n      ? `_${config.collection}EntitiesDefaultFilter`\n      : '_entitiesDefaultFilter',\n  };\n}\n\nexport function debounceFilterPipe<Filter>(\n  filter: Signal<Filter>,\n  defaultDebounce = 300,\n) {\n  return pipe(\n    debounce(\n      (value: {\n        filter: Filter;\n        debounce?: number;\n        patch?: boolean;\n        forceLoad?: boolean;\n        skipLoadingCall?: boolean;\n        _emitEvent?: boolean;\n      }) =>\n        value?.forceLoad || (value.debounce ?? defaultDebounce) == 0\n          ? of({})\n          : timer(value.debounce ?? defaultDebounce),\n    ),\n    concatMap((payload) =>\n      payload.patch\n        ? of({\n            ...payload,\n            filter: { ...filter?.(), ...payload?.filter },\n          })\n        : of(payload),\n    ),\n    distinctUntilChanged(\n      (previous, current) =>\n        !current?.forceLoad &&\n        !current.skipLoadingCall &&\n        !previous?.skipLoadingCall &&\n        JSON.stringify(previous?.filter) === JSON.stringify(current?.filter),\n    ),\n  );\n}\n\nexport function getWithEntitiesFilterEvents(config?: { collection?: string }) {\n  const collection = config?.collection;\n  return {\n    entitiesFilterChanged: createEvent(\n      `${collection}.entitiesFilterChanged`,\n      props<{ filter: unknown; skipLoadingCall?: boolean }>(),\n    ),\n  };\n}\n\nexport type FilterQueryMapper<Filter, T extends Params = Params> = {\n  /**\n   * @param defaultFilter the filter the store was created with, to fall back on\n   *   for fields the query params do not carry\n   * @param currentFilter the filter the store holds right now, to keep the\n   *   parts of it the query params say nothing about\n   * @returns the filter to apply, or undefined to leave the current one alone\n   */\n  queryParamsToFilter: (\n    query: T,\n    defaultFilter: Filter,\n    currentFilter: Filter,\n  ) => Filter | undefined;\n  filterToQueryParams: (filter: Filter) => T | undefined | null;\n  /**\n   * Merge the restored filter into the current one instead of replacing it,\n   * for mappers that only map some of the filter fields. Defaults to false,\n   * which replaces the whole filter.\n   */\n  patch?: boolean;\n};\n\n/**\n * Normalizes FilterOptions to always return the {filter, debounce?, ...} format.\n * Handles the case where a raw Filter object is passed directly.\n */\nexport function toFilterOptions<Filter extends Record<string, unknown>>(\n  options: Record<string, unknown>,\n  defaultFilter: Filter,\n): {\n  filter: Filter;\n  debounce?: number;\n  patch?: boolean;\n  forceLoad?: boolean;\n  skipLoadingCall?: boolean;\n  _emitEvent?: boolean;\n} {\n  // FilterOptions requires 'filter' key - if missing, it's raw Filter\n  if (!('filter' in options)) {\n    return { filter: options } as any;\n  }\n\n  // filter value can't be null/undefined/primitive in FilterOptions\n  // (Filter extends Record<string, unknown>)\n  const filterValue = options['filter'];\n  if (\n    filterValue === null ||\n    filterValue === undefined ||\n    typeof filterValue !== 'object'\n  ) {\n    return { filter: options } as any;\n  }\n\n  // Check for FilterOptions-specific keys not present in defaultFilter\n  const defaultFilterKeys = new Set(Object.keys(defaultFilter));\n  const specificKeys = [\n    'debounce',\n    'patch',\n    'forceLoad',\n    'skipLoadingCall',\n    '_emitEvent',\n  ];\n  if (specificKeys.some((k) => k in options && !defaultFilterKeys.has(k))) {\n    return options as any; // has debounce/patch/etc → FilterOptions\n  }\n\n  // Check if filter value's keys overlap with defaultFilter keys\n  const filterValueKeys = new Set(\n    Object.keys(filterValue as Record<string, unknown>),\n  );\n  if ([...defaultFilterKeys].some((k) => filterValueKeys.has(k))) {\n    return options as any; // FilterOptions\n  }\n\n  // Default: raw Filter\n  return { filter: options } as any;\n}\n\nexport function getQueryMapperForEntitiesFilter<Filter>(config?: {\n  collection?: string;\n  filterMapper?: FilterQueryMapper<Filter>;\n  skipLoadingCall?: boolean;\n}): QueryMapper<\n  typeof config extends { filterMapper: FilterQueryMapper<infer T> }\n    ? T\n    : { filter: string }\n> {\n  const { filterEntitiesKey, filterKey, defaultFilterKey } =\n    getWithEntitiesFilterKeys(config);\n\n  return {\n    queryParamsToState: (query, store, firstLoad) => {\n      const defaultFilter = (store[defaultFilterKey] as Signal<Filter>)?.();\n      const currentFilter = (store[filterKey] as Signal<Filter>)?.();\n      const filter = config?.filterMapper\n        ? config?.filterMapper.queryParamsToFilter(\n            query,\n            defaultFilter,\n            currentFilter,\n          )\n        : query.filter\n          ? JSON.parse(query.filter)\n          : undefined;\n\n      if (filter) {\n        const filterEntities = store[\n          filterEntitiesKey\n        ] as EntitiesRemoteFilterMethods<any, any>['filterEntities'];\n        filterEntities({\n          filter,\n          // only mappers that ask for it, so the ones that map the whole filter\n          // keep replacing it as they always have\n          patch: config?.filterMapper?.patch,\n          // we forceLoad on first load to ensure filter is set in the store, before fetching data\n          // after that it should not force load, to allow history navigation without triggering loading state\n          forceLoad: firstLoad,\n          // we only allow to skip the loading call on the first load,\n          // otherwise history navigation would not work as expected\n          skipLoadingCall: firstLoad && config?.skipLoadingCall,\n        });\n      }\n    },\n    stateToQueryParams: (store) => {\n      const filter = store[filterKey] as Signal<any>;\n      return filter\n        ? computed(() =>\n            config?.filterMapper\n              ? (config?.filterMapper.filterToQueryParams(filter()) as any)\n              : {\n                  filter: JSON.stringify({ ...filter() }),\n                },\n          )\n        : null;\n    },\n  };\n}\n","import { computed, effect, Signal, untracked } from '@angular/core';\nimport {\n  patchState,\n  signalStoreFeature,\n  SignalStoreFeature,\n  SignalStoreFeatureResult,\n  withComputed,\n  withHooks,\n  withMethods,\n  withState,\n  WritableStateSource,\n} from '@ngrx/signals';\nimport { EntityMap, SelectEntityId } from '@ngrx/signals/entities';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport { map, Observable, pipe, tap } from 'rxjs';\n\nimport { RequireEntities } from '../feature-requirements.model';\nimport { getWithEntitiesKeys } from '../util';\nimport { getWithCallStatusKeys } from '../with-call-status/with-call-status.util';\nimport {\n  broadcast,\n  withEventHandler,\n} from '../with-event-handler/with-event-handler';\nimport { withFeatureFactory } from '../with-feature-factory/with-feature-factory';\nimport {\n  FeatureConfigFactory,\n  getFeatureConfig,\n  StoreSource,\n} from '../with-feature-factory/with-feature-factory.model';\nimport {\n  debounceFilterPipe,\n  getWithEntitiesFilterEvents,\n  getWithEntitiesFilterKeys,\n  toFilterOptions,\n} from './with-entities-filter.util';\nimport {\n  EntitiesFilterComputed,\n  EntitiesFilterMethods,\n  EntitiesFilterState,\n  NamedEntitiesFilterComputed,\n  NamedEntitiesFilterMethods,\n  NamedEntitiesFilterState,\n} from './with-entities-local-filter.model';\n\n/**\n * Generates necessary state, computed and methods for locally filtering entities in the store,\n * the generated filter[Collection]Entities method will filter the entities based on the filter function\n * and is debounced by default.\n *\n * Requires withEntities to be used.\n *\n * @param configFactory - The configuration object for the feature or a factory function that receives the store and returns the configuration object\n * @param configFactory.filterFn - The function that will be used to filter the entities\n * @param configFactory.defaultFilter - The default filter to be used\n * @param configFactory.defaultDebounce - The default debounce time to be used, if not set it will default to 300ms\n * @param configFactory.entity - The entity type to be used\n * @param configFactory.collection - The optional collection name to be used\n * @param configFactory.selectId - The function to use to select the id of the entity\n *\n * @example\n * const entity = type<Product>();\n * const collection = 'product';\n * const store = signalStore(\n *   { providedIn: 'root' },\n *   // requires withEntities to be used\n *   withEntities({ entity, collection }),\n *\n *   withEntitiesLocalFilter({\n *     entity,\n *     collection,\n *     defaultFilter: { search: '' },\n *     filterFn: (entity, filter) =>\n *       !filter?.search || // if there is no search term return all entities\n *       entity?.name.toLowerCase().includes(filter?.search.toLowerCase()),\n *   }),\n *  );\n *\n * // generates the following signals\n *  store.productEntitiesFilter // { search: string }\n *  // generates the following methods\n *  store.filterProductEntities  // (options: { filter: { search: string }, debounce?: number, patch?: boolean, forceLoad?: boolean }) => void\n *  store.resetProductEntitiesFilter  // (options?: { newDefaultFilter?: { search: string } }) => void — resets to defaultFilter or to newDefaultFilter if provided, updating the default for future resets\n */\nexport function withEntitiesLocalFilter<\n  Input extends SignalStoreFeatureResult,\n  Entity,\n  Filter extends Record<string, unknown>,\n  Collection extends string = '',\n>(\n  configFactory: FeatureConfigFactory<\n    Input,\n    {\n      filterFn: (entity: Entity, filter: Filter) => boolean;\n      defaultFilter: Filter;\n      defaultDebounce?: number;\n      entity: Entity;\n      collection?: Collection;\n      selectId?: SelectEntityId<Entity>;\n    }\n  >,\n): SignalStoreFeature<\n  Input & RequireEntities<Input, Entity, Collection, 'withEntitiesLocalFilter'>,\n  Collection extends ''\n    ? {\n        state: EntitiesFilterState<Filter>;\n        props: EntitiesFilterComputed<Filter>;\n        methods: EntitiesFilterMethods<Filter, Entity>;\n      }\n    : {\n        state: NamedEntitiesFilterState<Collection, Filter>;\n        props: NamedEntitiesFilterComputed<Collection, Filter>;\n        methods: NamedEntitiesFilterMethods<Collection, Filter, Entity>;\n      }\n> {\n  return withFeatureFactory((store: StoreSource<Input>) => {\n    const { filterFn, defaultFilter, ...config } = getFeatureConfig(\n      configFactory,\n      store,\n    );\n    const { entityMapKey, idsKey, entitiesKey } = getWithEntitiesKeys(config);\n    const { entitiesFilterChanged } = getWithEntitiesFilterEvents(config);\n    const {\n      filterEntitiesKey,\n      filterKey,\n      defaultFilterKey,\n      resetEntitiesFilterKey,\n      isEntitiesFilterChangedKey,\n    } = getWithEntitiesFilterKeys(config);\n    return signalStoreFeature(\n      withState({\n        [filterKey]: defaultFilter,\n        [defaultFilterKey]: defaultFilter,\n      }),\n      withComputed((state: Record<string, Signal<unknown>>) => {\n        const filter = state[filterKey] as Signal<Filter>;\n        const currentDefault = state[defaultFilterKey] as Signal<Filter>;\n        return {\n          [isEntitiesFilterChangedKey]: computed(() => {\n            return (\n              JSON.stringify(filter()) !== JSON.stringify(currentDefault())\n            );\n          }),\n        };\n      }),\n      withEventHandler(),\n      withMethods((state: Record<string, Signal<unknown>>) => {\n        const filter = state[filterKey] as Signal<Filter>;\n        const entitiesMap = state[entityMapKey] as Signal<EntityMap<Entity>>;\n        const filteredEntities = state[entitiesKey] as Signal<Entity[]>;\n        // we create a computed entities that relies on the entitiesMap instead of\n        // using the computed state.entities from the withEntities , because this local filter is going to replace\n        // the ids array of the state with the filtered ids array, and the state.entities depends on it,\n        // so hour filter function needs the full list of entities always which will be always so we get them from entityMap\n        const entities = computed(() => Object.values(entitiesMap()));\n        const filterEntities = rxMethod<\n          | {\n              filter: Filter;\n              debounce?: number;\n              patch?: boolean;\n              forceLoad?: boolean;\n              _emitEvent?: boolean;\n            }\n          | undefined\n        >(\n          pipe(\n            map((options) =>\n              // if no options are provided, we use the default filter\n              // and forceLoad\n              options\n                ? toFilterOptions(options, defaultFilter)\n                : {\n                    filter: filter(),\n                    debounce: 0,\n                    forceLoad: true,\n                  },\n            ),\n            debounceFilterPipe(filter, config.defaultDebounce),\n            tap((value) => {\n              const newEntities = entities().filter((entity) => {\n                return filterFn(entity, value.filter);\n              });\n              patchState(\n                state as WritableStateSource<any>,\n                {\n                  [filterKey]: value.filter,\n                },\n                {\n                  [idsKey]: newEntities.map((entity) =>\n                    config.selectId\n                      ? config.selectId(entity)\n                      : (entity as any)['id'],\n                  ),\n                },\n              );\n              if (value._emitEvent !== false)\n                broadcast(state, entitiesFilterChanged(value));\n            }),\n          ),\n        );\n        return {\n          [filterEntitiesKey]: (\n            options:\n              | {\n                  filter: Filter;\n                  debounce?: number;\n                  patch?: boolean;\n                  forceLoad?: boolean;\n                  _emitEvent?: boolean;\n                }\n              | undefined,\n          ) => {\n            if (options instanceof Observable || typeof options === 'function')\n              return filterEntities(options);\n            filterEntities(options);\n            return Promise.resolve({ ok: true, value: filteredEntities });\n          },\n          [resetEntitiesFilterKey]: (options?: {\n            newDefaultFilter?: Filter;\n            debounce?: number;\n            forceLoad?: boolean;\n            skipLoadingCall?: boolean;\n          }) => {\n            const newDefault = options?.newDefaultFilter;\n            if (newDefault) {\n              patchState(state as WritableStateSource<any>, {\n                [defaultFilterKey]: newDefault,\n              });\n            }\n            const currentDefault =\n              newDefault ?? (state[defaultFilterKey] as Signal<Filter>)();\n            filterEntities({\n              filter: currentDefault,\n              debounce: options?.debounce,\n              forceLoad: options?.forceLoad,\n            });\n          },\n        };\n      }),\n      withHooks((state: Record<string, unknown>) => {\n        const { loadedKey } = getWithCallStatusKeys({\n          collection: config?.collection,\n        });\n        const loaded = state[loadedKey] as Signal<boolean> | undefined;\n        const filter = state[filterKey] as Signal<Filter>;\n        return {\n          onInit: () => {\n            if (loaded) {\n              const filterEntities = state[filterEntitiesKey] as (options: {\n                filter: Filter;\n                debounce?: number;\n                patch?: boolean;\n                forceLoad?: boolean;\n                _emitEvent?: boolean;\n              }) => void;\n              effect(() => {\n                if (loaded()) {\n                  untracked(() => {\n                    filterEntities({\n                      filter: filter(),\n                      debounce: 0,\n                      forceLoad: true,\n                      _emitEvent: false,\n                    });\n                  });\n                }\n              });\n            }\n          },\n        };\n      }),\n    );\n  }) as any;\n}\n","import { computed, EnvironmentInjector, inject, Signal } from '@angular/core';\nimport { toObservable } from '@angular/core/rxjs-interop';\nimport {\n  patchState,\n  signalStoreFeature,\n  SignalStoreFeature,\n  SignalStoreFeatureResult,\n  withComputed,\n  withMethods,\n  withState,\n  WritableStateSource,\n} from '@ngrx/signals';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport {\n  filter as filterPipe,\n  lastValueFrom,\n  map,\n  Observable,\n  pipe,\n  take,\n  tap,\n} from 'rxjs';\n\nimport {\n  RequireEntities,\n  RequireEntitiesCallStatus,\n} from '../feature-requirements.model';\nimport { getWithEntitiesKeys } from '../util';\nimport { CallStatus } from '../with-call-status/with-call-status.model';\nimport { getWithCallStatusKeys } from '../with-call-status/with-call-status.util';\nimport { Call } from '../with-calls/with-calls.model';\nimport {\n  broadcast,\n  withEventHandler,\n} from '../with-event-handler/with-event-handler';\nimport { withFeatureFactory } from '../with-feature-factory/with-feature-factory';\nimport {\n  FeatureConfigFactory,\n  getFeatureConfig,\n  StoreSource,\n} from '../with-feature-factory/with-feature-factory.model';\nimport {\n  debounceFilterPipe,\n  getWithEntitiesFilterEvents,\n  getWithEntitiesFilterKeys,\n  toFilterOptions,\n} from './with-entities-filter.util';\nimport {\n  EntitiesFilterComputed,\n  EntitiesFilterState,\n  NamedEntitiesFilterComputed,\n  NamedEntitiesFilterState,\n} from './with-entities-local-filter.model';\nimport {\n  EntitiesRemoteFilterMethods,\n  NamedEntitiesRemoteFilterMethods,\n} from './with-entities-remote-filter.model';\n\n/**\n * Generates necessary state, computed and methods for remotely filtering entities in the store,\n * the generated filter[Collection]Entities method will filter the entities by calling set[Collection]Loading()\n * and you should either create an effect that listens to [Collection]Loading can call the api with the [Collection]Filter params\n * or use withEntitiesLoadingCall to call the api with the [Collection]Filter params.\n * filter[Collection]Entities is debounced by default, you can change the debounce by using the debounce option filter[Collection]Entities or changing the defaultDebounce prop in the config.\n *\n * In case you dont want filter[Collection]Entities to call set[Collection]Loading() (which triggers a fetchEntities), you can pass skipLoadingCall: true to filter[Collection]Entities.\n * Useful in cases where you want to further change the state before manually calling set[Collection]Loading() to trigger a fetch of entities.\n *\n * Requires withEntities and withCallStatus to be present before this function.\n * @param configFactory - The configuration object for the feature or a factory function that receives the store and returns the configuration object\n * @param configFactory.defaultFilter - The default filter to be used\n * @param configFactory.defaultDebounce - The default debounce time to be used, if not set it will default to 300ms\n * @param configFactory.entity - The entity type to be used\n * @param configFactory.collection - The optional collection name to be used\n *\n * @example\n * const entity = type<Product>();\n * const collection = 'product';\n * export const store = signalStore(\n *   // requires withEntities and withCallStatus to be used\n *   withEntities({ entity, collection }),\n *   withCallStatus({ collection, initialValue: 'loading' }),\n *\n *   withEntitiesRemoteFilter({\n *     entity,\n *     collection,\n *     defaultFilter: { search: '' },\n *   }),\n *   // after you can use withEntitiesLoadingCall to connect the filter to\n *   // the api call, or do it manually as shown after\n *    withEntitiesLoadingCall({\n *     collection,\n *     fetchEntities: ({ productEntitiesFilter }) => {\n *       return inject(ProductService)\n *         .getProducts({\n *           search: productEntitiesFilter().search,\n *         })\n *     },\n *   }),\n * // withEntitiesLoadingCall is the same as doing the following:\n * // withHooks(({ isProductEntitiesLoading, productEntitiesFilter, setProductEntitiesError, ...state }) => ({\n * //   onInit: async () => {\n * //     effect(() => {\n * //       if (isProductEntitiesLoading()) {\n * //         inject(ProductService)\n * //              .getProducts({\n * //                 search: productEntitiesFilter().search,\n * //               })\n * //           .pipe(\n * //             takeUntilDestroyed(),\n * //             tap((res) =>\n * //               patchState(\n * //                 state,\n * //                 setAllEntities(res.resultList, { collection: 'product' }),\n * //               ),\n * //             ),\n * //             catchError((error) => {\n * //               setProductEntitiesError(error);\n * //               return EMPTY;\n * //             }),\n * //           )\n * //           .subscribe();\n * //       }\n * //     });\n * //   },\n *  })),\n * // generates the following signals\n *  store.productEntitiesFilter // { search: string }\n *  // generates the following methods\n *  store.filterProductEntities  // (options: { filter: { search: string }, debounce?: number, patch?: boolean, forceLoad?: boolean, skipLoadingCall?:boolean }) => void\n *  store.resetProductEntitiesFilter  // (options?: { newDefaultFilter?: { search: string } }) => void — resets to defaultFilter or to newDefaultFilter if provided, updating the default for future resets\n */\nexport function withEntitiesRemoteFilter<\n  Input extends SignalStoreFeatureResult,\n  Entity,\n  Filter extends Record<string, unknown>,\n  Collection extends string = '',\n>(\n  configFactory: FeatureConfigFactory<\n    Input,\n    {\n      defaultFilter: Filter;\n      defaultDebounce?: number;\n      entity: Entity;\n      collection?: Collection;\n    }\n  >,\n): SignalStoreFeature<\n  Input &\n    RequireEntities<Input, Entity, Collection, 'withEntitiesRemoteFilter'> &\n    RequireEntitiesCallStatus<Input, Collection, 'withEntitiesRemoteFilter'>,\n  Collection extends ''\n    ? {\n        state: EntitiesFilterState<Filter>;\n        props: EntitiesFilterComputed<Filter>;\n        methods: EntitiesRemoteFilterMethods<Filter, Entity>;\n      }\n    : {\n        state: NamedEntitiesFilterState<Collection, Filter>;\n        props: NamedEntitiesFilterComputed<Collection, Filter>;\n        methods: NamedEntitiesRemoteFilterMethods<Collection, Filter, Entity>;\n      }\n> {\n  return withFeatureFactory((store: StoreSource<Input>) => {\n    const { defaultFilter, ...config } = getFeatureConfig(configFactory, store);\n    const { setLoadingKey, callStatusKey, errorKey } = getWithCallStatusKeys({\n      collection: config.collection,\n    });\n    const { entitiesKey } = getWithEntitiesKeys(config);\n    const {\n      filterKey,\n      defaultFilterKey,\n      filterEntitiesKey,\n      resetEntitiesFilterKey,\n      isEntitiesFilterChangedKey,\n    } = getWithEntitiesFilterKeys(config);\n    const { entitiesFilterChanged } = getWithEntitiesFilterEvents(config);\n\n    return signalStoreFeature(\n      withState({\n        [filterKey]: defaultFilter,\n        [defaultFilterKey]: defaultFilter,\n      }),\n      withComputed((state: Record<string, Signal<unknown>>) => {\n        const filter = state[filterKey] as Signal<Filter>;\n        const currentDefault = state[defaultFilterKey] as Signal<Filter>;\n        return {\n          [isEntitiesFilterChangedKey]: computed(() => {\n            return (\n              JSON.stringify(filter()) !== JSON.stringify(currentDefault())\n            );\n          }),\n        };\n      }),\n      withEventHandler(),\n      withMethods(\n        (\n          state: Record<string, Signal<unknown>>,\n          environmentInjector = inject(EnvironmentInjector),\n        ) => {\n          const setLoading = state[setLoadingKey] as () => void;\n          const filter = state[filterKey] as Signal<Filter>;\n          const entities = state[entitiesKey] as Signal<Entity[]>;\n          const callState = state[callStatusKey] as Signal<CallStatus>;\n          const error = state[errorKey] as Signal<unknown>;\n\n          const filterEntities = rxMethod<\n            | {\n                filter: Filter;\n                debounce?: number;\n                patch?: boolean;\n                forceLoad?: boolean;\n                skipLoadingCall?: boolean;\n                _emitEvent?: boolean;\n              }\n            | undefined\n          >(\n            pipe(\n              map((options) =>\n                // if no options are provided, we use the default filter\n                // and forceLoad\n                options\n                  ? toFilterOptions(options, defaultFilter)\n                  : {\n                      filter: filter(),\n                      debounce: config.defaultDebounce,\n                      forceLoad: true,\n                    },\n              ),\n              debounceFilterPipe(filter, config.defaultDebounce),\n              tap((value) => {\n                patchState(state as WritableStateSource<any>, {\n                  [filterKey]: value.filter,\n                });\n                if (value._emitEvent !== false)\n                  broadcast(state, entitiesFilterChanged(value));\n                if (!value?.skipLoadingCall) setLoading();\n              }),\n            ),\n          );\n          return {\n            [filterEntitiesKey]: (\n              options:\n                | {\n                    filter: Filter;\n                    debounce?: number;\n                    patch?: boolean;\n                    forceLoad?: boolean;\n                    skipLoadingCall?: boolean;\n                  }\n                | undefined,\n            ) => {\n              if (\n                options instanceof Observable ||\n                typeof options === 'function'\n              ) {\n                return filterEntities(options);\n              }\n              filterEntities(options);\n\n              const resultPromise = lastValueFrom(\n                toObservable(callState, { injector: environmentInjector }).pipe(\n                  filterPipe((v) => v === 'loaded' || typeof v === 'object'),\n                  take(1),\n                  map((v) =>\n                    v === 'loaded'\n                      ? { value: entities, ok: true }\n                      : { error: error, ok: false },\n                  ),\n                ),\n              );\n              // see withCalls: keep a no-op handler attached so a promise the\n              // caller ignores cannot surface as an unhandled rejection\n              resultPromise.catch(() => {});\n              return resultPromise;\n            },\n            [resetEntitiesFilterKey]: (options?: {\n              newDefaultFilter?: Filter;\n              debounce?: number;\n              forceLoad?: boolean;\n              skipLoadingCall?: boolean;\n            }) => {\n              const newDefault = options?.newDefaultFilter;\n              if (newDefault) {\n                patchState(state as WritableStateSource<any>, {\n                  [defaultFilterKey]: newDefault,\n                });\n              }\n              const currentDefault =\n                newDefault ?? (state[defaultFilterKey] as Signal<Filter>)();\n              filterEntities({\n                filter: currentDefault,\n                debounce: options?.debounce,\n                forceLoad: options?.forceLoad,\n                skipLoadingCall: options?.skipLoadingCall,\n              });\n            },\n          };\n        },\n      ),\n    );\n  }) as any;\n}\n","import {\n  computed,\n  effect,\n  EnvironmentInjector,\n  inject,\n  Signal,\n  untracked,\n} from '@angular/core';\nimport { toObservable } from '@angular/core/rxjs-interop';\nimport {\n  patchState,\n  signalStoreFeature,\n  SignalStoreFeature,\n  SignalStoreFeatureResult,\n  withComputed,\n  withHooks,\n  withMethods,\n  withState,\n  WritableStateSource,\n} from '@ngrx/signals';\nimport { EntityMap, SelectEntityId } from '@ngrx/signals/entities';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport {\n  filter as filterPipe,\n  lastValueFrom,\n  map,\n  Observable,\n  pipe,\n  take,\n  tap,\n} from 'rxjs';\n\nimport {\n  RequireEntities,\n  RequireEntitiesCallStatus,\n} from '../feature-requirements.model';\nimport { getWithEntitiesKeys, insertIf } from '../util';\nimport { CallStatus } from '../with-call-status/with-call-status.model';\nimport { getWithCallStatusKeys } from '../with-call-status/with-call-status.util';\nimport {\n  broadcast,\n  withEventHandler,\n} from '../with-event-handler/with-event-handler';\nimport { withFeatureFactory } from '../with-feature-factory/with-feature-factory';\nimport {\n  FeatureConfigFactory,\n  getFeatureConfig,\n  StoreSource,\n} from '../with-feature-factory/with-feature-factory.model';\nimport {\n  debounceFilterPipe,\n  getWithEntitiesFilterEvents,\n  getWithEntitiesFilterKeys,\n  toFilterOptions,\n} from './with-entities-filter.util';\nimport {\n  EntitiesFilterComputed,\n  EntitiesFilterState,\n  NamedEntitiesFilterComputed,\n  NamedEntitiesFilterState,\n} from './with-entities-local-filter.model';\nimport {\n  EntitiesRemoteFilterMethods,\n  NamedEntitiesRemoteFilterMethods,\n} from './with-entities-remote-filter.model';\n\n/**\n * Generates necessary state and methods to do remote and local filtering of entities in the store,\n * the generated filter[Collection]Entities method will filter the entities by calling set[Collection]Loading() if the isRemoteFilter returns true\n * and if false will call the filterFn to filter the entities locally.\n *\n * For the remote case you should either create an effect that listens to [Collection]Loading can call the api with the [Collection]Filter params\n * or use withEntitiesLoadingCall to call the api with the [Collection]Filter params. filter[Collection]Entities\n * is debounced by default, you can change the debounce by using the debounce option filter[Collection]Entities or changing the defaultDebounce prop in the config.\n *\n * In case you dont want filter[Collection]Entities to call set[Collection]Loading() (which triggers a fetchEntities), you can pass skipLoadingCall: true to filter[Collection]Entities.\n * Useful in cases where you want to further change the state before manually calling set[Collection]Loading() to trigger a fetch of entities.\n *\n * Requires withEntities and withCallStatus to be present before this function.\n * @param configFactory - The configuration object for the feature or a factory function that receives the store and returns the configuration object\n * @param configFactory.defaultFilter - The default filter to be used\n * @param configFactory.defaultDebounce - The default debounce time to be used, if not set it will default to 300ms\n * @param configFactory.filterFn - The function to filter the entities\n * @param configFactory.isRemoteFilter - The function to determine if the filter is remote or local\n * @param configFactory.entity - The entity type to be used\n * @param configFactory.collection - The optional collection name to be used\n * @param configFactory.selectId - The optional function to select the id of the entity\n *\n * @example\n * const entity = type<Product>();\n * const collection = 'product';\n * export const store = signalStore(\n *   { providedIn: 'root' },\n *   // requires withEntities and withCallStatus to be used\n *   withEntities({ entity, collection }),\n *   withCallStatus({ collection, initialValue: 'loading' }),\n *   withEntitiesHybridFilter({\n *     entity,\n *     collection,\n *     defaultFilter: { search: '' , category: ''},\n *     filterFn: (entity, filter) =>\n *        (!filter.search || entity.name.toLowerCase().includes(filter.search.toLowerCase()))\n *     // in this case the filter will call setProductEntitiesLoading() if the category changes, othewise\n *     // it will filter the entities locally using filterFn\n *     isRemoteFilter: (previous, current) => {\n *          return previous.category !== current.category;\n *     }\n *   }),\n *   // after you can use withEntitiesLoadingCall to connect the filter to\n *   // the api call, or do it manually as shown after\n *    withEntitiesLoadingCall({\n *     collection,\n *     fetchEntities: ({ productEntitiesFilter }) => {\n *       return inject(ProductService)\n *         .getProducts({\n *           category: productEntitiesFilter().category,\n *         })\n *     },\n *   }),\n * // withEntitiesLoadingCall is the same as doing the following:\n * // withHooks(({ productEntitiesCallStatus, setProductEntitiesError, ...state }) => ({\n * //   onInit: async () => {\n * //     effect(() => {\n * //       if (isProductEntitiesLoading()) {\n * //         inject(ProductService)\n * //              .getProducts({\n * //                  category: productEntitiesFilter().category,\n * //               })\n * //           .pipe(\n * //             takeUntilDestroyed(),\n * //             tap((res) =>\n * //               patchState(\n * //                 state,\n * //                 setAllEntities(res.resultList, { collection: 'product' }),\n * //               ),\n * //             ),\n * //             catchError((error) => {\n * //               setProductEntitiesError(error);\n * //               return EMPTY;\n * //             }),\n * //           )\n * //           .subscribe();\n * //       }\n * //     });\n * //   },\n *  })),\n * // generates the following signals\n *  store.productEntitiesFilter // { search: string , category: string }\n *  // generates the following methods\n *  store.filterProductEntities  // (options: { filter: { search: string, category: string }, debounce?: number, patch?: boolean, forceLoad?: boolean, skipLoadingCall?:boolean }) => void\n *  store.resetProductEntitiesFilter  // (options?: { newDefaultFilter?: { search: string, category: string } }) => void — resets to defaultFilter or to newDefaultFilter if provided, updating the default for future resets\n */\nexport function withEntitiesHybridFilter<\n  Input extends SignalStoreFeatureResult,\n  Entity,\n  Filter extends Record<string, unknown>,\n  Collection extends string = '',\n>(\n  configFactory: FeatureConfigFactory<\n    Input,\n    {\n      defaultFilter: Filter;\n      defaultDebounce?: number;\n      entity: Entity;\n      collection?: Collection;\n      selectId?: SelectEntityId<Entity>;\n      filterFn: (entity: NoInfer<Entity>, filter: NoInfer<Filter>) => boolean;\n      isRemoteFilter: (\n        previous: NoInfer<Filter>,\n        current: NoInfer<Filter>,\n      ) => boolean;\n    }\n  >,\n): SignalStoreFeature<\n  Input &\n    RequireEntities<Input, Entity, Collection, 'withEntitiesHybridFilter'> &\n    RequireEntitiesCallStatus<Input, Collection, 'withEntitiesHybridFilter'>,\n  Collection extends ''\n    ? {\n        state: EntitiesFilterState<Filter>;\n        props: EntitiesFilterComputed<Filter>;\n        methods: EntitiesRemoteFilterMethods<Filter, Entity>;\n      }\n    : {\n        state: NamedEntitiesFilterState<Collection, Filter>;\n        props: NamedEntitiesFilterComputed<Collection, Filter>;\n        methods: NamedEntitiesRemoteFilterMethods<Collection, Filter, Entity>;\n      }\n> {\n  return withFeatureFactory((store: StoreSource<Input>) => {\n    const { defaultFilter, ...config } = getFeatureConfig(configFactory, store);\n    const filterFn = config.filterFn;\n    const { entityMapKey, idsKey, entitiesKey } = getWithEntitiesKeys(config);\n    const { setLoadingKey, loadedKey, callStatusKey, errorKey } =\n      getWithCallStatusKeys({\n        collection: config.collection,\n      });\n    const {\n      filterKey,\n      defaultFilterKey,\n      filterEntitiesKey,\n      resetEntitiesFilterKey,\n      isEntitiesFilterChangedKey,\n    } = getWithEntitiesFilterKeys(config);\n    const { entitiesFilterChanged } = getWithEntitiesFilterEvents(config);\n\n    return signalStoreFeature(\n      withState({\n        [filterKey]: defaultFilter,\n        [defaultFilterKey]: defaultFilter,\n      }),\n      withComputed((state: Record<string, Signal<unknown>>) => {\n        const filter = state[filterKey] as Signal<Filter>;\n        const currentDefault = state[defaultFilterKey] as Signal<Filter>;\n        return {\n          [isEntitiesFilterChangedKey]: computed(() => {\n            return (\n              JSON.stringify(filter()) !== JSON.stringify(currentDefault())\n            );\n          }),\n        };\n      }),\n      withEventHandler(),\n      withMethods(\n        (\n          state: Record<string, Signal<unknown>>,\n          environmentInjector = inject(EnvironmentInjector),\n        ) => {\n          const setLoading = state[setLoadingKey] as () => void;\n          const isLoaded = state[loadedKey] as Signal<boolean>;\n          const filter = state[filterKey] as Signal<Filter>;\n          const entitiesMap = state[entityMapKey] as Signal<EntityMap<Entity>>;\n          const filteredEntities = state[entitiesKey] as Signal<Entity[]>;\n          const callState = state[callStatusKey] as Signal<CallStatus>;\n          const error = state[errorKey] as Signal<unknown>;\n          // we create a computed entities that relies on the entitiesMap instead of\n          // using the computed state.entities from the withEntities , because this local filter is going to replace\n          // the ids array of the state with the filtered ids array, and the state.entities depends on it,\n          // so hour filter function needs the full list of entities always which will be always so we get them from entityMap\n          const entities = computed(() => Object.values(entitiesMap()));\n          const filterEntities = rxMethod<\n            | {\n                filter: Filter;\n                debounce?: number;\n                patch?: boolean;\n                forceLoad?: boolean;\n                skipLoadingCall?: boolean;\n                _emitEvent?: boolean;\n              }\n            | undefined\n          >(\n            pipe(\n              map((options) =>\n                // if no options are provided, we use the default filter\n                // and forceLoad\n                options\n                  ? toFilterOptions(options, defaultFilter)\n                  : {\n                      filter: filter(),\n                      debounce: config.defaultDebounce,\n                      forceLoad: true,\n                    },\n              ),\n              debounceFilterPipe(filter, config.defaultDebounce),\n              tap((value) => {\n                const isRemote =\n                  config.isRemoteFilter(value.filter, filter()) || !isLoaded();\n\n                patchState(state as WritableStateSource<any>, {\n                  [filterKey]: value.filter,\n                });\n                if (!isRemote || value?.forceLoad) {\n                  const newEntities = entities().filter((entity) => {\n                    return filterFn(entity, value.filter);\n                  });\n                  patchState(state as WritableStateSource<any>, {\n                    [idsKey]: newEntities.map((entity) =>\n                      config.selectId\n                        ? config.selectId(entity)\n                        : (entity as any)['id'],\n                    ),\n                  });\n                }\n                if (value._emitEvent !== false)\n                  broadcast(state, entitiesFilterChanged(value));\n                if (isRemote && !value?.skipLoadingCall) setLoading?.();\n              }),\n            ),\n          );\n          return {\n            [filterEntitiesKey]: (\n              options:\n                | {\n                    filter: Filter;\n                    debounce?: number;\n                    patch?: boolean;\n                    forceLoad?: boolean;\n                    skipLoadingCall?: boolean;\n                  }\n                | undefined,\n            ) => {\n              if (\n                options instanceof Observable ||\n                typeof options === 'function'\n              ) {\n                return filterEntities(options);\n              }\n              filterEntities(options);\n\n              const resultPromise = lastValueFrom(\n                toObservable(callState, { injector: environmentInjector }).pipe(\n                  filterPipe((v) => v === 'loaded' || typeof v === 'object'),\n                  take(1),\n                  map((v) =>\n                    v === 'loaded'\n                      ? { value: filteredEntities, ok: true }\n                      : { error: error, ok: false },\n                  ),\n                ),\n              );\n              // see withCalls: keep a no-op handler attached so a promise the\n              // caller ignores cannot surface as an unhandled rejection\n              resultPromise.catch(() => {});\n              return resultPromise;\n            },\n            [resetEntitiesFilterKey]: (options?: {\n              newDefaultFilter?: Filter;\n              debounce?: number;\n              forceLoad?: boolean;\n              skipLoadingCall?: boolean;\n            }) => {\n              const newDefault = options?.newDefaultFilter;\n              if (newDefault) {\n                patchState(state as WritableStateSource<any>, {\n                  [defaultFilterKey]: newDefault,\n                });\n              }\n              const currentDefault =\n                newDefault ?? (state[defaultFilterKey] as Signal<Filter>)();\n              filterEntities({\n                filter: currentDefault,\n                debounce: options?.debounce,\n                forceLoad: options?.forceLoad,\n                skipLoadingCall: options?.skipLoadingCall,\n              });\n            },\n          };\n        },\n      ),\n      withHooks((state: Record<string, unknown>) => {\n        const { loadedKey } = getWithCallStatusKeys({\n          collection: config?.collection,\n        });\n        const loaded = state[loadedKey] as Signal<boolean>;\n        const filter = state[filterKey] as Signal<Filter>;\n        return {\n          onInit: () => {\n            const filterEntities = state[filterEntitiesKey] as (options: {\n              filter: Filter;\n              debounce?: number;\n              patch?: boolean;\n              forceLoad?: boolean;\n              skipLoadingCall?: boolean;\n            }) => void;\n            effect(() => {\n              if (loaded()) {\n                untracked(() => {\n                  filterEntities({\n                    filter: filter(),\n                    debounce: 0,\n                    forceLoad: true,\n                    skipLoadingCall: true,\n                  });\n                });\n              }\n            });\n          },\n        };\n      }),\n    );\n  }) as any;\n}\n","/**\n * Shallow, order-sensitive array equality: same length and every element\n * equal by `Object.is`. Use it when the source produces a fresh array on\n * every read (e.g. a `computed` mapping ids), so syncs are only triggered by\n * real changes.\n */\nexport function equalArray(a: unknown, b: unknown): boolean {\n  if (Object.is(a, b)) return true;\n  if (!Array.isArray(a) || !Array.isArray(b)) return false;\n  return a.length === b.length && a.every((v, i) => Object.is(v, b[i]));\n}\n\n/**\n * Order-insensitive array equality, with set semantics: same elements\n * regardless of position. The size check guards against duplicates making\n * unequal arrays match, but the same values with different duplicate counts\n * (e.g. [x,x,y] vs [x,y,y]) still compare equal — on purpose, this is meant\n * for sources that hold a set, like an entity selection.\n */\nexport function equalSet(a: unknown, b: unknown): boolean {\n  if (Object.is(a, b)) return true;\n  if (!Array.isArray(a) || !Array.isArray(b)) return false;\n  if (a.length !== b.length) return false;\n  const aSet = new Set(a);\n  const bSet = new Set(b);\n  return aSet.size === bSet.size && a.every((v) => bSet.has(v));\n}\n\n/**\n * Structural equality by `JSON.stringify` of both values, for objects and\n * arrays alike. Key order matters (`{a,b}` and `{b,a}` are not equal) and\n * values JSON can not represent are lost, so prefer `'array'` for arrays of\n * primitives; this is the catch-all for nested objects.\n */\nexport function equalStringify(a: unknown, b: unknown): boolean {\n  if (Object.is(a, b)) return true;\n  return JSON.stringify(a) === JSON.stringify(b);\n}\n\n/**\n * Equality by a single property, for values identified by an id: compares\n * `a[key]` and `b[key]` with `Object.is`. On arrays it compares element by\n * element by that same key, in order — an array of entities is equal when it\n * holds the same ids in the same positions, whatever else changed in them\n * (this is what the 'array.<prop>' name resolves to).\n *\n * Non-object values (including a null on one side only) fall back to\n * `Object.is`, so an optional value is handled.\n */\nexport function equalByKey(key: string): (a: unknown, b: unknown) => boolean {\n  return (a, b) => {\n    if (Object.is(a, b)) return true;\n    if (Array.isArray(a) || Array.isArray(b)) {\n      if (!Array.isArray(a) || !Array.isArray(b)) return false;\n      return (\n        a.length === b.length && a.every((v, i) => equalOneByKey(key, v, b[i]))\n      );\n    }\n    return equalOneByKey(key, a, b);\n  };\n}\n\n/**\n * Order-insensitive version of `equalByKey` for arrays: the same key values\n * regardless of position, with the set semantics of `equalSet` (this is what\n * the 'set.<prop>' name resolves to).\n */\nexport function equalSetBy(key: string): (a: unknown, b: unknown) => boolean {\n  return (a, b) => {\n    if (Object.is(a, b)) return true;\n    if (!Array.isArray(a) || !Array.isArray(b)) return false;\n    return equalSet(\n      a.map((v) => keyOf(key, v)),\n      b.map((v) => keyOf(key, v)),\n    );\n  };\n}\n\nfunction keyOf(key: string, value: unknown): unknown {\n  return typeof value === 'object' && value\n    ? (value as Record<string, unknown>)[key]\n    : value;\n}\n\nfunction equalOneByKey(key: string, a: unknown, b: unknown): boolean {\n  if (Object.is(a, b)) return true;\n  if (typeof a !== 'object' || typeof b !== 'object' || !a || !b) return false;\n  return Object.is(keyOf(key, a), keyOf(key, b));\n}\n\n/**\n * The default comparison, chosen from the values at hand rather than fixed up\n * front: `Object.is` for primitives, element by element for arrays, and\n * structural for plain objects.\n *\n * A link is a two-way binding, so reference equality is the wrong default for\n * anything but a primitive: a `readFrom` that rebuilds an object out of the\n * state it reads (picking a few props off a bigger one) produces a fresh\n * reference every run, is never equal to its own previous value, and every\n * write it makes re-triggers the read — the link never settles. Comparing by\n * content is what stops that, so it is what happens unless a comparison is\n * asked for by name. Pass `'reference'` to get `Object.is` back.\n *\n * Arrays are compared with `equalArray` and never serialized, so a list stays\n * cheap however long it is — an array whose elements are rebuilt on every\n * read is the one shape this does not settle on its own, and wants an\n * explicit `equal` ('stringify', or 'array.<prop>' to compare by id).\n *\n * Structural comparison is JSON-based, with the caveats of `equalStringify`,\n * and only applies to plain objects: a `Date`, `Map`, `Set` or class instance\n * falls back to `Object.is`, since JSON flattens those to a shape that would\n * call two different values equal and silently drop an update.\n *\n * That check is on the value itself, not on what it contains — one of those\n * nested inside a plain object is still flattened, and two different ones\n * compare equal. Non-serializable values in store state are discouraged for\n * other reasons too; a link over one wants an `equal` of its own.\n */\nexport function equalAuto(a: unknown, b: unknown): boolean {\n  if (Object.is(a, b)) return true;\n  if (Array.isArray(a) || Array.isArray(b)) {\n    if (!Array.isArray(a) || !Array.isArray(b)) return false;\n    return equalArray(a, b);\n  }\n  if (!isPlainObject(a) || !isPlainObject(b)) return false;\n  return safeEqualStringify(a, b);\n}\n\n/** An object literal, as opposed to a Date, Map, Set or class instance. */\nfunction isPlainObject(value: unknown): boolean {\n  if (typeof value !== 'object' || !value) return false;\n  const prototype = Object.getPrototypeOf(value);\n  return prototype === Object.prototype || prototype === null;\n}\n\n/**\n * `equalStringify` for the default comparison, where a value JSON can not\n * serialize at all (a cycle, a BigInt) must degrade to \"not equal\" rather\n * than throw out of whatever read or write is in flight.\n */\nfunction safeEqualStringify(a: unknown, b: unknown): boolean {\n  try {\n    return equalStringify(a, b);\n  } catch {\n    return false;\n  }\n}\n\n/** Properties of `T`, when it is an object that is not an array. */\ntype PropertyName<T> = T extends readonly any[]\n  ? never\n  : T extends object\n    ? keyof NonNullable<T> & string\n    : never;\n\n/**\n * Properties of the elements of `T`, prefixed with the comparison to run over\n * the array: 'array.id' compares element by element in order, 'set.id'\n * compares the ids regardless of order.\n */\ntype ElementPropertyName<T> = T extends readonly (infer E)[]\n  ? E extends object\n    ?\n        | `array.${keyof NonNullable<E> & string}`\n        | `set.${keyof NonNullable<E> & string}`\n    : never\n  : never;\n\n/**\n * Premade equality names accepted wherever a custom `equal` can be given:\n * - 'reference': `Object.is`, the escape hatch from the content-based default\n * - 'array': shallow, order-sensitive element comparison\n * - 'set': order-insensitive element comparison, for selections\n * - 'stringify': structural comparison via JSON.stringify\n * - a property name of the value, e.g. 'id': comparison by that property\n * - 'array.<prop>' / 'set.<prop>' on an array of objects: comparison of the\n *   elements by that property, in order or as a set\n *\n * The array ones are only offered when the value is an array, the property\n * names when it is an object, the prefixed ones when it is an array of them.\n *\n * `unknown extends T` short-circuits all of that while `T` is still\n * unresolved, which is the case on the `computation` form of `withLink`: the\n * value type comes from a context-sensitive callback, typed only on a later\n * inference pass, while `equal` is a plain string checked on the first one.\n * Narrowing against the empty `T` of that first pass pins it to `unknown` for\n * good — the value type collapses and every name is rejected. Accepting any\n * name there costs nothing: `T` is known by the time the argument is checked,\n * so a wrong name or one that does not fit the value is still an error.\n */\nexport type EqualName<T> = unknown extends T\n  ? string\n  :\n      | 'stringify'\n      | 'reference'\n      | (T extends readonly any[] ? 'array' | 'set' : never)\n      | PropertyName<T>\n      | ElementPropertyName<T>;\n\n/** A custom equality function, or the name of a premade one. */\nexport type EqualOption<T> = ((a: T, b: T) => boolean) | EqualName<T>;\n\nconst equals: Record<string, (a: unknown, b: unknown) => boolean> = {\n  array: equalArray,\n  set: equalSet,\n  stringify: equalStringify,\n  reference: Object.is,\n};\n\n/**\n * Resolves an `equal` option to a function, defaulting to `equalAuto`, which\n * compares by content rather than by reference — pass `'reference'` for\n * `Object.is`.\n *\n * A name that is not one of the premade comparisons is a property name,\n * optionally prefixed with 'array.' or 'set.', so those four win over a\n * property called 'array', 'set', 'stringify' or 'reference' — pass\n * `equalByKey('stringify')` for one of those.\n */\nexport function resolveEqual<T>(\n  equal?: EqualOption<T>,\n): (a: T, b: T) => boolean {\n  if (!equal) return equalAuto;\n  if (typeof equal !== 'string') return equal;\n  // an own-property check, not a plain lookup: `equals` inherits\n  // Object.prototype, so a property named 'toString' or 'constructor' would\n  // otherwise resolve to a prototype member instead of falling through to a\n  // comparison by that property — one that reports every value equal, and so\n  // drops every write\n  const premade =\n    (Object.hasOwn(equals, equal) ? equals[equal] : undefined) ??\n    (equal.startsWith('array.')\n      ? equalByKey(equal.slice('array.'.length))\n      : equal.startsWith('set.')\n        ? equalSetBy(equal.slice('set.'.length))\n        : equalByKey(equal));\n  return premade as (a: T, b: T) => boolean;\n}\n","import {\n  computed,\n  effect,\n  EffectRef,\n  Injector,\n  isSignal,\n  linkedSignal,\n  Signal,\n  untracked,\n  WritableSignal,\n} from '@angular/core';\nimport { SIGNAL } from '@angular/core/primitives/signals';\nimport {\n  patchState,\n  signalMethod,\n  SignalStoreFeature,\n  signalStoreFeature,\n  SignalStoreFeatureResult,\n  withMethods,\n} from '@ngrx/signals';\n\nimport { capitalize } from '../util';\nimport { withFeatureFactory } from '../with-feature-factory/with-feature-factory';\nimport { StoreSource } from '../with-feature-factory/with-feature-factory.model';\nimport { EqualOption, resolveEqual } from './with-link.util';\n\ntype LinkCommonOptions<T> = {\n  /**\n   * Gates which writes reach the store. When provided, the returned signal\n   * becomes a `linkedSignal` buffer over the source: writes are kept locally\n   * and only pushed to the store when `updateStoreWhen(value)` returns true.\n   *\n   * It runs inside an effect, so it is reactive: a value held back while it\n   * returned false is pushed as soon as its dependencies make it true\n   * (e.g. a form becoming valid).\n   *\n   * Requires an injection context, since an effect is created.\n   */\n  updateStoreWhen?: (value: T) => boolean;\n};\n\n/**\n * Options of the generated `link<Name>()` method.\n *\n * `syncWith` is mutually exclusive with `readFrom`/`writeTo`: use `syncWith`\n * when the external signal already matches the store type, or the\n * `readFrom` + `writeTo` pair when each direction needs its own mapping.\n */\nexport type LinkOptions<T = any> =\n  | (LinkCommonOptions<T> & {\n      /**\n       * External signal kept in sync with the store both ways: writing it\n       * updates the store, and store changes are written back to it.\n       * Requires a WritableSignal (e.g. `model()`).\n       */\n      syncWith: WritableSignal<T>;\n      readFrom?: never;\n      writeTo?: never;\n      /**\n       * Where the value that wins on link comes from.\n       * - 'external' (default): the signal's current value is pushed to the store.\n       * - 'store': the store value is written to the signal.\n       */\n      initialValueFrom?: 'store' | 'external';\n    })\n  | (LinkCommonOptions<T> & {\n      /**\n       * External signal the store only reads from: its value is pushed to the\n       * store, and store changes are never written back. Accepts any signal,\n       * including a writable one whose writes you drive yourself\n       * (e.g. a `model()` only written on a button click), or a `computed`\n       * that maps an external model to the store type.\n       *\n       * Also accepts a function that receives the previous linked value (the\n       * store value, or the buffer when `updateStoreWhen` is used) so a partial\n       * external signal can be merged into it, e.g.\n       * `(prev) => ({ ...prev, search: this.search() })`. The signals it\n       * reads are tracked; the previous value is not, so store changes alone\n       * do not re-run it.\n       */\n      readFrom?: Signal<T> | ((prev: T) => T);\n      /**\n       * Where store changes are pushed: a WritableSignal that is set, or a\n       * function called with the new value — use it to map back to an\n       * external model's type, or to emit an output. Only changes after link\n       * are pushed, the value at link time is not.\n       *\n       * Combine with `readFrom` for a two-way sync with a mapping in each\n       * direction. Cannot be combined with `syncWith`.\n       */\n      writeTo?: WritableSignal<T> | ((value: T) => void);\n      syncWith?: never;\n      initialValueFrom?: never;\n    });\n\n/** The `link<Name>()` method generated by `withLink`. */\nexport type LinkMethod<T> = (options?: LinkOptions<T>) => WritableSignal<T>;\n\n/**\n * The `_set<Name>()` method generated by `withLink`, the same write path the\n * linked signal uses (the `set` callback, or `patchState` by default),\n * exposed as a store method. The `_` prefix makes it private to the store, so\n * other features and methods can write through it, but consumers cannot.\n *\n * Like the setters of `withStateSetter`, it is a `signalMethod`: it accepts a\n * plain value, a signal/reactive fn (keeping the store in sync with it), or an\n * updater `(current) => next` receiving the current value, for partial updates.\n */\nexport type LinkSetter<T> = ((\n  input: T | (() => T) | ((current: T) => T),\n  config?: { injector?: Injector },\n) => EffectRef) &\n  EffectRef;\n\n/**\n * Methods generated besides `link<Name>()`: the private setter, unless\n * `noSetter: true` was passed.\n */\ntype LinkSetterMethods<\n  NoSetter extends boolean,\n  Name extends string,\n  T,\n> = NoSetter extends true\n  ? {}\n  : { [P in `_set${Capitalize<Name>}`]: LinkSetter<T> };\n\nexport type LinkSourceOptions<\n  Input extends SignalStoreFeatureResult,\n  K extends keyof Input['state'],\n  NoSetter extends boolean = boolean,\n> = {\n  set?: (value: Input['state'][NoInfer<K>], store: StoreSource<Input>) => void;\n  /**\n   * Equality used to suppress redundant syncs in both directions.\n   *\n   * Defaults to comparing by content, chosen from the value at hand:\n   * `Object.is` for primitives, element by element for arrays, and\n   * structurally (JSON.stringify) for plain objects. Reference equality is\n   * the wrong default for a two-way link — a source that rebuilds an object\n   * on every read is never equal to its own previous value, so every write\n   * re-triggers the read and the link never settles.\n   *\n   * The structural comparison is JSON-based, so a `Date`, `Map`, `Set` or\n   * class instance nested in the value is flattened and two different ones\n   * can compare equal, dropping the update. Keeping non-serializable values\n   * in store state is discouraged anyway; if you do, pass an `equal` that\n   * knows how to compare them, or 'reference'.\n   *\n   * Override with a function, or the name of a premade one — 'reference'\n   * (`Object.is`, to opt out of the content comparison), 'array' (shallow,\n   * order sensitive), 'set' (order insensitive, both only offered for\n   * arrays), 'stringify' (JSON.stringify, works on objects and arrays, and\n   * the one to reach for when an array holds objects rebuilt on every read),\n   * a property of the value to compare by, e.g. 'id', or 'array.id' /\n   * 'set.id' to compare the elements of an array by one of their properties.\n   */\n  equal?: EqualOption<Input['state'][NoInfer<K>]>;\n  /**\n   * Skip generating the private `_set<Name>()` method, when the store has no\n   * use for it — e.g. it already exposes its own method for the same write.\n   */\n  noSetter?: NoSetter;\n  computation?: never;\n};\n\nexport type LinkComputedOptions<\n  Input extends SignalStoreFeatureResult,\n  T,\n  NoSetter extends boolean = boolean,\n> = {\n  computation: (store: StoreSource<Input>) => T;\n  set: (value: T, store: StoreSource<Input>) => void;\n  /**\n   * Equality used to suppress redundant syncs in both directions.\n   *\n   * Defaults to comparing by content, chosen from the value at hand:\n   * `Object.is` for primitives, element by element for arrays, and\n   * structurally (JSON.stringify) for plain objects. Reference equality is\n   * the wrong default for a two-way link — a source that rebuilds an object\n   * on every read is never equal to its own previous value, so every write\n   * re-triggers the read and the link never settles.\n   *\n   * The structural comparison is JSON-based, so a `Date`, `Map`, `Set` or\n   * class instance nested in the value is flattened and two different ones\n   * can compare equal, dropping the update. Keeping non-serializable values\n   * in store state is discouraged anyway; if you do, pass an `equal` that\n   * knows how to compare them, or 'reference'.\n   *\n   * Override with a function, or the name of a premade one — 'reference'\n   * (`Object.is`, to opt out of the content comparison), 'array' (shallow,\n   * order sensitive), 'set' (order insensitive, both only offered for\n   * arrays), 'stringify' (JSON.stringify, works on objects and arrays, and\n   * the one to reach for when an array holds objects rebuilt on every read),\n   * a property of the value to compare by, e.g. 'id', or 'array.id' /\n   * 'set.id' to compare the elements of an array by one of their properties.\n   */\n  equal?: EqualOption<NoInfer<T>>;\n  /**\n   * Skip generating the private `_set<Name>()` method, when the store has no\n   * use for it — e.g. it already exposes its own method for the same write.\n   */\n  noSetter?: NoSetter;\n};\n\n/**\n * Generates a `link<Name>()` method that connects store state to component\n * signals (inputs, models, signal forms), plus a `_set<Name>()` method — the\n * same write path, private to the store, for other features and methods to\n * write through (see `LinkSetter`), unless `noSetter: true` is passed.\n *\n * The first argument names the generated method and doubles as the state key\n * to link to, unless `computation` is provided in the options — then it is\n * just a name and the value is derived from the store.\n *\n * The method always returns a WritableSignal that is a live view of the store:\n * reading it reads the source, writing it calls `set` (or `patchState` by\n * default). It takes an options object that can also connect an external\n * signal, in one of three ways:\n * - `syncWith`: two-way, requires a WritableSignal (e.g. `model()`).\n * - `readFrom`: one-way external → store, accepts any signal — including a\n *   writable one you only write yourself (e.g. a `model()` set by a button) —\n *   or a function receiving the previous value, to merge a partial signal in.\n * - `writeTo`: one-way store → external, a WritableSignal that is set or a\n *   function called with each committed change (e.g. an `output` emit).\n *\n * `readFrom` and `writeTo` combine into a two-way sync with a mapping in each\n * direction (e.g. a `model()` whose type differs from the store's); `syncWith`\n * is mutually exclusive with both, and `initialValueFrom` only applies to it.\n *\n * Both sync directions are guarded by `equal`, so writes only happen when the\n * value actually changed — this prevents echo loops when `set` transforms the\n * value. It defaults to comparing by content, chosen from the value at hand:\n * `Object.is` for primitives, element by element for arrays, and structurally\n * for plain objects. Reference equality is the wrong default for a two-way\n * link, since a source that rebuilds an object on every read is never equal\n * to its own previous value and the link never settles.\n *\n * Besides a function, `equal` accepts the name of a premade comparison:\n * `'reference'` (`Object.is`, to opt out of the content comparison),\n * `'array'` (shallow, order sensitive), `'set'` (order insensitive — both\n * only offered when the value is an array), `'stringify'` (JSON.stringify,\n * for objects and arrays), a property of the value to compare by, or\n * `'array.<prop>'` / `'set.<prop>'` to compare the elements of an array by\n * one of their properties.\n *\n * `syncWith`, `readFrom`, `writeTo` and `updateStoreWhen` each require an injection context\n * (field initializer or constructor), because effects are created to keep\n * things in sync. The plain no-arg form has no such requirement.\n *\n * @param name - State key to link to, or a custom name when `computation` is used\n * @param options.computation - Derive the linked value from the store\n * @param options.set - How writes reach the store; defaults to\n *   `patchState(store, { [name]: value })`, required with `computation`\n * @param options.equal - Equality guard for both sync directions, a function,\n *   a premade name ('array', 'set', 'stringify'), a property to compare by\n *   ('id'), or the same per element of an array ('array.id', 'set.id')\n * @param options.noSetter - Skip generating the private `_set<Name>()` method\n *\n * @example\n * // State key - generates linkFilter(), writes patch state\n * const Store = signalStore(\n *   withState({ filter: { search: '' } }),\n *   withLink('filter'),\n * );\n * // in a component:\n * // filterForm = form(this.store.linkFilter());\n *\n * @example\n * // State key with a custom write\n * withLink('productEntitiesFilter', {\n *   set: (value, store) => store.filterProductEntities({ filter: value }),\n * });\n *\n * @example\n * // Custom name with computation + set, synced two-way with a model() input\n * withLink('selectedGenreIds', {\n *   computation: (store) => store.genreIdsSelected(),\n *   set: (value, store) =>\n *     store.selectGenreEntities({ ids: value, clearSelectionBeforeSelect: true }),\n *   // premade equality; a selection is a set, so order does not matter\n *   equal: 'set',\n * });\n * // in a component:\n * // value = model<string[]>([]);\n * // valueField = form(this.store.linkSelectedGenreIds({ syncWith: this.value }));\n *\n * @example\n * // Premade equality for an object state that is rebuilt on every read\n * withLink('filter', { equal: 'stringify' });\n *\n * @example\n * // Compare by a property, autocompleted from the linked value's type: the\n * // selected product only counts as changed when its id does\n * withLink('selectedProduct', { equal: 'id' });\n *\n * @example\n * // Same, per element of an array: 'array.id' keeps the order significant,\n * // 'set.id' does not\n * withLink('products', { equal: 'array.id' });\n *\n * @example\n * // One way: the store reads the model, writes to it stay local until the\n * // button pushes them\n * // draft = model<string>('');\n * // linked = this.store.linkFilter({ readFrom: this.draft });\n *\n * @example\n * // Merge a partial signal into the previous value: only search is external,\n * // other filter keys are left as they are\n * // search = input<string>(''); // store state is { search: string; category: string }\n * // linked = this.store.linkFilter({\n * //   readFrom: (prev) => ({ ...prev, search: this.search() }),\n * // });\n *\n * @example\n * // Two-way with a model of a different type: map in with a computed,\n * // map back out with a function\n * // search = model<string>(''); // store state is { search: string }\n * // linked = this.store.linkFilter({\n * //   readFrom: computed(() => ({ search: this.search() })),\n * //   writeTo: (value) => this.search.set(value.search),\n * // });\n *\n * @example\n * // Emit committed changes as an output\n * // filterChange = output<{ search: string }>();\n * // linked = this.store.linkFilter({\n * //   writeTo: (value) => this.filterChange.emit(value),\n * // });\n *\n * @example\n * // The private setter, for use inside the store\n * const Store = signalStore(\n *   withState({ filter: { search: '', category: '' } }),\n *   withLink('filter'),\n *   withMethods((store) => ({\n *     // value, updater for a partial change, or a signal to stay in sync with\n *     search: (search: string) => store._setFilter((f) => ({ ...f, search })),\n *   })),\n * );\n *\n * @example\n * // Buffered writes: only valid form data reaches the store\n * // filterForm = form(this.formData, (value) => required(value.search));\n * // formData = this.store.linkFilter({\n * //   // annotated because filterForm is declared below\n * //   updateStoreWhen: (): boolean => this.filterForm().valid(),\n * // });\n */\n// Overload: state key source\nexport function withLink<\n  Input extends SignalStoreFeatureResult,\n  K extends keyof Input['state'] & string,\n  NoSetter extends boolean = false,\n>(\n  source: K,\n  options?: LinkSourceOptions<Input, K, NoSetter>,\n): SignalStoreFeature<\n  Input,\n  {\n    state: {};\n    props: {};\n    methods: {\n      [P in `link${Capitalize<string & K>}`]: LinkMethod<Input['state'][K]>;\n    } & LinkSetterMethods<NoSetter, K, Input['state'][K]>;\n  }\n>;\n// Overload: custom name with computation\nexport function withLink<\n  Input extends SignalStoreFeatureResult,\n  T,\n  N extends string,\n  NoSetter extends boolean = false,\n>(\n  name: N,\n  options: LinkComputedOptions<Input, T, NoSetter>,\n): SignalStoreFeature<\n  Input,\n  {\n    state: {};\n    props: {};\n    methods: {\n      [P in `link${Capitalize<string & N>}`]: LinkMethod<T>;\n    } & LinkSetterMethods<NoSetter, N, T>;\n  }\n>;\n\nexport function withLink<Input extends SignalStoreFeatureResult>(\n  name: string,\n  options?: LinkSourceOptions<Input, any> | LinkComputedOptions<Input, any>,\n): SignalStoreFeature<Input, any> {\n  return withFeatureFactory((store) => {\n    const computation =\n      options && 'computation' in options ? options.computation : undefined;\n    // memoized: the computation must return the same value while its\n    // dependencies are unchanged, or every read produces a fresh value\n    // (e.g. a `.map()`), the source never compares equal to itself, and the\n    // updateStoreWhen buffer and the store push each other in an endless loop\n    const source: () => any = computation\n      ? computed(() => computation(store as any))\n      : (store as any)[name];\n\n    const equal = resolveEqual(options?.equal as EqualOption<any>);\n    const write = options?.set\n      ? (value: any) => options.set!(value, store as any)\n      : (value: any) => patchState(store as any, { [name]: value });\n\n    // untracked: set/update must never register dependencies when called\n    // inside a reactive context, matching WritableSignal semantics — the\n    // write itself is wrapped too, since it can read other signals\n    // (e.g. filterEntities reads entities())\n    const guardedWrite = (value: any) =>\n      untracked(() => {\n        if (!equal(value, source())) {\n          write(value);\n        }\n      });\n\n    const linkMethodName = `link${capitalize(name)}`;\n    const setterMethodName = `_set${capitalize(name)}`;\n\n    return signalStoreFeature(\n      withMethods(() => ({\n        ...(options?.noSetter\n          ? {}\n          : { [setterMethodName]: linkSetter(source, guardedWrite) }),\n        [linkMethodName]: (options?: LinkOptions) => {\n          const linkOptions = options as\n            | (LinkCommonOptions<any> & {\n                syncWith?: WritableSignal<any>;\n                readFrom?: Signal<any> | ((prev: any) => any);\n                writeTo?: WritableSignal<any> | ((value: any) => void);\n                initialValueFrom?: 'store' | 'external';\n              })\n            | undefined;\n          const updateStoreWhen = linkOptions?.updateStoreWhen;\n          // with updateStoreWhen the linked signal is a buffer over the source:\n          // writes stay local until the gate opens. Without it, writes go\n          // straight to the store.\n          const linked: WritableSignal<any> = updateStoreWhen\n            ? linkedSignal(() => source(), { equal })\n            : delegatedSignal({\n                computation: () => source(),\n                write: guardedWrite,\n                equal,\n              });\n\n          const readFrom = linkOptions?.readFrom;\n          if (readFrom) {\n            // the function form receives the previous linked value untracked,\n            // so a merge can not register the store (or buffer) as a\n            // dependency — only the external signals it reads re-run it\n            const read = isSignal(readFrom)\n              ? () => readFrom()\n              : () => readFrom(untracked(linked));\n            // one way: the store reads the signal, never writes it back\n            const initial = untracked(read);\n            linked.set(initial);\n            // the initial sync above already applied this value, so the effect\n            // below must not apply it again — that would discard a buffered\n            // write made before the first tick\n            let lastRead: unknown = initial;\n            effect(() => {\n              const value = read();\n              if (equal(value, lastRead)) return;\n              lastRead = value;\n              untracked(() => linked.set(value));\n            });\n          }\n\n          if (updateStoreWhen) {\n            // buffer -> store; updateStoreWhen is called tracked so its own\n            // dependencies re-run the effect, flushing a value that was\n            // held back while the gate was closed\n            effect(() => {\n              const value = linked();\n              if (updateStoreWhen(value)) {\n                untracked(() => guardedWrite(value));\n              }\n            });\n          }\n\n          const writeTo = linkOptions?.writeTo;\n          if (writeTo) {\n            const writeExternal =\n              typeof (writeTo as Partial<WritableSignal<any>>).set ===\n              'function'\n                ? (value: any) => (writeTo as WritableSignal<any>).set(value)\n                : (writeTo as (value: any) => void);\n            // changes only: the value at link time is not pushed, so an\n            // output does not emit spuriously and a readFrom mapping is not\n            // echoed straight back. Reads the source, not the buffer, so\n            // only values committed to the store are pushed out. The linked\n            // signal (not the source) seeds the guard so a readFrom initial\n            // value still pending in the updateStoreWhen buffer is not pushed\n            // once the gate commits it.\n            let lastWritten: unknown = untracked(linked);\n            effect(() => {\n              const value = source();\n              if (equal(value, lastWritten)) return;\n              lastWritten = value;\n              untracked(() => writeExternal(value));\n            });\n          }\n\n          const syncWith = linkOptions?.syncWith;\n          if (syncWith) {\n            const initialValueFrom =\n              linkOptions?.initialValueFrom ?? 'external';\n            // last value seen coming from the external signal, so writes we\n            // made to it ourselves are not mistaken for user edits. Both\n            // branches below seed it before the effects run\n            let lastExternal: unknown;\n            if (initialValueFrom === 'external') {\n              linked.set(untracked(syncWith));\n              // the initial sync above already applied this value, so the\n              // effect below must not apply it again — that would discard a\n              // buffered write made before the first tick\n              lastExternal = untracked(syncWith);\n            } else {\n              syncWith.set(untracked(source));\n              // our own write: without recording it, the effect below would\n              // treat its first run as a user edit and force-apply the\n              // external snapshot — reverting a store change or clobbering a\n              // buffered write made before the first tick\n              lastExternal = untracked(source);\n            }\n            // external -> linked\n            effect(() => {\n              const value = syncWith();\n              if (equal(value, lastExternal)) return;\n              lastExternal = value;\n              untracked(() => linked.set(value));\n            });\n            // store -> external. Reads the source, not the buffer, so an\n            // external model() only ever sees values committed to the store.\n            effect(() => {\n              const value = source();\n              untracked(() => {\n                if (!equal(syncWith(), value)) {\n                  // our own write, not a user edit: recording it keeps the\n                  // effect above from pushing it back into the buffer and\n                  // overwriting a value the gate is still holding\n                  lastExternal = value;\n                  syncWith.set(value);\n                }\n              });\n            });\n          }\n          return linked;\n        },\n      })),\n    );\n  }) as any;\n}\n\n/**\n * Builds the `_set<Name>()` method: a `signalMethod` writing through the\n * link's write path, that also accepts an updater receiving the current value.\n */\nfunction linkSetter<T>(\n  source: () => T,\n  write: (value: T) => void,\n): LinkSetter<T> {\n  const setValue = signalMethod<T>((value) => write(value));\n  // updaters take the current value as param; signalMethod treats any fn as a\n  // zero-arg reactive computation, so route by arity — same as withStateSetter\n  const setter = (\n    value: T | (() => T) | ((current: T) => T),\n    config?: { injector?: Injector },\n  ): EffectRef => {\n    if (typeof value === 'function' && value.length > 0) {\n      write((value as (current: T) => T)(untracked(source)));\n      return { destroy: () => void 0 };\n    }\n    return setValue(value as T | (() => T), config);\n  };\n  setter.destroy = setValue.destroy;\n  return setter as LinkSetter<T>;\n}\n\nfunction delegatedSignal<T>(options: {\n  computation: () => T;\n  write: (value: T) => void;\n  equal?: (a: T, b: T) => boolean;\n}): WritableSignal<T> {\n  const internalSignal = computed(options.computation, {\n    equal: options.equal,\n  });\n\n  // reuses the computed's SIGNAL node so isSignal/toSignal interop treats\n  // this as a real signal; set/update only exist on the wrapper, so code\n  // that writes through the node itself would bypass them\n  const res: WritableSignal<T> = Object.assign(() => internalSignal(), {\n    [SIGNAL]: internalSignal[SIGNAL],\n    set: (value: T) => options.write(value),\n    update: (updateFn: (value: T) => T) => {\n      const newValue = updateFn(untracked(internalSignal));\n      options.write(newValue);\n    },\n    asReadonly: () => internalSignal,\n  } as WritableSignal<T>);\n  return res;\n}\n","import { SignalStoreFeature, SignalStoreFeatureResult } from '@ngrx/signals';\n\nimport { RequireEntitiesFilter } from '../feature-requirements.model';\nimport { LinkMethod, withLink } from '../with-link/with-link';\nimport { getWithEntitiesFilterKeys } from './with-entities-filter.util';\nimport {\n  EntitiesFilterState,\n  NamedEntitiesFilterState,\n} from './with-entities-local-filter.model';\n\ntype ExtractFilter<State, Collection extends string> = Collection extends ''\n  ? State extends { entitiesFilter: infer F }\n    ? F\n    : Record<string, unknown>\n  : State extends { [K in `${Collection}EntitiesFilter`]: infer F }\n    ? F\n    : Record<string, unknown>;\n\n/**\n * Generates a `link[Collection]EntitiesFilter()` method that connects the\n * entities filter to component signals (inputs, models, signal forms).\n *\n * Prebuilt version of `withLink` for `withEntitiesLocalFilter` /\n * `withEntitiesRemoteFilter` / `withEntitiesHybridFilter`: writes route through\n * `filter[Collection]Entities` (so filtering and its debounce still happen).\n * Echo loops are prevented because the filter features patch the filter value\n * by reference, so the link method's default `Object.is` guard converges, and\n * `filter[Collection]Entities` itself drops structurally-equal filters.\n *\n * Requires one of the withEntities*Filter features to be used before it.\n *\n * @param config - The configuration object for the feature\n * @param config.entity - The entity type to be used\n * @param config.collection - The optional collection name to be used\n * @param config.debounce - Debounce passed to filter[Collection]Entities on\n *   each sync; defaults to 0 to respect signal semantics, and so user can use the signalForm field debounce\n * @param config.forceLoad - forceLoad passed to filter[Collection]Entities\n *\n * @example\n * const entity = type<Product>();\n * const store = signalStore(\n *   withEntities({ entity }),\n *   withEntitiesLocalFilter({\n *     entity,\n *     defaultFilter: { search: '' },\n *     filterFn: (entity, filter) =>\n *       !filter?.search || entity?.name.toLowerCase().includes(filter?.search.toLowerCase()),\n *   }),\n *   withLinkEntitiesFilter({ entity }),\n * );\n * // in a component:\n * // filterForm = form(this.store.linkEntitiesFilter());\n */\nexport function withLinkEntitiesFilter<\n  Input extends SignalStoreFeatureResult,\n  Entity,\n  Collection extends string = '',\n>(config?: {\n  entity?: Entity;\n  collection?: Collection;\n  debounce?: number;\n  forceLoad?: boolean;\n}): SignalStoreFeature<\n  Input &\n    RequireEntitiesFilter<\n      Input,\n      Collection,\n      'withLinkEntitiesFilter',\n      Collection extends ''\n        ? {\n            state: EntitiesFilterState<\n              ExtractFilter<Input['state'], Collection>\n            >;\n            props: {};\n            methods: {};\n          }\n        : {\n            state: NamedEntitiesFilterState<\n              Collection,\n              ExtractFilter<Input['state'], Collection>\n            >;\n            props: {};\n            methods: {};\n          }\n    >,\n  {\n    state: {};\n    props: {};\n    methods: {\n      [P in Collection extends ''\n        ? 'entitiesFilter'\n        : `${Collection}EntitiesFilter` as `link${Capitalize<\n        string & P\n      >}`]: LinkMethod<ExtractFilter<Input['state'], Collection>>;\n    };\n  }\n> {\n  const { filterKey, filterEntitiesKey } = getWithEntitiesFilterKeys(config);\n  return withLink(filterKey, {\n    set: (value: any, store: any) => {\n      (store[filterEntitiesKey] as (options: any) => void)({\n        filter: value,\n        debounce: config?.debounce ?? 0,\n        forceLoad: config?.forceLoad,\n      });\n    },\n    // the store already exposes filter[Collection]Entities for this write\n    noSetter: true,\n  } as any) as any;\n}\n","import { capitalize } from '../util';\n\nexport function getWithEntitiesSortKeys(config?: { collection?: string }) {\n  const collection = config?.collection;\n  const capitalizedProp = collection && capitalize(collection);\n  return {\n    sortKey: collection ? `${config.collection}EntitiesSort` : 'entitiesSort',\n    sortEntitiesKey: collection\n      ? `sort${capitalizedProp}Entities`\n      : 'sortEntities',\n  };\n}\n","import { computed, Signal } from '@angular/core';\n\nimport {\n  createEvent,\n  props,\n} from '../with-event-handler/with-event-handler.util';\nimport { QueryMapper } from '../with-sync-to-route-query-params/with-sync-to-route-query-params.util';\nimport { EntitiesSortState, Sort } from './with-entities-local-sort.model';\nimport { EntitiesRemoteSortMethods } from './with-entities-remote-sort.model';\nimport { getWithEntitiesSortKeys } from './with-entities-sort.util';\n\nconst MAX_SAFE_INTEGER = 9007199254740991;\n\nexport function _isNumberValue(value: any): boolean {\n  // parseFloat(value) handles most of the cases we're interested in (it treats null, empty string,\n  // and other non-number values as NaN, where Number just uses 0) but it considers the string\n  // '123hello' to be a valid number. Therefore, we also check if Number(value) is NaN.\n  return !isNaN(parseFloat(value as any)) && !isNaN(Number(value));\n}\n\nfunction sortingDataAccessor<T>(\n  data: T,\n  sortHeaderId: string,\n): string | number {\n  const value = (data as { [key: string]: any })[sortHeaderId];\n\n  if (_isNumberValue(value)) {\n    const numberValue = Number(value);\n\n    // Numbers beyond `MAX_SAFE_INTEGER` can't be compared reliably, so we\n    // leave them as strings. For more info: https://goo.gl/y5vbSg\n    return numberValue < MAX_SAFE_INTEGER ? numberValue : value;\n  }\n\n  return value;\n}\n\n/**\n * @internal\n * @ignore\n * Gets a sorted copy of the data array based on the state of the Sort.\n * @param data The array of data that should be sorted.\n * @param sort The connected MatSort that holds the current sort state.\n */\nexport function sortData<T>(data: T[], sort: Sort<T>): T[] {\n  const active = sort.field;\n  const direction = sort.direction;\n  if (!active || direction === '') {\n    return data;\n  }\n  return data.sort((a, b) => {\n    const valueA = sortingDataAccessor(a, active as string);\n    const valueB = sortingDataAccessor(b, active as string);\n\n    // If both valueA and valueB exist (truthy), then compare the two. Otherwise, check if\n    // one value exists while the other doesn't. In this case, existing value should come last.\n    // This avoids inconsistent results when comparing values to undefined/null.\n    // If neither value exists, return 0 (equal).\n    let comparatorResult = 0;\n    if (valueA != null && valueB != null) {\n      // Check if one value is greater than the other; if equal, comparatorResult should remain 0.\n\n      if (typeof valueA === 'string' || typeof valueB === 'string') {\n        // if either values are a string, then force both to be strings before localCompare\n        comparatorResult = valueA.toString().localeCompare(valueB.toString());\n      } else {\n        if (valueA > valueB) {\n          comparatorResult = 1;\n        } else if (valueA < valueB) {\n          comparatorResult = -1;\n        }\n      }\n    } else if (valueA != null) {\n      comparatorResult = 1;\n    } else if (valueB != null) {\n      comparatorResult = -1;\n    }\n\n    return comparatorResult * (direction === 'asc' ? 1 : -1);\n  });\n}\n\nexport function getWithEntitiesLocalSortEvents(config?: {\n  collection?: string;\n}) {\n  const collection = config?.collection;\n  return {\n    entitiesLocalSortChanged: createEvent(\n      `${collection}.entitiesLocalSortChanged`,\n      props<{ sort: Sort<any> }>(),\n    ),\n  };\n}\nexport function getQueryMapperForEntitiesSort(config?: {\n  collection?: string;\n  skipLoadingCall?: boolean;\n}): QueryMapper<{\n  sortBy: string;\n  sortDirection: string;\n}> {\n  const { sortEntitiesKey, sortKey } = getWithEntitiesSortKeys(config);\n  return {\n    queryParamsToState: (query, store, firstLoad) => {\n      const sortBy = query.sortBy;\n      if (sortBy) {\n        const sortDirection = query.sortDirection;\n        const sortEntities = store[\n          sortEntitiesKey\n        ] as EntitiesRemoteSortMethods<unknown>['sortEntities'];\n        const sort = store[sortKey] as Signal<\n          EntitiesSortState<any>['entitiesSort']\n        >;\n        if (sort().direction != sortDirection || sort().field != sortBy) {\n          sortEntities({\n            sort: { field: sortBy, direction: sortDirection as 'asc' | 'desc' },\n            // we only allow to skip the loading call on the first load,\n            // otherwise history navigation would not work as expected\n            skipLoadingCall: firstLoad && config?.skipLoadingCall,\n          });\n        }\n      }\n    },\n    stateToQueryParams: (store) => {\n      const sort = store[sortKey] as Signal<\n        EntitiesSortState<any>['entitiesSort']\n      >;\n      return sort\n        ? computed(() => ({\n            sortBy: sort().field as string,\n            sortDirection: sort().direction,\n          }))\n        : null;\n    },\n  };\n}\n","import { computed, Signal } from '@angular/core';\nimport { toObservable } from '@angular/core/rxjs-interop';\nimport { DeepSignal } from '@ngrx/signals';\n\nimport { capitalize } from '../util';\nimport { getWithCallStatusKeys } from '../with-call-status/with-call-status.util';\nimport {\n  createEvent,\n  props,\n} from '../with-event-handler/with-event-handler.util';\nimport { QueryMapper } from '../with-sync-to-route-query-params/with-sync-to-route-query-params.util';\nimport { EntitiesPaginationLocalState } from './with-entities-local-pagination.model';\nimport { EntitiesPaginationRemoteMethods } from './with-entities-remote-pagination.model';\n\nexport function getWithEntitiesLocalPaginationKeys(config?: {\n  collection?: string;\n}) {\n  const collection = config?.collection;\n  const capitalizedProp = collection && capitalize(collection);\n  return {\n    paginationKey: collection\n      ? `${config.collection}EntitiesPagination`\n      : 'entitiesPagination',\n    entitiesCurrentPageKey: collection\n      ? `${config.collection}EntitiesCurrentPage`\n      : 'entitiesCurrentPage',\n    loadEntitiesPageKey: collection\n      ? `load${capitalizedProp}EntitiesPage`\n      : 'loadEntitiesPage',\n  };\n}\n\nexport function getWithEntitiesLocalPaginationEvents(config?: {\n  collection?: string;\n}) {\n  const collection = config?.collection;\n  return {\n    entitiesLocalPageChanged: createEvent(\n      `${collection}.entitiesLocalPageChanged`,\n      props<{ pageIndex: number }>(),\n    ),\n  };\n}\n\nexport function getQueryMapperForEntitiesPagination(config?: {\n  collection?: string;\n  skipLoadingCall?: boolean;\n}): QueryMapper<{\n  page: string;\n  pageSize: string;\n}> {\n  const { loadEntitiesPageKey, paginationKey } =\n    getWithEntitiesLocalPaginationKeys(config);\n  const { loadingKey, loadedKey } = getWithCallStatusKeys({\n    collection: config?.collection,\n  });\n  return {\n    queryParamsToState: (query, store, firstLoad) => {\n      const page = query.page;\n      const pageSize = query.pageSize;\n      const pagination = store[paginationKey] as Signal<\n        EntitiesPaginationLocalState['entitiesPagination']\n      >;\n\n      if (\n        (page && +page - 1 != pagination()?.currentPage) ||\n        (pageSize && +pageSize != pagination()?.pageSize)\n      ) {\n        const loadEntitiesPage = store[\n          loadEntitiesPageKey\n        ] as EntitiesPaginationRemoteMethods<unknown>['loadEntitiesPage'];\n        const loading = store[loadingKey] as Signal<boolean>;\n        const loaded = store[loadedKey] as Signal<boolean>;\n        const loaded$ = toObservable(loaded);\n\n        loadEntitiesPage({\n          pageIndex: +page - 1,\n          // we forceLoad on first load to ensure filter is set in the store, before fetching data\n          // after that it should not force load, to allow history navigation without triggering loading state\n          forceLoad: true,\n          pageSize: pageSize ? +pageSize : undefined,\n          // we only allow to skip the loading call on the first load,\n          // otherwise history navigation would not work as expected\n          skipLoadingCall: firstLoad && config?.skipLoadingCall,\n        });\n      }\n    },\n    stateToQueryParams: (store) => {\n      const pagination = store[paginationKey] as DeepSignal<\n        EntitiesPaginationLocalState['entitiesPagination']\n      >;\n      return pagination\n        ? computed(() => ({\n            page: (pagination.currentPage() + 1).toString(),\n            pageSize: pagination.pageSize().toString(),\n          }))\n        : null;\n    },\n  };\n}\n","import { computed, Signal } from '@angular/core';\nimport {\n  deepComputed,\n  patchState,\n  signalStoreFeature,\n  SignalStoreFeature,\n  SignalStoreFeatureResult,\n  withComputed,\n  withMethods,\n  withState,\n  WritableStateSource,\n} from '@ngrx/signals';\n\nimport { RequireEntities } from '../feature-requirements.model';\nimport { getWithEntitiesKeys } from '../util';\nimport { getWithEntitiesFilterEvents } from '../with-entities-filter/with-entities-filter.util';\nimport { getWithEntitiesLocalSortEvents } from '../with-entities-sort/with-entities-local-sort.util';\nimport {\n  broadcast,\n  onEvent,\n  withEventHandler,\n} from '../with-event-handler/with-event-handler';\nimport { withFeatureFactory } from '../with-feature-factory/with-feature-factory';\nimport {\n  FeatureConfigFactory,\n  getFeatureConfig,\n  StoreSource,\n} from '../with-feature-factory/with-feature-factory.model';\nimport {\n  EntitiesPaginationLocalComputed,\n  EntitiesPaginationLocalMethods,\n  EntitiesPaginationLocalState,\n  NamedEntitiesPaginationLocalComputed,\n  NamedEntitiesPaginationLocalMethods,\n  NamedEntitiesPaginationLocalState,\n} from './with-entities-local-pagination.model';\nimport {\n  getWithEntitiesLocalPaginationEvents,\n  getWithEntitiesLocalPaginationKeys,\n} from './with-entities-local-pagination.util';\n\n/**\n * Generates necessary state, computed and methods for local pagination of entities in the store.\n *\n * Requires withEntities to be present in the store.\n * @param configFactory - The configuration object for the feature or a factory function that receives the store and returns the configuration object\n * @param configFactory.pageSize - The number of entities to show per page\n * @param configFactory.currentPage - The current page to show\n * @param configFactory.entity - The entity type\n * @param configFactory.collection - The name of the collection\n *\n * @example\n * const entity = type<Product>();\n * const collection = \"product\";\n * export const ProductsLocalStore = signalStore(\n *   { providedIn: 'root' },\n *   // required withEntities\n *   withEntities({ entity, collection }),\n *   withEntitiesLocalPagination({\n *     entity,\n *     collection,\n *     pageSize: 5,\n *   }),\n *\n *   // generates the following signals\n *   store.productEntitiesPagination // { currentPage: 0, pageSize: 5 }\n *   // generates the following computed signals\n *   store.productEntitiesCurrentPage // { entities: Product[], pageIndex: 0, total: 10, pageSize: 5, pagesCount: 2, hasPrevious: false, hasNext: true }\n *   // generates the following methods\n *   store.loadProductEntitiesPage // ({ pageIndex: number }) => void\n */\n\nexport function withEntitiesLocalPagination<\n  Input extends SignalStoreFeatureResult,\n  Entity,\n  Collection extends string = '',\n>(\n  configFactory: FeatureConfigFactory<\n    Input,\n    {\n      pageSize?: number;\n      currentPage?: number;\n      entity: Entity;\n      collection?: Collection;\n    }\n  >,\n): SignalStoreFeature<\n  Input &\n    RequireEntities<Input, Entity, Collection, 'withEntitiesLocalPagination'>,\n  Collection extends ''\n    ? {\n        state: EntitiesPaginationLocalState;\n        props: EntitiesPaginationLocalComputed<Entity>;\n        methods: EntitiesPaginationLocalMethods;\n      }\n    : {\n        state: NamedEntitiesPaginationLocalState<Collection>;\n        props: NamedEntitiesPaginationLocalComputed<Entity, Collection>;\n        methods: NamedEntitiesPaginationLocalMethods<Collection>;\n      }\n> {\n  return withFeatureFactory((store: StoreSource<Input>) => {\n    const {\n      pageSize = 10,\n      currentPage = 0,\n      ...config\n    } = getFeatureConfig(configFactory, store);\n    const { entitiesKey } = getWithEntitiesKeys(config);\n    const { loadEntitiesPageKey, entitiesCurrentPageKey, paginationKey } =\n      getWithEntitiesLocalPaginationKeys(config);\n    const { entitiesFilterChanged } = getWithEntitiesFilterEvents(config);\n    const { entitiesLocalPageChanged } =\n      getWithEntitiesLocalPaginationEvents(config);\n    const { entitiesLocalSortChanged } = getWithEntitiesLocalSortEvents(config);\n\n    function setCurrentPage(\n      state: Record<string, Signal<unknown>>,\n      pageIndex: number,\n      pageSize?: number,\n    ) {\n      const { entitiesKey } = getWithEntitiesKeys(config);\n      const entities = state[entitiesKey] as Signal<Entity[]>;\n      const pagination = state[paginationKey] as Signal<{\n        pageSize: number;\n        currentPage: number;\n      }>;\n      const size = pageSize ?? pagination().pageSize;\n      const startIndex = pageIndex * size;\n\n      patchState(state as WritableStateSource<object>, {\n        [paginationKey]: {\n          ...pagination(),\n          currentPage: pageIndex,\n          pageSize: size,\n        },\n      });\n    }\n\n    return signalStoreFeature(\n      withState({\n        [paginationKey]: {\n          pageSize,\n          currentPage,\n        },\n      }),\n      withComputed((state: Record<string, Signal<unknown>>) => {\n        const entities = state[entitiesKey] as Signal<Entity[]>;\n        const pagination = state[paginationKey] as Signal<{\n          pageSize: number;\n          currentPage: number;\n        }>;\n        const entitiesCurrentPage = deepComputed(() => {\n          const page = pagination().currentPage;\n          const startIndex = page * pagination().pageSize;\n          let endIndex = startIndex + pagination().pageSize;\n          endIndex =\n            endIndex < entities().length ? endIndex : entities().length;\n          const pageEntities = entities().slice(startIndex, endIndex);\n          const total = entities().length;\n          const pagesCount =\n            total && total! > 0\n              ? Math.ceil(total! / pagination().pageSize)\n              : undefined;\n          return {\n            entities: pageEntities,\n            pageIndex: pagination().currentPage,\n            total: total,\n            pageSize: pagination().pageSize,\n            pagesCount,\n            hasPrevious: pagination().currentPage - 1 >= 0,\n            hasNext:\n              pagesCount && total && total! > 0\n                ? pagination().currentPage + 1 < pagesCount\n                : true,\n          };\n        });\n        return {\n          [entitiesCurrentPageKey]: entitiesCurrentPage,\n        };\n      }),\n      withEventHandler((state: Record<string, Signal<unknown>>) => [\n        onEvent(entitiesFilterChanged, entitiesLocalSortChanged, () => {\n          const pagination = state[paginationKey] as Signal<{\n            pageSize: number;\n            currentPage: number;\n          }>;\n          const page = pagination().currentPage;\n\n          if (page !== 0) setCurrentPage(state, 0);\n        }),\n      ]),\n\n      withMethods((state: Record<string, Signal<unknown>>) => {\n        return {\n          [loadEntitiesPageKey]: ({\n            pageIndex,\n            pageSize,\n          }: {\n            pageIndex: number;\n            pageSize?: number;\n          }) => {\n            setCurrentPage(state, pageIndex, pageSize);\n            broadcast(state, entitiesLocalPageChanged({ pageIndex }));\n          },\n        };\n      }),\n    );\n  }) as any;\n}\n","import {\n  createEvent,\n  props,\n} from '../with-event-handler/with-event-handler.util';\nimport { Sort } from './with-entities-local-sort.model';\n\nexport function getWithEntitiesRemoteSortEvents(config?: {\n  collection?: string;\n}) {\n  const collection = config?.collection;\n  return {\n    entitiesRemoteSortChanged: createEvent(\n      `${collection}.entitiesRemoteSortChanged`,\n      props<{ sort: Sort<any>; skipLoadingCall?: boolean }>(),\n    ),\n  };\n}\n","import { capitalize } from '../util';\nimport {\n  createEvent,\n  props,\n} from '../with-event-handler/with-event-handler.util';\n\nexport function getWithEntitiesRemotePaginationKeys(config?: {\n  collection?: string;\n}) {\n  const collection = config?.collection;\n  const capitalizedProp = collection && capitalize(collection);\n  return {\n    paginationKey: collection\n      ? `${config.collection}EntitiesPagination`\n      : 'entitiesPagination',\n    entitiesCurrentPageKey: collection\n      ? `${config.collection}EntitiesCurrentPage`\n      : 'entitiesCurrentPage',\n    entitiesPagedRequestKey: collection\n      ? `${config.collection}EntitiesPagedRequest`\n      : 'entitiesPagedRequest',\n    loadEntitiesPageKey: collection\n      ? `load${capitalizedProp}EntitiesPage`\n      : 'loadEntitiesPage',\n    setEntitiesPagedResultKey: collection\n      ? `set${capitalizedProp}EntitiesPagedResult`\n      : 'setEntitiesPagedResult',\n  };\n}\n\nexport function getWithEntitiesRemotePaginationEvents(config?: {\n  collection?: string;\n}) {\n  const collection = config?.collection;\n  return {\n    entitiesRemotePageChanged: createEvent(\n      `${collection}.entitiesRemotePageChanged`,\n      props<{ pageIndex: number; isPageInCache: boolean }>(),\n    ),\n    entitiesPagedResultsLoaded: createEvent(\n      `${collection}.entitiesPagedResultsLoaded`,\n    ),\n  };\n}\n","import { computed, Signal } from '@angular/core';\nimport { toObservable } from '@angular/core/rxjs-interop';\nimport {\n  deepComputed,\n  patchState,\n  signalStoreFeature,\n  SignalStoreFeature,\n  SignalStoreFeatureResult,\n  withComputed,\n  withMethods,\n  withState,\n  WritableStateSource,\n} from '@ngrx/signals';\nimport { SelectEntityId, setAllEntities } from '@ngrx/signals/entities';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport {\n  distinctUntilChanged,\n  EMPTY,\n  exhaustMap,\n  first,\n  pipe,\n  tap,\n} from 'rxjs';\n\nimport {\n  RequireEntities,\n  RequireEntitiesCallStatus,\n} from '../feature-requirements.model';\nimport { getWithEntitiesKeys } from '../util';\nimport { getWithCallStatusKeys } from '../with-call-status/with-call-status.util';\nimport { getWithEntitiesFilterEvents } from '../with-entities-filter/with-entities-filter.util';\nimport { getWithEntitiesRemoteSortEvents } from '../with-entities-sort/with-entities-remote-sort.util';\nimport {\n  broadcast,\n  onEvent,\n  withEventHandler,\n} from '../with-event-handler/with-event-handler';\nimport { withFeatureFactory } from '../with-feature-factory/with-feature-factory';\nimport {\n  FeatureConfigFactory,\n  getFeatureConfig,\n  StoreSource,\n} from '../with-feature-factory/with-feature-factory.model';\nimport {\n  EntitiesPaginationRemoteComputed,\n  EntitiesPaginationRemoteMethods,\n  EntitiesPaginationRemoteState,\n  NamedEntitiesPaginationRemoteComputed,\n  NamedEntitiesPaginationRemoteMethods,\n  NamedEntitiesPaginationRemoteState,\n  PaginationState,\n} from './with-entities-remote-pagination.model';\nimport {\n  getWithEntitiesRemotePaginationEvents,\n  getWithEntitiesRemotePaginationKeys,\n} from './with-entities-remote-pagination.util';\n\n/**\n * Generates necessary state, computed and methods for remote pagination of entities in the store.\n * Call load[Collection]Page to change the page, it will try to load the new page from cache if it's not present,\n * it will call set[Collection]Loading(), and you should either create an effect that listens to [Collection]Loading\n * and call the api with the [Collection]PagedRequest params and use set[Collection]Result to set the result\n * and changing the status errors manually,\n * or use withEntitiesLoadingCall to call the api with the [Collection]PagedRequest params which handles setting\n * the result and errors automatically.\n *\n * In case you dont want load[Collection]Page to call set[Collection]Loading() (which triggers a fetchEntities), you can pass skipLoadingCall: true to load[Collection]Page.\n * Useful in cases where you want to further change the state before manually calling set[Collection]Loading() to trigger a fetch of entities.\n *\n * This will keep at least the provided (pagesToCache) pages in memory, so previous pages could be removed from the cache.\n * If you need to keep all previous pages in memory, use withEntitiesRemoteScrollPagination instead.\n *\n * Requires withEntities and withCallStatus to be present in the store.\n * @param configFactory - The configuration object for the feature or a factory function that receives the store and returns the configuration object\n * @param configFactory.pageSize - The number of entities to show per page\n * @param configFactory.currentPage - The current page to show\n * @param configFactory.pagesToCache - The number of pages to cache\n * @param configFactory.entity - The entity type\n * @param configFactory.collection - The name of the collection\n * @param configFactory.selectId - The function to use to select the id of the entity\n *\n * @example\n * const entity = type<Product>();\n * const collection = \"product\";\n * export const store = signalStore(\n *   { providedIn: 'root' },\n *   // required withEntities and withCallStatus\n *   withEntities({ entity, collection }),\n *   withCallStatus({ prop: collection, initialValue: 'loading' }),\n *\n *   withEntitiesRemotePagination({\n *     entity,\n *     collection,\n *     pageSize: 5,\n *     pagesToCache: 2,\n *   })\n *   // after you can use withEntitiesLoadingCall to connect the filter to\n *   // the api call, or do it manually as shown after\n *    withEntitiesLoadingCall({\n *     collection,\n *     fetchEntities: ({ productPagedRequest }) => {\n *       return inject(ProductService)\n *         .getProducts({\n *           take: productPagedRequest().size,\n *           skip: productPagedRequest().startIndex,\n *         }).pipe(\n *           map((d) => ({\n *             entities: d.resultList,\n *             total: d.total,\n *           })),\n *         )\n *     },\n *   }),\n * // withEntitiesLoadingCall is the same as doing the following:\n * // withHooks(({ productsLoading, setProductEntitiesError, setProductEntitiesPagedResult, ...state }) => ({\n * //   onInit: async () => {\n * //     effect(() => {\n * //       if (isProductEntitiesLoading()) {\n * //         inject(ProductService)\n * //             .getProducts({\n * //                take: productPagedRequest().size,\n * //                skip: productPagedRequest().startIndex,\n * //              })\n * //           .pipe(\n * //             takeUntilDestroyed(),\n * //             tap((res) =>\n * //               patchState(\n * //                 state,\n * //                 setProductEntitiesPagedResult({ entities: res.resultList, total: res.total } ),\n * //               ),\n * //             ),\n * //             catchError((error) => {\n * //               setProductEntitiesError(error);\n * //               return EMPTY;\n * //             }),\n * //           )\n * //           .subscribe();\n * //       }\n * //     });\n * //   },\n *  })),\n *   // generates the following signals\n *   store.productEntitiesPagination // { currentPage: number, requestPage: number, pageSize: 5, total: number, pagesToCache: number, cache: { start: number, end: number } } used internally\n *  // generates the following computed signals\n *  store.productEntitiesCurrentPage // { entities: Product[], pageIndex: number, total: number, pageSize: 5, pagesCount: number, hasPrevious: boolean, hasNext: boolean, isLoading: boolean }\n *  store.productPagedRequest // { startIndex: number, size: number, page: number }\n *  // generates the following methods\n *  store.loadProductEntitiesPage({ pageIndex: number, forceLoad?: boolean, skipLoadingCall?:boolean }) // loads the page and sets the requestPage to the pageIndex\n *  store.setProductEntitiesPagedResult(entities: Product[], total: number) // appends the entities to the cache of entities and total\n */\nexport function withEntitiesRemotePagination<\n  Input extends SignalStoreFeatureResult,\n  Entity,\n  Collection extends string = '',\n>(\n  configFactory: FeatureConfigFactory<\n    Input,\n    {\n      pageSize?: number;\n      currentPage?: number;\n      pagesToCache?: number;\n      entity: Entity;\n      collection?: Collection;\n      selectId?: SelectEntityId<Entity>;\n    }\n  >,\n): SignalStoreFeature<\n  Input &\n    RequireEntities<Input, Entity, Collection, 'withEntitiesRemotePagination'> &\n    RequireEntitiesCallStatus<\n      Input,\n      Collection,\n      'withEntitiesRemotePagination'\n    >,\n  Collection extends ''\n    ? {\n        state: EntitiesPaginationRemoteState;\n        props: EntitiesPaginationRemoteComputed<Entity>;\n        methods: EntitiesPaginationRemoteMethods<Entity>;\n      }\n    : {\n        state: NamedEntitiesPaginationRemoteState<Collection>;\n        props: NamedEntitiesPaginationRemoteComputed<Entity, Collection>;\n        methods: NamedEntitiesPaginationRemoteMethods<Entity, Collection>;\n      }\n> {\n  return withFeatureFactory((store: StoreSource<Input>) => {\n    const {\n      pageSize = 10,\n      currentPage = 0,\n      pagesToCache = 3,\n      ...config\n    } = getFeatureConfig(configFactory, store);\n    const { loadingKey, setLoadingKey } = getWithCallStatusKeys({\n      collection: config.collection,\n    });\n    const { entitiesKey } = getWithEntitiesKeys(config);\n\n    const {\n      loadEntitiesPageKey,\n      entitiesCurrentPageKey,\n      paginationKey,\n      entitiesPagedRequestKey,\n      setEntitiesPagedResultKey,\n    } = getWithEntitiesRemotePaginationKeys(config);\n\n    const { entitiesFilterChanged } = getWithEntitiesFilterEvents(config);\n    const { entitiesRemotePageChanged, entitiesPagedResultsLoaded } =\n      getWithEntitiesRemotePaginationEvents(config);\n    const { entitiesRemoteSortChanged } =\n      getWithEntitiesRemoteSortEvents(config);\n\n    return signalStoreFeature(\n      withState({\n        [paginationKey]: {\n          pageSize,\n          currentPage,\n          requestPage: currentPage,\n          pagesToCache,\n          total: undefined,\n          cache: {\n            start: 0,\n            end: 0,\n          },\n        },\n      }),\n      withComputed((state: Record<string, Signal<unknown>>) => {\n        const entities = state[entitiesKey] as Signal<Entity[]>;\n        const loading = state[loadingKey] as Signal<boolean>;\n        const pagination = state[paginationKey] as Signal<PaginationState>;\n        const entitiesCurrentPageList = computed(() => {\n          const page = pagination().currentPage;\n          const startIndex =\n            page * pagination().pageSize - pagination().cache.start;\n          let endIndex = startIndex + pagination().pageSize;\n          endIndex =\n            endIndex < pagination().cache.end\n              ? endIndex\n              : pagination().cache.end + 1;\n\n          return entities().slice(startIndex, endIndex);\n        });\n\n        const entitiesCurrentPage = deepComputed(() => {\n          const pagesCount =\n            pagination().total && pagination().total! > 0\n              ? Math.ceil(pagination().total! / pagination().pageSize)\n              : undefined;\n          return {\n            entities: entitiesCurrentPageList(),\n            pageIndex: pagination().currentPage,\n            total: pagination().total,\n            pageSize: pagination().pageSize,\n            pagesCount,\n            hasPrevious: pagination().currentPage - 1 >= 0,\n            hasNext:\n              pagesCount && pagination().total && pagination().total! > 0\n                ? pagination().currentPage + 1 < pagesCount\n                : true,\n            isLoading:\n              loading() &&\n              pagination().requestPage === pagination().currentPage,\n          };\n        });\n        const entitiesPagedRequest = computed(() => ({\n          startIndex: pagination().pageSize * pagination().requestPage,\n          size: pagination().pageSize * pagination().pagesToCache,\n          page: pagination().requestPage,\n        }));\n        return {\n          [entitiesCurrentPageKey]: entitiesCurrentPage,\n          [entitiesPagedRequestKey]: entitiesPagedRequest,\n        };\n      }),\n      withEventHandler((state) => [\n        onEvent(entitiesFilterChanged, entitiesRemoteSortChanged, () => {\n          clearEntitiesCache(state, config);\n        }),\n      ]),\n      withMethods((state: Record<string, Signal<unknown>>) => {\n        const pagination = state[paginationKey] as Signal<PaginationState>;\n        const entitiesList = state[entitiesKey] as Signal<Entity[]>;\n        const isLoading = state[loadingKey] as Signal<boolean>;\n        const $loading = toObservable(isLoading);\n        const setLoading = state[setLoadingKey] as () => void;\n\n        const loadPage = ({\n          pageIndex,\n          forceLoad,\n          pageSize,\n          skipLoadingCall,\n        }: {\n          pageIndex: number;\n          forceLoad: boolean;\n          pageSize?: number;\n          skipLoadingCall?: boolean;\n        }) => {\n          const size = pageSize ?? pagination().pageSize;\n          if (size !== pagination().pageSize)\n            clearEntitiesCache(state, config, size);\n          else {\n            patchState(state as WritableStateSource<object>, {\n              [paginationKey]: {\n                ...pagination(),\n                currentPage: pageIndex,\n                pageSize: size,\n                requestPage: pageIndex,\n              },\n            });\n          }\n\n          if (\n            isEntitiesInCache({\n              page: pageIndex,\n              pagination: pagination(),\n            }) &&\n            !forceLoad\n          ) {\n            if (\n              !isEntitiesInCache({\n                page: pageIndex + 1,\n                pagination: pagination(),\n              })\n            ) {\n              // preload next page\n              patchState(state as WritableStateSource<object>, {\n                [paginationKey]: {\n                  ...pagination(),\n                  currentPage: pageIndex,\n                  requestPage: pageIndex + 1,\n                },\n              });\n\n              if (!skipLoadingCall) setLoading();\n            }\n            broadcast(\n              state,\n              entitiesRemotePageChanged({\n                pageIndex: pagination().currentPage,\n                isPageInCache: true,\n              }),\n            );\n            return;\n          }\n          if (!skipLoadingCall) setLoading();\n\n          broadcast(\n            state,\n            entitiesRemotePageChanged({\n              pageIndex: pagination().currentPage,\n              isPageInCache: false,\n            }),\n          );\n        };\n        return {\n          [setEntitiesPagedResultKey]: ({\n            entities,\n            total,\n          }: {\n            entities: Entity[];\n            total: number;\n          }) => {\n            const isPreloadNextPagesReady =\n              pagination().currentPage + 1 === pagination().requestPage;\n\n            const newStart = pagination().currentPage * pagination().pageSize;\n            const newEntities = isPreloadNextPagesReady\n              ? [...entitiesList(), ...entities]\n              : entities;\n            patchState(\n              state as WritableStateSource<object>,\n              config.collection\n                ? setAllEntities(newEntities, {\n                    collection: config.collection,\n                    selectId:\n                      config.selectId ?? ((entity) => (entity as any).id),\n                  })\n                : setAllEntities(newEntities, {\n                    selectId:\n                      config.selectId ?? ((entity) => (entity as any).id),\n                  }),\n              {\n                [paginationKey]: {\n                  ...pagination(),\n                  total,\n                  cache: {\n                    ...pagination().cache,\n                    start: isPreloadNextPagesReady\n                      ? pagination().cache.start\n                      : newStart,\n                    end: isPreloadNextPagesReady\n                      ? pagination().cache.end + entities.length - 1\n                      : newStart + entities.length - 1,\n                  },\n                },\n              },\n            );\n            broadcast(state, entitiesPagedResultsLoaded());\n          },\n          [loadEntitiesPageKey]: rxMethod<{\n            pageIndex: number;\n            pageSize?: number;\n            forceLoad?: boolean;\n            skipLoadingCall?: boolean;\n          }>(\n            pipe(\n              distinctUntilChanged(\n                (previous, current) =>\n                  !current.forceLoad &&\n                  pagination().currentPage === current.pageIndex &&\n                  pagination().pageSize === current.pageSize,\n              ),\n              exhaustMap(\n                ({ pageIndex, forceLoad, pageSize, skipLoadingCall }) => {\n                  if (forceLoad) {\n                    loadPage({\n                      pageIndex,\n                      forceLoad: true,\n                      pageSize,\n                      skipLoadingCall,\n                    });\n                    return EMPTY;\n                  }\n                  return $loading.pipe(\n                    first((loading) => !loading),\n                    tap(() =>\n                      loadPage({\n                        pageIndex,\n                        forceLoad: false,\n                        pageSize,\n                        skipLoadingCall,\n                      }),\n                    ),\n                    // the exhaustMap to not loading ensures the function\n                    // can not be called multiple time before results are loaded, which could corrupt the cache\n                  );\n                },\n              ),\n            ),\n          ),\n        };\n      }),\n    );\n  }) as any;\n}\n\nfunction clearEntitiesCache<Entity>(\n  state: Record<string, Signal<unknown>>,\n  config: { collection?: string },\n  pageSize?: number,\n) {\n  const { paginationKey } = getWithEntitiesRemotePaginationKeys(config);\n  const pagination = state[paginationKey] as Signal<PaginationState>;\n  patchState(\n    state as WritableStateSource<object>,\n    config.collection\n      ? setAllEntities([], {\n          collection: config.collection,\n        })\n      : setAllEntities([]),\n    {\n      [paginationKey]: {\n        ...pagination(),\n        pageSize: pageSize ?? pagination().pageSize,\n        total: 0,\n        cache: { start: 0, end: 0 },\n        currentPage: 0,\n        requestPage: 0,\n      },\n    },\n  );\n}\n\nfunction isEntitiesInCache(\n  options:\n    | {\n        page: number;\n        pagination: EntitiesPaginationRemoteState['entitiesPagination'];\n      }\n    | {\n        start: number;\n        end: number;\n        pagination: EntitiesPaginationRemoteState['entitiesPagination'];\n      },\n) {\n  const pagination = options.pagination;\n  const startIndex =\n    'start' in options ? options.start : options.page * pagination.pageSize;\n  let endIndex =\n    'end' in options ? options.end : startIndex + pagination.pageSize - 1;\n  endIndex =\n    pagination.total && endIndex > pagination.total\n      ? pagination.total - 1\n      : endIndex;\n  return (\n    startIndex >= pagination.cache.start && endIndex <= pagination.cache.end\n  );\n}\n","import { capitalize } from '../util';\nimport { createEvent } from '../with-event-handler/with-event-handler.util';\n\nexport function getWithEntitiesInfinitePaginationKeys(config?: {\n  collection?: string;\n}) {\n  const collection = config?.collection;\n  const capitalizedProp = collection && capitalize(collection);\n  return {\n    paginationKey: collection ? `${config.collection}EntitiesPagination` : 'pagination',\n    entitiesCurrentPageKey: collection\n      ? `${config.collection}EntitiesCurrentPage`\n      : 'entitiesCurrentPage',\n    entitiesPagedRequestKey: collection\n      ? `${config.collection}EntitiesPagedRequest`\n      : 'entitiesPagedRequest',\n    loadMoreEntitiesKey: collection\n      ? `loadMore${capitalizedProp}Entities`\n      : 'loadMoreEntities',\n    loadEntitiesNextPageKey: collection\n      ? `load${capitalizedProp}EntitiesNextPage`\n      : 'loadEntitiesNextPage',\n    loadEntitiesPreviousPageKey: collection\n      ? `load${capitalizedProp}EntitiesPreviousPage`\n      : 'loadEntitiesPreviousPage',\n    loadEntitiesFirstPageKey: collection\n      ? `load${capitalizedProp}EntitiesFirstPage`\n      : 'loadEntitiesFirstPage',\n    setEntitiesPagedResultKey: collection\n      ? `set${capitalizedProp}EntitiesPagedResult`\n      : 'setEntitiesPagedResult',\n  };\n}\n\nexport function getWithEntitiesScrollPaginationEvents(config?: {\n  collection?: string;\n}) {\n  const collection = config?.collection;\n  return {\n    loadingMoreEntities: createEvent(`${collection}.loadingMoreEntities`),\n    entitiesResultsLoaded: createEvent(`${collection}.entitiesResultsLoaded`),\n  };\n}\n","import { computed, Signal } from '@angular/core';\nimport { toObservable } from '@angular/core/rxjs-interop';\nimport {\n  deepComputed,\n  patchState,\n  signalStoreFeature,\n  SignalStoreFeature,\n  SignalStoreFeatureResult,\n  withComputed,\n  withMethods,\n  withState,\n  WritableStateSource,\n} from '@ngrx/signals';\nimport {\n  addEntities,\n  SelectEntityId,\n  setAllEntities,\n} from '@ngrx/signals/entities';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport { exhaustMap, first, pipe, tap } from 'rxjs';\n\nimport {\n  RequireEntities,\n  RequireEntitiesCallStatus,\n} from '../feature-requirements.model';\nimport { getWithEntitiesKeys } from '../util';\nimport { getWithCallStatusKeys } from '../with-call-status/with-call-status.util';\nimport { getWithEntitiesFilterEvents } from '../with-entities-filter/with-entities-filter.util';\nimport { getWithEntitiesRemoteSortEvents } from '../with-entities-sort/with-entities-remote-sort.util';\nimport {\n  broadcast,\n  onEvent,\n  withEventHandler,\n} from '../with-event-handler/with-event-handler';\nimport { withFeatureFactory } from '../with-feature-factory/with-feature-factory';\nimport {\n  FeatureConfigFactory,\n  getFeatureConfig,\n  StoreSource,\n} from '../with-feature-factory/with-feature-factory.model';\nimport {\n  EntitiesScrollPaginationComputed,\n  EntitiesScrollPaginationMethods,\n  EntitiesScrollPaginationState,\n  NamedEntitiesScrollPaginationComputed,\n  NamedEntitiesScrollPaginationMethods,\n  NamedEntitiesScrollPaginationState,\n  ScrollPaginationState,\n} from './with-entities-remote-scroll-pagination.model';\nimport {\n  getWithEntitiesInfinitePaginationKeys,\n  getWithEntitiesScrollPaginationEvents,\n} from './with-entities-remote-scroll-pagination.util';\n\n/**\n * Generates necessary state, computed and methods for remote infinite scroll pagination of entities in the store.\n * This is ideal for implementing infinite scroll where the entities cache keeps growing, or for a paginated list that only\n * allows going to the next and previous page because you dont know the total number of entities\n * probably because the data is top big and partitioned in multiple nodes.\n *\n * When the page changes, it will try to load the current page from cache if it's not present,\n * it will call set[Collection]Loading(), and you should either create an effect that listens to is[Collection]Loading\n * and call the api with the [Collection]PagedRequest params and use set[Collection]Result to set the result\n * and changing the status errors manually\n * or use withEntitiesLoadingCall to call the api with the [Collection]PagedRequest params which handles setting\n * the result and errors automatically. Requires withEntities and withCallStatus to be used.\n *\n * The generated set[Collection]Result method will append the entities to the cache of entities,\n * it requires either just set of requested entities set[Collection]Result({ entities }) in which case it will assume there is no more result if you set less entities\n * than the requested buffer size, or you can provide an extra param to the entities, total set[Collection]Result({ entities, total }) so it calculates if there is more\n * or a hasMore param set[Collection]Result({entities, hasMore}) that you can set to false to indicate the end of the entities.\n *\n * Requires withEntities and withCallStatus to be present in the store.\n * @param configFactory - The configuration object for the feature or a factory function that receives the store and returns the configuration object\n * @param configFactory.pageSize - The number of entities to show per page\n * @param configFactory.pagesToCache - The number of pages to cache\n * @param configFactory.entity - The entity type\n * @param configFactory.collection - The name of the collection\n *\n * @example\n * const entity = type<Product>();\n * const collection = 'product';\n * export const store = signalStore(\n *   { providedIn: 'root' },\n *   // required withEntities and withCallStatus\n *   withEntities({ entity, collection }),\n *   withCallStatus({ collection, initialValue: 'loading' }),\n *\n *   withEntitiesRemoteScrollPagination({\n *     entity,\n *     collection,\n *     pageSize: 5,\n *     pagesToCache: 2,\n *   })\n *   // after you can use withEntitiesLoadingCall to connect the filter to\n *   // the api call, or do it manually as shown after\n *    withEntitiesLoadingCall({\n *     collection,\n *     fetchEntities: ({ productPagedRequest }) => {\n *       return inject(ProductService)\n *         .getProducts({\n *           take: productPagedRequest().size,\n *           skip: productPagedRequest().startIndex,\n *         }).pipe(\n *           map((d) => ({\n *             entities: d.resultList,\n *             total: d.total,\n *           })),\n *         )\n *     },\n *   }),\n * // withEntitiesLoadingCall is the same as doing the following:\n * // withHooks(({ productEntitiesCallStatus, setProductEntitiesError, setProductPagedResult, ...state }) => ({\n * //   onInit: async () => {\n * //     effect(() => {\n * //       if (isProductEntitiesLoading()) {\n * //         inject(ProductService)\n * //             .getProducts({\n * //                take: productPagedRequest().size,\n * //                skip: productPagedRequest().startIndex,\n * //              })\n * //           .pipe(\n * //             takeUntilDestroyed(),\n * //             tap((res) =>\n * //                 // total is not required, you can use hasMore or none see docs\n * //                 setProductPagedResult({ entities: res.resultList, total: res.total } )\n * //             ),\n * //             catchError((error) => {\n * //               setProductEntitiesError(error);\n * //               return EMPTY;\n * //             }),\n * //           )\n * //           .subscribe();\n * //       }\n * //     });\n * //   },\n *  })),\n *\n *  // in your component add\n *  store = inject(ProductsRemoteStore);\n *  dataSource = getInfiniteScrollDataSource(store, { collection: 'product' }) // pass this to your cdkVirtualFor see examples section\n *   // generates the following signals\n *   store.productEntitiesPagination // { currentPage: number,  pageSize: number,  pagesToCache: number, hasMore: boolean } used internally\n *  // generates the following computed signals\n *  store.productEntitiesCurrentPage // {  entities: Entity[], pageIndex: number, total: number, pageSize: number,  hasPrevious: boolean, hasNext: boolean, isLoading: boolean }\n *  store.productEntitiesPagedRequest // { startIndex: number, size: number }\n *  // generates the following methods\n *  store.loadProductEntitiesNextPage() // loads next page\n *  store.loadProductEntitiesPreviousPage() // loads previous page\n *  store.loadProductEntitiesFirstPage() // loads first page\n *  store.loadMoreProductEntities() // loads more entities (used for infinite scroll datasource)\n *  store.setProductEntitiesPagedResult(entities: Product[], total: number) // appends the entities to the cache of entities and total\n */\nexport function withEntitiesRemoteScrollPagination<\n  Input extends SignalStoreFeatureResult,\n  Entity,\n  Collection extends string = '',\n>(\n  configFactory: FeatureConfigFactory<\n    Input,\n    {\n      entity: Entity;\n      collection?: Collection;\n      pageSize?: number;\n      pagesToCache?: number;\n      selectId?: SelectEntityId<Entity>;\n    }\n  >,\n): SignalStoreFeature<\n  Input &\n    RequireEntities<\n      Input,\n      Entity,\n      Collection,\n      'withEntitiesRemoteScrollPagination'\n    > &\n    RequireEntitiesCallStatus<\n      Input,\n      Collection,\n      'withEntitiesRemoteScrollPagination'\n    >,\n  Collection extends ''\n    ? {\n        state: EntitiesScrollPaginationState;\n        props: EntitiesScrollPaginationComputed<Entity>;\n        methods: EntitiesScrollPaginationMethods<Entity>;\n      }\n    : {\n        state: NamedEntitiesScrollPaginationState<Collection>;\n        props: NamedEntitiesScrollPaginationComputed<Entity, Collection>;\n        methods: NamedEntitiesScrollPaginationMethods<Entity, Collection>;\n      }\n> {\n  return withFeatureFactory((store: StoreSource<Input>) => {\n    const {\n      pageSize = 10,\n      pagesToCache = 3,\n      ...config\n    } = getFeatureConfig(configFactory, store);\n    const { loadingKey, setLoadingKey } = getWithCallStatusKeys({\n      collection: config.collection,\n    });\n    const { entitiesKey } = getWithEntitiesKeys(config);\n\n    const {\n      loadMoreEntitiesKey,\n      setEntitiesPagedResultKey,\n      entitiesPagedRequestKey,\n      paginationKey,\n      loadEntitiesNextPageKey,\n      loadEntitiesPreviousPageKey,\n      loadEntitiesFirstPageKey,\n      entitiesCurrentPageKey,\n    } = getWithEntitiesInfinitePaginationKeys(config);\n\n    const { loadingMoreEntities, entitiesResultsLoaded } =\n      getWithEntitiesScrollPaginationEvents(config);\n    const { entitiesFilterChanged } = getWithEntitiesFilterEvents(config);\n    const { entitiesRemoteSortChanged } =\n      getWithEntitiesRemoteSortEvents(config);\n\n    return signalStoreFeature(\n      withState({\n        [paginationKey]: {\n          pageSize,\n          pagesToCache,\n          currentPage: 0,\n          requestPage: 0,\n          hasMore: true,\n        },\n      }),\n      withComputed((state: Record<string, Signal<unknown>>) => {\n        const entities = state[entitiesKey] as Signal<Entity[]>;\n        const loading = state[loadingKey] as Signal<boolean>;\n        const pagination = state[\n          paginationKey\n        ] as Signal<ScrollPaginationState>;\n\n        const entitiesPagedRequest = deepComputed(() => ({\n          startIndex: entities().length,\n          size: pagination().pageSize * pagination().pagesToCache,\n        }));\n\n        const entitiesCurrentPageList = computed(() => {\n          const page = pagination().currentPage;\n          const startIndex = page * pagination().pageSize;\n          let endIndex = startIndex + pagination().pageSize;\n          endIndex =\n            endIndex < entities().length ? endIndex : entities().length;\n          return entities().slice(startIndex, endIndex);\n        });\n\n        const entitiesCurrentPage = deepComputed(() => {\n          return {\n            entities: entitiesCurrentPageList(),\n            pageIndex: pagination().currentPage,\n            pageSize: pagination().pageSize,\n            hasPrevious: pagination().currentPage - 1 >= 0,\n            hasNext:\n              isEntitiesInCache({\n                page: pagination().currentPage + 1,\n                pagination: pagination(),\n                cacheTotal: entities().length,\n              }) || pagination().hasMore,\n            isLoading:\n              loading() &&\n              pagination().requestPage === pagination().currentPage,\n          };\n        });\n\n        return {\n          [entitiesCurrentPageKey]: entitiesCurrentPage,\n          [entitiesPagedRequestKey]: entitiesPagedRequest,\n        };\n      }),\n      withEventHandler((state) => [\n        onEvent(entitiesFilterChanged, entitiesRemoteSortChanged, () => {\n          clearEntitiesCache(state, config, paginationKey);\n        }),\n      ]),\n      withMethods((state: Record<string, Signal<unknown>>) => {\n        const pagination = state[\n          paginationKey\n        ] as Signal<ScrollPaginationState>;\n        const isLoading = state[loadingKey] as Signal<boolean>;\n        const $loading = toObservable(isLoading);\n        const setLoading = state[setLoadingKey] as () => void;\n        const entities = state[entitiesKey] as Signal<Entity[]>;\n\n        return {\n          [loadEntitiesFirstPageKey]: () => {\n            patchState(state as WritableStateSource<object>, {\n              [paginationKey]: {\n                ...pagination(),\n                currentPage: 0,\n                requestPage: 0,\n              },\n            });\n          },\n          [loadEntitiesPreviousPageKey]: () => {\n            const currentPage = pagination().currentPage;\n            if (currentPage > 0) {\n              patchState(state as WritableStateSource<object>, {\n                [paginationKey]: {\n                  ...pagination(),\n                  currentPage: currentPage - 1,\n                  requestPage: currentPage - 1,\n                },\n              });\n            }\n          },\n          [loadEntitiesNextPageKey]: rxMethod<void>(\n            pipe(\n              exhaustMap(() =>\n                $loading.pipe(\n                  first((loading) => !loading),\n                  // the previous exhaustMap to not loading ensures the function\n                  // can not be called multiple time before results are loaded, which could corrupt the cache\n                  tap(() => {\n                    const currentPage = pagination().currentPage;\n                    const nextPage = currentPage + 1;\n                    if (\n                      isEntitiesInCache({\n                        page: nextPage,\n                        pagination: pagination(),\n                        cacheTotal: entities().length,\n                      })\n                    ) {\n                      patchState(state as WritableStateSource<object>, {\n                        [paginationKey]: {\n                          ...pagination(),\n                          currentPage: nextPage,\n                        },\n                      });\n\n                      if (\n                        !isEntitiesInCache({\n                          page: nextPage + 1,\n                          pagination: pagination(),\n                          cacheTotal: entities().length,\n                        })\n                      ) {\n                        // preload next page\n                        patchState(state as WritableStateSource<object>, {\n                          [paginationKey]: {\n                            ...pagination(),\n                            currentPage: nextPage,\n                            requestPage: nextPage + 1,\n                          },\n                        });\n                        setLoading();\n                        broadcast(state, loadingMoreEntities());\n                      }\n                    } else if (pagination().hasMore) {\n                      patchState(state as WritableStateSource<object>, {\n                        [paginationKey]: {\n                          ...pagination(),\n                          currentPage: nextPage,\n                        },\n                      });\n                      setLoading();\n                      broadcast(state, loadingMoreEntities());\n                    }\n                  }),\n                ),\n              ),\n            ),\n          ),\n          [setEntitiesPagedResultKey]: (\n            options:\n              | {\n                  entities: Entity[];\n                  total: number;\n                }\n              | {\n                  entities: Entity[];\n                  hasMore: boolean;\n                }\n              | {\n                  entities: Entity[];\n                },\n          ) => {\n            const entities = options.entities;\n            const entitiesOld = state[entitiesKey] as Signal<Entity[]>;\n            patchState(\n              state as WritableStateSource<object>,\n              config.collection\n                ? addEntities(entities, {\n                    collection: config.collection,\n                    selectId:\n                      config.selectId ?? ((entity) => (entity as any).id),\n                  })\n                : addEntities(entities, {\n                    selectId:\n                      config.selectId ?? ((entity) => (entity as any).id),\n                  }),\n              {\n                [paginationKey]: {\n                  ...pagination(),\n                  hasMore:\n                    'hasMore' in options\n                      ? options.hasMore\n                      : 'total' in options\n                        ? entitiesOld().length + entities.length < options.total\n                        : entities.length ==\n                          pagination().pageSize * pagination().pagesToCache,\n                },\n              },\n            );\n            broadcast(state, entitiesResultsLoaded());\n          },\n          [loadMoreEntitiesKey]: rxMethod<void>(\n            pipe(\n              exhaustMap(() =>\n                $loading.pipe(\n                  first((loading) => !loading),\n                  // the previous exhaustMap to not loading ensures the function\n                  // can not be called multiple time before results are loaded, which could corrupt the cache\n                  tap(() => {\n                    if (pagination().hasMore) {\n                      setLoading();\n                      broadcast(state, loadingMoreEntities());\n                    }\n                  }),\n                ),\n              ),\n            ),\n          ),\n        };\n      }),\n    );\n  }) as any;\n}\n\nfunction clearEntitiesCache(\n  state: Record<string, Signal<unknown>>,\n  config: { collection?: string },\n  paginationKey: string,\n) {\n  const pagination = state[paginationKey] as Signal<ScrollPaginationState>;\n  patchState(\n    state as WritableStateSource<object>,\n    config.collection\n      ? setAllEntities([], {\n          collection: config.collection,\n        })\n      : setAllEntities([]),\n    {\n      [paginationKey]: {\n        ...pagination(),\n        total: 0,\n        hasMore: true,\n        currentPage: 0,\n        requestPage: 0,\n      },\n    },\n  );\n}\n\nfunction isEntitiesInCache(options: {\n  page: number;\n  pagination: EntitiesScrollPaginationState['pagination'];\n  cacheTotal: number;\n}) {\n  const pagination = options.pagination;\n  const startIndex = options.page * pagination.pageSize;\n  const endIndex = startIndex + pagination.pageSize - 1;\n  return (\n    endIndex <= options.cacheTotal ||\n    (!pagination.hasMore && startIndex <= options.cacheTotal) // check for last page\n  );\n}\n","import { CollectionViewer, DataSource } from '@angular/cdk/collections';\nimport { Signal } from '@angular/core';\nimport { toObservable } from '@angular/core/rxjs-interop';\nimport { EntityProps, NamedEntityProps } from '@ngrx/signals/entities';\nimport { debounceTime, Observable, Subscription } from 'rxjs';\nimport { filter } from 'rxjs/operators';\n\nimport { getWithEntitiesKeys } from '../util';\nimport {\n  EntitiesScrollPaginationMethods,\n  NamedEntitiesScrollPaginationMethods,\n  ScrollPaginationState,\n} from './with-entities-remote-scroll-pagination.model';\nimport { getWithEntitiesInfinitePaginationKeys } from './with-entities-remote-scroll-pagination.util';\n\nexport function getInfiniteScrollDataSource<Entity, Collection extends string>(\n  options:\n    | {\n        store: EntityProps<Entity> & EntitiesScrollPaginationMethods<Entity>;\n        debounceLoadMoreTime?: number;\n      }\n    | {\n        collection: Collection;\n        entity: Entity;\n        store: NamedEntityProps<Entity, Collection> &\n          NamedEntitiesScrollPaginationMethods<Entity, Collection>;\n        debounceLoadMoreTime?: number;\n      },\n) {\n  const collection = 'collection' in options ? options.collection : undefined;\n  const debounceLoadMoreTime = options.debounceLoadMoreTime ?? 300;\n  const { loadMoreEntitiesKey, paginationKey } =\n    getWithEntitiesInfinitePaginationKeys({\n      collection,\n    });\n  const { entitiesKey } = getWithEntitiesKeys({ collection });\n  const store = options.store as Record<string, unknown>;\n  const entities = store[entitiesKey] as Signal<Entity[]>;\n  const pagination = store[paginationKey] as Signal<ScrollPaginationState>;\n  const loadMoreEntities = store[loadMoreEntitiesKey] as () => void;\n\n  class MyDataSource extends DataSource<Entity> {\n    subscription?: Subscription;\n    entitiesList = toObservable(entities);\n    connect(collectionViewer: CollectionViewer): Observable<Entity[]> {\n      this.subscription = collectionViewer.viewChange\n        .pipe(\n          filter(({ end, start }) => {\n            const { pageSize, hasMore } = pagination();\n            return start != 0 && hasMore && end + pageSize >= entities().length;\n          }),\n          debounceTime(debounceLoadMoreTime),\n        )\n        .subscribe(() => {\n          loadMoreEntities();\n        });\n      return this.entitiesList;\n    }\n\n    disconnect(): void {\n      this.subscription?.unsubscribe();\n    }\n  }\n  return new MyDataSource();\n}\n","import { effect, Signal, untracked } from '@angular/core';\nimport {\n  patchState,\n  signalStoreFeature,\n  SignalStoreFeature,\n  SignalStoreFeatureResult,\n  withHooks,\n  withMethods,\n  withState,\n  WritableStateSource,\n} from '@ngrx/signals';\nimport { SelectEntityId } from '@ngrx/signals/entities';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport { isObservable, map, Observable, pipe, tap } from 'rxjs';\n\nimport { RequireEntities } from '../feature-requirements.model';\nimport { getWithEntitiesKeys } from '../util';\nimport { getWithCallStatusKeys } from '../with-call-status/with-call-status.util';\nimport { getWithEntitiesFilterEvents } from '../with-entities-filter/with-entities-filter.util';\nimport {\n  broadcast,\n  onEvent,\n  withEventHandler,\n} from '../with-event-handler/with-event-handler';\nimport { withFeatureFactory } from '../with-feature-factory/with-feature-factory';\nimport {\n  FeatureConfigFactory,\n  getFeatureConfig,\n  StoreSource,\n} from '../with-feature-factory/with-feature-factory.model';\nimport {\n  CdkSort,\n  EntitiesSortMethods,\n  EntitiesSortState,\n  NamedEntitiesSortMethods,\n  NamedEntitiesSortState,\n  Sort,\n} from './with-entities-local-sort.model';\nimport {\n  getWithEntitiesLocalSortEvents,\n  sortData,\n} from './with-entities-local-sort.util';\nimport { getWithEntitiesSortKeys } from './with-entities-sort.util';\n\nexport { sortData };\n/**\n * Generates necessary state, computed and methods for sorting locally entities in the store.\n *\n * Requires withEntities to be present before this function\n * @param configFactory - The configuration object for the feature or a factory function that receives the store and returns the configuration object\n * @param configFactory.defaultSort - The default sort to be applied to the entities\n * @param configFactory.entity - The type entity to be used\n * @param configFactory.collection - The name of the collection for which will be sorted\n * @param configFactory.selectId - The function to use to select the id of the entity\n * @param configFactory.sortFunction - Optional custom function use to sort the entities\n *\n * @example\n * const entity = type<Product>();\n * const collection = \"product\";\n * export const store = signalStore(\n *   { providedIn: 'root' },\n *   withEntities({ entity, collection }),\n *   withEntitiesLocalSort({\n *     entity,\n *     collection,\n *     defaultSort: { field: 'name', direction: 'asc' },\n *   }),\n * );\n * // generates the following signals\n * store.productEntitiesSort - the current sort applied to the products\n * // generates the following methods\n * store.sortProductEntities({ sort: { field: 'name', direction: 'asc' } }) - sorts the products entities\n */\n\nexport function withEntitiesLocalSort<\n  Input extends SignalStoreFeatureResult,\n  Entity,\n  Collection extends string = '',\n>(\n  configFactory: FeatureConfigFactory<\n    Input,\n    {\n      defaultSort: Sort<NoInfer<Entity>>;\n      entity: Entity;\n      collection?: Collection;\n      selectId?: SelectEntityId<Entity>;\n      sortFunction?: (entities: Entity[], sort: Sort<Entity>) => Entity[];\n    }\n  >,\n): SignalStoreFeature<\n  Input & RequireEntities<Input, Entity, Collection, 'withEntitiesLocalSort'>,\n  Collection extends ''\n    ? {\n        state: EntitiesSortState<Entity>;\n        props: {};\n        methods: EntitiesSortMethods<Entity>;\n      }\n    : {\n        state: NamedEntitiesSortState<Entity, Collection>;\n        props: {};\n        methods: NamedEntitiesSortMethods<Entity, Collection>;\n      }\n> {\n  return withFeatureFactory((store: StoreSource<Input>) => {\n    const { defaultSort, ...config } = getFeatureConfig(configFactory, store);\n    const { entitiesKey, idsKey } = getWithEntitiesKeys(config);\n    const { sortEntitiesKey, sortKey } = getWithEntitiesSortKeys(config);\n    const { entitiesLocalSortChanged } = getWithEntitiesLocalSortEvents(config);\n\n    return signalStoreFeature(\n      withState({ [sortKey]: defaultSort }),\n      withEventHandler(),\n      withMethods((state: Record<string, Signal<unknown>>) => {\n        const _sortEntities = rxMethod<{\n          sort?: Sort<Entity> | CdkSort<Entity>;\n          _emitEvent?: boolean;\n        }>(\n          pipe(\n            tap((options) => {\n              let newSort = options?.sort;\n              if (newSort && 'active' in newSort)\n                newSort = {\n                  field: newSort.active,\n                  direction: newSort.direction,\n                };\n              const sort = newSort ?? (state[sortKey]() as Sort<Entity>);\n              patchState(state as WritableStateSource<object>, {\n                [sortKey]: sort,\n                [idsKey]: (config?.sortFunction\n                  ? config.sortFunction(state[entitiesKey]() as Entity[], sort)\n                  : sortData(state[entitiesKey]() as Entity[], sort)\n                ).map((entity) =>\n                  config.selectId\n                    ? config.selectId(entity)\n                    : (entity as any).id,\n                ),\n              });\n              if (options?._emitEvent !== false)\n                broadcast(state, entitiesLocalSortChanged({ sort }));\n            }),\n          ),\n        );\n        function normalizeToWrapped(options: unknown): {\n          sort: Sort<Entity> | CdkSort<Entity>;\n        } {\n          if (\n            options &&\n            typeof options === 'object' &&\n            ('field' in options || 'active' in options)\n          ) {\n            return { sort: options as Sort<Entity> | CdkSort<Entity> };\n          }\n          return options as { sort: Sort<Entity> | CdkSort<Entity> };\n        }\n        return {\n          [sortEntitiesKey]: (options?: unknown) => {\n            if (isObservable(options)) {\n              return _sortEntities(\n                (options as Observable<unknown>).pipe(\n                  map((v) => normalizeToWrapped(v)),\n                ),\n              );\n            }\n            if (typeof options === 'function') {\n              return _sortEntities(() =>\n                normalizeToWrapped((options as () => unknown)()),\n              );\n            }\n            return _sortEntities(normalizeToWrapped(options));\n          },\n        };\n      }),\n      withEventHandler((state: Record<string, unknown>) => {\n        const sortEntities = state[sortEntitiesKey] as () => void;\n        const { entitiesFilterChanged } = getWithEntitiesFilterEvents(config);\n        return [onEvent(entitiesFilterChanged, () => sortEntities())];\n      }),\n      withHooks((state: Record<string, unknown>) => {\n        const { loadedKey } = getWithCallStatusKeys({\n          collection: config?.collection,\n        });\n        const loaded = state[loadedKey] as Signal<boolean> | undefined;\n        return {\n          onInit: () => {\n            if (loaded) {\n              const sortEntities = state[sortEntitiesKey] as (options?: {\n                _emitEvent?: boolean;\n              }) => void;\n              effect(() => {\n                if (loaded()) {\n                  untracked(() => {\n                    sortEntities({ _emitEvent: false });\n                  });\n                }\n              });\n            }\n          },\n        };\n      }),\n    );\n  }) as any;\n}\n","import { Signal } from '@angular/core';\nimport {\n  patchState,\n  signalStoreFeature,\n  SignalStoreFeature,\n  SignalStoreFeatureResult,\n  withMethods,\n  withState,\n  WritableStateSource,\n} from '@ngrx/signals';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport { isObservable, map, Observable, pipe, tap } from 'rxjs';\n\nimport {\n  RequireEntities,\n  RequireEntitiesCallStatus,\n} from '../feature-requirements.model';\nimport { getWithCallStatusKeys } from '../with-call-status/with-call-status.util';\nimport {\n  broadcast,\n  withEventHandler,\n} from '../with-event-handler/with-event-handler';\nimport { withFeatureFactory } from '../with-feature-factory/with-feature-factory';\nimport {\n  FeatureConfigFactory,\n  getFeatureConfig,\n  StoreSource,\n} from '../with-feature-factory/with-feature-factory.model';\nimport { CdkSort, Sort } from './with-entities-local-sort.model';\nimport {\n  EntitiesSortState,\n  NamedEntitiesSortState,\n} from './with-entities-local-sort.model';\nimport {\n  EntitiesRemoteSortMethods,\n  NamedEntitiesRemoteSortMethods,\n} from './with-entities-remote-sort.model';\nimport { getWithEntitiesRemoteSortEvents } from './with-entities-remote-sort.util';\nimport { getWithEntitiesSortKeys } from './with-entities-sort.util';\n\n/**\n * Generates state, signals, and methods to sort entities remotely. When the sort method sort[Collection]Entities is called it will store the sort\n * and call set[Collection]Loading, and you should either create an effect that listens to [Collection]Loading\n * and call the api with the [Collection]Sort params and use wither setAllEntities if is not paginated or set[Collection]Result if is paginated\n * with the sorted result that come from the backend, plus changing the status  and set errors is needed.\n * or use withEntitiesLoadingCall to call the api with the [Collection]Sort params which handles setting\n * the result and errors automatically.\n *\n *  In case you dont want sort[Collection]Entities to call set[Collection]Loading() (which triggers a fetchEntities), you can pass skipLoadingCall: true to sort[Collection]Entities.\n * Useful in cases where you want to further change the state before manually calling set[Collection]Loading() to trigger a fetch of entities.\n *\n * Requires withEntities and withCallStatus to be present before this function.\n *\n * @param configFactory - The configuration object for the feature or a factory function that receives the store and returns the configuration object\n * @param configFactory.defaultSort - The default sort to use when the store is initialized\n * @param configFactory.entity - The entity type\n * @param configFactory.collection - The collection name\n *\n * @example\n * const entity = type<Product>();\n * const collection = 'product';\n * export const store = signalStore(\n *   { providedIn: 'root' },\n *   // required withEntities and withCallStatus\n *   withEntities({ entity, collection }),\n *   withCallStatus({ collection, initialValue: 'loading' }),\n *\n *   withEntitiesRemoteSort({\n *     entity,\n *     collection,\n *     defaultSort: { field: 'name', direction: 'asc' },\n *   }),\n *   // after you can use withEntitiesLoadingCall to connect the filter to\n *   // the api call, or do it manually as shown after\n *    withEntitiesLoadingCall({\n *     collection,\n *     fetchEntities: ({ productEntitiesSort }) => {\n *       return inject(ProductService)\n *         .getProducts({\n *           sortColumn: productEntitiesSort().field,\n *           sortAscending: productEntitiesSort().direction === 'asc',\n *         })\n *     },\n *   }),\n * // withEntitiesLoadingCall is the same as doing the following:\n * // withHooks(({ productEntitiesSort, isProductEntitiesLoading, setProductEntitiesError, ...state }) => ({\n * //   onInit: async () => {\n * //     effect(() => {\n * //       if (isProductEntitiesLoading()) {\n * //         inject(ProductService)\n * //             .getProducts({\n * //                 sortColumn: productEntitiesSort().field,\n * //                 sortAscending: productEntitiesSort().direction === 'asc',\n * //              })\n * //           .pipe(\n * //             takeUntilDestroyed(),\n * //             tap((res) =>\n * //               patchState(\n * //                 state,\n * //                 setAllEntities(res.resultList, { collection: 'product' }),\n * //               ),\n * //             ),\n * //             catchError((error) => {\n * //               setProductEntitiesError(error);\n * //               return EMPTY;\n * //             }),\n * //           )\n * //           .subscribe();\n * //       }\n * //     });\n * //   },\n *  })),\n *\n * // generate the following signals\n * store.productEntitiesSort // the current sort\n * // and the following methods\n * store.sortProductEntities // (options: { sort: Sort<Entity>; , skipLoadingCall?:boolean}) => void;\n */\nexport function withEntitiesRemoteSort<\n  Input extends SignalStoreFeatureResult,\n  Entity,\n  Collection extends string = '',\n>(\n  configFactory: FeatureConfigFactory<\n    Input,\n    {\n      entity: Entity;\n      defaultSort: Sort<Entity>;\n      collection?: Collection;\n    }\n  >,\n): SignalStoreFeature<\n  Input &\n    RequireEntities<Input, Entity, Collection, 'withEntitiesRemoteSort'> &\n    RequireEntitiesCallStatus<Input, Collection, 'withEntitiesRemoteSort'>,\n  Collection extends ''\n    ? {\n        state: EntitiesSortState<Entity>;\n        props: {};\n        methods: EntitiesRemoteSortMethods<Entity>;\n      }\n    : {\n        state: NamedEntitiesSortState<Entity, Collection>;\n        props: {};\n        methods: NamedEntitiesRemoteSortMethods<Entity, Collection>;\n      }\n> {\n  return withFeatureFactory((store: StoreSource<Input>) => {\n    const { defaultSort, ...config } = getFeatureConfig(configFactory, store);\n    const { setLoadingKey } = getWithCallStatusKeys({\n      collection: config.collection,\n    });\n    const { sortKey, sortEntitiesKey } = getWithEntitiesSortKeys(config);\n    const { entitiesRemoteSortChanged } =\n      getWithEntitiesRemoteSortEvents(config);\n    return signalStoreFeature(\n      withState({ [sortKey]: defaultSort }),\n      withEventHandler(),\n      withMethods((state: Record<string, Signal<unknown>>) => {\n        const setLoading = state[setLoadingKey] as () => void;\n        const _sortEntities = rxMethod<{\n          sort?: Sort<Entity> | CdkSort<Entity>;\n          skipLoadingCall?: boolean;\n        }>(\n          pipe(\n            tap((options) => {\n              let newSort = options?.sort;\n              if (newSort && 'active' in newSort)\n                newSort = {\n                  field: newSort.active,\n                  direction: newSort.direction,\n                };\n              const skipLoadingCall = options?.skipLoadingCall;\n              const sort = newSort ?? (state[sortKey]() as Sort<Entity>);\n              patchState(state as WritableStateSource<object>, {\n                [sortKey]: sort,\n              });\n              broadcast(\n                state,\n                entitiesRemoteSortChanged({ sort, skipLoadingCall }),\n              );\n              if (!skipLoadingCall) setLoading();\n            }),\n          ),\n        );\n        function normalizeToWrapped(options: unknown): {\n          sort?: Sort<Entity> | CdkSort<Entity>;\n          skipLoadingCall?: boolean;\n        } {\n          if (\n            options &&\n            typeof options === 'object' &&\n            ('field' in options || 'active' in options)\n          ) {\n            return { sort: options as Sort<Entity> | CdkSort<Entity> };\n          }\n          return options as {\n            sort?: Sort<Entity> | CdkSort<Entity>;\n            skipLoadingCall?: boolean;\n          };\n        }\n        return {\n          [sortEntitiesKey]: (options?: unknown) => {\n            if (isObservable(options)) {\n              return _sortEntities(\n                (options as Observable<unknown>).pipe(\n                  map((v) => normalizeToWrapped(v)),\n                ),\n              );\n            }\n            if (typeof options === 'function') {\n              return _sortEntities(() =>\n                normalizeToWrapped((options as () => unknown)()),\n              );\n            }\n            return _sortEntities(normalizeToWrapped(options));\n          },\n        };\n      }),\n    );\n  }) as any;\n}\n","import { SignalStoreFeature, SignalStoreFeatureResult } from '@ngrx/signals';\n\nimport { RequireEntitiesSort } from '../feature-requirements.model';\nimport { LinkMethod, withLink } from '../with-link/with-link';\nimport {\n  EntitiesSortState,\n  NamedEntitiesSortState,\n  Sort,\n} from './with-entities-local-sort.model';\nimport { getWithEntitiesSortKeys } from './with-entities-sort.util';\n\n/**\n * Generates a `link[Collection]EntitiesSort()` method that connects the\n * entities sort to component signals (inputs, models, signal forms).\n *\n * Prebuilt version of `withLink` for `withEntitiesLocalSort` /\n * `withEntitiesRemoteSort`: writes route through `sort[Collection]Entities`\n * (so the entities are re-sorted), and syncs are guarded with a structural\n * equality on the sort, preventing echo loops.\n *\n * Requires withEntitiesLocalSort or withEntitiesRemoteSort to be used before it.\n *\n * @param config - The configuration object for the feature\n * @param config.entity - The entity type to be used\n * @param config.collection - The optional collection name to be used\n *\n * @example\n * const entity = type<Product>();\n * const store = signalStore(\n *   withEntities({ entity }),\n *   withEntitiesLocalSort({\n *     entity,\n *     defaultSort: { field: 'name', direction: 'asc' },\n *   }),\n *   withLinkEntitiesSort({ entity }),\n * );\n * // in a component:\n * // sort = model<Sort<Product>>({ field: 'name', direction: 'asc' });\n * // linked = this.store.linkEntitiesSort({ syncWith: this.sort });\n */\nexport function withLinkEntitiesSort<\n  Input extends SignalStoreFeatureResult,\n  Entity,\n  Collection extends string = '',\n>(config?: {\n  entity?: Entity;\n  collection?: Collection;\n}): SignalStoreFeature<\n  Input &\n    RequireEntitiesSort<\n      Input,\n      Collection,\n      'withLinkEntitiesSort',\n      Collection extends ''\n        ? { state: EntitiesSortState<Entity>; props: {}; methods: {} }\n        : {\n            state: NamedEntitiesSortState<Entity, Collection>;\n            props: {};\n            methods: {};\n          }\n    >,\n  {\n    state: {};\n    props: {};\n    methods: {\n      [P in Collection extends ''\n        ? 'entitiesSort'\n        : `${Collection}EntitiesSort` as `link${Capitalize<\n        string & P\n      >}`]: LinkMethod<Sort<Entity>>;\n    };\n  }\n> {\n  const { sortKey, sortEntitiesKey } = getWithEntitiesSortKeys(config);\n  return withLink(sortKey, {\n    set: (value: Sort<any>, store: any) => {\n      (store[sortEntitiesKey] as (options: { sort: Sort<any> }) => void)({\n        sort: value,\n      });\n    },\n    equal: (a: Sort<any>, b: Sort<any>) =>\n      a === b ||\n      (!!a && !!b && a.field === b.field && a.direction === b.direction),\n    // the store already exposes sort[Collection]Entities for this write\n    noSetter: true,\n  } as any) as any;\n}\n","import { computed, Signal } from '@angular/core';\n\nimport { capitalize } from '../util';\nimport { getWithCallStatusKeys } from '../with-call-status/with-call-status.util';\nimport { QueryMapper } from '../with-sync-to-route-query-params/with-sync-to-route-query-params.util';\nimport {\n  EntitiesSingleSelectionMethods,\n  EntitiesSingleSelectionState,\n} from './with-entities-single-selection.model';\n\nexport function getEntitiesSingleSelectionKeys(config?: {\n  collection?: string;\n}) {\n  const collection = config?.collection;\n  const capitalizedProp = collection && capitalize(collection);\n  return {\n    selectedIdKey: collection ? `${config.collection}IdSelected` : 'idSelected',\n    selectedEntityKey: collection\n      ? `${config.collection}EntitySelected`\n      : 'entitySelected',\n    selectEntityKey: collection\n      ? `select${capitalizedProp}Entity`\n      : 'selectEntity',\n    deselectEntityKey: collection\n      ? `deselect${capitalizedProp}Entity`\n      : 'deselectEntity',\n    toggleEntityKey: collection\n      ? `toggleSelect${capitalizedProp}Entity`\n      : 'toggleSelectEntity',\n  };\n}\n\nexport function getQueryMapperForSingleSelection(config?: {\n  collection?: string;\n}): QueryMapper<{\n  selectedId: string | number | undefined;\n}> {\n  const { selectedIdKey, selectEntityKey } =\n    getEntitiesSingleSelectionKeys(config);\n  const { loadingKey, loadedKey } = getWithCallStatusKeys({\n    collection: config?.collection,\n  });\n  return {\n    queryParamsToState: (query, store) => {\n      const selectedId = query.selectedId;\n      if (selectedId) {\n        const selectEntity = store[\n          selectEntityKey\n        ] as EntitiesSingleSelectionMethods['selectEntity'];\n\n        selectEntity({\n          id: selectedId,\n        });\n      }\n    },\n    stateToQueryParams: (store) => {\n      const selectedId = store[selectedIdKey] as Signal<\n        EntitiesSingleSelectionState['idSelected']\n      >;\n      return selectedId\n        ? computed(() => ({\n            selectedId: selectedId(),\n          }))\n        : undefined;\n    },\n  };\n}\n","import { computed, Signal } from '@angular/core';\nimport {\n  patchState,\n  signalStoreFeature,\n  SignalStoreFeature,\n  SignalStoreFeatureResult,\n  withComputed,\n  withMethods,\n  withState,\n  WritableStateSource,\n} from '@ngrx/signals';\nimport { EntityMap } from '@ngrx/signals/entities';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport { pipe, tap } from 'rxjs';\n\nimport { RequireEntities } from '../feature-requirements.model';\nimport { getWithEntitiesKeys } from '../util';\nimport { getWithEntitiesFilterEvents } from '../with-entities-filter/with-entities-filter.util';\nimport { getWithEntitiesRemoteSortEvents } from '../with-entities-sort/with-entities-remote-sort.util';\nimport {\n  onEvent,\n  withEventHandler,\n} from '../with-event-handler/with-event-handler';\nimport { withFeatureFactory } from '../with-feature-factory/with-feature-factory';\nimport {\n  FeatureConfigFactory,\n  getFeatureConfig,\n  StoreSource,\n} from '../with-feature-factory/with-feature-factory.model';\nimport {\n  EntitiesSingleSelectionComputed,\n  EntitiesSingleSelectionMethods,\n  EntitiesSingleSelectionState,\n  NamedEntitiesSingleSelectionComputed,\n  NamedEntitiesSingleSelectionMethods,\n  NamedEntitiesSingleSelectionState,\n} from './with-entities-single-selection.model';\nimport { getEntitiesSingleSelectionKeys } from './with-entities-single-selection.util';\n\n/**\n * Generates state, computed and methods for single selection of entities.\n *\n * Requires withEntities to be present before this function.\n * @param configFactory - The configuration object for the feature or a factory function that receives the store and returns the configuration object\n * @param configFactory.collection - The collection name\n * @param configFactory.entity - The entity type\n * @param configFactory.clearOnFilter - Clear the selected entity when the filter changes (default: true)\n * @param configFactory.clearOnRemoteSort - Clear the selected entity when the remote sort changes (default: true)\n * @example\n * const entity = type<Product>();\n * const collection = \"product\";\n * export const store = signalStore(\n *   { providedIn: 'root' },\n *   // Required withEntities and withCallStatus\n *   withEntities({ entity, collection }),\n *   withCallStatus({ prop: collection, initialValue: 'loading' }),\n *\n *   withEntitiesSingleSelection({\n *     entity,\n *     collection,\n *   }),\n *  );\n *\n *  // generates the following signals\n *  store.productIdSelected // string | number | undefined\n *  // generates the following computed signals\n *  store.productEntitySelected // Entity | undefined\n *  // generates the following methods\n *  store.selectProductEntity // (config: { id: string | number }) => void\n *  store.deselectProductEntity // (config: { id: string | number }) => void\n *  store.toggleProductEntity // (config: { id: string | number }) => void\n */\n\nexport function withEntitiesSingleSelection<\n  Input extends SignalStoreFeatureResult,\n  Entity,\n  Collection extends string = '',\n>(\n  configFactory: FeatureConfigFactory<\n    Input,\n    {\n      entity: Entity;\n      collection?: Collection;\n      clearOnFilter?: boolean;\n      clearOnRemoteSort?: boolean;\n      defaultSelectedId?: string | number;\n    }\n  >,\n): SignalStoreFeature<\n  Input &\n    RequireEntities<Input, Entity, Collection, 'withEntitiesSingleSelection'>,\n  Collection extends ''\n    ? {\n        state: EntitiesSingleSelectionState;\n        props: EntitiesSingleSelectionComputed<Entity>;\n        methods: EntitiesSingleSelectionMethods;\n      }\n    : {\n        state: NamedEntitiesSingleSelectionState<Collection>;\n        props: NamedEntitiesSingleSelectionComputed<Entity, Collection>;\n        methods: NamedEntitiesSingleSelectionMethods<Collection>;\n      }\n> {\n  return withFeatureFactory((store: StoreSource<Input>) => {\n    const config = getFeatureConfig(configFactory, store);\n    const { entityMapKey } = getWithEntitiesKeys(config);\n    const {\n      selectedEntityKey,\n      selectEntityKey,\n      deselectEntityKey,\n      toggleEntityKey,\n      selectedIdKey,\n    } = getEntitiesSingleSelectionKeys(config);\n\n    const { entitiesFilterChanged } = getWithEntitiesFilterEvents(config);\n    const { entitiesRemoteSortChanged } =\n      getWithEntitiesRemoteSortEvents(config);\n\n    return signalStoreFeature(\n      withState({ [selectedIdKey]: config.defaultSelectedId }),\n      withComputed((state: Record<string, Signal<unknown>>) => {\n        const entityMap = state[entityMapKey] as Signal<EntityMap<Entity>>;\n        const selectedId = state[selectedIdKey] as Signal<\n          string | number | undefined\n        >;\n        return {\n          [selectedEntityKey]: computed(() => {\n            const id = selectedId();\n            return id ? entityMap()[id] : undefined;\n          }),\n        };\n      }),\n      withMethods((state: Record<string, Signal<unknown>>) => {\n        const entityMap = state[entityMapKey] as Signal<EntityMap<Entity>>;\n        const selectedId = state[selectedIdKey] as Signal<\n          string | number | undefined\n        >;\n        const deselectEntity = () => {\n          patchState(state as WritableStateSource<object>, {\n            [selectedIdKey]: undefined,\n          });\n        };\n        return {\n          [selectEntityKey]: rxMethod<{ id: string | number } | undefined>(\n            pipe(\n              tap((item) => {\n                if (!item) {\n                  deselectEntity();\n                  return;\n                }\n                patchState(state as WritableStateSource<object>, {\n                  [selectedIdKey]: item.id,\n                });\n              }),\n            ),\n          ),\n          [deselectEntityKey]: deselectEntity,\n          [toggleEntityKey]: rxMethod<{ id: string | number } | undefined>(\n            pipe(\n              tap((item) => {\n                if (!item) {\n                  deselectEntity();\n                  return;\n                }\n                patchState(state as WritableStateSource<object>, {\n                  [selectedIdKey]:\n                    selectedId() === item.id ? undefined : item.id,\n                });\n              }),\n            ),\n          ),\n        };\n      }),\n      withEventHandler((state) => {\n        const clearOnFilter = config?.clearOnFilter ?? true;\n        const clearOnRemoteSort = config?.clearOnRemoteSort ?? true;\n        const events = [];\n        if (clearOnFilter) {\n          events.push(\n            onEvent(entitiesFilterChanged, () => {\n              const deselectEntity = state[deselectEntityKey] as () => void;\n              deselectEntity();\n            }),\n          );\n        }\n        if (clearOnRemoteSort) {\n          events.push(\n            onEvent(entitiesRemoteSortChanged, () => {\n              const deselectEntity = state[deselectEntityKey] as () => void;\n              deselectEntity();\n            }),\n          );\n        }\n        return events;\n      }),\n    );\n  }) as any;\n}\n","import { computed, Signal } from '@angular/core';\n\nimport { capitalize } from '../util';\nimport { getWithCallStatusKeys } from '../with-call-status/with-call-status.util';\nimport { QueryMapper } from '../with-sync-to-route-query-params/with-sync-to-route-query-params.util';\nimport { EntitiesMultiSelectionMethods } from './with-entities-multi-selection.model';\n\nexport function getEntitiesMultiSelectionKeys(config?: {\n  collection?: string;\n}) {\n  const collection = config?.collection;\n  const capitalizedProp = collection && capitalize(collection);\n  return {\n    selectedIdsMapKey: collection\n      ? `${config.collection}IdsSelectedMap`\n      : 'idsSelectedMap',\n    selectedEntitiesKey: collection\n      ? `${config.collection}EntitiesSelected`\n      : 'entitiesSelected',\n    selectedEntitiesIdsKey: collection\n      ? `${config.collection}IdsSelected`\n      : 'idsSelected',\n    selectEntitiesKey: collection\n      ? `select${capitalizedProp}Entities`\n      : 'selectEntities',\n    deselectEntitiesKey: collection\n      ? `deselect${capitalizedProp}Entities`\n      : 'deselectEntities',\n    toggleSelectEntitiesKey: collection\n      ? `toggleSelect${capitalizedProp}Entities`\n      : 'toggleSelectEntities',\n    toggleSelectAllEntitiesKey: collection\n      ? `toggleSelectAll${capitalizedProp}Entities`\n      : 'toggleSelectAllEntities',\n    clearEntitiesSelectionKey: collection\n      ? `clear${capitalizedProp}EntitiesSelection`\n      : 'clearEntitiesSelection',\n    isAllEntitiesSelectedKey: collection\n      ? `isAll${capitalizedProp}EntitiesSelected`\n      : 'isAllEntitiesSelected',\n  };\n}\n\nexport function getQueryMapperForMultiSelection(config?: {\n  collection?: string;\n}): QueryMapper<{\n  selectedIds: string | undefined;\n}> {\n  const { selectedEntitiesIdsKey, selectEntitiesKey } =\n    getEntitiesMultiSelectionKeys(config);\n  const { loadingKey, loadedKey } = getWithCallStatusKeys({\n    collection: config?.collection,\n  });\n  return {\n    queryParamsToState: (query, store) => {\n      const selectedIds = query.selectedIds;\n      if (selectedIds) {\n        const selectEntities = store[\n          selectEntitiesKey\n        ] as EntitiesMultiSelectionMethods['selectEntities'];\n\n        const ids = selectedIds\n          .split(',')\n          .map((id) => id.trim())\n          .filter(Boolean);\n\n        selectEntities({ ids });\n      }\n    },\n    stateToQueryParams: (store) => {\n      const selectedIds = store[selectedEntitiesIdsKey] as\n        | Signal<(string | number)[]>\n        | undefined;\n      return selectedIds\n        ? computed(() => ({\n            selectedIds:\n              selectedIds().length > 0 ? selectedIds().join(',') : undefined,\n          }))\n        : undefined;\n    },\n  };\n}\n","import { computed, Signal } from '@angular/core';\nimport {\n  patchState,\n  signalStoreFeature,\n  SignalStoreFeature,\n  SignalStoreFeatureResult,\n  withComputed,\n  withMethods,\n  withState,\n  WritableStateSource,\n} from '@ngrx/signals';\nimport { SelectEntityId } from '@ngrx/signals/entities';\nimport { EntityId, EntityMap } from '@ngrx/signals/entities';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport { pipe, tap } from 'rxjs';\n\nimport { RequireEntities } from '../feature-requirements.model';\nimport { getWithEntitiesKeys, toMap } from '../util';\nimport { getWithEntitiesFilterEvents } from '../with-entities-filter/with-entities-filter.util';\nimport { getWithEntitiesRemoteSortEvents } from '../with-entities-sort/with-entities-remote-sort.util';\nimport {\n  onEvent,\n  withEventHandler,\n} from '../with-event-handler/with-event-handler';\nimport { withFeatureFactory } from '../with-feature-factory/with-feature-factory';\nimport {\n  FeatureConfigFactory,\n  getFeatureConfig,\n  StoreSource,\n} from '../with-feature-factory/with-feature-factory.model';\nimport {\n  EntitiesMultiSelectionComputed,\n  EntitiesMultiSelectionMethods,\n  EntitiesMultiSelectionState,\n  NamedEntitiesMultiSelectionComputed,\n  NamedEntitiesMultiSelectionMethods,\n  NamedEntitiesMultiSelectionState,\n} from './with-entities-multi-selection.model';\nimport { getEntitiesMultiSelectionKeys } from './with-entities-multi-selection.util';\n\n/**\n * Generates state, signals and methods for multi selection of entities.\n * Warning: isAll[Collection]Selected and toggleSelectAll[Collection] wont work\n * correctly in using remote pagination, because they cant select all the data.\n *\n * Requires withEntities to be used before this feature.\n * @param configFactory - The configuration object for the feature or a factory function that receives the store and returns the configuration object\n * @param configFactory.entity - the entity type\n * @param configFactory.collection - the collection name\n * @param configFactory.clearOnFilter - Clear the selected entity when the filter changes (default: true)\n * @param configFactory.clearOnRemoteSort - Clear the selected entity when the remote sort changes (default: true)\n *\n * @example\n * const entity = type<Product>();\n * const collection = \"product\";\n * export const store = signalStore(\n *   { providedIn: 'root' },\n *   withEntities({ entity, collection }),\n *   withEntitiesMultiSelection({ entity, collection }),\n *   );\n *\n * // generates the following signals\n * store.productIdsSelectedMap // Record<string | number, boolean>;\n * // generates the following computed signals\n * store.productEntitiesSelected // Entity[];\n * store.isAllProductEntitiesSelected // 'all' | 'none' | 'some';\n * // generates the following methods\n * store.selectProducts // (config: { id: string | number } | { ids: (string | number)[] }) => void;\n * store.deselectProducts // (config: { id: string | number } | { ids: (string | number)[] }) => void;\n * store.toggleSelectProducts // (config: { id: string | number } | { ids: (string | number)[] }) => void;\n * store.toggleSelectAllProducts // () => void;\n */\n\nexport function withEntitiesMultiSelection<\n  Input extends SignalStoreFeatureResult,\n  Entity,\n  Collection extends string = '',\n>(\n  configFactory: FeatureConfigFactory<\n    Input,\n    {\n      entity: Entity;\n      collection?: Collection;\n      selectId?: SelectEntityId<Entity>;\n      clearOnFilter?: boolean;\n      clearOnRemoteSort?: boolean;\n      defaultSelectedIds?: (string | number)[];\n    }\n  >,\n): SignalStoreFeature<\n  Input &\n    RequireEntities<Input, Entity, Collection, 'withEntitiesMultiSelection'>,\n  Collection extends ''\n    ? {\n        state: EntitiesMultiSelectionState;\n        props: EntitiesMultiSelectionComputed<Entity>;\n        methods: EntitiesMultiSelectionMethods;\n      }\n    : {\n        state: NamedEntitiesMultiSelectionState<Collection>;\n        props: NamedEntitiesMultiSelectionComputed<Entity, Collection>;\n        methods: NamedEntitiesMultiSelectionMethods<Collection>;\n      }\n> {\n  return withFeatureFactory((store: StoreSource<Input>) => {\n    const config = getFeatureConfig(configFactory, store);\n    const { entityMapKey, idsKey } = getWithEntitiesKeys(config);\n    const {\n      selectedIdsMapKey,\n      selectedEntitiesKey,\n      selectedEntitiesIdsKey,\n      deselectEntitiesKey,\n      toggleSelectEntitiesKey,\n      clearEntitiesSelectionKey,\n      selectEntitiesKey,\n      toggleSelectAllEntitiesKey,\n      isAllEntitiesSelectedKey,\n    } = getEntitiesMultiSelectionKeys(config);\n\n    const { entitiesFilterChanged } = getWithEntitiesFilterEvents(config);\n    const { entitiesRemoteSortChanged } =\n      getWithEntitiesRemoteSortEvents(config);\n\n    return signalStoreFeature(\n      withState({\n        [selectedIdsMapKey]: config.defaultSelectedIds\n          ? toMap(config.defaultSelectedIds)\n          : {},\n      }),\n      withComputed((state: Record<string, Signal<unknown>>) => {\n        const entityMap = state[entityMapKey] as Signal<EntityMap<Entity>>;\n        const idsArray = state[idsKey] as Signal<Entity[]>;\n        const selectedIdsMap = state[selectedIdsMapKey] as Signal<\n          Record<string | number, boolean>\n        >;\n        const selectedIdsArray = computed(() =>\n          Object.entries(selectedIdsMap()).reduce(\n            (aux, [id, selected]) => {\n              const entity = entityMap()[id];\n              if (selected && entity) {\n                const id = config.selectId\n                  ? config.selectId(entity)\n                  : (entity as any).id;\n                aux.push(id);\n              }\n              return aux;\n            },\n            [] as (string | number)[],\n          ),\n        );\n        return {\n          [selectedEntitiesIdsKey]: selectedIdsArray,\n          [selectedEntitiesKey]: computed(() => {\n            return selectedIdsArray().map((id) => entityMap()[id]);\n          }),\n          [isAllEntitiesSelectedKey]: computed(() => {\n            const ids = selectedIdsArray();\n\n            if (ids.length === 0) {\n              return 'none';\n            }\n            if (ids.length === idsArray().length) {\n              return 'all';\n            }\n            return 'some';\n          }),\n        };\n      }),\n      withEventHandler((state) => {\n        const clearOnFilter = config?.clearOnFilter ?? true;\n        const clearOnRemoteSort = config?.clearOnRemoteSort ?? true;\n        const events = [];\n        if (clearOnFilter) {\n          events.push(\n            onEvent(entitiesFilterChanged, () => {\n              clearEntitiesSelection(state, selectedIdsMapKey);\n            }),\n          );\n        }\n        if (clearOnRemoteSort) {\n          events.push(\n            onEvent(entitiesRemoteSortChanged, () => {\n              clearEntitiesSelection(state, selectedIdsMapKey);\n            }),\n          );\n        }\n        return events;\n      }),\n      withMethods((state: Record<string, Signal<unknown>>) => {\n        const selectedIdsMap = state[selectedIdsMapKey] as Signal<\n          Record<string | number, boolean>\n        >;\n        const isAllEntitiesSelected = state[isAllEntitiesSelectedKey] as Signal<\n          'all' | 'none' | 'some'\n        >;\n        const selectedIds = state[selectedEntitiesIdsKey] as Signal<\n          (string | number)[]\n        >;\n        const idsArray = state[idsKey] as Signal<EntityId[]>;\n\n        function areAllIds({\n          ids,\n          selected,\n        }: {\n          ids: (string | number)[];\n          selected: boolean;\n        }) {\n          const previoslySelectedIds = selectedIds();\n          return (\n            previoslySelectedIds === ids ||\n            (previoslySelectedIds.length === ids.length &&\n              ids.every((id) =>\n                selected ? !!selectedIdsMap()[id] : !selectedIdsMap()[id],\n              ))\n          );\n        }\n        return {\n          [selectEntitiesKey]: rxMethod<\n            { clearSelectionBeforeSelect?: boolean } & (\n              | { id: string | number }\n              | { ids: (string | number)[] }\n            )\n          >(\n            pipe(\n              tap((options) => {\n                const ids = 'id' in options ? [options.id] : options.ids;\n                // protect againts cyclic resetting\n                if (areAllIds({ ids, selected: true })) return;\n\n                if (options.clearSelectionBeforeSelect) {\n                  clearEntitiesSelection(state, selectedIdsMapKey);\n                }\n                const idsMap = ids.reduce(\n                  (acc, id) => {\n                    acc[id] = true;\n                    return acc;\n                  },\n                  {} as Record<string | number, boolean>,\n                );\n\n                patchState(state as WritableStateSource<object>, {\n                  [selectedIdsMapKey]: { ...selectedIdsMap(), ...idsMap },\n                });\n              }),\n            ),\n          ),\n          [deselectEntitiesKey]: (\n            options: { id: string | number } | { ids: (string | number)[] },\n          ) => {\n            const ids = 'id' in options ? [options.id] : options.ids;\n            // protect againts cyclic resetting\n            if (areAllIds({ ids, selected: false })) return;\n\n            const idsMap = ids.reduce(\n              (acc, id) => {\n                acc[id] = false;\n                return acc;\n              },\n              {} as Record<string | number, boolean>,\n            );\n            patchState(state as WritableStateSource<object>, {\n              [selectedIdsMapKey]: { ...selectedIdsMap(), ...idsMap },\n            });\n          },\n          [toggleSelectEntitiesKey]: (\n            options: { id: string | number } | { ids: (string | number)[] },\n          ) => {\n            const ids = 'id' in options ? [options.id] : options.ids;\n            const oldIdsMap = selectedIdsMap();\n            const idsMap = ids.reduce(\n              (acc, id) => {\n                acc[id] = !oldIdsMap[id];\n                return acc;\n              },\n              {} as Record<string | number, boolean>,\n            );\n            patchState(state as WritableStateSource<object>, {\n              [selectedIdsMapKey]: { ...oldIdsMap, ...idsMap },\n            });\n          },\n          [clearEntitiesSelectionKey]: () => {\n            clearEntitiesSelection(state, selectedIdsMapKey);\n          },\n          [toggleSelectAllEntitiesKey]: () => {\n            const allSelected = isAllEntitiesSelected();\n            if (allSelected === 'all') {\n              patchState(state as WritableStateSource<object>, {\n                [selectedIdsMapKey]: {},\n              });\n            } else {\n              const idsMap = idsArray().reduce(\n                (acc, id) => {\n                  acc[id] = true;\n                  return acc;\n                },\n                {} as Record<string | number, boolean>,\n              );\n              patchState(state as WritableStateSource<object>, {\n                [selectedIdsMapKey]: idsMap,\n              });\n            }\n          },\n        };\n      }),\n    );\n  }) as any;\n}\nfunction clearEntitiesSelection(\n  state: Record<string, Signal<unknown>>,\n  selectedIdsMapKey: string,\n) {\n  patchState(state as WritableStateSource<object>, {\n    [selectedIdsMapKey]: {},\n  });\n}\n","import { SignalStoreFeature, SignalStoreFeatureResult } from '@ngrx/signals';\n\nimport { RequireEntitiesSingleSelection } from '../feature-requirements.model';\nimport { LinkMethod, withLink } from '../with-link/with-link';\nimport {\n  EntitiesSingleSelectionState,\n  NamedEntitiesSingleSelectionState,\n} from './with-entities-single-selection.model';\nimport { getEntitiesSingleSelectionKeys } from './with-entities-single-selection.util';\n\n/**\n * Generates a `link[Collection]IdSelected()` method that connects the selected\n * entity id to component signals (inputs, models, signal forms).\n *\n * Prebuilt version of `withLink` for `withEntitiesSingleSelection`: writes\n * route through `select[Collection]Entity` / `deselect[Collection]Entity`\n * (undefined deselects).\n *\n * Requires withEntitiesSingleSelection to be used before it.\n *\n * @param config - The configuration object for the feature\n * @param config.entity - The entity type to be used\n * @param config.collection - The optional collection name to be used\n *\n * @example\n * const entity = type<Product>();\n * const store = signalStore(\n *   withEntities({ entity }),\n *   withEntitiesSingleSelection({ entity }),\n *   withLinkEntitiesSingleSelection({ entity }),\n * );\n * // in a component:\n * // selectedId = model<string | number | undefined>(undefined);\n * // linked = this.store.linkIdSelected({ syncWith: this.selectedId });\n */\nexport function withLinkEntitiesSingleSelection<\n  Input extends SignalStoreFeatureResult,\n  Entity,\n  Collection extends string = '',\n>(config?: {\n  entity?: Entity;\n  collection?: Collection;\n}): SignalStoreFeature<\n  Input &\n    RequireEntitiesSingleSelection<\n      Input,\n      Collection,\n      'withLinkEntitiesSingleSelection',\n      Collection extends ''\n        ? { state: EntitiesSingleSelectionState; props: {}; methods: {} }\n        : {\n            state: NamedEntitiesSingleSelectionState<Collection>;\n            props: {};\n            methods: {};\n          }\n    >,\n  {\n    state: {};\n    props: {};\n    methods: {\n      [P in Collection extends ''\n        ? 'idSelected'\n        : `${Collection}IdSelected` as `link${Capitalize<\n        string & P\n      >}`]: LinkMethod<string | number | undefined>;\n    };\n  }\n> {\n  const { selectedIdKey, selectEntityKey, deselectEntityKey } =\n    getEntitiesSingleSelectionKeys(config);\n  return withLink(selectedIdKey, {\n    set: (value: string | number | undefined, store: any) => {\n      if (value == null) {\n        (store[deselectEntityKey] as () => void)();\n      } else {\n        (store[selectEntityKey] as (options: { id: string | number }) => void)({\n          id: value,\n        });\n      }\n    },\n    // the store already exposes select/deselect[Collection]Entity for this write\n    noSetter: true,\n  } as any) as any;\n}\n","import { Signal } from '@angular/core';\nimport { SignalStoreFeature, SignalStoreFeatureResult } from '@ngrx/signals';\n\nimport { RequireEntitiesMultiSelection } from '../feature-requirements.model';\nimport { LinkMethod, withLink } from '../with-link/with-link';\nimport {\n  EntitiesMultiSelectionState,\n  NamedEntitiesMultiSelectionState,\n} from './with-entities-multi-selection.model';\nimport { getEntitiesMultiSelectionKeys } from './with-entities-multi-selection.util';\n\n/**\n * Generates a `link[Collection]IdsSelected()` method that connects the\n * selected entity ids to component signals (inputs, models, signal forms).\n *\n * Prebuilt version of `withLink` for `withEntitiesMultiSelection`: reads the\n * `[collection]IdsSelected` computed, writes route through\n * `select[Collection]Entities` with `clearSelectionBeforeSelect` (an empty\n * array clears the selection), and syncs are guarded with an order-insensitive\n * ids equality — the selection map does not preserve the order of the ids it\n * was given, so an order-sensitive compare would cause echo loops.\n *\n * Requires withEntitiesMultiSelection to be used before it.\n *\n * @param config - The configuration object for the feature\n * @param config.entity - The entity type to be used\n * @param config.collection - The optional collection name to be used\n *\n * @example\n * const entity = type<Product>();\n * const store = signalStore(\n *   withEntities({ entity }),\n *   withEntitiesMultiSelection({ entity }),\n *   withLinkEntitiesMultiSelection({ entity }),\n * );\n * // in a component:\n * // value = model<(string | number)[]>([]);\n * // valueField = form(this.store.linkIdsSelected({ syncWith: this.value }));\n */\nexport function withLinkEntitiesMultiSelection<\n  Input extends SignalStoreFeatureResult,\n  Entity,\n  Collection extends string = '',\n>(config?: {\n  entity?: Entity;\n  collection?: Collection;\n}): SignalStoreFeature<\n  Input &\n    RequireEntitiesMultiSelection<\n      Input,\n      Collection,\n      'withLinkEntitiesMultiSelection',\n      Collection extends ''\n        ? { state: EntitiesMultiSelectionState; props: {}; methods: {} }\n        : {\n            state: NamedEntitiesMultiSelectionState<Collection>;\n            props: {};\n            methods: {};\n          }\n    >,\n  {\n    state: {};\n    props: {};\n    methods: {\n      [P in Collection extends ''\n        ? 'idsSelected'\n        : `${Collection}IdsSelected` as `link${Capitalize<\n        string & P\n      >}`]: LinkMethod<(string | number)[]>;\n    };\n  }\n> {\n  const {\n    selectedEntitiesIdsKey,\n    selectEntitiesKey,\n    clearEntitiesSelectionKey,\n  } = getEntitiesMultiSelectionKeys(config);\n  return withLink(selectedEntitiesIdsKey, {\n    computation: (store: any) =>\n      (store[selectedEntitiesIdsKey] as Signal<(string | number)[]>)(),\n    set: (ids: (string | number)[], store: any) => {\n      if (ids.length) {\n        (\n          store[selectEntitiesKey] as (options: {\n            ids: (string | number)[];\n            clearSelectionBeforeSelect?: boolean;\n          }) => void\n        )({ ids, clearSelectionBeforeSelect: true });\n      } else {\n        (store[clearEntitiesSelectionKey] as () => void)();\n      }\n    },\n    // set semantics on purpose: the selection map does not preserve the order\n    // of the ids it was given, so an order-sensitive compare would echo loop\n    equal: 'set',\n    // the store already exposes select/clear[Collection]Entities for this write\n    noSetter: true,\n  } as any) as any;\n}\n","import {\n  EnvironmentInjector,\n  inject,\n  runInInjectionContext,\n  Signal,\n} from '@angular/core';\nimport {\n  EmptyFeatureResult,\n  patchState,\n  signalStoreFeature,\n  SignalStoreFeature,\n  SignalStoreFeatureResult,\n  withHooks,\n  WritableStateSource,\n} from '@ngrx/signals';\nimport { SelectEntityId, setAllEntities } from '@ngrx/signals/entities';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport {\n  asapScheduler,\n  catchError,\n  concatMap,\n  debounceTime,\n  exhaustMap,\n  first,\n  from,\n  map,\n  Observable,\n  of,\n  pipe,\n  switchMap,\n} from 'rxjs';\n\nimport {\n  EntitiesCallStatusRequirement,\n  RequireEntities,\n  RequireEntitiesCallStatus,\n} from '../feature-requirements.model';\nimport {\n  getWithCallStatusEvents,\n  getWithCallStatusKeys,\n} from '../with-call-status/with-call-status.util';\nimport { getWithEntitiesRemotePaginationKeys } from '../with-entities-pagination/with-entities-remote-pagination.util';\nimport {\n  onEvent,\n  withEventHandler,\n} from '../with-event-handler/with-event-handler';\nimport { withFeatureFactory } from '../with-feature-factory/with-feature-factory';\nimport {\n  FeatureConfigFactory,\n  getFeatureConfig,\n  StoreSource,\n} from '../with-feature-factory/with-feature-factory.model';\nimport {\n  ExpectedFetchEntitiesResult,\n  FetchEntitiesResult,\n} from './with-entities-loading-call.model';\n\n/**\n * Generates a onInit hook that fetches entities from a remote source\n * when the [Collection]Loading is true, by calling the fetchEntities function\n * and if successful, it will call set[Collection]Loaded and also set the entities\n * to the store using the setAllEntities method or the setEntitiesPagedResult method\n * if it exists (comes from withEntitiesRemotePagination),\n * if an error occurs it will set the error to the store using set[Collection]Error with the error.\n *\n * Requires withEntities and withCallStatus to be present in the store.\n *\n * @param config - Configuration object or factory function that returns the configuration object\n * @param config.fetchEntities - A function that fetches the entities from a remote source, the return type can be an array of entities or an object with entities and total\n * @param config.collection - The collection name\n * @param config.onSuccess - A function that is called when the fetchEntities is successful\n * @param config.mapError - A function to transform the error before setting it to the store, requires withCallStatus errorType to be set\n * @param config.onError - A function that is called when the fetchEntities fails\n * @param config.selectId - The function to use to select the id of the entity\n * @param config.storeResult - Whether to automatically store the fetched entities in the store (default: true). When false, entities are not stored, but setLoaded and onSuccess are still called, useful when you want to handle storing in onSuccess yourself\n *\n *\n * @example\n * export const ProductsRemoteStore = signalStore(\n *   { providedIn: 'root' },\n *   // requires at least withEntities and withCallStatus\n *   withEntities({ entity, collection }),\n *   withCallStatus({ prop: collection, initialValue: 'loading' }),\n *   // other features\n *   withEntitiesRemoteFilter({\n *     entity,\n *     collection,\n *     defaultFilter: { name: '' },\n *   }),\n *   withEntitiesRemotePagination({\n *     entity,\n *     collection,\n *     pageSize: 5,\n *     pagesToCache: 2,\n *   }),\n *   withEntitiesRemoteSort({\n *     entity,\n *     collection,\n *     defaultSort: { field: 'name', direction: 'asc' },\n *   }),\n *   // now we add the withEntitiesLoadingCall, in this case any time the filter,\n *   // pagination or sort changes they call set[Collection]Loading() which then\n *   // triggers the onInit effect that checks if [Collection]Loading(), if true\n *   // then calls fetchEntities function\n *   withEntitiesLoadingCall({\n *     collection,\n *     fetchEntities: ({ productEntitiesFilter, productEntitiesPagedRequest, productEntitiesSort }) => {\n *       return inject(ProductService)\n *         .getProducts({\n *           search: productEntitiesFilter().name,\n *           take: productEntitiesPagedRequest().size,\n *           skip: productEntitiesPagedRequest().startIndex,\n *           sortColumn: productEntitiesSort().field,\n *           sortAscending: productEntitiesSort().direction === 'asc',\n *         })\n *         .pipe(\n *           map((d) => ({\n *             entities: d.resultList,\n *             total: d.total,\n *           })),\n *         );\n *     },\n *   }),\n */\n\nexport function withEntitiesLoadingCall<\n  Input extends SignalStoreFeatureResult,\n  Entity,\n  Collection extends string = '',\n  Error = unknown,\n>(\n  config: FeatureConfigFactory<\n    Input,\n    {\n      collection?: Collection;\n      fetchEntities: (\n        store: StoreSource<Input>,\n      ) =>\n        | Observable<ExpectedFetchEntitiesResult<Input, Collection, Entity>>\n        | Promise<ExpectedFetchEntitiesResult<Input, Collection, Entity>>;\n      mapPipe?: 'switchMap' | 'concatMap' | 'exhaustMap';\n      onSuccess?: (\n        result: FetchEntitiesResult<Input, Collection, Entity>,\n      ) => void;\n      mapError?: (error: unknown) => Error;\n      onError?: (error: Error) => void;\n      entity?: Entity;\n      selectId?: SelectEntityId<Entity>;\n      storeResult?: boolean;\n    }\n  >,\n): SignalStoreFeature<\n  Input &\n    RequireEntities<Input, Entity, Collection, 'withEntitiesLoadingCall'> &\n    RequireEntitiesCallStatus<\n      Input,\n      Collection,\n      'withEntitiesLoadingCall',\n      EntitiesCallStatusRequirement<Collection, Error>\n    >,\n  EmptyFeatureResult\n> {\n  return withFeatureFactory(\n    (\n      _store: StoreSource<Input>,\n      environmentInjector = inject(EnvironmentInjector),\n    ) => {\n      const {\n        collection,\n        fetchEntities,\n        onSuccess,\n        onError,\n        mapError,\n        mapPipe: mapPipeType,\n        selectId,\n        storeResult = true,\n      } = getFeatureConfig(config, _store);\n      const { loadingKey, setErrorKey, setLoadedKey } = getWithCallStatusKeys({\n        collection,\n      });\n      const { setEntitiesPagedResultKey } = getWithEntitiesRemotePaginationKeys(\n        {\n          collection,\n        },\n      );\n      const { callLoading } = getWithCallStatusEvents({ prop: collection });\n\n      const setLoaded = _store[setLoadedKey] as () => void;\n      const setError = _store[setErrorKey] as (error: unknown) => void;\n      const setEntitiesPagedResult = _store[\n        setEntitiesPagedResultKey\n      ] as (result: { entities: Entity[] }) => void;\n\n      const mapPipe = mapPipeType ? mapPipes[mapPipeType] : switchMap;\n      const loadEntities = rxMethod<void>(\n        pipe(\n          debounceTime(0, asapScheduler),\n          mapPipe(() =>\n            runInInjectionContext(environmentInjector, () =>\n              from(fetchEntities(_store)),\n            ).pipe(\n              map((result) => {\n                if (storeResult) {\n                  if (setEntitiesPagedResult)\n                    setEntitiesPagedResult(result as { entities: Entity[] });\n                  else {\n                    const entities = Array.isArray(result)\n                      ? result\n                      : (result as { entities: Entity[] }).entities;\n                    patchState(\n                      _store as WritableStateSource<object>,\n                      collection\n                        ? setAllEntities(entities as Entity[], {\n                            collection,\n                            selectId:\n                              selectId ?? ((entity) => (entity as any).id),\n                          })\n                        : setAllEntities(entities as Entity[], {\n                            selectId:\n                              selectId ??\n                              ((entity) => (entity as any).id as string),\n                          }),\n                    );\n                  }\n                }\n                setLoaded();\n                if (onSuccess)\n                  onSuccess(\n                    result as FetchEntitiesResult<Input, Collection, Entity>,\n                  );\n              }),\n              first(),\n              catchError((error: unknown) => {\n                const e = mapError ? mapError(error) : error;\n                setError(e);\n                console.error(`${collection ?? ''} fetchEntities fail `, e);\n                if (onError) onError(e as Error);\n                return of();\n              }),\n            ),\n          ),\n        ),\n      );\n      return signalStoreFeature(\n        withEventHandler(() => [onEvent(callLoading, () => loadEntities())]),\n        withHooks((store: Record<string, Signal<unknown>>) => {\n          const loading = store[loadingKey] as Signal<boolean>;\n          return {\n            onInit: () => {\n              if (loading()) loadEntities();\n            },\n          };\n        }),\n      );\n    },\n  ) as any;\n}\nconst mapPipes = {\n  switchMap: switchMap,\n  concatMap: concatMap,\n  exhaustMap: exhaustMap,\n};\n","interface DiffEntry {\n  text: string;\n  style: string;\n}\n\nexport function deepDiff(name: string, oldObj: any, newObj: any): void {\n  const diffEntries: DiffEntry[] = [];\n\n  // Helper to add a diff entry\n  function addDiffEntry(text: string, style: string): void {\n    diffEntries.push({ text, style });\n  }\n\n  // Recursive helper that builds the diff entries.\n  function diffHelper(path: string, a: any, b: any): void {\n    // Both values are objects (or arrays) and not null\n    if (\n      typeof a === 'object' &&\n      a !== null &&\n      typeof b === 'object' &&\n      b !== null\n    ) {\n      // If both are arrays, compare by index.\n      if (Array.isArray(a) && Array.isArray(b)) {\n        const maxLength = Math.max(a.length, b.length);\n        for (let i = 0; i < maxLength; i++) {\n          const currentPath = `${path}[${i}]`;\n          if (i >= a.length) {\n            // b has an extra element.\n            addDiffEntry(\n              `+ ${currentPath}: ${JSON.stringify(b[i])}`,\n              'color: green',\n            );\n          } else if (i >= b.length) {\n            // a had an element that is now removed.\n            addDiffEntry(\n              `- ${currentPath}: ${JSON.stringify(a[i])}`,\n              'color: red',\n            );\n          } else {\n            diffHelper(currentPath, a[i], b[i]);\n          }\n        }\n      }\n      // If both are plain objects, compare their keys.\n      else if (!Array.isArray(a) && !Array.isArray(b)) {\n        const keys = new Set([...Object.keys(a), ...Object.keys(b)]);\n        for (const key of keys) {\n          const currentPath = path ? `${path}.${key}` : key;\n          if (!(key in a)) {\n            addDiffEntry(\n              `+ ${currentPath}: ${JSON.stringify(b[key])}`,\n              'color: green',\n            );\n          } else if (!(key in b)) {\n            addDiffEntry(\n              `- ${currentPath}: ${JSON.stringify(a[key])}`,\n              'color: red',\n            );\n          } else {\n            diffHelper(currentPath, a[key], b[key]);\n          }\n        }\n      }\n      // Mismatched types: one is an array, the other an object.\n      else {\n        addDiffEntry(`- ${path}: ${JSON.stringify(a)}`, 'color: red');\n        addDiffEntry(`+ ${path}: ${JSON.stringify(b)}`, 'color: green');\n      }\n    }\n    // At least one value is primitive or null.\n    else {\n      if (a !== b) {\n        addDiffEntry(`- ${path}: ${JSON.stringify(a)}`, 'color: red');\n        addDiffEntry(`+ ${path}: ${JSON.stringify(b)}`, 'color: green');\n      }\n    }\n  }\n\n  // Start the recursive diff process.\n  diffHelper('', oldObj, newObj);\n\n  // If no differences are found, log a message.\n  if (diffEntries.length === 0) {\n    console.log(name, 'No differences found.');\n    return;\n  }\n\n  // Build a single output string with '%c' markers for styles.\n  const outputString = diffEntries.map((entry) => `%c${entry.text}`).join('\\n');\n  const styles = diffEntries.map((entry) => entry.style);\n\n  // Print everything in one console.log call.\n  console.log(name);\n  console.log(outputString, ...styles);\n}\n","import { computed, effect, isSignal } from '@angular/core';\nimport {\n  EmptyFeatureResult,\n  SignalStoreFeature,\n  signalStoreFeature,\n  SignalStoreFeatureResult,\n  StateSignals,\n  type,\n  withHooks,\n} from '@ngrx/signals';\n\nimport { deepDiff } from './with-logger.util';\n\n/**\n * Log the state of the store on every change, optionally filter the signals to log\n * the filter prop can receive an array with the names of the props to filter, or you can provide a function\n * which receives the store as an argument and should return the object to log, if any of the props in the object is a signal\n * it will log the value of the signal, the returned value can also be a non object value like a nested signal value.\n * If showDiff is true it will log the diff of the state on every change.\n *\n * @param name - The name of the store to log\n * @param filter - optional filter function to filter the store signals or an array of keys to filter\n * @param showDiff - optional flag to log the diff of the state on every change\n *\n * @example\n *\n *  const Store = signalStore(\n *     withState(() => ({ prop1: 1, prop2: 2 })),\n *     withComputed(({ prop1, prop2 }) => ({\n *       prop3: computed(() => prop1() + prop2()),\n *     })),\n *     withLogger({\n *       name: 'Store',\n *       // by default it will log all state and computed signals\n *       // or you can filter with an array of keys\n *       // filter: ['prop1', 'prop2'],\n *       // or you can filter with a function\n *       // filter: ({ prop1, prop2 }) => ({ prop1, prop2 }),\n *       // the function can also return nested signals or their values\n *       // filter: ({ myObject }) => ({ x: myObject.x }),\n *       // filter: ({ myObject }) => myObject.x(),\n *       // showDiff: true,\n *     }),\n *   );\n */\nexport function withLogger<Input extends SignalStoreFeatureResult>({\n  name,\n  filter,\n  showDiff,\n}: {\n  name: string;\n  filter?:\n    | ((store: StateSignals<Input['state']> & Input['props']) => any)\n    | readonly (keyof (StateSignals<Input['state']> & Input['props']))[];\n  showDiff?: boolean;\n}): SignalStoreFeature<Input, EmptyFeatureResult> {\n  return signalStoreFeature(\n    type<Input>(),\n    withHooks({\n      onInit(store) {\n        function evaluateSignals(source: any, keys?: string[], sort?: boolean) {\n          return typeof source === 'object'\n            ? (sort ? Object.keys(source).sort() : Object.keys(source)).reduce(\n                (acc, key) => {\n                  if (!keys || keys.includes(key)) {\n                    if (isSignal(source[key])) {\n                      acc[key] = source[key]();\n                    } else if (typeof source[key] != 'function') {\n                      // if not signal only log values that are not methods\n                      acc[key] = source[key];\n                    }\n                  }\n                  return acc;\n                },\n                {} as Record<string, any>,\n              )\n            : source;\n        }\n\n        const signalsComputed = computed(() => {\n          return !filter\n            ? evaluateSignals(store, undefined, true)\n            : typeof filter === 'function'\n              ? evaluateSignals(\n                  filter(\n                    store as StateSignals<Input['state']> & Input['props'],\n                  ),\n                )\n              : evaluateSignals(store, filter as unknown as string[]);\n        });\n        let lastState: any = undefined;\n        let initialized = false;\n        effect(() => {\n          const state = signalsComputed();\n          console.log(\n            `${name} store ${initialized ? 'changed' : 'initialized'}: `,\n            state,\n          );\n          if (showDiff && initialized)\n            deepDiff(`${name} store changes diff :`, lastState, state);\n          lastState = state;\n          initialized = true;\n        });\n      },\n    }),\n  );\n}\n","export function getWithCallKeys({\n  callName,\n  resultProp = `${callName}Result`,\n}: {\n  callName: string;\n  resultProp?: string;\n}) {\n  return {\n    callNameKey: callName,\n    resultPropKey: resultProp,\n  };\n}\n","import {\n  computed,\n  EnvironmentInjector,\n  inject,\n  isDevMode,\n  isSignal,\n  runInInjectionContext,\n  Signal,\n} from '@angular/core';\nimport { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';\nimport {\n  patchState,\n  signalStoreFeature,\n  SignalStoreFeature,\n  SignalStoreFeatureResult,\n  withComputed,\n  withHooks,\n  withMethods,\n  withState,\n  WritableStateSource,\n} from '@ngrx/signals';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport {\n  catchError,\n  concatMap,\n  exhaustMap,\n  finalize,\n  first,\n  from,\n  ignoreElements,\n  isObservable,\n  lastValueFrom,\n  map,\n  merge,\n  Observable,\n  of,\n  pipe,\n  share,\n  Subject,\n  switchMap,\n  take,\n  takeUntil,\n  tap,\n  timer,\n} from 'rxjs';\nimport { filter } from 'rxjs/operators';\n\nimport { insertIf } from '../util';\nimport { registerCallState } from '../with-all-call-status/with-all-call-status.util';\nimport {\n  CallStatus,\n  NamedCallStatusState,\n} from '../with-call-status/with-call-status.model';\nimport { getWithCallStatusKeys } from '../with-call-status/with-call-status.util';\nimport { withFeatureFactory } from '../with-feature-factory/with-feature-factory';\nimport { StoreSource } from '../with-feature-factory/with-feature-factory.model';\nimport {\n  Call,\n  CallConfig,\n  ExtractCallResultPropName,\n  ExtractCallResultType,\n  ExtractErrorType,\n  NamedCallsStatusComputed,\n  ObservableCall,\n  RxMethodRef,\n} from './with-calls.model';\nimport { getWithCallKeys } from './with-calls.util';\n\n/**\n * Generates necessary state, computed and methods to track the progress of the\n * call and store the result of the call. The generated methods are rxMethods with\n * the same name as the original call, which accepts either the original parameters\n * or a Signal or Observable of the same type as the original parameters.\n * The original call can only have zero or one parameter, use an object with multiple\n * props as first param if you need more.\n * If the name start with an underscore, the call will be private and all generated methods\n * will also start with an underscore, making it only accessible inside the store.\n * @param {callsFactory} callsFactory - a factory function that receives the store and returns an object of type {Record<string, Call | CallConfig>} with the calls to be made\n *\n * @example\n *  withCalls(({ productsSelectedEntity }) => ({\n *     loadProductDetail: callConfig({\n *       call: ({ id }: { id: string }) =>\n *         inject(ProductService).getProductDetail(id),\n *       resultProp: 'productDetail',\n *       // storeResult: false, // will omit storing the result, and remove the result prop from the store\n *       mapPipe: 'switchMap', // default is 'exhaustMap'\n *       onSuccess: (result, callParam) => {\n *       // do something with the result\n *       },\n *       mapError: (error, callParam) => {\n *         return // transform the error before storing it\n *       },\n *       onError: (error, callParam) => {\n *       // do something with the error\n *       },\n *       skipWhen: (callParam) => {\n *         // if return true, the call will be skip, if false, the call will execute as usual\n *         return // boolean | Promise<boolean> | Observable<boolean>\n *       },\n *       callWith: () =>\n *       // reactively call  with the selected product id, if undefined is return, the call is skip by default\n *        productEntitySelected()\n *            ? { id: productEntitySelected()!.id }\n *            : undefined,\n *     }),\n *     checkout: () =>\n *       inject(OrderService).checkout({\n *         productId: productsSelectedEntity()!.id,\n *         quantity: 1,\n *       }),\n *   })),\n *\n *   // generates the following signals\n *   store.loadProductDetailCallStatus // 'init' | 'loading' | 'loaded' | { error: unknown }\n *   store.productDetail // the result of the call\n *   store.checkoutCallStatus // 'init' | 'loading' | 'loaded' | { error: unknown }\n *   store.checkoutResult // the result of the call\n *   // generates the following computed signals\n *   store.isLoadProductDetailLoading // boolean\n *   store.isLoadProductDetailLoaded // boolean\n *   store.loadProductDetailError // string | null\n *   store.isCheckoutLoading // boolean\n *   store.isCheckoutLoaded // boolean\n *   store.checkoutError // unknown | null\n *   // generates the following methods\n *   store.loadProductDetail // ({id: string} | Signal<{id: string}> | Observable<{id: string}>) => void\n *   store.checkout // () => Promise<{value, ok: true} | {error, ok: false}>\n *\n * @warning The default mapPipe is {@link https://www.learnrxjs.io/learn-rxjs/operators/transformation/exhaustmap exhaustMap}. If your call returns an observable that does not complete after the first value is emitted, any changes to the input params will be ignored. Either specify {@link https://www.learnrxjs.io/learn-rxjs/operators/transformation/switchmap switchMap} as mapPipe, or use {@link https://www.learnrxjs.io/learn-rxjs/operators/filtering/take take(1)} or {@link https://www.learnrxjs.io/learn-rxjs/operators/filtering/first first()} as part of your call.\n */\nexport function withCalls<\n  Input extends SignalStoreFeatureResult,\n  const Calls extends Record<string, Call | CallConfig>,\n>(\n  callsFactory: (store: StoreSource<Input>) => Calls,\n): SignalStoreFeature<\n  Input,\n  {\n    state: NamedCallStatusState<keyof Calls & string> & {\n      [K in keyof Calls as ExtractCallResultPropName<\n        K,\n        Calls[K]\n      >]: ExtractCallResultType<Calls[K]>;\n    };\n    props: NamedCallsStatusComputed<Calls>;\n    methods: {\n      [K in keyof Calls]: Calls[K] extends (...args: infer P) => any\n        ? P extends []\n          ? () => Promise<\n              | { value: Signal<ExtractCallResultType<Calls[K]>>; ok: true }\n              | { error: Signal<ExtractErrorType<Calls[K]>>; ok: false }\n            >\n          : {\n              (\n                param: P[0],\n              ): Promise<\n                | { value: Signal<ExtractCallResultType<Calls[K]>>; ok: true }\n                | { error: Signal<ExtractErrorType<Calls[K]>>; ok: false }\n              >;\n              (param: Observable<P[0]> | (() => P[0])): RxMethodRef;\n            }\n        : Calls[K] extends CallConfig\n          ? Parameters<Calls[K]['call']> extends undefined[]\n            ? () => Promise<\n                | { value: Signal<ExtractCallResultType<Calls[K]>>; ok: true }\n                | { error: Signal<ExtractErrorType<Calls[K]>>; ok: false }\n              >\n            : {\n                (\n                  param: Parameters<Calls[K]['call']>[0],\n                ): Promise<\n                  | { value: Signal<ExtractCallResultType<Calls[K]>>; ok: true }\n                  | { error: Signal<ExtractErrorType<Calls[K]>>; ok: false }\n                >;\n                (\n                  param:\n                    | Observable<Parameters<Calls[K]['call']>[0]>\n                    | (() => Parameters<Calls[K]['call']>[0]),\n                ): RxMethodRef;\n              }\n          : never;\n    };\n  }\n> {\n  return withFeatureFactory((store) => {\n    const calls = callsFactory(store as StoreSource<Input>);\n    const callsState = Object.entries(calls).reduce(\n      (acc, [callName, call]) => {\n        const { callStatusKey } = getWithCallStatusKeys({ prop: callName });\n        acc[callStatusKey] = 'init';\n        const { resultPropKey } = getWithCallKeys({\n          callName,\n          resultProp:\n            isCallConfig(call) && call.resultProp?.length\n              ? call.resultProp\n              : `${callName}Result`,\n        });\n        if (!isCallConfig(call) || call.storeResult !== false) {\n          acc[resultPropKey] = isCallConfig(call)\n            ? call.defaultResult\n            : undefined;\n        }\n        return acc;\n      },\n      {} as Record<string, any>,\n    );\n\n    const hasCallWith = Object.entries(calls).some(\n      ([, call]) => isCallConfig(call) && 'callWith' in call,\n    );\n    return signalStoreFeature(\n      withState(callsState),\n      withComputed((state: Record<string, Signal<unknown>>) => {\n        const callsComputed = Object.keys(calls).reduce(\n          (acc, callName) => {\n            const { loadingKey, loadedKey, errorKey, callStatusKey } =\n              getWithCallStatusKeys({ prop: callName, supportPrivate: true });\n            const callState = state[callStatusKey] as Signal<CallStatus>;\n            const isLoading = computed(() => callState() === 'loading');\n            const error = computed(() => {\n              const v = callState();\n              return typeof v === 'object' ? v.error : null;\n            });\n            registerCallState(store, { loading: isLoading, error });\n            acc[loadingKey] = isLoading;\n            acc[errorKey] = error;\n            acc[loadedKey] = computed(() => callState() === 'loaded');\n\n            return acc;\n          },\n          {} as Record<string, any>,\n        );\n        return callsComputed;\n      }),\n      withMethods(\n        (state, environmentInjector = inject(EnvironmentInjector)) => {\n          const methods = Object.entries(calls).reduce(\n            (acc, [callName, call]) => {\n              const { callStatusKey, errorKey } = getWithCallStatusKeys({\n                prop: callName,\n              });\n              const { resultPropKey, callNameKey } = getWithCallKeys({\n                callName,\n                resultProp:\n                  isCallConfig(call) && call.resultProp?.length\n                    ? call.resultProp\n                    : `${callName}Result`,\n              });\n\n              const mapPipe =\n                isCallConfig(call) && call.mapPipe\n                  ? mapPipes[call.mapPipe]\n                  : exhaustMap;\n\n              const setLoading = () =>\n                patchState(store, {\n                  [callStatusKey]: 'loading',\n                } as WritableStateSource<Input['state']>);\n              const setLoaded = () =>\n                patchState(store, {\n                  [callStatusKey]: 'loaded',\n                } as WritableStateSource<Input['state']>);\n              const setError = (error: unknown) =>\n                patchState(store, {\n                  [callStatusKey]: { error },\n                } as WritableStateSource<Input['state']>);\n\n              const callFn = getCallFn(callName, call);\n              const skipWhenFn = isCallConfig(call)\n                ? call.skipWhen ??\n                  (call.callWith\n                    ? (param: unknown) => param === undefined || param === false\n                    : undefined)\n                : undefined;\n\n              let reactiveMethod = rxMethod<unknown>(\n                pipe(\n                  mapPipe((params) => {\n                    const previousResult = isCallConfig(call)\n                      ? call.storeResult != false\n                        ? state[resultPropKey]()\n                        : undefined\n                      : state[resultPropKey]();\n                    const skip = skipWhenFn?.(params, previousResult) ?? false;\n                    const process$ = concatMap((params) => {\n                      setLoading();\n                      return runInInjectionContext(environmentInjector, () => {\n                        return callFn(params).pipe(\n                          map((result) => {\n                            if (\n                              !isCallConfig(call) ||\n                              call.storeResult !== false\n                            ) {\n                              patchState(state, {\n                                [resultPropKey]: result,\n                              });\n                            }\n                            setLoaded();\n                            isCallConfig(call) &&\n                              call.onSuccess &&\n                              call.onSuccess(result, params, previousResult);\n                          }),\n                          takeUntilDestroyed(),\n                          catchError((error: unknown) => {\n                            const e =\n                              (isCallConfig(call) &&\n                                call.mapError?.(error, params)) ||\n                              error;\n                            setError(e);\n                            console.error(\n                              `Call ${callName} fail `,\n                              { params },\n                              e,\n                            );\n                            isCallConfig(call) &&\n                              call.onError &&\n                              call.onError(e, params);\n                            return of();\n                          }),\n                        );\n                      });\n                    });\n                    if (typeof skip === 'boolean') {\n                      if (isDevMode() && skip)\n                        console.warn(`Call ${callName} is skip`);\n                      return skip ? of() : of(params).pipe(process$);\n                    }\n                    // skip is a promise or observable\n                    return from(skip).pipe(\n                      tap((value) => {\n                        if (isDevMode() && value)\n                          console.warn(`Call ${callName} is skip`);\n                      }),\n                      // first((v) => !v),\n                      filter((v) => !v),\n                      take(1),\n                      map(() => params),\n                      process$,\n                    );\n                  }),\n                ),\n              );\n              acc[callNameKey] = function (param?: unknown) {\n                if (\n                  typeof param === 'function' ||\n                  param instanceof Observable ||\n                  isSignal(param)\n                ) {\n                  return reactiveMethod(param as any);\n                }\n\n                reactiveMethod(param as any);\n                const callState = state[callStatusKey] as Signal<CallStatus>;\n                const resultSignal = state[resultPropKey] as Signal<unknown>;\n                const errorSignal = state[errorKey] as Signal<unknown>;\n                let resultPromise = lastValueFrom(\n                  toObservable(callState, {\n                    injector: environmentInjector,\n                  }).pipe(\n                    filter((v) => v === 'loaded' || typeof v === 'object'),\n                    take(1),\n                    map((v) =>\n                      v === 'loaded'\n                        ? { value: resultSignal, ok: true as const }\n                        : { error: errorSignal, ok: false as const },\n                    ),\n                  ),\n                );\n                // the promise never settles if the call is skipped by skipWhen,\n                // or if the store is destroyed mid call (toObservable completes\n                // empty), and callers are free to ignore it, so keep a no-op\n                // handler attached to stop that surfacing as an unhandled\n                // rejection. Callers that await still see the rejection.\n                resultPromise.catch(() => {});\n                return resultPromise;\n              };\n              return acc;\n            },\n            {} as Record<string, any>,\n          );\n          return methods;\n        },\n      ),\n      ...insertIf(hasCallWith, () =>\n        withHooks((store: Record<string, Function>) => ({\n          onInit: () => {\n            for (const [callName, call] of Object.entries(calls)) {\n              if (isCallConfig(call) && 'callWith' in call) {\n                if (\n                  typeof call.callWith === 'function' &&\n                  !isObservable(call.callWith) &&\n                  !isSignal(call.callWith)\n                ) {\n                  store[callName](computed(call.callWith));\n                } else if (\n                  isObservable(call.callWith) ||\n                  isSignal(call.callWith)\n                ) {\n                  store[callName](call.callWith);\n                } else {\n                  const value = call.callWith;\n                  if (value !== undefined && value !== false) {\n                    store[callName](value);\n                  }\n                }\n              }\n            }\n          },\n        })),\n      ),\n    );\n  }) as any;\n}\n\nfunction isCallConfig<Param, Result>(\n  call: Call<Param, Result> | CallConfig<Param, Result>,\n): call is CallConfig<Param, Result> {\n  return typeof call === 'object';\n}\nconst mapPipes = {\n  switchMap: switchMap,\n  concatMap: concatMap,\n  exhaustMap: exhaustMap,\n};\n\nfunction getCallFn<Param, Result>(\n  callName: string,\n  call: Call<Param, Result> | CallConfig<Param, Result>,\n): ObservableCall<Param, Result> {\n  if (isCallConfig(call)) {\n    if (!call.mapPipe) {\n      return wrapMapPipeWarning(callName, call.call);\n    } else {\n      return (params) => from(call.call(params));\n    }\n  } else {\n    return wrapMapPipeWarning(callName, call);\n  }\n}\n\n/**\n * @private\n * Wraps a call with a warning mechanism in dev mode.\n * If the call does not complete after the first value, it logs a warning\n * indicating that the default \"exhaustMap\" pipe is being used.\n */\nfunction wrapMapPipeWarning<Param, Result>(\n  callName: string,\n  call: Call<Param, Result>,\n): ObservableCall<Param, Result> {\n  if (isDevMode()) {\n    return (params) => {\n      const source$ = from(call(params)).pipe(\n        finalize(() => completed$.next()),\n        share(),\n      );\n      const completed$ = new Subject<void>();\n\n      const monitor$ = source$.pipe(\n        take(1),\n        switchMap(() => timer(100)),\n        tap(() => {\n          console.warn(\n            `withCalls \"${callName}\" did not complete after the first value and is using the default \"exhaustMap\" pipe. This means that subsequent values from params will be ignored until the observable completes. Please specify the mapPipe operator or use an observable that completes to avoid this warning.`,\n          );\n        }),\n        takeUntil(completed$),\n        ignoreElements(),\n      );\n\n      return merge(monitor$, source$);\n    };\n  } else {\n    return (params) => from(call(params));\n  }\n}\ntype NotUndefined<T> = T extends undefined ? never : T;\n","import { capitalize } from '../util';\nimport {\n  createEvent,\n  props,\n} from '../with-event-handler/with-event-handler.util';\n\nexport function getWithCallStatusMapKeys(config: {\n  prop: string;\n  supportPrivate?: boolean;\n}) {\n  let prop = config.prop;\n  let prefix = '';\n\n  if (config?.supportPrivate && prop.startsWith('_')) {\n    prop = prop.slice(1);\n    prefix = '_';\n  }\n\n  const capitalizedProp = capitalize(prop);\n  return {\n    callStatusKey: `${prefix}${prop}CallStatus`,\n    loadingKey: `${prefix}is${capitalizedProp}Loading`,\n    loadedKey: `${prefix}is${capitalizedProp}Loaded`,\n    errorKey: `${prefix}${prop}Error`,\n    areAllLoadedKey: `areAll${capitalizedProp}Loaded`,\n    isAnyLoadingKey: `isAny${capitalizedProp}Loading`,\n    errorsKey: `${prop}Errors`,\n    setLoadingKey: `${prefix}set${capitalizedProp}Loading`,\n    setLoadedKey: `${prefix}set${capitalizedProp}Loaded`,\n    setErrorKey: `${prefix}set${capitalizedProp}Error`,\n  };\n}\n\nexport function getWithCallStatusMapEvents(config?: { prop: string }) {\n  const collection = config?.prop;\n  return {\n    callLoading: createEvent(\n      `${collection}.callLoading`,\n      props<{ id: string }>(),\n    ),\n    callLoaded: createEvent(\n      `${collection}.callLoaded`,\n      props<{ id: string }>(),\n    ),\n    callError: createEvent(\n      `${collection}.callError`,\n      props<{ id: string; error: unknown }>(),\n    ),\n  };\n}\n","import { computed, Signal } from '@angular/core';\nimport {\n  patchState,\n  SignalStoreFeature,\n  signalStoreFeature,\n  SignalStoreFeatureResult,\n  withComputed,\n  withMethods,\n  withState,\n} from '@ngrx/signals';\n\nimport { registerCallState } from '../with-all-call-status/with-all-call-status.util';\nimport { CallStatus } from '../with-call-status/with-call-status.model';\nimport {\n  broadcast,\n  withEventHandler,\n} from '../with-event-handler/with-event-handler';\nimport { withFeatureFactory } from '../with-feature-factory/with-feature-factory';\nimport {\n  FeatureConfigFactory,\n  getFeatureConfig,\n  StoreSource,\n} from '../with-feature-factory/with-feature-factory.model';\nimport {\n  NamedCallStatusMapComputed,\n  NamedCallStatusMapMethods,\n  NamedCallStatusMapState,\n} from './with-call-status-map.model';\nimport {\n  getWithCallStatusMapEvents,\n  getWithCallStatusMapKeys,\n} from './with-call-status-map.util';\n\n/**\n * Generates necessary state, computed and methods for call progress status but map by a key, allowing to implement\n * calls of the same type that run on parallel each with its own status.\n * @param configFactory - The configuration object for the feature or a factory function that receives the store and returns the configuration object\n * @param configFactory.prop - The name of the property for which this represents the call status\n * @param configFactory.initialValue - The initial value of the call status\n * @param configFactory.collection - The name of the collection for which this represents the call status is an alias to prop param\n * @param configFactory.errorType - The type of the error\n * they do the same thing\n *\n * prop or collection is required\n * @example\n * export const Store = signalStore(\n *   { providedIn: 'root' },\n *   withEntities(orderEntity),\n *   withCallStatusMap({ prop: 'loadDetails' }),\n *   withMethods((store) => ({\n *     loadProducts: rxMethod<{ orderId: string }>(\n *       pipe(\n *         switchMap((params) => {\n *           store.setLoadDetailsLoading(params.orderId);\n *           return inject(OrderService)\n *             .getOrderDetail(params.orderId)\n *             .pipe(\n *               tap((res) =>\n *                 patchState(\n *                   store,\n *                   updateEntity(\n *                     {\n *                       id: params.orderId,\n *                       changes: { items: res.items },\n *                     },\n *                     orderEntity,\n *                   ),\n *                 ),\n *               ),\n *               catchError((error) => {\n *                 store.setLoadDetailsError(params.orderId, error);\n *                 return EMPTY;\n *               }),\n *             );\n *         }),\n *       ),\n *     ),\n *   })),\n * );\n *\n *  // generates the following signals\n *  store.loadDetailsCallStatus // '{[key:string]: init' | 'loading' | 'loaded' | { error: unknown }}\n *  // generates the following computed signals\n *  store.isAnyLoadDetailsLoading() // boolean\n *  store.areAllLoadDetailsLoaded // boolean\n *  store.loadDetailsErrors() // Errors[] | undefined\n *  // generates the following methods\n *  store.isLoadDetailsLoading(key: string) // boolean\n *  store.isLoadDetailsLoaded(key: string) // boolean\n *  store.loadDetailsError(key: string) // unknown | null\n *  store.setLoadDetailsLoading(key: string) // () => void\n *  store.setLoadDetailsLoaded(key: string) // () => void\n *  store.setLoadDetailsError(key: string) // (error?: unknown) => void\n */\n\nexport function withCallStatusMap<\n  Input extends SignalStoreFeatureResult,\n  Prop extends string = '',\n  Error = unknown,\n>(\n  configFactory: FeatureConfigFactory<\n    Input,\n    {\n      initialValue?: Record<string | number, CallStatus>;\n      errorType?: Error;\n      prop: Prop;\n    }\n  >,\n): SignalStoreFeature<\n  Input & { state: {}; props: {}; methods: {} },\n  {\n    state: NamedCallStatusMapState<Prop>;\n    props: NamedCallStatusMapComputed<Prop, Error>;\n    methods: NamedCallStatusMapMethods<Prop, Error>;\n  }\n> {\n  return withFeatureFactory((store: StoreSource<Input>) => {\n    const config = getFeatureConfig(configFactory, store);\n\n    const prop = config.prop;\n    const {\n      callStatusKey,\n      errorKey,\n      loadedKey,\n      loadingKey,\n      isAnyLoadingKey,\n      areAllLoadedKey,\n      errorsKey,\n      setLoadingKey,\n      setLoadedKey,\n      setErrorKey,\n    } = getWithCallStatusMapKeys({ prop });\n\n    const { callLoaded, callLoading, callError } = getWithCallStatusMapEvents({\n      prop,\n    });\n    return signalStoreFeature(\n      withState({ [callStatusKey]: config.initialValue ?? {} }),\n      withComputed((state: Record<string, Signal<unknown>>) => {\n        const callState = state[callStatusKey] as Signal<\n          Record<string, CallStatus>\n        >;\n\n        const isAnyLoading = computed(() =>\n          Object.values(callState()).some((status) => status === 'loading'),\n        );\n        const areAllLoaded = computed(() => {\n          const values = Object.values(callState());\n          return values?.length\n            ? values.every((status) => status === 'loaded')\n            : false;\n        });\n\n        const errors = computed(() => {\n          const v = callState();\n          const errorsArray = Object.values(v)\n            .map((v) => (typeof v === 'object' ? v.error : undefined))\n            .filter(Boolean);\n          return errorsArray?.length ? errorsArray : undefined;\n        });\n\n        registerCallState(store, { loading: isAnyLoading, error: errors });\n\n        return {\n          [isAnyLoadingKey]: isAnyLoading,\n          [errorsKey]: errors,\n          [areAllLoadedKey]: areAllLoaded,\n        };\n      }),\n      withEventHandler(),\n      withMethods((store) => {\n        const callState = store[callStatusKey] as unknown as Signal<\n          Record<string, CallStatus>\n        >;\n        const isLoading = (id: string) => callState()[id] === 'loading';\n        const isLoaded = (id: string) => callState()[id] === 'loaded';\n        const error = (id: string) => {\n          const v = callState()[id];\n          return typeof v === 'object' ? v.error : undefined;\n        };\n        const setLoading = (id: string) => {\n          patchState(store, {\n            [callStatusKey]: { ...callState(), [id]: 'loading' },\n          } as any);\n          broadcast(store, callLoading({ id }));\n        };\n        const setLoaded = (id: string) => {\n          patchState(store, {\n            [callStatusKey]: { ...callState(), [id]: 'loaded' },\n          } as any);\n          broadcast(store, callLoaded({ id }));\n        };\n        const setError = (id: string, error: unknown) => {\n          patchState(store, {\n            [callStatusKey]: { ...callState(), [id]: { error } },\n          } as any);\n          broadcast(store, callError({ id, error }));\n        };\n        return {\n          [loadingKey]: isLoading,\n          [loadedKey]: isLoaded,\n          [errorKey]: error,\n          [setLoadingKey]: setLoading,\n          [setLoadedKey]: setLoaded,\n          [setErrorKey]: setError,\n        };\n      }),\n    );\n  }) as any;\n}\n","import { CallConfig } from './with-calls.model';\n\n/**\n * Call configuration object for withCalls\n * @param config - the call configuration\n * @param config.call - required, the function that will be called\n * @param config.mapPipe - optional, default exhaustMap the pipe operator that will be used to map the call result\n * @param config.storeResult - optional, default true, if false, the result will not be stored in the store\n * @param config.resultProp - optional, default callName + 'Result', the name of the prop where the result will be stored\n * @param config.onSuccess - optional, a function that will be called when the call is successful\n * @param config.mapError - optional, a function that will be called to transform the error before storing it\n * @param config.onError - optional, a function that will be called when the call fails\n * @param config.skipWhen - optional, a function that will be called to determine if the call should be skipped\n * @param config.callWith - optional, reactively execute the call with the provided params return by a function or observable\n * @param config.defaultResult - optional, A default value for the result before the call is executed\n */\nexport function callConfig<\n  Param = undefined,\n  Result = any,\n  PropName extends string = '',\n  Error = unknown,\n  C extends CallConfig<Param, Result, PropName, Error, Result> = CallConfig<\n    Param,\n    Result,\n    PropName,\n    Error,\n    Result\n  >,\n  DefaultResult extends Result | undefined = undefined,\n>(\n  config: Omit<\n    CallConfig<Param, Result, PropName, Error>,\n    'resultProp' | 'storeResult' | 'defaultResult'\n  > & {\n    resultProp?: PropName;\n    defaultResult: NoInfer<Result>;\n  },\n): C;\n/**\n * Call configuration object for withCalls\n * @param config - the call configuration\n * @param config.call - required, the function that will be called\n * @param config.mapPipe - optional, default exhaustMap the pipe operator that will be used to map the call result\n * @param config.storeResult - optional, default true, if false, the result will not be stored in the store\n * @param config.resultProp - optional, default callName + 'Result', the name of the prop where the result will be stored\n * @param config.onSuccess - optional, a function that will be called when the call is successful\n * @param config.mapError - optional, a function that will be called to transform the error before storing it\n * @param config.onError - optional, a function that will be called when the call fails\n * @param config.skipWhen - optional, a function that will be called to determine if the call should be skipped\n * @param config.callWith - optional, reactively execute the call with the provided params return by a function or observable\n * @param config.defaultResult - optional, A default value for the result before the call is executed\n */\nexport function callConfig<\n  Param = undefined,\n  Result = any,\n  PropName extends string = '',\n  Error = unknown,\n  C extends CallConfig<Param, Result, PropName, Error, undefined> = CallConfig<\n    Param,\n    Result,\n    PropName,\n    Error,\n    undefined\n  >,\n  DefaultResult extends Result | undefined = undefined,\n>(\n  config: Omit<\n    CallConfig<Param, Result, PropName, Error>,\n    'resultProp' | 'storeResult' | 'defaultResult'\n  > & {\n    resultProp?: PropName;\n  },\n): C;\n/**\n * Call configuration object for withCalls\n * @param config - the call configuration\n * @param config.call - required, the function that will be called\n * @param config.mapPipe - optional, default exhaustMap the pipe operator that will be used to map the call result\n * @param config.storeResult - optional, default true, if false, the result will not be stored in the store\n * @param config.resultProp - optional, default callName + 'Result', the name of the prop where the result will be stored\n * @param config.onSuccess - optional, a function that will be called when the call is successful\n * @param config.mapError - optional, a function that will be called to transform the error before storing it\n * @param config.onError - optional, a function that will be called when the call fails\n * @param config.skipWhen - optional, a function that will be called to determine if the call should be skipped\n * @param config.callWith - optional, reactively execute the call with the provided params return by a function or observable\n * @param config.defaultResult - optional, A default value for the result before the call is executed\n */\nexport function callConfig<\n  Param = undefined,\n  Result = any,\n  Error = unknown,\n  C extends Omit<\n    CallConfig<Param, Result, '', Error>,\n    'resultProp' | 'storeResult' | 'defaultResult'\n  > & { storeResult: false } = Omit<\n    CallConfig<Param, Result, '', Error>,\n    'resultProp' | 'storeResult' | 'defaultResult'\n  > & { storeResult: false },\n>(\n  config: Omit<\n    CallConfig<Param, Result, '', Error>,\n    'resultProp' | 'storeResult' | 'defaultResult'\n  > & { storeResult: false },\n): C & { resultProp: ''; defaultResult: undefined };\nexport function callConfig(config: any): any {\n  return { ...config, resultProp: config.resultProp ?? '' };\n}\n\n// ===== Old version\n\n/**\n * Call configuration object for withCalls\n * @Deprecated renamed to callConfig()\n * @param config - the call configuration\n * @param config.call - required, the function that will be called\n * @param config.mapPipe - optional, default exhaustMap the pipe operator that will be used to map the call result\n * @param config.storeResult - optional, default true, if false, the result will not be stored in the store\n * @param config.resultProp - optional, default callName + 'Result', the name of the prop where the result will be stored\n * @param config.onSuccess - optional, a function that will be called when the call is successful\n * @param config.mapError - optional, a function that will be called to transform the error before storing it\n * @param config.onError - optional, a function that will be called when the call fails\n * @param config.skipWhen - optional, a function that will be called to determine if the call should be skipped\n * @param config.callWith - optional, reactively execute the call with the provided params return by a function or observable\n * @param config.defaultResult - optional, A default value for the result before the call is executed\n */\nexport function typedCallConfig<\n  Param = undefined,\n  Result = any,\n  PropName extends string = '',\n  Error = unknown,\n  C extends CallConfig<Param, Result, PropName, Error, Result> = CallConfig<\n    Param,\n    Result,\n    PropName,\n    Error,\n    Result\n  >,\n  DefaultResult extends Result | undefined = undefined,\n>(\n  config: Omit<\n    CallConfig<Param, Result, PropName, Error>,\n    'resultProp' | 'storeResult' | 'defaultResult'\n  > & {\n    resultProp?: PropName;\n    defaultResult: NoInfer<Result>;\n  },\n): C;\n/**\n * Call configuration object for withCalls\n * @Deprecated renamed to callConfig()\n * @param config - the call configuration\n * @param config.call - required, the function that will be called\n * @param config.mapPipe - optional, default exhaustMap the pipe operator that will be used to map the call result\n * @param config.storeResult - optional, default true, if false, the result will not be stored in the store\n * @param config.resultProp - optional, default callName + 'Result', the name of the prop where the result will be stored\n * @param config.onSuccess - optional, a function that will be called when the call is successful\n * @param config.mapError - optional, a function that will be called to transform the error before storing it\n * @param config.onError - optional, a function that will be called when the call fails\n * @param config.skipWhen - optional, a function that will be called to determine if the call should be skipped\n * @param config.callWith - optional, reactively execute the call with the provided params return by a function or observable\n * @param config.defaultResult - optional, A default value for the result before the call is executed\n */\nexport function typedCallConfig<\n  Param = undefined,\n  Result = any,\n  PropName extends string = '',\n  Error = unknown,\n  C extends CallConfig<Param, Result, PropName, Error, undefined> = CallConfig<\n    Param,\n    Result,\n    PropName,\n    Error,\n    undefined\n  >,\n  DefaultResult extends Result | undefined = undefined,\n>(\n  config: Omit<\n    CallConfig<Param, Result, PropName, Error>,\n    'resultProp' | 'storeResult' | 'defaultResult'\n  > & {\n    resultProp?: PropName;\n  },\n): C;\n/**\n * Call configuration object for withCalls\n * @Deprecated renamed to callConfig()\n * @param config - the call configuration\n * @param config.call - required, the function that will be called\n * @param config.mapPipe - optional, default exhaustMap the pipe operator that will be used to map the call result\n * @param config.storeResult - optional, default true, if false, the result will not be stored in the store\n * @param config.resultProp - optional, default callName + 'Result', the name of the prop where the result will be stored\n * @param config.onSuccess - optional, a function that will be called when the call is successful\n * @param config.mapError - optional, a function that will be called to transform the error before storing it\n * @param config.onError - optional, a function that will be called when the call fails\n * @param config.skipWhen - optional, a function that will be called to determine if the call should be skipped\n * @param config.callWith - optional, reactively execute the call with the provided params return by a function or observable\n * @param config.defaultResult - optional, A default value for the result before the call is executed\n */\nexport function typedCallConfig<\n  Param = undefined,\n  Result = any,\n  Error = unknown,\n  C extends Omit<\n    CallConfig<Param, Result, '', Error>,\n    'resultProp' | 'storeResult' | 'defaultResult'\n  > & { storeResult: false } = Omit<\n    CallConfig<Param, Result, '', Error>,\n    'resultProp' | 'storeResult' | 'defaultResult'\n  > & { storeResult: false },\n>(\n  config: Omit<\n    CallConfig<Param, Result, '', Error>,\n    'resultProp' | 'storeResult' | 'defaultResult'\n  > & { storeResult: false },\n): C & { resultProp: ''; defaultResult: undefined };\nexport function typedCallConfig(config: any): any {\n  return { ...config, resultProp: config.resultProp ?? '' };\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport { effect, inject, isDevMode, PLATFORM_ID } from '@angular/core';\nimport {\n  getState,\n  patchState,\n  Prettify,\n  SignalStoreFeature,\n  signalStoreFeature,\n  SignalStoreFeatureResult,\n  StateSignals,\n  type,\n  withHooks,\n  withMethods,\n  WritableStateSource,\n} from '@ngrx/signals';\n\nimport { combineFunctionsInObject } from '../util';\nimport { StoreSource } from '../with-feature-factory/with-feature-factory.model';\nimport { StorageValueMapper } from './with-sync-to-web-storage.util';\n\n/**\n * Sync the state of the store to the web storage\n * @param key - the key to use in the web storage\n * @param type - 'session' or 'local' storage\n * @param saveStateChangesAfterMs - save the state to the storage after this many milliseconds, 0 to disable\n * @param restoreOnInit - restore the state from the storage on init\n * @param filterState - filter the state before saving to the storage (mutually exclusive with valueMapper)\n * @param valueMapper - custom transformation between store state and storage value (mutually exclusive with filterState)\n * @param onRestore - callback after the state is restored from the storage\n * @param expires - storage will not be loaded if is older than this many milliseconds\n *\n * @example\n * // Example 1: Using filterState to save specific state properties\n * const store = signalStore(\n *  withEntities({ entity, collection }),\n *  withCallStatus({ prop: collection, initialValue: 'loading' }),\n *\n *  withSyncToWebStorage({\n *      key: 'my-key',\n *      type: 'session',\n *      restoreOnInit: true,\n *      saveStateChangesAfterMs: 300,\n *      // optionally, filter the state before saving to the storage\n *      filterState: ({ orderItemsEntityMap, orderItemsIds }) => ({\n *       orderItemsEntityMap,\n *       orderItemsIds,\n *     }),\n *  }),\n *  );\n *\n * @example\n * // Example 2: Using valueMapper for custom transformation\n * const store = signalStore(\n *  withState({\n *    userProfile: {\n *      userName: '',\n *      email: '',\n *      preferences: { theme: 'light', notifications: true },\n *      tempData: null,\n *    }\n *  }),\n *\n *  withSyncToWebStorage({\n *      key: 'user-form',\n *      type: 'local',\n *      restoreOnInit: true,\n *      saveStateChangesAfterMs: 500,\n *      // Custom mapper to store only userName and email\n *      valueMapper: (store) => ({\n *        stateToStorageValue: () => ({\n *          userName: store.userProfile().userName,\n *          email: store.userProfile().email,\n *        }),\n *        storageValueToState: (savedData) => {\n *          patchState(store, {\n *            userProfile: {\n *              ...store.userProfile(),\n *              userName: savedData.userName,\n *              email: savedData.email,\n *            }\n *          });\n *        },\n *      }),\n *  }),\n *  );\n *\n *  // generates the following methods\n *  store.saveToStorage();\n *  store.loadFromStorage();\n *  store.clearFromStore();\n *\n */\nexport function withSyncToWebStorage<Input extends SignalStoreFeatureResult>({\n  key,\n  type: storageType,\n  saveStateChangesAfterMs = 500,\n  restoreOnInit = true,\n  onRestore,\n  expires,\n  ...rest\n}: {\n  key: string;\n  type: 'session' | 'local';\n  restoreOnInit?: boolean;\n  saveStateChangesAfterMs?: number;\n  expires?: number;\n  onRestore?: (store: StoreSource<Input>) => void;\n} & (\n  | {\n      filterState: (state: Input['state']) => Partial<Input['state']>;\n    }\n  | { valueMapper: StorageValueMapper<any, StoreSource<Input>> }\n  | {}\n)): SignalStoreFeature<\n  Input,\n  {\n    state: {};\n    props: {};\n    methods: {\n      saveToStorage: () => void;\n      loadFromStorage: () => void;\n      clearFromStore: () => void;\n    };\n  }\n> {\n  return signalStoreFeature(\n    type<Input>(),\n    withMethods((store: WritableStateSource<Input['state']>) => {\n      const isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n      const filterState = (rest as any).filterState;\n      const valueMapper = (rest as any).valueMapper?.(store);\n      return combineFunctionsInObject(\n        {\n          saveToStorage() {\n            if (!isBrowser) {\n              isDevMode() &&\n                console.warn(\n                  `${key} saveToStorage skipped - not running in browser`,\n                );\n              return;\n            }\n            const state = filterState\n              ? filterState(getState(store))\n              : valueMapper\n                ? valueMapper.stateToStorageValue()\n                : getState(store);\n            if (storageType === 'local') {\n              window.localStorage.setItem(key, JSON.stringify(state));\n              window.localStorage.setItem(\n                key + '-date',\n                new Date().toISOString(),\n              );\n            } else {\n              window.sessionStorage.setItem(key, JSON.stringify(state));\n              window.sessionStorage.setItem(\n                key + '-date',\n                new Date().toISOString(),\n              );\n            }\n          },\n          loadFromStorage(): boolean {\n            if (!isBrowser) {\n              return false;\n            }\n            let stateJson =\n              storageType === 'local'\n                ? window.localStorage.getItem(key)\n                : window.sessionStorage.getItem(key);\n            if (!stateJson) {\n              return false;\n            }\n            if (expires) {\n              const dateStr =\n                storageType === 'local'\n                  ? window.localStorage.getItem(key + '-date')\n                  : window.sessionStorage.getItem(key + '-date');\n              if (dateStr == null) {\n                return false;\n              }\n              const date = new Date(dateStr);\n              if (new Date().getTime() - date.getTime() > expires) {\n                isDevMode() &&\n                  console.warn(`${key} ${storageType} web storage expired`);\n                return false;\n              }\n            }\n            if (valueMapper) {\n              valueMapper.storageValueToState(JSON.parse(stateJson));\n            } else patchState(store, JSON.parse(stateJson));\n            onRestore?.(store as StoreSource<Input>);\n            return true;\n          },\n          clearFromStore() {\n            if (!isBrowser) {\n              isDevMode() &&\n                console.warn(\n                  `${key} clearFromStore skipped - not running in browser`,\n                );\n              return;\n            }\n            if (storageType === 'local') window.localStorage.removeItem(key);\n            else window.sessionStorage.removeItem(key);\n          },\n        },\n        store,\n      );\n    }),\n    withHooks(({ loadFromStorage, saveToStorage, ...store }) => ({\n      onInit() {\n        if (restoreOnInit) loadFromStorage();\n\n        if (saveStateChangesAfterMs) {\n          effect(() => {\n            getState(store as any); // we call this just so this effect is triggered when the state changes\n            const timeout = setTimeout(() => {\n              saveToStorage();\n            }, saveStateChangesAfterMs);\n            return () => {\n              clearTimeout(timeout);\n            };\n          });\n        }\n      },\n    })),\n  );\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport {\n  effect,\n  inject,\n  makeStateKey,\n  PLATFORM_ID,\n  TransferState,\n} from '@angular/core';\nimport {\n  getState,\n  patchState,\n  SignalStoreFeature,\n  signalStoreFeature,\n  SignalStoreFeatureResult,\n  type,\n  withHooks,\n  WritableStateSource,\n} from '@ngrx/signals';\n\nimport { StoreSource } from '../with-feature-factory/with-feature-factory.model';\nimport { TransferValueMapper } from './with-server-state-transfer.util';\n\n/**\n * Sync the state of the store using Angular's TransferState API for SSR\n * @param key - the key to use in the TransferState\n * @param filterState - filter the state before saving to TransferState (mutually exclusive with valueMapper)\n * @param valueMapper - custom transformation between store state and transfer value (mutually exclusive with filterState)\n * @param onRestore - callback after the state is restored from TransferState\n *\n * @example\n * // Example 1: Using filterState to transfer specific state properties\n * const store = signalStore(\n *  withEntities({ entity, collection }),\n *  withCallStatus({ prop: collection, initialValue: 'loading' }),\n *\n *  withServerStateTransfer({\n *      key: 'my-state',\n *      // optionally, filter the state before transferring\n *      filterState: ({ orderItemsEntityMap, orderItemsIds }) => ({\n *       orderItemsEntityMap,\n *       orderItemsIds,\n *     }),\n *  }),\n *  );\n *\n * @example\n * // Example 2: Using valueMapper for custom transformation\n * const store = signalStore(\n *  withState({\n *    userProfile: {\n *      userName: '',\n *      email: '',\n *      preferences: { theme: 'light', notifications: true },\n *      tempData: null,\n *    }\n *  }),\n *\n *  withServerStateTransfer({\n *      key: 'user-profile',\n *      // Custom mapper to transfer only userName and email\n *      valueMapper: (store) => ({\n *        stateToTransferValue: () => ({\n *          userName: store.userProfile().userName,\n *          email: store.userProfile().email,\n *        }),\n *        transferValueToState: (savedData) => {\n *          patchState(store, {\n *            userProfile: {\n *              ...store.userProfile(),\n *              userName: savedData.userName,\n *              email: savedData.email,\n *            }\n *          });\n *        },\n *      }),\n *  }),\n *  );\n *\n */\nexport function withServerStateTransfer<Input extends SignalStoreFeatureResult>({\n  key,\n  onRestore,\n  ...rest\n}: {\n  key: string;\n  onRestore?: (store: StoreSource<Input>) => void;\n} & (\n  | {\n      filterState: (state: Input['state']) => Partial<Input['state']>;\n    }\n  | { valueMapper: TransferValueMapper<any, StoreSource<Input>> }\n  | {}\n)): SignalStoreFeature<Input, { state: {}; props: {}; methods: {} }> {\n  return signalStoreFeature(\n    type<Input>(),\n    withHooks((store: WritableStateSource<Input['state']>) => {\n      const transferState = inject(TransferState);\n      const isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n      const filterState = (rest as any).filterState;\n      const valueMapper = (rest as any).valueMapper?.(store);\n      const stateKey = makeStateKey<any>(key);\n\n      return {\n        onInit() {\n          if (isBrowser) {\n            // Client side: restore state from TransferState\n            const transferredState = transferState.get(stateKey, null);\n            if (transferredState) {\n              if (valueMapper) {\n                valueMapper.transferValueToState(transferredState);\n              } else {\n                patchState(store, transferredState);\n              }\n              onRestore?.(store as StoreSource<Input>);\n              // Clean up TransferState after restoration\n              transferState.remove(stateKey);\n            }\n          } else {\n            // Server side: save state changes to TransferState\n            effect(() => {\n              const state = filterState\n                ? filterState(getState(store))\n                : valueMapper\n                  ? valueMapper.stateToTransferValue()\n                  : getState(store);\n              transferState.set(stateKey, state);\n            });\n          }\n        },\n      };\n    }),\n  );\n}\n","import {\n  computed,\n  DestroyRef,\n  EnvironmentInjector,\n  inject,\n  Injector,\n  runInInjectionContext,\n} from '@angular/core';\nimport { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';\nimport { ActivatedRoute, Router } from '@angular/router';\nimport {\n  SignalStoreFeature,\n  signalStoreFeature,\n  SignalStoreFeatureResult,\n  type,\n  withHooks,\n  withMethods,\n  withProps,\n} from '@ngrx/signals';\nimport { concatWith, debounce, defaultIfEmpty, NEVER, timer } from 'rxjs';\n\nimport { combineFunctionsInObject } from '../util';\nimport { StoreSource } from '../with-feature-factory/with-feature-factory.model';\nimport { QueryMapper } from './with-sync-to-route-query-params.util';\n\n/**\n * Syncs the route query params with the store and back. On init it will load\n * the query params once and set them in the store using the mapper.queryParamsToState, after that\n * and change on the store will be reflected in the query params using the mapper.stateToQueryParams\n * @param config.mappers - The mappers to sync the query params with the store\n * @param config.defaultDebounce - The debounce time to wait before updating the query params from the store\n *\n * @example\n *     const Store = signalStore(\n *       withState({\n *         test: 'test',\n *         foo: 'foo',\n *         bar: false,\n *       }),\n *       withSyncToRouteQueryParams({\n *         mappers: [\n *           {\n *             queryParamsToState: (query, store) => {\n *             // set the query params in the store (only called once on init)\n *               patchState(store, {\n *                 test: query.test,\n *                 foo: query.foo,\n *                 bar: query.bar === 'true',\n *               });\n *             },\n *             stateToQueryParams: (store) =>\n *               // return the query params to be set in the route\n *               computed(() => ({\n *                 test: store.test(),\n *                 foo: store.foo(),\n *                 bar: store.bar().toString(),\n *               })),\n *           },\n *         ],\n *         defaultDebounce: debounce,\n *       }),\n *     );\n */\nexport function withSyncToRouteQueryParams<\n  Input extends SignalStoreFeatureResult,\n  Params extends Record<string, any>,\n  Mappers extends ReadonlyArray<QueryMapper<any, StoreSource<Input>, Input>>,\n>(config: {\n  mappers: Mappers;\n  defaultDebounce?: number;\n  restoreOnInit?: boolean;\n  onQueryParamsStored?: (store: StoreSource<Input>) => void;\n}): SignalStoreFeature<\n  Input,\n  {\n    state: {};\n    props: {};\n    methods: {\n      loadFromQueryParams: () => void;\n    };\n  }\n> {\n  // per instance holder for the last query params this store pushed to the url.\n  // It has to live on the store because withHooks writes it and withMethods\n  // reads it, and it is symbol keyed so it stays off the store public api.\n  const LAST_PUSHED_QUERY_PARAMS = Symbol('lastPushedQueryParams');\n  return signalStoreFeature(\n    type<Input>(),\n    withProps(() => ({\n      [LAST_PUSHED_QUERY_PARAMS]: {\n        value: undefined as Record<string, unknown> | undefined,\n      },\n    })),\n    withMethods((store) => {\n      const injector = inject(Injector);\n      const environmentInjector = inject(EnvironmentInjector);\n      const destroyRef = inject(DestroyRef);\n      const lastPushedQueryParams = store[LAST_PUSHED_QUERY_PARAMS];\n      // per store instance, true until the first query params emission has been\n      // restored into the store. Mappers receive it so they can force the load\n      // and honour skipLoadingCall only on that first restore.\n      let firstLoad = true;\n      return combineFunctionsInObject(\n        {\n          loadFromQueryParams: () => {\n            const activatedRoute = injector.get(ActivatedRoute);\n            activatedRoute.queryParams\n              .pipe(\n                defaultIfEmpty({}), // Provide default empty object if observable completes without emitting\n                takeUntilDestroyed(destroyRef),\n              )\n              .subscribe((queryParams) => {\n                if (\n                  shallowEqualParams(lastPushedQueryParams.value, queryParams)\n                ) {\n                  return;\n                }\n                runInInjectionContext(environmentInjector, () => {\n                  const queryMappers = config.mappers;\n                  queryMappers.forEach((mapper) => {\n                    mapper.queryParamsToState(\n                      queryParams as Params,\n                      store as any,\n                      firstLoad,\n                    );\n                  });\n                  firstLoad = false;\n                  config.onQueryParamsStored?.(store);\n                });\n              });\n          },\n        },\n        store,\n      );\n    }),\n    withHooks((store) => {\n      const router = inject(Router);\n      const lastPushedQueryParams = store[LAST_PUSHED_QUERY_PARAMS];\n      return {\n        onInit: () => {\n          if (config.restoreOnInit ?? true) {\n            store.loadFromQueryParams();\n          }\n\n          const activatedRoute = inject(ActivatedRoute);\n          const changesSignals = config.mappers\n            .map((mapper) => mapper.stateToQueryParams(store as any))\n            .filter((mapper) => !!mapper);\n\n          const computedChanges = computed(() => {\n            const queryParams = changesSignals.reduce((acc, mapper) => {\n              return {\n                ...acc,\n                ...mapper?.(),\n              };\n            }, {});\n            return queryParams;\n          });\n          // the first push only reflects the initial state into the url, so it\n          // replaces the current history entry rather than adding one.\n          // Otherwise every sync feature in the store would cost the user an\n          // extra back navigation to get off the page.\n          let firstPush = true;\n          toObservable(computedChanges)\n            .pipe(\n              concatWith(NEVER),\n              debounce(() => timer(config.defaultDebounce ?? 300)),\n              takeUntilDestroyed(),\n            )\n            .subscribe((queryParams) => {\n              const lastParams: Record<string, unknown> = {\n                ...(activatedRoute.snapshot?.queryParams || {}),\n                ...queryParams,\n              };\n              for (const key of Object.keys(lastParams)) {\n                // undefined params will be deleted from the url so we should\n                // not store them\n                if (lastParams[key] === undefined) {\n                  delete lastParams[key];\n                }\n              }\n              lastPushedQueryParams.value = lastParams;\n              // replaceUrl defaults to false, so it is only set when needed to\n              // keep the navigation extras unchanged for later pushes\n              const replaceUrlExtra = firstPush ? { replaceUrl: true } : {};\n              firstPush = false;\n              router\n                .navigate([], {\n                  relativeTo: activatedRoute,\n                  queryParams,\n                  queryParamsHandling: 'merge',\n                  ...replaceUrlExtra,\n                })\n                .catch((error) => {\n                  console.error(\n                    'withSyncToRouteQueryParams: failed to sync the store to the route query params',\n                    error,\n                  );\n                });\n            });\n        },\n      };\n    }),\n  ) as any;\n}\n\nfunction shallowEqualParams(\n  a: Record<string, unknown> | undefined,\n  b: Record<string, unknown>,\n): boolean {\n  if (!a) return false;\n  const aKeys = Object.keys(a);\n  if (aKeys.length !== Object.keys(b).length) return false;\n  return aKeys.every((k) => a[k] === b[k]);\n}\n","import { computed, Signal } from '@angular/core';\nimport { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';\nimport {\n  SignalStoreFeature,\n  signalStoreFeature,\n  SignalStoreFeatureResult,\n  type,\n  withHooks,\n} from '@ngrx/signals';\nimport { concatMap, first } from 'rxjs';\n\nimport {\n  RequireEntities,\n  RequireEntitiesCallStatus,\n} from '../feature-requirements.model';\nimport { getWithCallStatusKeys } from '../with-call-status/with-call-status.util';\nimport {\n  FilterQueryMapper,\n  getQueryMapperForEntitiesFilter,\n} from '../with-entities-filter/with-entities-filter.util';\nimport { getQueryMapperForEntitiesPagination } from '../with-entities-pagination/with-entities-local-pagination.util';\nimport { getQueryMapperForMultiSelection } from '../with-entities-selection/with-entities-multi-selection.util';\nimport { getQueryMapperForSingleSelection } from '../with-entities-selection/with-entities-single-selection.util';\nimport { getQueryMapperForEntitiesSort } from '../with-entities-sort/with-entities-local-sort.util';\nimport { StoreSource } from '../with-feature-factory/with-feature-factory.model';\nimport { withSyncToRouteQueryParams } from './with-sync-to-route-query-params';\nimport { QueryMapper } from './with-sync-to-route-query-params.util';\n\n/**\n * Syncs entities filter, pagination, sort and single selection to route query params for local or remote entities store features. If a collection is provided, it will be used as a prefix (if non is provided) for the query params.\n * The prefix can be disabled by setting it to false, or changed by providing a string. The filterMapper can be used to customize how the filter object is map to a query params object,\n * when is not provided the filter will use JSON.stringify to serialize the filter object.\n *\n * Requires withEntities and withCallStatus to be present in the store.\n *\n * @param config.collection The collection name to use as a prefix for the query params. If not provided, the collection name will be used.\n * @param config.filterMapper A function to map the filter object to a query params object.\n * @param config.prefix The prefix to use for the query params. If set to false, the prefix will be disabled.\n * @param config.onQueryParamsLoaded A function to be called when the query params are loaded into the store, (only gets called once).\n * @param config.defaultDebounce The default debounce time to use sync the store changes back to the route query params.\n * @param config.skipLoadingCall When true, restoring state from query params will update the store state but will not trigger a backend call to fetch entities. Default is false.\n *\n * @example\n * export const ProductsRemoteStore = signalStore(\n *   { providedIn: 'root' },\n *   // requires at least withEntities and withCallStatus\n *   withEntities({ entity, collection }),\n *   withCallStatus({ collection, initialValue: 'loading' }),\n *   withEntitiesRemoteFilter({\n *     entity,\n *     collection,\n *   }),\n *   withEntitiesRemotePagination({\n *     entity,\n *     collection,\n *   }),\n *   withEntitiesRemoteSort({\n *     entity,\n *     collection,\n *     defaultSort: { field: 'name', direction: 'asc' },\n *   }),\n *   withEntitiesLoadingCall({\n *     collection,\n *     fetchEntities: ({ productEntitiesFilter, productEntitiesPagedRequest, productEntitiesSort }) => {\n *       return inject(ProductService)\n *         .getProducts({\n *           search: productEntitiesFilter().name,\n *           take: productEntitiesPagedRequest().size,\n *           skip: productEntitiesPagedRequest().startIndex,\n *           sortColumn: productEntitiesSort().field,\n *           sortAscending: productEntitiesSort().direction === 'asc',\n *         })\n *         .pipe(\n *           map((d) => ({\n *             entities: d.resultList,\n *             total: d.total,\n *           })),\n *         );\n *     },\n *   }),\n *   // syncs the entities filter, pagination, sort and single selection to the route query params\n *   withEntitiesSyncToRouteQueryParams({\n *     entity,\n *     collection,\n *   })\n *);\n *\n * @example\n * // this feature only covers the entities params, any other state that should\n * // survive a reload is synced by adding withSyncToRouteQueryParams with a\n * // mapper generated by getQueryMapperForState, the two live side by side\n * export const ProductsRemoteStore = signalStore(\n *   { providedIn: 'root' },\n *   withEntities({ entity, collection }),\n *   withCallStatus({ collection, initialValue: 'loading' }),\n *   withEntitiesRemoteFilter({ entity, collection }),\n *   withEntitiesRemotePagination({ entity, collection }),\n *   withEntitiesLoadingCall({ collection, fetchEntities: () => ... }),\n *   withState({\n *     view: 'grid' as 'grid' | 'list',\n *     showSold: false,\n *     day: new Date(),\n *   }),\n *   // 👇 product-filter, product-page, product-pageSize, product-selectedId\n *   withEntitiesSyncToRouteQueryParams({\n *     entity,\n *     collection,\n *   }),\n *   // 👇 view, showSold and day, the prop names and their types are checked\n *   // against the state above\n *   withSyncToRouteQueryParams({\n *     mappers: [\n *       getQueryMapperForState({\n *         view: 'string',\n *         showSold: 'boolean',\n *         day: 'date',\n *       }),\n *     ],\n *   }),\n *);\n * // ?product-filter=%7B%22search%22%3A%22tv%22%7D&product-page=2\n * //  &view=grid&showSold=true&day=2026-08-11\n *\n * @example\n * // the filter is serialized with JSON.stringify by default, which makes it\n * // the longest param in the url. getFilterQueryMapper builds a filterMapper\n * // that spreads it over one param per field instead, the filter type has to\n * // be given since it cannot be inferred from the store\n * type ProductFilter = { search: string; maxPrice: number; from: Date };\n *\n * export const ProductsRemoteStore = signalStore(\n *   { providedIn: 'root' },\n *   withEntities({ entity, collection }),\n *   withCallStatus({ collection, initialValue: 'loading' }),\n *   withEntitiesRemoteFilter({\n *     entity,\n *     collection,\n *     defaultFilter: { search: '', maxPrice: 0, from: new Date() },\n *   }),\n *   withEntitiesLoadingCall({ collection, fetchEntities: () => ... }),\n *   withEntitiesSyncToRouteQueryParams({\n *     entity,\n *     collection,\n *     filterMapper: getFilterQueryMapper<ProductFilter>({\n *       search: 'string',\n *       maxPrice: 'number',\n *       from: 'date',\n *     }),\n *   }),\n *);\n * // ?product-search=tv&product-maxPrice=100&product-from=2026-08-11\n * // instead of ?product-filter=%7B%22search%22%3A%22tv%22%2C%22maxPrice%22...\n */\nexport function withEntitiesSyncToRouteQueryParams<\n  Input extends SignalStoreFeatureResult,\n  Entity,\n  Filter,\n  const Collection extends string = '',\n>(config: {\n  entity: Entity;\n  collection?: Collection;\n  filterMapper?: FilterQueryMapper<Filter>;\n  prefix?: string | false;\n  onQueryParamsLoaded?: (store: StoreSource<Input>) => void;\n  defaultDebounce?: number;\n  restoreOnInit?: boolean;\n  skipLoadingCall?: boolean;\n  syncFilter?: boolean;\n  syncPagination?: boolean;\n  syncSort?: boolean;\n  syncSingleSelection?: boolean;\n  syncMultiSelection?: boolean;\n}): SignalStoreFeature<\n  Input &\n    RequireEntities<\n      Input,\n      Entity,\n      Collection,\n      'withEntitiesSyncToRouteQueryParams'\n    > &\n    RequireEntitiesCallStatus<\n      Input,\n      Collection,\n      'withEntitiesSyncToRouteQueryParams'\n    >,\n  {\n    state: {};\n    props: {};\n    methods: {\n      loadFromQueryParams: () => void;\n    };\n  }\n> {\n  const mappers = [\n    ...(config?.syncSort !== false\n      ? [\n          getQueryMapperForEntitiesSort({\n            collection: config?.collection,\n            skipLoadingCall: config?.skipLoadingCall ?? false,\n          }),\n        ]\n      : []),\n    ...(config?.syncFilter !== false\n      ? [\n          getQueryMapperForEntitiesFilter({\n            collection: config?.collection,\n            filterMapper: config?.filterMapper,\n            skipLoadingCall: config?.skipLoadingCall ?? false,\n          }),\n        ]\n      : []),\n    ...(config?.syncSingleSelection !== false\n      ? [getQueryMapperForSingleSelection(config)]\n      : []),\n    ...(config?.syncMultiSelection === true\n      ? [getQueryMapperForMultiSelection(config)]\n      : []),\n    ...(config?.syncPagination !== false\n      ? [\n          getQueryMapperForEntitiesPagination({\n            collection: config?.collection,\n            skipLoadingCall: config?.skipLoadingCall ?? false,\n          }),\n        ]\n      : []),\n  ];\n  const prefixString =\n    config?.prefix === false ? undefined : config?.prefix ?? config?.collection;\n\n  const { loadingKey, loadedKey, setLoadingKey } = getWithCallStatusKeys({\n    collection: config?.collection,\n  });\n\n  return signalStoreFeature(\n    type<Input>(),\n    withSyncToRouteQueryParams({\n      defaultDebounce: config?.defaultDebounce,\n      mappers: prefixString\n        ? mappers.map((mapper) =>\n            getQueryMapperWithPrefix({ prefix: prefixString, mapper }),\n          )\n        : mappers,\n\n      restoreOnInit: config?.restoreOnInit ?? true,\n    }),\n    withHooks((store) => {\n      return {\n        onInit: () => {\n          if (config?.onQueryParamsLoaded) {\n            const loading = store[loadingKey] as unknown as Signal<boolean>;\n            const loaded = store[loadedKey] as unknown as Signal<boolean>;\n            const loaded$ = toObservable(loaded);\n\n            toObservable(loading)\n              .pipe(\n                first((v) => v),\n                concatMap(() => loaded$.pipe(first((v) => v))),\n                takeUntilDestroyed(),\n              )\n              .subscribe(() => {\n                config?.onQueryParamsLoaded?.(store);\n              });\n          }\n        },\n      };\n    }),\n  ) as any;\n}\n\nexport function getQueryMapperWithPrefix(config: {\n  prefix: string;\n  mapper: QueryMapper<any>;\n}): QueryMapper<any> {\n  return {\n    queryParamsToState: (query, store, firstLoad) => {\n      const newQuery = Object.entries(query).reduce(\n        (acc, [key, value]) => {\n          if (key.startsWith(config.prefix + '-')) {\n            const keyWithoutPrefix = key.replace(config?.prefix + '-', '');\n            acc[keyWithoutPrefix] = value;\n            return acc;\n          }\n          return acc;\n        },\n        {} as Record<string, any>,\n      );\n      config.mapper.queryParamsToState(newQuery, store, firstLoad);\n    },\n    stateToQueryParams: (store) => {\n      const query = config.mapper.stateToQueryParams(store);\n      return query\n        ? computed(() => {\n            return Object.entries(query()).reduce(\n              (acc, [key, value]) => {\n                acc[config.prefix + '-' + key] = value;\n                return acc;\n              },\n              {} as Record<string, any>,\n            );\n          })\n        : undefined;\n    },\n  };\n}\n","import { computed, isDevMode, Signal } from '@angular/core';\nimport { Params } from '@angular/router';\nimport { patchState, SignalStoreFeatureResult } from '@ngrx/signals';\n\n// type only, so it does not create a cycle with with-entities-filter.util which\n// imports QueryMapper from here\nimport type { FilterQueryMapper } from '../with-entities-filter/with-entities-filter.util';\n\nexport type QueryMapper<\n  T extends Params = Params,\n  Store extends Record<string, any> = Record<string, any>,\n  Input extends SignalStoreFeatureResult = SignalStoreFeatureResult,\n> = {\n  /**\n   * @param firstLoad true only for the first query params emission restored\n   *   into this store instance. Mappers should only read it, the caller resets\n   *   it once all mappers have run.\n   */\n  queryParamsToState: (query: T, store: Store, firstLoad: boolean) => void;\n  stateToQueryParams: (store: Store) => Signal<T> | undefined | null;\n};\n\n/**\n * The kind of value a state prop holds, it decides how the prop is written to\n * and read back from the query params.\n */\nexport type QueryParamType =\n  | 'string'\n  | 'number'\n  | 'boolean'\n  | 'date'\n  | 'date-time'\n  | 'time'\n  | 'string-array'\n  | 'number-array'\n  | 'json';\n\n/**\n * The type that can be declared for a state prop holding T, so only the valid\n * ones are suggested and a wrong one fails on the prop itself. Null and\n * undefined are stripped so optional props can be synced too.\n *\n * Each kind of value gets exactly one type, except dates which choose how much\n * of the date to keep in the url, and objects which either travel as 'json' or\n * are described field by field with a nested props object of the same shape.\n * 'json' is not offered as an alternative for the primitives because it writes\n * the same url while validating less on the way back, so '?flag=123' would put\n * a number in a boolean prop, and not for dates because JSON.parse gives back a\n * string, not a Date. An array of strings or of numbers can travel as a comma\n * separated list instead of json, anything else in an array only takes 'json'.\n */\ntype QueryParamTypeFor<T> = 0 extends 1 & T\n  ? // an any typed prop matches every branch below, so let it pick any type\n    QueryParamType | Record<string, any>\n  : [NonNullable<T>] extends [Date]\n    ? 'date' | 'date-time' | 'time'\n    : [NonNullable<T>] extends [boolean]\n      ? 'boolean'\n      : [NonNullable<T>] extends [string]\n        ? 'string'\n        : [NonNullable<T>] extends [number]\n          ? 'number'\n          : [NonNullable<T>] extends [readonly string[]]\n            ? 'json' | 'string-array'\n            : [NonNullable<T>] extends [readonly number[]]\n              ? 'json' | 'number-array'\n              : [NonNullable<T>] extends [readonly any[]]\n                ? 'json'\n                : [NonNullable<T>] extends [object]\n                  ? 'json' | QueryParamTypesFor<NonNullable<T>>\n                  : 'json';\n\n/**\n * The props object shape for a given store state, every state prop is optional\n * and can only be declared as one of the types that fits its value, or as a\n * nested props object when it holds one.\n */\ntype QueryParamTypesFor<State> = {\n  [K in keyof State]?: QueryParamTypeFor<State[K]>;\n};\n\n/**\n * The query param names a props object produces, a prop declared with a nested\n * props object becomes one param per leaf, named with the path to it joined by\n * dots.\n */\ntype QueryParamNames<Props> = {\n  [K in keyof Props & string]: Props[K] extends QueryParamType\n    ? K\n    : `${K}.${QueryParamNames<Props[K]>}`;\n}[keyof Props & string];\n\n/**\n * Fails on the props that are not in the state, at every level. The names are\n * autocompleted from QueryParamTypesFor but not checked against it, because the\n * state is still being inferred while the props object is read, which is what\n * turns the excess property check off. Mapping every key to the type it is\n * allowed to have, or to a message when the state does not have it, checks them\n * once the state is known.\n */\ntype OnlyStateProps<Props, State> = {\n  [K in keyof Props]: K extends keyof State\n    ? Props[K] extends QueryParamType\n      ? QueryParamTypeFor<State[K]>\n      : OnlyStateProps<Props[K], NonNullable<State[K]>>\n    : `'${K & string}' is not a prop of the state`;\n};\n\ntype PropsTree = { [key: string]: QueryParamType | PropsTree };\n\n/**\n * Turns a props object into one entry per leaf, keeping the path to each one,\n * so a nested prop becomes the query param 'filter.color' and can be read back\n * into the right place.\n */\nfunction flattenProps(\n  props: PropsTree,\n  path: string[] = [],\n): [string[], QueryParamType][] {\n  return Object.entries(props).reduce(\n    (acc, [key, value]) =>\n      typeof value === 'string'\n        ? [...acc, [[...path, key], value] as [string[], QueryParamType]]\n        : [...acc, ...flattenProps(value, [...path, key])],\n    [] as [string[], QueryParamType][],\n  );\n}\n\n/**\n * Reads the value at a path, undefined as soon as the path runs into nothing.\n */\nfunction getIn(value: unknown, path: string[]): unknown {\n  return path.reduce<any>(\n    (acc, key) => (acc === undefined || acc === null ? undefined : acc[key]),\n    value,\n  );\n}\n\n/**\n * Returns a copy of value with the path set. The objects along the way are\n * copied instead of mutated, and the fields the path does not touch are kept,\n * so the ones a props object does not declare survive the round trip.\n */\nfunction setIn(value: unknown, path: string[], leaf: unknown): unknown {\n  const [key, ...rest] = path;\n  const base =\n    value && typeof value === 'object'\n      ? (value as Record<string, unknown>)\n      : {};\n  return {\n    ...base,\n    [key]: rest.length ? setIn(base[key], rest, leaf) : leaf,\n  };\n}\n\n/**\n * Creates a QueryMapper that syncs state props to query params with the same\n * name, using the declared type of each prop to serialize and deserialize it.\n *\n * The prop names come from the state of the store the\n * withSyncToRouteQueryParams feature is added to, so they autocomplete, and\n * each prop only accepts the types that fit its value, so declaring\n * `page: 'string'` for a numeric prop, or a prop the state does not have, is a\n * compile error, at every level of a nested props object.\n *\n * Only 'json' props go through JSON.stringify, the rest are written in their\n * plain form so urls stay readable. Date props pick how much of the date to\n * keep, 'date' writes 2026-08-11, 'date-time' writes an iso timestamp and\n * 'time' writes 09:30, all in local time except 'date-time'. An array of\n * strings or of numbers can be written as a comma separated list with\n * 'string-array' or 'number-array', so ?tags=shoes,boots. The comma is the\n * separator, so a string carrying one comes back split in two, use 'json' for\n * those, in dev mode a warning is logged when it happens.\n *\n * A prop holding an object can be declared as 'json' to travel as a single\n * param, or described field by field with a nested props object, which gives\n * it one param per field named with the path to it, so `filter.color=red`. The\n * fields left undeclared keep the value they have in the store, they are\n * neither written to the url nor cleared when it is read back.\n *\n * A prop that is undefined or null is removed from the url, a param missing\n * from the url is left untouched in the store, and a param that does not match\n * its declared type (a hand edited url) is skipped instead of writing a wrong\n * value into the state.\n *\n * @param props - the state props to sync, mapped to their type\n *\n * @example\n *     const Store = signalStore(\n *       withState({\n *         search: '',\n *         page: 0,\n *         showSold: false,\n *         day: new Date(),\n *         startsAt: new Date(),\n *         tags: ['shoes'],\n *         filter: { color: 'red', size: 10 },\n *       }),\n *       withSyncToRouteQueryParams({\n *         mappers: [\n *           getQueryMapperForState({\n *             search: 'string',\n *             page: 'number',\n *             showSold: 'boolean',\n *             day: 'date',\n *             startsAt: 'date-time',\n *             tags: 'string-array',\n *             filter: 'json',\n *           }),\n *         ],\n *       }),\n *     );\n *     // ?search=shoes&page=2&showSold=true&day=2026-08-11\n *     //  &startsAt=2026-08-11T09:30:00.000Z&tags=shoes,boots\n *     //  &filter=%7B%22color%22%3A%22red%22%2C%22size%22%3A10%7D\n *\n * @example\n *     // the same filter prop described field by field instead, which keeps the\n *     // url readable and brings back a real Date rather than the string\n *     // JSON.parse would give\n *     const Store = signalStore(\n *       withState({\n *         filter: { color: 'red', size: 10, from: new Date() },\n *       }),\n *       withSyncToRouteQueryParams({\n *         mappers: [\n *           getQueryMapperForState({\n *             filter: { color: 'string', from: 'date' },\n *           }),\n *         ],\n *       }),\n *     );\n *     // ?filter.color=red&filter.from=2026-08-11\n *     // size is not declared, so it stays at whatever the store holds\n */\nexport function getQueryMapperForState<\n  Input extends SignalStoreFeatureResult,\n  const Props extends QueryParamTypesFor<Input['state']> &\n    OnlyStateProps<Props, Input['state']>,\n>(\n  props: Props,\n): QueryMapper<\n  Partial<Record<QueryParamNames<Props>, string>>,\n  Record<string, any>,\n  Input\n> {\n  const entries = flattenProps(props as PropsTree);\n  return {\n    queryParamsToState: (query, store) => {\n      const params = query as Record<string, string | undefined>;\n      const signals = store as unknown as Record<string, Signal<unknown>>;\n      const state = entries.reduce(\n        (acc, [path, propType]) => {\n          const value = params[path.join('.')];\n          if (value === undefined) return acc;\n          const parsed = deserializeQueryParam(value, propType);\n          if (!parsed) return acc;\n          const [prop, ...rest] = path;\n          acc[prop] = rest.length\n            ? // merged over the value the prop already holds, patchState only\n              // replaces whole props, so the fields this mapper does not\n              // declare would be dropped otherwise\n              setIn(\n                prop in acc ? acc[prop] : signals[prop]?.(),\n                rest,\n                parsed.value,\n              )\n            : parsed.value;\n          return acc;\n        },\n        {} as Record<string, unknown>,\n      );\n      if (Object.keys(state).length) {\n        patchState(store as any, state);\n      }\n    },\n    stateToQueryParams: (store) => {\n      const signals = store as unknown as Record<string, Signal<unknown>>;\n      return computed(\n        () =>\n          entries.reduce(\n            (acc, [path, propType]) => {\n              const [prop, ...rest] = path;\n              acc[path.join('.')] = serializeQueryParam(\n                getIn(signals[prop](), rest),\n                propType,\n                path.join('.'),\n              );\n              return acc;\n            },\n            {} as Record<string, string | undefined>,\n          ) as Partial<Record<QueryParamNames<Props>, string>>,\n      );\n    },\n  };\n}\n\n/**\n * Creates a FilterQueryMapper for the filterMapper option of\n * withEntitiesSyncToRouteQueryParams and getQueryMapperForEntitiesFilter, using\n * the same types as getQueryMapperForState. It spreads the filter over one\n * query param per field instead of the default single json blob, so the url\n * reads as ?search=shoes&maxPrice=100 instead of ?filter=%7B%22search%22...\n *\n * The filter type cannot be inferred from the store, so it has to be given,\n * which is what makes the field names autocomplete and their types check.\n *\n * A field holding an object can be described field by field too, with a nested\n * props object, which gives it one param per field named with the path to it,\n * so `range.from=2026-08-11`.\n *\n * A field that is undefined or null is removed from the url. On the way back\n * the mapper patches the filter instead of replacing it, so the fields it does\n * not declare keep their value, the ones at the top level and the ones inside\n * a declared object alike, while every declared field is restored, falling\n * back to the value the field has in the store defaultFilter when its param is\n * missing or does not match its type, or to the one the filter already holds\n * when defaultFilter says nothing about it. A bare url therefore restores the\n * declared fields to their defaults, which is also what makes the back button\n * work after clearing a filter.\n *\n * The flip side of leaning on defaultFilter is that a field cannot travel as\n * cleared unless its default already is, restoring a url without its param\n * brings the default back rather than an empty value.\n *\n * @param props - the filter fields to sync, mapped to their type\n *\n * @example\n *     type ProductFilter = { search: string; maxPrice: number; from: Date };\n *\n *     withEntitiesSyncToRouteQueryParams({\n *       entity,\n *       collection,\n *       filterMapper: getFilterQueryMapper<ProductFilter>({\n *         search: 'string',\n *         maxPrice: 'number',\n *         from: 'date',\n *       }),\n *     });\n *     // ?product-search=shoes&product-maxPrice=100&product-from=2026-08-11\n *\n * @example\n *     type ProductFilter = {\n *       search: string;\n *       range: { from: Date; to: Date };\n *     };\n *\n *     withEntitiesSyncToRouteQueryParams({\n *       entity,\n *       collection,\n *       filterMapper: getFilterQueryMapper<ProductFilter>({\n *         search: 'string',\n *         range: { from: 'date', to: 'date' },\n *       }),\n *     });\n *     // ?product-search=shoes&product-range.from=2026-08-11\n *     //  &product-range.to=2026-08-31\n */\nexport function getFilterQueryMapper<\n  Filter extends Record<string, any>,\n  const Props extends QueryParamTypesFor<Filter> = QueryParamTypesFor<Filter>,\n>(props: Props): FilterQueryMapper<Filter> {\n  const entries = flattenProps(props as PropsTree);\n  return {\n    // the filter is merged, so the fields this mapper does not declare survive\n    patch: true,\n    queryParamsToFilter: (query, defaultFilter, currentFilter) => {\n      const params = query as Record<string, string | undefined>;\n      return entries.reduce(\n        (acc, [path, propType]) => {\n          const value = params[path.join('.')];\n          const parsed =\n            value === undefined\n              ? undefined\n              : deserializeQueryParam(value, propType);\n          // every declared field is written, one whose param is missing or\n          // unparsable falls back to its default rather than to undefined,\n          // which would hand a filterFn a field it does not expect to be empty.\n          // the default comes first so a bare url restores the declared fields\n          // to it, the current value is only there for the fields defaultFilter\n          // says nothing about\n          const leaf = parsed\n            ? parsed.value\n            : getIn(defaultFilter, path) ?? getIn(currentFilter, path);\n          const [prop, ...rest] = path;\n          acc[prop] = rest.length\n            ? // the filter is only merged field by field at the top level, so\n              // a nested field this mapper does not declare is kept by seeding\n              // the object with the one the store holds, the same way the state\n              // mapper seeds from the prop it is about to patch\n              setIn(\n                prop in acc\n                  ? acc[prop]\n                  : getIn(currentFilter, [prop]) ?? defaultFilter?.[prop],\n                rest,\n                leaf,\n              )\n            : leaf;\n          return acc;\n        },\n        {} as Record<string, unknown>,\n      ) as Filter;\n    },\n    filterToQueryParams: (filter) =>\n      entries.reduce(\n        (acc, [path, propType]) => {\n          acc[path.join('.')] = serializeQueryParam(\n            getIn(filter, path),\n            propType,\n            path.join('.'),\n          );\n          return acc;\n        },\n        {} as Record<string, string | undefined>,\n      ),\n  };\n}\n\nfunction serializeQueryParam(\n  value: unknown,\n  type: QueryParamType,\n  name?: string,\n): string | undefined {\n  // undefined removes the param from the url, null is treated the same so a\n  // cleared prop does not end up as the string 'null' in the url\n  if (value === undefined || value === null) return undefined;\n  switch (type) {\n    case 'json':\n      return JSON.stringify(value);\n    case 'string-array':\n    case 'number-array':\n      if (!Array.isArray(value)) return String(value);\n      if (\n        isDevMode() &&\n        type === 'string-array' &&\n        value.some((item) => `${item}`.includes(','))\n      ) {\n        // the comma is the separator, so the value would silently come back\n        // split in two, which is worth saying out loud rather than debugging.\n        // dev mode only, this runs on every write of the param\n        console.warn(\n          `[withSyncToRouteQueryParams] the value of ${\n            name ? `'${name}'` : 'a string-array prop'\n          } contains a comma, it will be read back as two entries, declare the prop as 'json' instead`,\n        );\n      }\n      // an empty array still writes the param, as an empty value, dropping it\n      // would read back as 'the url does not carry this prop' instead\n      return value.join(',');\n    case 'date':\n      // the local date, not the utc one, so a date picked as the 11th does not\n      // travel as the 10th for anyone west of greenwich\n      return value instanceof Date\n        ? `${value.getFullYear()}-${pad(value.getMonth() + 1)}-${pad(\n            value.getDate(),\n          )}`\n        : String(value);\n    case 'date-time':\n      return value instanceof Date ? value.toISOString() : String(value);\n    case 'time': {\n      if (!(value instanceof Date)) return String(value);\n      const time = `${pad(value.getHours())}:${pad(value.getMinutes())}`;\n      // seconds are only written when they carry something\n      return value.getSeconds() ? `${time}:${pad(value.getSeconds())}` : time;\n    }\n    default:\n      return String(value);\n  }\n}\n\nfunction pad(value: number): string {\n  return String(value).padStart(2, '0');\n}\n\n/**\n * Returns the parsed value wrapped in an object, or undefined when the param\n * does not match its declared type, which is the signal to leave the prop\n * alone. The wrapper is what tells 'parsed to undefined' apart from 'skip'.\n */\nfunction deserializeQueryParam(\n  value: string,\n  type: QueryParamType,\n): { value: unknown } | undefined {\n  // a repeated param, ?tags=a&tags=b, is handed over as an array, and there is\n  // no telling which entry was meant, so it is skipped like any other value\n  // that does not match its declared type. without this the string methods\n  // below throw, and the throw takes the whole restore with it, the mappers\n  // after this one never run\n  if (typeof value !== 'string') return undefined;\n  switch (type) {\n    case 'string':\n      return { value };\n    case 'number': {\n      if (value.trim() === '') return undefined;\n      const parsed = Number(value);\n      return Number.isNaN(parsed) ? undefined : { value: parsed };\n    }\n    case 'boolean':\n      if (value === 'true') return { value: true };\n      if (value === 'false') return { value: false };\n      return undefined;\n    case 'date': {\n      const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(value);\n      if (!match) return undefined;\n      const [, year, month, day] = match.map(Number);\n      // built from the parts so it lands on local midnight, new Date('2026-08-11')\n      // would parse as utc and shift the day\n      const parsed = new Date(year, month - 1, day);\n      // rejects the likes of 2026-02-31, which Date would roll over to march\n      return parsed.getMonth() === month - 1 && parsed.getDate() === day\n        ? { value: parsed }\n        : undefined;\n    }\n    case 'date-time': {\n      const parsed = new Date(value);\n      return Number.isNaN(parsed.getTime()) ? undefined : { value: parsed };\n    }\n    case 'time': {\n      const match = /^(\\d{2}):(\\d{2})(?::(\\d{2}))?$/.exec(value);\n      if (!match) return undefined;\n      const hours = Number(match[1]);\n      const minutes = Number(match[2]);\n      const seconds = match[3] ? Number(match[3]) : 0;\n      if (hours > 23 || minutes > 59 || seconds > 59) return undefined;\n      // a time on its own has no day to sit on, so it lands on the epoch date\n      return { value: new Date(1970, 0, 1, hours, minutes, seconds) };\n    }\n    case 'string-array':\n      return { value: value === '' ? [] : value.split(',') };\n    case 'number-array': {\n      if (value === '') return { value: [] };\n      const items = value.split(',');\n      // an empty element would read as 0, the same way '?page=' is rejected\n      // for a number prop rather than restored as one\n      if (items.some((item) => item.trim() === '')) return undefined;\n      const parsed = items.map(Number);\n      // one bad element skips the whole param, half an array is worse than the\n      // one the prop already holds\n      return parsed.some((item) => Number.isNaN(item))\n        ? undefined\n        : { value: parsed };\n    }\n    case 'json':\n      try {\n        return { value: JSON.parse(value) };\n      } catch {\n        return undefined;\n      }\n  }\n}\n","import { computed, inject, Signal } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport {\n  ActivatedRoute,\n  ActivatedRouteSnapshot,\n  NavigationEnd,\n  Params,\n  Router,\n} from '@angular/router';\nimport { signalStoreFeature, withComputed } from '@ngrx/signals';\nimport { filter, map, startWith } from 'rxjs/operators';\n\n/**\n * Store feature that provides access to route params, query params, and route data.\n * Creates a computed signal for each property returned by the mapParams function.\n *\n * @param mapParams Function receiving `{ params, queryParams, data }` and returning an object.\n *\n * @example\n * // Combined params, queryParams and data\n * const Store = signalStore(\n *   withRoute(({ params, queryParams, data }) => ({\n *     id: params['id'] as string,\n *     tab: queryParams['tab'] as string,\n *     title: data?.['title'] as string,\n *   })),\n *   withHooks(({ id, tab, title }) => ({\n *     onInit: () => console.log(`Product ID: ${id()}, tab: ${tab()}, title:${title()}` ),\n *   })),\n * );\n */\nexport function withRoute<T extends Record<string, any>>(\n  mapParams: (options: {\n    params: Params;\n    queryParams: Params;\n    data?: {\n      [key: string | symbol]: any;\n    };\n  }) => T,\n) {\n  return signalStoreFeature(\n    withComputed(() => {\n      const activatedRoute = inject(ActivatedRoute);\n      const router = inject(Router);\n\n      // Fallback to direct params observable if router events don't provide snapshot\n      const directParamsSignal = toSignal(activatedRoute.params);\n\n      // Listen to router events and extract params from the entire route tree\n      const paramsSignal = toSignal(\n        router.events.pipe(\n          filter((event) => event instanceof NavigationEnd),\n          startWith(null),\n          map(() => {\n            // If snapshot is not available, return null to use fallback\n            if (!activatedRoute.snapshot) {\n              return null;\n            }\n            let route = activatedRoute.snapshot;\n            // Navigate to the root of the route tree\n            while (route.parent) {\n              route = route.parent;\n            }\n            // Extract params from all child routes\n            return extractRouteParams(route);\n          }),\n        ),\n      );\n\n      const dataSignal = activatedRoute.data\n        ? toSignal(activatedRoute.data)\n        : undefined;\n      const queryParamSignal = activatedRoute.queryParams\n        ? toSignal(activatedRoute.queryParams)\n        : undefined;\n      const params = computed(() =>\n        mapParams({\n          params: paramsSignal() ?? directParamsSignal() ?? {},\n          data: dataSignal?.(),\n          queryParams: queryParamSignal?.() ?? {},\n        }),\n      );\n      const computedParams = {} as any;\n      Object.keys(params()).forEach((key) => {\n        computedParams[key] = computed(() => params()[key]);\n      });\n      return computedParams as { [K in keyof T]: Signal<T[K]> };\n    }),\n  );\n}\n\nfunction extractRouteParams(route: ActivatedRouteSnapshot): Params {\n  return route.children.reduce(\n    (params, childRoute) => ({ ...params, ...extractRouteParams(childRoute) }),\n    { ...route.params },\n  );\n}\n","import { computed, inject, Signal } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport {\n  ActivatedRoute,\n  ActivatedRouteSnapshot,\n  NavigationEnd,\n  Params,\n  Router,\n} from '@angular/router';\nimport { signalStoreFeature, withComputed } from '@ngrx/signals';\nimport { filter, map, startWith } from 'rxjs/operators';\n\n/**\n * @deprecated use withRoute instead\n * This store feature provides access to the route params. The mapParams receives the route params object, use it to transform it\n * to an object, this will create a computed for each prop return by the mapParams function\n * @param mapParams A function to transform the params before they are stored.\n *\n * @example\n *\n * // example route  /products/:id/\n * const ProductDetailStore = signalStore(\n *   withRouteParams(({ id }) => ({ id })),\n *   withCalls(() => ({\n *     loadProductDetail: (id: string) =>\n *       inject(ProductService).getProductDetail(id),\n *   })),\n *   withHooks(({ loadProductDetail, id }) => ({\n *     onInit: () => {\n *       loadProductDetail(id());\n *     },\n *   })),\n * );\n */\nexport function withRouteParams<T extends Record<string, any>>(\n  mapParams: (params: Params, data?: any) => T,\n) {\n  return signalStoreFeature(\n    withComputed(() => {\n      const activatedRoute = inject(ActivatedRoute);\n      const router = inject(Router);\n\n      // Fallback to direct params observable if router events don't provide snapshot\n      const directParamsSignal = toSignal(activatedRoute.params);\n\n      // Listen to router events and extract params from the entire route tree\n      const paramsSignal = toSignal(\n        router.events.pipe(\n          filter((event) => event instanceof NavigationEnd),\n          startWith(null),\n          map(() => {\n            // If snapshot is not available, return null to use fallback\n            if (!activatedRoute.snapshot) {\n              return null;\n            }\n            let route = activatedRoute.snapshot;\n            // Navigate to the root of the route tree\n            while (route.parent) {\n              route = route.parent;\n            }\n            // Extract params from all child routes\n            return extractRouteParams(route);\n          }),\n        ),\n      );\n\n      const dataSignal = activatedRoute.data\n        ? toSignal(activatedRoute.data)\n        : undefined;\n      const params = computed(() =>\n        mapParams(paramsSignal() ?? directParamsSignal() ?? {}, dataSignal?.()),\n      );\n      const computedParams = {} as any;\n      Object.keys(params()).forEach((key) => {\n        computedParams[key] = computed(() => params()[key]);\n      });\n      return computedParams as { [K in keyof T]: Signal<T[K]> };\n    }),\n  );\n}\n\nfunction extractRouteParams(route: ActivatedRouteSnapshot): Params {\n  return route.children.reduce(\n    (params, childRoute) => ({ ...params, ...extractRouteParams(childRoute) }),\n    { ...route.params },\n  );\n}\n","import { computed, isSignal, Signal } from '@angular/core';\nimport {\n  patchState,\n  signalStoreFeature,\n  withMethods,\n  withState,\n} from '@ngrx/signals';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport { pipe, tap } from 'rxjs';\n\ntype RecordSignals<T extends object> = {\n  [K in keyof T]: Signal<T[K]>;\n};\n\n/**\n * Binds component inputs to the store, so that the store is updated with the latest values of the inputs.\n * @param inputs\n *\n * @example\n *\n * const Store = signalStore(\n *    withInputBindings({\n *       pageIndex: 0,\n *       length: 0,\n *       pageSize: 10,\n *       pageSizeOptions: [5, 10, 20],\n *     }),\n *    //... other features that use foo and bar\n *  );\n *  // generates the signals\n *    store.pageIndex(); // 0\n *    store.length(); // 0\n *    store.pageSize(); // 10\n *    store.pageSizeOptions(); // [5, 10, 20]\n *\n *    generates the method\n *    store.bindInputs({ pageIndex: Signal<number>, length: Signal<number>, pageSize: Signal<number>, pageSizeOptions: Signal<number[]> });\n *\n *  // use in a component\n *    class PaginatorComponent {\n *     readonly pageIndex = input.required<number>;\n *     readonly length = input.required<number>;\n *     readonly pageSize = input.required<number>;\n *     readonly pageSizeOptions = input.required<number[]>;\n *     readonly store = inject(Store);\n *     constructor() {\n *       this.store.bindInputs({\n *         pageIndex: this.pageIndex,\n *         length: this.length,\n *         pageSize: this.pageSize,\n *         pageSizeOptions: this.pageSizeOptions,\n *       });\n *       // if the inputs have the same name and type as the store,\n *       // you can use bindInputs like\n *       // this.store.bindInputs(this);\n *     }\n *   }\n *\n */\nexport function withInputBindings<\n  Object extends object,\n  Inputs extends RecordSignals<Object> = RecordSignals<Object>,\n>(inputs: Object) {\n  return signalStoreFeature(\n    withState({ _inputsInitialized: false }),\n    withState(inputs),\n    withMethods((store) => {\n      const setValues = rxMethod<Object>(\n        pipe(\n          tap((values) => {\n            patchState(store, { ...values });\n          }),\n        ),\n      );\n      return {\n        bindInputs: (inputs: Inputs) => {\n          const combined = computed((): Object => {\n            return Object.entries(inputs).reduce((acc, [key, s]) => {\n              if (isSignal(s)) {\n                acc[key] = (s as Signal<unknown>)();\n              }\n              return acc;\n            }, {} as any);\n          });\n          const methodRef = setValues(combined);\n          patchState(store, { _inputsInitialized: true } as any);\n          return methodRef;\n        },\n      };\n    }),\n  );\n}\n","import { computed } from '@angular/core';\nimport {\n  patchState,\n  signalStoreFeature,\n  withComputed,\n  withMethods,\n  withState,\n} from '@ngrx/signals';\n\nimport { CallStatus } from './with-all-call-status.model';\n\n/**\n * Adds methods to the store to track the status of all calls in the store\n * @example\n * export const ProductsLocalStore = signalStore(\n *   withAllCallStatus(), // <-- add this line\n *   withEntities({ entity, collection }),\n *   withCallStatus({ collection, initialValue: 'loading' }),\n *   withEntitiesLoadingCall({\n *     collection,\n *     fetchEntities: () => {\n *       return inject(ProductService)\n *         .getProducts()\n *         .pipe(map((d) => d.resultList));\n *     },\n *   }),\n *   withCalls(() => ({\n *     loadProductDetail: callConfig({\n *       call: ({ id }: { id: string }) =>\n *         inject(ProductService).getProductDetail(id),\n *       resultProp: 'productDetail',\n *     }),\n *     checkout: () => inject(OrderService).checkout(),\n *   })),\n * );\n * // generates the following methods\n *  store.isAnyCallLoading() // Signal<boolean>\n *  store.callsErrors // () => Signals<unknown[]>\n */\nexport function withAllCallStatus() {\n  return signalStoreFeature(\n    withState({\n      _allCallStatus: [] as CallStatus[],\n    }),\n    withComputed(({ _allCallStatus }) => ({\n      isAnyCallLoading: computed(() =>\n        _allCallStatus().some((callStatus) => callStatus.loading()),\n      ),\n      callsErrors: computed(() =>\n        _allCallStatus()\n          .map((callStatus) => callStatus.error?.())\n          .filter(Boolean),\n      ),\n    })),\n    withMethods(({ _allCallStatus, ...store }) => ({\n      _registerCallStatus: (callStatus: CallStatus) => {\n        patchState(store, {\n          _allCallStatus: [..._allCallStatus(), callStatus],\n        });\n      },\n    })),\n  );\n}\n","import { capitalize } from '../util';\n\nexport function getWithEntitiesCallKeys({ callName }: { callName: string }) {\n  const capitalizedName = callName && capitalize(callName);\n  return {\n    callNameKey: callName,\n    areAllLoadedKey: `areAll${capitalizedName}Loaded`,\n    isAnyLoadingKey: `isAny${capitalizedName}Loading`,\n    isLoadingKey: `is${capitalizedName}Loading`,\n    isLoadedKey: `is${capitalizedName}Loaded`,\n    errorKey: `${callName}Error`,\n    errorsKey: `${callName}Errors`,\n    callStatusKey: `${callName}CallStatus`,\n  };\n}\n","import {\n  computed,\n  EnvironmentInjector,\n  inject,\n  isDevMode,\n  isSignal,\n  runInInjectionContext,\n  Signal,\n} from '@angular/core';\nimport { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';\nimport {\n  patchState,\n  signalStoreFeature,\n  SignalStoreFeature,\n  SignalStoreFeatureResult,\n  withComputed,\n  withHooks,\n  withMethods,\n  withState,\n} from '@ngrx/signals';\nimport {\n  removeEntity,\n  SelectEntityId,\n  updateEntity,\n} from '@ngrx/signals/entities';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport {\n  catchError,\n  concatMap,\n  finalize,\n  from,\n  isObservable,\n  lastValueFrom,\n  map,\n  mergeMap,\n  Observable,\n  of,\n  pipe,\n  take,\n  tap,\n  throwError,\n} from 'rxjs';\nimport { filter } from 'rxjs/operators';\n\nimport { RequireEntities } from '../feature-requirements.model';\nimport { getWithEntitiesKeys, insertIf } from '../util';\nimport { registerCallState } from '../with-all-call-status/with-all-call-status.util';\nimport { NamedCallStatusMapState } from '../with-call-status-map/with-call-status-map.model';\nimport { CallStatus } from '../with-call-status/with-call-status.model';\nimport { ObservableCall, RxMethodRef } from '../with-calls/with-calls.model';\nimport { withFeatureFactory } from '../with-feature-factory/with-feature-factory';\nimport { StoreSource } from '../with-feature-factory/with-feature-factory.model';\nimport {\n  EntityCall,\n  EntityCallConfig,\n  ExtractEntityCallErrorType,\n  NamedEntitiesCallsStatusComputed,\n  NamedEntitiesCallsStatusMethods,\n} from './with-entities-calls.model';\nimport { getWithEntitiesCallKeys } from './with-entities-calls.util';\n\n/**\n * Generates necessary state, computed and methods to track the progress of\n * calls related to an entity and merges the result back to entities list. The generated methods are rxMethods with\n * the same name as the original call, which accepts either the original parameters\n * or a Signal or Observable of the same type as the original parameters.\n * The original call can only have zero or one parameter, use an object with multiple\n * props as first param if you need more.\n * *Important* The calls must have a parameter of type Entity  {entity: Entity, ...extra params} or use entityCallConfig\n * and the paramsSelectId to return with param prop represents the entityId .\n * The call can be skipped based on the result of the previous call, to skip a call return undefined or false.\n * @param config.entity - The entity type to be used\n * @param config.collection - The optional collection name to be used\n * @param config.selectId - The function to use to select the id of the entity\n * @param config.callsFactory - a factory function that receives the store and returns an object of type {Record<string,  EntitiesCallConfig>} with the calls to be made\n *\n * @example\n * const orderEntity = entityConfig({\n *   entity: type<OrderSummary & { items?: OrderDetail['items'] }>(),\n *   collection: 'order',\n * });\n * export const OrderStore = signalStore(\n *   withEntities(orderEntity),\n *   withEntitiesCalls({\n *     ...orderEntity,\n *     calls: (store, orderService = inject(OrderService)) => ({\n *       loadOrderDetail: (entity) => orderService.getOrderDetail(entity.id),\n *       // alternative way to define the call\n *       // loadOrderDetail: entityCallConfig({\n *       //   call: (entity: OrderSummary) => orderService.getOrderDetail(entity.id),\n *       //   // skip the call if result is already loaded\n *       //   skipWhen: (param, previousResult) => !!previousResult?.items,\n *       // }),\n *       changeOrderStatus: (option: {\n *         entity: OrderSummary;\n *         status: OrderSummary['status'];\n *       }) => orderService.changeStatus(option.entity.id, option.status),\n *       deleteOrder: (entity: OrderSummary) => {\n *         return orderService.delete(entity.id).pipe(\n *           map((deleted) => {\n *             deleted ? undefined : entity; // returning undefined will remove the entity from the store\n *           }),\n *         );\n *       },\n *     }),\n *   }),\n * );\n *\n *   // generates the following signals\n *   store.loadOrderDetailCallStatus // a map { [id: string]:'init' | 'loading' | 'loaded' | { error: unknown }}\n *   // similar for changeOrderStatus and deleteOrder *\n *   // the calls updates the entities so results, which can be accessed with the usual entities list computed signals\n *   // generates the following computed signals\n *   store.isAnyLoadOrderDetailLoading: Signal<boolean>\n *   store.isAnyLoadOrderDetailLoaded: Signal<boolean>\n *   store.loadOrderDetailErrors: Signal<unknown[]>\n *   // same for changeOrderStatus and deleteOrder\n *   // generates the following methods\n *   store.isLoadOrderDetailLoading(id: string) => boolean\n *   store.isLoadOrderDetailLoaded(id: string) => boolean\n *   store.loadOrderDetailError(id: string) => string | null\n *   store.loadOrderDetail // ({id: string}) => Promise<{value, ok: true} | {error, ok: false}>\n *   //   passing a Signal or Observable instead returns an RxMethodRef\n *   // same for changeOrderStatus and deleteOrder\n *\n */\nexport function withEntitiesCalls<\n  Input extends SignalStoreFeatureResult,\n  Entity,\n  const Calls extends Record<\n    string,\n    EntityCall<NoInfer<Entity>> | EntityCallConfig<NoInfer<Entity>>\n  >,\n  Collection extends string = '',\n>(config: {\n  entity: Entity;\n  collection?: Collection;\n  selectId?: SelectEntityId<NoInfer<Entity>>;\n  calls: (store: StoreSource<Input>) => Calls;\n}): SignalStoreFeature<\n  Input &\n    RequireEntities<Input, Entity, Collection, 'withEntitiesCalls'>,\n  {\n    state: NamedCallStatusMapState<keyof Calls & string>;\n    props: NamedEntitiesCallsStatusComputed<Calls>;\n    methods: NamedEntitiesCallsStatusMethods<Entity, Calls> & {\n      [K in keyof Calls]: Calls[K] extends (...args: infer P) => any\n        ? {\n            (param: P[0]): Promise<\n              | { value: Signal<Entity>; ok: true }\n              | {\n                  error: Signal<ExtractEntityCallErrorType<Calls[K]>>;\n                  ok: false;\n                }\n            >;\n            (param: Observable<P[0]> | (() => P[0])): RxMethodRef;\n          }\n        : Calls[K] extends EntityCallConfig\n          ? Parameters<Calls[K]['call']> extends undefined[]\n            ? // an entity call needs a param to derive the entity id from, so\n              // a call with no params is not a supported shape\n              never\n            : {\n                (...param: Parameters<Calls[K]['call']>): Promise<\n                  | { value: Signal<Entity>; ok: true }\n                  | {\n                      error: Signal<ExtractEntityCallErrorType<Calls[K]>>;\n                      ok: false;\n                    }\n                >;\n                (\n                  param:\n                    | Observable<Parameters<Calls[K]['call']>[0]>\n                    | (() => Parameters<Calls[K]['call']>[0]),\n                ): RxMethodRef;\n              }\n          : never;\n    };\n  }\n> {\n  return withFeatureFactory((store) => {\n    const calls = config.calls(store as StoreSource<Input>);\n    const callsState = Object.entries(calls).reduce(\n      (acc, [callName]) => {\n        const { callStatusKey } = getWithEntitiesCallKeys({\n          callName,\n        });\n        acc[callStatusKey] = {};\n        return acc;\n      },\n      {} as Record<string, any>,\n    );\n\n    const hasCallWith = Object.entries(calls).some(\n      ([, call]) => 'callWith' in call,\n    );\n    return signalStoreFeature(\n      withState(callsState),\n      withComputed((state: Record<string, Signal<unknown>>) => {\n        const callsComputed = Object.keys(calls).reduce(\n          (acc, callName) => {\n            const {\n              isAnyLoadingKey,\n              areAllLoadedKey,\n              errorsKey,\n              callStatusKey,\n            } = getWithEntitiesCallKeys({ callName });\n            const callState = state[callStatusKey] as Signal<\n              Record<string, CallStatus>\n            >;\n            const isAnyLoading = computed(() =>\n              Object.values(callState()).some((status) => status === 'loading'),\n            );\n            const areAllLoaded = computed(() => {\n              const values = Object.values(callState());\n              return values?.length\n                ? values.every((status) => status === 'loaded')\n                : false;\n            });\n\n            const errors = computed(() => {\n              const v = callState();\n              const errorsArray = Object.values(v)\n                .map((v) => (typeof v === 'object' ? v.error : undefined))\n                .filter(Boolean);\n              return errorsArray?.length ? errorsArray : undefined;\n            });\n\n            registerCallState(store, { loading: isAnyLoading, error: errors });\n            acc[isAnyLoadingKey] = isAnyLoading;\n            acc[errorsKey] = errors;\n            acc[areAllLoadedKey] = areAllLoaded;\n\n            return acc;\n          },\n          {} as Record<string, any>,\n        );\n        return callsComputed;\n      }),\n      withMethods(\n        (state, environmentInjector = inject(EnvironmentInjector)) => {\n          const methods = Object.entries(calls).reduce(\n            (acc, [callName, call]) => {\n              const {\n                callStatusKey,\n                callNameKey,\n                isLoadingKey,\n                isLoadedKey,\n                errorKey,\n              } = getWithEntitiesCallKeys({\n                callName,\n              });\n              const { entityMapKey } = getWithEntitiesKeys({\n                collection: config.collection,\n              });\n              const entityMap = state[entityMapKey] as Signal<\n                Record<string, NoInfer<Entity>>\n              >;\n              const callState = state[callStatusKey] as Signal<\n                Record<string, CallStatus>\n              >;\n\n              function selectId(entityOrId: Entity | string | number) {\n                return typeof entityOrId === 'string' ||\n                  typeof entityOrId === 'number'\n                  ? entityOrId\n                  : config.selectId\n                    ? config.selectId(entityOrId)\n                    : ((entityOrId as any).id as string);\n              }\n              const isLoading = (entityOrId: Entity | string | number) =>\n                callState()[selectId(entityOrId)] === 'loading';\n              const isLoaded = (entityOrId: Entity | string | number) =>\n                callState()[selectId(entityOrId)] === 'loaded';\n              const error = (entityOrId: Entity | string | number) => {\n                const v = callState()[selectId(entityOrId)];\n                return typeof v === 'object' ? v.error : undefined;\n              };\n              acc[isLoadingKey] = isLoading;\n              acc[isLoadedKey] = isLoaded;\n              acc[errorKey] = error;\n\n              const setLoading = (id: string | number) => {\n                patchState(store, {\n                  [callStatusKey]: { ...callState(), [id]: 'loading' },\n                } as any);\n              };\n              const setLoaded = (id: string | number) => {\n                patchState(store, {\n                  [callStatusKey]: { ...callState(), [id]: 'loaded' },\n                } as any);\n              };\n              const setError = (id: string | number, error: unknown) => {\n                patchState(store, {\n                  [callStatusKey]: { ...callState(), [id]: { error } },\n                } as any);\n              };\n\n              const callFn = getCallFn(call);\n              const skipWhenFn = isCallConfig(call)\n                ? call.skipWhen ??\n                  (call.callWith\n                    ? (param: unknown) => param === undefined || param === false\n                    : undefined)\n                : undefined;\n              const inFlight = new Set<number | string>();\n              const reactiveMethod = rxMethod<unknown>(\n                pipe(\n                  mergeMap((params: any) => {\n                    const id =\n                      isCallConfig(call) && call.paramsSelectId\n                        ? call.paramsSelectId(params)\n                        : typeof params === 'object' && 'entity' in params\n                          ? selectId(params.entity)\n                          : selectId(params);\n                    const previousResult = isCallConfig(call)\n                      ? call.storeResult != false\n                        ? entityMap()[id]\n                        : undefined\n                      : entityMap()[id];\n                    const skip = skipWhenFn?.(params, previousResult) ?? false;\n\n                    const filterDuplicateIds = filter((value) => {\n                      if (inFlight.has(id)) {\n                        // Skip this value because it's already being processed.\n                        return false;\n                      } else {\n                        // Mark the value as in-flight and allow it to continue.\n                        inFlight.add(id);\n                        return true;\n                      }\n                    });\n                    const process$ = pipe(\n                      filterDuplicateIds,\n                      concatMap((params: any) => {\n                        if (!id) {\n                          const error = new Error(\n                            `The id could not be found in ${callName} params. Make sure the params of the call is of type  Entity | {entity: Entity} or provide a paramsSelectId function in the call config`,\n                          );\n                          console.error(error);\n                          return throwError(() => error);\n                        }\n                        setLoading(id);\n                        // Set to track which values are currently being processed\n\n                        return runInInjectionContext(\n                          environmentInjector,\n                          () => {\n                            return callFn(params).pipe(\n                              map((result) => {\n                                patchState(\n                                  state,\n                                  !!result // if result do an update\n                                    ? config.collection\n                                      ? updateEntity(\n                                          {\n                                            id,\n                                            changes: result,\n                                          },\n                                          {\n                                            collection: config.collection,\n                                            selectId:\n                                              config.selectId ??\n                                              ((entity: Entity) =>\n                                                (entity as any).id),\n                                          } as any,\n                                        )\n                                      : updateEntity({\n                                          id,\n                                          changes: result,\n                                        })\n                                    : config.collection // if no result do a remove\n                                      ? removeEntity(id, {\n                                          collection: config.collection,\n                                          selectId:\n                                            config.selectId ??\n                                            ((entity: Entity) =>\n                                              (entity as any).id),\n                                        } as any)\n                                      : removeEntity(id),\n                                );\n                                setLoaded(id);\n                                isCallConfig(call) &&\n                                  call.onSuccess &&\n                                  call.onSuccess(\n                                    result,\n                                    params,\n                                    previousResult,\n                                  );\n                              }),\n                              takeUntilDestroyed(),\n                              catchError((error: unknown) => {\n                                const e =\n                                  (isCallConfig(call) &&\n                                    call.mapError?.(error, params)) ||\n                                  error;\n                                setError(id, e);\n                                console.error(\n                                  `Call ${callName} fail `,\n                                  { params },\n                                  e,\n                                );\n                                isCallConfig(call) &&\n                                  call.onError &&\n                                  call.onError(e, params);\n                                return of();\n                              }),\n                              finalize(() => {\n                                inFlight.delete(id);\n                              }),\n                            );\n                          },\n                        );\n                      }),\n                      // Catch errors from the id check (throwError)\n                      catchError(() => of()),\n                    );\n\n                    if (typeof skip === 'boolean') {\n                      if (isDevMode() && skip)\n                        console.warn(`EntityCall ${callName} is skip`);\n                      return skip ? of() : of(params).pipe(process$);\n                    }\n                    // skip is a promise or observable\n                    return from(skip).pipe(\n                      tap((value) => {\n                        if (isDevMode() && value)\n                          console.warn(`EntityCall ${callName} is skip`);\n                      }),\n                      // first((v) => !v),\n                      filter((v) => !v),\n                      take(1),\n                      map(() => params),\n                      process$,\n                    );\n                  }),\n                ),\n              );\n              acc[callNameKey] = function (param?: unknown) {\n                if (\n                  typeof param === 'function' ||\n                  param instanceof Observable ||\n                  isSignal(param)\n                ) {\n                  return reactiveMethod(param as any);\n                }\n\n                reactiveMethod(param as any);\n                const id =\n                  isCallConfig(call) && call.paramsSelectId\n                    ? call.paramsSelectId(param)\n                    : typeof param === 'object' &&\n                        param !== null &&\n                        'entity' in param\n                      ? selectId((param as any).entity)\n                      : selectId(param as any);\n                const entityStatus = computed(() => callState()[id]);\n                const resultPromise = lastValueFrom(\n                  toObservable(entityStatus, {\n                    injector: environmentInjector,\n                  }).pipe(\n                    filter((v) => v === 'loaded' || typeof v === 'object'),\n                    take(1),\n                    map((v) =>\n                      v === 'loaded'\n                        ? {\n                            value: computed(() => entityMap()[id]),\n                            ok: true as const,\n                          }\n                        : {\n                            error: computed(() =>\n                              typeof v === 'object' ? v.error : undefined,\n                            ),\n                            ok: false as const,\n                          },\n                    ),\n                  ),\n                );\n                // see withCalls: keep a no-op handler attached so a promise the\n                // caller ignores cannot surface as an unhandled rejection\n                resultPromise.catch(() => {});\n                return resultPromise;\n              };\n              return acc;\n            },\n            {} as Record<string, any>,\n          );\n          return methods;\n        },\n      ),\n      ...insertIf(hasCallWith, () =>\n        withHooks((store: Record<string, Function>) => ({\n          onInit: () => {\n            for (const [callName, call] of Object.entries(calls)) {\n              if ('callWith' in call) {\n                if (\n                  typeof call.callWith === 'function' &&\n                  !isObservable(call.callWith) &&\n                  !isSignal(call.callWith)\n                ) {\n                  store[callName](computed(call.callWith));\n                } else if (\n                  isObservable(call.callWith) ||\n                  isSignal(call.callWith)\n                ) {\n                  store[callName](call.callWith);\n                } else {\n                  const value = call.callWith;\n                  if (value !== undefined && value !== false) {\n                    store[callName](value);\n                  }\n                }\n              }\n            }\n          },\n        })),\n      ),\n    );\n  }) as any;\n}\nfunction isCallConfig(\n  call: EntityCall<any> | EntityCallConfig,\n): call is EntityCallConfig {\n  return typeof call === 'object';\n}\n\nfunction getCallFn(\n  call: EntityCall<any> | EntityCallConfig,\n): ObservableCall<any, any> {\n  if (isCallConfig(call)) {\n    return (params) => from(call.call(params));\n  } else {\n    return (params) => from(call(params));\n  }\n}\n","import { EntityCallConfig } from './with-entities-calls.model';\n\n/**\n * Call configuration object for withEntitiesCalls\n * @param config - the call configuration\n * @param config.call - required, the function that will be called\n * @param config.mapResult - required, a function to transform the result of the call to the entity\n * @param config.entityId - required, a function that returns the entity id in the params\n * @param config.onSuccess - optional, a function that will be called when the call is successful\n * @param config.mapError - optional, a function that will be called to transform the error before storing it\n * @param config.onError - optional, a function that will be called when the call fails\n * @param config.skipWhen - optional, a function that will be called to determine if the call should be skipped\n * @param config.callWith - optional, reactively execute the call with the provided params return by a function or observable\n * @param config.defaultResult - optional, A default value for the result before the call is executed\n */\n\nexport function entityCallConfig<\n  Entity,\n  Param,\n  Result = Partial<Entity> | undefined,\n  Error = unknown,\n  C extends EntityCallConfig<Param, Result, Error> = EntityCallConfig<\n    Param,\n    Result,\n    Error\n  >,\n>(\n  config: Omit<\n    EntityCallConfig<Entity, Param, Result, Error>,\n    'storeResult' | 'paramsSelectId'\n  > & { paramsSelectId: (param: NoInfer<Param>) => string },\n): EntityCallConfig<Entity, Param, Result, Error>;\nexport function entityCallConfig<\n  Param,\n  Result,\n  Error = unknown,\n  C extends EntityCallConfig<any, Param, Result, Error> = EntityCallConfig<\n    any,\n    Param,\n    Result,\n    Error\n  >,\n>(\n  config: Omit<\n    EntityCallConfig<any, Param, Result, Error>,\n    'storeResult' | 'paramsSelectId'\n  > & { paramsSelectId: (param: NoInfer<Param>) => string; storeResult: false },\n): EntityCallConfig<any, Param, Result, Error>;\nexport function entityCallConfig<\n  Entity,\n  Param extends\n    | string\n    | number\n    | Entity\n    | ({ entity: Entity } & Record<string, any>),\n  Result = Partial<Entity> | undefined,\n  Error = unknown,\n  C extends EntityCallConfig<Entity, Param, Result, Error> = EntityCallConfig<\n    Entity,\n    Param,\n    Result,\n    Error\n  >,\n>(\n  config: Omit<\n    EntityCallConfig<Entity, Param, Result, Error>,\n    'storeResult' | 'paramsSelectId'\n  >,\n): EntityCallConfig<Entity, Param, Result, Error>;\nexport function entityCallConfig(config: any): any {\n  return config;\n}\n","import { CacheData, CacheKey, CacheKeys, CacheState } from './cache.model';\n\nfunction hash(key: string | object): string {\n  return JSON.stringify(key, (_, val) =>\n    typeof val == 'object'\n      ? Object.keys(val)\n          .sort()\n          .reduce((result, k) => {\n            result[k] = val[k];\n            return result;\n          }, {} as any)\n      : val,\n  );\n}\n\nexport function hashKey(key: CacheKey): string[] {\n  return typeof key === 'string'\n    ? [key]\n    : key.map((k) => {\n        return typeof k === 'string' ? k : hash(k);\n      });\n}\nexport function getCacheData(\n  state: CacheState,\n  keys: string[],\n): CacheData | undefined {\n  let parent: CacheKeys | undefined = state;\n  for (const key of keys) {\n    parent = parent?.keys?.get(key);\n    if (!parent) return undefined;\n  }\n  return parent?.data;\n}\n\nexport function isCacheValid(cache: CacheData, exp: number) {\n  return !cache.invalid && Date.now() <= cache.date + exp;\n}\n\nexport function setCacheValue(\n  cacheState: CacheState,\n  keys: string[],\n  value: Omit<CacheData, 'hitCount'>,\n  maxCacheSize?: number,\n  expires?: number,\n) {\n  let cache = cacheState;\n  let lastCache: CacheKeys | undefined = undefined;\n  for (let i = 0; i < keys.length; i++) {\n    const key = keys[i];\n    cache.keys = cache?.keys ?? new Map<string, CacheKeys>();\n    let v = cache.keys.get(key);\n    v = v ?? ({} as CacheKeys);\n    cache.keys.set(key, v);\n    lastCache = cache;\n    cache = v;\n  }\n  cache.data = cache.data\n    ? { ...value, hitCount: cache.data.hitCount + 1, expires }\n    : { ...value, hitCount: 1, expires };\n\n  if (maxCacheSize && lastCache?.keys && lastCache.keys.size > maxCacheSize) {\n    const entries = findLessHitOrOldestCacheEntries(\n      lastCache,\n      expires ?? Infinity,\n      maxCacheSize,\n    );\n    if (entries && entries.length) {\n      for (const [key] of entries) {\n        lastCache.keys.delete(key);\n      }\n    }\n  }\n}\n\nexport function findLessHitOrOldestCacheEntries(\n  state: CacheKeys,\n  expires: number,\n  maxCacheSize: number,\n) {\n  if (!state.keys) return undefined;\n  const entries = [...state.keys.entries()];\n  // find the newest key;\n  const [newestKey] = entries.reduce((a, b) => {\n    const aDate = a[1].data?.date ?? 0;\n    const bDate = b[1].data?.date ?? 0;\n    return aDate > bDate ? a : b;\n  });\n  const sorted = entries.sort(([aKey, aValue], [bKey, bValue]) => {\n    // ensures the newest key always wins\n    if (aKey === newestKey) return -1;\n    if (bKey === newestKey) return 1;\n    const aValid = aValue.data && isCacheValid(aValue.data, expires) ? 1 : 0;\n    const bValid = bValue.data && isCacheValid(bValue.data, expires) ? 1 : 0;\n    const diffValid = aValid - bValid;\n    const diffHit = (aValue.data?.hitCount ?? 0) - (bValue.data?.hitCount ?? 0);\n    const diffDate = (aValue.data?.date ?? 0) - (bValue.data?.date ?? 0);\n    return (\n      -1 * (diffValid === 0 ? (diffHit === 0 ? diffDate : diffHit) : diffValid)\n    );\n  });\n  return sorted.slice(maxCacheSize);\n}\n\nexport function deleteCache(cacheState: CacheState, keys: string[]) {\n  let cache = cacheState;\n  for (const key of keys) {\n    if (!cache.keys) return;\n    let v = cache.keys.get(key);\n    if (!v) return;\n    cache = v;\n  }\n  if (cache.data) delete cache.data;\n  else if (cache.keys) delete cache.keys;\n}\n\nexport function invalidateCache(cacheState: CacheState, keys: string[]) {\n  let cache = cacheState;\n  for (const key of keys) {\n    if (!cache?.keys) return;\n    let v = cache?.keys?.get(key);\n    if (!v) return;\n    cache = v;\n  }\n  cache && invalidateSubKeys(cache);\n}\n\nexport function increaseCacheHitCount(cacheState: CacheState, keys: string[]) {\n  let cache = cacheState;\n  for (const key of keys) {\n    if (!cache?.keys) return;\n    let v = cache?.keys?.get(key);\n    if (!v) return;\n    cache = v;\n  }\n  if (!cache.data) return;\n  cache.data = { ...cache.data, hitCount: cache.data.hitCount + 1 };\n}\n\nexport function invalidateSubKeys(state: CacheKeys) {\n  if (state.data) {\n    state.data = { ...state.data, invalid: true };\n  }\n  if (state.keys) {\n    for (const key in state.keys) {\n      const cache = state.keys.get(key);\n      cache && invalidateSubKeys(cache);\n    }\n  }\n  return state;\n}\nexport function getCacheEntry(cacheState: CacheState, keys: string[]) {\n  let parent = cacheState as CacheKeys | undefined;\n  for (const key of keys) {\n    parent = parent?.keys?.get(key);\n    if (!parent) return undefined;\n  }\n  return parent?.data;\n}\n\nexport function deleteExpiredOrInvalidCache(cacheState: CacheState) {\n  const entries = cacheState.keys ? [...cacheState.keys.entries()] : [];\n  for (const [key, value] of entries) {\n    if (\n      value.data &&\n      (value.data.invalid ||\n        Date.now() > value.data.date + (value.data.expires ?? Infinity))\n    ) {\n      cacheState.keys?.delete(key);\n    } else if (value.keys) {\n      deleteExpiredOrInvalidCache(value);\n    }\n  }\n}\nexport function clearCache(cacheState: CacheState) {\n  const entries = cacheState.keys ? [...cacheState.keys.entries()] : [];\n  for (const [key, value] of entries) {\n    if (value.data) {\n      cacheState.keys?.clear();\n    } else if (value.keys) {\n      clearCache(value);\n    }\n  }\n  cacheState.keys?.clear();\n}\n","import { Inject, OnDestroy } from '@angular/core';\nimport { from, isObservable, lastValueFrom, Observable, of, tap } from 'rxjs';\n\nimport { CacheKey, CacheState, CacheValue } from './cache.model';\nimport {\n  clearCache,\n  deleteCache,\n  deleteExpiredOrInvalidCache,\n  getCacheEntry,\n  hashKey,\n  increaseCacheHitCount,\n  invalidateCache,\n  isCacheValid,\n  setCacheValue,\n} from './cache.utils';\n\n@Inject({})\nexport class CacheStore implements OnDestroy {\n  cacheState: CacheState = {};\n  skipAllCache = false;\n  private intervalCancelKey: any;\n  private isBrowser = typeof window !== 'undefined';\n\n  constructor({ clearExpiredEvery }: { clearExpiredEvery: number }) {\n    if (this.isBrowser && clearExpiredEvery > 0) {\n      this.intervalCancelKey = setInterval(\n        () => deleteExpiredOrInvalidCache(this.cacheState),\n        clearExpiredEvery,\n      );\n    }\n  }\n\n  get({ key }: { key: CacheKey }) {\n    if (!this.isBrowser) {\n      return undefined;\n    }\n    const keys = hashKey(key);\n    const cache = getCacheEntry(this.cacheState, keys);\n    const exp = cache?.expires ?? Infinity;\n    const isValid = cache && !this.skipAllCache && isCacheValid(cache, exp);\n    return isValid ? cache : undefined;\n  }\n\n  set<T extends CacheValue>({\n    key,\n    value: valueOrFn,\n    expires,\n    maxCacheSize,\n  }: {\n    key: CacheKey;\n    value: ((previousValue?: T) => T) | T;\n    expires?: number;\n    maxCacheSize?: number;\n  }) {\n    if (!this.isBrowser) {\n      return;\n    }\n    const exp = expires ?? Infinity;\n    const keys = hashKey(key);\n    if (typeof valueOrFn === 'function') {\n      const cache = getCacheEntry(this.cacheState, keys);\n      const isValid = cache && !this.skipAllCache && isCacheValid(cache, exp);\n\n      const value = isValid ? valueOrFn(cache?.value) : valueOrFn();\n      setCacheValue(\n        this.cacheState,\n        keys,\n        { value, date: Date.now(), invalid: false },\n        maxCacheSize,\n      );\n    } else {\n      setCacheValue(\n        this.cacheState,\n        keys,\n        { value: valueOrFn, date: Date.now(), invalid: false },\n        maxCacheSize,\n      );\n    }\n  }\n\n  invalidate({ key }: { key: CacheKey }) {\n    if (!this.isBrowser) {\n      return;\n    }\n    return invalidateCache(this.cacheState, hashKey(key));\n  }\n\n  delete({ key }: { key: CacheKey }) {\n    if (!this.isBrowser) {\n      return;\n    }\n    return deleteCache(this.cacheState, hashKey(key));\n  }\n\n  setSkipCacheForAllCalls(skipAllCache: boolean) {\n    if (!this.isBrowser) {\n      return;\n    }\n    this.skipAllCache = skipAllCache;\n  }\n\n  clear() {\n    if (!this.isBrowser) {\n      return;\n    }\n    clearCache(this.cacheState);\n  }\n\n  ngOnDestroy() {\n    this.intervalCancelKey && clearInterval(this.intervalCancelKey);\n    this.clear();\n  }\n}\n","import { Provider } from '@angular/core';\nimport { from, isObservable, lastValueFrom, Observable, of, tap } from 'rxjs';\n\nimport { CacheStore } from './cache-store';\nimport { CacheKey } from './cache.model';\nimport {\n  getCacheEntry,\n  hashKey,\n  increaseCacheHitCount,\n  isCacheValid,\n  setCacheValue,\n} from './cache.utils';\n\nlet globalCache = new CacheStore({ clearExpiredEvery: 10 * 60 * 1000 });\n\nexport function setGlobalCache(cache: CacheStore) {\n  globalCache.ngOnDestroy();\n  globalCache = cache;\n}\n\nexport function getGlobalCache() {\n  return globalCache;\n}\n\n/**\n * Return the cached results of the key if available, otherwise return the value of source and cache it\n * @param options\n */\nexport function cacheCall<T>({\n  key,\n  call,\n  expires,\n  maxCacheSize,\n  skip,\n  cacheStore,\n}: {\n  key: CacheKey;\n  call: () => Promise<T>;\n  expires?: number;\n  maxCacheSize?: number;\n  skip?: boolean;\n  cacheStore?: CacheStore;\n}): Promise<T> {\n  const cs = cacheStore ?? getGlobalCache();\n  const exp = expires ?? Infinity;\n  const keys = hashKey(key);\n  const cache = getCacheEntry(cs.cacheState, keys);\n  const isValid =\n    cache && !skip && !cs.skipAllCache && isCacheValid(cache, exp);\n  if (isValid) {\n    increaseCacheHitCount(cs.cacheState, keys);\n    return Promise.resolve(cache.value);\n  } else {\n    return call().then((value) => {\n      setCacheValue(\n        cs.cacheState,\n        keys,\n        { value, date: Date.now(), invalid: false },\n        maxCacheSize,\n      );\n      return value;\n    });\n  }\n}\n\n/**\n * Return the cached results of the key if available, otherwise return the value of source and cache it\n * @param options\n */\nexport function cacheRxCall<T>({\n  key,\n  call,\n  expires,\n  maxCacheSize,\n  skip,\n  cacheStore,\n}: {\n  key: CacheKey;\n  call: Observable<T>;\n  expires?: number;\n  maxCacheSize?: number;\n  skip?: boolean;\n  cacheStore?: CacheStore;\n}): Observable<T> {\n  const cs = cacheStore ?? getGlobalCache();\n  const exp = expires ?? Infinity;\n  const keys = hashKey(key);\n  const cache = getCacheEntry(cs.cacheState, keys);\n  const isValid =\n    cache && !skip && !cs.skipAllCache && isCacheValid(cache, exp);\n  if (isValid) {\n    increaseCacheHitCount(cs.cacheState, keys);\n    return of(cache.value);\n  } else {\n    return call.pipe(\n      tap((value) => {\n        setCacheValue(\n          cs.cacheState,\n          keys,\n          { value, date: Date.now(), invalid: false },\n          maxCacheSize,\n        );\n        return value;\n      }),\n    );\n  }\n}\n\nexport function provideCacheStore(cacheStore: CacheStore): Provider[] {\n  return [\n    {\n      provide: CacheStore,\n      useValue: cacheStore,\n    },\n  ];\n}\n","import { EffectRef, Injector } from '@angular/core';\nimport {\n  getState,\n  patchState,\n  signalMethod,\n  SignalStoreFeature,\n  signalStoreFeature,\n  SignalStoreFeatureResult,\n  withMethods,\n} from '@ngrx/signals';\n\nimport { capitalize } from '../util';\n\n/**\n * Setter generated by `withStateSetter` for a state prop of type T.\n * Accepts a plain value, a signal/reactive fn (keeps state in sync via\n * `signalMethod`), or an updater `(current) => next` for partial updates.\n */\nexport type StateSetter<T> = ((\n  input: T | (() => T) | ((current: T) => T),\n  config?: { injector?: Injector },\n) => EffectRef) &\n  EffectRef;\n\n/** Prop name without its leading underscore, if it has one. */\ntype Unprefixed<P extends string> = P extends `_${infer R}` ? R : P;\n\n/**\n * Name of the setter generated by `withStateSetter` for state prop P: always\n * the public `set<P>`, a leading underscore in the prop name is dropped\n * (`_filter` -> `setFilter`).\n */\nexport type SetterKey<P extends string> = `set${Capitalize<Unprefixed<P>>}`;\n\n/**\n * Name of the setter generated by `withStatePrivateSetter` for state prop P:\n * always the private `_set<P>`, regardless of whether P itself starts with an\n * underscore (`filter` and `_filter` both -> `_setFilter`).\n */\nexport type PrivateSetterKey<P extends string> =\n  `_set${Capitalize<Unprefixed<P>>}`;\n\nfunction setterKey(key: string, isPrivate: boolean): string {\n  const prop = capitalize(key.startsWith('_') ? key.slice(1) : key);\n  return isPrivate ? `_set${prop}` : `set${prop}`;\n}\n\nfunction stateSetterFactory(\n  keys: string[],\n  { featureName, isPrivate }: { featureName: string; isPrivate: boolean },\n): SignalStoreFeature<SignalStoreFeatureResult, any> {\n  return signalStoreFeature(\n    withMethods((store) => {\n      const state = getState(store);\n      return keys.reduce(\n        (methods, key) => {\n          if (!(key in state)) {\n            console.warn(\n              `@ngrx-traits/signals: ${featureName}('${key}') does not match any state prop`,\n            );\n          }\n          const setValue = signalMethod<unknown>((value) =>\n            patchState(store, { [key]: value }),\n          );\n          // updaters take the current value as param; signalMethod treats any\n          // fn as a zero-arg reactive computation, so route by arity\n          const setter = (\n            value: unknown,\n            config?: { injector?: Injector },\n          ): EffectRef => {\n            if (typeof value === 'function' && value.length > 0) {\n              patchState(store, (state: Record<string, unknown>) => ({\n                [key]: value(state[key]),\n              }));\n              return { destroy: () => void 0 };\n            }\n            return setValue(value, config);\n          };\n          setter.destroy = setValue.destroy;\n          methods[setterKey(key, isPrivate)] = setter;\n          return methods;\n        },\n        {} as Record<string, StateSetter<unknown>>,\n      );\n    }),\n  ) as SignalStoreFeature<SignalStoreFeatureResult, any>;\n}\n\n/**\n * Generates a `set<Prop>()` method for each provided state prop that patches\n * the state with the given value. The generated methods are `signalMethod`s,\n * so they accept either a plain value or a signal/computed; when given a\n * signal, the state is kept in sync with it. They also accept an updater\n * function `(current) => next` receiving the current prop value, for partial\n * updates.\n *\n * The generated setters are always public: a leading underscore in the prop\n * name is dropped (`_filter` -> `setFilter`). Use `withStatePrivateSetter` to\n * generate setters only accessible inside the store.\n *\n * Note: updaters are told apart from reactive fns by arity — an updater must\n * declare its parameter (`(current) => ...`), a zero-arg fn is treated as a\n * reactive computation.\n *\n * @param keys - names of state props to generate setters for\n *\n * @example\n * const Store = signalStore(\n *   withState({\n *     a: { b: '' },\n *     c: 1,\n *     d: 12,\n *   }),\n *   withStateSetter('a', 'd'),\n * );\n * // generates the methods\n * store.setA({ b: 'hello' }); // patchState(store, { a: { b: 'hello' } })\n * store.setD(42);             // patchState(store, { d: 42 })\n * // updater fn receives the current prop value, for partial updates:\n * store.setA((a) => ({ ...a, b: 'partial' }));\n * // signalMethod also accepts signals, keeping state in sync:\n * store.setD(this.dInput); // dInput: Signal<number>\n */\nexport function withStateSetter<\n  Input extends SignalStoreFeatureResult,\n  K extends keyof Input['state'] & string,\n>(\n  ...keys: K[]\n): SignalStoreFeature<\n  Input,\n  {\n    state: {};\n    props: {};\n    methods: {\n      [P in K as SetterKey<P>]: StateSetter<Input['state'][P]>;\n    };\n  }\n>;\nexport function withStateSetter(\n  ...keys: string[]\n): SignalStoreFeature<SignalStoreFeatureResult, any> {\n  return stateSetterFactory(keys, {\n    featureName: 'withStateSetter',\n    isPrivate: false,\n  });\n}\n\n/**\n * Like `withStateSetter`, but the generated setters are private: for each\n * provided state prop it generates a `_set<Prop>()` method, which starts with\n * an underscore, making it only accessible inside the store. Useful to allow a\n * prop to be publicly readable while only writable from within the store.\n *\n * The generated methods behave exactly like the ones from `withStateSetter`:\n * they are `signalMethod`s that accept a plain value, a signal/computed (keeps\n * state in sync), or an updater function `(current) => next` for partial\n * updates. A leading underscore in the prop name is dropped, so `filter` and\n * `_filter` both generate `_setFilter`.\n *\n * @param keys - names of state props to generate private setters for\n *\n * @example\n * const Store = signalStore(\n *   withState({\n *     filter: '',\n *     d: 12,\n *   }),\n *   withStatePrivateSetter('filter'),\n *   withMethods((store) => ({\n *     clearFilter: () => store._setFilter(''), // usable inside the store\n *   })),\n * );\n * // outside the store, filter is readable but _setFilter is not accessible\n * store.filter();\n */\nexport function withStatePrivateSetter<\n  Input extends SignalStoreFeatureResult,\n  K extends keyof Input['state'] & string,\n>(\n  ...keys: K[]\n): SignalStoreFeature<\n  Input,\n  {\n    state: {};\n    props: {};\n    methods: {\n      [P in K as PrivateSetterKey<P>]: StateSetter<Input['state'][P]>;\n    };\n  }\n>;\nexport function withStatePrivateSetter(\n  ...keys: string[]\n): SignalStoreFeature<SignalStoreFeatureResult, any> {\n  return stateSetterFactory(keys, {\n    featureName: 'withStatePrivateSetter',\n    isPrivate: true,\n  });\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["filter","filterPipe","clearEntitiesCache","isEntitiesInCache","mapPipes","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