atom.io 0.6.7 → 0.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +27 -17
- package/dist/index.d.ts +27 -17
- package/dist/index.js +28 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -22
- package/dist/index.mjs.map +1 -1
- package/introspection/dist/index.d.mts +14 -15
- package/introspection/dist/index.d.ts +14 -15
- package/introspection/dist/index.js +2 -2
- package/introspection/dist/index.js.map +1 -1
- package/introspection/dist/index.mjs +2 -2
- package/introspection/dist/index.mjs.map +1 -1
- package/json/dist/index.d.mts +5 -7
- package/json/dist/index.d.ts +5 -7
- package/json/dist/index.js.map +1 -1
- package/json/dist/index.mjs.map +1 -1
- package/package.json +15 -7
- package/react-devtools/dist/index.css +9 -1
- package/react-devtools/dist/index.css.map +1 -1
- package/react-devtools/dist/index.d.mts +14 -15
- package/react-devtools/dist/index.d.ts +14 -15
- package/react-devtools/dist/index.js +769 -249
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs +752 -227
- package/react-devtools/dist/index.mjs.map +1 -1
- package/realtime/dist/index.d.mts +6 -8
- package/realtime/dist/index.d.ts +6 -8
- package/realtime/dist/index.js +0 -1
- package/realtime/dist/index.js.map +1 -1
- package/realtime/dist/index.mjs +0 -1
- package/realtime/dist/index.mjs.map +1 -1
- package/realtime-react/dist/index.d.mts +11 -13
- package/realtime-react/dist/index.d.ts +11 -13
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/dist/index.mjs.map +1 -1
- package/src/atom.ts +4 -4
- package/src/index.ts +1 -1
- package/src/internal/families-internal.ts +23 -20
- package/src/internal/index.ts +1 -1
- package/src/internal/selector/create-read-write-selector.ts +3 -1
- package/src/internal/selector/create-readonly-selector.ts +3 -1
- package/src/internal/time-travel-internal.ts +4 -4
- package/src/internal/timeline/add-atom-to-timeline.ts +2 -2
- package/src/internal/timeline-internal.ts +2 -2
- package/src/introspection/attach-timeline-family.ts +1 -1
- package/src/json/select-json.ts +1 -1
- package/src/react-devtools/StateEditor.tsx +5 -1
- package/src/react-devtools/StateIndex.tsx +4 -1
- package/src/react-devtools/devtools.scss +0 -1
- package/src/realtime/hook-composition/expose-family.ts +2 -2
- package/src/realtime/hook-composition/expose-single.ts +1 -1
- package/src/realtime/hook-composition/receive-state.ts +1 -1
- package/src/realtime-react/realtime-hooks.ts +4 -4
- package/src/realtime-react/use-pull-family-member.ts +2 -2
- package/src/realtime-react/use-pull-family.ts +2 -2
- package/src/realtime-react/use-pull.ts +3 -1
- package/src/realtime-react/use-push.ts +3 -1
- package/src/selector.ts +14 -12
- package/src/subscribe.ts +1 -1
- package/src/tracker/index.ts +3 -0
- package/src/tracker/tracker.ts +61 -0
- package/src/web-effects/storage.ts +1 -1
- package/src/internal/subject.ts +0 -24
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../anvl/src/string/capitalize.ts","../src/internal/index.ts","../src/internal/get.ts","../src/internal/is-default.ts","../../anvl/src/function/index.ts","../../anvl/src/join/core-relation-data.ts","../../anvl/src/array/venn.ts","../../anvl/src/array/index.ts","../../anvl/src/object/refinement.ts","../../anvl/src/object/access.ts","../../anvl/src/object/entries.ts","../../anvl/src/object/mapObject.ts","../../anvl/src/nullish/index.ts","../../anvl/src/refinement/index.ts","../../anvl/src/join/get-related-ids.ts","../../anvl/src/join/make-json-interface.ts","../../anvl/src/join/relation-contents.ts","../../anvl/src/join/relation-record.ts","../../anvl/src/join/remove-relation.ts","../../anvl/src/object/index.ts","../../anvl/src/string/split.ts","../../anvl/src/join/set-relation.ts","../../anvl/src/join/index.ts","../src/internal/store.ts","../src/internal/operation.ts","../src/internal/transaction-internal.ts","../src/internal/atom-internal.ts","../../anvl/src/json/index.ts","../src/internal/families-internal.ts","../src/internal/selector/create-read-write-selector.ts","../src/internal/selector/lookup-selector-sources.ts","../src/internal/selector/trace-selector-atoms.ts","../src/internal/selector/update-selector-atoms.ts","../src/internal/set.ts","../src/internal/selector/register-selector.ts","../src/internal/selector/create-readonly-selector.ts","../src/internal/selector-internal.ts","../src/internal/subject.ts","../src/internal/subscribe-internal.ts","../src/internal/time-travel-internal.ts","../src/internal/timeline/add-atom-to-timeline.ts","../src/internal/timeline-internal.ts","../src/internal/transaction/abort-transaction.ts","../src/internal/transaction/apply-transaction.ts","../src/internal/transaction/build-transaction.ts","../src/internal/transaction/redo-transaction.ts","../src/internal/transaction/undo-transaction.ts","../src/internal/transaction/index.ts","../src/atom.ts","../src/logger.ts","../src/selector.ts","../src/silo.ts","../src/subscribe.ts","../src/timeline.ts","../src/transaction.ts","../src/index.ts"],"sourcesContent":["export const capitalize = (str: string): string =>\n\tstr[0].toUpperCase() + str.slice(1)\n","export * from \"./atom-internal\"\nexport * from \"./families-internal\"\nexport * from \"./get\"\nexport * from \"./is-default\"\nexport * from \"./operation\"\nexport * from \"./selector-internal\"\nexport * from \"./selector\"\nexport * from \"./set\"\nexport * from \"./store\"\nexport * from \"./subject\"\nexport * from \"./subscribe-internal\"\nexport * from \"./time-travel-internal\"\nexport * from \"./timeline-internal\"\nexport * from \"./transaction-internal\"\nexport * from \"./transaction\"\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type {\n\tAtom,\n\tReadonlySelector,\n\tSelector,\n\tStore,\n\tTimeline,\n\tTransaction,\n} from \".\"\nimport { target, isValueCached, readCachedValue, IMPLICIT } from \".\"\nimport type {\n\tAtomToken,\n\tReadonlySelectorToken,\n\tSelectorToken,\n\tStateToken,\n\tTimelineToken,\n\tTransactionToken,\n} from \"..\"\n\nexport const computeSelectorState = <T>(\n\tselector: ReadonlySelector<T> | Selector<T>,\n): T => selector.get()\n\nexport function lookup(\n\tkey: string,\n\tstore: Store,\n): AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown> {\n\tconst core = target(store)\n\tconst type = core.atoms.has(key)\n\t\t? `atom`\n\t\t: core.selectors.has(key)\n\t\t? `selector`\n\t\t: `readonly_selector`\n\treturn { key, type } as any\n}\n\nexport function withdraw<T>(token: AtomToken<T>, store: Store): Atom<T> | null\nexport function withdraw<T>(\n\ttoken: SelectorToken<T>,\n\tstore: Store,\n): Selector<T> | null\nexport function withdraw<T>(\n\ttoken: StateToken<T>,\n\tstore: Store,\n): Atom<T> | Selector<T> | null\nexport function withdraw<T>(\n\ttoken: ReadonlySelectorToken<T>,\n\tstore: Store,\n): ReadonlySelector<T> | null\nexport function withdraw<T>(\n\ttoken: TransactionToken<T>,\n\tstore: Store,\n): Transaction<T extends ƒn ? T : never> | null\nexport function withdraw<T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\tstore: Store,\n): Atom<T> | ReadonlySelector<T> | Selector<T> | null\nexport function withdraw<T>(token: TimelineToken, store: Store): Timeline | null\nexport function withdraw<T>(\n\ttoken:\n\t\t| ReadonlySelectorToken<T>\n\t\t| StateToken<T>\n\t\t| TimelineToken\n\t\t| TransactionToken<T>,\n\tstore: Store,\n):\n\t| Atom<T>\n\t| ReadonlySelector<T>\n\t| Selector<T>\n\t| Timeline\n\t| Transaction<T extends ƒn ? T : never>\n\t| null {\n\tconst core = target(store)\n\treturn (\n\t\tcore.atoms.get(token.key) ??\n\t\tcore.selectors.get(token.key) ??\n\t\tcore.readonlySelectors.get(token.key) ??\n\t\tcore.transactions.get(token.key) ??\n\t\tcore.timelines.get(token.key) ??\n\t\tnull\n\t)\n}\n\nexport function deposit<T>(state: Atom<T>): AtomToken<T>\nexport function deposit<T>(state: Selector<T>): SelectorToken<T>\nexport function deposit<T>(state: Atom<T> | Selector<T>): StateToken<T>\nexport function deposit<T>(state: ReadonlySelector<T>): ReadonlySelectorToken<T>\nexport function deposit<T>(\n\tstate: Transaction<T extends ƒn ? T : never>,\n): TransactionToken<T>\nexport function deposit<T>(\n\tstate: Atom<T> | ReadonlySelector<T> | Selector<T>,\n): ReadonlySelectorToken<T> | StateToken<T>\nexport function deposit<T>(\n\tstate:\n\t\t| Atom<T>\n\t\t| ReadonlySelector<T>\n\t\t| Selector<T>\n\t\t| Transaction<T extends ƒn ? T : never>,\n):\n\t| AtomToken<T>\n\t| ReadonlySelectorToken<T>\n\t| SelectorToken<T>\n\t| TransactionToken<T> {\n\treturn {\n\t\tkey: state.key,\n\t\ttype: state.type,\n\t\t...(`family` in state && { family: state.family }),\n\t} as any\n}\n\nexport const getState__INTERNAL = <T>(\n\tstate: Atom<T> | ReadonlySelector<T> | Selector<T>,\n\tstore: Store = IMPLICIT.STORE,\n): T => {\n\tif (isValueCached(state.key, store)) {\n\t\tstore.config.logger?.info(`>> read \"${state.key}\"`)\n\t\treturn readCachedValue(state.key, store)\n\t}\n\tif (state.type !== `atom`) {\n\t\tstore.config.logger?.info(`-> calc \"${state.key}\"`)\n\t\treturn computeSelectorState(state)\n\t}\n\tstore.config.logger?.error(\n\t\t`Attempted to get atom \"${state.key}\", which was never initialized in store \"${store.config.name}\".`,\n\t)\n\treturn state.default\n}\n","import type { Store } from \".\"\nimport { target, IMPLICIT, traceAllSelectorAtoms } from \".\"\n\nexport const isAtomDefault = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): boolean => {\n\tconst core = target(store)\n\treturn core.atomsThatAreDefault.has(key)\n}\n\nexport const markAtomAsDefault = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.atomsThatAreDefault = new Set(core.atomsThatAreDefault).add(key)\n}\n\nexport const markAtomAsNotDefault = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.atomsThatAreDefault = new Set(target(store).atomsThatAreDefault)\n\tcore.atomsThatAreDefault.delete(key)\n}\n\nexport const isSelectorDefault = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): boolean => {\n\tconst roots = traceAllSelectorAtoms(key, store)\n\treturn roots.every((root) => isAtomDefault(root.key, store))\n}\n","import type { Refinement } from \"fp-ts/Refinement\"\nexport * from \"./curry\"\n\nexport type ƒn = (...parameters: any[]) => any\n\nexport const doNothing = (): void => undefined\n\nexport const become =\n\t<T>(nextVersionOfThing: Modifier<T> | T) =>\n\t(originalThing: T | (() => T)): T =>\n\t\tnextVersionOfThing instanceof Function\n\t\t\t? nextVersionOfThing(\n\t\t\t\t\toriginalThing instanceof Function ? originalThing() : originalThing,\n\t\t\t )\n\t\t\t: nextVersionOfThing\n\nexport type Applicator<X, Y> = (next: Modifier<X> | X) => Modifier<Y>\nexport type Modifier<T> = (thing: T) => T\n\nexport type OneOrMany<T> = T | T[]\n\nexport const isModifier =\n\t<T>(validate: Refinement<unknown, T>) =>\n\t(sample: T): Refinement<unknown, Modifier<T>> => {\n\t\tconst sampleIsValid = validate(sample)\n\t\tif (!sampleIsValid) {\n\t\t\tthrow new Error(`Invalid test case: JSON.stringify(${sample})`)\n\t\t}\n\t\treturn (input: unknown): input is Modifier<T> => {\n\t\t\tif (typeof input !== `function`) return false\n\t\t\tconst testResult = input(sample)\n\t\t\treturn validate(testResult)\n\t\t}\n\t}\n\nexport const pass =\n\t<Params extends ReadonlyArray<any>, Out>(...params: Params) =>\n\t(fn: (...params: Params) => Out): Out =>\n\t\tfn(...params)\n\nexport const typeOf =\n\t<T>(input: unknown) =>\n\t(isType: Refinement<unknown, T>): boolean =>\n\t\tisType(input)\n\nexport const raiseError = (message: string): never => {\n\tthrow new Error(message)\n}\n\nexport type Encapsulate<T extends (...args: any[]) => any> = (\n\t...args: Parameters<T>\n) => void\n\nexport const attempt = (fn: () => void): boolean => {\n\ttry {\n\t\tfn()\n\t\treturn true\n\t} catch (_) {\n\t\treturn false\n\t}\n}\n\nexport const fallback = <T>(fn: () => T, fallbackValue: T): T => {\n\ttry {\n\t\treturn fn()\n\t} catch (_) {\n\t\treturn fallbackValue\n\t}\n}\n","import { isString } from \"fp-ts/string\"\n\nimport type { Json, JsonObj } from \"~/packages/anvl/src/json\"\n\nimport { isArray } from \"../array\"\nimport { hasExactProperties, isRecord } from \"../object/refinement\"\nimport { isLiteral } from \"../refinement\"\n\nexport const RELATION_TYPES = [`1:1`, `1:n`, `n:n`] as const\n\nexport type RelationType = typeof RELATION_TYPES[number]\n\nexport const isRelationType = (x: unknown): x is RelationType =>\n\tRELATION_TYPES.includes(x as RelationType)\n\nexport type RelationData<\n\tCONTENT extends JsonObj | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n> = {\n\tcontents: JsonObj<string, CONTENT>\n\trelations: JsonObj<string, string[]>\n\trelationType: RelationType\n\ta: A\n\tb: B\n}\n\nexport const EMPTY_RELATION_DATA: RelationData = {\n\tcontents: {},\n\trelations: {},\n\trelationType: `n:n`,\n\ta: `from`,\n\tb: `to`,\n}\n\nexport type IsRelationDataOptions<\n\tCONTENT extends JsonObj | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n> = {\n\tfrom?: A\n\tto?: B\n\tisContent?: (json: Json) => json is CONTENT\n}\nexport const isRelationData =\n\t<\n\t\tCONTENT extends JsonObj | null = null,\n\t\tA extends string = `from`,\n\t\tB extends string = `to`,\n\t>({\n\t\tfrom: a = `from` as A,\n\t\tto: b = `to` as B,\n\t\tisContent,\n\t}: IsRelationDataOptions<CONTENT, A, B> = {}) =>\n\t(input: unknown): input is RelationData<CONTENT, A, B> => {\n\t\treturn hasExactProperties<RelationData<CONTENT, A, B>>({\n\t\t\tcontents: isContent\n\t\t\t\t? isRecord(isString, isContent)\n\t\t\t\t: hasExactProperties({}),\n\t\t\trelations: isRecord(isString, isArray(isString)),\n\t\t\trelationType: isRelationType,\n\t\t\ta: isLiteral(a),\n\t\t\tb: isLiteral(b),\n\t\t})(input)\n\t}\n","export type VennCheck = (\n\titems: ReadonlyArray<unknown> | unknown[],\n) => (array: ReadonlyArray<unknown> | unknown[]) => boolean\n\nexport type VennTally = (\n\titems: ReadonlyArray<unknown> | unknown[],\n) => (array: ReadonlyArray<unknown> | unknown[]) => number\n\nexport const includesAll: VennCheck = (items) => (array) => {\n\tfor (const item of items) {\n\t\tif (!array.includes(item)) return false\n\t}\n\treturn true\n}\n\nexport const includesAny: VennCheck = (items) => (array) => {\n\tfor (const item of items) {\n\t\tif (array.includes(item)) return true\n\t}\n\treturn false\n}\n\nexport const excludesAll: VennCheck = (items) => (array) =>\n\t!includesAny(items)(array)\n\nexport const excludesAny: VennCheck = (items) => (array) =>\n\t!includesAll(items)(array)\n\nexport const comprises: VennCheck = (items) => (array) =>\n\tincludesAll(items)(array) && includesAll(array)(items)\n\nexport const overlaps: VennTally = (items) => (array) => {\n\tlet incidences = 0\n\tfor (const item of items) {\n\t\tif (array.includes(item)) incidences += 1\n\t}\n\treturn incidences\n}\n","export * from \"./match\"\nexport * from \"./venn\"\n\nimport type { Refinement } from \"fp-ts/Refinement\"\n\nexport const each =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): T[] =>\n\t\tisType(input) ? [input] : Array.isArray(input) ? input.filter(isType) : []\n\nexport const lastOf = <T>(input: ReadonlyArray<T>): T | undefined =>\n\tinput[input.length - 1]\n\nexport const isArray =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): input is T[] =>\n\t\tArray.isArray(input) && input.every((item) => isType(item))\n\nexport const at =\n\t<T>(index: number) =>\n\t(input: T[]): T | undefined =>\n\t\tinput.at(index)\n\nexport const content =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): input is T | T[] =>\n\t\tisType(input) || isArray(isType)(input)\n\nexport const join = (separator?: string) => (a: string[]): string =>\n\ta.join(separator)\n\nexport const map =\n\t<I, O>(f: (value: I, index: number, array: I[]) => O) =>\n\t(a: I[]): O[] =>\n\t\ta.map(f)\n\nexport const reduce =\n\t<I, O>(f: (acc: O, value: I, index: number, array: I[]) => O, initial: O) =>\n\t(a: I[]): O =>\n\t\ta.reduce(f, initial)\n\nexport const slice = (start: number, end?: number) => <I>(a: I[]): I[] =>\n\ta.slice(start, end)\n\nexport const using =\n\t<I, O>(a: I[]) =>\n\t(f: (acc: O, value: I, index: number, array: I[]) => O) =>\n\t(initial: O): O =>\n\t\ta.reduce(f, initial)\n\nexport const reduceRight =\n\t<I, O>(f: (acc: O, value: I, index: number, array: I[]) => O, initial: O) =>\n\t(a: I[]): O =>\n\t\ta.reduceRight(f, initial)\n\nexport const reverse = <I>(a: I[]): I[] => a.reverse()\n\nexport const sort =\n\t<I>(a: I[]) =>\n\t(f?: (x: I, y: I) => number): I[] =>\n\t\tf ? a.sort(f) : a.sort()\n\nexport const sortBy =\n\t<I>(f: (value: I) => number) =>\n\t(a: I[]): I[] =>\n\t\ta.sort((x, y) => f(x) - f(y))\n\nexport const sortByDesc =\n\t<I>(f: (value: I) => number) =>\n\t(a: I[]): I[] =>\n\t\ta.sort((x, y) => f(y) - f(x))\n\nexport const every =\n\t<I>(f: (value: I, index: number, array: I[]) => boolean = Boolean) =>\n\t(a: I[]): boolean =>\n\t\ta.every(f)\n\nexport const allTrue = every((x: boolean) => x === true)\n\nexport const addTo =\n\t<I>(a: I[]) =>\n\t(x: I): I[] =>\n\t\ta.includes(x) ? a : [...a, x]\n\nexport const isEmptyArray = (input: unknown): input is [] =>\n\tArray.isArray(input) && input.length === 0\n\nexport const isOneOf =\n\t<T>(...args: ReadonlyArray<T>) =>\n\t(input: unknown): input is T =>\n\t\targs.includes(input as T)\n\nexport const filter =\n\t<I, O extends I>(f: (value: I, index: number, array: I[]) => value is O) =>\n\t(a: I[]): O[] =>\n\t\ta.filter(f)\n","import { pipe } from \"fp-ts/function\"\nimport type { Refinement } from \"fp-ts/Refinement\"\n\nimport { access } from \"./access\"\nimport { recordToEntries } from \"./entries\"\nimport { mob } from \"./mapObject\"\nimport { allTrue, every } from \"../array\"\nimport { pass } from \"../function\"\nimport { ifNullish } from \"../nullish\"\n\nexport type PlainObject = Record<keyof any, unknown>\nexport type EmptyObject = Record<keyof any, never>\n\nexport const isNonNullObject = (input: unknown): input is object =>\n\ttypeof input === `object` && input !== null\n\nexport const isPlainObject = (input: unknown): input is PlainObject =>\n\tisNonNullObject(input) && Object.getPrototypeOf(input) === Object.prototype\n\nexport const isEmptyObject = (input: unknown): input is EmptyObject =>\n\tisPlainObject(input) && Object.keys(input).length === 0\n\n/* prettier-ignore */\nexport const isRecord =\n\t<KEY extends keyof any, VAL>(\n\t\tisKey: Refinement<keyof any, KEY>,\n\t\tisValue: Refinement<unknown, VAL>,\n\t) =>\n\t(input: unknown): input is Record<KEY, VAL> =>\n\t\tisPlainObject(input) &&\n\t\tObject.entries(input).every(([k, v]) => isKey(k) && isValue(v))\n/* prettier-ignore-end */\n\nexport type HasPropertiesOptions = {\n\treadonly allowExtraProperties?: boolean\n}\nexport const hasProperties = <OBJ extends object>(\n\tisValue: {\n\t\t[K in keyof OBJ]: Refinement<unknown, OBJ[K]>\n\t},\n\toptions: HasPropertiesOptions = { allowExtraProperties: false },\n): Refinement<unknown, OBJ> => {\n\tconst name = `{${recordToEntries(\n\t\tisValue as Record<keyof any, Refinement<any, any>>,\n\t)\n\t\t.map(([k, v]) => String(k) + `:` + v.name)\n\t\t.join(`,`)}}`\n\n\tconst _ = {\n\t\t[name]: (input: unknown): input is OBJ =>\n\t\t\tisPlainObject(input) &&\n\t\t\tpipe(\n\t\t\t\tisValue,\n\t\t\t\tObject.entries,\n\t\t\t\tevery(([key, val]) => key in input || val(undefined)),\n\t\t\t) &&\n\t\t\tpipe(\n\t\t\t\tinput,\n\t\t\t\tmob((val, key) =>\n\t\t\t\t\tpipe(\n\t\t\t\t\t\tisValue,\n\t\t\t\t\t\taccess(key),\n\t\t\t\t\t\tifNullish(() => options.allowExtraProperties),\n\t\t\t\t\t\tpass(val),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\tObject.values,\n\t\t\t\tallTrue,\n\t\t\t),\n\t}\n\treturn _[name]\n}\n\nexport const doesExtend =\n\t/* alias for hasExactProperties with allowExtraProperties */\n\t<OBJ extends object>(\n\t\tisValue: {\n\t\t\t[K in keyof OBJ]: Refinement<unknown, OBJ[K]>\n\t\t},\n\t): Refinement<unknown, OBJ> =>\n\t\thasProperties(isValue, { allowExtraProperties: true })\n\nexport const hasExactProperties =\n\t/* alias for hasProperties without allowExtraProperties */\n\t<OBJ extends object>(\n\t\tisValue: {\n\t\t\t[K in keyof OBJ]: Refinement<unknown, OBJ[K]>\n\t\t},\n\t): Refinement<unknown, OBJ> =>\n\t\thasProperties(isValue, { allowExtraProperties: false })\n","export const key =\n\t<T extends object>(k: keyof T) =>\n\t(obj: Exclude<object, null>): unknown =>\n\t\t(obj as Record<keyof any, any>)[k]\n\nexport const access = <V, T extends Record<keyof any, V>>(\n\tk: keyof any,\n): {\n\t(obj: T): T[keyof T] | undefined\n\tin: (obj: T) => T[keyof T] | undefined\n} =>\n\tObject.assign((obj: T) => obj[k as keyof T], {\n\t\tin: (obj: T) => obj[k as keyof T],\n\t})\n","export type Entries<K extends keyof any, V> = [key: K, value: V][]\n\nexport const recordToEntries = <K extends keyof any, V>(\n\tobj: Record<K, V>,\n): Entries<K, V> => Object.entries(obj) as Entries<K, V>\n\nexport const entriesToRecord = <K extends keyof any, V>(\n\tentries: Entries<K, V>,\n): Record<K, V> => Object.fromEntries(entries) as Record<K, V>\n","import { pipe } from \"fp-ts/function\"\n\nimport { entriesToRecord, recordToEntries } from \"./entries\"\nimport { map } from \"../array\"\n\nexport const mapObject = <K extends keyof any, I, O>(\n\tobj: Record<K, I>,\n\tfn: (val: I, key: K) => O,\n): Record<K, O> =>\n\tpipe(\n\t\tobj,\n\t\trecordToEntries,\n\t\tmap(([key, val]) => [key, fn(val, key)] as const),\n\t\tentriesToRecord,\n\t)\n\nexport const mob =\n\t<K extends keyof any, I, O>(fn: (val: I, key: K) => O) =>\n\t(obj: Record<K, I>): Record<K, O> =>\n\t\tmapObject(obj, fn)\n","import type { Refinement } from \"fp-ts/Refinement\"\n\nexport const isUndefined = (input: unknown): input is undefined =>\n\tinput === undefined\n\nexport const ifDefined = <T>(\n\tvalidate: Refinement<unknown, T>,\n): Refinement<unknown, T | undefined> =>\n\t((input) => isUndefined(input) || validate(input)) as Refinement<\n\t\tunknown,\n\t\tT | undefined\n\t>\n\nexport const isNull = (input: unknown): input is null => input === null\n\nexport const isNullish = (input: unknown): input is null | undefined =>\n\tisUndefined(input) || isNull(input)\n\nexport type NullSafeUnion<Base, Extension> = Extension extends null\n\t? Base\n\t: Base & Extension\n\nexport type NullSafeRest<MaybeArg> = MaybeArg extends null\n\t? [] | [undefined]\n\t: [MaybeArg]\n\nexport interface Discard {\n\treadonly _discard: unique symbol\n}\n\nexport const ifNullish =\n\t<X, Y>(alt: Y) =>\n\t(input: X): Exclude<X, null | undefined> | Y =>\n\t\t(input ?? alt) as Exclude<X, null | undefined> | Y\n","import type { Refinement } from \"fp-ts/Refinement\"\n\nexport * from \"./refined\"\n\nexport const canExist = (_: unknown): _ is unknown => true\nexport const cannotExist = (_: unknown): _ is never => false\n\nexport const isLiteral =\n\t<T extends boolean | number | string>(value: T): Refinement<unknown, T> =>\n\t(input: unknown): input is T =>\n\t\tinput === value\n\nexport const isWithin =\n\t<Options extends ReadonlyArray<any>>(args: Options) =>\n\t(input: unknown): input is Options[number] =>\n\t\targs.includes(input as Options[number])\n\nexport const ensure =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): T => {\n\t\tif (!isType(input)) {\n\t\t\tthrow new TypeError(`Expected ${input} to be of type ${isType.name}`)\n\t\t}\n\t\treturn input as T\n\t}\n\nexport const ensureAgainst =\n\t<A, B>(isType: Refinement<unknown, A>) =>\n\t(input: A | B): Exclude<A | B, A> => {\n\t\tif (isType(input)) {\n\t\t\tthrow new TypeError(`Expected ${input} to not be of type ${isType.name}`)\n\t\t}\n\t\treturn input as Exclude<A | B, A>\n\t}\n\nexport type ExtendsSome<A, B> = Refinement<unknown, A | B> & {\n\tor: <C>(isType: Refinement<unknown, C>) => ExtendsSome<unknown, A | B | C>\n}\nexport const couldBe = <A>(\n\tisTypeA: Refinement<unknown, A>,\n\tlogging = false,\n\trefinements: Refinement<unknown, any>[] = [isTypeA],\n): {\n\t(input: unknown): input is A\n\tor: <B>(isTypeB: Refinement<unknown, B>) => ExtendsSome<A, B>\n} => {\n\tconst name = `(${refinements.map((r) => r.name || `anon`).join(` | `)})`\n\tconst _ = {\n\t\t[name]: (input: unknown): input is A =>\n\t\t\trefinements.some(\n\t\t\t\t(refinement) => (\n\t\t\t\t\tlogging &&\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\trefinements.map((r) => r.name || `anon`).join(` | `),\n\t\t\t\t\t\t\t`>`,\n\t\t\t\t\t\t\trefinement.name ?? `anon`,\n\t\t\t\t\t\t\t`:`,\n\t\t\t\t\t\t\trefinement(input),\n\t\t\t\t\t\t),\n\t\t\t\t\trefinement(input)\n\t\t\t\t),\n\t\t\t),\n\t}\n\tconst checkTypes: {\n\t\t(input: unknown): input is A\n\t\tor: <B>(isTypeB: Refinement<unknown, B>) => ExtendsSome<A, B>\n\t} = Object.assign(_[name], {\n\t\tor: <B>(isTypeB: Refinement<unknown, B>): ExtendsSome<A, B> =>\n\t\t\tcouldBe(isTypeB, logging, [...refinements, isTypeB]),\n\t})\n\treturn checkTypes\n}\n\nexport const isUnion = couldBe(cannotExist)\n\nexport type ExtendsAll<A, B> = Refinement<unknown, A & B> & {\n\tand: <C>(isType: Refinement<unknown, C>) => ExtendsAll<A & B, C>\n}\n\nexport const mustBe = <A>(\n\tisTypeA: Refinement<unknown, A>,\n\tlogging = false,\n\trefinements: Refinement<unknown, any>[] = [isTypeA],\n): {\n\t(input: unknown): input is A\n\tand: <B>(isTypeB: Refinement<unknown, B>) => ExtendsAll<A, B>\n} => {\n\tconst name = `(${refinements.map((r) => r.name || `anon`).join(` & `)})`\n\tconst _ = {\n\t\t[name]: (input: unknown): input is A =>\n\t\t\trefinements.every(\n\t\t\t\t(refinement) => (\n\t\t\t\t\tlogging &&\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\trefinements.map((r) => r.name || `anon`).join(` & `),\n\t\t\t\t\t\t\t`>`,\n\t\t\t\t\t\t\trefinement.name || `anon`,\n\t\t\t\t\t\t\t`:`,\n\t\t\t\t\t\t\trefinement(input),\n\t\t\t\t\t\t),\n\t\t\t\t\trefinement(input)\n\t\t\t\t),\n\t\t\t),\n\t}\n\tconst checkTypes: {\n\t\t(input: unknown): input is A\n\t\tand: <B>(isTypeB: Refinement<unknown, B>) => ExtendsAll<A, B>\n\t} = Object.assign(_[name], {\n\t\tand: <B>(isTypeB: Refinement<unknown, B>): ExtendsAll<A, B> =>\n\t\t\tmustBe(isTypeB, logging, [...refinements, isTypeB]) as ExtendsAll<A, B>,\n\t})\n\treturn checkTypes\n}\n\nexport const isIntersection = mustBe(canExist)\n\nexport type ClassSignature = abstract new (...args: any) => any\n\nexport const isClass =\n\t<CS extends ClassSignature>(signature: CS) =>\n\t(input: unknown): input is InstanceType<ClassSignature> =>\n\t\tinput instanceof signature\n","import type { RelationData } from \"./core-relation-data\"\nimport type { JsonObj } from \"../json\"\n\nexport const getRelatedIds = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): string[] => relationMap.relations[id] ?? []\n\nexport const getRelatedId = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): string | undefined => {\n\tconst relations = getRelatedIds(relationMap, id)\n\tif (relations.length > 1) {\n\t\tconsole.warn(\n\t\t\t`entry with id ${id} was not expected to have multiple relations`,\n\t\t)\n\t}\n\treturn relations[0]\n}\n","import type { Json, JsonInterface, JsonObj } from \"~/packages/anvl/src/json\"\n\nimport { Join } from \".\"\nimport type { IsRelationDataOptions, RelationData } from \"./core-relation-data\"\n\nexport const makeJsonInterface = <\n\tCONTENT extends JsonObj | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n>(\n\tjoin: Join<CONTENT, A, B>,\n\t...params: CONTENT extends null ? [] : [(x: Json) => x is CONTENT]\n): JsonInterface<Join<CONTENT, A, B>, RelationData<CONTENT, A, B>> => {\n\tconst isContent = params[0] as (x: Json) => x is CONTENT\n\tconst { a, b } = join\n\tconst options: IsRelationDataOptions<CONTENT, A, B> = {\n\t\tfrom: a,\n\t\tto: b,\n\t\tisContent,\n\t}\n\treturn {\n\t\ttoJson: (join) => join.toJSON(),\n\t\tfromJson: (json) => Join.fromJSON(json, options),\n\t}\n}\n","import { pipe } from \"fp-ts/function\"\n\nimport type { Identified } from \"~/packages/anvl/src/id/identified\"\nimport { isEmptyObject } from \"~/packages/anvl/src/object/refinement\"\n\nimport type { RelationData } from \"./core-relation-data\"\nimport { getRelatedIds } from \"./get-related-ids\"\nimport { getRelationEntries } from \"./relation-record\"\nimport { removeRelation } from \"./remove-relation\"\nimport { setRelationWithContent } from \"./set-relation\"\nimport type { JsonObj } from \"../json\"\nimport type { NullSafeRest } from \"../nullish\"\n\nexport const makeContentId = (idA: string, idB: string): string =>\n\t[idA, idB].sort().join(`/`)\n\nexport const getContent = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n): CONTENT | undefined => relationMap.contents[makeContentId(idA, idB)]\n\nexport const setContent = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\tmap: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n\tcontent: CONTENT,\n): RelationData<CONTENT, A, B> => ({\n\t...map,\n\tcontents: {\n\t\t...map.contents,\n\t\t[makeContentId(idA, idB)]: content,\n\t},\n})\n\nexport const getRelations = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): (CONTENT extends null ? Identified : CONTENT & Identified)[] =>\n\tgetRelationEntries(relationMap, id).map(\n\t\t([id, content]) =>\n\t\t\t({\n\t\t\t\tid,\n\t\t\t\t...content,\n\t\t\t}) as CONTENT extends null ? Identified : CONTENT & Identified,\n\t)\n\nexport const setRelations = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tsubject: { [from in A]: string } | { [to in B]: string },\n\trelations: (CONTENT extends null ? Identified : CONTENT & Identified)[],\n): RelationData<CONTENT, A, B> => {\n\tconst idA: string | undefined = (subject as { [from in A]: string })[current.a]\n\tconst idB: string | undefined = (subject as { [to in B]: string })[current.b]\n\treturn pipe(\n\t\tcurrent,\n\t\t(relationData) => {\n\t\t\tconst relatedIds = getRelatedIds(current, idA)\n\t\t\tconst removedIds = relatedIds.filter(\n\t\t\t\t(id) => !relations.some((r) => r.id === id),\n\t\t\t)\n\t\t\tlet step = relationData\n\t\t\tfor (const id of removedIds) {\n\t\t\t\tconst remove = {\n\t\t\t\t\t[current.a]: idA ?? id,\n\t\t\t\t\t[current.b]: idB ?? id,\n\t\t\t\t} as Record<A | B, string>\n\t\t\t\tstep = removeRelation(step, remove)\n\t\t\t}\n\t\t\treturn step\n\t\t},\n\t\t(relationData) => {\n\t\t\tlet step = relationData\n\t\t\tfor (const { id, ...rest } of relations) {\n\t\t\t\tconst content = isEmptyObject(rest) ? undefined : rest\n\t\t\t\tstep = setRelationWithContent(\n\t\t\t\t\tstep,\n\t\t\t\t\t{ [current.a]: idA ?? id, [current.b]: idB ?? id } as Record<\n\t\t\t\t\t\tA | B,\n\t\t\t\t\t\tstring\n\t\t\t\t\t>,\n\t\t\t\t\t// @ts-expect-error hacky\n\t\t\t\t\tcontent as NullSafeRest<CONTENT>,\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn step\n\t\t},\n\t\t(relationData) => {\n\t\t\tconst newlyOrderedIds = relations.map((r) => r.id)\n\t\t\treturn {\n\t\t\t\t...relationData,\n\t\t\t\trelations: {\n\t\t\t\t\t...relationData.relations,\n\t\t\t\t\t[idA ?? idB]: newlyOrderedIds,\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t)\n}\n","import type { RelationData } from \"./core-relation-data\"\nimport { getRelatedIds } from \"./get-related-ids\"\nimport { getContent } from \"./relation-contents\"\nimport type { JsonObj } from \"../json\"\n\nexport const getRelationEntries = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tidA: string,\n): [string, CONTENT][] =>\n\tgetRelatedIds(relationMap, idA).map((idB) => [\n\t\tidB,\n\t\tgetContent(relationMap, idA, idB) as CONTENT,\n\t])\n\nexport const getRelationRecord = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): Record<string, CONTENT> =>\n\tObject.fromEntries(getRelationEntries(relationMap, id))\n","import { pipe } from \"fp-ts/function\"\nimport { isString } from \"fp-ts/string\"\n\nimport type { RelationData } from \"./core-relation-data\"\nimport { isEmptyArray, isOneOf, map } from \"../array\"\nimport { comprises } from \"../array/venn\"\nimport type { JsonObj } from \"../json\"\nimport type { RequireAtLeastOne } from \"../object\"\nimport { treeShake as removeProperties } from \"../object\"\nimport { entriesToRecord, recordToEntries } from \"../object/entries\"\nimport { split } from \"../string/split\"\n\nexport const removeSpecific = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n): RelationData<CONTENT, A, B> => {\n\tconst isIdForRemoval = isOneOf(idA, idB)\n\treturn {\n\t\t...current,\n\t\trelations: pipe(\n\t\t\tcurrent.relations,\n\t\t\trecordToEntries,\n\t\t\tmap(([id, relations]): [id: string, fewerRelations: string[]] => [\n\t\t\t\tid,\n\t\t\t\tisIdForRemoval(id)\n\t\t\t\t\t? relations.filter((relation) => !isIdForRemoval(relation))\n\t\t\t\t\t: relations,\n\t\t\t]),\n\t\t\tentriesToRecord,\n\t\t\tremoveProperties(isEmptyArray),\n\t\t),\n\t\tcontents: pipe(\n\t\t\tcurrent.contents,\n\t\t\tremoveProperties(\n\t\t\t\t(_, key) =>\n\t\t\t\t\tisString(key) && pipe(key, split(`/`), comprises([idA, idB])),\n\t\t\t),\n\t\t),\n\t}\n}\n\nexport const removeAll = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tidToRemove: string,\n): RelationData<CONTENT, A, B> => {\n\tconst next: RelationData<CONTENT, A, B> = {\n\t\t...current,\n\t\trelations: pipe(\n\t\t\tcurrent.relations,\n\t\t\trecordToEntries,\n\t\t\tmap(([id, relations]): [id: string, fewerRelations: string[]] => [\n\t\t\t\tid,\n\t\t\t\trelations.filter((relation) => relation !== idToRemove),\n\t\t\t]),\n\t\t\tentriesToRecord,\n\t\t\tremoveProperties((val, key) => key === idToRemove || isEmptyArray(val)),\n\t\t),\n\t\tcontents: pipe(\n\t\t\tcurrent.contents,\n\t\t\tremoveProperties(\n\t\t\t\t(_, key) => isString(key) && key.split(`/`).includes(idToRemove),\n\t\t\t),\n\t\t),\n\t}\n\treturn next\n}\n\nexport const removeRelation = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\trelation: Partial<Record<A | B, string>>,\n): RelationData<CONTENT, A, B> => {\n\tconst idA: string | undefined = (relation as { [key in A | B]: string })[\n\t\tcurrent.a\n\t]\n\tconst idB: string | undefined = (relation as { [key in A | B]: string })[\n\t\tcurrent.b\n\t]\n\treturn idB ? removeSpecific(current, idA, idB) : removeAll(current, idA)\n}\n","import { pipe } from \"fp-ts/function\"\nimport type { Refinement } from \"fp-ts/Refinement\"\n\nimport { deepMob } from \"./deepMob\"\nimport { entriesToRecord, recordToEntries } from \"./entries\"\nimport { isPlainObject } from \"./refinement\"\nimport { includesAny, reduce, filter } from \"../array\"\nimport { isUndefined } from \"../nullish\"\n\nexport * from \"./access\"\nexport * from \"./deepMob\"\nexport * from \"./entries\"\nexport * from \"./mapObject\"\nexport * from \"./modify\"\nexport * from \"./patch\"\nexport * from \"./refinement\"\nexport * from \"./sprawl\"\n\nexport const redact =\n\t<K extends keyof any>(...args: K[]) =>\n\t<O extends Record<K, any>>(obj: O): Omit<O, K> =>\n\t\treduce<K, O>((acc, key) => (delete acc[key], acc), obj)(args)\n\nexport type Redacted<Holder, RedactProp extends keyof any> = Omit<\n\t{\n\t\t[K in keyof Holder]: Holder[K] extends (infer Item)[]\n\t\t\t? Redacted<Item, RedactProp>[]\n\t\t\t: Redacted<Omit<Holder[K], RedactProp>, RedactProp>\n\t},\n\tRedactProp\n>\nexport const redactDeep =\n\t<K extends keyof any>(...args: K[]) =>\n\t<O extends Record<K, any>>(base: O): Redacted<O, K> =>\n\t\tdeepMob(base, (node, path) =>\n\t\t\tincludesAny(args)(path)\n\t\t\t\t? {\n\t\t\t\t\t\tmeta: { pathComplete: true },\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tdata: isPlainObject(node)\n\t\t\t\t\t\t\t? redact(...args)(node as Record<keyof any, any>)\n\t\t\t\t\t\t\t: node,\n\t\t\t\t },\n\t\t)\n\nexport const select =\n\t<Key extends keyof any>(...args: Key[]) =>\n\t<Obj extends object>(\n\t\tobj: Obj,\n\t): {\n\t\t// @ts-expect-error fuk u\n\t\t[K in keyof Pick<Obj, Key>]: any extends Pick<Obj, Key>[K]\n\t\t\t? undefined\n\t\t\t: // @ts-expect-error fuk u\n\t\t\t Pick<Obj, Key>[K]\n\t} =>\n\t\t// @ts-expect-error fuk u ts\n\t\treduce<Key, Pick<Obj, Key>>(\n\t\t\t// @ts-expect-error i will fite u\n\t\t\t(acc, key) => (key in obj ? (acc[key] = obj[key as keyof Obj]) : acc, acc),\n\t\t\t// @ts-expect-error fuk u\n\t\t\t{} as Pick<Obj, Key>,\n\t\t)(args)\n\nexport const treeShake =\n\t(shouldDiscard: (val: unknown, key: keyof any) => boolean = isUndefined) =>\n\t<T extends object>(\n\t\tobj: T,\n\t): T extends Record<keyof any, unknown> ? T : Partial<T> => {\n\t\tconst newObj = {} as T\n\t\tconst entries = Object.entries(obj) as [keyof T, any][]\n\t\tentries.forEach(([key, val]) =>\n\t\t\t!shouldDiscard(val, key) ? (newObj[key] = val) : null,\n\t\t)\n\t\treturn newObj as T extends Record<keyof any, unknown> ? T : Partial<T>\n\t}\n\nexport type KeysExtending<T, V> = keyof {\n\t[K in keyof T]: T[K] extends V ? K : never\n}\n\nconst a: never | null = null\n\nexport const filterProperties =\n\t<DiscardVal, DiscardKey extends keyof any>(\n\t\tshouldDiscardVal: Refinement<unknown, DiscardVal>,\n\t\tshouldDiscardKey: Refinement<unknown, DiscardKey>,\n\t) =>\n\t<P extends Record<keyof any, any>>(\n\t\tprops: P,\n\t): DiscardVal extends never\n\t\t? DiscardKey extends never\n\t\t\t? P\n\t\t\t: Omit<P, DiscardKey>\n\t\t: Omit<P, DiscardKey | KeysExtending<P, DiscardVal>> =>\n\t\t// @ts-expect-error oh well\n\t\tpipe(\n\t\t\tprops,\n\t\t\trecordToEntries,\n\t\t\tfilter(\n\t\t\t\t(\n\t\t\t\t\tentry,\n\t\t\t\t): entry is [\n\t\t\t\t\tExclude<keyof P, DiscardKey>,\n\t\t\t\t\tExclude<P[keyof P], DiscardVal>,\n\t\t\t\t] => !shouldDiscardKey(entry[0]) || !shouldDiscardVal(entry[1]),\n\t\t\t),\n\t\t\tentriesToRecord,\n\t\t)\n\nexport const delve = (\n\tobj: Record<keyof any, any>,\n\tpath: ReadonlyArray<keyof any>,\n): Error | { found: unknown } => {\n\tconst found = path.reduce((acc, key) => acc?.[key], obj)\n\treturn found === undefined ? new Error(`Not found`) : { found }\n}\n\nexport const tweak = (\n\tobj: Record<keyof any, any>,\n\tpath: ReadonlyArray<keyof any>,\n\tvalue: unknown,\n): void =>\n\tpath.reduce((acc, key, i) => {\n\t\tif (i === path.length - 1) {\n\t\t\tacc[key] = value\n\t\t}\n\t\tif (acc[key] === undefined) {\n\t\t\tacc[key] = typeof key === `number` ? [] : {}\n\t\t}\n\t\treturn acc[key]\n\t}, obj)\n\nexport type RequireAtLeastOne<T> = {\n\t[K in keyof T]-?: Partial<Pick<T, Exclude<keyof T, K>>> & Required<Pick<T, K>>\n}[keyof T]\n\nexport type RequireExactlyOne<T> = {\n\t[K in keyof T]-?: Required<Pick<T, K>>\n}[keyof T]\n","export const split = (separator: string) => (str: string): string[] =>\n\tstr.split(separator)\n","import type { RelationData } from \"./core-relation-data\"\nimport { getRelatedId } from \"./get-related-ids\"\nimport { setContent } from \"./relation-contents\"\nimport { addTo, isEmptyArray } from \"../array\"\nimport type { JsonObj } from \"../json\"\nimport type { NullSafeRest } from \"../nullish\"\nimport { treeShake as removeProperties } from \"../object\"\n\nexport const setManyToMany = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\tmap: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst next = {\n\t\t...map,\n\t\trelations: {\n\t\t\t...map.relations,\n\t\t\t[idA]: addTo(map.relations[idA] ?? [])(idB),\n\t\t\t[idB]: addTo(map.relations[idB] ?? [])(idA),\n\t\t},\n\t}\n\tconst content = rest[0] as CONTENT | undefined\n\treturn content ? setContent(next, idA, idB, content) : next\n}\n\nconst removeEmpties = removeProperties(isEmptyArray)\n\nexport const set1ToMany = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tleaderId: string,\n\tfollowerId: string,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst relations = { ...current.relations }\n\tconst prevLeaderId = getRelatedId(current, followerId)\n\tconst next = {\n\t\t...current,\n\t\trelations: removeEmpties({\n\t\t\t...relations,\n\t\t\t...(prevLeaderId &&\n\t\t\t\tprevLeaderId !== leaderId && {\n\t\t\t\t\t[prevLeaderId]: relations[prevLeaderId].filter(\n\t\t\t\t\t\t(id) => id !== followerId,\n\t\t\t\t\t),\n\t\t\t\t}),\n\t\t\t[followerId]: [leaderId],\n\t\t\t[leaderId]: addTo(relations[leaderId] ?? [])(followerId),\n\t\t}),\n\t}\n\tconst content = rest[0] as CONTENT | undefined\n\treturn content ? setContent(next, leaderId, followerId, content) : next\n}\n\nexport const set1To1 = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\twifeId: string,\n\thusbandId: string,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst prevWifeId = getRelatedId(current, husbandId)\n\tconst prevHusbandId = getRelatedId(current, wifeId)\n\tconst next = {\n\t\t...current,\n\t\trelations: removeEmpties({\n\t\t\t...current.relations,\n\t\t\t...(prevWifeId && { [prevWifeId]: [] }),\n\t\t\t...(prevHusbandId && { [prevHusbandId]: [] }),\n\t\t\t[wifeId]: [husbandId],\n\t\t\t[husbandId]: [wifeId],\n\t\t}),\n\t}\n\n\tconst content = rest[0] as CONTENT | undefined\n\treturn content ? setContent(next, wifeId, husbandId, content) : next\n}\n\nexport const setRelationWithContent = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\trelation: Record<A | B, string>,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst { [current.a]: idA, [current.b]: idB } = relation\n\t// console.log({\n\t// current,\n\t// relation,\n\t// idA,\n\t// idB,\n\t// })\n\tswitch (current.relationType) {\n\t\tcase `1:1`:\n\t\t\treturn set1To1(current, idA, idB, ...rest)\n\t\tcase `1:n`:\n\t\t\treturn set1ToMany(current, idA, idB, ...rest)\n\t\tcase `n:n`:\n\t\t\treturn setManyToMany(current, idA, idB, ...rest)\n\t}\n}\n","import type { Refinement } from \"fp-ts/Refinement\"\n\nimport type { Identified } from \"~/packages/anvl/src/id/identified\"\n\nimport type { IsRelationDataOptions, RelationData } from \"./core-relation-data\"\nimport { EMPTY_RELATION_DATA, isRelationData } from \"./core-relation-data\"\nimport { getRelatedId, getRelatedIds } from \"./get-related-ids\"\nimport { makeJsonInterface } from \"./make-json-interface\"\nimport { getContent, getRelations, setRelations } from \"./relation-contents\"\nimport { getRelationEntries, getRelationRecord } from \"./relation-record\"\nimport { removeRelation } from \"./remove-relation\"\nimport { setRelationWithContent } from \"./set-relation\"\nimport type { Json, JsonInterface, JsonObj } from \"../json\"\nimport type { NullSafeRest, NullSafeUnion } from \"../nullish\"\n\nexport class Join<\n\tCONTENT extends JsonObj | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n> implements RelationData<CONTENT, A, B>\n{\n\tpublic readonly relationType: `1:1` | `1:n` | `n:n`\n\tpublic readonly a: A = `from` as A\n\tpublic readonly b: B = `to` as B\n\tpublic readonly relations: Record<string, string[]>\n\tpublic readonly contents: Record<string, CONTENT>\n\tpublic constructor(json?: Partial<RelationData<CONTENT, A, B>>) {\n\t\tObject.assign(this, {\n\t\t\t...EMPTY_RELATION_DATA,\n\t\t\t...json,\n\t\t\tmakeJsonInterface: this.makeJsonInterface,\n\t\t})\n\t}\n\tpublic toJSON(): RelationData<CONTENT, A, B> {\n\t\treturn {\n\t\t\trelationType: this.relationType,\n\t\t\trelations: this.relations,\n\t\t\tcontents: this.contents,\n\t\t\ta: this.a,\n\t\t\tb: this.b,\n\t\t}\n\t}\n\tpublic static fromJSON<\n\t\tCONTENT extends JsonObj | null,\n\t\tA extends string,\n\t\tB extends string,\n\t>(\n\t\tjson: Json,\n\t\toptions?: IsRelationDataOptions<CONTENT, A, B>,\n\t): Join<CONTENT, A, B> {\n\t\tconst isValid = isRelationData<CONTENT, A, B>(options)(json)\n\t\tif (isValid) {\n\t\t\treturn new Join<CONTENT, A, B>(json)\n\t\t}\n\t\tthrow new Error(\n\t\t\t`Saved JSON for this Join is invalid: ${JSON.stringify(json)}`,\n\t\t)\n\t}\n\n\tpublic from<AA extends string>(newA: AA): Join<CONTENT, AA, B> {\n\t\treturn new Join({ ...this, a: newA })\n\t}\n\n\tpublic to<BB extends string>(newB: BB): Join<CONTENT, A, BB> {\n\t\treturn new Join({ ...this, b: newB })\n\t}\n\n\tpublic makeJsonInterface = (\n\t\t...params: CONTENT extends null ? [] : [Refinement<unknown, CONTENT>]\n\t): JsonInterface<Join<CONTENT, A, B>, RelationData<CONTENT, A, B>> => {\n\t\treturn makeJsonInterface<CONTENT, A, B>(this, ...params)\n\t}\n\n\tpublic getRelatedId(id: string): string | undefined {\n\t\treturn getRelatedId(this, id)\n\t}\n\tpublic getRelatedIds(id: string): string[] {\n\t\treturn getRelatedIds(this, id)\n\t}\n\tpublic getContent(idA: string, idB: string): CONTENT | undefined {\n\t\treturn getContent(this, idA, idB)\n\t}\n\tpublic getRelationEntries(id: string): [string, CONTENT][] {\n\t\treturn getRelationEntries(this, id)\n\t}\n\tpublic getRelationRecord(id: string): Record<string, CONTENT> {\n\t\treturn getRelationRecord(this, id)\n\t}\n\tpublic getRelation(\n\t\tid: string,\n\t): NullSafeUnion<Identified, CONTENT> | undefined {\n\t\treturn getRelations(this, id)[0]\n\t}\n\tpublic getRelations(id: string): NullSafeUnion<Identified, CONTENT>[] {\n\t\treturn getRelations(this, id)\n\t}\n\tpublic setRelations(\n\t\tsubject: { [from in A]: string } | { [to in B]: string },\n\t\trelations: NullSafeUnion<Identified, CONTENT>[],\n\t): Join<CONTENT, A, B> {\n\t\treturn new Join(setRelations(this, subject, relations))\n\t}\n\tpublic set(\n\t\trelation: { [key in A | B]: string },\n\t\t...rest: NullSafeRest<CONTENT>\n\t): Join<CONTENT, A, B> {\n\t\treturn new Join(setRelationWithContent(this, relation, ...rest))\n\t}\n\tpublic remove(relation: Partial<Record<A | B, string>>): Join<CONTENT, A, B> {\n\t\treturn new Join(\n\t\t\tremoveRelation(this, relation as Partial<Record<A | B, string>>),\n\t\t)\n\t}\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\nimport { doNothing } from \"~/packages/anvl/src/function\"\nimport { Join } from \"~/packages/anvl/src/join\"\n\nimport { Subject } from \".\"\nimport type {\n\tAtom,\n\tOperationProgress,\n\tReadonlySelector,\n\tSelector,\n\tTransactionStatus,\n\tTimeline,\n\tTransaction,\n} from \".\"\nimport type {\n\tAtomToken,\n\tLogger,\n\tReadonlySelectorToken,\n\tSelectorToken,\n\tTimelineToken,\n\tTransactionToken,\n} from \"..\"\n\nexport type StoreCore = Pick<\n\tStore,\n\t| `atoms`\n\t| `atomsThatAreDefault`\n\t| `operation`\n\t| `readonlySelectors`\n\t| `selectorAtoms`\n\t| `selectorGraph`\n\t| `selectors`\n\t| `timelineAtoms`\n\t| `timelines`\n\t| `transactions`\n\t| `valueMap`\n>\n\nexport interface Store {\n\tatoms: Map<string, Atom<any>>\n\tatomsThatAreDefault: Set<string>\n\treadonlySelectors: Map<string, ReadonlySelector<any>>\n\tselectorAtoms: Join<null, `selectorKey`, `atomKey`>\n\tselectorGraph: Join<{ source: string }>\n\tselectors: Map<string, Selector<any>>\n\ttimelineAtoms: Join<null, `timelineKey`, `atomKey`>\n\ttimelines: Map<string, Timeline>\n\ttransactions: Map<string, Transaction<any>>\n\tvalueMap: Map<string, any>\n\n\tsubject: {\n\t\tatomCreation: Subject<AtomToken<unknown>>\n\t\tselectorCreation: Subject<\n\t\t\tReadonlySelectorToken<unknown> | SelectorToken<unknown>\n\t\t>\n\t\ttransactionCreation: Subject<TransactionToken<ƒn>>\n\t\ttimelineCreation: Subject<TimelineToken>\n\t\toperationStatus: Subject<OperationProgress>\n\t}\n\n\toperation: OperationProgress\n\ttransactionStatus: TransactionStatus<ƒn>\n\tconfig: {\n\t\tname: string\n\t\tlogger: Logger | null\n\t\tlogger__INTERNAL: Logger\n\t}\n}\n\nexport const createStore = (name: string, store: Store | null = null): Store => {\n\tconst created = {\n\t\t...(store ??\n\t\t\t(() => ({\n\t\t\t\tatomsThatAreDefault: new Set(),\n\t\t\t\tselectorAtoms: new Join({ relationType: `n:n` })\n\t\t\t\t\t.from(`selectorKey`)\n\t\t\t\t\t.to(`atomKey`),\n\t\t\t\tselectorGraph: new Join({ relationType: `n:n` }),\n\t\t\t}))()),\n\n\t\tvalueMap: new Map(store?.valueMap),\n\t\tatoms: new Map(),\n\t\treadonlySelectors: new Map(),\n\t\tselectors: new Map(),\n\t\ttransactions: new Map(),\n\t\ttimelines: new Map(),\n\n\t\ttimelineAtoms: new Join({ relationType: `1:n` })\n\t\t\t.from(`timelineKey`)\n\t\t\t.to(`atomKey`),\n\n\t\tsubject: {\n\t\t\tatomCreation: new Subject(),\n\t\t\tselectorCreation: new Subject(),\n\t\t\ttransactionCreation: new Subject(),\n\t\t\ttimelineCreation: new Subject(),\n\t\t\toperationStatus: new Subject(),\n\t\t},\n\n\t\toperation: {\n\t\t\topen: false,\n\t\t\t...store?.operation,\n\t\t},\n\t\ttransactionStatus: {\n\t\t\tphase: `idle`,\n\t\t\t...store?.transactionStatus,\n\t\t},\n\t\tconfig: {\n\t\t\tlogger: {\n\t\t\t\t...console,\n\t\t\t\tinfo: doNothing,\n\t\t\t\t...store?.config?.logger,\n\t\t\t},\n\t\t\tlogger__INTERNAL: console,\n\t\t\t...store?.config,\n\t\t\tname,\n\t\t},\n\t} satisfies Store\n\n\tstore?.atoms.forEach((atom) => {\n\t\tconst copiedAtom = { ...atom, subject: new Subject() } satisfies Atom<any>\n\t\tcreated.atoms.set(atom.key, copiedAtom)\n\t})\n\tstore?.readonlySelectors.forEach((selector) => {\n\t\tselector.install(created)\n\t})\n\tstore?.selectors.forEach((selector) => {\n\t\tselector.install(created)\n\t})\n\tstore?.transactions.forEach((tx) => {\n\t\ttx.install(created)\n\t})\n\tstore?.timelines.forEach((timeline) => {\n\t\ttimeline.install(created)\n\t})\n\n\treturn created\n}\n\nexport const IMPLICIT = {\n\tSTORE_INTERNAL: undefined as Store | undefined,\n\tget STORE(): Store {\n\t\treturn this.STORE_INTERNAL ?? (this.STORE_INTERNAL = createStore(`DEFAULT`))\n\t},\n}\n\nexport const clearStore = (store: Store = IMPLICIT.STORE): void => {\n\tconst { config } = store\n\tObject.assign(store, createStore(config.name))\n\tstore.config = config\n}\n","import type { Atom, ReadonlySelector, Selector } from \".\"\nimport { target } from \".\"\nimport type { Store } from \"./store\"\nimport { IMPLICIT } from \"./store\"\nimport type { StateToken } from \"..\"\n\nexport type OperationProgress =\n\t| {\n\t\t\topen: false\n\t }\n\t| {\n\t\t\topen: true\n\t\t\tdone: Set<string>\n\t\t\tprev: Map<string, any>\n\t\t\ttime: number\n\t\t\ttoken: StateToken<any>\n\t }\n\nexport const openOperation = (token: StateToken<any>, store: Store): void => {\n\tconst core = target(store)\n\tif (core.operation.open) {\n\t\tstore.config.logger?.error(\n\t\t\t`❌ failed to setState to \"${token.key}\" during a setState for \"${core.operation.token.key}\"`,\n\t\t)\n\t\tthrow Symbol(`violation`)\n\t}\n\tcore.operation = {\n\t\topen: true,\n\t\tdone: new Set(),\n\t\tprev: new Map(store.valueMap),\n\t\ttime: Date.now(),\n\t\ttoken,\n\t}\n\tstore.config.logger?.info(\n\t\t`⭕ operation start from \"${token.key}\" in store \"${store.config.name}\"`,\n\t)\n}\nexport const closeOperation = (store: Store): void => {\n\tconst core = target(store)\n\tcore.operation = { open: false }\n\tstore.config.logger?.info(`🔴 operation done`)\n\tstore.subject.operationStatus.next(core.operation)\n}\n\nexport const isDone = (key: string, store: Store = IMPLICIT.STORE): boolean => {\n\tconst core = target(store)\n\tif (!core.operation.open) {\n\t\tstore.config.logger?.warn(\n\t\t\t`isDone called outside of an operation. This is probably a bug.`,\n\t\t)\n\t\treturn true\n\t}\n\treturn core.operation.done.has(key)\n}\nexport const markDone = (key: string, store: Store = IMPLICIT.STORE): void => {\n\tconst core = target(store)\n\tif (!core.operation.open) {\n\t\tstore.config.logger?.warn(\n\t\t\t`markDone called outside of an operation. This is probably a bug.`,\n\t\t)\n\t\treturn\n\t}\n\tcore.operation.done.add(key)\n}\nexport const recallState = <T>(\n\tstate: Atom<T> | ReadonlySelector<T> | Selector<T>,\n\tstore: Store = IMPLICIT.STORE,\n): T => {\n\tconst core = target(store)\n\tif (!core.operation.open) {\n\t\tstore.config.logger?.warn(\n\t\t\t`recall called outside of an operation. This is probably a bug.`,\n\t\t)\n\t\treturn core.valueMap.get(state.key)\n\t}\n\treturn core.operation.prev.get(state.key)\n}\n\nexport const cacheValue = (\n\tkey: string,\n\tvalue: unknown,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.valueMap.set(key, value)\n}\n\nexport const evictCachedValue = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.valueMap.delete(key)\n}\nexport const readCachedValue = <T>(\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): T => target(store).valueMap.get(key)\n\nexport const isValueCached = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): boolean => target(store).valueMap.has(key)\n\nexport const storeAtom = (\n\tatom: Atom<any>,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.atoms.set(atom.key, atom)\n}\n\nexport const storeSelector = (\n\tselector: Selector<any>,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.selectors.set(selector.key, selector)\n}\n\nexport const storeReadonlySelector = (\n\tselector: ReadonlySelector<any>,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.readonlySelectors.set(selector.key, selector)\n}\n\nexport const hasKeyBeenUsed = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): boolean => {\n\tconst core = target(store)\n\treturn (\n\t\tcore.atoms.has(key) ||\n\t\tcore.selectors.has(key) ||\n\t\tcore.readonlySelectors.has(key)\n\t)\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store, StoreCore } from \".\"\nimport {\n\tSubject,\n\tabortTransaction,\n\tapplyTransaction,\n\tbuildTransaction,\n\tdeposit,\n\tIMPLICIT,\n} from \".\"\nimport type { TransactionOptions, TransactionToken, TransactionUpdate } from \"..\"\nimport { getState, setState } from \"..\"\n\nexport type Transaction<ƒ extends ƒn> = {\n\tkey: string\n\ttype: `transaction`\n\tinstall: (store: Store) => void\n\tsubject: Subject<TransactionUpdate<ƒ>>\n\trun: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>\n}\n\nexport function transaction__INTERNAL<ƒ extends ƒn>(\n\toptions: TransactionOptions<ƒ>,\n\tstore: Store = IMPLICIT.STORE,\n): TransactionToken<ƒ> {\n\tconst newTransaction: Transaction<ƒ> = {\n\t\tkey: options.key,\n\t\ttype: `transaction`,\n\t\trun: (...params: Parameters<ƒ>) => {\n\t\t\tbuildTransaction(options.key, params, store)\n\t\t\ttry {\n\t\t\t\tconst output = options.do(\n\t\t\t\t\t{\n\t\t\t\t\t\tget: (token) => getState(token, store),\n\t\t\t\t\t\tset: (token, value) => setState(token, value, store),\n\t\t\t\t\t},\n\t\t\t\t\t...params,\n\t\t\t\t)\n\t\t\t\tapplyTransaction(output, store)\n\t\t\t\treturn output\n\t\t\t} catch (thrown) {\n\t\t\t\tabortTransaction(store)\n\t\t\t\tstore.config.logger?.error(`Transaction ${options.key} failed`, thrown)\n\t\t\t\tthrow thrown\n\t\t\t}\n\t\t},\n\t\tinstall: (store) => transaction__INTERNAL(options, store),\n\t\tsubject: new Subject(),\n\t}\n\tconst core = target(store)\n\tcore.transactions.set(newTransaction.key, newTransaction)\n\tconst token = deposit(newTransaction)\n\tstore.subject.transactionCreation.next(token)\n\treturn token\n}\n\nexport const target = (store: Store = IMPLICIT.STORE): StoreCore =>\n\tstore.transactionStatus.phase === `building`\n\t\t? store.transactionStatus.core\n\t\t: store\n","import { Subject } from \".\"\nimport { deposit } from \"./get\"\nimport { markAtomAsDefault } from \"./is-default\"\nimport { cacheValue } from \"./operation\"\nimport type { Store } from \"./store\"\nimport { IMPLICIT } from \"./store\"\nimport { target } from \"./transaction-internal\"\nimport type { AtomToken, FamilyMetadata, UpdateHandler } from \"..\"\nimport { setState, subscribe } from \"..\"\nimport type { AtomOptions } from \"../atom\"\n\nexport type Atom<T> = {\n\tkey: string\n\ttype: `atom`\n\tfamily?: FamilyMetadata\n\tsubject: Subject<{ newValue: T; oldValue: T }>\n\tdefault: T\n}\n\nexport function atom__INTERNAL<T>(\n\toptions: AtomOptions<T>,\n\tfamily?: FamilyMetadata,\n\tstore: Store = IMPLICIT.STORE,\n): AtomToken<T> {\n\tconst core = target(store)\n\tconst existing = core.atoms.get(options.key)\n\tif (existing) {\n\t\tstore.config.logger?.error?.(\n\t\t\t`Key \"${options.key}\" already exists in the store.`,\n\t\t)\n\t\treturn deposit(existing)\n\t}\n\tconst subject = new Subject<{ newValue: T; oldValue: T }>()\n\tconst newAtom = {\n\t\t...options,\n\t\tsubject,\n\t\ttype: `atom`,\n\t\t...(family && { family }),\n\t} as const\n\tconst initialValue =\n\t\toptions.default instanceof Function ? options.default() : options.default\n\tcore.atoms.set(newAtom.key, newAtom)\n\tmarkAtomAsDefault(options.key, store)\n\tcacheValue(options.key, initialValue, store)\n\tconst token = deposit(newAtom)\n\toptions.effects?.forEach((effect) =>\n\t\teffect({\n\t\t\tsetSelf: (next) => setState(token, next, store),\n\t\t\tonSet: (handle: UpdateHandler<T>) => subscribe(token, handle, store),\n\t\t}),\n\t)\n\tstore.subject.atomCreation.next(token)\n\treturn token as AtomToken<T>\n}\n","import { pipe } from \"fp-ts/function\"\n\nexport * from \"./refine\"\nexport * from \"./json-interface\"\n\nexport const serializeSet = <T>(set: Set<T>): string =>\n\tpipe(set, Array.from, JSON.stringify)\n\nexport const deserializeSet = <T>(str: string): Set<T> =>\n\tpipe(str, JSON.parse, Array.from, (a) => new Set(a as T[]))\n\nexport type Primitive = boolean | number | string | null\n\nexport type Serializable =\n\t| Primitive\n\t| Readonly<{ [key: string]: Serializable }>\n\t| ReadonlyArray<Serializable>\n\nexport type JsonObj<\n\tKey extends string = string,\n\tValue extends Serializable = Serializable,\n> = Record<Key, Value>\n\nexport type JsonArr<Element extends Serializable = Serializable> =\n\tReadonlyArray<Element>\n\nexport type Json = JsonArr | JsonObj | Primitive\n\nexport const parseJson = <S extends Stringified<Json>>(\n\tstr: S | string,\n): S extends Stringified<infer J> ? J : Json => JSON.parse(str)\n\nexport type Stringified<J extends Json> = string & { __json: J }\n\nexport const stringifyJson = <J extends Json>(json: J): Stringified<J> =>\n\tJSON.stringify(json) as Stringified<J>\n\nexport type Empty = Record<string, never>\n\nexport const JSON_TYPE_NAMES = [\n\t`array`,\n\t`boolean`,\n\t`null`,\n\t`number`,\n\t`object`,\n\t`string`,\n] as const\n\nexport type JsonTypeName = typeof JSON_TYPE_NAMES[number]\n\nexport interface JsonTypes extends Record<JsonTypeName, Json> {\n\tarray: JsonArr\n\tboolean: boolean\n\tnull: null\n\tnumber: number\n\tobject: JsonObj\n\tstring: string\n}\n\nexport const JSON_DEFAULTS: JsonTypes = {\n\tarray: [],\n\tboolean: false,\n\tnull: null,\n\tnumber: 0,\n\tobject: {},\n\tstring: ``,\n}\n","import type { Serializable } from \"~/packages/anvl/src/json\"\nimport { stringifyJson } from \"~/packages/anvl/src/json\"\n\nimport type { Store } from \".\"\nimport {\n\tSubject,\n\tatom__INTERNAL,\n\twithdraw,\n\tselector__INTERNAL,\n\ttarget,\n\tdeposit,\n\tIMPLICIT,\n} from \".\"\nimport type {\n\tAtomFamily,\n\tAtomFamilyOptions,\n\tAtomToken,\n\tFamilyMetadata,\n\tReadonlySelectorFamily,\n\tReadonlySelectorFamilyOptions,\n\tReadonlySelectorToken,\n\tSelectorFamily,\n\tSelectorFamilyOptions,\n\tSelectorToken,\n} from \"..\"\n\nexport function atomFamily__INTERNAL<T, K extends Serializable>(\n\toptions: AtomFamilyOptions<T, K>,\n\tstore: Store = IMPLICIT.STORE,\n): AtomFamily<T, K> {\n\tconst subject = new Subject<AtomToken<T>>()\n\treturn Object.assign(\n\t\t(key: K): AtomToken<T> => {\n\t\t\tconst subKey = stringifyJson(key)\n\t\t\tconst family: FamilyMetadata = { key: options.key, subKey }\n\t\t\tconst fullKey = `${options.key}(${subKey})`\n\t\t\tconst existing = withdraw({ key: fullKey, type: `atom` }, store)\n\t\t\tconst token: AtomToken<any> = existing\n\t\t\t\t? deposit(existing)\n\t\t\t\t: atom__INTERNAL<T>(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey: fullKey,\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\toptions.default instanceof Function\n\t\t\t\t\t\t\t\t\t? options.default(key)\n\t\t\t\t\t\t\t\t\t: options.default,\n\t\t\t\t\t\t\teffects: options.effects?.(key),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tfamily,\n\t\t\t\t\t\tstore,\n\t\t\t\t )\n\t\t\tsubject.next(token)\n\t\t\treturn token\n\t\t},\n\t\t{\n\t\t\tkey: options.key,\n\t\t\ttype: `atom_family`,\n\t\t\tsubject,\n\t\t} as const,\n\t)\n}\n\nexport function readonlySelectorFamily__INTERNAL<T, K extends Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K>,\n\tstore?: Store,\n): ReadonlySelectorFamily<T, K> {\n\tconst core = target(store)\n\tconst subject = new Subject<ReadonlySelectorToken<T>>()\n\treturn Object.assign(\n\t\t(key: K): ReadonlySelectorToken<T> => {\n\t\t\tconst subKey = stringifyJson(key)\n\t\t\tconst family: FamilyMetadata = { key: options.key, subKey }\n\t\t\tconst fullKey = `${options.key}(${subKey})`\n\t\t\tconst existing = core.readonlySelectors.get(fullKey)\n\t\t\tif (existing) {\n\t\t\t\treturn deposit(existing)\n\t\t\t}\n\t\t\treturn selector__INTERNAL<T>(\n\t\t\t\t{\n\t\t\t\t\tkey: fullKey,\n\t\t\t\t\tget: options.get(key),\n\t\t\t\t},\n\t\t\t\tfamily,\n\t\t\t\tstore,\n\t\t\t) as ReadonlySelectorToken<T>\n\t\t},\n\t\t{\n\t\t\tkey: options.key,\n\t\t\ttype: `readonly_selector_family`,\n\t\t\tsubject,\n\t\t} as const,\n\t) as ReadonlySelectorFamily<T, K>\n}\n\nexport function selectorFamily__INTERNAL<T, K extends Serializable>(\n\toptions: SelectorFamilyOptions<T, K>,\n\tstore?: Store,\n): SelectorFamily<T, K>\nexport function selectorFamily__INTERNAL<T, K extends Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K>,\n\tstore?: Store,\n): ReadonlySelectorFamily<T, K>\nexport function selectorFamily__INTERNAL<T, K extends Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K> | SelectorFamilyOptions<T, K>,\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorFamily<T, K> | SelectorFamily<T, K> {\n\tconst isReadonly = !(`set` in options)\n\n\tif (isReadonly) {\n\t\treturn readonlySelectorFamily__INTERNAL(options, store)\n\t}\n\tconst core = target(store)\n\tconst subject = new Subject<SelectorToken<T>>()\n\n\treturn Object.assign(\n\t\t(key: K): SelectorToken<T> => {\n\t\t\tconst subKey = stringifyJson(key)\n\t\t\tconst family: FamilyMetadata = { key: options.key, subKey }\n\t\t\tconst fullKey = `${options.key}(${subKey})`\n\t\t\tconst existing = core.selectors.get(fullKey)\n\t\t\tif (existing) {\n\t\t\t\treturn deposit(existing)\n\t\t\t}\n\t\t\tconst token = selector__INTERNAL<T>(\n\t\t\t\t{\n\t\t\t\t\tkey: fullKey,\n\t\t\t\t\tget: options.get(key),\n\t\t\t\t\tset: options.set(key),\n\t\t\t\t},\n\t\t\t\tfamily,\n\t\t\t\tstore,\n\t\t\t)\n\t\t\tsubject.next(token)\n\t\t\treturn token\n\t\t},\n\t\t{\n\t\t\tkey: options.key,\n\t\t\ttype: `selector_family`,\n\t\t} as const,\n\t) as SelectorFamily<T, K>\n}\n","import { become } from \"~/packages/anvl/src/function\"\n\nimport { Subject } from \"..\"\nimport {\n\ttype Store,\n\ttype Selector,\n\ttype StoreCore,\n\tregisterSelector,\n\tselector__INTERNAL,\n} from \"..\"\nimport type { FamilyMetadata, SelectorToken } from \"../..\"\nimport type { SelectorOptions } from \"../../selector\"\nimport { cacheValue, markDone } from \"../operation\"\n\nexport const createReadWriteSelector = <T>(\n\toptions: SelectorOptions<T>,\n\tfamily: FamilyMetadata | undefined,\n\tstore: Store,\n\tcore: StoreCore,\n): SelectorToken<T> => {\n\tconst subject = new Subject<{ newValue: T; oldValue: T }>()\n\n\tconst { get, set } = registerSelector(options.key, store)\n\tconst getSelf = () => {\n\t\tconst value = options.get({ get })\n\t\tcacheValue(options.key, value, store)\n\t\treturn value\n\t}\n\n\tconst setSelf = (next: T | ((oldValue: T) => T)): void => {\n\t\tconst oldValue = getSelf()\n\t\tstore.config.logger?.info(\n\t\t\t` <- \"${options.key}\" went (`,\n\t\t\toldValue,\n\t\t\t`->`,\n\t\t\tnext,\n\t\t\t`)`,\n\t\t)\n\t\tconst newValue = become(next)(oldValue)\n\t\tcacheValue(options.key, newValue, store)\n\t\tmarkDone(options.key, store)\n\t\tif (store.transactionStatus.phase === `idle`) {\n\t\t\tsubject.next({ newValue, oldValue })\n\t\t}\n\t\toptions.set({ get, set }, newValue)\n\t}\n\tconst mySelector: Selector<T> = {\n\t\t...options,\n\t\tsubject,\n\t\tinstall: (s: Store) => selector__INTERNAL(options, family, s),\n\t\tget: getSelf,\n\t\tset: setSelf,\n\t\ttype: `selector`,\n\t\t...(family && { family }),\n\t}\n\tcore.selectors.set(options.key, mySelector)\n\tconst initialValue = getSelf()\n\tstore.config.logger?.info(` ✨ \"${options.key}\" =`, initialValue)\n\tconst token: SelectorToken<T> = {\n\t\tkey: options.key,\n\t\ttype: `selector`,\n\t\tfamily,\n\t}\n\tstore.subject.selectorCreation.next(token)\n\treturn token\n}\n","import type { Store } from \"..\"\nimport { target, lookup } from \"..\"\nimport type { AtomToken, ReadonlySelectorToken, SelectorToken } from \"../..\"\n\nexport const lookupSelectorSources = (\n\tkey: string,\n\tstore: Store,\n): (\n\t| AtomToken<unknown>\n\t| ReadonlySelectorToken<unknown>\n\t| SelectorToken<unknown>\n)[] =>\n\ttarget(store)\n\t\t.selectorGraph.getRelations(key)\n\t\t.filter(({ source }) => source !== key)\n\t\t.map(({ source }) => lookup(source, store))\n","import { lookupSelectorSources } from \"./lookup-selector-sources\"\nimport type { Store, AtomToken, ReadonlySelectorToken, StateToken } from \"../..\"\n\nexport const traceSelectorAtoms = (\n\tselectorKey: string,\n\tdependency: ReadonlySelectorToken<unknown> | StateToken<unknown>,\n\tstore: Store,\n): AtomToken<unknown>[] => {\n\tconst roots: AtomToken<unknown>[] = []\n\n\tconst sources = lookupSelectorSources(dependency.key, store)\n\tlet depth = 0\n\twhile (sources.length > 0) {\n\t\t// rome-ignore lint/style/noNonNullAssertion: just checked length ^^^\n\t\tconst source = sources.shift()!\n\t\t++depth\n\t\tif (depth > 999) {\n\t\t\tthrow new Error(\n\t\t\t\t`Maximum selector dependency depth exceeded in selector \"${selectorKey}\".`,\n\t\t\t)\n\t\t}\n\n\t\tif (source.type !== `atom`) {\n\t\t\tsources.push(...lookupSelectorSources(source.key, store))\n\t\t} else {\n\t\t\troots.push(source)\n\t\t}\n\t}\n\n\treturn roots\n}\n\nexport const traceAllSelectorAtoms = (\n\tselectorKey: string,\n\tstore: Store,\n): AtomToken<unknown>[] => {\n\tconst sources = lookupSelectorSources(selectorKey, store)\n\treturn sources.flatMap((source) =>\n\t\tsource.type === `atom`\n\t\t\t? source\n\t\t\t: traceSelectorAtoms(selectorKey, source, store),\n\t)\n}\n","import { traceSelectorAtoms } from \"./trace-selector-atoms\"\nimport type { Store } from \"..\"\nimport { target } from \"..\"\nimport type { ReadonlySelectorToken, StateToken } from \"../..\"\n\nexport const updateSelectorAtoms = (\n\tselectorKey: string,\n\tdependency: ReadonlySelectorToken<unknown> | StateToken<unknown>,\n\tstore: Store,\n): void => {\n\tconst core = target(store)\n\tif (dependency.type === `atom`) {\n\t\tcore.selectorAtoms = core.selectorAtoms.set({\n\t\t\tselectorKey,\n\t\t\tatomKey: dependency.key,\n\t\t})\n\t\tstore.config.logger?.info(\n\t\t\t` || adding root for \"${selectorKey}\": ${dependency.key}`,\n\t\t)\n\t\treturn\n\t}\n\tconst roots = traceSelectorAtoms(selectorKey, dependency, store)\n\tstore.config.logger?.info(\n\t\t` || adding roots for \"${selectorKey}\":`,\n\t\troots.map((r) => r.key),\n\t)\n\tfor (const root of roots) {\n\t\tcore.selectorAtoms = core.selectorAtoms.set({\n\t\t\tselectorKey,\n\t\t\tatomKey: root.key,\n\t\t})\n\t}\n}\n","import { become } from \"~/packages/anvl/src/function\"\n\nimport type { Atom, Selector, Store } from \".\"\nimport {\n\tIMPLICIT,\n\tcacheValue,\n\temitUpdate,\n\tevictCachedValue,\n\tgetState__INTERNAL,\n\tisAtomDefault,\n\tisDone,\n\tmarkAtomAsNotDefault,\n\tmarkDone,\n\tstowUpdate,\n\ttarget,\n} from \".\"\n\nexport const evictDownStream = <T>(\n\tstate: Atom<T>,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tconst downstream = core.selectorAtoms.getRelations(state.key)\n\tconst downstreamKeys = downstream.map(({ id }) => id)\n\tstore.config.logger?.info(\n\t\t` || ${downstreamKeys.length} downstream:`,\n\t\tdownstreamKeys,\n\t)\n\tif (core.operation.open) {\n\t\tstore.config.logger?.info(` ||`, [...core.operation.done], `already done`)\n\t}\n\tdownstream.forEach(({ id: stateKey }) => {\n\t\tif (isDone(stateKey, store)) {\n\t\t\tstore.config.logger?.info(` || ${stateKey} already done`)\n\t\t\treturn\n\t\t}\n\t\tconst state =\n\t\t\tcore.selectors.get(stateKey) ?? core.readonlySelectors.get(stateKey)\n\t\tif (!state) {\n\t\t\tstore.config.logger?.info(\n\t\t\t\t` || ${stateKey} is an atom, and can't be downstream`,\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tevictCachedValue(stateKey, store)\n\t\tstore.config.logger?.info(` xx evicted \"${stateKey}\"`)\n\n\t\tmarkDone(stateKey, store)\n\t})\n}\n\nexport const setAtomState = <T>(\n\tatom: Atom<T>,\n\tnext: T | ((oldValue: T) => T),\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst oldValue = getState__INTERNAL(atom, store)\n\tconst newValue = become(next)(oldValue)\n\tstore.config.logger?.info(`<< setting atom \"${atom.key}\" to`, newValue)\n\tcacheValue(atom.key, newValue, store)\n\tif (isAtomDefault(atom.key, store)) {\n\t\tmarkAtomAsNotDefault(atom.key, store)\n\t}\n\tmarkDone(atom.key, store)\n\tstore.config.logger?.info(\n\t\t` || evicting caches downstream from \"${atom.key}\"`,\n\t)\n\tevictDownStream(atom, store)\n\tconst update = { oldValue, newValue }\n\tif (store.transactionStatus.phase !== `building`) {\n\t\temitUpdate(atom, update, store)\n\t} else {\n\t\tstowUpdate(atom, update, store)\n\t}\n}\nexport const setSelectorState = <T>(\n\tselector: Selector<T>,\n\tnext: T | ((oldValue: T) => T),\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst oldValue = getState__INTERNAL(selector, store)\n\tconst newValue = become(next)(oldValue)\n\n\tstore.config.logger?.info(`<< setting selector \"${selector.key}\" to`, newValue)\n\tstore.config.logger?.info(` || propagating change made to \"${selector.key}\"`)\n\n\tselector.set(newValue)\n}\nexport const setState__INTERNAL = <T>(\n\tstate: Atom<T> | Selector<T>,\n\tvalue: T | ((oldValue: T) => T),\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tif (`set` in state) {\n\t\tsetSelectorState(state, value, store)\n\t} else {\n\t\tsetAtomState(state, value, store)\n\t}\n}\n","import { updateSelectorAtoms } from \"./update-selector-atoms\"\nimport type { Transactors } from \"../../transaction\"\nimport { getState__INTERNAL, withdraw } from \"../get\"\nimport { setState__INTERNAL } from \"../set\"\nimport type { Store } from \"../store\"\nimport { IMPLICIT } from \"../store\"\nimport { target } from \"../transaction-internal\"\n\nexport const registerSelector = (\n\tselectorKey: string,\n\tstore: Store = IMPLICIT.STORE,\n): Transactors => ({\n\tget: (dependency) => {\n\t\tconst core = target(store)\n\t\tconst alreadyRegistered = core.selectorGraph\n\t\t\t.getRelations(selectorKey)\n\t\t\t.some(({ source }) => source === dependency.key)\n\n\t\tconst dependencyState = withdraw(dependency, store)\n\t\tif (dependencyState === null) {\n\t\t\tthrow new Error(\n\t\t\t\t`State \"${dependency.key}\" not found in this store. Did you forget to initialize with the \"atom\" or \"selector\" function?`,\n\t\t\t)\n\t\t}\n\t\tconst dependencyValue = getState__INTERNAL(dependencyState, store)\n\n\t\tif (alreadyRegistered) {\n\t\t\tstore.config.logger?.info(\n\t\t\t\t` || ${selectorKey} <- ${dependency.key} =`,\n\t\t\t\tdependencyValue,\n\t\t\t)\n\t\t} else {\n\t\t\tstore.config.logger?.info(\n\t\t\t\t`🔌 registerSelector \"${selectorKey}\" <- ( \"${dependency.key}\" =`,\n\t\t\t\tdependencyValue,\n\t\t\t\t`)`,\n\t\t\t)\n\t\t\tcore.selectorGraph = core.selectorGraph.set(\n\t\t\t\t{ from: dependency.key, to: selectorKey },\n\t\t\t\t{\n\t\t\t\t\tsource: dependency.key,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tupdateSelectorAtoms(selectorKey, dependency, store)\n\t\treturn dependencyValue\n\t},\n\tset: (stateToken, newValue) => {\n\t\tconst state = withdraw(stateToken, store)\n\t\tif (state === null) {\n\t\t\tthrow new Error(\n\t\t\t\t`State \"${stateToken.key}\" not found in this store. Did you forget to initialize with the \"atom\" or \"selector\" function?`,\n\t\t\t)\n\t\t}\n\t\tsetState__INTERNAL(state, newValue, store)\n\t},\n})\n","import { registerSelector } from \"./register-selector\"\nimport { Subject } from \"..\"\nimport type {\n\tFamilyMetadata,\n\tReadonlySelectorOptions,\n\tReadonlySelectorToken,\n\tStore,\n} from \"../..\"\nimport { cacheValue } from \"../operation\"\nimport { selector__INTERNAL, type ReadonlySelector } from \"../selector-internal\"\nimport type { StoreCore } from \"../store\"\n\nexport const createReadonlySelector = <T>(\n\toptions: ReadonlySelectorOptions<T>,\n\tfamily: FamilyMetadata | undefined,\n\tstore: Store,\n\tcore: StoreCore,\n): ReadonlySelectorToken<T> => {\n\tconst subject = new Subject<{ newValue: T; oldValue: T }>()\n\n\tconst { get } = registerSelector(options.key, store)\n\tconst getSelf = () => {\n\t\tconst value = options.get({ get })\n\t\tcacheValue(options.key, value, store)\n\t\treturn value\n\t}\n\n\tconst readonlySelector: ReadonlySelector<T> = {\n\t\t...options,\n\t\tsubject,\n\t\tinstall: (s: Store) => selector__INTERNAL(options, family, s),\n\t\tget: getSelf,\n\t\ttype: `readonly_selector`,\n\t\t...(family && { family }),\n\t}\n\tcore.readonlySelectors.set(options.key, readonlySelector)\n\tconst initialValue = getSelf()\n\tstore.config.logger?.info(` ✨ \"${options.key}\" =`, initialValue)\n\tconst token: ReadonlySelectorToken<T> = {\n\t\tkey: options.key,\n\t\ttype: `readonly_selector`,\n\t\tfamily,\n\t}\n\tstore.subject.selectorCreation.next(token)\n\treturn token\n}\n","import { target, IMPLICIT } from \".\"\nimport type { Store, Subject } from \".\"\nimport { createReadWriteSelector } from \"./selector/create-read-write-selector\"\nimport { createReadonlySelector } from \"./selector/create-readonly-selector\"\nimport type {\n\tFamilyMetadata,\n\tReadonlySelectorOptions,\n\tReadonlySelectorToken,\n\tSelectorOptions,\n\tSelectorToken,\n} from \"..\"\n\nexport type Selector<T> = {\n\tkey: string\n\ttype: `selector`\n\tfamily?: FamilyMetadata\n\tinstall: (store: Store) => void\n\tsubject: Subject<{ newValue: T; oldValue: T }>\n\tget: () => T\n\tset: (newValue: T | ((oldValue: T) => T)) => void\n}\nexport type ReadonlySelector<T> = {\n\tkey: string\n\ttype: `readonly_selector`\n\tfamily?: FamilyMetadata\n\tinstall: (store: Store) => void\n\tsubject: Subject<{ newValue: T; oldValue: T }>\n\tget: () => T\n}\n\nexport function selector__INTERNAL<T>(\n\toptions: SelectorOptions<T>,\n\tfamily?: FamilyMetadata,\n\tstore?: Store,\n): SelectorToken<T>\nexport function selector__INTERNAL<T>(\n\toptions: ReadonlySelectorOptions<T>,\n\tfamily?: FamilyMetadata,\n\tstore?: Store,\n): ReadonlySelectorToken<T>\nexport function selector__INTERNAL<T>(\n\toptions: ReadonlySelectorOptions<T> | SelectorOptions<T>,\n\tfamily?: FamilyMetadata,\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorToken<T> | SelectorToken<T> {\n\tconst core = target(store)\n\n\tif (core.selectors.has(options.key)) {\n\t\tstore.config.logger?.error(\n\t\t\t`Key \"${options.key}\" already exists in the store.`,\n\t\t)\n\t}\n\n\tif (!(`set` in options)) {\n\t\treturn createReadonlySelector(options, family, store, core)\n\t}\n\treturn createReadWriteSelector(options, family, store, core)\n}\n","type Subscriber<T> = (value: T) => void\n\nexport class Subject<T> {\n\tpublic subscribers: Subscriber<T>[] = []\n\n\tpublic subscribe(subscriber: Subscriber<T>): { unsubscribe: () => void } {\n\t\tthis.subscribers.push(subscriber)\n\t\tconst unsubscribe = () => this.unsubscribe(subscriber)\n\t\treturn { unsubscribe }\n\t}\n\n\tprivate unsubscribe(subscriber: Subscriber<T>) {\n\t\tconst subscriberIndex = this.subscribers.indexOf(subscriber)\n\t\tif (subscriberIndex !== -1) {\n\t\t\tthis.subscribers.splice(subscriberIndex, 1)\n\t\t}\n\t}\n\n\tpublic next(value: T): void {\n\t\tfor (const subscriber of this.subscribers) {\n\t\t\tsubscriber(value)\n\t\t}\n\t}\n}\n","import type { Atom, ReadonlySelector, Selector, Store } from \".\"\nimport {\n\tgetState__INTERNAL,\n\twithdraw,\n\trecallState,\n\ttraceAllSelectorAtoms,\n} from \".\"\nimport type { StateUpdate } from \"..\"\n\nexport const prepareUpdate = <T>(\n\tstate: Atom<T> | ReadonlySelector<T> | Selector<T>,\n\tstore: Store,\n): StateUpdate<T> => {\n\tconst oldValue = recallState(state, store)\n\tconst newValue = getState__INTERNAL(state, store)\n\treturn { newValue, oldValue }\n}\n\nexport const stowUpdate = <T>(\n\tstate: Atom<T>,\n\tupdate: StateUpdate<T>,\n\tstore: Store,\n): void => {\n\tconst { key } = state\n\tconst { logger } = store.config\n\tif (store.transactionStatus.phase !== `building`) {\n\t\tstore.config.logger?.warn(\n\t\t\t`stowUpdate called outside of a transaction. This is probably a bug.`,\n\t\t)\n\t\treturn\n\t}\n\tstore.transactionStatus.atomUpdates.push({ key, ...update })\n\tlogger?.info(`📝 ${key} stowed (`, update.oldValue, `->`, update.newValue, `)`)\n}\n\nexport const emitUpdate = <T>(\n\tstate: Atom<T> | ReadonlySelector<T> | Selector<T>,\n\tupdate: StateUpdate<T>,\n\tstore: Store,\n): void => {\n\tconst { key } = state\n\tconst { logger } = store.config\n\tlogger?.info(\n\t\t`📢 ${state.type} \"${key}\" went (`,\n\t\tupdate.oldValue,\n\t\t`->`,\n\t\tupdate.newValue,\n\t\t`)`,\n\t)\n\tstate.subject.next(update)\n}\n\nexport const subscribeToRootAtoms = <T>(\n\tstate: ReadonlySelector<T> | Selector<T>,\n\tstore: Store,\n): { unsubscribe: () => void }[] | null => {\n\tconst dependencySubscriptions =\n\t\t`default` in state\n\t\t\t? null\n\t\t\t: traceAllSelectorAtoms(state.key, store).map((atomToken) => {\n\t\t\t\t\tconst atom = withdraw(atomToken, store)\n\t\t\t\t\tif (atom === null) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Atom \"${atomToken.key}\", a dependency of selector \"${state.key}\", not found in store \"${store.config.name}\".`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\treturn atom.subject.subscribe((atomChange) => {\n\t\t\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t\t\t`📢 selector \"${state.key}\" saw root \"${atomToken.key}\" go (`,\n\t\t\t\t\t\t\tatomChange.oldValue,\n\t\t\t\t\t\t\t`->`,\n\t\t\t\t\t\t\tatomChange.newValue,\n\t\t\t\t\t\t\t`)`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tconst oldValue = recallState(state, store)\n\t\t\t\t\t\tconst newValue = getState__INTERNAL(state, store)\n\t\t\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t\t\t` <- \"${state.key}\" went (`,\n\t\t\t\t\t\t\toldValue,\n\t\t\t\t\t\t\t`->`,\n\t\t\t\t\t\t\tnewValue,\n\t\t\t\t\t\t\t`)`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tstate.subject.next({ newValue, oldValue })\n\t\t\t\t\t})\n\t\t\t })\n\treturn dependencySubscriptions\n}\n","import type { Store } from \".\"\nimport { IMPLICIT } from \".\"\nimport type { TimelineToken } from \"..\"\nimport { setState } from \"..\"\n\nexport const redo__INTERNAL = (\n\ttoken: TimelineToken,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tstore.config.logger?.info(`⏩ redo \"${token.key}\"`)\n\tconst timelineData = store.timelines.get(token.key)\n\tif (!timelineData) {\n\t\tstore.config.logger?.error(\n\t\t\t`Failed to redo on timeline \"${token.key}\". This timeline has not been initialized.`,\n\t\t)\n\t\treturn\n\t}\n\tif (timelineData.at === timelineData.history.length) {\n\t\tstore.config.logger?.warn(\n\t\t\t`Failed to redo at the end of timeline \"${token.key}\". There is nothing to redo.`,\n\t\t)\n\t\treturn\n\t}\n\ttimelineData.timeTraveling = true\n\tconst update = timelineData.history[timelineData.at]\n\tswitch (update.type) {\n\t\tcase `atom_update`: {\n\t\t\tconst { key, newValue } = update\n\t\t\tsetState({ key, type: `atom` }, newValue, store)\n\t\t\tbreak\n\t\t}\n\t\tcase `selector_update`:\n\t\tcase `transaction_update`: {\n\t\t\tfor (const atomUpdate of update.atomUpdates) {\n\t\t\t\tconst { key, newValue } = atomUpdate\n\t\t\t\tsetState({ key, type: `atom` }, newValue, store)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\t++timelineData.at\n\ttimelineData.subject.next(`redo`)\n\ttimelineData.timeTraveling = false\n\tstore.config.logger?.info(\n\t\t`⏹️ \"${token.key}\" is now at ${timelineData.at} / ${timelineData.history.length}`,\n\t)\n}\n\nexport const undo__INTERNAL = (\n\ttoken: TimelineToken,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tstore.config.logger?.info(`⏪ undo \"${token.key}\"`)\n\tconst timelineData = store.timelines.get(token.key)\n\tif (!timelineData) {\n\t\tstore.config.logger?.error(\n\t\t\t`Failed to undo on timeline \"${token.key}\". This timeline has not been initialized.`,\n\t\t)\n\t\treturn\n\t}\n\tif (timelineData.at === 0) {\n\t\tstore.config.logger?.warn(\n\t\t\t`Failed to undo at the beginning of timeline \"${token.key}\". There is nothing to undo.`,\n\t\t)\n\t\treturn\n\t}\n\ttimelineData.timeTraveling = true\n\n\t--timelineData.at\n\tconst update = timelineData.history[timelineData.at]\n\tswitch (update.type) {\n\t\tcase `atom_update`: {\n\t\t\tconst { key, oldValue } = update\n\t\t\tsetState({ key, type: `atom` }, oldValue, store)\n\t\t\tbreak\n\t\t}\n\t\tcase `selector_update`:\n\t\tcase `transaction_update`: {\n\t\t\tfor (const atomUpdate of update.atomUpdates) {\n\t\t\t\tconst { key, oldValue } = atomUpdate\n\t\t\t\tsetState({ key, type: `atom` }, oldValue, store)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\ttimelineData.subject.next(`undo`)\n\ttimelineData.timeTraveling = false\n\tstore.config.logger?.info(\n\t\t`⏹️ \"${token.key}\" is now at ${timelineData.at} / ${timelineData.history.length}`,\n\t)\n}\n","import { IMPLICIT, withdraw } from \"..\"\nimport type {\n\tTimeline,\n\tStore,\n\tTimelineTransactionUpdate,\n\tTimelineAtomUpdate,\n} from \"..\"\nimport type { AtomFamily, AtomToken, TimelineUpdate } from \"../..\"\n\nexport const addAtomToTimeline = (\n\tatomToken: AtomToken<any>,\n\tatoms: (AtomFamily<any> | AtomToken<any>)[],\n\ttl: Timeline,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst atom = withdraw(atomToken, store)\n\tif (atom === null) {\n\t\tthrow new Error(\n\t\t\t`Cannot subscribe to atom \"${atomToken.key}\" because it has not been initialized in store \"${store.config.name}\"`,\n\t\t)\n\t}\n\tatom.subject.subscribe((update) => {\n\t\tconst currentSelectorKey =\n\t\t\tstore.operation.open && store.operation.token.type === `selector`\n\t\t\t\t? store.operation.token.key\n\t\t\t\t: null\n\t\tconst currentSelectorTime =\n\t\t\tstore.operation.open && store.operation.token.type === `selector`\n\t\t\t\t? store.operation.time\n\t\t\t\t: null\n\t\tconst currentTransactionKey =\n\t\t\tstore.transactionStatus.phase === `applying`\n\t\t\t\t? store.transactionStatus.key\n\t\t\t\t: null\n\t\tconst currentTransactionTime =\n\t\t\tstore.transactionStatus.phase === `applying`\n\t\t\t\t? store.transactionStatus.time\n\t\t\t\t: null\n\n\t\tstore.config.logger?.info(\n\t\t\t`⏳ timeline \"${tl.key}\" saw atom \"${atomToken.key}\" go (`,\n\t\t\tupdate.oldValue,\n\t\t\t`->`,\n\t\t\tupdate.newValue,\n\t\t\tcurrentTransactionKey\n\t\t\t\t? `) in transaction \"${currentTransactionKey}\"`\n\t\t\t\t: currentSelectorKey\n\t\t\t\t? `) in selector \"${currentSelectorKey}\"`\n\t\t\t\t: `)`,\n\t\t)\n\n\t\tif (tl.timeTraveling === false) {\n\t\t\tif (tl.selectorTime && tl.selectorTime !== currentSelectorTime) {\n\t\t\t\tconst mostRecentUpdate: TimelineUpdate | undefined = tl.history.at(-1)\n\t\t\t\tif (mostRecentUpdate === undefined) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Timeline \"${tl.key}\" has a selectorTime, but no history. This is most likely a bug in AtomIO.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\tcurrentTransactionKey &&\n\t\t\t\tstore.transactionStatus.phase === `applying`\n\t\t\t) {\n\t\t\t\tconst currentTransaction = withdraw(\n\t\t\t\t\t{ key: currentTransactionKey, type: `transaction` },\n\t\t\t\t\tstore,\n\t\t\t\t)\n\t\t\t\tif (currentTransaction === null) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Transaction \"${currentTransactionKey}\" not found in store \"${store.config.name}\". This is surprising, because we are in the application phase of \"${currentTransactionKey}\".`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (tl.transactionKey !== currentTransactionKey) {\n\t\t\t\t\tif (tl.transactionKey) {\n\t\t\t\t\t\tstore.config.logger?.error(\n\t\t\t\t\t\t\t`Timeline \"${tl.key}\" was unable to resolve transaction \"${tl.transactionKey}. This is probably a bug.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\ttl.transactionKey = currentTransactionKey\n\t\t\t\t\tconst subscription = currentTransaction.subject.subscribe((update) => {\n\t\t\t\t\t\tsubscription.unsubscribe()\n\t\t\t\t\t\tif (tl.timeTraveling === false && currentTransactionTime) {\n\t\t\t\t\t\t\tif (tl.at !== tl.history.length) {\n\t\t\t\t\t\t\t\ttl.history.splice(tl.at)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst timelineTransactionUpdate: TimelineTransactionUpdate = {\n\t\t\t\t\t\t\t\ttype: `transaction_update`,\n\t\t\t\t\t\t\t\ttimestamp: currentTransactionTime,\n\t\t\t\t\t\t\t\t...update,\n\t\t\t\t\t\t\t\tatomUpdates: update.atomUpdates.filter((atomUpdate) =>\n\t\t\t\t\t\t\t\t\tatoms.some((atom) => atom.key === atomUpdate.key),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttl.history.push(timelineTransactionUpdate)\n\t\t\t\t\t\t\ttl.at = tl.history.length\n\t\t\t\t\t\t\ttl.subject.next(timelineTransactionUpdate)\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttl.transactionKey = null\n\t\t\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t\t\t`⌛ timeline \"${tl.key}\" got a transaction_update \"${update.key}\"`,\n\t\t\t\t\t\t)\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t} else if (currentSelectorKey && currentSelectorTime) {\n\t\t\t\tlet latestUpdate: TimelineUpdate | undefined = tl.history.at(-1)\n\n\t\t\t\tif (currentSelectorTime !== tl.selectorTime) {\n\t\t\t\t\tlatestUpdate = {\n\t\t\t\t\t\ttype: `selector_update`,\n\t\t\t\t\t\ttimestamp: currentSelectorTime,\n\t\t\t\t\t\tkey: currentSelectorKey,\n\t\t\t\t\t\tatomUpdates: [],\n\t\t\t\t\t}\n\t\t\t\t\tlatestUpdate.atomUpdates.push({\n\t\t\t\t\t\tkey: atom.key,\n\t\t\t\t\t\ttype: `atom_update`,\n\t\t\t\t\t\t...update,\n\t\t\t\t\t})\n\t\t\t\t\tif (tl.at !== tl.history.length) {\n\t\t\t\t\t\ttl.history.splice(tl.at)\n\t\t\t\t\t}\n\t\t\t\t\ttl.history.push(latestUpdate)\n\n\t\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t\t`⌛ timeline \"${tl.key}\" got a selector_update \"${currentSelectorKey}\" with`,\n\t\t\t\t\t\tlatestUpdate.atomUpdates.map((atomUpdate) => atomUpdate.key),\n\t\t\t\t\t)\n\n\t\t\t\t\ttl.at = tl.history.length\n\t\t\t\t\ttl.selectorTime = currentSelectorTime\n\t\t\t\t} else {\n\t\t\t\t\tif (latestUpdate?.type === `selector_update`) {\n\t\t\t\t\t\tlatestUpdate.atomUpdates.push({\n\t\t\t\t\t\t\tkey: atom.key,\n\t\t\t\t\t\t\ttype: `atom_update`,\n\t\t\t\t\t\t\t...update,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t\t\t` ⌛ timeline \"${tl.key}\" set selector_update \"${currentSelectorKey}\" to`,\n\t\t\t\t\t\t\tlatestUpdate?.atomUpdates.map((atomUpdate) => atomUpdate.key),\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (latestUpdate) tl.subject.next(latestUpdate)\n\t\t\t} else {\n\t\t\t\tconst timestamp = Date.now()\n\t\t\t\ttl.selectorTime = null\n\t\t\t\tif (tl.at !== tl.history.length) {\n\t\t\t\t\ttl.history.splice(tl.at)\n\t\t\t\t}\n\t\t\t\tconst atomUpdate: TimelineAtomUpdate = {\n\t\t\t\t\ttype: `atom_update`,\n\t\t\t\t\ttimestamp,\n\t\t\t\t\tkey: atom.key,\n\t\t\t\t\toldValue: update.oldValue,\n\t\t\t\t\tnewValue: update.newValue,\n\t\t\t\t}\n\t\t\t\ttl.history.push(atomUpdate)\n\t\t\t\ttl.subject.next(atomUpdate)\n\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t`⌛ timeline \"${tl.key}\" got an atom_update to \"${atom.key}\"`,\n\t\t\t\t)\n\t\t\t\ttl.at = tl.history.length\n\t\t\t}\n\t\t}\n\t})\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \".\"\nimport { Subject, target, IMPLICIT } from \".\"\nimport { addAtomToTimeline } from \"./timeline/add-atom-to-timeline\"\nimport type {\n\tStateUpdate,\n\tTimelineOptions,\n\tTimelineToken,\n\tTimelineUpdate,\n\tTransactionUpdate,\n} from \"..\"\n\nexport type TimelineAtomUpdate = StateUpdate<unknown> & {\n\tkey: string\n\ttype: `atom_update`\n\ttimestamp: number\n}\nexport type TimelineSelectorUpdate = {\n\tkey: string\n\ttype: `selector_update`\n\ttimestamp: number\n\tatomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[]\n}\nexport type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {\n\tkey: string\n\ttype: `transaction_update`\n\ttimestamp: number\n}\n\nexport type Timeline = {\n\tkey: string\n\tat: number\n\ttimeTraveling: boolean\n\thistory: TimelineUpdate[]\n\tselectorTime: number | null\n\ttransactionKey: string | null\n\tinstall: (store: Store) => void\n\tsubject: Subject<\n\t\t| TimelineAtomUpdate\n\t\t| TimelineSelectorUpdate\n\t\t| TimelineTransactionUpdate\n\t\t| `redo`\n\t\t| `undo`\n\t>\n}\n\nexport function timeline__INTERNAL(\n\toptions: TimelineOptions,\n\tstore: Store = IMPLICIT.STORE,\n\tdata: Timeline | null = null,\n): TimelineToken {\n\tconst tl: Timeline = {\n\t\tkey: options.key,\n\t\tat: 0,\n\t\ttimeTraveling: false,\n\t\tselectorTime: null,\n\t\ttransactionKey: null,\n\t\t...data,\n\t\thistory: data?.history.map((update) => ({ ...update })) ?? [],\n\t\tinstall: (store) => timeline__INTERNAL(options, store, tl),\n\t\tsubject: new Subject(),\n\t}\n\n\tconst core = target(store)\n\tfor (const tokenOrFamily of options.atoms) {\n\t\tconst timelineKey = core.timelineAtoms.getRelatedId(tokenOrFamily.key)\n\t\tif (timelineKey) {\n\t\t\tstore.config.logger?.error(\n\t\t\t\t`❌ Failed to add atom \"${tokenOrFamily.key}\" to timeline \"${options.key}\" because it belongs to timeline \"${timelineKey}\"`,\n\t\t\t)\n\t\t\tcontinue\n\t\t}\n\t\tif (tokenOrFamily.type === `atom_family`) {\n\t\t\tconst family = tokenOrFamily\n\t\t\tfamily.subject.subscribe((token) =>\n\t\t\t\taddAtomToTimeline(token, options.atoms, tl, store),\n\t\t\t)\n\t\t} else {\n\t\t\tconst token = tokenOrFamily\n\t\t\tif (`family` in token && token.family) {\n\t\t\t\tconst familyTimelineKey = core.timelineAtoms.getRelatedId(\n\t\t\t\t\ttoken.family.key,\n\t\t\t\t)\n\t\t\t\tif (familyTimelineKey) {\n\t\t\t\t\tstore.config.logger?.error(\n\t\t\t\t\t\t`❌ Failed to add atom \"${token.key}\" to timeline \"${options.key}\" because its family \"${token.family.key}\" belongs to timeline \"${familyTimelineKey}\"`,\n\t\t\t\t\t)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\taddAtomToTimeline(token, options.atoms, tl, store)\n\t\t}\n\t\tcore.timelineAtoms = core.timelineAtoms.set({\n\t\t\tatomKey: tokenOrFamily.key,\n\t\t\ttimelineKey: options.key,\n\t\t})\n\t}\n\n\tstore.timelines.set(options.key, tl)\n\tconst token: TimelineToken = {\n\t\tkey: options.key,\n\t\ttype: `timeline`,\n\t}\n\tstore.subject.timelineCreation.next(token)\n\treturn token\n}\n","import type { Store } from \"..\"\n\nexport const abortTransaction = (store: Store): void => {\n\tif (store.transactionStatus.phase === `idle`) {\n\t\tstore.config.logger?.warn(\n\t\t\t`abortTransaction called outside of a transaction. This is probably a bug.`,\n\t\t)\n\t\treturn\n\t}\n\tstore.transactionStatus = { phase: `idle` }\n\tstore.config.logger?.info(`🪂`, `transaction fail`)\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \"..\"\nimport { withdraw } from \"..\"\nimport type { AtomToken } from \"../..\"\nimport { setState } from \"../..\"\n\nexport const applyTransaction = <ƒ extends ƒn>(\n\toutput: ReturnType<ƒ>,\n\tstore: Store,\n): void => {\n\tif (store.transactionStatus.phase !== `building`) {\n\t\tstore.config.logger?.warn(\n\t\t\t`abortTransaction called outside of a transaction. This is probably a bug.`,\n\t\t)\n\t\treturn\n\t}\n\tstore.config.logger?.info(\n\t\t`🛃 apply transaction \"${store.transactionStatus.key}\"`,\n\t)\n\tstore.transactionStatus.phase = `applying`\n\tstore.transactionStatus.output = output\n\tconst { atomUpdates } = store.transactionStatus\n\n\tfor (const { key, newValue } of atomUpdates) {\n\t\tconst token: AtomToken<unknown> = { key, type: `atom` }\n\t\tif (!store.valueMap.has(token.key)) {\n\t\t\tconst newAtom = store.transactionStatus.core.atoms.get(token.key)\n\t\t\tif (!newAtom) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Absurd Error: Atom \"${token.key}\" not found while copying updates from transaction \"${store.transactionStatus.key}\" to store \"${store.config.name}\"`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tstore.atoms.set(newAtom.key, newAtom)\n\t\t\tstore.valueMap.set(newAtom.key, newAtom.default)\n\t\t\tstore.config.logger?.info(`🔧`, `add atom \"${newAtom.key}\"`)\n\t\t}\n\t\tsetState(token, newValue, store)\n\t}\n\tconst myTransaction = withdraw<ƒ>(\n\t\t{ key: store.transactionStatus.key, type: `transaction` },\n\t\tstore,\n\t)\n\tif (myTransaction === null) {\n\t\tthrow new Error(\n\t\t\t`Transaction \"${store.transactionStatus.key}\" not found. Absurd. How is this running?`,\n\t\t)\n\t}\n\tmyTransaction.subject.next({\n\t\tkey: store.transactionStatus.key,\n\t\tatomUpdates,\n\t\toutput,\n\t\tparams: store.transactionStatus.params as Parameters<ƒ>,\n\t})\n\tstore.transactionStatus = { phase: `idle` }\n\tstore.config.logger?.info(`🛬`, `transaction done`)\n}\n","import type { Store } from \"..\"\n\nexport const buildTransaction = (\n\tkey: string,\n\tparams: any[],\n\tstore: Store,\n): void => {\n\tstore.transactionStatus = {\n\t\tkey,\n\t\tphase: `building`,\n\t\ttime: Date.now(),\n\t\tcore: {\n\t\t\tatoms: new Map(store.atoms),\n\t\t\tatomsThatAreDefault: store.atomsThatAreDefault,\n\t\t\toperation: { open: false },\n\t\t\treadonlySelectors: new Map(store.readonlySelectors),\n\t\t\ttimelines: new Map(store.timelines),\n\t\t\ttimelineAtoms: store.timelineAtoms,\n\t\t\ttransactions: new Map(store.transactions),\n\t\t\tselectorAtoms: store.selectorAtoms,\n\t\t\tselectorGraph: store.selectorGraph,\n\t\t\tselectors: new Map(store.selectors),\n\t\t\tvalueMap: new Map(store.valueMap),\n\t\t},\n\t\tatomUpdates: [],\n\t\tparams,\n\t\toutput: undefined,\n\t}\n\tstore.config.logger?.info(\n\t\t`🛫`,\n\t\t`transaction \"${key}\" started in store \"${store.config.name}\"`,\n\t)\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \"..\"\nimport { withdraw } from \"..\"\nimport type { AtomToken, TransactionUpdate } from \"../..\"\nimport { setState } from \"../..\"\n\nexport const redoTransactionUpdate = <ƒ extends ƒn>(\n\tupdate: TransactionUpdate<ƒ>,\n\tstore: Store,\n): void => {\n\tstore.config.logger?.info(` ⏭ redo transaction \"${update.key}\" (redo)`)\n\tfor (const { key, newValue } of update.atomUpdates) {\n\t\tconst token: AtomToken<unknown> = { key, type: `atom` }\n\t\tconst state = withdraw(token, store)\n\t\tif (state === null) {\n\t\t\tthrow new Error(\n\t\t\t\t`State \"${token.key}\" not found in this store. This is surprising, because we are navigating the history of the store.`,\n\t\t\t)\n\t\t}\n\t\tsetState(state, newValue, store)\n\t}\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \"..\"\nimport { withdraw } from \"..\"\nimport type { AtomToken, TransactionUpdate } from \"../..\"\nimport { setState } from \"../..\"\n\nexport const undoTransactionUpdate = <ƒ extends ƒn>(\n\tupdate: TransactionUpdate<ƒ>,\n\tstore: Store,\n): void => {\n\tstore.config.logger?.info(` ⏮ undo transaction \"${update.key}\" (undo)`)\n\tfor (const { key, oldValue } of update.atomUpdates) {\n\t\tconst token: AtomToken<unknown> = { key, type: `atom` }\n\t\tconst state = withdraw(token, store)\n\t\tif (state === null) {\n\t\t\tthrow new Error(\n\t\t\t\t`State \"${token.key}\" not found in this store. This is surprising, because we are navigating the history of the store.`,\n\t\t\t)\n\t\t}\n\t\tsetState(state, oldValue, store)\n\t}\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { StoreCore } from \"..\"\nimport type { StateUpdate, TransactionUpdate } from \"../..\"\n\nexport * from \"./abort-transaction\"\nexport * from \"./apply-transaction\"\nexport * from \"./build-transaction\"\nexport * from \"./redo-transaction\"\nexport * from \"./undo-transaction\"\n\nexport const TRANSACTION_PHASES = [`idle`, `building`, `applying`] as const\nexport type TransactionPhase = typeof TRANSACTION_PHASES[number]\n\nexport type TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdate<ƒ> & {\n\tphase: `applying` | `building`\n\ttime: number\n\tcore: StoreCore\n}\nexport type TransactionIdle = {\n\tphase: `idle`\n}\nexport type TransactionStatus<ƒ extends ƒn> =\n\t| TransactionIdle\n\t| TransactionUpdateInProgress<ƒ>\n","import type { Serializable } from \"~/packages/anvl/src/json\"\n\nimport type { AtomToken } from \".\"\nimport type { Subject } from \"./internal\"\nimport { atomFamily__INTERNAL, atom__INTERNAL } from \"./internal\"\n\nexport type Effectors<T> = {\n\tsetSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void\n\tonSet: (callback: (options: { newValue: T; oldValue: T }) => void) => void\n}\n\nexport type AtomEffect<T> = (tools: Effectors<T>) => void\n\nexport type AtomOptions<T> = {\n\tkey: string\n\tdefault: T | (() => T)\n\teffects?: AtomEffect<T>[]\n}\n\nexport function atom<T>(options: AtomOptions<T>): AtomToken<T> {\n\treturn atom__INTERNAL<T>(options)\n}\n\nexport type AtomFamilyOptions<T, K extends Serializable> = {\n\tkey: string\n\tdefault: T | ((key: K) => T)\n\teffects?: (key: K) => AtomEffect<T>[]\n}\n\nexport type AtomFamily<T, K extends Serializable = Serializable> = ((\n\tkey: K,\n) => AtomToken<T>) & {\n\tkey: string\n\ttype: `atom_family`\n\tsubject: Subject<AtomToken<T>>\n}\n\nexport function atomFamily<T, K extends Serializable>(\n\toptions: AtomFamilyOptions<T, K>,\n): AtomFamily<T, K> {\n\treturn atomFamily__INTERNAL<T, K>(options)\n}\n","import { doNothing } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \"./internal/store\"\nimport { IMPLICIT } from \"./internal/store\"\n\nexport type Logger = Pick<Console, `error` | `info` | `warn`>\nexport const LOG_LEVELS: ReadonlyArray<keyof Logger> = [\n\t`info`,\n\t`warn`,\n\t`error`,\n] as const\n\nexport const setLogLevel = (\n\tpreferredLevel: `error` | `info` | `warn` | null,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst { logger__INTERNAL } = store.config\n\tif (preferredLevel === null) {\n\t\tstore.config.logger = null\n\t} else {\n\t\tstore.config.logger = { ...console }\n\t\tLOG_LEVELS.forEach((logLevel) => {\n\t\t\tif (LOG_LEVELS.indexOf(logLevel) < LOG_LEVELS.indexOf(preferredLevel)) {\n\t\t\t\t// rome-ignore lint/style/noNonNullAssertion: we just set it\n\t\t\t\tstore.config.logger![logLevel] = doNothing\n\t\t\t} else {\n\t\t\t\t// rome-ignore lint/style/noNonNullAssertion: we just set it\n\t\t\t\tstore.config.logger![logLevel] = logger__INTERNAL[logLevel]\n\t\t\t}\n\t\t})\n\t}\n}\n\nexport const useLogger = (\n\tlogger: Logger,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst currentLogLevel =\n\t\tstore.config.logger === null\n\t\t\t? null\n\t\t\t: LOG_LEVELS.find(\n\t\t\t\t\t(logLevel) => store.config.logger?.[logLevel] !== doNothing,\n\t\t\t ) ?? null\n\tstore.config.logger__INTERNAL = { ...logger }\n\tsetLogLevel(currentLogLevel, store)\n}\n","import type { Serializable } from \"~/packages/anvl/src/json\"\n\nimport type { ReadonlySelectorToken, SelectorToken } from \".\"\nimport type { Subject } from \"./internal\"\nimport { selectorFamily__INTERNAL, selector__INTERNAL } from \"./internal\"\nimport type { Read, Write } from \"./transaction\"\n\nexport type SelectorOptions<T> = {\n\tkey: string\n\tget: Read<() => T>\n\tset: Write<(newValue: T) => void>\n}\nexport type ReadonlySelectorOptions<T> = {\n\tkey: string\n\tget: Read<() => T>\n}\n\nexport function selector<T>(options: SelectorOptions<T>): SelectorToken<T>\nexport function selector<T>(\n\toptions: ReadonlySelectorOptions<T>,\n): ReadonlySelectorToken<T>\nexport function selector<T>(\n\toptions: ReadonlySelectorOptions<T> | SelectorOptions<T>,\n): ReadonlySelectorToken<T> | SelectorToken<T> {\n\treturn selector__INTERNAL(options)\n}\n\nexport type SelectorFamilyOptions<T, K extends Serializable> = {\n\tkey: string\n\tget: (key: K) => Read<() => T>\n\tset: (key: K) => Write<(newValue: T) => void>\n}\nexport type ReadonlySelectorFamilyOptions<T, K extends Serializable> = {\n\tkey: string\n\tget: (key: K) => Read<() => T>\n}\n\nexport type SelectorFamily<T, K extends Serializable = Serializable> = ((\n\tkey: K,\n) => SelectorToken<T>) & {\n\tkey: string\n\ttype: `selector_family`\n\tsubject: Subject<SelectorToken<T>>\n}\n\nexport type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((\n\tkey: K,\n) => ReadonlySelectorToken<T>) & {\n\tkey: string\n\ttype: `readonly_selector_family`\n\tsubject: Subject<ReadonlySelectorToken<T>>\n}\n\nexport function selectorFamily<T, K extends Serializable>(\n\toptions: SelectorFamilyOptions<T, K>,\n): SelectorFamily<T, K>\nexport function selectorFamily<T, K extends Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K>,\n): ReadonlySelectorFamily<T, K>\nexport function selectorFamily<T, K extends Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K> | SelectorFamilyOptions<T, K>,\n): ReadonlySelectorFamily<T, K> | SelectorFamily<T, K> {\n\treturn selectorFamily__INTERNAL(options)\n}\n","import type { redo, timeline, undo } from \".\"\nimport { getState, setState, subscribe } from \".\"\nimport type { atom, atomFamily } from \"./atom\"\nimport type { Store } from \"./internal\"\nimport {\n\tatomFamily__INTERNAL,\n\tatom__INTERNAL,\n\tcreateStore,\n\tredo__INTERNAL,\n\tselectorFamily__INTERNAL,\n\tselector__INTERNAL,\n\ttimeline__INTERNAL,\n\ttransaction__INTERNAL,\n\tundo__INTERNAL,\n} from \"./internal\"\nimport type { selector, selectorFamily } from \"./selector\"\nimport type { transaction } from \"./transaction\"\n\nexport type Silo = ReturnType<typeof silo>\n\nexport const silo = (\n\tname: string,\n\tfromStore: Store | null = null,\n): {\n\tstore: Store\n\tatom: typeof atom\n\tatomFamily: typeof atomFamily\n\tselector: typeof selector\n\tselectorFamily: typeof selectorFamily\n\ttransaction: typeof transaction\n\ttimeline: typeof timeline\n\tgetState: typeof getState\n\tsetState: typeof setState\n\tsubscribe: typeof subscribe\n\tundo: typeof undo\n\tredo: typeof redo\n} => {\n\tconst store = createStore(name, fromStore)\n\treturn {\n\t\tstore,\n\t\tatom: (options) => atom__INTERNAL(options, undefined, store),\n\t\tatomFamily: (options) => atomFamily__INTERNAL(options, store),\n\t\tselector: (options) => selector__INTERNAL(options, undefined, store) as any,\n\t\tselectorFamily: (options) => selectorFamily__INTERNAL(options, store) as any,\n\t\ttransaction: (options) => transaction__INTERNAL(options, store),\n\t\ttimeline: (options) => timeline__INTERNAL(options, store),\n\t\tgetState: (token) => getState(token, store),\n\t\tsetState: (token, newValue) => setState(token, newValue, store),\n\t\tsubscribe: (token, handler) => subscribe(token, handler, store),\n\t\tundo: (token) => undo__INTERNAL(token, store),\n\t\tredo: (token) => redo__INTERNAL(token, store),\n\t}\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type {\n\tReadonlySelectorToken,\n\tStateToken,\n\tTimelineToken,\n\tTimelineUpdate,\n\tTransactionToken,\n\tTransactionUpdate,\n} from \".\"\nimport type { Store } from \"./internal\"\nimport { IMPLICIT, subscribeToRootAtoms, withdraw } from \"./internal\"\n\nexport type StateUpdate<T> = { newValue: T; oldValue: T }\nexport type KeyedStateUpdate<T> = StateUpdate<T> & { key: string }\nexport type UpdateHandler<T> = (update: StateUpdate<T>) => void\n\nexport const subscribe = <T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\thandleUpdate: UpdateHandler<T>,\n\tstore: Store = IMPLICIT.STORE,\n): (() => void) => {\n\tconst state = withdraw<T>(token, store)\n\tif (state === null) {\n\t\tthrow new Error(\n\t\t\t`State \"${token.key}\" not found in this store. Did you forget to initialize with the \"atom\" or \"selector\" function?`,\n\t\t)\n\t}\n\tconst subscription = state.subject.subscribe(handleUpdate)\n\tstore.config.logger?.info(`👀 subscribe to \"${state.key}\"`)\n\tconst dependencySubscriptions =\n\t\tstate.type !== `atom` ? subscribeToRootAtoms(state, store) : null\n\n\tconst unsubscribe =\n\t\tdependencySubscriptions === null\n\t\t\t? () => {\n\t\t\t\t\tstore.config.logger?.info(`🙈 unsubscribe from \"${state.key}\"`)\n\t\t\t\t\tsubscription.unsubscribe()\n\t\t\t }\n\t\t\t: () => {\n\t\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t\t`🙈 unsubscribe from \"${state.key}\" and its dependencies`,\n\t\t\t\t\t)\n\t\t\t\t\tsubscription.unsubscribe()\n\t\t\t\t\tfor (const dependencySubscription of dependencySubscriptions) {\n\t\t\t\t\t\tdependencySubscription.unsubscribe()\n\t\t\t\t\t}\n\t\t\t }\n\n\treturn unsubscribe\n}\n\nexport type TransactionUpdateHandler<ƒ extends ƒn> = (\n\tdata: TransactionUpdate<ƒ>,\n) => void\n\nexport const subscribeToTransaction = <ƒ extends ƒn>(\n\ttoken: TransactionToken<ƒ>,\n\thandleUpdate: TransactionUpdateHandler<ƒ>,\n\tstore = IMPLICIT.STORE,\n): (() => void) => {\n\tconst tx = withdraw(token, store)\n\tif (tx === null) {\n\t\tthrow new Error(\n\t\t\t`Cannot subscribe to transaction \"${token.key}\": transaction not found in store \"${store.config.name}\".`,\n\t\t)\n\t}\n\tstore.config.logger?.info(`👀 subscribe to transaction \"${token.key}\"`)\n\tconst subscription = tx.subject.subscribe(handleUpdate)\n\tconst unsubscribe = () => {\n\t\tstore.config.logger?.info(`🙈 unsubscribe from transaction \"${token.key}\"`)\n\t\tsubscription.unsubscribe()\n\t}\n\treturn unsubscribe\n}\n\nexport const subscribeToTimeline = (\n\ttoken: TimelineToken,\n\thandleUpdate: (update: TimelineUpdate) => void,\n\tstore = IMPLICIT.STORE,\n): (() => void) => {\n\tconst tl = withdraw(token, store)\n\tif (tl === null) {\n\t\tthrow new Error(\n\t\t\t`Cannot subscribe to timeline \"${token.key}\": timeline not found in store \"${store.config.name}\".`,\n\t\t)\n\t}\n\tstore.config.logger?.info(`👀 subscribe to timeline \"${token.key}\"`)\n\tconst subscription = tl.subject.subscribe(handleUpdate)\n\tconst unsubscribe = () => {\n\t\tstore.config.logger?.info(`🙈 unsubscribe from timeline \"${token.key}\"`)\n\t\tsubscription.unsubscribe()\n\t}\n\treturn unsubscribe\n}\n","import type { AtomFamily, AtomToken } from \".\"\nimport type {\n\tTimelineAtomUpdate,\n\tTimelineSelectorUpdate,\n\tTimelineTransactionUpdate,\n} from \"./internal\"\nimport { IMPLICIT } from \"./internal\"\nimport { redo__INTERNAL, timeline__INTERNAL, undo__INTERNAL } from \"./internal/\"\n\nexport type TimelineToken = {\n\tkey: string\n\ttype: `timeline`\n}\n\nexport type TimelineOptions = {\n\tkey: string\n\tatoms: (AtomFamily<any, any> | AtomToken<any>)[]\n}\n\nexport type TimelineUpdate =\n\t| TimelineAtomUpdate\n\t| TimelineSelectorUpdate\n\t| TimelineTransactionUpdate\n\nexport const timeline = (options: TimelineOptions): TimelineToken => {\n\treturn timeline__INTERNAL(options)\n}\n\nexport const redo = (token: TimelineToken): void => {\n\tredo__INTERNAL(token, IMPLICIT.STORE)\n}\n\nexport const undo = (token: TimelineToken): void => {\n\tundo__INTERNAL(token, IMPLICIT.STORE)\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { KeyedStateUpdate, ReadonlySelectorToken, StateToken } from \".\"\nimport type { Store } from \"./internal\"\nimport { IMPLICIT, transaction__INTERNAL, withdraw } from \"./internal\"\n\nexport type TransactionToken<_> = {\n\tkey: string\n\ttype: `transaction`\n\t__brand?: _\n}\n\nexport type TransactionUpdate<ƒ extends ƒn> = {\n\tkey: string\n\tatomUpdates: KeyedStateUpdate<unknown>[]\n\tparams: Parameters<ƒ>\n\toutput: ReturnType<ƒ>\n}\n\nexport type Transactors = {\n\tget: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S\n\tset: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void\n}\nexport type ReadonlyTransactors = Pick<Transactors, `get`>\n\nexport type Read<ƒ extends ƒn> = (\n\ttransactors: ReadonlyTransactors,\n\t...parameters: Parameters<ƒ>\n) => ReturnType<ƒ>\n\nexport type Write<ƒ extends ƒn> = (\n\ttransactors: Transactors,\n\t...parameters: Parameters<ƒ>\n) => ReturnType<ƒ>\n\nexport type TransactionOptions<ƒ extends ƒn> = {\n\tkey: string\n\tdo: Write<ƒ>\n}\n\nexport type TransactionIO<Token extends TransactionToken<any>> =\n\tToken extends TransactionToken<infer ƒ> ? ƒ : never\n\nexport function transaction<ƒ extends ƒn>(\n\toptions: TransactionOptions<ƒ>,\n): TransactionToken<ƒ> {\n\treturn transaction__INTERNAL(options)\n}\n\nexport const runTransaction =\n\t<ƒ extends ƒn>(token: TransactionToken<ƒ>, store: Store = IMPLICIT.STORE) =>\n\t(...parameters: Parameters<ƒ>): ReturnType<ƒ> => {\n\t\tconst tx = withdraw(token, store)\n\t\tif (tx) {\n\t\t\treturn tx.run(...parameters)\n\t\t}\n\t\tthrow new Error(\n\t\t\t`Cannot run transaction \"${token.key}\": transaction not found in store \"${store.config.name}\".`,\n\t\t)\n\t}\n","import { capitalize } from \"~/packages/anvl/src/string/capitalize\"\n\nimport {\n\tIMPLICIT,\n\tcloseOperation,\n\topenOperation,\n\tgetState__INTERNAL,\n\tsetState__INTERNAL,\n\tisAtomDefault,\n\tisSelectorDefault,\n\twithdraw,\n} from \"./internal\"\nimport * as __INTERNAL__ from \"./internal\"\nimport type { Store } from \"./internal/store\"\n\nexport * from \"./atom\"\nexport * from \"./logger\"\nexport * from \"./selector\"\nexport * from \"./silo\"\nexport * from \"./subscribe\"\nexport * from \"./timeline\"\nexport * from \"./transaction\"\nexport { __INTERNAL__ }\nexport type { Store } from \"./internal/store\"\nexport type { Serializable } from \"~/packages/anvl/src/json\"\n\nexport type AtomToken<_> = {\n\tkey: string\n\ttype: `atom`\n\tfamily?: FamilyMetadata\n\t__brand?: _\n}\nexport type SelectorToken<_> = {\n\tkey: string\n\ttype: `selector`\n\tfamily?: FamilyMetadata\n\t__brand?: _\n}\nexport type StateToken<T> = AtomToken<T> | SelectorToken<T>\n\nexport type ReadonlySelectorToken<_> = {\n\tkey: string\n\ttype: `readonly_selector`\n\tfamily?: FamilyMetadata\n\t__brand?: _\n}\n\nexport type FamilyMetadata = {\n\tkey: string\n\tsubKey: string\n}\n\nexport const getState = <T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\tstore: Store = IMPLICIT.STORE,\n): T => {\n\tconst state = withdraw<T>(token, store)\n\tif (state === null) {\n\t\tthrow new Error(\n\t\t\t`${capitalize(token.type)} \"${token.key}\" not found in store \"${\n\t\t\t\tstore.config.name\n\t\t\t}\".`,\n\t\t)\n\t}\n\treturn getState__INTERNAL(state, store)\n}\n\nexport const setState = <T, New extends T>(\n\ttoken: StateToken<T>,\n\tvalue: New | ((oldValue: T) => New),\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\ttry {\n\t\topenOperation(token, store)\n\t} catch (thrown) {\n\t\tif (!(typeof thrown === `symbol`)) {\n\t\t\tthrow thrown\n\t\t}\n\t\treturn\n\t}\n\tconst state = withdraw(token, store)\n\tif (state === null) {\n\t\tthrow new Error(\n\t\t\t`${capitalize(token.type)} \"${token.key}\" not found in store \"${\n\t\t\t\tstore.config.name\n\t\t\t}\".`,\n\t\t)\n\t}\n\tsetState__INTERNAL(state, value, store)\n\tcloseOperation(store)\n}\n\nexport const isDefault = (\n\ttoken: ReadonlySelectorToken<unknown> | StateToken<unknown>,\n\tstore: Store = IMPLICIT.STORE,\n): boolean =>\n\ttoken.type === `atom`\n\t\t? isAtomDefault(token.key, store)\n\t\t: isSelectorDefault(token.key, store)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAM,aAAa,CAAC,QAC1B,IAAI,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC;;;ACDnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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UAAU;AAAA,EAC5B;AACA,QAAM,IAAI;AAAA,IACT,2BAA2B,MAAM,GAAG,sCAAsC,MAAM,OAAO,IAAI;AAAA,EAC5F;AACD;;;ACPM,IAAM,WAAW,CACvB,OACA,QAAe,SAAS,UACjB;AACP,QAAM,QAAQ,SAAY,OAAO,KAAK;AACtC,MAAI,UAAU,MAAM;AACnB,UAAM,IAAI;AAAA,MACT,GAAG,WAAW,MAAM,IAAI,CAAC,KAAK,MAAM,GAAG,yBACtC,MAAM,OAAO,IACd;AAAA,IACD;AAAA,EACD;AACA,SAAO,mBAAmB,OAAO,KAAK;AACvC;AAEO,IAAM,WAAW,CACvB,OACA,OACA,QAAe,SAAS,UACd;AACV,MAAI;AACH,kBAAc,OAAO,KAAK;AAAA,EAC3B,SAAS,QAAQ;AAChB,QAAI,EAAE,OAAO,WAAW,WAAW;AAClC,YAAM;AAAA,IACP;AACA;AAAA,EACD;AACA,QAAM,QAAQ,SAAS,OAAO,KAAK;AACnC,MAAI,UAAU,MAAM;AACnB,UAAM,IAAI;AAAA,MACT,GAAG,WAAW,MAAM,IAAI,CAAC,KAAK,MAAM,GAAG,yBACtC,MAAM,OAAO,IACd;AAAA,IACD;AAAA,EACD;AACA,qBAAmB,OAAO,OAAO,KAAK;AACtC,iBAAe,KAAK;AACrB;AAEO,IAAM,YAAY,CACxB,OACA,QAAe,SAAS,UAExB,MAAM,SAAS,SACZ,cAAc,MAAM,KAAK,KAAK,IAC9B,kBAAkB,MAAM,KAAK,KAAK;","names":["selector","pipe","pipe","join","pipe","pipe","isString","pipe","pipe","isString","map","map","id","pipe","atom","selector","timeline","atom","selector","token","store","pipe","_a","_a","_b","state","atom","selector","atom","atom","update","_a","store","token","_a","_a"]}
|
|
1
|
+
{"version":3,"sources":["../../anvl/src/string/capitalize.ts","../src/internal/index.ts","../src/internal/get.ts","../src/internal/is-default.ts","../../anvl/src/function/index.ts","../../anvl/src/join/core-relation-data.ts","../../anvl/src/array/venn.ts","../../anvl/src/array/index.ts","../../anvl/src/object/refinement.ts","../../anvl/src/object/access.ts","../../anvl/src/object/entries.ts","../../anvl/src/object/mapObject.ts","../../anvl/src/nullish/index.ts","../../anvl/src/refinement/index.ts","../../anvl/src/join/get-related-ids.ts","../../anvl/src/join/make-json-interface.ts","../../anvl/src/join/relation-contents.ts","../../anvl/src/join/relation-record.ts","../../anvl/src/join/remove-relation.ts","../../anvl/src/object/index.ts","../../anvl/src/string/split.ts","../../anvl/src/join/set-relation.ts","../../anvl/src/join/index.ts","../src/internal/store.ts","../src/internal/operation.ts","../src/internal/transaction-internal.ts","../src/internal/atom-internal.ts","../../anvl/src/json/index.ts","../src/internal/families-internal.ts","../src/internal/selector/create-read-write-selector.ts","../src/internal/selector/lookup-selector-sources.ts","../src/internal/selector/trace-selector-atoms.ts","../src/internal/selector/update-selector-atoms.ts","../src/internal/set.ts","../src/internal/selector/register-selector.ts","../src/internal/selector/create-readonly-selector.ts","../src/internal/selector-internal.ts","../../anvl/reactivity/subject.ts","../src/internal/subscribe-internal.ts","../src/internal/time-travel-internal.ts","../src/internal/timeline/add-atom-to-timeline.ts","../src/internal/timeline-internal.ts","../src/internal/transaction/abort-transaction.ts","../src/internal/transaction/apply-transaction.ts","../src/internal/transaction/build-transaction.ts","../src/internal/transaction/redo-transaction.ts","../src/internal/transaction/undo-transaction.ts","../src/internal/transaction/index.ts","../src/atom.ts","../src/logger.ts","../src/selector.ts","../src/silo.ts","../src/subscribe.ts","../src/timeline.ts","../src/transaction.ts","../src/index.ts"],"sourcesContent":["export const capitalize = (str: string): string =>\n\tstr[0].toUpperCase() + str.slice(1)\n","export * from \"./atom-internal\"\nexport * from \"./families-internal\"\nexport * from \"./get\"\nexport * from \"./is-default\"\nexport * from \"./operation\"\nexport * from \"./selector-internal\"\nexport * from \"./selector\"\nexport * from \"./set\"\nexport * from \"./store\"\nexport * from \"../../../anvl/reactivity/subject\"\nexport * from \"./subscribe-internal\"\nexport * from \"./time-travel-internal\"\nexport * from \"./timeline-internal\"\nexport * from \"./transaction-internal\"\nexport * from \"./transaction\"\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type {\n\tAtom,\n\tReadonlySelector,\n\tSelector,\n\tStore,\n\tTimeline,\n\tTransaction,\n} from \".\"\nimport { target, isValueCached, readCachedValue, IMPLICIT } from \".\"\nimport type {\n\tAtomToken,\n\tReadonlySelectorToken,\n\tSelectorToken,\n\tStateToken,\n\tTimelineToken,\n\tTransactionToken,\n} from \"..\"\n\nexport const computeSelectorState = <T>(\n\tselector: ReadonlySelector<T> | Selector<T>,\n): T => selector.get()\n\nexport function lookup(\n\tkey: string,\n\tstore: Store,\n): AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown> {\n\tconst core = target(store)\n\tconst type = core.atoms.has(key)\n\t\t? `atom`\n\t\t: core.selectors.has(key)\n\t\t? `selector`\n\t\t: `readonly_selector`\n\treturn { key, type } as any\n}\n\nexport function withdraw<T>(token: AtomToken<T>, store: Store): Atom<T> | null\nexport function withdraw<T>(\n\ttoken: SelectorToken<T>,\n\tstore: Store,\n): Selector<T> | null\nexport function withdraw<T>(\n\ttoken: StateToken<T>,\n\tstore: Store,\n): Atom<T> | Selector<T> | null\nexport function withdraw<T>(\n\ttoken: ReadonlySelectorToken<T>,\n\tstore: Store,\n): ReadonlySelector<T> | null\nexport function withdraw<T>(\n\ttoken: TransactionToken<T>,\n\tstore: Store,\n): Transaction<T extends ƒn ? T : never> | null\nexport function withdraw<T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\tstore: Store,\n): Atom<T> | ReadonlySelector<T> | Selector<T> | null\nexport function withdraw<T>(token: TimelineToken, store: Store): Timeline | null\nexport function withdraw<T>(\n\ttoken:\n\t\t| ReadonlySelectorToken<T>\n\t\t| StateToken<T>\n\t\t| TimelineToken\n\t\t| TransactionToken<T>,\n\tstore: Store,\n):\n\t| Atom<T>\n\t| ReadonlySelector<T>\n\t| Selector<T>\n\t| Timeline\n\t| Transaction<T extends ƒn ? T : never>\n\t| null {\n\tconst core = target(store)\n\treturn (\n\t\tcore.atoms.get(token.key) ??\n\t\tcore.selectors.get(token.key) ??\n\t\tcore.readonlySelectors.get(token.key) ??\n\t\tcore.transactions.get(token.key) ??\n\t\tcore.timelines.get(token.key) ??\n\t\tnull\n\t)\n}\n\nexport function deposit<T>(state: Atom<T>): AtomToken<T>\nexport function deposit<T>(state: Selector<T>): SelectorToken<T>\nexport function deposit<T>(state: Atom<T> | Selector<T>): StateToken<T>\nexport function deposit<T>(state: ReadonlySelector<T>): ReadonlySelectorToken<T>\nexport function deposit<T>(\n\tstate: Transaction<T extends ƒn ? T : never>,\n): TransactionToken<T>\nexport function deposit<T>(\n\tstate: Atom<T> | ReadonlySelector<T> | Selector<T>,\n): ReadonlySelectorToken<T> | StateToken<T>\nexport function deposit<T>(\n\tstate:\n\t\t| Atom<T>\n\t\t| ReadonlySelector<T>\n\t\t| Selector<T>\n\t\t| Transaction<T extends ƒn ? T : never>,\n):\n\t| AtomToken<T>\n\t| ReadonlySelectorToken<T>\n\t| SelectorToken<T>\n\t| TransactionToken<T> {\n\treturn {\n\t\tkey: state.key,\n\t\ttype: state.type,\n\t\t...(`family` in state && { family: state.family }),\n\t} as any\n}\n\nexport const getState__INTERNAL = <T>(\n\tstate: Atom<T> | ReadonlySelector<T> | Selector<T>,\n\tstore: Store = IMPLICIT.STORE,\n): T => {\n\tif (isValueCached(state.key, store)) {\n\t\tstore.config.logger?.info(`>> read \"${state.key}\"`)\n\t\treturn readCachedValue(state.key, store)\n\t}\n\tif (state.type !== `atom`) {\n\t\tstore.config.logger?.info(`-> calc \"${state.key}\"`)\n\t\treturn computeSelectorState(state)\n\t}\n\tstore.config.logger?.error(\n\t\t`Attempted to get atom \"${state.key}\", which was never initialized in store \"${store.config.name}\".`,\n\t)\n\treturn state.default\n}\n","import type { Store } from \".\"\nimport { target, IMPLICIT, traceAllSelectorAtoms } from \".\"\n\nexport const isAtomDefault = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): boolean => {\n\tconst core = target(store)\n\treturn core.atomsThatAreDefault.has(key)\n}\n\nexport const markAtomAsDefault = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.atomsThatAreDefault = new Set(core.atomsThatAreDefault).add(key)\n}\n\nexport const markAtomAsNotDefault = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.atomsThatAreDefault = new Set(target(store).atomsThatAreDefault)\n\tcore.atomsThatAreDefault.delete(key)\n}\n\nexport const isSelectorDefault = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): boolean => {\n\tconst roots = traceAllSelectorAtoms(key, store)\n\treturn roots.every((root) => isAtomDefault(root.key, store))\n}\n","import type { Refinement } from \"fp-ts/Refinement\"\nexport * from \"./curry\"\n\nexport type ƒn = (...parameters: any[]) => any\n\nexport const doNothing = (): void => undefined\n\nexport const become =\n\t<T>(nextVersionOfThing: Modifier<T> | T) =>\n\t(originalThing: T | (() => T)): T =>\n\t\tnextVersionOfThing instanceof Function\n\t\t\t? nextVersionOfThing(\n\t\t\t\t\toriginalThing instanceof Function ? originalThing() : originalThing,\n\t\t\t )\n\t\t\t: nextVersionOfThing\n\nexport type Applicator<X, Y> = (next: Modifier<X> | X) => Modifier<Y>\nexport type Modifier<T> = (thing: T) => T\n\nexport type OneOrMany<T> = T | T[]\n\nexport const isModifier =\n\t<T>(validate: Refinement<unknown, T>) =>\n\t(sample: T): Refinement<unknown, Modifier<T>> => {\n\t\tconst sampleIsValid = validate(sample)\n\t\tif (!sampleIsValid) {\n\t\t\tthrow new Error(`Invalid test case: JSON.stringify(${sample})`)\n\t\t}\n\t\treturn (input: unknown): input is Modifier<T> => {\n\t\t\tif (typeof input !== `function`) return false\n\t\t\tconst testResult = input(sample)\n\t\t\treturn validate(testResult)\n\t\t}\n\t}\n\nexport const pass =\n\t<Params extends ReadonlyArray<any>, Out>(...params: Params) =>\n\t(fn: (...params: Params) => Out): Out =>\n\t\tfn(...params)\n\nexport const typeOf =\n\t<T>(input: unknown) =>\n\t(isType: Refinement<unknown, T>): boolean =>\n\t\tisType(input)\n\nexport const raiseError = (message: string): never => {\n\tthrow new Error(message)\n}\n\nexport type Encapsulate<T extends (...args: any[]) => any> = (\n\t...args: Parameters<T>\n) => void\n\nexport const attempt = (fn: () => void): boolean => {\n\ttry {\n\t\tfn()\n\t\treturn true\n\t} catch (_) {\n\t\treturn false\n\t}\n}\n\nexport const fallback = <T>(fn: () => T, fallbackValue: T): T => {\n\ttry {\n\t\treturn fn()\n\t} catch (_) {\n\t\treturn fallbackValue\n\t}\n}\n","import { isString } from \"fp-ts/string\"\n\nimport type { Json } from \"~/packages/anvl/src/json\"\n\nimport { isArray } from \"../array\"\nimport { hasExactProperties, isRecord } from \"../object/refinement\"\nimport { isLiteral } from \"../refinement\"\n\nexport const RELATION_TYPES = [`1:1`, `1:n`, `n:n`] as const\n\nexport type RelationType = typeof RELATION_TYPES[number]\n\nexport const isRelationType = (x: unknown): x is RelationType =>\n\tRELATION_TYPES.includes(x as RelationType)\n\nexport type RelationData<\n\tCONTENT extends Json.Object | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n> = {\n\tcontents: Json.Object<string, CONTENT>\n\trelations: Json.Object<string, string[]>\n\trelationType: RelationType\n\ta: A\n\tb: B\n}\n\nexport const EMPTY_RELATION_DATA: RelationData = {\n\tcontents: {},\n\trelations: {},\n\trelationType: `n:n`,\n\ta: `from`,\n\tb: `to`,\n}\n\nexport type IsRelationDataOptions<\n\tCONTENT extends Json.Object | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n> = {\n\tfrom?: A\n\tto?: B\n\tisContent?: (json: Json.Serializable) => json is CONTENT\n}\nexport const isRelationData =\n\t<\n\t\tCONTENT extends Json.Object | null = null,\n\t\tA extends string = `from`,\n\t\tB extends string = `to`,\n\t>({\n\t\tfrom: a = `from` as A,\n\t\tto: b = `to` as B,\n\t\tisContent,\n\t}: IsRelationDataOptions<CONTENT, A, B> = {}) =>\n\t(input: unknown): input is RelationData<CONTENT, A, B> => {\n\t\treturn hasExactProperties<RelationData<CONTENT, A, B>>({\n\t\t\tcontents: isContent\n\t\t\t\t? isRecord(isString, isContent)\n\t\t\t\t: hasExactProperties({}),\n\t\t\trelations: isRecord(isString, isArray(isString)),\n\t\t\trelationType: isRelationType,\n\t\t\ta: isLiteral(a),\n\t\t\tb: isLiteral(b),\n\t\t})(input)\n\t}\n","export type VennCheck = (\n\titems: ReadonlyArray<unknown> | unknown[],\n) => (array: ReadonlyArray<unknown> | unknown[]) => boolean\n\nexport type VennTally = (\n\titems: ReadonlyArray<unknown> | unknown[],\n) => (array: ReadonlyArray<unknown> | unknown[]) => number\n\nexport const includesAll: VennCheck = (items) => (array) => {\n\tfor (const item of items) {\n\t\tif (!array.includes(item)) return false\n\t}\n\treturn true\n}\n\nexport const includesAny: VennCheck = (items) => (array) => {\n\tfor (const item of items) {\n\t\tif (array.includes(item)) return true\n\t}\n\treturn false\n}\n\nexport const excludesAll: VennCheck = (items) => (array) =>\n\t!includesAny(items)(array)\n\nexport const excludesAny: VennCheck = (items) => (array) =>\n\t!includesAll(items)(array)\n\nexport const comprises: VennCheck = (items) => (array) =>\n\tincludesAll(items)(array) && includesAll(array)(items)\n\nexport const overlaps: VennTally = (items) => (array) => {\n\tlet incidences = 0\n\tfor (const item of items) {\n\t\tif (array.includes(item)) incidences += 1\n\t}\n\treturn incidences\n}\n","export * from \"./match\"\nexport * from \"./venn\"\n\nimport type { Refinement } from \"fp-ts/Refinement\"\n\nexport const each =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): T[] =>\n\t\tisType(input) ? [input] : Array.isArray(input) ? input.filter(isType) : []\n\nexport const lastOf = <T>(input: ReadonlyArray<T>): T | undefined =>\n\tinput[input.length - 1]\n\nexport const isArray =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): input is T[] =>\n\t\tArray.isArray(input) && input.every((item) => isType(item))\n\nexport const at =\n\t<T>(index: number) =>\n\t(input: T[]): T | undefined =>\n\t\tinput.at(index)\n\nexport const content =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): input is T | T[] =>\n\t\tisType(input) || isArray(isType)(input)\n\nexport const join = (separator?: string) => (a: string[]): string =>\n\ta.join(separator)\n\nexport const map =\n\t<I, O>(f: (value: I, index: number, array: I[]) => O) =>\n\t(a: I[]): O[] =>\n\t\ta.map(f)\n\nexport const reduce =\n\t<I, O>(f: (acc: O, value: I, index: number, array: I[]) => O, initial: O) =>\n\t(a: I[]): O =>\n\t\ta.reduce(f, initial)\n\nexport const slice = (start: number, end?: number) => <I>(a: I[]): I[] =>\n\ta.slice(start, end)\n\nexport const using =\n\t<I, O>(a: I[]) =>\n\t(f: (acc: O, value: I, index: number, array: I[]) => O) =>\n\t(initial: O): O =>\n\t\ta.reduce(f, initial)\n\nexport const reduceRight =\n\t<I, O>(f: (acc: O, value: I, index: number, array: I[]) => O, initial: O) =>\n\t(a: I[]): O =>\n\t\ta.reduceRight(f, initial)\n\nexport const reverse = <I>(a: I[]): I[] => a.reverse()\n\nexport const sort =\n\t<I>(a: I[]) =>\n\t(f?: (x: I, y: I) => number): I[] =>\n\t\tf ? a.sort(f) : a.sort()\n\nexport const sortBy =\n\t<I>(f: (value: I) => number) =>\n\t(a: I[]): I[] =>\n\t\ta.sort((x, y) => f(x) - f(y))\n\nexport const sortByDesc =\n\t<I>(f: (value: I) => number) =>\n\t(a: I[]): I[] =>\n\t\ta.sort((x, y) => f(y) - f(x))\n\nexport const every =\n\t<I>(f: (value: I, index: number, array: I[]) => boolean = Boolean) =>\n\t(a: I[]): boolean =>\n\t\ta.every(f)\n\nexport const allTrue = every((x: boolean) => x === true)\n\nexport const addTo =\n\t<I>(a: I[]) =>\n\t(x: I): I[] =>\n\t\ta.includes(x) ? a : [...a, x]\n\nexport const isEmptyArray = (input: unknown): input is [] =>\n\tArray.isArray(input) && input.length === 0\n\nexport const isOneOf =\n\t<T>(...args: ReadonlyArray<T>) =>\n\t(input: unknown): input is T =>\n\t\targs.includes(input as T)\n\nexport const filter =\n\t<I, O extends I>(f: (value: I, index: number, array: I[]) => value is O) =>\n\t(a: I[]): O[] =>\n\t\ta.filter(f)\n","import { pipe } from \"fp-ts/function\"\nimport type { Refinement } from \"fp-ts/Refinement\"\n\nimport { access } from \"./access\"\nimport { recordToEntries } from \"./entries\"\nimport { mob } from \"./mapObject\"\nimport { allTrue, every } from \"../array\"\nimport { pass } from \"../function\"\nimport { ifNullish } from \"../nullish\"\n\nexport type PlainObject = Record<keyof any, unknown>\nexport type EmptyObject = Record<keyof any, never>\n\nexport const isNonNullObject = (input: unknown): input is object =>\n\ttypeof input === `object` && input !== null\n\nexport const isPlainObject = (input: unknown): input is PlainObject =>\n\tisNonNullObject(input) && Object.getPrototypeOf(input) === Object.prototype\n\nexport const isEmptyObject = (input: unknown): input is EmptyObject =>\n\tisPlainObject(input) && Object.keys(input).length === 0\n\n/* prettier-ignore */\nexport const isRecord =\n\t<KEY extends keyof any, VAL>(\n\t\tisKey: Refinement<keyof any, KEY>,\n\t\tisValue: Refinement<unknown, VAL>,\n\t) =>\n\t(input: unknown): input is Record<KEY, VAL> =>\n\t\tisPlainObject(input) &&\n\t\tObject.entries(input).every(([k, v]) => isKey(k) && isValue(v))\n/* prettier-ignore-end */\n\nexport type HasPropertiesOptions = {\n\treadonly allowExtraProperties?: boolean\n}\nexport const hasProperties = <OBJ extends object>(\n\tisValue: {\n\t\t[K in keyof OBJ]: Refinement<unknown, OBJ[K]>\n\t},\n\toptions: HasPropertiesOptions = { allowExtraProperties: false },\n): Refinement<unknown, OBJ> => {\n\tconst name = `{${recordToEntries(\n\t\tisValue as Record<keyof any, Refinement<any, any>>,\n\t)\n\t\t.map(([k, v]) => String(k) + `:` + v.name)\n\t\t.join(`,`)}}`\n\n\tconst _ = {\n\t\t[name]: (input: unknown): input is OBJ =>\n\t\t\tisPlainObject(input) &&\n\t\t\tpipe(\n\t\t\t\tisValue,\n\t\t\t\tObject.entries,\n\t\t\t\tevery(([key, val]) => key in input || val(undefined)),\n\t\t\t) &&\n\t\t\tpipe(\n\t\t\t\tinput,\n\t\t\t\tmob((val, key) =>\n\t\t\t\t\tpipe(\n\t\t\t\t\t\tisValue,\n\t\t\t\t\t\taccess(key),\n\t\t\t\t\t\tifNullish(() => options.allowExtraProperties),\n\t\t\t\t\t\tpass(val),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\tObject.values,\n\t\t\t\tallTrue,\n\t\t\t),\n\t}\n\treturn _[name]\n}\n\nexport const doesExtend =\n\t/* alias for hasExactProperties with allowExtraProperties */\n\t<OBJ extends object>(\n\t\tisValue: {\n\t\t\t[K in keyof OBJ]: Refinement<unknown, OBJ[K]>\n\t\t},\n\t): Refinement<unknown, OBJ> =>\n\t\thasProperties(isValue, { allowExtraProperties: true })\n\nexport const hasExactProperties =\n\t/* alias for hasProperties without allowExtraProperties */\n\t<OBJ extends object>(\n\t\tisValue: {\n\t\t\t[K in keyof OBJ]: Refinement<unknown, OBJ[K]>\n\t\t},\n\t): Refinement<unknown, OBJ> =>\n\t\thasProperties(isValue, { allowExtraProperties: false })\n","export const key =\n\t<T extends object>(k: keyof T) =>\n\t(obj: Exclude<object, null>): unknown =>\n\t\t(obj as Record<keyof any, any>)[k]\n\nexport const access = <V, T extends Record<keyof any, V>>(\n\tk: keyof any,\n): {\n\t(obj: T): T[keyof T] | undefined\n\tin: (obj: T) => T[keyof T] | undefined\n} =>\n\tObject.assign((obj: T) => obj[k as keyof T], {\n\t\tin: (obj: T) => obj[k as keyof T],\n\t})\n","export type Entries<K extends keyof any, V> = [key: K, value: V][]\n\nexport const recordToEntries = <K extends keyof any, V>(\n\tobj: Record<K, V>,\n): Entries<K, V> => Object.entries(obj) as Entries<K, V>\n\nexport const entriesToRecord = <K extends keyof any, V>(\n\tentries: Entries<K, V>,\n): Record<K, V> => Object.fromEntries(entries) as Record<K, V>\n","import { pipe } from \"fp-ts/function\"\n\nimport { entriesToRecord, recordToEntries } from \"./entries\"\nimport { map } from \"../array\"\n\nexport const mapObject = <K extends keyof any, I, O>(\n\tobj: Record<K, I>,\n\tfn: (val: I, key: K) => O,\n): Record<K, O> =>\n\tpipe(\n\t\tobj,\n\t\trecordToEntries,\n\t\tmap(([key, val]) => [key, fn(val, key)] as const),\n\t\tentriesToRecord,\n\t)\n\nexport const mob =\n\t<K extends keyof any, I, O>(fn: (val: I, key: K) => O) =>\n\t(obj: Record<K, I>): Record<K, O> =>\n\t\tmapObject(obj, fn)\n","import type { Refinement } from \"fp-ts/Refinement\"\n\nexport const isUndefined = (input: unknown): input is undefined =>\n\tinput === undefined\n\nexport const ifDefined = <T>(\n\tvalidate: Refinement<unknown, T>,\n): Refinement<unknown, T | undefined> =>\n\t((input) => isUndefined(input) || validate(input)) as Refinement<\n\t\tunknown,\n\t\tT | undefined\n\t>\n\nexport const isNull = (input: unknown): input is null => input === null\n\nexport const isNullish = (input: unknown): input is null | undefined =>\n\tisUndefined(input) || isNull(input)\n\nexport type NullSafeUnion<Base, Extension> = Extension extends null\n\t? Base\n\t: Base & Extension\n\nexport type NullSafeRest<MaybeArg, IfArg = MaybeArg> = MaybeArg extends null\n\t? [] | [undefined]\n\t: [IfArg]\n\nexport interface Discard {\n\treadonly _discard: unique symbol\n}\n\nexport const ifNullish =\n\t<X, Y>(alt: Y) =>\n\t(input: X): Exclude<X, null | undefined> | Y =>\n\t\t(input ?? alt) as Exclude<X, null | undefined> | Y\n","import type { Refinement } from \"fp-ts/Refinement\"\n\nexport * from \"./refined\"\n\nexport const canExist = (_: unknown): _ is unknown => true\nexport const cannotExist = (_: unknown): _ is never => false\n\nexport const isLiteral =\n\t<T extends boolean | number | string>(value: T): Refinement<unknown, T> =>\n\t(input: unknown): input is T =>\n\t\tinput === value\n\nexport const isWithin =\n\t<Options extends ReadonlyArray<any>>(args: Options) =>\n\t(input: unknown): input is Options[number] =>\n\t\targs.includes(input as Options[number])\n\nexport const ensure =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): T => {\n\t\tif (!isType(input)) {\n\t\t\tthrow new TypeError(`Expected ${input} to be of type ${isType.name}`)\n\t\t}\n\t\treturn input as T\n\t}\n\nexport const ensureAgainst =\n\t<A, B>(isType: Refinement<unknown, A>) =>\n\t(input: A | B): Exclude<A | B, A> => {\n\t\tif (isType(input)) {\n\t\t\tthrow new TypeError(`Expected ${input} to not be of type ${isType.name}`)\n\t\t}\n\t\treturn input as Exclude<A | B, A>\n\t}\n\nexport type ExtendsSome<A, B> = Refinement<unknown, A | B> & {\n\tor: <C>(isType: Refinement<unknown, C>) => ExtendsSome<unknown, A | B | C>\n}\nexport const couldBe = <A>(\n\tisTypeA: Refinement<unknown, A>,\n\tlogging = false,\n\trefinements: Refinement<unknown, any>[] = [isTypeA],\n): {\n\t(input: unknown): input is A\n\tor: <B>(isTypeB: Refinement<unknown, B>) => ExtendsSome<A, B>\n} => {\n\tconst name = `(${refinements.map((r) => r.name || `anon`).join(` | `)})`\n\tconst _ = {\n\t\t[name]: (input: unknown): input is A =>\n\t\t\trefinements.some(\n\t\t\t\t(refinement) => (\n\t\t\t\t\tlogging &&\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\trefinements.map((r) => r.name || `anon`).join(` | `),\n\t\t\t\t\t\t\t`>`,\n\t\t\t\t\t\t\trefinement.name ?? `anon`,\n\t\t\t\t\t\t\t`:`,\n\t\t\t\t\t\t\trefinement(input),\n\t\t\t\t\t\t),\n\t\t\t\t\trefinement(input)\n\t\t\t\t),\n\t\t\t),\n\t}\n\tconst checkTypes: {\n\t\t(input: unknown): input is A\n\t\tor: <B>(isTypeB: Refinement<unknown, B>) => ExtendsSome<A, B>\n\t} = Object.assign(_[name], {\n\t\tor: <B>(isTypeB: Refinement<unknown, B>): ExtendsSome<A, B> =>\n\t\t\tcouldBe(isTypeB, logging, [...refinements, isTypeB]),\n\t})\n\treturn checkTypes\n}\n\nexport const isUnion = couldBe(cannotExist)\n\nexport type ExtendsAll<A, B> = Refinement<unknown, A & B> & {\n\tand: <C>(isType: Refinement<unknown, C>) => ExtendsAll<A & B, C>\n}\n\nexport const mustBe = <A>(\n\tisTypeA: Refinement<unknown, A>,\n\tlogging = false,\n\trefinements: Refinement<unknown, any>[] = [isTypeA],\n): {\n\t(input: unknown): input is A\n\tand: <B>(isTypeB: Refinement<unknown, B>) => ExtendsAll<A, B>\n} => {\n\tconst name = `(${refinements.map((r) => r.name || `anon`).join(` & `)})`\n\tconst _ = {\n\t\t[name]: (input: unknown): input is A =>\n\t\t\trefinements.every(\n\t\t\t\t(refinement) => (\n\t\t\t\t\tlogging &&\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\trefinements.map((r) => r.name || `anon`).join(` & `),\n\t\t\t\t\t\t\t`>`,\n\t\t\t\t\t\t\trefinement.name || `anon`,\n\t\t\t\t\t\t\t`:`,\n\t\t\t\t\t\t\trefinement(input),\n\t\t\t\t\t\t),\n\t\t\t\t\trefinement(input)\n\t\t\t\t),\n\t\t\t),\n\t}\n\tconst checkTypes: {\n\t\t(input: unknown): input is A\n\t\tand: <B>(isTypeB: Refinement<unknown, B>) => ExtendsAll<A, B>\n\t} = Object.assign(_[name], {\n\t\tand: <B>(isTypeB: Refinement<unknown, B>): ExtendsAll<A, B> =>\n\t\t\tmustBe(isTypeB, logging, [...refinements, isTypeB]) as ExtendsAll<A, B>,\n\t})\n\treturn checkTypes\n}\n\nexport const isIntersection = mustBe(canExist)\n\nexport type ClassSignature = abstract new (...args: any) => any\n\nexport const isClass =\n\t<CS extends ClassSignature>(signature: CS) =>\n\t(input: unknown): input is InstanceType<ClassSignature> =>\n\t\tinput instanceof signature\n","import type { RelationData } from \"./core-relation-data\"\nimport type { Json } from \"../json\"\n\nexport const getRelatedIds = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): string[] => relationMap.relations[id] ?? []\n\nexport const getRelatedId = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): string | undefined => {\n\tconst relations = getRelatedIds(relationMap, id)\n\tif (relations.length > 1) {\n\t\tconsole.warn(\n\t\t\t`entry with id ${id} was not expected to have multiple relations`,\n\t\t)\n\t}\n\treturn relations[0]\n}\n","import type { Json, JsonInterface } from \"~/packages/anvl/src/json\"\n\nimport { Join } from \".\"\nimport type { IsRelationDataOptions, RelationData } from \"./core-relation-data\"\n\nexport const makeJsonInterface = <\n\tCONTENT extends Json.Object | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n>(\n\tjoin: Join<CONTENT, A, B>,\n\t...params: CONTENT extends null ? [] : [(x: Json.Serializable) => x is CONTENT]\n): JsonInterface<Join<CONTENT, A, B>, RelationData<CONTENT, A, B>> => {\n\tconst isContent = params[0] as (x: Json.Serializable) => x is CONTENT\n\tconst { a, b } = join\n\tconst options: IsRelationDataOptions<CONTENT, A, B> = {\n\t\tfrom: a,\n\t\tto: b,\n\t\tisContent,\n\t}\n\treturn {\n\t\ttoJson: (join) => join.toJSON(),\n\t\tfromJson: (json) => Join.fromJSON(json, options),\n\t}\n}\n","import { pipe } from \"fp-ts/function\"\n\nimport type { Identified } from \"~/packages/anvl/src/id/identified\"\nimport { isEmptyObject } from \"~/packages/anvl/src/object/refinement\"\n\nimport type { RelationData } from \"./core-relation-data\"\nimport { getRelatedIds } from \"./get-related-ids\"\nimport { getRelationEntries } from \"./relation-record\"\nimport { removeRelation } from \"./remove-relation\"\nimport { setRelationWithContent } from \"./set-relation\"\nimport type { Json } from \"../json\"\nimport type { NullSafeRest } from \"../nullish\"\n\nexport const makeContentId = (idA: string, idB: string): string =>\n\t[idA, idB].sort().join(`/`)\n\nexport const getContent = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n): CONTENT | undefined => relationMap.contents[makeContentId(idA, idB)]\n\nexport const setContent = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tmap: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n\tcontent: CONTENT,\n): RelationData<CONTENT, A, B> => ({\n\t...map,\n\tcontents: {\n\t\t...map.contents,\n\t\t[makeContentId(idA, idB)]: content,\n\t},\n})\n\nexport const getRelations = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): (CONTENT extends null ? Identified : CONTENT & Identified)[] =>\n\tgetRelationEntries(relationMap, id).map(\n\t\t([id, content]) =>\n\t\t\t({\n\t\t\t\tid,\n\t\t\t\t...content,\n\t\t\t}) as CONTENT extends null ? Identified : CONTENT & Identified,\n\t)\n\nexport const setRelations = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tsubject: { [from in A]: string } | { [to in B]: string },\n\trelations: (CONTENT extends null ? Identified : CONTENT & Identified)[],\n): RelationData<CONTENT, A, B> => {\n\tconst idA: string | undefined = (subject as { [from in A]: string })[current.a]\n\tconst idB: string | undefined = (subject as { [to in B]: string })[current.b]\n\treturn pipe(\n\t\tcurrent,\n\t\t(relationData) => {\n\t\t\tconst relatedIds = getRelatedIds(current, idA)\n\t\t\tconst removedIds = relatedIds.filter(\n\t\t\t\t(id) => !relations.some((r) => r.id === id),\n\t\t\t)\n\t\t\tlet step = relationData\n\t\t\tfor (const id of removedIds) {\n\t\t\t\tconst remove = {\n\t\t\t\t\t[current.a]: idA ?? id,\n\t\t\t\t\t[current.b]: idB ?? id,\n\t\t\t\t} as Record<A | B, string>\n\t\t\t\tstep = removeRelation(step, remove)\n\t\t\t}\n\t\t\treturn step\n\t\t},\n\t\t(relationData) => {\n\t\t\tlet step = relationData\n\t\t\tfor (const { id, ...rest } of relations) {\n\t\t\t\tconst content = isEmptyObject(rest) ? undefined : rest\n\t\t\t\tstep = setRelationWithContent(\n\t\t\t\t\tstep,\n\t\t\t\t\t{ [current.a]: idA ?? id, [current.b]: idB ?? id } as Record<\n\t\t\t\t\t\tA | B,\n\t\t\t\t\t\tstring\n\t\t\t\t\t>,\n\t\t\t\t\t// @ts-expect-error hacky\n\t\t\t\t\tcontent as NullSafeRest<CONTENT>,\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn step\n\t\t},\n\t\t(relationData) => {\n\t\t\tconst newlyOrderedIds = relations.map((r) => r.id)\n\t\t\treturn {\n\t\t\t\t...relationData,\n\t\t\t\trelations: {\n\t\t\t\t\t...relationData.relations,\n\t\t\t\t\t[idA ?? idB]: newlyOrderedIds,\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t)\n}\n","import type { RelationData } from \"./core-relation-data\"\nimport { getRelatedIds } from \"./get-related-ids\"\nimport { getContent } from \"./relation-contents\"\nimport type { Json } from \"../json\"\n\nexport const getRelationEntries = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tidA: string,\n): [string, CONTENT][] =>\n\tgetRelatedIds(relationMap, idA).map((idB) => [\n\t\tidB,\n\t\tgetContent(relationMap, idA, idB) as CONTENT,\n\t])\n\nexport const getRelationRecord = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): Record<string, CONTENT> =>\n\tObject.fromEntries(getRelationEntries(relationMap, id))\n","import { pipe } from \"fp-ts/function\"\nimport { isString } from \"fp-ts/string\"\n\nimport type { RelationData } from \"./core-relation-data\"\nimport { isEmptyArray, isOneOf, map } from \"../array\"\nimport { comprises } from \"../array/venn\"\nimport type { Json } from \"../json\"\nimport { treeShake as removeProperties } from \"../object\"\nimport { entriesToRecord, recordToEntries } from \"../object/entries\"\nimport { split } from \"../string/split\"\n\nexport const removeSpecific = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n): RelationData<CONTENT, A, B> => {\n\tconst isIdForRemoval = isOneOf(idA, idB)\n\treturn {\n\t\t...current,\n\t\trelations: pipe(\n\t\t\tcurrent.relations,\n\t\t\trecordToEntries,\n\t\t\tmap(([id, relations]): [id: string, fewerRelations: string[]] => [\n\t\t\t\tid,\n\t\t\t\tisIdForRemoval(id)\n\t\t\t\t\t? relations.filter((relation) => !isIdForRemoval(relation))\n\t\t\t\t\t: relations,\n\t\t\t]),\n\t\t\tentriesToRecord,\n\t\t\tremoveProperties(isEmptyArray),\n\t\t),\n\t\tcontents: pipe(\n\t\t\tcurrent.contents,\n\t\t\tremoveProperties(\n\t\t\t\t(_, key) =>\n\t\t\t\t\tisString(key) && pipe(key, split(`/`), comprises([idA, idB])),\n\t\t\t),\n\t\t),\n\t}\n}\n\nexport const removeAll = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tidToRemove: string,\n): RelationData<CONTENT, A, B> => {\n\tconst next: RelationData<CONTENT, A, B> = {\n\t\t...current,\n\t\trelations: pipe(\n\t\t\tcurrent.relations,\n\t\t\trecordToEntries,\n\t\t\tmap(([id, relations]): [id: string, fewerRelations: string[]] => [\n\t\t\t\tid,\n\t\t\t\trelations.filter((relation) => relation !== idToRemove),\n\t\t\t]),\n\t\t\tentriesToRecord,\n\t\t\tremoveProperties((val, key) => key === idToRemove || isEmptyArray(val)),\n\t\t),\n\t\tcontents: pipe(\n\t\t\tcurrent.contents,\n\t\t\tremoveProperties(\n\t\t\t\t(_, key) => isString(key) && key.split(`/`).includes(idToRemove),\n\t\t\t),\n\t\t),\n\t}\n\treturn next\n}\n\nexport const removeRelation = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\trelation: Partial<Record<A | B, string>>,\n): RelationData<CONTENT, A, B> => {\n\tconst idA: string | undefined = (relation as { [key in A | B]: string })[\n\t\tcurrent.a\n\t]\n\tconst idB: string | undefined = (relation as { [key in A | B]: string })[\n\t\tcurrent.b\n\t]\n\treturn idB ? removeSpecific(current, idA, idB) : removeAll(current, idA)\n}\n","import { pipe } from \"fp-ts/function\"\nimport type { Refinement } from \"fp-ts/Refinement\"\n\nimport { deepMob } from \"./deepMob\"\nimport { entriesToRecord, recordToEntries } from \"./entries\"\nimport { isPlainObject } from \"./refinement\"\nimport { includesAny, reduce, filter } from \"../array\"\nimport { isUndefined } from \"../nullish\"\n\nexport * from \"./access\"\nexport * from \"./deepMob\"\nexport * from \"./entries\"\nexport * from \"./mapObject\"\nexport * from \"./modify\"\nexport * from \"./patch\"\nexport * from \"./refinement\"\nexport * from \"./sprawl\"\n\nexport const redact =\n\t<K extends keyof any>(...args: K[]) =>\n\t<O extends Record<K, any>>(obj: O): Omit<O, K> =>\n\t\treduce<K, O>((acc, key) => (delete acc[key], acc), obj)(args)\n\nexport type Redacted<Holder, RedactProp extends keyof any> = Omit<\n\t{\n\t\t[K in keyof Holder]: Holder[K] extends (infer Item)[]\n\t\t\t? Redacted<Item, RedactProp>[]\n\t\t\t: Redacted<Omit<Holder[K], RedactProp>, RedactProp>\n\t},\n\tRedactProp\n>\nexport const redactDeep =\n\t<K extends keyof any>(...args: K[]) =>\n\t<O extends Record<K, any>>(base: O): Redacted<O, K> =>\n\t\tdeepMob(base, (node, path) =>\n\t\t\tincludesAny(args)(path)\n\t\t\t\t? {\n\t\t\t\t\t\tmeta: { pathComplete: true },\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tdata: isPlainObject(node)\n\t\t\t\t\t\t\t? redact(...args)(node as Record<keyof any, any>)\n\t\t\t\t\t\t\t: node,\n\t\t\t\t },\n\t\t)\n\nexport const select =\n\t<Key extends keyof any>(...args: Key[]) =>\n\t<Obj extends object>(\n\t\tobj: Obj,\n\t): {\n\t\t// @ts-expect-error fuk u\n\t\t[K in keyof Pick<Obj, Key>]: any extends Pick<Obj, Key>[K]\n\t\t\t? undefined\n\t\t\t: // @ts-expect-error fuk u\n\t\t\t Pick<Obj, Key>[K]\n\t} =>\n\t\t// @ts-expect-error fuk u ts\n\t\treduce<Key, Pick<Obj, Key>>(\n\t\t\t// @ts-expect-error i will fite u\n\t\t\t(acc, key) => (key in obj ? (acc[key] = obj[key as keyof Obj]) : acc, acc),\n\t\t\t// @ts-expect-error fuk u\n\t\t\t{} as Pick<Obj, Key>,\n\t\t)(args)\n\nexport const treeShake =\n\t(shouldDiscard: (val: unknown, key: keyof any) => boolean = isUndefined) =>\n\t<T extends object>(\n\t\tobj: T,\n\t): T extends Record<keyof any, unknown> ? T : Partial<T> => {\n\t\tconst newObj = {} as T\n\t\tconst entries = Object.entries(obj) as [keyof T, any][]\n\t\tentries.forEach(([key, val]) =>\n\t\t\t!shouldDiscard(val, key) ? (newObj[key] = val) : null,\n\t\t)\n\t\treturn newObj as T extends Record<keyof any, unknown> ? T : Partial<T>\n\t}\n\nexport type KeysExtending<T, V> = keyof {\n\t[K in keyof T]: T[K] extends V ? K : never\n}\n\nconst a: never | null = null\n\nexport const filterProperties =\n\t<DiscardVal, DiscardKey extends keyof any>(\n\t\tshouldDiscardVal: Refinement<unknown, DiscardVal>,\n\t\tshouldDiscardKey: Refinement<unknown, DiscardKey>,\n\t) =>\n\t<P extends Record<keyof any, any>>(\n\t\tprops: P,\n\t): DiscardVal extends never\n\t\t? DiscardKey extends never\n\t\t\t? P\n\t\t\t: Omit<P, DiscardKey>\n\t\t: Omit<P, DiscardKey | KeysExtending<P, DiscardVal>> =>\n\t\t// @ts-expect-error oh well\n\t\tpipe(\n\t\t\tprops,\n\t\t\trecordToEntries,\n\t\t\tfilter(\n\t\t\t\t(\n\t\t\t\t\tentry,\n\t\t\t\t): entry is [\n\t\t\t\t\tExclude<keyof P, DiscardKey>,\n\t\t\t\t\tExclude<P[keyof P], DiscardVal>,\n\t\t\t\t] => !shouldDiscardKey(entry[0]) || !shouldDiscardVal(entry[1]),\n\t\t\t),\n\t\t\tentriesToRecord,\n\t\t)\n\nexport const delve = (\n\tobj: Record<keyof any, any>,\n\tpath: ReadonlyArray<keyof any>,\n): Error | { found: unknown } => {\n\tconst found = path.reduce((acc, key) => acc?.[key], obj)\n\treturn found === undefined ? new Error(`Not found`) : { found }\n}\n\nexport const tweak = (\n\tobj: Record<keyof any, any>,\n\tpath: ReadonlyArray<keyof any>,\n\tvalue: unknown,\n): void =>\n\tpath.reduce((acc, key, i) => {\n\t\tif (i === path.length - 1) {\n\t\t\tacc[key] = value\n\t\t}\n\t\tif (acc[key] === undefined) {\n\t\t\tacc[key] = typeof key === `number` ? [] : {}\n\t\t}\n\t\treturn acc[key]\n\t}, obj)\n\nexport type RequireAtLeastOne<T> = {\n\t[K in keyof T]-?: Partial<Pick<T, Exclude<keyof T, K>>> & Required<Pick<T, K>>\n}[keyof T]\n\nexport type RequireExactlyOne<T> = {\n\t[K in keyof T]-?: Required<Pick<T, K>>\n}[keyof T]\n","export const split = (separator: string) => (str: string): string[] =>\n\tstr.split(separator)\n","import type { RelationData } from \"./core-relation-data\"\nimport { getRelatedId } from \"./get-related-ids\"\nimport { setContent } from \"./relation-contents\"\nimport { addTo, isEmptyArray } from \"../array\"\nimport type { Json } from \"../json\"\nimport type { NullSafeRest } from \"../nullish\"\nimport { treeShake as removeProperties } from \"../object\"\n\nexport const setManyToMany = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tmap: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst next = {\n\t\t...map,\n\t\trelations: {\n\t\t\t...map.relations,\n\t\t\t[idA]: addTo(map.relations[idA] ?? [])(idB),\n\t\t\t[idB]: addTo(map.relations[idB] ?? [])(idA),\n\t\t},\n\t}\n\tconst content = rest[0] as CONTENT | undefined\n\treturn content ? setContent(next, idA, idB, content) : next\n}\n\nconst removeEmpties = removeProperties(isEmptyArray)\n\nexport const set1ToMany = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tleaderId: string,\n\tfollowerId: string,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst relations = { ...current.relations }\n\tconst prevLeaderId = getRelatedId(current, followerId)\n\tconst next = {\n\t\t...current,\n\t\trelations: removeEmpties({\n\t\t\t...relations,\n\t\t\t...(prevLeaderId &&\n\t\t\t\tprevLeaderId !== leaderId && {\n\t\t\t\t\t[prevLeaderId]: relations[prevLeaderId].filter(\n\t\t\t\t\t\t(id) => id !== followerId,\n\t\t\t\t\t),\n\t\t\t\t}),\n\t\t\t[followerId]: [leaderId],\n\t\t\t[leaderId]: addTo(relations[leaderId] ?? [])(followerId),\n\t\t}),\n\t}\n\tconst content = rest[0] as CONTENT | undefined\n\treturn content ? setContent(next, leaderId, followerId, content) : next\n}\n\nexport const set1To1 = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\twifeId: string,\n\thusbandId: string,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst prevWifeId = getRelatedId(current, husbandId)\n\tconst prevHusbandId = getRelatedId(current, wifeId)\n\tconst next = {\n\t\t...current,\n\t\trelations: removeEmpties({\n\t\t\t...current.relations,\n\t\t\t...(prevWifeId && { [prevWifeId]: [] }),\n\t\t\t...(prevHusbandId && { [prevHusbandId]: [] }),\n\t\t\t[wifeId]: [husbandId],\n\t\t\t[husbandId]: [wifeId],\n\t\t}),\n\t}\n\n\tconst content = rest[0] as CONTENT | undefined\n\treturn content ? setContent(next, wifeId, husbandId, content) : next\n}\n\nexport const setRelationWithContent = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\trelation: Record<A | B, string>,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst { [current.a]: idA, [current.b]: idB } = relation\n\tswitch (current.relationType) {\n\t\tcase `1:1`:\n\t\t\treturn set1To1(current, idA, idB, ...rest)\n\t\tcase `1:n`:\n\t\t\treturn set1ToMany(current, idA, idB, ...rest)\n\t\tcase `n:n`:\n\t\t\treturn setManyToMany(current, idA, idB, ...rest)\n\t}\n}\n","import type { Refinement } from \"fp-ts/Refinement\"\n\nimport type { Identified } from \"~/packages/anvl/src/id/identified\"\n\nimport type { IsRelationDataOptions, RelationData } from \"./core-relation-data\"\nimport { EMPTY_RELATION_DATA, isRelationData } from \"./core-relation-data\"\nimport { getRelatedId, getRelatedIds } from \"./get-related-ids\"\nimport { makeJsonInterface } from \"./make-json-interface\"\nimport { getContent, getRelations, setRelations } from \"./relation-contents\"\nimport { getRelationEntries, getRelationRecord } from \"./relation-record\"\nimport { removeRelation } from \"./remove-relation\"\nimport { setRelationWithContent } from \"./set-relation\"\nimport type { Json, JsonInterface } from \"../json\"\nimport type { NullSafeRest, NullSafeUnion } from \"../nullish\"\n\nexport class Join<\n\tCONTENT extends Json.Object | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n> implements RelationData<CONTENT, A, B>\n{\n\tpublic readonly relationType: `1:1` | `1:n` | `n:n`\n\tpublic readonly a: A = `from` as A\n\tpublic readonly b: B = `to` as B\n\tpublic readonly relations: Record<string, string[]>\n\tpublic readonly contents: Record<string, CONTENT>\n\tpublic constructor(json?: Partial<RelationData<CONTENT, A, B>>) {\n\t\tObject.assign(this, {\n\t\t\t...EMPTY_RELATION_DATA,\n\t\t\t...json,\n\t\t\tmakeJsonInterface: this.makeJsonInterface,\n\t\t})\n\t}\n\tpublic toJSON(): RelationData<CONTENT, A, B> {\n\t\treturn {\n\t\t\trelationType: this.relationType,\n\t\t\trelations: this.relations,\n\t\t\tcontents: this.contents,\n\t\t\ta: this.a,\n\t\t\tb: this.b,\n\t\t}\n\t}\n\tpublic static fromJSON<\n\t\tCONTENT extends Json.Object | null,\n\t\tA extends string,\n\t\tB extends string,\n\t>(\n\t\tjson: Json.Serializable,\n\t\toptions?: IsRelationDataOptions<CONTENT, A, B>,\n\t): Join<CONTENT, A, B> {\n\t\tconst isValid = isRelationData<CONTENT, A, B>(options)(json)\n\t\tif (isValid) {\n\t\t\treturn new Join<CONTENT, A, B>(json)\n\t\t}\n\t\tthrow new Error(\n\t\t\t`Saved JSON for this Join is invalid: ${JSON.stringify(json)}`,\n\t\t)\n\t}\n\n\tpublic from<AA extends string>(newA: AA): Join<CONTENT, AA, B> {\n\t\treturn new Join({ ...this, a: newA })\n\t}\n\n\tpublic to<BB extends string>(newB: BB): Join<CONTENT, A, BB> {\n\t\treturn new Join({ ...this, b: newB })\n\t}\n\n\tpublic makeJsonInterface = (\n\t\t...params: CONTENT extends null ? [] : [Refinement<unknown, CONTENT>]\n\t): JsonInterface<Join<CONTENT, A, B>, RelationData<CONTENT, A, B>> => {\n\t\treturn makeJsonInterface<CONTENT, A, B>(this, ...params)\n\t}\n\n\tpublic getRelatedId(id: string): string | undefined {\n\t\treturn getRelatedId(this, id)\n\t}\n\tpublic getRelatedIds(id: string): string[] {\n\t\treturn getRelatedIds(this, id)\n\t}\n\tpublic getContent(idA: string, idB: string): CONTENT | undefined {\n\t\treturn getContent(this, idA, idB)\n\t}\n\tpublic getRelationEntries(id: string): [string, CONTENT][] {\n\t\treturn getRelationEntries(this, id)\n\t}\n\tpublic getRelationRecord(id: string): Record<string, CONTENT> {\n\t\treturn getRelationRecord(this, id)\n\t}\n\tpublic getRelation(\n\t\tid: string,\n\t): NullSafeUnion<Identified, CONTENT> | undefined {\n\t\treturn getRelations(this, id)[0]\n\t}\n\tpublic getRelations(id: string): NullSafeUnion<Identified, CONTENT>[] {\n\t\treturn getRelations(this, id)\n\t}\n\tpublic setRelations(\n\t\tsubject: { [from in A]: string } | { [to in B]: string },\n\t\trelations: NullSafeUnion<Identified, CONTENT>[],\n\t): Join<CONTENT, A, B> {\n\t\treturn new Join(setRelations(this, subject, relations))\n\t}\n\tpublic set(\n\t\trelation: { [key in A | B]: string },\n\t\t...rest: NullSafeRest<CONTENT>\n\t): Join<CONTENT, A, B> {\n\t\treturn new Join(setRelationWithContent(this, relation, ...rest))\n\t}\n\tpublic remove(relation: Partial<Record<A | B, string>>): Join<CONTENT, A, B> {\n\t\treturn new Join(\n\t\t\tremoveRelation(this, relation as Partial<Record<A | B, string>>),\n\t\t)\n\t}\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\nimport { doNothing } from \"~/packages/anvl/src/function\"\nimport { Join } from \"~/packages/anvl/src/join\"\n\nimport { Subject } from \".\"\nimport type {\n\tAtom,\n\tOperationProgress,\n\tReadonlySelector,\n\tSelector,\n\tTransactionStatus,\n\tTimeline,\n\tTransaction,\n} from \".\"\nimport type {\n\tAtomToken,\n\tLogger,\n\tReadonlySelectorToken,\n\tSelectorToken,\n\tTimelineToken,\n\tTransactionToken,\n} from \"..\"\n\nexport type StoreCore = Pick<\n\tStore,\n\t| `atoms`\n\t| `atomsThatAreDefault`\n\t| `operation`\n\t| `readonlySelectors`\n\t| `selectorAtoms`\n\t| `selectorGraph`\n\t| `selectors`\n\t| `timelineAtoms`\n\t| `timelines`\n\t| `transactions`\n\t| `valueMap`\n>\n\nexport interface Store {\n\tatoms: Map<string, Atom<any>>\n\tatomsThatAreDefault: Set<string>\n\treadonlySelectors: Map<string, ReadonlySelector<any>>\n\tselectorAtoms: Join<null, `selectorKey`, `atomKey`>\n\tselectorGraph: Join<{ source: string }>\n\tselectors: Map<string, Selector<any>>\n\ttimelineAtoms: Join<null, `timelineKey`, `atomKey`>\n\ttimelines: Map<string, Timeline>\n\ttransactions: Map<string, Transaction<any>>\n\tvalueMap: Map<string, any>\n\n\tsubject: {\n\t\tatomCreation: Subject<AtomToken<unknown>>\n\t\tselectorCreation: Subject<\n\t\t\tReadonlySelectorToken<unknown> | SelectorToken<unknown>\n\t\t>\n\t\ttransactionCreation: Subject<TransactionToken<ƒn>>\n\t\ttimelineCreation: Subject<TimelineToken>\n\t\toperationStatus: Subject<OperationProgress>\n\t}\n\n\toperation: OperationProgress\n\ttransactionStatus: TransactionStatus<ƒn>\n\tconfig: {\n\t\tname: string\n\t\tlogger: Logger | null\n\t\tlogger__INTERNAL: Logger\n\t}\n}\n\nexport const createStore = (name: string, store: Store | null = null): Store => {\n\tconst created = {\n\t\t...(store ??\n\t\t\t(() => ({\n\t\t\t\tatomsThatAreDefault: new Set(),\n\t\t\t\tselectorAtoms: new Join({ relationType: `n:n` })\n\t\t\t\t\t.from(`selectorKey`)\n\t\t\t\t\t.to(`atomKey`),\n\t\t\t\tselectorGraph: new Join({ relationType: `n:n` }),\n\t\t\t}))()),\n\n\t\tvalueMap: new Map(store?.valueMap),\n\t\tatoms: new Map(),\n\t\treadonlySelectors: new Map(),\n\t\tselectors: new Map(),\n\t\ttransactions: new Map(),\n\t\ttimelines: new Map(),\n\n\t\ttimelineAtoms: new Join({ relationType: `1:n` })\n\t\t\t.from(`timelineKey`)\n\t\t\t.to(`atomKey`),\n\n\t\tsubject: {\n\t\t\tatomCreation: new Subject(),\n\t\t\tselectorCreation: new Subject(),\n\t\t\ttransactionCreation: new Subject(),\n\t\t\ttimelineCreation: new Subject(),\n\t\t\toperationStatus: new Subject(),\n\t\t},\n\n\t\toperation: {\n\t\t\topen: false,\n\t\t\t...store?.operation,\n\t\t},\n\t\ttransactionStatus: {\n\t\t\tphase: `idle`,\n\t\t\t...store?.transactionStatus,\n\t\t},\n\t\tconfig: {\n\t\t\tlogger: {\n\t\t\t\t...console,\n\t\t\t\tinfo: doNothing,\n\t\t\t\t...store?.config?.logger,\n\t\t\t},\n\t\t\tlogger__INTERNAL: console,\n\t\t\t...store?.config,\n\t\t\tname,\n\t\t},\n\t} satisfies Store\n\n\tstore?.atoms.forEach((atom) => {\n\t\tconst copiedAtom = { ...atom, subject: new Subject() } satisfies Atom<any>\n\t\tcreated.atoms.set(atom.key, copiedAtom)\n\t})\n\tstore?.readonlySelectors.forEach((selector) => {\n\t\tselector.install(created)\n\t})\n\tstore?.selectors.forEach((selector) => {\n\t\tselector.install(created)\n\t})\n\tstore?.transactions.forEach((tx) => {\n\t\ttx.install(created)\n\t})\n\tstore?.timelines.forEach((timeline) => {\n\t\ttimeline.install(created)\n\t})\n\n\treturn created\n}\n\nexport const IMPLICIT = {\n\tSTORE_INTERNAL: undefined as Store | undefined,\n\tget STORE(): Store {\n\t\treturn this.STORE_INTERNAL ?? (this.STORE_INTERNAL = createStore(`DEFAULT`))\n\t},\n}\n\nexport const clearStore = (store: Store = IMPLICIT.STORE): void => {\n\tconst { config } = store\n\tObject.assign(store, createStore(config.name))\n\tstore.config = config\n}\n","import type { Atom, ReadonlySelector, Selector } from \".\"\nimport { target } from \".\"\nimport type { Store } from \"./store\"\nimport { IMPLICIT } from \"./store\"\nimport type { StateToken } from \"..\"\n\nexport type OperationProgress =\n\t| {\n\t\t\topen: false\n\t }\n\t| {\n\t\t\topen: true\n\t\t\tdone: Set<string>\n\t\t\tprev: Map<string, any>\n\t\t\ttime: number\n\t\t\ttoken: StateToken<any>\n\t }\n\nexport const openOperation = (token: StateToken<any>, store: Store): void => {\n\tconst core = target(store)\n\tif (core.operation.open) {\n\t\tstore.config.logger?.error(\n\t\t\t`❌ failed to setState to \"${token.key}\" during a setState for \"${core.operation.token.key}\"`,\n\t\t)\n\t\tthrow Symbol(`violation`)\n\t}\n\tcore.operation = {\n\t\topen: true,\n\t\tdone: new Set(),\n\t\tprev: new Map(store.valueMap),\n\t\ttime: Date.now(),\n\t\ttoken,\n\t}\n\tstore.config.logger?.info(\n\t\t`⭕ operation start from \"${token.key}\" in store \"${store.config.name}\"`,\n\t)\n}\nexport const closeOperation = (store: Store): void => {\n\tconst core = target(store)\n\tcore.operation = { open: false }\n\tstore.config.logger?.info(`🔴 operation done`)\n\tstore.subject.operationStatus.next(core.operation)\n}\n\nexport const isDone = (key: string, store: Store = IMPLICIT.STORE): boolean => {\n\tconst core = target(store)\n\tif (!core.operation.open) {\n\t\tstore.config.logger?.warn(\n\t\t\t`isDone called outside of an operation. This is probably a bug.`,\n\t\t)\n\t\treturn true\n\t}\n\treturn core.operation.done.has(key)\n}\nexport const markDone = (key: string, store: Store = IMPLICIT.STORE): void => {\n\tconst core = target(store)\n\tif (!core.operation.open) {\n\t\tstore.config.logger?.warn(\n\t\t\t`markDone called outside of an operation. This is probably a bug.`,\n\t\t)\n\t\treturn\n\t}\n\tcore.operation.done.add(key)\n}\nexport const recallState = <T>(\n\tstate: Atom<T> | ReadonlySelector<T> | Selector<T>,\n\tstore: Store = IMPLICIT.STORE,\n): T => {\n\tconst core = target(store)\n\tif (!core.operation.open) {\n\t\tstore.config.logger?.warn(\n\t\t\t`recall called outside of an operation. This is probably a bug.`,\n\t\t)\n\t\treturn core.valueMap.get(state.key)\n\t}\n\treturn core.operation.prev.get(state.key)\n}\n\nexport const cacheValue = (\n\tkey: string,\n\tvalue: unknown,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.valueMap.set(key, value)\n}\n\nexport const evictCachedValue = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.valueMap.delete(key)\n}\nexport const readCachedValue = <T>(\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): T => target(store).valueMap.get(key)\n\nexport const isValueCached = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): boolean => target(store).valueMap.has(key)\n\nexport const storeAtom = (\n\tatom: Atom<any>,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.atoms.set(atom.key, atom)\n}\n\nexport const storeSelector = (\n\tselector: Selector<any>,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.selectors.set(selector.key, selector)\n}\n\nexport const storeReadonlySelector = (\n\tselector: ReadonlySelector<any>,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.readonlySelectors.set(selector.key, selector)\n}\n\nexport const hasKeyBeenUsed = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): boolean => {\n\tconst core = target(store)\n\treturn (\n\t\tcore.atoms.has(key) ||\n\t\tcore.selectors.has(key) ||\n\t\tcore.readonlySelectors.has(key)\n\t)\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store, StoreCore } from \".\"\nimport {\n\tSubject,\n\tabortTransaction,\n\tapplyTransaction,\n\tbuildTransaction,\n\tdeposit,\n\tIMPLICIT,\n} from \".\"\nimport type { TransactionOptions, TransactionToken, TransactionUpdate } from \"..\"\nimport { getState, setState } from \"..\"\n\nexport type Transaction<ƒ extends ƒn> = {\n\tkey: string\n\ttype: `transaction`\n\tinstall: (store: Store) => void\n\tsubject: Subject<TransactionUpdate<ƒ>>\n\trun: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>\n}\n\nexport function transaction__INTERNAL<ƒ extends ƒn>(\n\toptions: TransactionOptions<ƒ>,\n\tstore: Store = IMPLICIT.STORE,\n): TransactionToken<ƒ> {\n\tconst newTransaction: Transaction<ƒ> = {\n\t\tkey: options.key,\n\t\ttype: `transaction`,\n\t\trun: (...params: Parameters<ƒ>) => {\n\t\t\tbuildTransaction(options.key, params, store)\n\t\t\ttry {\n\t\t\t\tconst output = options.do(\n\t\t\t\t\t{\n\t\t\t\t\t\tget: (token) => getState(token, store),\n\t\t\t\t\t\tset: (token, value) => setState(token, value, store),\n\t\t\t\t\t},\n\t\t\t\t\t...params,\n\t\t\t\t)\n\t\t\t\tapplyTransaction(output, store)\n\t\t\t\treturn output\n\t\t\t} catch (thrown) {\n\t\t\t\tabortTransaction(store)\n\t\t\t\tstore.config.logger?.error(`Transaction ${options.key} failed`, thrown)\n\t\t\t\tthrow thrown\n\t\t\t}\n\t\t},\n\t\tinstall: (store) => transaction__INTERNAL(options, store),\n\t\tsubject: new Subject(),\n\t}\n\tconst core = target(store)\n\tcore.transactions.set(newTransaction.key, newTransaction)\n\tconst token = deposit(newTransaction)\n\tstore.subject.transactionCreation.next(token)\n\treturn token\n}\n\nexport const target = (store: Store = IMPLICIT.STORE): StoreCore =>\n\tstore.transactionStatus.phase === `building`\n\t\t? store.transactionStatus.core\n\t\t: store\n","import { Subject } from \".\"\nimport { deposit } from \"./get\"\nimport { markAtomAsDefault } from \"./is-default\"\nimport { cacheValue } from \"./operation\"\nimport type { Store } from \"./store\"\nimport { IMPLICIT } from \"./store\"\nimport { target } from \"./transaction-internal\"\nimport type { AtomToken, FamilyMetadata, UpdateHandler } from \"..\"\nimport { setState, subscribe } from \"..\"\nimport type { AtomOptions } from \"../atom\"\n\nexport type Atom<T> = {\n\tkey: string\n\ttype: `atom`\n\tfamily?: FamilyMetadata\n\tsubject: Subject<{ newValue: T; oldValue: T }>\n\tdefault: T\n}\n\nexport function atom__INTERNAL<T>(\n\toptions: AtomOptions<T>,\n\tfamily?: FamilyMetadata,\n\tstore: Store = IMPLICIT.STORE,\n): AtomToken<T> {\n\tconst core = target(store)\n\tconst existing = core.atoms.get(options.key)\n\tif (existing) {\n\t\tstore.config.logger?.error?.(\n\t\t\t`Key \"${options.key}\" already exists in the store.`,\n\t\t)\n\t\treturn deposit(existing)\n\t}\n\tconst subject = new Subject<{ newValue: T; oldValue: T }>()\n\tconst newAtom = {\n\t\t...options,\n\t\tsubject,\n\t\ttype: `atom`,\n\t\t...(family && { family }),\n\t} as const\n\tconst initialValue =\n\t\toptions.default instanceof Function ? options.default() : options.default\n\tcore.atoms.set(newAtom.key, newAtom)\n\tmarkAtomAsDefault(options.key, store)\n\tcacheValue(options.key, initialValue, store)\n\tconst token = deposit(newAtom)\n\toptions.effects?.forEach((effect) =>\n\t\teffect({\n\t\t\tsetSelf: (next) => setState(token, next, store),\n\t\t\tonSet: (handle: UpdateHandler<T>) => subscribe(token, handle, store),\n\t\t}),\n\t)\n\tstore.subject.atomCreation.next(token)\n\treturn token as AtomToken<T>\n}\n","export * from \"./json-interface\"\nimport type * as Json from \"./json\"\nexport { Json }\n\nexport const parseJson = <S extends Stringified<Json.Serializable>>(\n\tstr: S | string,\n): S extends Stringified<infer J> ? J : Json.Serializable => JSON.parse(str)\n\nexport type Stringified<J extends Json.Serializable> = string & { __json: J }\n\nexport const stringifyJson = <J extends Json.Serializable>(\n\tjson: J,\n): Stringified<J> => JSON.stringify(json) as Stringified<J>\n\nexport type Empty = Record<string, never>\n\nexport const JSON_TYPE_NAMES = [\n\t`array`,\n\t`boolean`,\n\t`null`,\n\t`number`,\n\t`object`,\n\t`string`,\n] as const\n\nexport type JsonTypeName = typeof JSON_TYPE_NAMES[number]\n\nexport interface JsonTypes extends Record<JsonTypeName, Json.Serializable> {\n\tarray: Json.Array\n\tboolean: boolean\n\tnull: null\n\tnumber: number\n\tobject: Json.Object\n\tstring: string\n}\n\nexport const JSON_DEFAULTS: JsonTypes = {\n\tarray: [],\n\tboolean: false,\n\tnull: null,\n\tnumber: 0,\n\tobject: {},\n\tstring: ``,\n}\n","import type { Json } from \"~/packages/anvl/src/json\"\nimport { stringifyJson } from \"~/packages/anvl/src/json\"\n\nimport type { Store } from \".\"\nimport {\n\tSubject,\n\tatom__INTERNAL,\n\twithdraw,\n\tselector__INTERNAL,\n\ttarget,\n\tdeposit,\n\tIMPLICIT,\n} from \".\"\nimport type {\n\tAtomFamily,\n\tAtomFamilyOptions,\n\tAtomOptions,\n\tAtomToken,\n\tFamilyMetadata,\n\tReadonlySelectorFamily,\n\tReadonlySelectorFamilyOptions,\n\tReadonlySelectorToken,\n\tSelectorFamily,\n\tSelectorFamilyOptions,\n\tSelectorToken,\n} from \"..\"\n\nexport function atomFamily__INTERNAL<T, K extends Json.Serializable>(\n\toptions: AtomFamilyOptions<T, K>,\n\tstore: Store = IMPLICIT.STORE,\n): AtomFamily<T, K> {\n\tconst subject = new Subject<AtomToken<T>>()\n\treturn Object.assign(\n\t\t(key: K): AtomToken<T> => {\n\t\t\tconst subKey = stringifyJson(key)\n\t\t\tconst family: FamilyMetadata = { key: options.key, subKey }\n\t\t\tconst fullKey = `${options.key}(${subKey})`\n\t\t\tconst existing = withdraw({ key: fullKey, type: `atom` }, store)\n\t\t\tlet token: AtomToken<any>\n\t\t\tif (existing) {\n\t\t\t\ttoken = deposit(existing)\n\t\t\t} else {\n\t\t\t\tconst individualOptions: AtomOptions<any> = {\n\t\t\t\t\tkey: fullKey,\n\t\t\t\t\tdefault:\n\t\t\t\t\t\toptions.default instanceof Function\n\t\t\t\t\t\t\t? options.default(key)\n\t\t\t\t\t\t\t: options.default,\n\t\t\t\t}\n\t\t\t\tif (options.effects) {\n\t\t\t\t\tindividualOptions.effects = options.effects(key)\n\t\t\t\t}\n\t\t\t\ttoken = atom__INTERNAL<T>(individualOptions, family, store)\n\t\t\t}\n\t\t\tsubject.next(token)\n\t\t\treturn token\n\t\t},\n\t\t{\n\t\t\tkey: options.key,\n\t\t\ttype: `atom_family`,\n\t\t\tsubject,\n\t\t} as const,\n\t)\n}\n\nexport function readonlySelectorFamily__INTERNAL<T, K extends Json.Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K>,\n\tstore?: Store,\n): ReadonlySelectorFamily<T, K> {\n\tconst core = target(store)\n\tconst subject = new Subject<ReadonlySelectorToken<T>>()\n\treturn Object.assign(\n\t\t(key: K): ReadonlySelectorToken<T> => {\n\t\t\tconst subKey = stringifyJson(key)\n\t\t\tconst family: FamilyMetadata = { key: options.key, subKey }\n\t\t\tconst fullKey = `${options.key}(${subKey})`\n\t\t\tconst existing = core.readonlySelectors.get(fullKey)\n\t\t\tif (existing) {\n\t\t\t\treturn deposit(existing)\n\t\t\t}\n\t\t\treturn selector__INTERNAL<T>(\n\t\t\t\t{\n\t\t\t\t\tkey: fullKey,\n\t\t\t\t\tget: options.get(key),\n\t\t\t\t},\n\t\t\t\tfamily,\n\t\t\t\tstore,\n\t\t\t) as ReadonlySelectorToken<T>\n\t\t},\n\t\t{\n\t\t\tkey: options.key,\n\t\t\ttype: `readonly_selector_family`,\n\t\t\tsubject,\n\t\t} as const,\n\t) as ReadonlySelectorFamily<T, K>\n}\n\nexport function selectorFamily__INTERNAL<T, K extends Json.Serializable>(\n\toptions: SelectorFamilyOptions<T, K>,\n\tstore?: Store,\n): SelectorFamily<T, K>\nexport function selectorFamily__INTERNAL<T, K extends Json.Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K>,\n\tstore?: Store,\n): ReadonlySelectorFamily<T, K>\nexport function selectorFamily__INTERNAL<T, K extends Json.Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K> | SelectorFamilyOptions<T, K>,\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorFamily<T, K> | SelectorFamily<T, K> {\n\tconst isReadonly = !(`set` in options)\n\n\tif (isReadonly) {\n\t\treturn readonlySelectorFamily__INTERNAL(options, store)\n\t}\n\tconst core = target(store)\n\tconst subject = new Subject<SelectorToken<T>>()\n\n\treturn Object.assign(\n\t\t(key: K): SelectorToken<T> => {\n\t\t\tconst subKey = stringifyJson(key)\n\t\t\tconst family: FamilyMetadata = { key: options.key, subKey }\n\t\t\tconst fullKey = `${options.key}(${subKey})`\n\t\t\tconst existing = core.selectors.get(fullKey)\n\t\t\tif (existing) {\n\t\t\t\treturn deposit(existing)\n\t\t\t}\n\t\t\tconst token = selector__INTERNAL<T>(\n\t\t\t\t{\n\t\t\t\t\tkey: fullKey,\n\t\t\t\t\tget: options.get(key),\n\t\t\t\t\tset: options.set(key),\n\t\t\t\t},\n\t\t\t\tfamily,\n\t\t\t\tstore,\n\t\t\t)\n\t\t\tsubject.next(token)\n\t\t\treturn token\n\t\t},\n\t\t{\n\t\t\tkey: options.key,\n\t\t\ttype: `selector_family`,\n\t\t} as const,\n\t) as SelectorFamily<T, K>\n}\n","import { become } from \"~/packages/anvl/src/function\"\n\nimport { Subject } from \"..\"\nimport {\n\ttype Store,\n\ttype Selector,\n\ttype StoreCore,\n\tregisterSelector,\n\tselector__INTERNAL,\n} from \"..\"\nimport type { FamilyMetadata, SelectorToken } from \"../..\"\nimport type { SelectorOptions } from \"../../selector\"\nimport { cacheValue, markDone } from \"../operation\"\n\nexport const createReadWriteSelector = <T>(\n\toptions: SelectorOptions<T>,\n\tfamily: FamilyMetadata | undefined,\n\tstore: Store,\n\tcore: StoreCore,\n): SelectorToken<T> => {\n\tconst subject = new Subject<{ newValue: T; oldValue: T }>()\n\n\tconst { get, set } = registerSelector(options.key, store)\n\tconst getSelf = () => {\n\t\tconst value = options.get({ get })\n\t\tcacheValue(options.key, value, store)\n\t\treturn value\n\t}\n\n\tconst setSelf = (next: T | ((oldValue: T) => T)): void => {\n\t\tconst oldValue = getSelf()\n\t\tstore.config.logger?.info(\n\t\t\t` <- \"${options.key}\" went (`,\n\t\t\toldValue,\n\t\t\t`->`,\n\t\t\tnext,\n\t\t\t`)`,\n\t\t)\n\t\tconst newValue = become(next)(oldValue)\n\t\tcacheValue(options.key, newValue, store)\n\t\tmarkDone(options.key, store)\n\t\tif (store.transactionStatus.phase === `idle`) {\n\t\t\tsubject.next({ newValue, oldValue })\n\t\t}\n\t\toptions.set({ get, set }, newValue)\n\t}\n\tconst mySelector: Selector<T> = {\n\t\t...options,\n\t\tsubject,\n\t\tinstall: (s: Store) => selector__INTERNAL(options, family, s),\n\t\tget: getSelf,\n\t\tset: setSelf,\n\t\ttype: `selector`,\n\t\t...(family && { family }),\n\t}\n\tcore.selectors.set(options.key, mySelector)\n\tconst initialValue = getSelf()\n\tstore.config.logger?.info(` ✨ \"${options.key}\" =`, initialValue)\n\tconst token: SelectorToken<T> = {\n\t\tkey: options.key,\n\t\ttype: `selector`,\n\t}\n\tif (family) {\n\t\ttoken.family = family\n\t}\n\tstore.subject.selectorCreation.next(token)\n\treturn token\n}\n","import type { Store } from \"..\"\nimport { target, lookup } from \"..\"\nimport type { AtomToken, ReadonlySelectorToken, SelectorToken } from \"../..\"\n\nexport const lookupSelectorSources = (\n\tkey: string,\n\tstore: Store,\n): (\n\t| AtomToken<unknown>\n\t| ReadonlySelectorToken<unknown>\n\t| SelectorToken<unknown>\n)[] =>\n\ttarget(store)\n\t\t.selectorGraph.getRelations(key)\n\t\t.filter(({ source }) => source !== key)\n\t\t.map(({ source }) => lookup(source, store))\n","import { lookupSelectorSources } from \"./lookup-selector-sources\"\nimport type { Store, AtomToken, ReadonlySelectorToken, StateToken } from \"../..\"\n\nexport const traceSelectorAtoms = (\n\tselectorKey: string,\n\tdependency: ReadonlySelectorToken<unknown> | StateToken<unknown>,\n\tstore: Store,\n): AtomToken<unknown>[] => {\n\tconst roots: AtomToken<unknown>[] = []\n\n\tconst sources = lookupSelectorSources(dependency.key, store)\n\tlet depth = 0\n\twhile (sources.length > 0) {\n\t\t// rome-ignore lint/style/noNonNullAssertion: just checked length ^^^\n\t\tconst source = sources.shift()!\n\t\t++depth\n\t\tif (depth > 999) {\n\t\t\tthrow new Error(\n\t\t\t\t`Maximum selector dependency depth exceeded in selector \"${selectorKey}\".`,\n\t\t\t)\n\t\t}\n\n\t\tif (source.type !== `atom`) {\n\t\t\tsources.push(...lookupSelectorSources(source.key, store))\n\t\t} else {\n\t\t\troots.push(source)\n\t\t}\n\t}\n\n\treturn roots\n}\n\nexport const traceAllSelectorAtoms = (\n\tselectorKey: string,\n\tstore: Store,\n): AtomToken<unknown>[] => {\n\tconst sources = lookupSelectorSources(selectorKey, store)\n\treturn sources.flatMap((source) =>\n\t\tsource.type === `atom`\n\t\t\t? source\n\t\t\t: traceSelectorAtoms(selectorKey, source, store),\n\t)\n}\n","import { traceSelectorAtoms } from \"./trace-selector-atoms\"\nimport type { Store } from \"..\"\nimport { target } from \"..\"\nimport type { ReadonlySelectorToken, StateToken } from \"../..\"\n\nexport const updateSelectorAtoms = (\n\tselectorKey: string,\n\tdependency: ReadonlySelectorToken<unknown> | StateToken<unknown>,\n\tstore: Store,\n): void => {\n\tconst core = target(store)\n\tif (dependency.type === `atom`) {\n\t\tcore.selectorAtoms = core.selectorAtoms.set({\n\t\t\tselectorKey,\n\t\t\tatomKey: dependency.key,\n\t\t})\n\t\tstore.config.logger?.info(\n\t\t\t` || adding root for \"${selectorKey}\": ${dependency.key}`,\n\t\t)\n\t\treturn\n\t}\n\tconst roots = traceSelectorAtoms(selectorKey, dependency, store)\n\tstore.config.logger?.info(\n\t\t` || adding roots for \"${selectorKey}\":`,\n\t\troots.map((r) => r.key),\n\t)\n\tfor (const root of roots) {\n\t\tcore.selectorAtoms = core.selectorAtoms.set({\n\t\t\tselectorKey,\n\t\t\tatomKey: root.key,\n\t\t})\n\t}\n}\n","import { become } from \"~/packages/anvl/src/function\"\n\nimport type { Atom, Selector, Store } from \".\"\nimport {\n\tIMPLICIT,\n\tcacheValue,\n\temitUpdate,\n\tevictCachedValue,\n\tgetState__INTERNAL,\n\tisAtomDefault,\n\tisDone,\n\tmarkAtomAsNotDefault,\n\tmarkDone,\n\tstowUpdate,\n\ttarget,\n} from \".\"\n\nexport const evictDownStream = <T>(\n\tstate: Atom<T>,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tconst downstream = core.selectorAtoms.getRelations(state.key)\n\tconst downstreamKeys = downstream.map(({ id }) => id)\n\tstore.config.logger?.info(\n\t\t` || ${downstreamKeys.length} downstream:`,\n\t\tdownstreamKeys,\n\t)\n\tif (core.operation.open) {\n\t\tstore.config.logger?.info(` ||`, [...core.operation.done], `already done`)\n\t}\n\tdownstream.forEach(({ id: stateKey }) => {\n\t\tif (isDone(stateKey, store)) {\n\t\t\tstore.config.logger?.info(` || ${stateKey} already done`)\n\t\t\treturn\n\t\t}\n\t\tconst state =\n\t\t\tcore.selectors.get(stateKey) ?? core.readonlySelectors.get(stateKey)\n\t\tif (!state) {\n\t\t\tstore.config.logger?.info(\n\t\t\t\t` || ${stateKey} is an atom, and can't be downstream`,\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tevictCachedValue(stateKey, store)\n\t\tstore.config.logger?.info(` xx evicted \"${stateKey}\"`)\n\n\t\tmarkDone(stateKey, store)\n\t})\n}\n\nexport const setAtomState = <T>(\n\tatom: Atom<T>,\n\tnext: T | ((oldValue: T) => T),\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst oldValue = getState__INTERNAL(atom, store)\n\tconst newValue = become(next)(oldValue)\n\tstore.config.logger?.info(`<< setting atom \"${atom.key}\" to`, newValue)\n\tcacheValue(atom.key, newValue, store)\n\tif (isAtomDefault(atom.key, store)) {\n\t\tmarkAtomAsNotDefault(atom.key, store)\n\t}\n\tmarkDone(atom.key, store)\n\tstore.config.logger?.info(\n\t\t` || evicting caches downstream from \"${atom.key}\"`,\n\t)\n\tevictDownStream(atom, store)\n\tconst update = { oldValue, newValue }\n\tif (store.transactionStatus.phase !== `building`) {\n\t\temitUpdate(atom, update, store)\n\t} else {\n\t\tstowUpdate(atom, update, store)\n\t}\n}\nexport const setSelectorState = <T>(\n\tselector: Selector<T>,\n\tnext: T | ((oldValue: T) => T),\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst oldValue = getState__INTERNAL(selector, store)\n\tconst newValue = become(next)(oldValue)\n\n\tstore.config.logger?.info(`<< setting selector \"${selector.key}\" to`, newValue)\n\tstore.config.logger?.info(` || propagating change made to \"${selector.key}\"`)\n\n\tselector.set(newValue)\n}\nexport const setState__INTERNAL = <T>(\n\tstate: Atom<T> | Selector<T>,\n\tvalue: T | ((oldValue: T) => T),\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tif (`set` in state) {\n\t\tsetSelectorState(state, value, store)\n\t} else {\n\t\tsetAtomState(state, value, store)\n\t}\n}\n","import { updateSelectorAtoms } from \"./update-selector-atoms\"\nimport type { Transactors } from \"../../transaction\"\nimport { getState__INTERNAL, withdraw } from \"../get\"\nimport { setState__INTERNAL } from \"../set\"\nimport type { Store } from \"../store\"\nimport { IMPLICIT } from \"../store\"\nimport { target } from \"../transaction-internal\"\n\nexport const registerSelector = (\n\tselectorKey: string,\n\tstore: Store = IMPLICIT.STORE,\n): Transactors => ({\n\tget: (dependency) => {\n\t\tconst core = target(store)\n\t\tconst alreadyRegistered = core.selectorGraph\n\t\t\t.getRelations(selectorKey)\n\t\t\t.some(({ source }) => source === dependency.key)\n\n\t\tconst dependencyState = withdraw(dependency, store)\n\t\tif (dependencyState === null) {\n\t\t\tthrow new Error(\n\t\t\t\t`State \"${dependency.key}\" not found in this store. Did you forget to initialize with the \"atom\" or \"selector\" function?`,\n\t\t\t)\n\t\t}\n\t\tconst dependencyValue = getState__INTERNAL(dependencyState, store)\n\n\t\tif (alreadyRegistered) {\n\t\t\tstore.config.logger?.info(\n\t\t\t\t` || ${selectorKey} <- ${dependency.key} =`,\n\t\t\t\tdependencyValue,\n\t\t\t)\n\t\t} else {\n\t\t\tstore.config.logger?.info(\n\t\t\t\t`🔌 registerSelector \"${selectorKey}\" <- ( \"${dependency.key}\" =`,\n\t\t\t\tdependencyValue,\n\t\t\t\t`)`,\n\t\t\t)\n\t\t\tcore.selectorGraph = core.selectorGraph.set(\n\t\t\t\t{ from: dependency.key, to: selectorKey },\n\t\t\t\t{\n\t\t\t\t\tsource: dependency.key,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tupdateSelectorAtoms(selectorKey, dependency, store)\n\t\treturn dependencyValue\n\t},\n\tset: (stateToken, newValue) => {\n\t\tconst state = withdraw(stateToken, store)\n\t\tif (state === null) {\n\t\t\tthrow new Error(\n\t\t\t\t`State \"${stateToken.key}\" not found in this store. Did you forget to initialize with the \"atom\" or \"selector\" function?`,\n\t\t\t)\n\t\t}\n\t\tsetState__INTERNAL(state, newValue, store)\n\t},\n})\n","import { registerSelector } from \"./register-selector\"\nimport { Subject } from \"..\"\nimport type {\n\tFamilyMetadata,\n\tReadonlySelectorOptions,\n\tReadonlySelectorToken,\n\tStore,\n} from \"../..\"\nimport { cacheValue } from \"../operation\"\nimport { selector__INTERNAL, type ReadonlySelector } from \"../selector-internal\"\nimport type { StoreCore } from \"../store\"\n\nexport const createReadonlySelector = <T>(\n\toptions: ReadonlySelectorOptions<T>,\n\tfamily: FamilyMetadata | undefined,\n\tstore: Store,\n\tcore: StoreCore,\n): ReadonlySelectorToken<T> => {\n\tconst subject = new Subject<{ newValue: T; oldValue: T }>()\n\n\tconst { get } = registerSelector(options.key, store)\n\tconst getSelf = () => {\n\t\tconst value = options.get({ get })\n\t\tcacheValue(options.key, value, store)\n\t\treturn value\n\t}\n\n\tconst readonlySelector: ReadonlySelector<T> = {\n\t\t...options,\n\t\tsubject,\n\t\tinstall: (s: Store) => selector__INTERNAL(options, family, s),\n\t\tget: getSelf,\n\t\ttype: `readonly_selector`,\n\t\t...(family && { family }),\n\t}\n\tcore.readonlySelectors.set(options.key, readonlySelector)\n\tconst initialValue = getSelf()\n\tstore.config.logger?.info(` ✨ \"${options.key}\" =`, initialValue)\n\tconst token: ReadonlySelectorToken<T> = {\n\t\tkey: options.key,\n\t\ttype: `readonly_selector`,\n\t}\n\tif (family) {\n\t\ttoken.family = family\n\t}\n\tstore.subject.selectorCreation.next(token)\n\treturn token\n}\n","import { target, IMPLICIT } from \".\"\nimport type { Store, Subject } from \".\"\nimport { createReadWriteSelector } from \"./selector/create-read-write-selector\"\nimport { createReadonlySelector } from \"./selector/create-readonly-selector\"\nimport type {\n\tFamilyMetadata,\n\tReadonlySelectorOptions,\n\tReadonlySelectorToken,\n\tSelectorOptions,\n\tSelectorToken,\n} from \"..\"\n\nexport type Selector<T> = {\n\tkey: string\n\ttype: `selector`\n\tfamily?: FamilyMetadata\n\tinstall: (store: Store) => void\n\tsubject: Subject<{ newValue: T; oldValue: T }>\n\tget: () => T\n\tset: (newValue: T | ((oldValue: T) => T)) => void\n}\nexport type ReadonlySelector<T> = {\n\tkey: string\n\ttype: `readonly_selector`\n\tfamily?: FamilyMetadata\n\tinstall: (store: Store) => void\n\tsubject: Subject<{ newValue: T; oldValue: T }>\n\tget: () => T\n}\n\nexport function selector__INTERNAL<T>(\n\toptions: SelectorOptions<T>,\n\tfamily?: FamilyMetadata,\n\tstore?: Store,\n): SelectorToken<T>\nexport function selector__INTERNAL<T>(\n\toptions: ReadonlySelectorOptions<T>,\n\tfamily?: FamilyMetadata,\n\tstore?: Store,\n): ReadonlySelectorToken<T>\nexport function selector__INTERNAL<T>(\n\toptions: ReadonlySelectorOptions<T> | SelectorOptions<T>,\n\tfamily?: FamilyMetadata,\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorToken<T> | SelectorToken<T> {\n\tconst core = target(store)\n\n\tif (core.selectors.has(options.key)) {\n\t\tstore.config.logger?.error(\n\t\t\t`Key \"${options.key}\" already exists in the store.`,\n\t\t)\n\t}\n\n\tif (!(`set` in options)) {\n\t\treturn createReadonlySelector(options, family, store, core)\n\t}\n\treturn createReadWriteSelector(options, family, store, core)\n}\n","type Subscriber<T> = (value: T) => void\n\nexport class Subject<T> {\n\tpublic subscribers: Subscriber<T>[] = []\n\n\tpublic subscribe(subscriber: Subscriber<T>): { unsubscribe: () => void } {\n\t\tthis.subscribers.push(subscriber)\n\t\tconst unsubscribe = () => this.unsubscribe(subscriber)\n\t\treturn { unsubscribe }\n\t}\n\n\tprivate unsubscribe(subscriber: Subscriber<T>) {\n\t\tconst subscriberIndex = this.subscribers.indexOf(subscriber)\n\t\tif (subscriberIndex !== -1) {\n\t\t\tthis.subscribers.splice(subscriberIndex, 1)\n\t\t}\n\t}\n\n\tpublic next(value: T): void {\n\t\tfor (const subscriber of this.subscribers) {\n\t\t\tsubscriber(value)\n\t\t}\n\t}\n}\n","import type { Atom, ReadonlySelector, Selector, Store } from \".\"\nimport {\n\tgetState__INTERNAL,\n\twithdraw,\n\trecallState,\n\ttraceAllSelectorAtoms,\n} from \".\"\nimport type { StateUpdate } from \"..\"\n\nexport const prepareUpdate = <T>(\n\tstate: Atom<T> | ReadonlySelector<T> | Selector<T>,\n\tstore: Store,\n): StateUpdate<T> => {\n\tconst oldValue = recallState(state, store)\n\tconst newValue = getState__INTERNAL(state, store)\n\treturn { newValue, oldValue }\n}\n\nexport const stowUpdate = <T>(\n\tstate: Atom<T>,\n\tupdate: StateUpdate<T>,\n\tstore: Store,\n): void => {\n\tconst { key } = state\n\tconst { logger } = store.config\n\tif (store.transactionStatus.phase !== `building`) {\n\t\tstore.config.logger?.warn(\n\t\t\t`stowUpdate called outside of a transaction. This is probably a bug.`,\n\t\t)\n\t\treturn\n\t}\n\tstore.transactionStatus.atomUpdates.push({ key, ...update })\n\tlogger?.info(`📝 ${key} stowed (`, update.oldValue, `->`, update.newValue, `)`)\n}\n\nexport const emitUpdate = <T>(\n\tstate: Atom<T> | ReadonlySelector<T> | Selector<T>,\n\tupdate: StateUpdate<T>,\n\tstore: Store,\n): void => {\n\tconst { key } = state\n\tconst { logger } = store.config\n\tlogger?.info(\n\t\t`📢 ${state.type} \"${key}\" went (`,\n\t\tupdate.oldValue,\n\t\t`->`,\n\t\tupdate.newValue,\n\t\t`)`,\n\t)\n\tstate.subject.next(update)\n}\n\nexport const subscribeToRootAtoms = <T>(\n\tstate: ReadonlySelector<T> | Selector<T>,\n\tstore: Store,\n): { unsubscribe: () => void }[] | null => {\n\tconst dependencySubscriptions =\n\t\t`default` in state\n\t\t\t? null\n\t\t\t: traceAllSelectorAtoms(state.key, store).map((atomToken) => {\n\t\t\t\t\tconst atom = withdraw(atomToken, store)\n\t\t\t\t\tif (atom === null) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Atom \"${atomToken.key}\", a dependency of selector \"${state.key}\", not found in store \"${store.config.name}\".`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\treturn atom.subject.subscribe((atomChange) => {\n\t\t\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t\t\t`📢 selector \"${state.key}\" saw root \"${atomToken.key}\" go (`,\n\t\t\t\t\t\t\tatomChange.oldValue,\n\t\t\t\t\t\t\t`->`,\n\t\t\t\t\t\t\tatomChange.newValue,\n\t\t\t\t\t\t\t`)`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tconst oldValue = recallState(state, store)\n\t\t\t\t\t\tconst newValue = getState__INTERNAL(state, store)\n\t\t\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t\t\t` <- \"${state.key}\" went (`,\n\t\t\t\t\t\t\toldValue,\n\t\t\t\t\t\t\t`->`,\n\t\t\t\t\t\t\tnewValue,\n\t\t\t\t\t\t\t`)`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tstate.subject.next({ newValue, oldValue })\n\t\t\t\t\t})\n\t\t\t })\n\treturn dependencySubscriptions\n}\n","import type { Store } from \".\"\nimport { IMPLICIT } from \".\"\nimport type { TimelineToken } from \"..\"\nimport { setState } from \"..\"\n\nexport const redo__INTERNAL = (\n\ttoken: TimelineToken,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tstore.config.logger?.info(`⏩ redo \"${token.key}\"`)\n\tconst timelineData = store.timelines.get(token.key)\n\tif (!timelineData) {\n\t\tstore.config.logger?.error(\n\t\t\t`Failed to redo on timeline \"${token.key}\". This timeline has not been initialized.`,\n\t\t)\n\t\treturn\n\t}\n\tif (timelineData.at === timelineData.history.length) {\n\t\tstore.config.logger?.warn(\n\t\t\t`Failed to redo at the end of timeline \"${token.key}\". There is nothing to redo.`,\n\t\t)\n\t\treturn\n\t}\n\ttimelineData.timeTraveling = `into_future`\n\tconst update = timelineData.history[timelineData.at]\n\tswitch (update.type) {\n\t\tcase `atom_update`: {\n\t\t\tconst { key, newValue } = update\n\t\t\tsetState({ key, type: `atom` }, newValue, store)\n\t\t\tbreak\n\t\t}\n\t\tcase `selector_update`:\n\t\tcase `transaction_update`: {\n\t\t\tfor (const atomUpdate of update.atomUpdates) {\n\t\t\t\tconst { key, newValue } = atomUpdate\n\t\t\t\tsetState({ key, type: `atom` }, newValue, store)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\t++timelineData.at\n\ttimelineData.subject.next(`redo`)\n\ttimelineData.timeTraveling = null\n\tstore.config.logger?.info(\n\t\t`⏹️ \"${token.key}\" is now at ${timelineData.at} / ${timelineData.history.length}`,\n\t)\n}\n\nexport const undo__INTERNAL = (\n\ttoken: TimelineToken,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tstore.config.logger?.info(`⏪ undo \"${token.key}\"`)\n\tconst timelineData = store.timelines.get(token.key)\n\tif (!timelineData) {\n\t\tstore.config.logger?.error(\n\t\t\t`Failed to undo on timeline \"${token.key}\". This timeline has not been initialized.`,\n\t\t)\n\t\treturn\n\t}\n\tif (timelineData.at === 0) {\n\t\tstore.config.logger?.warn(\n\t\t\t`Failed to undo at the beginning of timeline \"${token.key}\". There is nothing to undo.`,\n\t\t)\n\t\treturn\n\t}\n\ttimelineData.timeTraveling = `into_past`\n\n\t--timelineData.at\n\tconst update = timelineData.history[timelineData.at]\n\tswitch (update.type) {\n\t\tcase `atom_update`: {\n\t\t\tconst { key, oldValue } = update\n\t\t\tsetState({ key, type: `atom` }, oldValue, store)\n\t\t\tbreak\n\t\t}\n\t\tcase `selector_update`:\n\t\tcase `transaction_update`: {\n\t\t\tfor (const atomUpdate of update.atomUpdates) {\n\t\t\t\tconst { key, oldValue } = atomUpdate\n\t\t\t\tsetState({ key, type: `atom` }, oldValue, store)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\ttimelineData.subject.next(`undo`)\n\ttimelineData.timeTraveling = null\n\tstore.config.logger?.info(\n\t\t`⏹️ \"${token.key}\" is now at ${timelineData.at} / ${timelineData.history.length}`,\n\t)\n}\n","import { IMPLICIT, withdraw } from \"..\"\nimport type {\n\tTimeline,\n\tStore,\n\tTimelineTransactionUpdate,\n\tTimelineAtomUpdate,\n} from \"..\"\nimport type { AtomFamily, AtomToken, TimelineUpdate } from \"../..\"\n\nexport const addAtomToTimeline = (\n\tatomToken: AtomToken<any>,\n\tatoms: (AtomFamily<any> | AtomToken<any>)[],\n\ttl: Timeline,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst atom = withdraw(atomToken, store)\n\tif (atom === null) {\n\t\tthrow new Error(\n\t\t\t`Cannot subscribe to atom \"${atomToken.key}\" because it has not been initialized in store \"${store.config.name}\"`,\n\t\t)\n\t}\n\tatom.subject.subscribe((update) => {\n\t\tconst currentSelectorKey =\n\t\t\tstore.operation.open && store.operation.token.type === `selector`\n\t\t\t\t? store.operation.token.key\n\t\t\t\t: null\n\t\tconst currentSelectorTime =\n\t\t\tstore.operation.open && store.operation.token.type === `selector`\n\t\t\t\t? store.operation.time\n\t\t\t\t: null\n\t\tconst currentTransactionKey =\n\t\t\tstore.transactionStatus.phase === `applying`\n\t\t\t\t? store.transactionStatus.key\n\t\t\t\t: null\n\t\tconst currentTransactionTime =\n\t\t\tstore.transactionStatus.phase === `applying`\n\t\t\t\t? store.transactionStatus.time\n\t\t\t\t: null\n\n\t\tstore.config.logger?.info(\n\t\t\t`⏳ timeline \"${tl.key}\" saw atom \"${atomToken.key}\" go (`,\n\t\t\tupdate.oldValue,\n\t\t\t`->`,\n\t\t\tupdate.newValue,\n\t\t\tcurrentTransactionKey\n\t\t\t\t? `) in transaction \"${currentTransactionKey}\"`\n\t\t\t\t: currentSelectorKey\n\t\t\t\t? `) in selector \"${currentSelectorKey}\"`\n\t\t\t\t: `)`,\n\t\t)\n\n\t\tif (tl.timeTraveling === null) {\n\t\t\tif (tl.selectorTime && tl.selectorTime !== currentSelectorTime) {\n\t\t\t\tconst mostRecentUpdate: TimelineUpdate | undefined = tl.history.at(-1)\n\t\t\t\tif (mostRecentUpdate === undefined) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Timeline \"${tl.key}\" has a selectorTime, but no history. This is most likely a bug in AtomIO.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\tcurrentTransactionKey &&\n\t\t\t\tstore.transactionStatus.phase === `applying`\n\t\t\t) {\n\t\t\t\tconst currentTransaction = withdraw(\n\t\t\t\t\t{ key: currentTransactionKey, type: `transaction` },\n\t\t\t\t\tstore,\n\t\t\t\t)\n\t\t\t\tif (currentTransaction === null) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Transaction \"${currentTransactionKey}\" not found in store \"${store.config.name}\". This is surprising, because we are in the application phase of \"${currentTransactionKey}\".`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (tl.transactionKey !== currentTransactionKey) {\n\t\t\t\t\tif (tl.transactionKey) {\n\t\t\t\t\t\tstore.config.logger?.error(\n\t\t\t\t\t\t\t`Timeline \"${tl.key}\" was unable to resolve transaction \"${tl.transactionKey}. This is probably a bug.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\ttl.transactionKey = currentTransactionKey\n\t\t\t\t\tconst subscription = currentTransaction.subject.subscribe((update) => {\n\t\t\t\t\t\tsubscription.unsubscribe()\n\t\t\t\t\t\tif (tl.timeTraveling === null && currentTransactionTime) {\n\t\t\t\t\t\t\tif (tl.at !== tl.history.length) {\n\t\t\t\t\t\t\t\ttl.history.splice(tl.at)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst timelineTransactionUpdate: TimelineTransactionUpdate = {\n\t\t\t\t\t\t\t\ttype: `transaction_update`,\n\t\t\t\t\t\t\t\ttimestamp: currentTransactionTime,\n\t\t\t\t\t\t\t\t...update,\n\t\t\t\t\t\t\t\tatomUpdates: update.atomUpdates.filter((atomUpdate) =>\n\t\t\t\t\t\t\t\t\tatoms.some((atom) => atom.key === atomUpdate.key),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttl.history.push(timelineTransactionUpdate)\n\t\t\t\t\t\t\ttl.at = tl.history.length\n\t\t\t\t\t\t\ttl.subject.next(timelineTransactionUpdate)\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttl.transactionKey = null\n\t\t\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t\t\t`⌛ timeline \"${tl.key}\" got a transaction_update \"${update.key}\"`,\n\t\t\t\t\t\t)\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t} else if (currentSelectorKey && currentSelectorTime) {\n\t\t\t\tlet latestUpdate: TimelineUpdate | undefined = tl.history.at(-1)\n\n\t\t\t\tif (currentSelectorTime !== tl.selectorTime) {\n\t\t\t\t\tlatestUpdate = {\n\t\t\t\t\t\ttype: `selector_update`,\n\t\t\t\t\t\ttimestamp: currentSelectorTime,\n\t\t\t\t\t\tkey: currentSelectorKey,\n\t\t\t\t\t\tatomUpdates: [],\n\t\t\t\t\t}\n\t\t\t\t\tlatestUpdate.atomUpdates.push({\n\t\t\t\t\t\tkey: atom.key,\n\t\t\t\t\t\ttype: `atom_update`,\n\t\t\t\t\t\t...update,\n\t\t\t\t\t})\n\t\t\t\t\tif (tl.at !== tl.history.length) {\n\t\t\t\t\t\ttl.history.splice(tl.at)\n\t\t\t\t\t}\n\t\t\t\t\ttl.history.push(latestUpdate)\n\n\t\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t\t`⌛ timeline \"${tl.key}\" got a selector_update \"${currentSelectorKey}\" with`,\n\t\t\t\t\t\tlatestUpdate.atomUpdates.map((atomUpdate) => atomUpdate.key),\n\t\t\t\t\t)\n\n\t\t\t\t\ttl.at = tl.history.length\n\t\t\t\t\ttl.selectorTime = currentSelectorTime\n\t\t\t\t} else {\n\t\t\t\t\tif (latestUpdate?.type === `selector_update`) {\n\t\t\t\t\t\tlatestUpdate.atomUpdates.push({\n\t\t\t\t\t\t\tkey: atom.key,\n\t\t\t\t\t\t\ttype: `atom_update`,\n\t\t\t\t\t\t\t...update,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t\t\t` ⌛ timeline \"${tl.key}\" set selector_update \"${currentSelectorKey}\" to`,\n\t\t\t\t\t\t\tlatestUpdate?.atomUpdates.map((atomUpdate) => atomUpdate.key),\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (latestUpdate) tl.subject.next(latestUpdate)\n\t\t\t} else {\n\t\t\t\tconst timestamp = Date.now()\n\t\t\t\ttl.selectorTime = null\n\t\t\t\tif (tl.at !== tl.history.length) {\n\t\t\t\t\ttl.history.splice(tl.at)\n\t\t\t\t}\n\t\t\t\tconst atomUpdate: TimelineAtomUpdate = {\n\t\t\t\t\ttype: `atom_update`,\n\t\t\t\t\ttimestamp,\n\t\t\t\t\tkey: atom.key,\n\t\t\t\t\toldValue: update.oldValue,\n\t\t\t\t\tnewValue: update.newValue,\n\t\t\t\t}\n\t\t\t\ttl.history.push(atomUpdate)\n\t\t\t\ttl.subject.next(atomUpdate)\n\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t`⌛ timeline \"${tl.key}\" got an atom_update to \"${atom.key}\"`,\n\t\t\t\t)\n\t\t\t\ttl.at = tl.history.length\n\t\t\t}\n\t\t}\n\t})\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \".\"\nimport { Subject, target, IMPLICIT } from \".\"\nimport { addAtomToTimeline } from \"./timeline/add-atom-to-timeline\"\nimport type {\n\tStateUpdate,\n\tTimelineOptions,\n\tTimelineToken,\n\tTimelineUpdate,\n\tTransactionUpdate,\n} from \"..\"\n\nexport type TimelineAtomUpdate = StateUpdate<unknown> & {\n\tkey: string\n\ttype: `atom_update`\n\ttimestamp: number\n}\nexport type TimelineSelectorUpdate = {\n\tkey: string\n\ttype: `selector_update`\n\ttimestamp: number\n\tatomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[]\n}\nexport type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {\n\tkey: string\n\ttype: `transaction_update`\n\ttimestamp: number\n}\n\nexport type Timeline = {\n\tkey: string\n\tat: number\n\ttimeTraveling: `into_future` | `into_past` | null\n\thistory: TimelineUpdate[]\n\tselectorTime: number | null\n\ttransactionKey: string | null\n\tinstall: (store: Store) => void\n\tsubject: Subject<\n\t\t| TimelineAtomUpdate\n\t\t| TimelineSelectorUpdate\n\t\t| TimelineTransactionUpdate\n\t\t| `redo`\n\t\t| `undo`\n\t>\n}\n\nexport function timeline__INTERNAL(\n\toptions: TimelineOptions,\n\tstore: Store = IMPLICIT.STORE,\n\tdata: Timeline | null = null,\n): TimelineToken {\n\tconst tl: Timeline = {\n\t\tkey: options.key,\n\t\tat: 0,\n\t\ttimeTraveling: null,\n\t\tselectorTime: null,\n\t\ttransactionKey: null,\n\t\t...data,\n\t\thistory: data?.history.map((update) => ({ ...update })) ?? [],\n\t\tinstall: (store) => timeline__INTERNAL(options, store, tl),\n\t\tsubject: new Subject(),\n\t}\n\n\tconst core = target(store)\n\tfor (const tokenOrFamily of options.atoms) {\n\t\tconst timelineKey = core.timelineAtoms.getRelatedId(tokenOrFamily.key)\n\t\tif (timelineKey) {\n\t\t\tstore.config.logger?.error(\n\t\t\t\t`❌ Failed to add atom \"${tokenOrFamily.key}\" to timeline \"${options.key}\" because it belongs to timeline \"${timelineKey}\"`,\n\t\t\t)\n\t\t\tcontinue\n\t\t}\n\t\tif (tokenOrFamily.type === `atom_family`) {\n\t\t\tconst family = tokenOrFamily\n\t\t\tfamily.subject.subscribe((token) =>\n\t\t\t\taddAtomToTimeline(token, options.atoms, tl, store),\n\t\t\t)\n\t\t} else {\n\t\t\tconst token = tokenOrFamily\n\t\t\tif (`family` in token && token.family) {\n\t\t\t\tconst familyTimelineKey = core.timelineAtoms.getRelatedId(\n\t\t\t\t\ttoken.family.key,\n\t\t\t\t)\n\t\t\t\tif (familyTimelineKey) {\n\t\t\t\t\tstore.config.logger?.error(\n\t\t\t\t\t\t`❌ Failed to add atom \"${token.key}\" to timeline \"${options.key}\" because its family \"${token.family.key}\" belongs to timeline \"${familyTimelineKey}\"`,\n\t\t\t\t\t)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\taddAtomToTimeline(token, options.atoms, tl, store)\n\t\t}\n\t\tcore.timelineAtoms = core.timelineAtoms.set({\n\t\t\tatomKey: tokenOrFamily.key,\n\t\t\ttimelineKey: options.key,\n\t\t})\n\t}\n\n\tstore.timelines.set(options.key, tl)\n\tconst token: TimelineToken = {\n\t\tkey: options.key,\n\t\ttype: `timeline`,\n\t}\n\tstore.subject.timelineCreation.next(token)\n\treturn token\n}\n","import type { Store } from \"..\"\n\nexport const abortTransaction = (store: Store): void => {\n\tif (store.transactionStatus.phase === `idle`) {\n\t\tstore.config.logger?.warn(\n\t\t\t`abortTransaction called outside of a transaction. This is probably a bug.`,\n\t\t)\n\t\treturn\n\t}\n\tstore.transactionStatus = { phase: `idle` }\n\tstore.config.logger?.info(`🪂`, `transaction fail`)\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \"..\"\nimport { withdraw } from \"..\"\nimport type { AtomToken } from \"../..\"\nimport { setState } from \"../..\"\n\nexport const applyTransaction = <ƒ extends ƒn>(\n\toutput: ReturnType<ƒ>,\n\tstore: Store,\n): void => {\n\tif (store.transactionStatus.phase !== `building`) {\n\t\tstore.config.logger?.warn(\n\t\t\t`abortTransaction called outside of a transaction. This is probably a bug.`,\n\t\t)\n\t\treturn\n\t}\n\tstore.config.logger?.info(\n\t\t`🛃 apply transaction \"${store.transactionStatus.key}\"`,\n\t)\n\tstore.transactionStatus.phase = `applying`\n\tstore.transactionStatus.output = output\n\tconst { atomUpdates } = store.transactionStatus\n\n\tfor (const { key, newValue } of atomUpdates) {\n\t\tconst token: AtomToken<unknown> = { key, type: `atom` }\n\t\tif (!store.valueMap.has(token.key)) {\n\t\t\tconst newAtom = store.transactionStatus.core.atoms.get(token.key)\n\t\t\tif (!newAtom) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Absurd Error: Atom \"${token.key}\" not found while copying updates from transaction \"${store.transactionStatus.key}\" to store \"${store.config.name}\"`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tstore.atoms.set(newAtom.key, newAtom)\n\t\t\tstore.valueMap.set(newAtom.key, newAtom.default)\n\t\t\tstore.config.logger?.info(`🔧`, `add atom \"${newAtom.key}\"`)\n\t\t}\n\t\tsetState(token, newValue, store)\n\t}\n\tconst myTransaction = withdraw<ƒ>(\n\t\t{ key: store.transactionStatus.key, type: `transaction` },\n\t\tstore,\n\t)\n\tif (myTransaction === null) {\n\t\tthrow new Error(\n\t\t\t`Transaction \"${store.transactionStatus.key}\" not found. Absurd. How is this running?`,\n\t\t)\n\t}\n\tmyTransaction.subject.next({\n\t\tkey: store.transactionStatus.key,\n\t\tatomUpdates,\n\t\toutput,\n\t\tparams: store.transactionStatus.params as Parameters<ƒ>,\n\t})\n\tstore.transactionStatus = { phase: `idle` }\n\tstore.config.logger?.info(`🛬`, `transaction done`)\n}\n","import type { Store } from \"..\"\n\nexport const buildTransaction = (\n\tkey: string,\n\tparams: any[],\n\tstore: Store,\n): void => {\n\tstore.transactionStatus = {\n\t\tkey,\n\t\tphase: `building`,\n\t\ttime: Date.now(),\n\t\tcore: {\n\t\t\tatoms: new Map(store.atoms),\n\t\t\tatomsThatAreDefault: store.atomsThatAreDefault,\n\t\t\toperation: { open: false },\n\t\t\treadonlySelectors: new Map(store.readonlySelectors),\n\t\t\ttimelines: new Map(store.timelines),\n\t\t\ttimelineAtoms: store.timelineAtoms,\n\t\t\ttransactions: new Map(store.transactions),\n\t\t\tselectorAtoms: store.selectorAtoms,\n\t\t\tselectorGraph: store.selectorGraph,\n\t\t\tselectors: new Map(store.selectors),\n\t\t\tvalueMap: new Map(store.valueMap),\n\t\t},\n\t\tatomUpdates: [],\n\t\tparams,\n\t\toutput: undefined,\n\t}\n\tstore.config.logger?.info(\n\t\t`🛫`,\n\t\t`transaction \"${key}\" started in store \"${store.config.name}\"`,\n\t)\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \"..\"\nimport { withdraw } from \"..\"\nimport type { AtomToken, TransactionUpdate } from \"../..\"\nimport { setState } from \"../..\"\n\nexport const redoTransactionUpdate = <ƒ extends ƒn>(\n\tupdate: TransactionUpdate<ƒ>,\n\tstore: Store,\n): void => {\n\tstore.config.logger?.info(` ⏭ redo transaction \"${update.key}\" (redo)`)\n\tfor (const { key, newValue } of update.atomUpdates) {\n\t\tconst token: AtomToken<unknown> = { key, type: `atom` }\n\t\tconst state = withdraw(token, store)\n\t\tif (state === null) {\n\t\t\tthrow new Error(\n\t\t\t\t`State \"${token.key}\" not found in this store. This is surprising, because we are navigating the history of the store.`,\n\t\t\t)\n\t\t}\n\t\tsetState(state, newValue, store)\n\t}\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \"..\"\nimport { withdraw } from \"..\"\nimport type { AtomToken, TransactionUpdate } from \"../..\"\nimport { setState } from \"../..\"\n\nexport const undoTransactionUpdate = <ƒ extends ƒn>(\n\tupdate: TransactionUpdate<ƒ>,\n\tstore: Store,\n): void => {\n\tstore.config.logger?.info(` ⏮ undo transaction \"${update.key}\" (undo)`)\n\tfor (const { key, oldValue } of update.atomUpdates) {\n\t\tconst token: AtomToken<unknown> = { key, type: `atom` }\n\t\tconst state = withdraw(token, store)\n\t\tif (state === null) {\n\t\t\tthrow new Error(\n\t\t\t\t`State \"${token.key}\" not found in this store. This is surprising, because we are navigating the history of the store.`,\n\t\t\t)\n\t\t}\n\t\tsetState(state, oldValue, store)\n\t}\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { StoreCore } from \"..\"\nimport type { StateUpdate, TransactionUpdate } from \"../..\"\n\nexport * from \"./abort-transaction\"\nexport * from \"./apply-transaction\"\nexport * from \"./build-transaction\"\nexport * from \"./redo-transaction\"\nexport * from \"./undo-transaction\"\n\nexport const TRANSACTION_PHASES = [`idle`, `building`, `applying`] as const\nexport type TransactionPhase = typeof TRANSACTION_PHASES[number]\n\nexport type TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdate<ƒ> & {\n\tphase: `applying` | `building`\n\ttime: number\n\tcore: StoreCore\n}\nexport type TransactionIdle = {\n\tphase: `idle`\n}\nexport type TransactionStatus<ƒ extends ƒn> =\n\t| TransactionIdle\n\t| TransactionUpdateInProgress<ƒ>\n","import type { Json } from \"~/packages/anvl/src/json\"\n\nimport type { AtomToken } from \".\"\nimport type { Subject } from \"./internal\"\nimport { atomFamily__INTERNAL, atom__INTERNAL } from \"./internal\"\n\nexport type Effectors<T> = {\n\tsetSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void\n\tonSet: (callback: (options: { newValue: T; oldValue: T }) => void) => void\n}\n\nexport type AtomEffect<T> = (tools: Effectors<T>) => void\n\nexport type AtomOptions<T> = {\n\tkey: string\n\tdefault: T | (() => T)\n\teffects?: AtomEffect<T>[]\n}\n\nexport function atom<T>(options: AtomOptions<T>): AtomToken<T> {\n\treturn atom__INTERNAL<T>(options)\n}\n\nexport type AtomFamilyOptions<T, K extends Json.Serializable> = {\n\tkey: string\n\tdefault: T | ((key: K) => T)\n\teffects?: (key: K) => AtomEffect<T>[]\n}\n\nexport type AtomFamily<T, K extends Json.Serializable = Json.Serializable> = ((\n\tkey: K,\n) => AtomToken<T>) & {\n\tkey: string\n\ttype: `atom_family`\n\tsubject: Subject<AtomToken<T>>\n}\n\nexport function atomFamily<T, K extends Json.Serializable>(\n\toptions: AtomFamilyOptions<T, K>,\n): AtomFamily<T, K> {\n\treturn atomFamily__INTERNAL<T, K>(options)\n}\n","import { doNothing } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \"./internal/store\"\nimport { IMPLICIT } from \"./internal/store\"\n\nexport type Logger = Pick<Console, `error` | `info` | `warn`>\nexport const LOG_LEVELS: ReadonlyArray<keyof Logger> = [\n\t`info`,\n\t`warn`,\n\t`error`,\n] as const\n\nexport const setLogLevel = (\n\tpreferredLevel: `error` | `info` | `warn` | null,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst { logger__INTERNAL } = store.config\n\tif (preferredLevel === null) {\n\t\tstore.config.logger = null\n\t} else {\n\t\tstore.config.logger = { ...console }\n\t\tLOG_LEVELS.forEach((logLevel) => {\n\t\t\tif (LOG_LEVELS.indexOf(logLevel) < LOG_LEVELS.indexOf(preferredLevel)) {\n\t\t\t\t// rome-ignore lint/style/noNonNullAssertion: we just set it\n\t\t\t\tstore.config.logger![logLevel] = doNothing\n\t\t\t} else {\n\t\t\t\t// rome-ignore lint/style/noNonNullAssertion: we just set it\n\t\t\t\tstore.config.logger![logLevel] = logger__INTERNAL[logLevel]\n\t\t\t}\n\t\t})\n\t}\n}\n\nexport const useLogger = (\n\tlogger: Logger,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst currentLogLevel =\n\t\tstore.config.logger === null\n\t\t\t? null\n\t\t\t: LOG_LEVELS.find(\n\t\t\t\t\t(logLevel) => store.config.logger?.[logLevel] !== doNothing,\n\t\t\t ) ?? null\n\tstore.config.logger__INTERNAL = { ...logger }\n\tsetLogLevel(currentLogLevel, store)\n}\n","import type { Json } from \"~/packages/anvl/src/json\"\n\nimport type { ReadonlySelectorToken, SelectorToken } from \".\"\nimport type { Subject } from \"./internal\"\nimport { selectorFamily__INTERNAL, selector__INTERNAL } from \"./internal\"\nimport type { Read, Write } from \"./transaction\"\n\nexport type SelectorOptions<T> = {\n\tkey: string\n\tget: Read<() => T>\n\tset: Write<(newValue: T) => void>\n}\nexport type ReadonlySelectorOptions<T> = {\n\tkey: string\n\tget: Read<() => T>\n}\n\nexport function selector<T>(options: SelectorOptions<T>): SelectorToken<T>\nexport function selector<T>(\n\toptions: ReadonlySelectorOptions<T>,\n): ReadonlySelectorToken<T>\nexport function selector<T>(\n\toptions: ReadonlySelectorOptions<T> | SelectorOptions<T>,\n): ReadonlySelectorToken<T> | SelectorToken<T> {\n\treturn selector__INTERNAL(options)\n}\n\nexport type SelectorFamilyOptions<T, K extends Json.Serializable> = {\n\tkey: string\n\tget: (key: K) => Read<() => T>\n\tset: (key: K) => Write<(newValue: T) => void>\n}\nexport type ReadonlySelectorFamilyOptions<T, K extends Json.Serializable> = {\n\tkey: string\n\tget: (key: K) => Read<() => T>\n}\n\nexport type SelectorFamily<\n\tT,\n\tK extends Json.Serializable = Json.Serializable,\n> = ((key: K) => SelectorToken<T>) & {\n\tkey: string\n\ttype: `selector_family`\n\tsubject: Subject<SelectorToken<T>>\n}\n\nexport type ReadonlySelectorFamily<\n\tT,\n\tK extends Json.Serializable = Json.Serializable,\n> = ((key: K) => ReadonlySelectorToken<T>) & {\n\tkey: string\n\ttype: `readonly_selector_family`\n\tsubject: Subject<ReadonlySelectorToken<T>>\n}\n\nexport function selectorFamily<T, K extends Json.Serializable>(\n\toptions: SelectorFamilyOptions<T, K>,\n): SelectorFamily<T, K>\nexport function selectorFamily<T, K extends Json.Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K>,\n): ReadonlySelectorFamily<T, K>\nexport function selectorFamily<T, K extends Json.Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K> | SelectorFamilyOptions<T, K>,\n): ReadonlySelectorFamily<T, K> | SelectorFamily<T, K> {\n\treturn selectorFamily__INTERNAL(options)\n}\n","import type { redo, timeline, undo } from \".\"\nimport { getState, setState, subscribe } from \".\"\nimport type { atom, atomFamily } from \"./atom\"\nimport type { Store } from \"./internal\"\nimport {\n\tatomFamily__INTERNAL,\n\tatom__INTERNAL,\n\tcreateStore,\n\tredo__INTERNAL,\n\tselectorFamily__INTERNAL,\n\tselector__INTERNAL,\n\ttimeline__INTERNAL,\n\ttransaction__INTERNAL,\n\tundo__INTERNAL,\n} from \"./internal\"\nimport type { selector, selectorFamily } from \"./selector\"\nimport type { transaction } from \"./transaction\"\n\nexport type Silo = ReturnType<typeof silo>\n\nexport const silo = (\n\tname: string,\n\tfromStore: Store | null = null,\n): {\n\tstore: Store\n\tatom: typeof atom\n\tatomFamily: typeof atomFamily\n\tselector: typeof selector\n\tselectorFamily: typeof selectorFamily\n\ttransaction: typeof transaction\n\ttimeline: typeof timeline\n\tgetState: typeof getState\n\tsetState: typeof setState\n\tsubscribe: typeof subscribe\n\tundo: typeof undo\n\tredo: typeof redo\n} => {\n\tconst store = createStore(name, fromStore)\n\treturn {\n\t\tstore,\n\t\tatom: (options) => atom__INTERNAL(options, undefined, store),\n\t\tatomFamily: (options) => atomFamily__INTERNAL(options, store),\n\t\tselector: (options) => selector__INTERNAL(options, undefined, store) as any,\n\t\tselectorFamily: (options) => selectorFamily__INTERNAL(options, store) as any,\n\t\ttransaction: (options) => transaction__INTERNAL(options, store),\n\t\ttimeline: (options) => timeline__INTERNAL(options, store),\n\t\tgetState: (token) => getState(token, store),\n\t\tsetState: (token, newValue) => setState(token, newValue, store),\n\t\tsubscribe: (token, handler) => subscribe(token, handler, store),\n\t\tundo: (token) => undo__INTERNAL(token, store),\n\t\tredo: (token) => redo__INTERNAL(token, store),\n\t}\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type {\n\tReadonlySelectorToken,\n\tStateToken,\n\tTimelineToken,\n\tTimelineUpdate,\n\tTransactionToken,\n\tTransactionUpdate,\n} from \".\"\nimport type { Store } from \"./internal\"\nimport { IMPLICIT, subscribeToRootAtoms, withdraw } from \"./internal\"\n\nexport type StateUpdate<T> = { newValue: T; oldValue: T }\nexport type KeyedStateUpdate<T> = StateUpdate<T> & { key: string }\nexport type UpdateHandler<T> = (update: StateUpdate<T>) => void\n\nexport const subscribe = <T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\thandleUpdate: UpdateHandler<T>,\n\tstore: Store = IMPLICIT.STORE,\n): (() => void) => {\n\tconst state = withdraw<T>(token, store)\n\tif (state === null) {\n\t\tthrow new Error(\n\t\t\t`State \"${token.key}\" not found in this store. Did you forget to initialize with the \"atom\" or \"selector\" function?`,\n\t\t)\n\t}\n\tconst subscription = state.subject.subscribe(handleUpdate)\n\tstore.config.logger?.info(`👀 subscribe to \"${state.key}\"`)\n\tconst dependencySubscriptions =\n\t\tstate.type !== `atom` ? subscribeToRootAtoms(state, store) : null\n\n\tconst unsubscribe =\n\t\tdependencySubscriptions === null\n\t\t\t? () => {\n\t\t\t\t\tstore.config.logger?.info(`🙈 unsubscribe from \"${state.key}\"`)\n\t\t\t\t\tsubscription.unsubscribe()\n\t\t\t }\n\t\t\t: () => {\n\t\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t\t`🙈 unsubscribe from \"${state.key}\" and its dependencies`,\n\t\t\t\t\t)\n\t\t\t\t\tsubscription.unsubscribe()\n\t\t\t\t\tfor (const dependencySubscription of dependencySubscriptions) {\n\t\t\t\t\t\tdependencySubscription.unsubscribe()\n\t\t\t\t\t}\n\t\t\t }\n\n\treturn unsubscribe\n}\n\nexport type TransactionUpdateHandler<ƒ extends ƒn> = (\n\tdata: TransactionUpdate<ƒ>,\n) => void\n\nexport const subscribeToTransaction = <ƒ extends ƒn>(\n\ttoken: TransactionToken<ƒ>,\n\thandleUpdate: TransactionUpdateHandler<ƒ>,\n\tstore = IMPLICIT.STORE,\n): (() => void) => {\n\tconst tx = withdraw(token, store)\n\tif (tx === null) {\n\t\tthrow new Error(\n\t\t\t`Cannot subscribe to transaction \"${token.key}\": transaction not found in store \"${store.config.name}\".`,\n\t\t)\n\t}\n\tstore.config.logger?.info(`👀 subscribe to transaction \"${token.key}\"`)\n\tconst subscription = tx.subject.subscribe(handleUpdate)\n\tconst unsubscribe = () => {\n\t\tstore.config.logger?.info(`🙈 unsubscribe from transaction \"${token.key}\"`)\n\t\tsubscription.unsubscribe()\n\t}\n\treturn unsubscribe\n}\n\nexport const subscribeToTimeline = (\n\ttoken: TimelineToken,\n\thandleUpdate: (update: TimelineUpdate | `redo` | `undo`) => void,\n\tstore = IMPLICIT.STORE,\n): (() => void) => {\n\tconst tl = withdraw(token, store)\n\tif (tl === null) {\n\t\tthrow new Error(\n\t\t\t`Cannot subscribe to timeline \"${token.key}\": timeline not found in store \"${store.config.name}\".`,\n\t\t)\n\t}\n\tstore.config.logger?.info(`👀 subscribe to timeline \"${token.key}\"`)\n\tconst subscription = tl.subject.subscribe(handleUpdate)\n\tconst unsubscribe = () => {\n\t\tstore.config.logger?.info(`🙈 unsubscribe from timeline \"${token.key}\"`)\n\t\tsubscription.unsubscribe()\n\t}\n\treturn unsubscribe\n}\n","import type { AtomFamily, AtomToken } from \".\"\nimport type {\n\tTimelineAtomUpdate,\n\tTimelineSelectorUpdate,\n\tTimelineTransactionUpdate,\n} from \"./internal\"\nimport { IMPLICIT } from \"./internal\"\nimport { redo__INTERNAL, timeline__INTERNAL, undo__INTERNAL } from \"./internal/\"\n\nexport type TimelineToken = {\n\tkey: string\n\ttype: `timeline`\n}\n\nexport type TimelineOptions = {\n\tkey: string\n\tatoms: (AtomFamily<any, any> | AtomToken<any>)[]\n}\n\nexport type TimelineUpdate =\n\t| TimelineAtomUpdate\n\t| TimelineSelectorUpdate\n\t| TimelineTransactionUpdate\n\nexport const timeline = (options: TimelineOptions): TimelineToken => {\n\treturn timeline__INTERNAL(options)\n}\n\nexport const redo = (token: TimelineToken): void => {\n\tredo__INTERNAL(token, IMPLICIT.STORE)\n}\n\nexport const undo = (token: TimelineToken): void => {\n\tundo__INTERNAL(token, IMPLICIT.STORE)\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { KeyedStateUpdate, ReadonlySelectorToken, StateToken } from \".\"\nimport type { Store } from \"./internal\"\nimport { IMPLICIT, transaction__INTERNAL, withdraw } from \"./internal\"\n\nexport type TransactionToken<_> = {\n\tkey: string\n\ttype: `transaction`\n\t__brand?: _\n}\n\nexport type TransactionUpdate<ƒ extends ƒn> = {\n\tkey: string\n\tatomUpdates: KeyedStateUpdate<unknown>[]\n\tparams: Parameters<ƒ>\n\toutput: ReturnType<ƒ>\n}\n\nexport type Transactors = {\n\tget: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S\n\tset: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void\n}\nexport type ReadonlyTransactors = Pick<Transactors, `get`>\n\nexport type Read<ƒ extends ƒn> = (\n\ttransactors: ReadonlyTransactors,\n\t...parameters: Parameters<ƒ>\n) => ReturnType<ƒ>\n\nexport type Write<ƒ extends ƒn> = (\n\ttransactors: Transactors,\n\t...parameters: Parameters<ƒ>\n) => ReturnType<ƒ>\n\nexport type TransactionOptions<ƒ extends ƒn> = {\n\tkey: string\n\tdo: Write<ƒ>\n}\n\nexport type TransactionIO<Token extends TransactionToken<any>> =\n\tToken extends TransactionToken<infer ƒ> ? ƒ : never\n\nexport function transaction<ƒ extends ƒn>(\n\toptions: TransactionOptions<ƒ>,\n): TransactionToken<ƒ> {\n\treturn transaction__INTERNAL(options)\n}\n\nexport const runTransaction =\n\t<ƒ extends ƒn>(token: TransactionToken<ƒ>, store: Store = IMPLICIT.STORE) =>\n\t(...parameters: Parameters<ƒ>): ReturnType<ƒ> => {\n\t\tconst tx = withdraw(token, store)\n\t\tif (tx) {\n\t\t\treturn tx.run(...parameters)\n\t\t}\n\t\tthrow new Error(\n\t\t\t`Cannot run transaction \"${token.key}\": transaction not found in store \"${store.config.name}\".`,\n\t\t)\n\t}\n","import { capitalize } from \"~/packages/anvl/src/string/capitalize\"\n\nimport {\n\tIMPLICIT,\n\tcloseOperation,\n\topenOperation,\n\tgetState__INTERNAL,\n\tsetState__INTERNAL,\n\tisAtomDefault,\n\tisSelectorDefault,\n\twithdraw,\n} from \"./internal\"\nimport * as __INTERNAL__ from \"./internal\"\nimport type { Store } from \"./internal/store\"\n\nexport * from \"./atom\"\nexport * from \"./logger\"\nexport * from \"./selector\"\nexport * from \"./silo\"\nexport * from \"./subscribe\"\nexport * from \"./timeline\"\nexport * from \"./transaction\"\nexport { __INTERNAL__ }\nexport type { Store } from \"./internal/store\"\nexport type { Json } from \"~/packages/anvl/src/json\"\n\nexport type AtomToken<_> = {\n\tkey: string\n\ttype: `atom`\n\tfamily?: FamilyMetadata\n\t__brand?: _\n}\nexport type SelectorToken<_> = {\n\tkey: string\n\ttype: `selector`\n\tfamily?: FamilyMetadata\n\t__brand?: _\n}\nexport type StateToken<T> = AtomToken<T> | SelectorToken<T>\n\nexport type ReadonlySelectorToken<_> = {\n\tkey: string\n\ttype: `readonly_selector`\n\tfamily?: FamilyMetadata\n\t__brand?: _\n}\n\nexport type FamilyMetadata = {\n\tkey: string\n\tsubKey: string\n}\n\nexport const getState = <T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\tstore: Store = IMPLICIT.STORE,\n): T => {\n\tconst state = withdraw<T>(token, store)\n\tif (state === null) {\n\t\tthrow new Error(\n\t\t\t`${capitalize(token.type)} \"${token.key}\" not found in store \"${\n\t\t\t\tstore.config.name\n\t\t\t}\".`,\n\t\t)\n\t}\n\treturn getState__INTERNAL(state, store)\n}\n\nexport const setState = <T, New extends T>(\n\ttoken: StateToken<T>,\n\tvalue: New | ((oldValue: T) => New),\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\ttry {\n\t\topenOperation(token, store)\n\t} catch (thrown) {\n\t\tif (!(typeof thrown === `symbol`)) {\n\t\t\tthrow thrown\n\t\t}\n\t\treturn\n\t}\n\tconst state = withdraw(token, store)\n\tif (state === null) {\n\t\tthrow new Error(\n\t\t\t`${capitalize(token.type)} \"${token.key}\" not found in store \"${\n\t\t\t\tstore.config.name\n\t\t\t}\".`,\n\t\t)\n\t}\n\tsetState__INTERNAL(state, value, store)\n\tcloseOperation(store)\n}\n\nexport const isDefault = (\n\ttoken: ReadonlySelectorToken<unknown> | StateToken<unknown>,\n\tstore: Store = IMPLICIT.STORE,\n): boolean =>\n\ttoken.type === `atom`\n\t\t? isAtomDefault(token.key, store)\n\t\t: isSelectorDefault(token.key, store)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAM,aAAa,CAAC,QAC1B,IAAI,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC;;;ACDnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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c,MAAM,KAAK,KAAK,IAC9B,kBAAkB,MAAM,KAAK,KAAK;","names":["selector","pipe","pipe","join","pipe","pipe","isString","pipe","pipe","isString","map","map","id","pipe","atom","selector","timeline","atom","selector","token","store","_a","_a","_b","state","atom","selector","atom","atom","update","_a","store","token","_a","_a"]}
|