{"version":3,"file":"state-adapt-rxjs.mjs","sources":["../../../../libs/rxjs/src/lib/sources/source.ts","../../../../libs/rxjs/src/lib/sources/source.function.ts","../../../../libs/rxjs/src/lib/sources/to-source.operator.ts","../../../../libs/rxjs/src/lib/sources/type.operator.ts","../../../../libs/rxjs/src/lib/sources/catch-error-source.operator.ts","../../../../libs/rxjs/src/lib/sources/to-request-source.operator.ts","../../../../libs/rxjs/src/lib/sources/split-sources.function.ts","../../../../libs/rxjs/src/lib/sources/split-request-sources.function.ts","../../../../libs/rxjs/src/lib/sources/get-request-sources.function.ts","../../../../libs/rxjs/src/lib/http/prefix-source.function.ts","../../../../libs/rxjs/src/lib/http/get-http-error.function.ts","../../../../libs/rxjs/src/lib/http/get-catch-http-error.function.ts","../../../../libs/rxjs/src/lib/http/get-http-actions.function.ts","../../../../libs/rxjs/src/lib/http/split-http-sources.function.ts","../../../../libs/rxjs/src/lib/http/get-http-sources.function.ts","../../../../libs/rxjs/src/lib/stores/join-stores.function.ts","../../../../libs/rxjs/src/lib/sources/is-source.function.ts","../../../../libs/rxjs/src/lib/global-store/state-adapt.types.ts","../../../../libs/rxjs/src/lib/sources/get-payload.function.ts","../../../../libs/rxjs/src/lib/global-store/create-initial-state-getter.function.ts","../../../../libs/rxjs/src/lib/global-store/state-adapt.ts","../../../../libs/rxjs/src/lib/global-store/observable-store.ts","../../../../libs/rxjs/src/lib/create-global-store.function.ts","../../../../libs/rxjs/src/lib/global-store/configure-state-adapt.function.ts","../../../../libs/rxjs/src/lib/utils/map-each-with-effect.function.ts","../../../../libs/rxjs/src/state-adapt-rxjs.ts"],"sourcesContent":["import { Subject } from 'rxjs';\nimport { Action } from '@state-adapt/core';\nimport { source } from './source.function';\n\ntype SubjectWithoutNext = new <K>() => {\n  [P in Exclude<keyof Subject<K>, 'next'>]: Subject<K>[P];\n};\n\nconst SubjectWithoutNext: SubjectWithoutNext = Subject;\n\n/**\n * @deprecated Use {@link source} instead.\n */\nexport class Source<T> extends SubjectWithoutNext<Action<T>> {\n  type: string;\n\n  constructor(type = '') {\n    super();\n    this.type = type;\n  }\n  next(payload: T): void {\n    Subject.prototype.next.call(this, { type: this.type, payload });\n  }\n}\n","import { Subject } from 'rxjs';\n\n/**\n *  `source` returns an object that extends an RxJS [Subject](https://rxjs.dev/guide/subject) with an extra `type: string` property, and is also callable directly.\n *  When using a `source`, you can provide a `type` argument, which will appear as the action type in Redux DevTools:\n *\n *  ![Action Type in Redux Devtools](https://state-adapt.github.io/assets/devtools-add$.png)\n *\n *  In the future we want to add a build step to add this annotation automatically. That is why source types are optional.\n *\n *  #### Example: Creating a source without a type\n *\n *  ```typescript\n *  import { source } from '@state-adapt/rxjs';\n *\n *  const add$ = source<number>();\n *\n *  add$.subscribe(console.log);\n *\n *  add$.next(1);\n *  // 1\n *\n *  add$(2)\n *  // 2\n *  ```\n *\n *  #### Example: Creating a source with a type\n *  ```typescript\n *  const add$ = source<number>('add$');\n *  ```\n *\n *  #### Example: Creating a source with onEvent naming convention\n *  ```typescript\n *  import { source } from '@state-adapt/rxjs';\n *\n *  const onAdd = source<number>();\n *\n *  onAdd.subscribe(console.log);\n *\n *  onAdd(1)\n *  // 1\n *  ```\n */\nexport function source<T>(type = '') {\n  const subject = new Subject<T>();\n\n  const onEvent = function (payload: T): void {\n    onEvent.next(payload);\n  } as any;\n\n  onEvent.type = type;\n  onEvent.prototype.name = type;\n\n  onEvent.next = function (payload: T): void {\n    subject.next(payload);\n  };\n  onEvent.subscribe = subject.subscribe.bind(subject);\n  onEvent.complete = subject.complete.bind(subject);\n  onEvent.error = subject.error.bind(subject);\n  onEvent.pipe = subject.pipe.bind(subject);\n  onEvent.lift = subject.lift.bind(subject);\n\n  return onEvent as SourceFn<T>;\n}\n\nexport type SourceFn<T> = (unknown extends T ? () => void : (payload: T) => void) &\n  Subject<T>;\n","import { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport { Action } from '@state-adapt/core';\n\n/**\n  `toSource` is a custom RxJS [operator](https://rxjs.dev/guide/operators) that converts an RxJS [Observable](https://rxjs.dev/guide/observable)\n  of values of type {@link Payload} (inferred) into an observable of values of type {@link Action}<{@link Payload}, {@link Type}>.\n  It takes one argument, `type`, which is the `type` property of the {@link Action} objects that will be emitted, and which will\n  appear as the action type in Redux DevTools:\n\n  ![Action Type in Redux Devtools](https://state-adapt.github.io/assets/devtools-timer$.png)\n\n  #### Example: Converting an observable into a source\n\n  ```typescript\n  import { timer } from 'rxjs';\n  import { toSource } from '@state-adapt/rxjs';\n\n  const timer$ = timer(1000).pipe(toSource('timer$'));\n\n  timer$.subscribe(console.log);\n  // { type: 'timer$', payload: 0 }\n  ```\n */\nexport function toSource<Payload, Type extends string = ''>(type: Type = '' as Type) {\n  return (source$: Observable<Payload>): Observable<Action<Payload, Type>> => {\n    const sourceWithType$ = source$.pipe(map(payload => ({ type, payload })));\n    return sourceWithType$ as Observable<Action<Payload, Type>>;\n  };\n}\n","/**\n  `type` is a custom RxJS [operator](https://rxjs.dev/guide/operators) that mutates an RxJS [Observable](https://rxjs.dev/guide/observable)\n  by setting a `type` property. It takes one argument, which will appear as the action type in Redux DevTools:\n\n  ![Action Type in Redux Devtools](https://state-adapt.github.io/assets/devtools-timer$.png)\n\n  #### Example: Converting an observable into a source\n\n  ```typescript\n  import { timer } from 'rxjs';\n  import { type } from '@state-adapt/rxjs';\n\n  const timer$ = timer(1000).pipe(type('timer$'));\n\n  timer$.subscribe(console.log);\n  // 0\n  ```\n */\nexport function type(type: string) {\n  return function <T>(source$: T): T & { type: string } {\n    (source$ as any).type = type;\n    return source$ as any;\n  };\n}\n","import { Observable, of } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\nimport { Action, getAction } from '@state-adapt/core';\n\n/**\n  `catchErrorSource` is a custom RxJS [operator](https://rxjs.dev/guide/operators) that converts an RxJS [Observable](https://rxjs.dev/guide/observable)\n  of any values into a source of errors, using RxJS' [catchError](https://rxjs.dev/api/operators/catchError) operator.\n  It takes one argument, {@link TypePrefix}, and prefixes it to create an object of type {@link Action}<any, ${{@link TypePrefix}}.error$>.\n\n  #### Example: Catching errors from a source\n\n  ```typescript\n  import { timer, map } from 'rxjs';\n\n  const timer$ = timer(1000).pipe(\n    map(n => ({ type: 'timer$', payload: n.fakeNumberMethod() })),\n    catchErrorSource('timer'),\n  );\n\n  timer$.subscribe(console.log);\n  // { type: 'timer.error$', payload: 'Error: n.fakeNumberMethod is not a function' }\n  ```\n */\nexport function catchErrorSource<Payload, TypePrefix extends string>(\n  typePrefix: TypePrefix,\n) {\n  return (\n    source$: Observable<Payload>,\n  ): Observable<Payload | Action<any, `${TypePrefix}.error$`>> =>\n    source$.pipe(catchError(err => of(getAction(`${typePrefix}.error$`, err))));\n}\n","import { Observable } from 'rxjs';\nimport { Action } from '@state-adapt/core';\nimport { toSource } from './to-source.operator';\nimport { catchErrorSource } from './catch-error-source.operator';\n\n/**\n  `toRequestSource` takes in a {@link TypePrefix} and converts an RxJS [Observable](https://rxjs.dev/guide/observable)\n  of values of type {@link Payload} (inferred) into an [Observable](https://rxjs.dev/guide/observable) of values of type\n\n  ```ts\n  | { type: `${TypePrefix}.success$`; payload: Payload }\n  | { type: `${TypePrefix}.error$`; payload: any }\n  ```\n\n  #### Example: Convert an HTTP POST observable into an observable with `success$` and `error$` values\n\n  ```typescript\n  import { exhaustMap } from 'rxjs';\n  import { ajax } from 'rxjs/ajax';\n  import { toRequestSource } from '@state-adapt/rxjs';\n\n  const deleteTodo$ = source<number>();\n\n  const deleteTodoRequest$ = deleteTodo$.pipe(\n    exhaustMap((id) =>\n      ajax({\n        url: `https://jsonplaceholder.typicode.com/todos/${id}`,\n        method: 'DELETE',\n      }).pipe(toRequestSource('todo.delete'))\n    )\n  );\n\n  deleteTodoRequest$.subscribe(console.log);\n\n  deleteTodo$.next(1);\n  // { type: 'todo.delete.success$', payload: AjaxResponse{…} }\n\n  deleteTodo$.next(Infinity);\n  // { type: 'todo.delete.error$', payload: 'AjaxErrorImpl{…} }\n\n  deleteTodo$.next(2);\n  // { type: 'todo.delete.success$', payload: AjaxResponse{…} }\n  ```\n\n  The main stream is not killed because `toRequestSource` operates on the request observable\n  instead of the outer observable.\n\n  #### Example: Converting any observable into a request source\n\n  ```typescript\n  import { interval } from 'rxjs';\n  import { toRequestSource } from '@state-adapt/rxjs';\n\n  const interval$ = interval(1000).pipe(\n    map(n => n < 2 ? n : n.fakeNumberMethod()),\n    toRequestSource('interval'),\n  );\n\n  interval$.subscribe(console.log);\n  // { type: 'interval.success$', payload: 0 }\n  // { type: 'interval.success$', payload: 1 }\n  // { type: 'interval.error$', payload: 'Error: n.fakeNumberMethod is not a function' }\n  // End\n  ```\n\n  The main stream is killed because `toRequestSource` operates directly on it\n  instead of on an inner observable.\n\n */\nexport function toRequestSource<Payload, TypePrefix extends string>(\n  typePrefix: TypePrefix,\n) {\n  return (\n    source$: Observable<Payload>,\n  ): Observable<\n    Action<Payload, `${TypePrefix}.success$`> | Action<any, `${TypePrefix}.error$`>\n  > => source$.pipe(toSource(`${typePrefix}.success$`), catchErrorSource(typePrefix));\n}\n","import { Observable } from 'rxjs';\nimport { filter, share } from 'rxjs/operators';\nimport { Action } from '@state-adapt/core';\n\n/**\n  `splitSources` is a function that takes in an [Observable](https://rxjs.dev/guide/observable) that emits multiple types of {@link Action} objects and splits it into a source for each {@link Action} type.\n  It takes two arguments:\n  - `source$`: [Observable](https://rxjs.dev/guide/observable)<{@link CommonAction}>\n  - `aliases?`: {@link Aliases} extends { [index: string]: {@link CommonType} } — An optional object with keys that will become the new source names,\n  and values that will filter against the `type` property of the actions from the `source$` observable.\n\n  It returns a proxy object that defines keys from the source types and the `aliases` argument (if provided),\n  and values of type [Observable](https://rxjs.dev/guide/observable)<{@link Action}<`Payload`, `Type`>>\n  where `Payload` and `Type` are inferred from the filtered `CommonAction` type.\n\n  If the source type is specific (as in `'even$' | 'odd$'`), the returned object will have `'even$'` and `'odd$'` properties.\n  If the source type is just a string, any string can be accessed, and {@link splitSources} will filter against that string.\n  The proxy defines this filtered source once the property is accessed.\n\n  #### Example: Splitting a source into multiple sources\n\n  ```typescript\n  import { getAction } from '@state-adapt/core';\n  import { splitSources } from '@state-adapt/rxjs';\n  import { interval, map } from 'rxjs';\n\n  const evenAndOdd$ = interval(1000).pipe(\n    map(n => ({\n      // type has to be 'even$' | 'odd$', not just a string\n      type: n % 2 === 0 ? ('even$' as const) : ('odd$' as const),\n      payload: n,\n    })),\n  );\n\n  evenAndOdd$.subscribe(console.log);\n  // { type: 'even$', payload: 0 }\n  // { type: 'odd$', payload: 1 }\n  // { type: 'even$', payload: 2 }\n  // { type: 'odd$', payload: 3 }\n\n  const { even$, odd$ } = splitSources(evenAndOdd$);\n\n  even$.subscribe(console.log);\n  // { type: 'even$', payload: 0 }\n  // { type: 'even$', payload: 2 }\n\n  odd$.subscribe(console.log);\n  // { type: 'odd$', payload: 1 }\n  // { type: 'odd$', payload: 3 }\n  ```\n\n  #### Example: Splitting an HTTP source using aliases\n\n  ```typescript\n  import { getAction } from '@state-adapt/core';\n  import { toSource, splitSources } from '@state-adapt/rxjs';\n  import { ajax } from 'rxjs/ajax';\n\n  const http$ = ajax('https://jsonplaceholder.typicode.com/todos/1').pipe(\n    map(res => ({ type: 'todos.success$' as const, payload: res })),\n    catchError(error => of({ type: 'todos.error$' as const, payload: error })),\n  );\n\n  const { success$, error$ } = splitSources(http$, {\n    success$: 'todos.success$',\n    error$: 'todos.error$',\n  });\n\n  success$.subscribe(console.log);\n  // { type: 'success$', payload: { ... } }\n\n  error$.subscribe(console.log);\n  // { type: 'error$', payload: { ... } }\n  ```\n */\nexport function splitSources<\n  CommonAction extends { type: string },\n  Aliases extends { [index: string]: keyof ActionMap<CommonAction> },\n>(\n  source$: Observable<CommonAction>,\n  partitions?: Aliases,\n): {\n  [K in string extends keyof Aliases\n    ? never\n    : keyof Aliases]: ActionMap<CommonAction>[Aliases[K]];\n} & ActionMap<CommonAction> {\n  const shared$ = source$.pipe(share()); // Each and every filtered source would cause everything upstream to run for iteslf\n\n  const sources = {} as any;\n\n  // Proxy enables optional partitions object\n  // Observable is defined as accessed, restricted to possible types\n  return new Proxy({} as any, {\n    get: (_, name: string) => {\n      const type = (partitions && partitions[name as keyof Aliases]) ?? name;\n      const typeSource$ =\n        sources[type] ?? (sources[type] = shared$.pipe(filter(val => val.type === type)));\n      return typeSource$;\n    },\n  });\n}\n\n// Helper type to split unions in the 'type' property\nexport type SplitAction<A> = A extends { type: infer T; payload: infer P }\n  ? T extends any\n    ? { type: T; payload: P }\n    : never\n  : A extends { type: infer T }\n  ? T extends any\n    ? { type: T }\n    : never\n  : never;\n\n// Apply the helper type to all actions\nexport type SplitActions<U> = U extends any ? SplitAction<U> : never;\n\n// Mapped type to transform the union into an object\nexport type ActionMap<U extends { type: string }> = {\n  [K in SplitActions<U>['type']]: Observable<Extract<SplitActions<U>, { type: K }>>;\n};\n","import { Action } from '@state-adapt/core';\nimport { splitSources } from './split-sources.function';\nimport { Observable } from 'rxjs';\n\n/**\n  `splitRequestSources` is a function that takes in a {@link TypePrefix} and an [Observable](https://rxjs.dev/guide/observable) with values of type\n\n  ```ts\n  | { type: `${TypePrefix}.success$`; payload: Payload }\n  | { type: `${TypePrefix}.error$`; payload: any }\n  ```\n\n  and returns an object with `success$` and `error$` propeties.\n\n  The `success$` property is an observable of values of type\n\n  ```ts\n  { type: `${TypePrefix}.success$`; payload: Payload }\n  ```\n\n  The `error$` property is an observable of values of type\n\n  ```ts\n  { type: `${TypePrefix}.error$`; payload: any }\n  ```\n\n  #### Example: Convert an HTTP POST observable into success$ and error$ sources\n\n  ```typescript\n  import { exhaustMap } from 'rxjs';\n  import { ajax } from 'rxjs/ajax';\n  import { splitRequestSources,  toRequestSource } from '@state-adapt/rxjs';\n\n  const deleteTodo$ = source<number>();\n\n  const deleteTodoRequest$ = deleteTodo$.pipe(\n    exhaustMap((id) =>\n      ajax({\n        url: `https://jsonplaceholder.typicode.com/todos/${id}`,\n        method: 'DELETE',\n      }).pipe(toRequestSource('todo.delete'))\n    )\n  );\n  const deleteTodoRequest = splitRequestSources('todo.delete', deleteTodoRequest$);\n\n  todoRequest.success$.subscribe(console.log);\n  todoRequest.error$.subscribe(console.log);\n\n  deleteTodo$.next(1);\n  // { type: 'todo.delete.success$', payload: AjaxResponse{…} }\n\n  deleteTodo$.next(Infinity);\n  // { type: 'todo.delete.error$', payload: 'AjaxErrorImpl{…} }\n\n  deleteTodo$.next(2);\n  // { type: 'todo.delete.success$', payload: AjaxResponse{…} }\n  ```\n\n  The main stream is not killed because `toRequestSource` operates on the request observable\n  instead of the outer observable.\n\n  #### Example: Splitting an observable of request actions into success$ and error$ sources\n\n  ```typescript\n  import { interval } from 'rxjs';\n  import { splitRequestSources, toRequestSource } from '@state-adapt/rxjs';\n\n  const interval$ = interval(1000).pipe(\n    map(n => n < 2 ? n : n.fakeNumberMethod()),\n    toRequestSource('interval'),\n  );\n\n  const { success$, error$ } = splitRequestSources('interval', interval$);\n\n  success$.subscribe(console.log);\n  // { type: 'interval.success$', payload: 0 }\n  // { type: 'interval.success$', payload: 1 }\n  // End\n\n  error$.subscribe(console.log);\n  // { type: 'interval.error$', payload: 'Error: n.fakeNumberMethod is not a function' }\n  ```\n\n  The main stream is killed because `toRequestSource` operates directly on it\n  instead of on an inner observable.\n\n  */\nexport function splitRequestSources<\n  TypePrefix extends string,\n  A extends Action<any, `${TypePrefix}.success$` | `${TypePrefix}.error$`>,\n>(\n  typePrefix: TypePrefix,\n  obs$: Observable<A>,\n): {\n  success$: Observable<\n    A extends Action<infer Payload, `${TypePrefix}.success$`>\n      ? Action<Payload, `${TypePrefix}.success$`>\n      : never\n  >;\n  error$: Observable<Action<any, `${TypePrefix}.error$`>>;\n} {\n  return splitSources(obs$, {\n    success$: `${typePrefix}.success$`,\n    error$: `${typePrefix}.error$`,\n  }) as any;\n}\n","import { Observable } from 'rxjs';\nimport { Action } from '@state-adapt/core';\nimport { toRequestSource } from './to-request-source.operator';\nimport { splitRequestSources } from './split-request-sources.function';\n\n/**\n  `getRequestSources` takes in a {@link TypePrefix} and an [Observable](https://rxjs.dev/guide/observable)\n  of values of type {@link Payload} (inferred) and returns an object with `success$` and `error$` propeties.\n\n  The `success$` property is an observable of values of type\n\n  ```ts\n  { type: `${TypePrefix}.success$`; payload: Payload }\n  ```\n\n  The `error$` property is an observable of values of type\n\n  ```ts\n  { type: `${TypePrefix}.error$`; payload: any }\n  ```\n\n  `getRequestSources` combines the functionality of {@link toRequestSource} and {@link splitRequestSources}.\n\n  Important: RxJS streams complete immediately after they error. For simple HTTP requests, this is fine.\n  But if you need to keep a stream alive, look into using {@link toRequestSource} and {@link splitRequestSources}\n  directly.\n\n  #### Example: Split an HTTP source into success$ and error$ sources\n\n  ```typescript\n  import { ajax } from 'rxjs/ajax';\n  import { getRequestSources } from '@state-adapt/rxjs';\n\n  const http$ = ajax('https://jsonplaceholder.typicode.com/todos/1');\n\n  const todoRequest = getRequestSources('todo', http$);\n\n  todoRequest.success$.subscribe(console.log);\n  // { type: 'todo.success$', payload: { ... } }\n\n  todoRequest.error$.subscribe(console.log);\n  // { type: 'todo.error$', payload: { ... } }\n  ```\n\n  #### Example: Convert any observable into success$ and error$ sources\n\n  ```typescript\n  import { interval, map } from 'rxjs';\n  import { getRequestSources } from '@state-adapt/rxjs';\n\n  const interval$ = interval(1000).pipe(\n    map(n => n !== 2 ? n : (n as any).fakeNumberMethod()),\n  );\n\n  const { success$, error$ } = getRequestSources('interval', interval$);\n\n  success$.subscribe(console.log);\n  // { type: 'interval.success$', payload: 0 }\n  // { type: 'interval.success$', payload: 1 }\n  // Will not log anymore, after error\n\n  error$.subscribe(console.log);\n  // { type: 'interval.error$', payload: 'Error: n.fakeNumberMethod is not a function' }\n  ```\n\n */\nexport function getRequestSources<TypePrefix extends string, Payload>(\n  typePrefix: TypePrefix,\n  obs$: Observable<Payload>,\n): {\n  success$: Observable<Action<Payload, `${TypePrefix}.success$`>>;\n  error$: Observable<Action<any, `${TypePrefix}.error$`>>;\n} {\n  const requestSources = obs$.pipe(toRequestSource(typePrefix));\n  return splitRequestSources(typePrefix, requestSources);\n}\n","import { Action, prefixAction } from '@state-adapt/core';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\nexport function prefixSource<\n  Type extends string = string,\n  Prefix extends string = string,\n>(prefix: Prefix) {\n  return <T>(\n    obs$: Observable<Action<T, Type>>,\n  ): Observable<Action<T, `${Prefix} ${Type}`>> =>\n    obs$.pipe(map(action => prefixAction<Prefix, Type, T>(prefix, action)));\n}\n","import { Action, getAction } from '@state-adapt/core';\nimport { Observable, of } from 'rxjs';\n\nexport type ErrorAction<Err = string> = Action<Err, 'error$'>;\nexport type ErrorActionWithReq<Req, Err = string> = Action<[Err, Req], 'error$'>;\n\n/**\n * @deprecated Use {@link getAction} instead.\n */\nexport function getHttpError<Type extends string>(\n  type: Type,\n): (err: string) => Observable<ErrorAction>;\n/**\n * @deprecated Use {@link getAction} instead.\n */\nexport function getHttpError<Type extends string, Req = any>(\n  type: Type,\n  req: Req,\n): (err: string) => Observable<ErrorActionWithReq<Req>>;\nexport function getHttpError<Type extends string, Req = any>(type: Type, req?: Req) {\n  return (err: string) =>\n    of(\n      req !== undefined\n        ? getAction(type, [err, req] as [string, Req])\n        : getAction(type, err),\n    );\n}\n","import { Observable } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\nimport { ErrorAction, ErrorActionWithReq, getHttpError } from './get-http-error.function';\nimport { catchErrorSource } from '../sources/catch-error-source.operator';\n\n/**\n * @deprecated Use {@link catchErrorSource} instead.\n */\nexport function getCatchHttpError<Type extends string>(\n  type: Type,\n): <T>(obs$: Observable<T>) => Observable<T | ErrorAction<string>>;\n/**\n * @deprecated Use {@link catchErrorSource} instead.\n */\nexport function getCatchHttpError<Type extends string, Req = any>(\n  type: Type,\n  req: Req,\n): <T>(obs$: Observable<T>) => Observable<T | ErrorActionWithReq<Req, string>>;\nexport function getCatchHttpError<Type extends string, Req = any>(type: Type, req?: Req) {\n  return <T>(obs$: Observable<T>) =>\n    req !== undefined\n      ? obs$.pipe(catchError(getHttpError(type, req))) // catchError doesn't like union types\n      : obs$.pipe(catchError(getHttpError(type)));\n}\n","import { getAction } from '@state-adapt/core';\nimport { concat, Observable, of } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport { getCatchHttpError } from './get-catch-http-error.function';\nimport { ErrorAction, ErrorActionWithReq } from './get-http-error.function';\nimport { toRequestSource } from '../sources/to-request-source.operator';\n\nexport type GetResponse<Res, Body, Err> = (res: Res) => [boolean, Body, Err];\nexport type RequestActionVoid = {\n  type: 'request$';\n  payload: void;\n};\nexport type RequestAction<Req> = {\n  type: 'request$';\n  payload: Req;\n};\nexport type SuccessAction<Body> = {\n  type: 'success$';\n  payload: Body;\n};\n\n// For TypeScript 4.7 (Angular 14) this will be unnecessary as `typeof functionName<Generic>`\n// will be supported. See https://stackoverflow.com/a/64840774/4906280\nexport interface GetHttpActions<Res, Body, Err> {\n  (http$: Observable<Res>, getResponse: GetResponse<Res, Body, Err>): Observable<\n    RequestActionVoid | SuccessAction<Body> | ErrorAction<Err | string>\n  >;\n}\nexport interface GetHttpActionsWithReq<Res, Body, Err, Req> {\n  (\n    http$: Observable<Res>,\n    getResponse: GetResponse<Res, Body, Err>,\n    req: Req,\n  ): Observable<\n    RequestAction<Req> | SuccessAction<Body> | ErrorActionWithReq<Req, Err | string>\n  >;\n}\n\n/**\n * @deprecated Use {@link toRequestSource} instead.\n */\nexport function getHttpActions<Res, Body, Err>(\n  ...[http$, getResponse]: Parameters<GetHttpActions<Res, Body, Err>>\n): ReturnType<GetHttpActions<Res, Body, Err>>;\n/**\n * @deprecated Use {@link toRequestSource} instead.\n */\nexport function getHttpActions<Res, Body, Err, Req = any>(\n  ...[http$, getResponse, req]: Parameters<GetHttpActionsWithReq<Res, Body, Err, Req>>\n): ReturnType<GetHttpActionsWithReq<Res, Body, Err, Req>>;\nexport function getHttpActions<Res, Body, Err, Req = any>(\n  ...[http$, getResponse, req]:\n    | Parameters<GetHttpActions<Res, Body, Err>>\n    | Parameters<GetHttpActionsWithReq<Res, Body, Err, Req | undefined>>\n):\n  | ReturnType<GetHttpActions<Res, Body, Err>>\n  | ReturnType<GetHttpActionsWithReq<Res, Body, Err, Req | undefined>> {\n  const x$ = concat(\n    of(getAction('request$', req)),\n    http$.pipe(\n      map(res => {\n        const [succeeded, body, err] = getResponse(res);\n        return succeeded ? getAction(`success$`, body) : getAction(`error$`, [err, req]);\n      }),\n      getCatchHttpError('error$', req),\n    ),\n  );\n  const y$ = concat(\n    of(getAction('request$')),\n    http$.pipe(\n      map(res => {\n        const [succeeded, body, err] = getResponse(res);\n        return succeeded ? getAction(`success$`, body) : getAction(`error$`, err);\n      }),\n      getCatchHttpError('error$'),\n    ),\n  );\n  const z$ = req !== undefined ? x$ : y$;\n  return z$ as any; // Something weird happens with the merging of the types, but z$ looks fine\n}\n","import { Observable } from 'rxjs';\nimport { PrefixedAction } from '@state-adapt/core';\nimport { splitSources } from '../sources/split-sources.function';\nimport {\n  GetHttpActions,\n  GetHttpActionsWithReq,\n  RequestAction,\n  RequestActionVoid,\n  SuccessAction,\n} from './get-http-actions.function';\nimport { ErrorAction, ErrorActionWithReq } from './get-http-error.function';\nimport { prefixSource } from './prefix-source.function';\nimport { splitRequestSources } from '../sources/split-request-sources.function';\n\nexport type SeparatedHttpSources<Prefix extends string, Body, Err> = {\n  request$: Observable<PrefixedAction<Prefix, RequestActionVoid>>;\n  success$: Observable<PrefixedAction<Prefix, SuccessAction<Body>>>;\n  error$: Observable<PrefixedAction<Prefix, ErrorAction<string | Err>>>;\n};\nexport type SeparatedHttpSourcesWithReq<Prefix extends string, Body, Err, Req> = {\n  request$: Observable<PrefixedAction<Prefix, RequestAction<Req>>>;\n  success$: Observable<PrefixedAction<Prefix, SuccessAction<Body>>>;\n  error$: Observable<PrefixedAction<Prefix, ErrorActionWithReq<Req, string | Err>>>;\n};\n\n/**\n * @deprecated Use {@link splitRequestSources} instead.\n */\nexport function splitHttpSources<Res, Body, Err, Prefix extends string = string>(\n  feature: Prefix,\n  httpWithSources$: ReturnType<GetHttpActions<Res, Body, Err>>,\n): SeparatedHttpSources<Prefix, Body, Err>;\n/**\n * @deprecated Use {@link splitRequestSources} instead.\n */\nexport function splitHttpSources<Res, Body, Err, Req, Prefix extends string = string>(\n  feature: Prefix,\n  httpWithSources$: ReturnType<GetHttpActionsWithReq<Res, Body, Err, Req>>,\n): SeparatedHttpSourcesWithReq<Prefix, Body, Err, Req>;\nexport function splitHttpSources<Res, Body, Err, Prefix extends string = string>(\n  feature: Prefix,\n  httpWithSources$: ReturnType<GetHttpActions<Res, Body, Err>>,\n): SeparatedHttpSources<Prefix, Body, Err> {\n  const sources = splitSources(httpWithSources$, {\n    request$: 'request$',\n    success$: 'success$',\n    error$: 'error$',\n  });\n  return {\n    request$: sources.request$.pipe(prefixSource(feature)),\n    success$: sources.success$.pipe(prefixSource(feature)),\n    error$: sources.error$.pipe(prefixSource(feature)),\n  };\n}\n","import { Observable } from 'rxjs';\nimport {\n  getHttpActions,\n  GetHttpActionsWithReq,\n  GetResponse,\n} from './get-http-actions.function';\nimport {\n  SeparatedHttpSources,\n  SeparatedHttpSourcesWithReq,\n  splitHttpSources,\n} from './split-http-sources.function';\nimport { getRequestSources } from '../sources/get-request-sources.function';\n\n/**\n * @deprecated Use {@link getRequestSources} instead.\n */\nexport function getHttpSources<Prefix extends string, Res, Body, Err>(\n  feature: Prefix,\n  http$: Observable<Res>,\n  getResponse: GetResponse<Res, Body, Err>,\n): SeparatedHttpSources<Prefix, Body, Err>;\n/**\n * @deprecated Use {@link getRequestSources} instead.\n */\nexport function getHttpSources<Prefix extends string, Res, Body, Err, Req>(\n  feature: Prefix,\n  http$: Observable<Res>,\n  getResponse: GetResponse<Res, Body, Err>,\n  req: Req,\n): SeparatedHttpSourcesWithReq<Prefix, Body, Err, Req>;\nexport function getHttpSources<Prefix extends string, Res, Body, Err, Req = any>(\n  feature: Prefix,\n  http$: Observable<Res>,\n  getResponse: GetResponse<Res, Body, Err>,\n  req?: Req,\n) {\n  const httpWithSources$ =\n    req !== undefined\n      ? getHttpActions<Res, Body, Err, Req>(http$, getResponse, req)\n      : getHttpActions<Res, Body, Err>(http$, getResponse);\n  return splitHttpSources(\n    feature,\n    httpWithSources$ as ReturnType<GetHttpActionsWithReq<Res, Body, Err, Req>>,\n  );\n}\n","import { merge, using } from 'rxjs';\n\nimport {\n  combineSelectors,\n  createSelectorsCache,\n  memoizeWithProxy,\n  Selectors,\n  SelectorsCache,\n  joinAdapters,\n} from '@state-adapt/core';\n\nimport {\n  AddNewBlock,\n  EntriesState,\n  JoinedSelectors,\n  NewBlockAdder,\n  StoreBuilder,\n  StoreEntries,\n} from './join-stores.types';\n\n/**\n  `joinStores` is a function that takes in a `StoreEntries extends { [index: string]: StoreLike }` object and returns a `StoreBuilder` function.\n  The `StoreBuilder` function can be called again and again with more selector definitions, and finally with no arguments to create a store.\n\n  `joinStores` syntax is identical to that of {@link joinAdapters} so that you can easily switch between the two.\n  The difference is that `joinStores` can only define selectors, while `joinAdapters` can define both selectors and reactions.\n\n  #### Example: Combining states from two stores\n\n  ```typescript\n  import { joinStores } from '@state-adapt/rxjs';\n  import { adapt } from '../configure-state-adapt.ts';\n\n  const store1 = adapt(1);\n  const store2 = adapt(2);\n\n  const joinedStore = joinStores({ store1, store2 })();\n\n  joinedStore.state$.subscribe(console.log);\n  // { store1: 1, store2: 2 }\n  ```\n\n  #### Example: Combining selectors from two stores\n\n  ```typescript\n  import { createAdapter } from '@state-adapt/core';\n  import { joinStores } from '@state-adapt/rxjs';\n  import { adapt } from '../configure-state-adapt.ts';\n\n  const adapter = createAdapter<number>()({\n    selectors: {\n      double: s => s * 2,\n    }\n  });\n\n  const store1 = adapt(1, adapter);\n  const store2 = adapt(2, adapter);\n\n  const joinedStore = joinStores({ store1, store2 })({\n    sum: s => s.store1Double + s.store2Double,\n  })();\n\n  joinedStore.sum$.subscribe(console.log);\n  // 6\n  ```\n */\n// state => easy\n// joined selectors => Map—Grab from each store, prefix object, do merge trick\n//\nexport function joinStores<SE extends StoreEntries>(\n  storeEntries: SE,\n): NewBlockAdder<\n  { [P in keyof EntriesState<SE>]: EntriesState<SE>[P] },\n  JoinedSelectors<SE>,\n  SE\n> {\n  // The initial selectors defined in `combineSelectors` are selecting against State.\n  // Here, we are defining the initial selectors. The result includes\n  // a selector for each piece of state. The developer only defines the 2nd+ selector group.\n\n  const namespaces = Object.keys(storeEntries) as (string & keyof SE)[];\n  const stateAdaptInstanceId = storeEntries[namespaces[0]].__.stateAdaptInstanceId;\n\n  if (\n    namespaces.some(\n      namespace =>\n        storeEntries[namespace].__.stateAdaptInstanceId !== stateAdaptInstanceId,\n    )\n  ) {\n    throw new Error(\n      'StateAdapt Error: joinStores cannot combine stores created by different StateAdapt instances.',\n    );\n  }\n\n  const joinedSelectors: Selectors<any> = {};\n  const joinedFullSelectors: Selectors<any> = {};\n\n  const selectorsCache = createSelectorsCache();\n  // const fullSelectorsCache = createSelectorsCache();\n  const getCacheOverride = (sharedChildCache: SelectorsCache) => {\n    // Use this join's cache instead of the one from future joins\n    // But register future joins' caches as children\n    // Skip if the child cache is the same as the parent cache—it's a selector from this joinStores call\n    if (sharedChildCache && sharedChildCache !== selectorsCache) {\n      selectorsCache.__children[sharedChildCache.__id] = sharedChildCache;\n    }\n    return selectorsCache;\n  };\n  // const getCacheOverride = createGetCacheOverride(selectorsCache);\n  // const getFullCacheOverride = createGetCacheOverride(fullSelectorsCache);\n\n  const getJoinedState = (state: any) => {\n    const newState = {} as any;\n    namespaces.forEach(key => {\n      newState[key] = state[key];\n    });\n    return newState;\n  };\n\n  joinedSelectors['state'] = memoizeWithProxy()(\n    'state',\n    joinedSelectors,\n    getJoinedState,\n    getCacheOverride,\n  );\n\n  joinedFullSelectors['state'] = memoizeWithProxy()(\n    'state',\n    joinedFullSelectors,\n    getJoinedState,\n    getCacheOverride,\n  );\n\n  const joinedInitialState = {} as any;\n\n  namespaces.forEach(namespace => {\n    // Already cached selectors to be made available under new names\n    // to be used in subsequent selector definitions.\n    joinedInitialState[namespace] = storeEntries[namespace].__.initialState;\n    const selectors = storeEntries[namespace].__.selectors;\n    const fullSelectors = storeEntries[namespace].__.fullSelectors;\n    for (const selectorName in fullSelectors) {\n      const selector = selectors[selectorName];\n      const fullSelector = fullSelectors[selectorName];\n      if (selectorName === 'state') {\n        joinedSelectors[namespace] = (state: any) => state[namespace];\n        joinedFullSelectors[namespace] = fullSelector;\n      } else {\n        const newSelectorName = `${namespace}${\n          selectorName.charAt(0).toUpperCase() + selectorName.substr(1)\n        }`;\n        joinedSelectors[newSelectorName] = memoizeWithProxy()(\n          newSelectorName,\n          joinedSelectors,\n          s => selector(s[namespace]), // selector is already cached\n          getCacheOverride,\n        );\n        joinedFullSelectors[newSelectorName] = fullSelector;\n      }\n    }\n  });\n\n  return addNewBlock({\n    storeEntries,\n    namespaces,\n    selectors: joinedSelectors,\n    fullSelectors: joinedFullSelectors,\n    initialState: joinedInitialState,\n    getCacheOverride,\n  });\n}\n\nfunction addNewBlock<SB extends StoreBuilder<any, any, any>>(\n  builder: SB,\n): ReturnType<AddNewBlock<any, any, any>> {\n  return <NewS extends Selectors<any>>(newS?: NewS) => {\n    if (newS)\n      return addNewBlock({\n        ...builder,\n        fullSelectors: combineSelectors<any>()<any, any, any>(\n          builder.fullSelectors,\n          newS,\n          // These new selectors will ignore the cache objects (if any) given to them\n          // Instead, attach that cache object as a child of this joined store's cache object\n          builder.getCacheOverride,\n        ),\n        selectors: combineSelectors<any>()<any, any, any>(\n          builder.selectors,\n          newS,\n          // These new selectors will ignore the cache objects (if any) given to them\n          // Instead, attach that cache object as a child of this joined store's cache object\n          builder.getCacheOverride,\n        ),\n      });\n\n    // Done\n    const { namespaces, selectors, fullSelectors, initialState, storeEntries } = builder;\n    const select = storeEntries[namespaces[0]].__.select;\n\n    const requireAllSources$ = merge(\n      ...namespaces.map(namespace => storeEntries[namespace].__.requireSources$),\n    );\n\n    const joinedStore = {\n      __: {\n        stateAdaptInstanceId: storeEntries[namespaces[0]].__.stateAdaptInstanceId,\n        selectors,\n        fullSelectors,\n        requireSources$: requireAllSources$,\n        initialState,\n        getCurrentState: () =>\n          fullSelectors.state(storeEntries[namespaces[0]].__.getGlobalState()),\n        getGlobalState: storeEntries[namespaces[0]].__.getGlobalState,\n        isActive: () =>\n          namespaces.every(namespace => storeEntries[namespace].__.isActive()),\n        select: select,\n      },\n    } as any;\n\n    for (const selectorName in fullSelectors) {\n      joinedStore[selectorName + '$'] = using(\n        () => requireAllSources$.subscribe(),\n        () => select(fullSelectors[selectorName]),\n      );\n    }\n\n    return joinedStore;\n  };\n}\n","import { isObservable } from 'rxjs';\n\nexport function isSource(thing: unknown) {\n  return Array.isArray(thing) || isObservable(thing);\n}\n","import {\n  Action,\n  BasicAdapterMethods,\n  ReactionsWithSelectors,\n  Selectors,\n  SyntheticSources,\n  WithGetState,\n  WithNoopReaction,\n  WithUpdateReaction,\n} from '@state-adapt/core';\nimport { Observable } from 'rxjs';\nimport { Sources } from '../stores/sources.type';\nimport { SmartStore } from '../stores/smart-store.interface';\n\nexport interface GlobalStoreMethods {\n  readonly value: any;\n  select: (sel: any) => Observable<any>;\n  dispatch: (action: any) => any;\n}\n\n/**\n  A store's initial state, either as a plain value or as a factory function that returns it.\n\n  A factory runs once per activation: the store calls it when it activates, holds onto that\n  value for as long as it stays active, and discards it when it deactivates. So a store that\n  is reset always goes back to what its *current* activation started from.\n  Reading state from an inactive store calls the factory for that read alone.\n\n  ```typescript\n  const name = adapt(() => localStorage.getItem('name') ?? 'John');\n  ```\n\n  @hidden\n */\nexport type InitialState<State> = State | (() => State);\n\nexport type DefaultReactions<State> = BasicAdapterMethods<State> &\n  (State extends object ? WithUpdateReaction<State> : unknown) &\n  WithNoopReaction<State>;\n\ntype SourceObject<\n  State,\n  S extends Selectors<State>,\n  R extends ReactionsWithSelectors<State, S>,\n> = Sources<State, S, DefaultReactions<State>> & Sources<State, S, R>;\n\ntype ObservableSource<State> =\n  | Observable<State>\n  | Observable<State>[]\n  | Observable<Action<State>>\n  | Observable<Action<State>>[];\n\nexport type ConcreteSourceArg<\n  State,\n  S extends Selectors<State>,\n  R extends ReactionsWithSelectors<State, S>,\n> = SourceObject<State, S, R> | ObservableSource<State>;\n\n// Extra callback keys become `never` so they fail assignability. Excess-property\n// checks do not apply to a callback return when `sources` is a union.\ntype StrictSources<ReturnedSources, Allowed> = {\n  [K in keyof ReturnedSources]?: K extends keyof Allowed ? Allowed[K] : never;\n};\n\nexport type SourceArg<\n  State,\n  S extends Selectors<State>,\n  R extends ReactionsWithSelectors<State, S>,\n  ReturnedSources = unknown,\n> =\n  | ConcreteSourceArg<State, S, R>\n  | ((\n      detachedStore: SmartStore<State, S & WithGetState<State>>,\n    ) =>\n      | StrictSources<ReturnedSources, SourceObject<State, S, R>>\n      | ObservableSource<State>);\n\nexport type InitializedReactions<\n  State,\n  // eslint-disable-next-line @typescript-eslint/ban-types -- Intentional empty generic default.\n  S extends Selectors<State> = {},\n  // eslint-disable-next-line @typescript-eslint/ban-types -- Intentional empty generic default.\n  R extends ReactionsWithSelectors<State, S> = {},\n  // eslint-disable-next-line @typescript-eslint/ban-types -- Literal `{}` preserves deferred inference and the empty branch.\n> = ({} extends R ? {} : R) & DefaultReactions<State>;\n\nexport type InitializedSmartStore<\n  State,\n  // eslint-disable-next-line @typescript-eslint/ban-types -- Intentional empty generic default.\n  S extends Selectors<State> = {},\n  // eslint-disable-next-line @typescript-eslint/ban-types -- Intentional empty generic default.\n  R extends ReactionsWithSelectors<State, S> = {},\n  // eslint-disable-next-line @typescript-eslint/ban-types -- Literal `{}` preserves deferred inference and the empty branch.\n> = SmartStore<State, ({} extends S ? {} : S) & WithGetState<State>> &\n  SyntheticSources<InitializedReactions<State, S, R>>;\n\nexport interface AdaptOptions<\n  State,\n  // eslint-disable-next-line @typescript-eslint/ban-types -- Intentional empty generic default.\n  S extends Selectors<State> = {},\n  // eslint-disable-next-line @typescript-eslint/ban-types -- Intentional empty generic default.\n  R extends ReactionsWithSelectors<State, S> = {},\n  ReturnedSources = unknown,\n> {\n  path?: string;\n  adapter?: R & { selectors?: S };\n  sources?: SourceArg<State, S, R, ReturnedSources>;\n}\n\nexport function isAdaptOptions<\n  State,\n  // eslint-disable-next-line @typescript-eslint/ban-types -- Intentional empty generic default.\n  S extends Selectors<State> = {},\n  // eslint-disable-next-line @typescript-eslint/ban-types -- Intentional empty generic default.\n  R extends ReactionsWithSelectors<State, S> = {},\n>(\n  options: AdaptOptions<State, S, R> | undefined | R,\n): options is AdaptOptions<State, S, R> {\n  return ['path', 'adapter', 'sources'].some(key => key in (options || {}));\n}\n\nexport type NotAdaptOptions = {\n  path?: never;\n  adapter?: never;\n  sources?: never;\n};\n","import { isAction } from '@state-adapt/core';\n\nexport function getPayload(value: any) {\n  // If has both type and payload, treat as Action\n  // Otherwise, it doesn't matter if we pass the whole thing as a payload because they payload isn't used.\n  // If a plain observable is emitting an object like { type: 'Something' } then it passes through\n  // If a plain observable is emitting an object like { type: 'Something', payload: 'Something' } then it expects it to match the payload type\n  return isAction(value) ? value.payload : value;\n}\n","import { InitialState } from './state-adapt.types';\n\nexport interface InitialStateGetter<State> {\n  (): State;\n  /** Starts memoization */\n  activate(): State;\n  /** Stops memoization */\n  deactivate(): void;\n}\n\n/**\n  Normalizes an {@link InitialState} argument into a function that returns the initial state.\n\n  {@link InitialStateGetter.activate} captures a value that stays stable until\n  {@link InitialStateGetter.deactivate}.\n\n  Outside of an activation there is no session for a value to belong to, so each call is an\n  independent, up-to-the-moment read rather than a cached one.\n */\nexport function createInitialStateGetter<State>(\n  initialState: InitialState<State>,\n): InitialStateGetter<State> {\n  if (typeof initialState !== 'function') {\n    const getInitialState = () => initialState as State;\n    return Object.assign(getInitialState, {\n      activate: getInitialState,\n      deactivate: () => {},\n    });\n  }\n\n  const createInitialState = initialState as () => State;\n  let active = false;\n  let state: State | undefined;\n\n  return Object.assign(() => (active ? (state as State) : createInitialState()), {\n    activate: () => {\n      active = true;\n      return (state = createInitialState());\n    },\n    deactivate: () => {\n      active = false;\n      state = undefined; // Don't hold onto unused state\n    },\n  });\n}\n","import {\n  createNoopReaction,\n  createUpdateReaction,\n  getId,\n  Adapter,\n  BasicAdapterMethods,\n  createAdapter,\n  createDestroy,\n  createInit,\n  createPatchState,\n  flatten,\n  getAction,\n  Reactions,\n  ReactionsWithSelectors,\n  Selectors,\n  SyntheticSources,\n  WithGetState,\n  createSelectorsCache,\n  getMemoizedSelector,\n  globalSelectorsCache,\n  SelectorsCache,\n} from '@state-adapt/core';\nimport { defer, merge, NEVER, Observable, Subject, using } from 'rxjs';\nimport {\n  distinctUntilChanged,\n  filter,\n  finalize,\n  share,\n  takeUntil,\n  tap,\n} from 'rxjs/operators';\nimport { isSource } from '../sources/is-source.function';\nimport { Selections } from '../stores/selections.type';\nimport { SmartStore } from '../stores/smart-store.interface';\nimport { Sources } from '../stores/sources.type';\nimport {\n  GlobalStoreMethods,\n  InitializedSmartStore,\n  AdaptOptions,\n  isAdaptOptions,\n  NotAdaptOptions,\n  InitializedReactions,\n  InitialState,\n} from './state-adapt.types';\nimport { getPayload } from '../sources/get-payload.function';\nimport {\n  createInitialStateGetter,\n  InitialStateGetter,\n} from './create-initial-state-getter.function';\n\ninterface ParsedPath {\n  path: string;\n  pathAr: string[];\n  provided: boolean;\n}\n\nconst INACTIVE = '__INACTIVE';\n\nconst filterActivated = <T>(sel$: Observable<T>) =>\n  sel$.pipe(\n    filter(a => a !== INACTIVE),\n    distinctUntilChanged(),\n  );\n\ninterface PathState {\n  lastState: any;\n  initialState: any;\n  arr: string[];\n  selectorsCache: SelectorsCache;\n}\n\ninterface PathStates {\n  [index: string]: PathState;\n}\n\ninterface UpdaterStream {\n  source$: Observable<any>;\n  requireSources$: Observable<any>;\n  reactions: {\n    path: string;\n    reaction: (...args: any[]) => any;\n  }[];\n}\n\n/**\n *\n */\nexport class StateAdapt<CommonStore extends GlobalStoreMethods = any> {\n  private pathStates: PathStates = {};\n  private updaterStreams: UpdaterStream[] = [];\n\n  private readonly stateAdaptInstanceId = Symbol('StateAdapt instance');\n\n  constructor(private commonStore: CommonStore) {}\n\n  /**\n  `adapt` creates a store that will manage state while it has subscribers.\n\n  ### Example: initialState only\n  `adapt(initialState)`\n\n  The simplest way to use `adapt` is to only pass it an initial state. `adapt` returns a store object that is ready to start managing state once it has subscribers.\n  The store object comes with `set` and `reset` methods for updating state, and a `state$` observable of the store's state.\n\n  ```typescript\n  const name = adapt('John');\n\n  name.state$.subscribe(console.log); // logs 'John'\n\n  name.set('Johnsh'); // logs 'Johnsh'\n  name.reset(); // logs 'John'\n  ```\n\n  Usually you won't manually subscribe to state like this, but you can if you want the store to immediately start managing state\n  and never clean it up.\n\n  ### Example: Using an adapter\n  `adapt(initialState, adapter)`\n\n  You can also pass in a state {@link Adapter} object to customize the state change functions and selectors.\n\n  ```typescript\n  const name = adapt('John', {\n    concat: (state, payload: string) => state + payload,\n    selectors: {\n      length: state => state.length,\n    },\n  });\n\n  name.state$.subscribe(console.log); // Logs 'John'\n  name.length$.subscribe(console.log); // Logs 4\n\n  name.concat('sh'); // logs 'Johnsh' and 6\n  name.reset(); // logs 'John' and 4\n  ```\n\n  ### Example: Using {@link AdaptOptions}\n  `adapt(initialState, { adapter, sources, path })`\n\n  You can also define an adapter, sources, and/or a state path as part of an {@link AdaptOptions} object.\n\n  Sources allow the store to declaratively react to external events rather than being commanded\n  by imperative code in callback functions.\n\n  ```typescript\n  const tick$ = interval(1000);\n\n  const clock = adapt(0, {\n    adapter: {\n      increment: state => state + 1,\n    },\n    sources: tick$, // or [tick$], or { set: tick$ }, or { set: [tick$] }\n    path: 'clock',\n  });\n\n  clock.state$.subscribe(console.log); // Logs 0, 1, 2, 3, etc.\n  ```\n\n  When a store is subscribed to, it passes the subscriptions up the its sources.\n  For example, if a store has an HTTP source, it will be triggered when the store\n  receives its first subscriber, and it will be canceled when the store loses its\n  last subscriber.\n\n  There are 4 possible ways sources can be defined:\n\n  1\\. A source can be a single source or [Observable](https://rxjs.dev/guide/observable)<`State`>. When the source emits, it triggers the store's `set` method\n  with the payload.\n\n  #### Example: Single source or observable\n\n  ```typescript\n  const nameChange$ = source<string>();\n\n  const name = adapt('John', {\n    sources: nameChange$,\n    path: 'name',\n  });\n\n  name.state$.subscribe(console.log); // Logs 'John'\n\n  nameChange$.next('Johnsh'); // logs 'Johnsh'\n  ```\n\n  2\\. A source can be an array of sources or [Observable](https://rxjs.dev/guide/observable)<`State`>. When any of the sources emit, it triggers the store's `set`\n   method with the payload.\n\n  #### Example: Array of sources or observables\n\n  ```typescript\n  const nameChange$ = source<string>();\n  const nameChange2$ = source<string>();\n\n  const name = adapt('John', {\n    sources: [nameChange$, nameChange2$],\n    path: 'name',\n  });\n\n  name.state$.subscribe(console.log); // Logs 'John'\n\n  nameChange$.next('Johnsh'); // logs 'Johnsh'\n  nameChange2$.next('Johnsh2'); // logs 'Johnsh2'\n  ```\n\n  3\\. A source can be an object with keys that match the names of the {@link Adapter} state change functions, with a corresponding source or array of\n  sources that trigger the store's reaction with the payload.\n\n  #### Example: Object of sources or observables\n\n  ```typescript\n  const nameChange$ = source<string>();\n  const nameReset$ = source<void>();\n\n  const name = adapt('John', {\n    sources: {\n      set: nameChange$,\n      reset: nameReset$,\n    },\n    path: 'name',\n  });\n\n  name.state$.subscribe(console.log); // Logs 'John'\n\n  nameChange$.next('Johnsh'); // logs 'Johnsh'\n  nameReset$.next(); // logs 'John'\n  ```\n\n  4\\. A source can be a function that takes in a detached store (doesn't chain off of sources) and returns any of the above\n  types of sources or observables.\n\n  #### Example: Function that returns an observable\n\n  ```typescript\n  const name = adapt('John', {\n    sources: store => store.state$.pipe(\n      delay(1000),\n      map(name => `${name}sh`),\n    ),\n    path: 'name',\n  });\n\n  name.state$.subscribe(console.log); // Logs 'John'\n  // logs 'Johnsh' after 1 second, then 'Johnshsh' after 2 seconds, etc.\n  ```\n\n  Defining a path alongside sources is recommended to enable easier debugging with Redux DevTools. It's easy to trace state changes\n  caused by user events, but it's much harder to trace state changes caused by spontaneous RxJS streams.\n\n  The path string specifies the location in the global store you will find the state for the store\n  (while it is being used). StateAdapt splits this string at periods `'.'` to create an object path within\n  the global store. Here are some example paths and the resulting global state objects:\n\n  #### Example: Paths and global state\n\n  ```ts\n  const count1 = adapt(0, { path: 'count.1' });\n  const count2 = adapt(0, { path: 'count.2' });\n\n  this.count1.state$.subscribe();\n  // global state:\n  // {\n  //   count: {\n  //     1: 0,\n  //   }\n  // }\n\n  this.count2.state$.subscribe();\n  // global state:\n  // {\n  //   count: {\n  //     1: 0,\n  //     2: 0,\n  //   }\n  // }\n  ```\n\n  Each store completely owns its own state. If more than one store tries to use the same path, StateAdapt will throw this error:\n\n  `Path '${path}' collides with '${existingPath}', which has already been initialized as a state path.`\n\n  This applies both to paths that are identical as well as paths that are subtrings of each other. For example, if `'featureA'`\n  is already being used by a store and then another store tried to initialize at `'featureA.number'`, that error would be thrown.\n\n  To help avoid this error, StateAdapt provides a {@link getId} function that can be used to generate unique paths:\n\n  #### Example: getId for unique paths\n\n  ```typescript\n  import { getId } from '@state-adapt/core';\n\n  const store1 = adapt(0, { path: 'number' + getId() });\n  store1.state$.subscribe();\n  const store2 = adapt(0, { path: 'number' + getId() });\n  store2.state$.subscribe();\n  // global state includes both: { number0: 0, number1: 0 }\n  ```\n\n  ### No path\n\n  If no path is provided, then the store's path defaults to the result of calling {@link getId}.\n\n  ### Example: Initial state factory\n  `adapt(() => initialState)`\n\n  You can pass a function that returns the initial state. The store calls it when it activates,\n  keeps that value for as long as it stays active, and discards it when it deactivates — so the factory runs again\n  for each activation.\n\n  This helps when initial state might be different at each time the store is being used, like with `localStorage`:\n\n  ```typescript\n  const name = adapt(() => localStorage.getItem('name') ?? 'John');\n\n  // `localStorage` hasn't been read yet\n\n  const sub1 = name.state$.subscribe(console.log); // Reads `localStorage`, then logs 'John'\n  name.set('Johnsh'); // logs 'Johnsh'\n  name.reset(); // logs 'John'\n  sub1.unsubscribe(); // The store deactivates and forgets 'John'\n\n  localStorage.setItem('name', 'Jane');\n\n  const sub2 = name.state$.subscribe(console.log); // Reads `localStorage` again, logs 'Jane'\n  name.set('Janesh'); // logs 'Janesh'\n  name.reset(); // logs 'Jane', not 'John'\n  ```\n\n  A one-off store read will call the state factory function.\n\n  ### Remember!\n\n  The store needs to have subscribers in order to start managing state,\n  and it only subscribes to sources when it has subscribers itself.\n  */\n  adapt<\n    State,\n    S extends Selectors<State>,\n    R extends ReactionsWithSelectors<State, S>,\n    R2 extends ReactionsWithSelectors<State, S>,\n    ReturnedSources = unknown,\n  >(\n    initialState: InitialState<State>,\n    second:\n      | (R & { selectors?: S } & NotAdaptOptions)\n      | AdaptOptions<State, S, R2, ReturnedSources> = {},\n    // eslint-disable-next-line @typescript-eslint/ban-types -- Literal `{}` preserves deferred generic inference.\n  ): InitializedSmartStore<State, S, {} extends R ? R2 : R> {\n    let sources: any;\n\n    // Initialize parameters\n    const getInitialState = createInitialStateGetter(initialState);\n    const options = isAdaptOptions(second) ? second : undefined;\n\n    const pathObj = this.parsePath(options?.path);\n    const path = pathObj.path;\n\n    // const stackItems = {\n    //   Error: false,\n    //   'at StateAdapt.adapt': false,\n    //   'at adapt': false,\n    //   'at Object.adaptInjectableFactory [as factory]': 'adaptInjectableFactory',\n    // } as const;\n\n    // const stackLines = new Error().stack\n    //   ?.split('\\n')\n    //   .map(line => line.trim().split(' (http')[0]);\n\n    // const interestingLine = stackLines?.find(\n    //   line => (stackItems[line as keyof typeof stackItems] as any) !== false,\n    // );\n    // const stackPath =\n    //   stackItems[interestingLine as keyof typeof stackItems] || interestingLine;\n    // console.log(interestingLine);\n    // const path =\n    //   options?.path ||\n    //   this.adapt.caller.toString().replace(/\\./g, '_') + getId().toString();\n\n    const adapterArg = options?.adapter || second;\n    const adapter = adapterArg\n      ? createAdapter<State>()(adapterArg as R & { selectors?: S })\n      : createAdapter<State>()({});\n    (adapter as any).noop = createNoopReaction();\n    // A factory can't be inspected without calling it, which would defeat its laziness.\n    // `update` is only exposed on the store's type when `State extends object`, so defining\n    // it for every factory can't be reached by type-checked code that returns other state.\n    const stateSupportsUpdate =\n      typeof initialState === 'function' ||\n      (typeof initialState === 'object' &&\n        !Array.isArray(initialState) &&\n        initialState !== null);\n    if (!(adapter as any).update && stateSupportsUpdate) {\n      (adapter as any).update = createUpdateReaction();\n    }\n\n    const sourcesArg = options?.sources;\n\n    const sourcesDefined =\n      typeof sourcesArg === 'function'\n        ? sourcesArg(this.watch(path, adapter) as any)\n        : sourcesArg || ({} as any);\n    sources = isSource(sourcesDefined) // Single source or array\n      ? { set: sourcesDefined }\n      : sourcesDefined;\n    sources = sources as Sources<State, S, R & BasicAdapterMethods<State>>;\n\n    // Parameters are all defined\n\n    const [requireSources$, syntheticSources] = this.getRequire<\n      State,\n      S,\n      R,\n      SyntheticSources<R>\n    >(adapter as any, pathObj, sources, getInitialState);\n\n    const getSelectorsCache = this.getSelectorsCacheFactory(path);\n    const getState = this.getStateSelector<State>(pathObj.pathAr, getInitialState);\n    const getStateSelector = getMemoizedSelector(path, getState, () =>\n      this.getGlobalSelectorsCache(),\n    ); // all state selectors go in global cache\n    const { fullSelectors, selections, selectors } = this.getSelections<State, S>(\n      adapter.selectors as unknown as S,\n      getStateSelector as (state: any) => State,\n      requireSources$,\n      getSelectorsCache,\n    );\n\n    return {\n      ...(syntheticSources as SyntheticSources<InitializedReactions<State, S, R>>),\n      ...selections,\n      __: {\n        stateAdaptInstanceId: this.stateAdaptInstanceId,\n        requireSources$,\n        selectors,\n        fullSelectors,\n        // added for React integration, which requires immediate access to initial state before subscribing.\n        // A getter so an initial state factory isn't called until something reads it: during an activation\n        // that's the state the store started from, and outside of one it's a fresh read.\n        get initialState() {\n          return getInitialState();\n        },\n        path,\n        getCurrentState: () =>\n          this.pathStates[path] ? this.pathStates[path].lastState : getInitialState(), // With signals, we use default state when inactive\n        getGlobalState: () => this.commonStore.value,\n        isActive: () => this.isPathActive(path),\n        select: (sel: any) => this.commonStore.select(sel),\n      },\n    } as any;\n  }\n\n  /**\n  `watch` returns a detached store (doesn't chain off of sources). This allows you to watch state without affecting anything.\n  It takes the path of the state you are interested in and, optionally, the adapter whose selectors you want to use.\n\n  ```tsx\n  watch(path, adapter)\n  ```\n\n  path — Object path in Redux Devtools\n\n  adapter — Optional object with state change functions and selectors. When omitted, `watch` uses the base adapter.\n\n  ### Usage\n\n  `watch` enables accessing state without subscribing to sources. For example, if your adapter manages the loading state\n  for an HTTP request and you need to know if the request is loading before the user is interested in the data,\n  `watch` can give you access to it without triggering the request.\n\n  #### Example: Accessing loading state\n\n  ```tsx\n  watch('data', httpAdapter).loading$.subscribe(console.log);\n  ```\n   */\n  watch<\n    State = any,\n    // eslint-disable-next-line @typescript-eslint/ban-types -- Intentional empty generic default.\n    S extends Selectors<State> = {},\n    // eslint-disable-next-line @typescript-eslint/ban-types -- Intentional empty generic default.\n    R extends ReactionsWithSelectors<State, S> = {},\n  >(\n    path: string,\n    adapter?: Adapter<State, S, R & BasicAdapterMethods<State>>,\n  ): SmartStore<State, S & WithGetState<State>> {\n    const adapterSelectors = adapter?.selectors || createAdapter<State>()({}).selectors;\n    const onlyWhenActiveSelectors = { ...adapterSelectors } as S;\n    // Replace with selectors that short-circuit when INACTIVE\n    for (const key in onlyWhenActiveSelectors) {\n      const originalSelector = onlyWhenActiveSelectors[key];\n      (onlyWhenActiveSelectors as any)[key] = (state: State, cache: SelectorsCache) =>\n        this.isPathActive(path) ? (originalSelector as any)(state, cache) : INACTIVE;\n    }\n\n    const getSelectorsCache = this.getSelectorsCacheFactory(path);\n    const getState = this.getStateSelector<State>(path.split('.'));\n    const getStateWhenActive = (state: any) =>\n      this.isPathActive(path) ? getState(state) : INACTIVE;\n    const getStateSelector = getMemoizedSelector(path, getStateWhenActive, () =>\n      this.getGlobalSelectorsCache(),\n    ); // all state selectors go in global cache\n    const requireSources$ = NEVER;\n    const { fullSelectors, selections, selectors } = this.getSelections<State, S>(\n      onlyWhenActiveSelectors,\n      getStateSelector as (state: any) => State,\n      requireSources$,\n      getSelectorsCache,\n    );\n\n    const detachedStore = {\n      ...selections,\n      __: {\n        stateAdaptInstanceId: this.stateAdaptInstanceId,\n        requireSources$: requireSources$,\n        fullSelectors: fullSelectors,\n        selectors,\n        initialState: undefined as unknown as State, // added for React integration, which requires immediate access to initial state before subscribing,\n        path,\n        getCurrentState: () => this.pathStates[path]?.lastState, // For signals - not needed here, but to satisfy type\n        getGlobalState: () => this.commonStore.value,\n        isActive: () => this.isPathActive(path),\n        select: (sel: any) => filterActivated(this.commonStore.select(sel)),\n      },\n    };\n\n    for (const key in selections) {\n      (detachedStore as any)[key] = filterActivated((detachedStore as any)[key]);\n    }\n\n    return detachedStore;\n  }\n\n  private parsePath(path?: string): ParsedPath {\n    if (path) {\n      return { path, pathAr: path.split('.'), provided: true };\n    }\n    const defaultPath = getId().toString();\n    return {\n      path: defaultPath,\n      pathAr: [defaultPath],\n      provided: false,\n    };\n  }\n\n  private getRequire<\n    State,\n    S extends Selectors<State>,\n    R extends ReactionsWithSelectors<State, S>,\n    RSS extends SyntheticSources<R>,\n  >(\n    reactions: Reactions<State>,\n    { path, pathAr, provided: pathProvided }: ParsedPath,\n    sources: Sources<State, S, R>,\n    getInitialState: InitialStateGetter<State>,\n  ): [Observable<any>, RSS] {\n    const reactionEntries = Object.entries(reactions);\n    const allSourcesWithReactions = flatten(\n      reactionEntries\n        .filter(([name]) => name !== 'selectors')\n        .map(([reactionName, reaction]) => {\n          const reactionSource = sources[reactionName] || [];\n          const reactionSources = Array.isArray(reactionSource)\n            ? reactionSource\n            : [reactionSource];\n          return reactionSources.map(source$ => ({ source$, reaction }));\n        }),\n    );\n\n    const allUpdatesFromSources$ = allSourcesWithReactions.map(\n      ({ source$, reaction }) => {\n        // (parameter) source$: Observable<Action<SecondParameterOrAny<Parameters<R[string]>>, string>>\n        const s$ = source$ as Observable<any>;\n        // Source-grouped updates:\n        return defer(() => {\n          const updaterStream = this.getSourceUpdateStream(source$);\n          const requireSources$ = updaterStream\n            ? updaterStream.requireSources$\n            : s$.pipe(\n                tap(action => {\n                  const payload = getPayload(action);\n                  const updates = this.getAllSourceUpdates(source$, payload);\n                  const type = payload === action ? (source$ as any).type : action.type;\n                  this.commonStore.dispatch(createPatchState(action, updates, type));\n                }),\n                finalize(() => {\n                  this.updaterStreams.splice(\n                    this.updaterStreams.findIndex(\n                      ({ source$: updaterSource$ }) => source$ === updaterSource$,\n                    ),\n                    1,\n                  );\n                }),\n                share(),\n              );\n          if (!updaterStream) {\n            this.updaterStreams.push({\n              source$,\n              requireSources$,\n              reactions: [],\n            });\n          }\n          // Now there is definitely an update stream for this source, so push this reaction onto it\n          const updateStream = this.getSourceUpdateStream(source$);\n          updateStream?.reactions.push({ path, reaction });\n          return requireSources$;\n        });\n      },\n    );\n\n    const contextDestroyed$ = new Subject();\n    const stateDestroyed$ = new Subject();\n\n    const requireState$ = defer(() => {\n      // Runs first upon subscription.\n      // If any of the sources emits immediately, this needs to have been set up first.\n\n      if (pathProvided) {\n        const colllisionPath = this.getPathCollisions(path);\n        if (colllisionPath) {\n          throw this.getPathCollisionError(path, colllisionPath);\n        }\n      }\n      const selectorsCache = this.createSelectorsCache(path);\n      const initialState = getInitialState.activate();\n      this.pathStates[path] = {\n        lastState: initialState,\n        initialState,\n        arr: pathAr,\n        selectorsCache,\n      };\n      this.commonStore.dispatch(createInit(path, initialState));\n      return NEVER;\n    }).pipe(\n      takeUntil(contextDestroyed$),\n      finalize(() => {\n        // Pull the rug - we can't have sources updating destroyed state\n        stateDestroyed$.next();\n        // Runs Last to clean up the store:\n        delete this.pathStates[path];\n        getInitialState.deactivate();\n        this.destroySelectorsCache(path);\n        this.commonStore.dispatch(createDestroy(path));\n      }),\n      share(),\n    );\n\n    const requireSources$ = merge(...allUpdatesFromSources$, NEVER).pipe(\n      takeUntil(contextDestroyed$),\n      takeUntil(stateDestroyed$),\n      finalize(() => {\n        // Runs next to last to remove state from source updates:\n        allSourcesWithReactions.forEach(({ source$ }) => {\n          const updateStream = this.getSourceUpdateStream(source$);\n          const updateReactions = updateStream?.reactions || [];\n          updateReactions.splice(\n            updateReactions.findIndex(({ path: reactionPath }) => reactionPath === path),\n            1,\n          );\n        });\n      }),\n      share(),\n    );\n\n    const require$ = merge(requireState$, requireSources$).pipe(share());\n\n    const syntheticSources = reactionEntries.reduce((acc, [reactionName, reaction]) => {\n      return {\n        ...acc,\n        [reactionName]: (payload: any) => {\n          const update = this.getUpdate(path, reaction, payload);\n          const action = getAction(`${path} ${reactionName}`, payload);\n          this.commonStore.dispatch(createPatchState(action, [update]));\n        },\n      };\n    }, {} as RSS);\n\n    return [require$, syntheticSources];\n  }\n\n  private getPathCollisions(path: string) {\n    return Object.keys(this.pathStates).find(\n      existingPath =>\n        path === existingPath ||\n        existingPath + '.' === path.substr(0, existingPath.length + 1) ||\n        path + '.' === existingPath.substr(0, path.length + 1),\n    );\n  }\n\n  private getPathCollisionError(path: string, existingPath: string) {\n    return new Error(\n      `Path '${path}' collides with '${existingPath}', which has already been initialized as a state path.`,\n    );\n  }\n\n  private getSourceUpdateStream(searchSource$: Observable<any>) {\n    return this.updaterStreams.find(\n      ({ source$ }) => searchSource$ === source$,\n    ) as UpdaterStream;\n  }\n\n  private getAllSourceUpdates(source$: Observable<any>, payload: any): [string[], any][] {\n    return this.getSourceUpdateStream(source$).reactions.map(({ path, reaction }) =>\n      this.getUpdate(path, reaction, payload),\n    );\n  }\n\n  private getUpdate(\n    path: string,\n    reaction: (...args: any[]) => any,\n    payload: any,\n  ): [string[], any] {\n    const pathState = this.pathStates[path];\n    if (pathState === undefined) {\n      throw `Cannot apply update before store \"${path}\" is initialized.`;\n    }\n    const { lastState, initialState, arr, selectorsCache } = pathState;\n    const newState = reaction(lastState, payload, initialState, selectorsCache);\n    pathState.lastState = newState;\n    return [arr, newState];\n  }\n\n  private getStateSelector<State>(\n    pathAr: string[],\n    getInitialState?: () => State,\n  ): ({ adapt }: { adapt: any }) => State {\n    return ({ adapt }) => {\n      const pathState = pathAr.reduce((state, segment) => state?.[segment], adapt);\n      return pathState === undefined ? getInitialState?.() : pathState;\n    };\n  }\n\n  private getGlobalSelectorsCache() {\n    return globalSelectorsCache;\n  }\n\n  private getSelectorsCacheFactory(path: string) {\n    return () => globalSelectorsCache.__children[path];\n  }\n\n  private createSelectorsCache(path: string) {\n    return (globalSelectorsCache.__children[path] = createSelectorsCache());\n  }\n\n  private destroySelectorsCache(path: string) {\n    delete globalSelectorsCache.__children[path];\n  }\n\n  private getSelections<State, S extends Selectors<State>>(\n    selectors: S,\n    getState: (state: any) => State, // uses global cache\n    requireSources$: Observable<any>,\n    getSelectorsCache: () => SelectorsCache,\n  ): {\n    fullSelectors: S & { state: () => State };\n    selectors: S & { state: () => State };\n    selections: Selections<State, S>;\n  } {\n    const getUsing = <T>(selection$: Observable<T>) =>\n      using(\n        () => requireSources$.subscribe(),\n        () => selection$,\n      );\n\n    const selections = {\n      fullSelectors: { state: getState },\n      selections: {\n        state$: getUsing(this.commonStore.select(getState)),\n      },\n      selectors: { state: (pathState: any) => pathState },\n    } as {\n      fullSelectors: S & { state: () => State };\n      selections: Selections<State, S>;\n      selectors: S & { state: () => State };\n    };\n    for (const key in selectors) {\n      const fullSelector = (state: any, sharedChildCache: SelectorsCache) => {\n        const pathState = getState(state);\n        const cache = getSelectorsCache();\n        if (cache && sharedChildCache) {\n          cache && (cache.__children[sharedChildCache.__id] = sharedChildCache);\n        }\n        return (selectors[key] as any)(pathState, cache);\n      };\n\n      (selections as any).selectors[key] = (pathState: any) =>\n        (selectors[key] as any)(pathState, getSelectorsCache());\n      (selections.fullSelectors as any)[key] = fullSelector;\n      (selections.selections as any)[key + '$'] = getUsing(\n        this.commonStore.select(fullSelector),\n      );\n    }\n\n    return selections;\n  }\n\n  private isPathActive(path: string) {\n    return !!this.pathStates[path];\n  }\n}\n","import { BehaviorSubject } from 'rxjs';\nimport { distinctUntilChanged, map } from 'rxjs/operators';\n\nexport interface GlobalStore<State, AnyAction> {\n  subscribe: (observer: any) => void;\n  getState: () => State;\n  dispatch: (action: AnyAction) => void;\n}\n\nexport class ObservableStore<\n  State,\n  AnyAction,\n  Action extends AnyAction,\n  Store extends GlobalStore<State, AnyAction>,\n> extends BehaviorSubject<State> {\n  store: Store;\n  actionQueue = [] as any[]; // First is currently dispatching\n\n  constructor(store: Store) {\n    super(store.getState());\n    this.store = store;\n    store.subscribe(() => this.next(store.getState()));\n  }\n\n  select<T>(sel: (s: State) => T) {\n    return this.pipe(\n      map(state => sel(state)),\n      distinctUntilChanged(),\n    );\n  }\n\n  dispatch(action: Action) {\n    if (!this.actionQueue[0]) {\n      this.actionQueue.push(action);\n      this.dispatchNext();\n    } else {\n      this.actionQueue.push(action);\n    }\n  }\n\n  dispatchNext() {\n    if (this.actionQueue[0]) {\n      this.store.dispatch(this.actionQueue[0]);\n      this.actionQueue.shift();\n      this.dispatchNext();\n    }\n  }\n}\n","import { GlobalStore } from './global-store/observable-store';\n\nexport function createGlobalStore(\n  reducer: any,\n  preloadedState: any,\n  enhancer?: any,\n): GlobalStore<any, any> {\n  let state = preloadedState ?? undefined;\n  const listeners: any[] = [];\n\n  if (enhancer) {\n    return enhancer(createGlobalStore)(reducer, state);\n  }\n\n  const dispatch = (action: any) => {\n    state = reducer(state, action);\n    listeners.forEach(l => l(state));\n  };\n\n  dispatch({ type: '@@redux/INIT' + Math.random() });\n\n  return {\n    getState: () => state,\n    dispatch,\n    subscribe: (cb: () => void) => {\n      listeners.push(cb);\n      return () => listeners.splice(listeners.indexOf(cb), 1);\n    },\n  };\n}\n","import {\n  actionSanitizer,\n  adaptReducer,\n  createAdaptNestedReducer,\n  globalSelectorsOptions,\n  stateSanitizer,\n} from '@state-adapt/core';\nimport { StateAdapt } from './state-adapt';\nimport { GlobalStore, ObservableStore } from './observable-store';\nimport { createGlobalStore } from '../create-global-store.function';\nimport { ConfigureStateAdaptOptions } from './configure-state-adapt.options';\n\nfunction isStoreOptions(options: ConfigureStateAdaptOptions): options is { store: any } {\n  return (options as any).store !== undefined;\n}\n\n/**\n * @internal\n */\nexport type ConfiguredStateAdapt<\n  Store extends GlobalStore<any, any> = GlobalStore<any, any>,\n> = Pick<StateAdapt<any>, 'adapt' | 'watch'> & Pick<Store, never>;\n\n/**\n  `configureStateAdapt` takes in a {@link ConfigureStateAdaptOptions} object and returns a new instance of {@link StateAdapt}.\n\n  ### Example: Standalone with default options\n\n  ```ts\n  import { actionSanitizer, stateSanitizer } from '@state-adapt/core';\n  import { configureStateAdapt } from '@state-adapt/rxjs';\n\n  export const stateAdapt = configureStateAdapt();\n\n  export const { adapt, watch } = stateAdapt;\n  ```\n\n  ### Example: Standalone\n\n  ```ts\n  import { actionSanitizer, stateSanitizer } from '@state-adapt/core';\n  import { configureStateAdapt } from '@state-adapt/rxjs';\n\n  export const stateAdapt = configureStateAdapt({\n    devtools: (window as any)?.__REDUX_DEVTOOLS_EXTENSION__?.({\n      actionSanitizer,\n      stateSanitizer,\n    }),\n    showSelectors: false,\n  });\n\n  export const { adapt, watch } = stateAdapt;\n  ```\n\n  ### Example: With another store\n\n  ```ts\n  import { configureStore } from '@reduxjs/toolkit'; // or any other Redux-like store\n  import { configureStateAdapt } from '@state-adapt/rxjs';\n  import { reducer } from './reducer';\n\n  const store = configureStore({ reducer });\n\n  export const stateAdapt = configureStateAdapt({ store });\n\n  export const { adapt, watch } = stateAdapt;\n  ```\n*/\nexport function configureStateAdapt<\n  Store extends GlobalStore<any, any> = GlobalStore<any, any>,\n>(\n  options: ConfigureStateAdaptOptions<Store> = {\n    devtools:\n      typeof window !== 'undefined' &&\n      (window as any).__REDUX_DEVTOOLS_EXTENSION__?.({\n        actionSanitizer,\n        stateSanitizer,\n      }),\n  },\n): Pick<StateAdapt<any>, 'adapt' | 'watch'> {\n  globalSelectorsOptions.devtools = options.showSelectors ?? true;\n  const store = isStoreOptions(options)\n    ? options.store\n    : createGlobalStore(\n        createAdaptNestedReducer(adaptReducer),\n        options.preloadedState,\n        options.devtools,\n      );\n\n  const stateAdapt = new StateAdapt(new ObservableStore(store));\n  return {\n    adapt: stateAdapt.adapt.bind(stateAdapt),\n    watch: stateAdapt.watch.bind(stateAdapt),\n    ['commonStore' as never]: (stateAdapt as any).commonStore,\n    ['stateAdaptInstanceId' as never]: (stateAdapt as any).stateAdaptInstanceId,\n  };\n}\n","import { Observable } from 'rxjs';\nimport { map, pairwise, startWith } from 'rxjs/operators';\n\nexport function mapEachWithEffect<T, U>(\n  input$: Observable<T[]>,\n  fn: (value: T) => [U, () => void] | [U],\n): Observable<U[]> {\n  const cache = new Map<T, [U, () => void] | [U]>();\n\n  return input$.pipe(\n    startWith([] as T[]),\n    pairwise(),\n    map(([prev, next]) => {\n      prev.forEach(value => {\n        if (!next.includes(value)) {\n          const [, destroy] = cache.get(value)!;\n          destroy?.();\n          cache.delete(value);\n        }\n      });\n\n      return next.map(value => {\n        if (!cache.has(value)) {\n          const results = fn(value);\n          cache.set(value, results);\n          return results[0];\n        } else {\n          return cache.get(value)![0];\n        }\n      });\n    }),\n  );\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAQA,MAAM,kBAAkB,GAAuB,OAAO;AAEtD;;AAEG;AACG,MAAO,MAAU,SAAQ,kBAA6B,CAAA;IAG1D,WAAY,CAAA,IAAI,GAAG,EAAE,EAAA;AACnB,QAAA,KAAK,EAAE;AACP,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI;;AAElB,IAAA,IAAI,CAAC,OAAU,EAAA;AACb,QAAA,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC;;AAElE;;ACrBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCG;AACa,SAAA,MAAM,CAAI,IAAI,GAAG,EAAE,EAAA;AACjC,IAAA,MAAM,OAAO,GAAG,IAAI,OAAO,EAAK;IAEhC,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