/** * Configuration <-> StateValue helpers (ports of XState `stateUtils`): * `getStateValue`, `matchesState`, `toStatePath`, `pathToStateValue`, * `getStateNodeById`, `getStateNodeByPath`. Spec: section 3.8. `normalize` * reuses the lookups (with a config path for its errors) and `toStatePath`. */ import type { EventObject, MachineContext, StateValue } from "../types/index.js"; import type { MachineModel, StateNode } from "./model.js"; /** Splits `"a.b.c"` into `["a", "b", "c"]`; a backslash escapes the next character. */ export declare function toStatePath(stateId: string): string[]; /** `["a", "b", "c"]` -> `{ a: { b: "c" } }`; a single segment stays a string. */ export declare function pathToStateValue(statePath: readonly string[]): StateValue; /** * XState `matchesState`: is `parentStateValue` (string path or partial object) * a prefix of `childStateValue`? Strings are expanded with `toStatePath` first, * so `"a.b"` matches `{ a: "b" }` and `{ a: { b: "c" } }`. */ export declare function matchesState(parentStateValue: StateValue, childStateValue: StateValue): boolean; /** * XState `getStateValue`: state value of a configuration. A compound node * with an atomic/final active child -> the child's key; a compound node with * a non-atomic child -> `{ key: }`; a parallel node -> an object * with every region (an atomic region renders as `{}`). The result is deeply * frozen. A partial configuration is completed with initial states first * (XState `getAllStateNodes`), so the pre-initial `{ root }` already reads as * the initial value. */ export declare function getStateValue(model: MachineModel, configuration: ReadonlySet>): StateValue; /** * What `#id` resolution needs: the machine id (for the error message) and the * id map. A finished `MachineModel` satisfies it; `normalize` passes its build * context while the model is still being assembled. */ export interface StateNodeLookup { readonly id: string; readonly idMap: ReadonlyMap>; } /** * XState `getStateNodeById`: `"#id"` / `"id"` optionally followed by * `".child.path"`. Throws `MachineConfigError` (XState's message) when unknown; * `configPath` is the path the error is attributed to (`""` = root). */ export declare function getStateNodeById(lookup: StateNodeLookup, stateId: string, configPath?: string): StateNode; /** * XState `getStateNodeByPath`: walks child keys from `node`. An empty segment * stops the walk (`"."` resolves to `node` itself). Throws `MachineConfigError` * (XState's message) when a key does not exist; `configPath` is the path the * error is attributed to (`""` = root). */ export declare function getStateNodeByPath(node: StateNode, statePath: string | readonly string[], configPath?: string): StateNode; /** Deduplicated tags of a configuration, in document order of the nodes; frozen. */ export declare function collectTags(configuration: ReadonlySet>): readonly string[];