{"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-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-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-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-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/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  queryParamsToFilter: (query: T) => Filter;\n  filterToQueryParams: (filter: Filter) => T | undefined | null;\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 } = getWithEntitiesFilterKeys(config);\n\n  return {\n    queryParamsToState: (query, store, firstLoad) => {\n      const filter = config?.filterMapper\n        ? config?.filterMapper.queryParamsToFilter(query)\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          // 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 {\n  EntityMap,\n  EntityProps,\n  EntityState,\n  NamedEntityProps,\n  NamedEntityState,\n  SelectEntityId,\n} from '@ngrx/signals/entities';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport { map, Observable, pipe, tap } from 'rxjs';\n\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 &\n    (Collection extends ''\n      ? {\n          state: EntityState<Entity>;\n          props: EntityProps<Entity>;\n          methods: {};\n        }\n      : {\n          state: NamedEntityState<Entity, Collection>;\n          props: NamedEntityProps<Entity, Collection>;\n          methods: {};\n        }),\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 type {\n  EntityProps,\n  EntityState,\n  NamedEntityProps,\n  NamedEntityState,\n} 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 { getWithEntitiesKeys } from '../util';\nimport {\n  CallStatus,\n  CallStatusMethods,\n  NamedCallStatusMethods,\n} 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    (Collection extends ''\n      ? {\n          state: EntityState<Entity>;\n          props: EntityProps<Entity>;\n          methods: CallStatusMethods;\n        }\n      : {\n          state: NamedEntityState<Entity, Collection>;\n          props: NamedEntityProps<Entity, Collection>;\n          methods: NamedCallStatusMethods<`${Collection}Entities`>;\n        }),\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              return 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            },\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 {\n  EntityMap,\n  EntityProps,\n  EntityState,\n  NamedEntityProps,\n  NamedEntityState,\n  SelectEntityId,\n} 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 { getWithEntitiesKeys, insertIf } from '../util';\nimport {\n  CallStatus,\n  CallStatusMethods,\n  NamedCallStatusMethods,\n} 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    (Collection extends ''\n      ? {\n          state: EntityState<Entity>;\n          props: EntityProps<Entity>;\n          methods: CallStatusMethods;\n        }\n      : {\n          state: NamedEntityState<Entity, Collection>;\n          props: NamedEntityProps<Entity, Collection>;\n          methods: NamedCallStatusMethods<`${Collection}Entities`>;\n        }),\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              return 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            },\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","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';\nimport { EntityState, NamedEntityState } from '@ngrx/signals/entities';\nimport { EntityProps, NamedEntityProps } from '@ngrx/signals/entities';\n\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    (Collection extends ''\n      ? {\n          state: EntityState<Entity>;\n          props: EntityProps<Entity>;\n          methods: {};\n        }\n      : {\n          state: NamedEntityState<Entity, Collection>;\n          props: NamedEntityProps<Entity, Collection>;\n          methods: {};\n        }),\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 {\n  EntityProps,\n  EntityState,\n  NamedEntityProps,\n  NamedEntityState,\n  SelectEntityId,\n  setAllEntities,\n} 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 { getWithEntitiesKeys } from '../util';\nimport {\n  CallStatusComputed,\n  CallStatusMethods,\n  NamedCallStatusComputed,\n  NamedCallStatusMethods,\n} from '../with-call-status/with-call-status.model';\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    (Collection extends ''\n      ? {\n          state: EntityState<Entity>;\n          props: EntityProps<Entity> & CallStatusComputed;\n          methods: CallStatusMethods;\n        }\n      : {\n          state: NamedEntityState<Entity, Collection>;\n          props: NamedEntityProps<Entity, Collection> &\n            NamedCallStatusComputed<`${Collection}Entities`>;\n          methods: NamedCallStatusMethods<`${Collection}Entities`>;\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\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  EntityProps,\n  EntityState,\n  NamedEntityProps,\n  NamedEntityState,\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 { getWithEntitiesKeys } from '../util';\nimport {\n  CallStatusComputed,\n  CallStatusMethods,\n  NamedCallStatusComputed,\n  NamedCallStatusMethods,\n} from '../with-call-status/with-call-status.model';\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    (Collection extends ''\n      ? {\n          state: EntityState<Entity>;\n          props: EntityProps<Entity> & CallStatusComputed;\n          methods: CallStatusMethods;\n        }\n      : {\n          state: NamedEntityState<Entity, Collection>;\n          props: NamedEntityProps<Entity, Collection> &\n            NamedCallStatusComputed<`${Collection}Entities`>;\n          methods: NamedCallStatusMethods<`${Collection}Entities`>;\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 {\n  EntityProps,\n  EntityState,\n  NamedEntityProps,\n  NamedEntityState,\n  SelectEntityId,\n} from '@ngrx/signals/entities';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport { isObservable, map, Observable, pipe, tap } from 'rxjs';\n\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 &\n    (Collection extends ''\n      ? {\n          state: EntityState<Entity>;\n          props: EntityProps<Entity>;\n          methods: {};\n        }\n      : {\n          state: NamedEntityState<Entity, Collection>;\n          props: NamedEntityProps<Entity, Collection>;\n          methods: {};\n        }),\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 { EntityState, NamedEntityState } from '@ngrx/signals/entities';\nimport { EntityProps, NamedEntityProps } from '@ngrx/signals/entities';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport { isObservable, map, Observable, pipe, tap } from 'rxjs';\n\nimport {\n  CallStatusMethods,\n  NamedCallStatusMethods,\n} 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 { 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    (Collection extends ''\n      ? {\n          state: EntityState<Entity>;\n          props: EntityProps<Entity>;\n          methods: CallStatusMethods;\n        }\n      : {\n          state: NamedEntityState<Entity, Collection>;\n          props: NamedEntityProps<Entity, Collection>;\n          methods: NamedCallStatusMethods<`${Collection}Entities`>;\n        }),\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 { 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 {\n  EntityMap,\n  EntityProps,\n  EntityState,\n  NamedEntityProps,\n  NamedEntityState,\n} from '@ngrx/signals/entities';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport { pipe, tap } from 'rxjs';\n\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    (Collection extends ''\n      ? {\n          state: EntityState<Entity>;\n          props: EntityProps<Entity>;\n          methods: {};\n        }\n      : {\n          state: NamedEntityState<Entity, Collection>;\n          props: NamedEntityProps<Entity, Collection>;\n          methods: {};\n        }),\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 {\n  EntityState,\n  NamedEntityState,\n  SelectEntityId,\n} from '@ngrx/signals/entities';\nimport {\n  EntityId,\n  EntityMap,\n  EntityProps,\n  NamedEntityProps,\n} from '@ngrx/signals/entities';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport { pipe, tap } from 'rxjs';\n\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    (Collection extends ''\n      ? {\n          state: EntityState<Entity>;\n          props: EntityProps<Entity>;\n          methods: {};\n        }\n      : {\n          state: NamedEntityState<Entity, Collection>;\n          props: NamedEntityProps<Entity, Collection>;\n          methods: {};\n        }),\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 {\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 {\n  EntityProps,\n  EntityState,\n  NamedEntityProps,\n  NamedEntityState,\n  SelectEntityId,\n  setAllEntities,\n} 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  CallStatusComputed,\n  CallStatusMethods,\n  CallStatusState,\n  NamedCallStatusComputed,\n  NamedCallStatusMethods,\n  NamedCallStatusState,\n} from '../with-call-status/with-call-status.model';\nimport {\n  getWithCallStatusEvents,\n  getWithCallStatusKeys,\n} from '../with-call-status/with-call-status.util';\nimport { NamedSetEntitiesResult } from '../with-entities-pagination/with-entities-local-pagination.model';\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';\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<\n            Input['methods'] extends NamedSetEntitiesResult<\n              Collection,\n              infer ResultParam\n            >\n              ? ResultParam\n              : Entity[] | { entities: Entity[] }\n          >\n        | Promise<\n            Input['methods'] extends NamedSetEntitiesResult<\n              Collection,\n              infer ResultParam\n            >\n              ? ResultParam\n              : Entity[] | { entities: Entity[] }\n          >;\n      mapPipe?: 'switchMap' | 'concatMap' | 'exhaustMap';\n      onSuccess?: (\n        result: Input['methods'] extends NamedSetEntitiesResult<\n          Collection,\n          infer ResultParam\n        >\n          ? ResultParam\n          : Entity[] | { entities: 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    (Collection extends ''\n      ? {\n          state: EntityState<Entity> & CallStatusState;\n          props: EntityProps<Entity> & CallStatusComputed<Error>;\n          methods: CallStatusMethods<Error>;\n        }\n      : {\n          state: NamedEntityState<Entity, Collection> &\n            NamedCallStatusState<`${Collection}Entities`>;\n          props: NamedEntityProps<Entity, Collection> &\n            NamedCallStatusComputed<`${Collection}Entities`, Error>;\n          methods: NamedCallStatusMethods<`${Collection}Entities`, 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) onSuccess(result);\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. 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 *       // 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(store[key])) {\n                      acc[key] = store[key]();\n                    } else if (typeof store[key] != 'function') {\n                      // if not signal only log values that are not methods\n                      acc[key] = store[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        effect(() => {\n          const state = signalsComputed();\n          console.log(`${name} store changed: `, state);\n          if (showDiff && lastState)\n            deepDiff(`${name} store changes diff :`, lastState, state);\n          lastState = state;\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 // () => void\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          ? () => void\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            ? () => void\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                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>>>,\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 {\n  EntityProps,\n  EntityState,\n  NamedEntityProps,\n  NamedEntityState,\n} from '@ngrx/signals/entities';\nimport { concatMap, first } from 'rxjs';\n\nimport {\n  CallStatusComputed,\n  CallStatusMethods,\n  CallStatusState,\n  NamedCallStatusComputed,\n  NamedCallStatusMethods,\n  NamedCallStatusState,\n} from '../with-call-status/with-call-status.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({ prop: 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 */\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    (Collection extends ''\n      ? {\n          state: EntityState<Entity> & CallStatusState;\n          props: EntityProps<Entity> & CallStatusComputed;\n          methods: CallStatusMethods;\n        }\n      : {\n          state: NamedEntityState<Entity, Collection> &\n            NamedCallStatusState<`${Collection}Entities`>;\n          props: NamedEntityProps<Entity, Collection> &\n            NamedCallStatusComputed<`${Collection}Entities`>;\n          methods: NamedCallStatusMethods<`${Collection}Entities`>;\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, 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  EntityProps,\n  EntityState,\n  NamedEntityProps,\n  NamedEntityState,\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 { 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 {\n  CallStatus,\n  NamedCallStatusState,\n} 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} | Signal<{id: string}> | Observable<{id: string}>) => void\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    (Collection extends ''\n      ? {\n          state: EntityState<NoInfer<Entity>>;\n          props: EntityProps<NoInfer<Entity>>;\n          methods: {};\n        }\n      : {\n          state: NamedEntityState<NoInfer<Entity>, Collection>;\n          props: NamedEntityProps<NoInfer<Entity>, Collection>;\n          methods: {};\n        }),\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            (\n              param: P[0],\n            ): Promise<\n              | { value: Signal<Entity>; ok: true }\n              | { error: Signal<ExtractEntityCallErrorType<Calls[K]>>; ok: false }\n            >;\n            (param: Observable<P[0]> | (() => P[0])): RxMethodRef;\n          }\n        : Calls[K] extends EntityCallConfig\n          ? Parameters<Calls[K]['call']> extends undefined[]\n            ? () => void\n            : {\n                (\n                  ...param: Parameters<Calls[K]['call']>\n                ): Promise<\n                  | { value: Signal<Entity>; ok: true }\n                  | { error: Signal<ExtractEntityCallErrorType<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 = 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                return 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                        ? { value: computed(() => entityMap()[id]), ok: true as const }\n                        : {\n                            error: computed(() => typeof v === 'object' ? v.error : undefined),\n                            ok: false as const,\n                          },\n                    ),\n                  ),\n                );\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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["filter","filterPipe","clearEntitiesCache","isEntitiesInCache","mapPipes","isCallConfig","getCallFn","map","extractRouteParams"],"mappings":";;;;;;;;;;;;AAIM,SAAU,iBAAiB,CAC/B,KAA0B,EAC1B,UAAsB,EAAA;AAEtB,IAAA,IAAI,qBAAqB,IAAI,KAAK,EAAE;AAEhC,QAAA,KACD,CAAC,mBAAmB,CAAC,UAAU,CAAC;IACnC;AACF;;ACbM,SAAU,UAAU,CAAC,IAAY,EAAA;AACrC,IAAA,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AACrD;AAEM,SAAU,mBAAmB,CAAC,MAAgC,EAAA;AAClE,IAAA,MAAM,UAAU,GAAG,MAAM,EAAE,UAAU;IACrC,OAAO;AACL,QAAA,MAAM,EAAE,UAAU,GAAG,CAAA,EAAG,MAAM,CAAC,UAAU,CAAA,GAAA,CAAK,GAAG,KAAK;AACtD,QAAA,WAAW,EAAE,UAAU,GAAG,CAAA,EAAG,MAAM,CAAC,UAAU,CAAA,QAAA,CAAU,GAAG,UAAU;AACrE,QAAA,YAAY,EAAE,UAAU,GAAG,CAAA,EAAG,MAAM,CAAC,UAAU,CAAA,SAAA,CAAW,GAAG,WAAW;KACzE;AACH;AACM,SAAU,KAAK,CAAC,CAAyB,EAAA;IAC7C,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,IAAgC,EAAE,KAAK,KAAI;AAC1D,QAAA,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI;AAClB,QAAA,OAAO,IAAI;IACb,CAAC,EAAE,EAAE,CAAC;AACR;AACM,SAAU,QAAQ,CAAI,SAAc,EAAE,UAAmB,EAAA;AAC7D,IAAA,QAAQ,SAAS,GAAG,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE;AACzC;AAOM,SAAU,gBAAgB,CAC9B,QAA8B,EAC9B,I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