@mark1russell7/vex 0.18.0 → 0.19.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["NONE","isObject","FORBIDDEN","TERMS","vexOk","vexFail","partsOf","ok","withItem","accepts","WITH_ARGUMENT","NONE","term","path","Refusal","kindOf","isNone","joinKind","kindOfJoin","kindOf","reference","kernelReference","agree","kernelAgree","spaces","keyMove","indexMove","offsetMove","otherMove","originMove","parentMove","fnExpr","callExpr","iterateExpr","lastExpr","fixExpr","foldExpr","cellRef"],"sources":["../src/result.ts","../src/errors.ts","../src/checked.ts","../src/list.ts","../src/error-text.ts","../src/item-names.ts","../src/ir.ts","../src/space.ts","../src/domain.ts","../src/array-list.ts","../src/codec.ts","../src/limit-error.ts","../src/fix.ts","../src/same.ts","../src/kernel.ts","../src/write.ts","../src/document.ts","../src/monotone.ts","../src/size.ts","../src/constructs.ts","../src/steps.ts","../src/evaluate.ts","../src/deps.ts","../src/json.ts","../src/plan.ts","../src/traversal.ts","../src/sheet.ts","../src/builder.ts"],"sourcesContent":["import type { Optional as FamilyOptional } from \"@mark1russell7/optional\";\nimport type { VexError } from \"./errors.ts\";\n\n/**\n * A value that is there, or not there. This is the public result of a Vex program. It is the Optional of the\n * family (`@mark1russell7/optional`), so render and Vex give and take the same values. The import is a type import\n * only: the build copies the type into the declarations, so the package has no runtime dependency.\n */\nexport type Optional<T> = FamilyOptional<T>;\n\n/** A value, or the error that tells why there is no value. The interpreter uses this type. */\nexport type Result<T> = { readonly ok: true; readonly value: T } | { readonly ok: false; readonly error: VexError };\n\nconst NONE: Optional<never> = Object.freeze({ tag: \"none\" });\n\n/** This function makes an `Optional` that holds `value`. */\nexport const some = <T>(value: T): Optional<T> => ({ tag: \"some\", value });\n\n/** This function gives the shared empty `Optional`. */\nexport const none = <T = never>(): Optional<T> => NONE;\n\n/** This function makes a successful `Result`. */\nexport const ok = <T>(value: T): Result<T> => ({ ok: true, value });\n\n/** This function makes a failed `Result`. */\nexport const fail = <T = never>(error: VexError): Result<T> => ({ ok: false, error });\n\n/** This function tells if an `Optional` holds a value. */\nexport const isSome = <T>(o: Optional<T>): o is { readonly tag: \"some\"; readonly value: T } => o.tag === \"some\";\n\n/** This function tells if an `Optional` is empty. */\nexport const isNone = <T>(o: Optional<T>): o is { readonly tag: \"none\" } => o.tag === \"none\";\n\n/** This function changes a `Result` into an `Optional`. The error is lost. */\nexport const toOptional = <T>(r: Result<T>): Optional<T> => (r.ok ? some(r.value) : none());\n\n/** This function gives the value of an `Optional`, or `fallback` if it is empty. */\nexport const getOr = <T, U>(o: Optional<T>, fallback: U): T | U => (o.tag === \"some\" ? o.value : fallback);\n\n/** This function applies `f` to the value of a `Result`. An error stays the same. */\nexport const mapResult = <T, U>(r: Result<T>, f: (value: T) => U): Result<U> => (r.ok ? ok(f(r.value)) : r);\n\n/** This function applies `f` to the value of a `Result`, and `f` gives a `Result`. An error stays the same. */\nexport const chainResult = <T, U>(r: Result<T>, f: (value: T) => Result<U>): Result<U> => (r.ok ? f(r.value) : r);\n","import type { KernelCode } from \"@mark1russell7/coeval\";\n\n/**\n * The error codes of Vex. The names come from the spreadsheet error values, because a Vex program is a spreadsheet\n * formula over records. Each code is a code of the kernel of coeval with the same meaning. For example, `#N/A` is a step\n * that reaches nothing, and `#DEPTH!` is a full call stack. The type checks it: a code that the kernel does not have is\n * not a member.\n */\nexport type ErrorCode = Extract<KernelCode, \"#REF!\" | \"#N/A\" | \"#VALUE!\" | \"#NAME?\" | \"#NUM!\" | \"#CALC!\" | \"#ARGS\" | \"#CYCLE!\" | \"#DEPTH!\">;\n\n/** The cause of an error, in more detail than the code. */\nexport type ErrorKind =\n | \"unknown-key\"\n | \"not-a-pair\"\n | \"out-of-bounds\"\n | \"no-offset\"\n | \"no-grid\"\n | \"no-tree\"\n | \"no-table\"\n | \"no-graph\"\n | \"missing-field\"\n | \"empty\"\n | \"not-instance\"\n | \"kind-mismatch\"\n | \"unknown-op\"\n | \"unbound\"\n | \"not-finite\"\n | \"invalid-value\"\n | \"threw\"\n | \"undefined-result\"\n | \"args\"\n | \"cycle\"\n | \"depth\"\n | \"bad-expression\"\n | \"limit\";\n\nconst CODE_OF: Readonly<Record<ErrorKind, ErrorCode>> = {\n \"unknown-key\": \"#REF!\",\n \"not-a-pair\": \"#REF!\",\n \"out-of-bounds\": \"#REF!\",\n \"no-offset\": \"#REF!\",\n \"no-grid\": \"#REF!\",\n \"no-tree\": \"#REF!\",\n \"no-table\": \"#REF!\",\n \"no-graph\": \"#REF!\",\n \"missing-field\": \"#N/A\",\n empty: \"#N/A\",\n \"not-instance\": \"#VALUE!\",\n \"kind-mismatch\": \"#VALUE!\",\n \"bad-expression\": \"#VALUE!\",\n \"unknown-op\": \"#NAME?\",\n unbound: \"#NAME?\",\n \"not-finite\": \"#NUM!\",\n \"invalid-value\": \"#NUM!\",\n limit: \"#NUM!\",\n threw: \"#CALC!\",\n \"undefined-result\": \"#CALC!\",\n args: \"#ARGS\",\n cycle: \"#CYCLE!\",\n depth: \"#DEPTH!\",\n};\n\n/**\n * This function tells if an exception is the report of the engine that the call stack is full. V8 and JavaScriptCore\n * throw a `RangeError`. SpiderMonkey throws an `InternalError` (\"too much recursion\").\n */\nexport function isStackOverflow(thrown: unknown): boolean {\n if (!(thrown instanceof Error)) return false;\n return (thrown instanceof RangeError && /call stack/i.test(thrown.message)) || (thrown.name === \"InternalError\" && /recursion/i.test(thrown.message));\n}\n\n/** This function tells if an error is `#DEPTH!`. `ifError` and the reductions that skip errors do not hide it (EVAL.DEPTH). */\nexport const isDepthError = (e: VexError): boolean => e.kind === \"depth\";\n\n/** A Vex error. It is a value: a program can catch it with `ifError`, except `#DEPTH!`. */\nexport interface VexError {\n /** The spreadsheet-style code, for example `#REF!`. */\n readonly code: ErrorCode;\n /** The cause in more detail. */\n readonly kind: ErrorKind;\n /** A sentence that tells what went wrong. */\n readonly message: string;\n /** The position of the failed node in the expression tree. The root is `[]`. */\n readonly path: readonly number[];\n /** The key where the evaluation started. */\n readonly origin?: string;\n /** The key where relative references read when the error occurred. */\n readonly focus?: string;\n /** The op name, for errors of an op. */\n readonly op?: string;\n /** The errors of the arguments, for the code `#ARGS`. */\n readonly causes?: readonly VexError[];\n /** The value that an op threw, for the kind `threw`. */\n readonly thrown?: unknown;\n}\n\n/** The details that a caller can give to `vexError`. */\nexport interface ErrorDetails {\n readonly path?: readonly number[];\n readonly origin?: string;\n readonly focus?: string;\n readonly op?: string;\n readonly causes?: readonly VexError[];\n readonly thrown?: unknown;\n}\n\n/** This function gives the code of an error kind. */\nexport const codeOf = (kind: ErrorKind): ErrorCode => CODE_OF[kind];\n\n/** This function makes a `VexError`. */\nexport function vexError(kind: ErrorKind, message: string, details: ErrorDetails = {}): VexError {\n return {\n code: CODE_OF[kind],\n kind,\n message,\n path: details.path ?? [],\n ...(details.origin === undefined ? {} : { origin: details.origin }),\n ...(details.focus === undefined ? {} : { focus: details.focus }),\n ...(details.op === undefined ? {} : { op: details.op }),\n ...(details.causes === undefined ? {} : { causes: details.causes }),\n ...(details.thrown === undefined ? {} : { thrown: details.thrown }),\n };\n}\n\n/** This function gives a short text for an error, for example `#REF! unknown-key: there is no key \"Z\"`. */\nexport const formatError = (e: VexError): string => `${e.code} ${e.kind}: ${e.message}`;\n","/**\n * The cache of the lists that passed the check of LIST.SHAPE. `isVexList` adds each frozen list that passes its check.\n * The interpreter adds each list that it makes from the items of such lists, because these items passed the check.\n * The package index does not export this module.\n */\nexport const CHECKED: WeakSet<object> = new WeakSet<object>();\n","import { CHECKED } from \"./checked.ts\";\nimport type { SizeRule } from \"./domain.ts\";\nimport type { Result } from \"./result.ts\";\n\n/** One item of a list: the key of the target and the result of the body there. */\nexport interface ListItem<T = unknown> {\n readonly key: string;\n readonly result: Result<T>;\n}\n\n/** The value of an `each` expression: one item for each target of the axis. */\nexport interface VexList<T = unknown> {\n readonly kind: \"vex.list\";\n readonly items: readonly ListItem<T>[];\n}\n\n/** This function makes a list. */\nexport const vexList = <T>(items: readonly ListItem<T>[]): VexList<T> => Object.freeze({ kind: \"vex.list\", items: Object.freeze([...items]) });\n\n/** This function tells if a value is an error value: a text `code`, `kind` and `message`, and a `path` (LIST.SHAPE). */\nconst isErrorValue = (u: unknown): boolean => {\n if (typeof u !== \"object\" || u === null) return false;\n const e = u as { code?: unknown; kind?: unknown; message?: unknown; path?: unknown };\n return typeof e.code === \"string\" && typeof e.kind === \"string\" && typeof e.message === \"string\" && Array.isArray(e.path);\n};\n\n/** This function tells if a value is an item of a list: a text key, and a value or an error value (LIST.SHAPE). */\nconst isListItem = (u: unknown): boolean => {\n if (typeof u !== \"object\" || u === null) return false;\n const { key, result } = u as { key?: unknown; result?: unknown };\n if (typeof key !== \"string\" || typeof result !== \"object\" || result === null) return false;\n const r = result as { ok?: unknown; value?: unknown; error?: unknown };\n return r.ok === true ? r.value !== undefined : r.ok === false && isErrorValue(r.error);\n};\n\n/**\n * This function tells if a value is a Vex list (LIST.SHAPE). A list has the kind `vex.list`, and each item has a text key\n * and a result. Another value with the kind `vex.list` is a record, so no list op applies to it. A frozen\n * list passes the check once.\n */\nexport const isVexList = (u: unknown): u is VexList => {\n if (typeof u !== \"object\" || u === null) return false;\n // Stryker disable next-line ConditionalExpression,BlockStatement: the cache holds only lists that pass the check again\n if (CHECKED.has(u)) return true;\n const { kind, items } = u as { kind?: unknown; items?: unknown };\n if (kind !== \"vex.list\" || !Array.isArray(items)) return false;\n // A loop over the positions, not `every`, so a hole of a sparse array is not an item.\n for (let i = 0; i < items.length; i++) if (!isListItem(items[i])) return false;\n if (Object.isFrozen(u) && Object.isFrozen(items)) CHECKED.add(u);\n return true;\n};\n\n/**\n * The name of a core list op. `sortBy`, `take`, `drop`, `append`, `flat` and `without` give a list (LIST.BUILD), and\n * the other ops give a value. `get` gives the value at a key (LIST.GET), and `indexOf` gives the position of a value\n * (LIST.INDEXOF). `distinct` and `group` give a list, and `join` gives a text (LIST.DISTINCT, LIST.GROUP, LIST.JOIN).\n * `setNth` gives a list with a new value at one position (LIST.SETNTH).\n */\nexport type ListOp = \"count\" | \"sum\" | \"min\" | \"max\" | \"mean\" | \"any\" | \"all\" | \"none\" | \"values\" | \"keys\" | \"reduce\" | \"first\" | \"errors\" | \"sortBy\" | \"take\" | \"nth\" | \"setNth\" | \"drop\" | \"append\" | \"flat\" | \"without\" | \"get\" | \"indexOf\" | \"distinct\" | \"group\" | \"join\";\n\n/**\n * The names of the core list ops. They apply when the first argument is a list. They apply to an array too, when no\n * domain and no function of the host has the op for it (LIST.ARRAY).\n */\nexport const LIST_OPS: ReadonlySet<string> = new Set<ListOp>([\"count\", \"sum\", \"min\", \"max\", \"mean\", \"any\", \"all\", \"none\", \"values\", \"keys\", \"reduce\", \"first\", \"errors\", \"sortBy\", \"take\", \"nth\", \"setNth\", \"drop\", \"append\", \"flat\", \"without\", \"get\", \"indexOf\", \"distinct\", \"group\", \"join\"]);\n\n/**\n * The size rules of the core list ops and of `fill` (LOOP.SIZE.OPS). Each op that gives a list has a rule here. An\n * error item has no size, so `errors` has no bound: the messages of the errors can hold texts.\n */\nexport const LIST_SIZES: Readonly<Record<ListOp | \"fill\", SizeRule>> = Object.freeze<Record<ListOp | \"fill\", SizeRule>>({\n count: \"scalar\",\n sum: \"scalar\",\n min: \"scalar\",\n max: \"scalar\",\n mean: \"scalar\",\n any: \"scalar\",\n all: \"scalar\",\n none: \"scalar\",\n indexOf: \"scalar\",\n values: { size: [1], count: [1], inner: [1], item: [1], part: [1], keys: \"position\" },\n keys: { size: [1], count: [1], keys: \"position\" },\n errors: { size: [\"unbounded\"] },\n reduce: \"reduce\",\n first: { size: [[1, \"item\"]], count: [[1, \"item\"]], inner: [[1, \"item\"]], item: [[1, \"part\"]] },\n nth: { size: [[1, \"item\"], 0], count: [[1, \"item\"], 0], inner: [[1, \"item\"], 0], item: [[1, \"part\"], 0] },\n get: { size: [[1, \"item\"], 0], count: [[1, \"item\"], 0], inner: [[1, \"item\"], 0], item: [[1, \"part\"], 0] },\n // LOOP.SIZE.SETNTH: the bound counts the list and the value one time each. A bound cannot subtract the old item.\n setNth: { size: [1, 0, 1], count: [1, 0, 0], inner: [1, 0, [1, \"count\"]], item: [1, 0, [1, \"size\"]], part: [1, 0, [1, \"item\"]] },\n sortBy: { size: [1, 0], count: [1, 0], inner: [1, 0], item: [1, 0], part: [1, 0] },\n // LOOP.SIZE.PART: the second reading counts the items that a literal limit keeps.\n take: {\n size: [1, 0],\n count: [1, 0],\n inner: [1, 0],\n item: [1, 0],\n part: [1, 0],\n limit: 1,\n byParts: { size: [[\"limit\", \"item\"], 0], count: [1, 0], inner: [[\"limit\", \"item\"], 0], item: [1, 0], part: [1, 0] },\n },\n drop: { size: [1, 0], count: [1, 0], inner: [1, 0], item: [1, 0], part: [1, 0] },\n without: { size: [1, 0], count: [1, 0], inner: [1, 0], item: [1, 0], part: [1, 0] },\n append: { size: [1, 1], count: [1, 1], inner: [1, 1], item: [1, 1], part: [1, 1] },\n flat: { size: [1], count: [[1, \"inner\"]], item: [[1, \"part\"]] },\n distinct: { size: [1], count: [1], inner: [1], item: [1], part: [1] },\n group: { size: [1, \"scaled\"], count: [0, 1], inner: [[1, \"count\"], 0] },\n join: { size: [1, \"each\"] },\n fill: { size: [0, \"copies\"], count: [\"number\", 0], inner: [0, [\"copies\", \"count\"]], item: [0, [1, \"size\"]], part: [0, [1, \"item\"]], keys: \"position\" },\n});\n\n/** This function tells if a name is the name of a core list op. */\nexport const isListOp = (op: string): op is ListOp => LIST_OPS.has(op);\n\n/** The options of a list op. */\nexport interface ListOptions {\n /** With `true`, any error item makes the result that error. The default skips error items. */\n readonly strict?: boolean;\n}\n","/**\n * The texts of the errors of the nodes of a program. The interpreter and the materialize step of the compiler use them.\n * Thus tier 1 and tier 2 give the same error (docs/COMPILER.md §4.1).\n */\nimport type { ParamKind } from \"./domain.ts\";\nimport { vexError, type ErrorKind, type VexError } from \"./errors.ts\";\nimport { isVexList } from \"./list.ts\";\nimport type { Position } from \"./space.ts\";\n\n/** The part of an error that does not depend on the position of its node: the kind, the sentence and the op name. */\nexport interface ErrorText {\n readonly kind: ErrorKind;\n readonly message: string;\n readonly op?: string;\n}\n\n/** This function gives a short name for the type of a value, for error messages. */\nexport function describeType(u: unknown): string {\n if (u === null) return \"null\";\n if (Array.isArray(u)) return \"array\";\n if (isVexList(u)) return \"list\";\n if (typeof u === \"object\") {\n const name = (Object.getPrototypeOf(u) as { constructor?: { name?: unknown } } | null)?.constructor?.name;\n return typeof name === \"string\" && name !== \"Object\" ? name : \"object\";\n }\n return typeof u;\n}\n\n/** The texts of the errors. Each function takes the facts of the error that do not come from the position of its node. */\nexport const errorText = {\n /** A name without a binding (`var`). */\n unbound: (name: string): ErrorText => ({ kind: \"unbound\", message: `the name \"${name}\" has no binding` }),\n /** A read of a function as a value (FN.VALUE). */\n functionValue: (name: string): ErrorText => ({ kind: \"kind-mismatch\", message: `the name \"${name}\" is a function, not a value` }),\n /** A call of a name without a binding (FN.CALL). */\n noFunction: (name: string): ErrorText => ({ kind: \"unbound\", message: `the function \"${name}\" has no binding` }),\n /** A call of a name that holds a value (FN.CALL). */\n notFunction: (name: string): ErrorText => ({ kind: \"kind-mismatch\", message: `the name \"${name}\" is a value, not a function` }),\n /** A call with the wrong number of arguments (FN.CALL). */\n arity: (name: string, params: number, args: number): ErrorText => ({ kind: \"bad-expression\", message: `the function \"${name}\" takes ${String(params)} arguments, not ${String(args)}` }),\n /** An extension kind without a handler. */\n noHandler: (kind: string): ErrorText => ({ kind: \"unknown-op\", message: `no handler for the extension kind \"${kind}\"` }),\n /** An exception of an op, of an extension or of `fromScalar`. */\n threw: (op: string): ErrorText => ({ kind: \"threw\", message: `\"${op}\" threw an exception`, op }),\n /** A reference that reads no value. `where` is the part of the path that failed. */\n missing: (key: string, where: string): ErrorText => ({ kind: \"missing-field\", message: `the record at \"${key}\" has no value at \"${where}\"` }),\n /** A reference whose getter threw. */\n readThrew: (key: string, where: string): ErrorText => ({ kind: \"threw\", message: `reading \"${where}\" at \"${key}\" threw an exception` }),\n /** Two or more arguments or fields that failed (CALL.ARGS, REC.FIELDS). */\n args: (count: number, what: string): ErrorText => ({ kind: \"args\", message: `${String(count)} ${what} failed` }),\n /** The axis table of an evaluation without that table. */\n noTable: (name: string): ErrorText => ({ kind: \"no-table\", message: `the evaluation has no table \"${name}\"` }),\n /** The test `until` of `iterate`, with a value that is not a boolean. */\n untilKind: (value: unknown): ErrorText => ({ kind: \"kind-mismatch\", message: `the test \"until\" of \"iterate\" gave a ${typeof value}, not a boolean` }),\n /** The limit of `iterate` with a test that is not true. */\n limit: (limit: number): ErrorText => ({ kind: \"limit\", message: `\"iterate\" made its ${String(limit)} steps, and its test \"until\" is not true` }),\n /** A value of a row of `fix` of the wrong kind for its join. */\n fixKind: (name: string, join: string, kind: string, value: unknown): ErrorText => ({ kind: \"kind-mismatch\", message: `the \"fix\" \"${name}\" with the join \"${join}\" needs a ${kind}, not a ${describeType(value)}` }),\n /** A value of a row of `fix` that is not a finite number. */\n fixNumber: (name: string, value: unknown): ErrorText => ({ kind: \"not-finite\", message: `the \"fix\" \"${name}\" gave the value ${String(value)}, not a finite number` }),\n /** The limit of the rounds of `fix`. */\n fixLimit: (name: string, rounds: number): ErrorText => ({ kind: \"limit\", message: `the \"fix\" \"${name}\" made its ${String(rounds)} rounds, and its values still change` }),\n /** A read of `last` at a key that is not a row. */\n lastKey: (name: string, key: string): ErrorText => ({ kind: \"unknown-key\", message: `the \"fix\" \"${name}\" has no row \"${key}\"` }),\n /** The test of `where`, with a value that is not a boolean. */\n whereKind: (value: unknown): ErrorText => ({ kind: \"kind-mismatch\", message: `the test of \"where\" gave a ${typeof value}, not a boolean` }),\n /** A domain that accepts the receiver of an op and has no such op. */\n domainNoOp: (domain: string, op: string): ErrorText => ({ kind: \"unknown-op\", message: `the domain \"${domain}\" has no op \"${op}\"`, op }),\n /** An op without arguments and without a free function. */\n noOp: (op: string): ErrorText => ({ kind: \"unknown-op\", message: `there is no function \"${op}\"`, op }),\n /** An op whose receiver no domain accepts. */\n noDomain: (op: string, self: unknown): ErrorText => ({ kind: \"not-instance\", message: `no domain accepts the receiver of \"${op}\" (${describeType(self)})`, op }),\n /** A special form without the argument at the index `i`. */\n needsArgument: (op: string, i: number): ErrorText => ({ kind: \"bad-expression\", message: `\"${op}\" needs argument ${String(i + 1)}`, op }),\n /** `and` or `or` without arguments. */\n needsArguments: (op: string): ErrorText => ({ kind: \"bad-expression\", message: `\"${op}\" needs at least 1 argument`, op }),\n /** An argument of a special form that is not a boolean. */\n notBoolean: (op: string, i: number, value: unknown): ErrorText => ({ kind: \"kind-mismatch\", message: `argument ${String(i + 1)} of \"${op}\" is a ${describeType(value)}, not a boolean`, op }),\n /** An argument of an op that does not have the kind of its parameter. */\n badParam: (op: string, i: number, value: unknown, kind: ParamKind, domain: string): ErrorText => ({\n kind: kind === \"domain\" ? \"not-instance\" : \"kind-mismatch\",\n message: `argument ${String(i + 1)} of \"${op}\" is a ${describeType(value)}, not a ${kind === \"domain\" ? domain : kind}`,\n op,\n }),\n /** An op that gave `undefined` or `null`. */\n noValue: (op: string): ErrorText => ({ kind: \"undefined-result\", message: `\"${op}\" gave no value`, op }),\n /** An op that gave a number that is not finite. */\n notFinite: (op: string, value: number): ErrorText => ({ kind: \"not-finite\", message: `\"${op}\" gave ${String(value)}`, op }),\n /** An op that gave a value that its domain does not accept as valid. */\n invalid: (op: string, domain: string): ErrorText => ({ kind: \"invalid-value\", message: `\"${op}\" gave a value that is not a valid ${domain}`, op }),\n /** A check `valid` of a domain that threw. */\n validThrew: (op: string, domain: string): ErrorText => ({ kind: \"threw\", message: `the \"valid\" check of \"${domain}\" threw an exception`, op }),\n /** A list op whose items must have one kind, with an item of another kind. */\n /** The axis `list` over a value that is not a list (AXIS.LIST). */\n axisList: (value: unknown): ErrorText => ({ kind: \"kind-mismatch\", message: `the axis \"list\" needs a list, not a ${describeType(value)}` }),\n needsItems: (op: string, what: \"numbers\" | \"booleans\", item: unknown): ErrorText => ({ kind: \"kind-mismatch\", message: `\"${op}\" needs ${what}, but an item is a ${describeType(item)}`, op }),\n /** A list op that has no items to work with. */\n empty: (op: string): ErrorText => ({ kind: \"empty\", message: `\"${op}\" has no values to work with`, op }),\n /** `reduce` with an op name that is not a text. */\n reduceName: (name: unknown): ErrorText => ({ kind: \"kind-mismatch\", message: `\"reduce\" needs an op name, but got a ${describeType(name)}`, op: \"reduce\" }),\n /** A step of `reduce` or of `sortBy` that no domain gives. */\n noStep: (op: string, value: unknown): ErrorText => ({ kind: \"unknown-op\", message: `no domain gives \"${op}\" for a ${describeType(value)}`, op }),\n} as const;\n\n/** The details of an error that come from its evaluation, and not from its text. */\nexport interface ErrorExtra {\n readonly causes?: readonly VexError[];\n readonly thrown?: unknown;\n}\n\n/** This function makes the error of a text at a node: the path of the node, with its origin and its focus. */\nexport function errorAt(t: ErrorText, pos: Position, path: readonly number[], extra: ErrorExtra = {}): VexError {\n return vexError(t.kind, t.message, { path, origin: pos.origin, focus: pos.focus, ...(t.op === undefined ? {} : { op: t.op }), ...extra });\n}\n","/**\n * The check of the names `as` of a loop over the axis `list` (AXIS.LIST.SCOPE). The package index does not export this\n * module: `isExpr`, `shapeError` and `fromDocument` use it, so an expression and a document follow the same rule.\n */\n\nconst isObject = (u: unknown): u is Readonly<Record<string, unknown>> => typeof u === \"object\" && u !== null;\n\n/** This function tells if the base axis of an axis is `list`, through `where` and `reverse`. It uses a loop, not recursion. */\nfunction isListAxis(u: unknown): boolean {\n let x = u;\n while (isObject(x) && x[\"t\"] === \"where\") x = x[\"axis\"];\n if (isObject(x) && x[\"t\"] === \"reverse\") x = x[\"axis\"];\n return isObject(x) && x[\"t\"] === \"list\";\n}\n\n/**\n * This function gives the reason that the names `as` of a loop are not valid, or `undefined` for valid names or no\n * names (AXIS.LIST.SCOPE). The names are one or two distinct texts, the axis is `list`, and no name is a name of `init`.\n */\nexport function itemNamesError(u: Readonly<Record<string, unknown>>): string | undefined {\n const as = u[\"as\"];\n if (as === undefined) return undefined;\n if (!Array.isArray(as) || as.length === 0 || as.length > 2 || !as.every((n) => typeof n === \"string\")) return '\"as\" is a list of one or two names: the item, and then its index';\n if (as[0] === as[1]) return `the two names of \"as\" are the same name \"${String(as[0])}\"`;\n if (!isListAxis(u[\"axis\"])) return '\"as\" needs the axis \"list\", also inside \"reverse\" and \"where\"';\n const init = u[\"init\"];\n const clash = isObject(init) ? (as as readonly string[]).find((n) => Object.hasOwn(init, n)) : undefined;\n return clash === undefined ? undefined : `the name \"${clash}\" of \"as\" is a name of \"init\" too`;\n}\n","/**\n * The expression IR of Vex. It is plain JSON data. Its first three kinds (`lit`, `ref`, `app`) have the same\n * shape as the expressions of `render`.\n */\n\nimport { itemNamesError } from \"./item-names.ts\";\n\n/**\n * One move of an address. The moves of an address apply in order, from the focus of the evaluation. The key of `key`\n * and the position of `index` can be an expression, which evaluates before the moves (NAV.COMPUTED).\n */\nexport type Move =\n | { readonly t: \"key\"; readonly key: string | Expr }\n | { readonly t: \"index\"; readonly i: number | Expr }\n | { readonly t: \"other\" }\n | { readonly t: \"offset\"; readonly d: readonly number[] }\n | { readonly t: \"origin\" }\n | { readonly t: \"parent\" };\n\n/** A move with a fixed key or position: a move with no expression. */\nexport type FixedMove = Exclude<Move, { readonly t: \"key\" | \"index\" }> | { readonly t: \"key\"; readonly key: string } | { readonly t: \"index\"; readonly i: number };\n\n/** An address: a list of moves. The empty list is the focus. */\nexport type Addr = readonly Move[];\n\n/** An axis: the relation between a position and the targets that a body reads. */\nexport type Axis =\n | { readonly t: \"all\" }\n | { readonly t: \"others\" }\n | { readonly t: \"other\" }\n | { readonly t: \"neighbors\"; readonly n: 4 | 8 }\n | { readonly t: \"children\" }\n | { readonly t: \"ancestors\" }\n | { readonly t: \"descendants\" }\n | { readonly t: \"siblings\" }\n | { readonly t: \"window\"; readonly from: number; readonly to: number }\n | { readonly t: \"table\"; readonly name: string }\n | { readonly t: \"successors\" }\n | { readonly t: \"predecessors\" }\n | { readonly t: \"reachable\" }\n | { readonly t: \"list\"; readonly list: Expr }\n | { readonly t: \"reverse\"; readonly axis: Axis }\n | { readonly t: \"where\"; readonly axis: Axis; readonly test: Expr };\n\n/** A Vex expression. */\nexport type Expr =\n | { readonly tag: \"lit\"; readonly value: unknown }\n | { readonly tag: \"ref\"; readonly path: readonly string[]; readonly at?: Addr }\n | { readonly tag: \"app\"; readonly op: string; readonly args: readonly Expr[] }\n | { readonly tag: \"let\"; readonly bind: Readonly<Record<string, Expr>>; readonly body: Expr }\n | { readonly tag: \"var\"; readonly name: string }\n | { readonly tag: \"rec\"; readonly fields: Readonly<Record<string, Expr>> }\n | { readonly tag: \"each\"; readonly axis: Axis; readonly body: Expr; readonly at?: Addr; readonly as?: ItemNames }\n | { readonly tag: \"fold\"; readonly axis: Axis; readonly init: Names; readonly step: Names; readonly result: Expr; readonly at?: Addr; readonly as?: ItemNames }\n | { readonly tag: \"iterate\"; readonly limit: number | DataLimit; readonly init: Names; readonly step: Names; readonly until?: Expr; readonly result: Expr }\n | { readonly tag: \"fix\"; readonly name: string; readonly join: FixJoin; readonly init: Expr; readonly step: Expr }\n | { readonly tag: \"last\"; readonly name: string }\n | { readonly tag: \"fn\"; readonly params: readonly string[]; readonly body: Expr }\n | { readonly tag: \"call\"; readonly fn: string; readonly args: readonly Expr[] }\n | { readonly tag: \"ext\"; readonly kind: string; readonly data: unknown };\n\n/** The names of a loop and an expression for each (LOOP.NAMES). */\nexport type Names = Readonly<Record<string, Expr>>;\n\n/**\n * The names of the items of a loop over the axis `list`. The first name holds the value of the item, and the second\n * its position (AXIS.LIST.ITEM, AXIS.LIST.INDEX). The body of `each` and the steps of `fold` see them (AXIS.LIST.SCOPE).\n */\nexport type ItemNames = readonly [item: string] | readonly [item: string, index: string];\n\n/** The joins of `fix`. The join `or` or `max` moves a row up, and `and` or `min` moves a row down (FIX.JOIN). */\nexport type FixJoin = \"or\" | \"and\" | \"max\" | \"min\";\n\n/** The largest number of steps of `iterate` (ITERATE.LIMIT). */\nexport const MAX_ITERATIONS = 100_000;\n\n/**\n * The limit of `iterate` from the size of the data (ITERATE.LIMIT.DATA): the number of targets of an axis. This is the\n * number of steps that a `fold` over the axis makes. The axis `list` gives the count of a list. This limit needs step B.\n */\nexport interface DataLimit {\n readonly axis: Axis;\n}\n\n/** The tag of an expression kind. */\nexport type ExprTag = Expr[\"tag\"];\n\n/** An expression of one kind. */\nexport type ExprOf<T extends ExprTag> = Extract<Expr, { readonly tag: T }>;\n\n// ---------------------------------------------------------------- constructors\n\n/** This function makes a literal. */\nexport const lit = (value: unknown): ExprOf<\"lit\"> => ({ tag: \"lit\", value });\n\n/** This function splits a dotted path, for example `\"pos.x\"`, into its segments. */\nexport const toPath = (path: string | readonly string[]): readonly string[] =>\n typeof path === \"string\" ? path.split(\".\").filter((s) => s.length > 0) : path;\n\n/** This function makes a reference to a field path. With `at`, the reference reads at that address. */\nexport function ref(path: string | readonly string[], at?: Addr): ExprOf<\"ref\"> {\n const segments = toPath(path);\n return at === undefined || at.length === 0 ? { tag: \"ref\", path: segments } : { tag: \"ref\", path: segments, at };\n}\n\n/** This function makes the application of an op to arguments. For a method op, the first argument is the receiver. */\nexport const app = (op: string, ...args: readonly Expr[]): ExprOf<\"app\"> => ({ tag: \"app\", op, args });\n\n/** This function binds names to expressions for the body. */\nexport const let_ = (bind: Readonly<Record<string, Expr>>, body: Expr): ExprOf<\"let\"> => ({ tag: \"let\", bind, body });\n\n/** This function makes a reference to a bound name. */\nexport const v = (name: string): ExprOf<\"var\"> => ({ tag: \"var\", name });\n\n/** This function makes a record from field expressions. */\nexport const rec = (fields: Readonly<Record<string, Expr>>): ExprOf<\"rec\"> => ({ tag: \"rec\", fields });\n\n/**\n * This function evaluates `body` once for each target of `axis`. The result is a list. With `at`, the axis finds its\n * targets from the key of that address, not from the focus. With `as`, the body of a loop over the axis `list` reads the\n * value of each item and its position by these names (AXIS.LIST.ITEM, AXIS.LIST.INDEX).\n */\nexport function each(axis: Axis, body: Expr, at?: Addr, as?: ItemNames): ExprOf<\"each\"> {\n const named = as === undefined ? {} : { as };\n return at === undefined || at.length === 0 ? { tag: \"each\", axis, body, ...named } : { tag: \"each\", axis, body, at, ...named };\n}\n\n/**\n * This function makes a fold: a step at each target of `axis`, in order. `init` gives the names and their first\n * values, and `step` gives the next values. `result` gives the value from the last values (LOOP.NAMES, FOLD.ORDER). With\n * `as`, the steps of a fold over the axis `list` read the value of each item and its position by these names\n * (AXIS.LIST.ITEM, AXIS.LIST.INDEX).\n */\nexport function fold(axis: Axis, init: Names, step: Names, result: Expr, at?: Addr, as?: ItemNames): ExprOf<\"fold\"> {\n const named = as === undefined ? {} : { as };\n return at === undefined || at.length === 0 ? { tag: \"fold\", axis, init, step, result, ...named } : { tag: \"fold\", axis, init, step, result, at, ...named };\n}\n\n/**\n * This function makes an iteration: up to `limit` steps. `init` gives the names and their first values, and `step`\n * gives the next values. A true `until` stops it, and `result` gives the value (ITERATE.LIMIT, ITERATE.UNTIL).\n */\nexport function iterate(limit: number | DataLimit, init: Names, step: Names, result: Expr, until?: Expr): ExprOf<\"iterate\"> {\n return until === undefined ? { tag: \"iterate\", limit, init, step, result } : { tag: \"iterate\", limit, init, step, until, result };\n}\n\n/**\n * This function makes a fixed-point column (FIX.ROUNDS). `init` gives the first value of each row. `step` gives the next\n * value of each row, and it reads the last round with `last`. `join` joins each next value to the old value of its row.\n */\nexport function fix(name: string, join: FixJoin, init: Expr, step: Expr): ExprOf<\"fix\"> {\n return { tag: \"fix\", name, join, init, step };\n}\n\n/** This function makes a read of the value of the focus in the last round of the `fix` with the name `name` (FIX.LAST). */\nexport function last(name: string): ExprOf<\"last\"> {\n return { tag: \"last\", name };\n}\n\n/** This function makes the limit of `iterate` from the size of the data: the number of targets of an axis (ITERATE.LIMIT.DATA). */\nexport const dataLimit = (axis: Axis): DataLimit => ({ axis });\n\n/** This function gives the axis of the data limit of an iteration, or `undefined` for a limit that is a number. */\nexport const limitAxis = (e: ExprOf<\"iterate\">): Axis | undefined => (typeof e.limit === \"number\" ? undefined : e.limit.axis);\n\n/**\n * This function gives the parts of an iteration with a data limit, for a walk that tells the axes apart. The parts are\n * an `each` over the axis, and the iteration without its axis. An iteration with a number has `undefined`.\n */\nexport function splitLimit(e: ExprOf<\"iterate\">): readonly [ExprOf<\"each\">, ExprOf<\"iterate\">] | undefined {\n const axis = limitAxis(e);\n return axis === undefined ? undefined : [each(axis, lit(0)), { ...e, limit: 0 }];\n}\n\n/**\n * This function makes a function (FN.BIND): the names of its parameters and its body. A function is only the value of\n * a binding of `let`. The body sees the names of the place of that `let`, so a function cannot call itself.\n */\nexport const fn = (params: readonly string[], body: Expr): ExprOf<\"fn\"> => ({ tag: \"fn\", params, body });\n\n/** This function makes a call of a bound function (FN.CALL). The body evaluates at the position of the call. */\nexport const call = (name: string, ...args: Expr[]): ExprOf<\"call\"> => ({ tag: \"call\", fn: name, args });\n\n/** This function makes an expression of an extension kind. */\nexport const ext = (kind: string, data: unknown): ExprOf<\"ext\"> => ({ tag: \"ext\", kind, data });\n\n// ---------------------------------------------------------------- moves and axes\n\n/** The move to an absolute key. The key can be an expression that gives a text. */\nexport function key(k: string): FixedMove;\nexport function key(k: string | Expr): Move;\nexport function key(k: string | Expr): Move {\n return { t: \"key\", key: k };\n}\n/** The move to a position in the key order. The position can be an expression that gives a number. */\nexport function index(i: number): FixedMove;\nexport function index(i: number | Expr): Move;\nexport function index(i: number | Expr): Move {\n return { t: \"index\", i };\n}\n\n/** This function gives the expression of a move with a computed key or position, or `undefined`. */\nexport function moveExpr(m: Move): Expr | undefined {\n if (m.t === \"key\") return typeof m.key === \"string\" ? undefined : m.key;\n return m.t === \"index\" && typeof m.i !== \"number\" ? m.i : undefined;\n}\n\n/** This function gives the expressions of the computed moves of an address, in the order of the moves. */\nexport const addrExprs = (at: Addr | undefined): readonly Expr[] => (at ?? []).flatMap((m) => moveExpr(m) ?? []);\n\n/** This function tells if each move of an address is fixed. */\nexport const isFixedAddr = (at: Addr | undefined): at is readonly FixedMove[] => addrExprs(at).length === 0;\n/** The move to the other key of a space with two keys. */\nexport const other: FixedMove = Object.freeze({ t: \"other\" });\n/** The relative move in an array (one number) or a grid (two numbers). */\nexport const offset = (...d: readonly number[]): FixedMove => ({ t: \"offset\", d });\n/** The move back to the origin of the evaluation. */\nexport const origin: FixedMove = Object.freeze({ t: \"origin\" });\n/** The move to the parent of the focus in a tree space. */\nexport const parent: FixedMove = Object.freeze({ t: \"parent\" });\n\n/** The axes. */\nexport const axes = {\n /** Each key of the space. */\n all: Object.freeze({ t: \"all\" }) as Axis,\n /** Each key except the focus. */\n others: Object.freeze({ t: \"others\" }) as Axis,\n /** The other key of a pair. */\n other: Object.freeze({ t: \"other\" }) as Axis,\n /** The neighbors of the focus in a grid. */\n neighbors: (n: 4 | 8 = 8): Axis => ({ t: \"neighbors\", n }),\n /** The children of the focus in a tree, in key order. */\n children: Object.freeze({ t: \"children\" }) as Axis,\n /** The ancestors of the focus in a tree: the parent first, the root last. */\n ancestors: Object.freeze({ t: \"ancestors\" }) as Axis,\n /** The descendants of the focus in a tree, depth first, each parent before its children. */\n descendants: Object.freeze({ t: \"descendants\" }) as Axis,\n /** The other children of the parent of the focus. For a root, the other roots. */\n siblings: Object.freeze({ t: \"siblings\" }) as Axis,\n /**\n * The keys at the offsets from `from` to `to` of the focus, in order: a window of rows. The offset 0 is the focus. In\n * a tree space, the offsets go among the siblings. An offset outside the space has no target.\n */\n window: (from: number, to: number): Axis => ({ t: \"window\", from, to }),\n /**\n * Each key of the table `name` of the evaluation, in key order. The body evaluates in the space of that table, and\n * there the origin is the target.\n */\n table: (name: string): Axis => ({ t: \"table\", name }),\n /** The keys at the ends of the edges from the focus, in a graph space. In a tree space, the children. */\n successors: Object.freeze({ t: \"successors\" }) as Axis,\n /** The keys with an edge to the focus, in key order. In a tree space, the parent. */\n predecessors: Object.freeze({ t: \"predecessors\" }) as Axis,\n /** Each key that a path of edges reaches from the focus, in breadth-first order, without the focus. */\n reachable: Object.freeze({ t: \"reachable\" }) as Axis,\n /**\n * The targets of `axis` in the reverse order (AXIS.REVERSE). The inner axis is a base axis: not `where`, `reverse` or\n * `table`. A test goes outside: `where(reverse(axis), test)`.\n */\n reverse: (axis: Axis): Axis => ({ t: \"reverse\", axis }),\n /**\n * The keys of the items of the list that `list` gives, in the order of the list (AXIS.LIST). The expression evaluates\n * before the targets. An error item gives an error item for its target.\n */\n list: (list: Expr): Axis => ({ t: \"list\", list }),\n /** The targets of `axis` where `test` gives `true`. */\n where: (axis: Axis, test: Expr): Axis => ({ t: \"where\", axis, test }),\n} as const;\n\n// ---------------------------------------------------------------- validation\n\nconst isObject = (u: unknown): u is Readonly<Record<string, unknown>> => typeof u === \"object\" && u !== null;\n\nconst isStringArray = (u: unknown): u is readonly string[] => Array.isArray(u) && u.every((s) => typeof s === \"string\");\n\n/** This function tells if a value is a valid move. The expression of a computed move must be valid too. */\nexport function isMove(u: unknown): u is Move {\n const exprs = moveParts(u);\n return exprs !== undefined && exprs.every(isExpr);\n}\n\n/**\n * A test of the numbers of a move or of a window. The JSON form needs whole numbers. An expression in code can have any\n * number, and a number that is not whole has a meaning at run time (EVAL.SHAPE).\n */\ntype NumberTest = (x: unknown) => boolean;\n\nconst anyNumber: NumberTest = (x) => typeof x === \"number\";\n\n/** This function checks the fixed parts of a move. It gives the expressions of the move, or `undefined` for a bad move. */\nfunction moveParts(u: unknown, isNumber: NumberTest = Number.isInteger): readonly unknown[] | undefined {\n if (!isObject(u)) return undefined;\n switch (u[\"t\"]) {\n case \"key\":\n return typeof u[\"key\"] === \"string\" ? [] : isObject(u[\"key\"]) ? [u[\"key\"]] : undefined;\n case \"index\":\n return isNumber(u[\"i\"]) ? [] : isObject(u[\"i\"]) ? [u[\"i\"]] : undefined;\n case \"offset\":\n return Array.isArray(u[\"d\"]) && u[\"d\"].every((n) => isNumber(n)) ? [] : undefined;\n case \"other\":\n case \"origin\":\n case \"parent\":\n return [];\n default:\n return undefined;\n }\n}\n\n/** This function tells if a value is a valid axis. It checks the tests of `where` too. */\nexport function isAxis(u: unknown): u is Axis {\n return badPart([{ axis: true, u }], true) === undefined;\n}\n\n/** This function tells if a value is a valid expression. It checks the whole tree. */\nexport function isExpr(u: unknown): u is Expr {\n return badPart([{ axis: false, u }], true) === undefined;\n}\n\n/** The tags of the expressions of this version of Vex. */\nconst TAGS: ReadonlySet<unknown> = new Set([\"lit\", \"ref\", \"app\", \"let\", \"var\", \"rec\", \"each\", \"fold\", \"iterate\", \"fix\", \"last\", \"fn\", \"call\", \"ext\"]);\n\n/** The joins of `fix`. */\nconst JOINS: ReadonlySet<unknown> = new Set<FixJoin>([\"or\", \"and\", \"max\", \"min\"]);\n\n/**\n * This function gives the reason that a value is not a valid expression, or `undefined` for a valid expression\n * (EVAL.SHAPE). An expression from a newer version of Vex can have a tag that this version does not know. Unlike\n * `isExpr`, it accepts a number that is not whole in a move or in a window, because it has a meaning at run time.\n */\nexport function shapeError(u: unknown): string | undefined {\n const bad = badPart([{ axis: false, u }], false);\n if (bad === undefined) return undefined;\n const tag = isObject(bad.u) ? bad.u[\"tag\"] : undefined;\n if (bad.axis) return \"the expression has an axis that is not valid\";\n if (typeof tag === \"string\" && !TAGS.has(tag)) return `the expression has a node with the tag \"${tag}\", and this version of Vex does not know it`;\n if (tag === \"fn\") return \"the expression has a function outside the bindings of a let, or a function with parameters that are not distinct names\";\n const named = tag === \"each\" || tag === \"fold\" ? itemNamesError(bad.u as Readonly<Record<string, unknown>>) : undefined;\n if (named !== undefined) return `the expression has a node \"${String(tag)}\" with names \"as\" that are not valid: ${named}`;\n return typeof tag === \"string\" ? `the expression has a node \"${tag}\" with parts that are not valid` : \"the expression has a part that is not a node\";\n}\n\n/**\n * This function checks the names of a loop: `init` and `step` are records, and each name of `step` is a name of `init`.\n * It gives the expressions of `init`, of `step` and `result`, or `undefined` (LOOP.NAMES).\n */\nfunction loopParts(u: Readonly<Record<string, unknown>>): readonly unknown[] | undefined {\n const { init, step } = u;\n if (!isObject(init) || Array.isArray(init) || !isObject(step) || Array.isArray(step)) return undefined;\n if (!Object.keys(step).every((n) => Object.hasOwn(init, n))) return undefined;\n return [...Object.values(init), ...Object.values(step), u[\"result\"]];\n}\n\n/** This function checks the fixed parts of an address. It gives the expressions of its moves, or `undefined`. */\nfunction addrParts(u: unknown, isNumber: NumberTest): readonly unknown[] | undefined {\n if (u === undefined) return [];\n if (!Array.isArray(u)) return undefined;\n const out: unknown[] = [];\n for (const m of u) {\n const parts = moveParts(m, isNumber);\n if (parts === undefined) return undefined;\n out.push(...parts);\n }\n return out;\n}\n\n/**\n * This function checks a tree of expressions and axes, and it gives the first part that is not valid. It uses a stack,\n * not recursion, so the input can be deep. For example, a deep JSON file from a stranger does not need a deep call\n * stack (EVAL.NESTING). With `whole`, the numbers of the moves and of the windows must be whole, as the JSON form needs.\n */\nfunction badPart(todo: { readonly axis: boolean; readonly u: unknown }[], whole: boolean): { readonly axis: boolean; readonly u: unknown } | undefined {\n const moveNumber = whole ? Number.isInteger : anyNumber;\n const windowNumber = whole ? Number.isSafeInteger : anyNumber;\n const push = (axis: boolean, values: readonly unknown[]): void => {\n for (const u of values) todo.push({ axis, u });\n };\n for (let item = todo.pop(); item !== undefined; item = todo.pop()) {\n const { u } = item;\n if (!isObject(u)) return item;\n if (item.axis) {\n const t = u[\"t\"];\n if (t === \"neighbors\") {\n if (u[\"n\"] !== 4 && u[\"n\"] !== 8) return item;\n } else if (t === \"window\") {\n if (!windowNumber(u[\"from\"]) || !windowNumber(u[\"to\"])) return item;\n } else if (t === \"table\") {\n if (typeof u[\"name\"] !== \"string\") return item;\n } else if (t === \"where\") {\n push(true, [u[\"axis\"]]);\n push(false, [u[\"test\"]]);\n } else if (t === \"list\") {\n push(false, [u[\"list\"]]);\n } else if (t === \"reverse\") {\n // The inner axis of reverse is a base axis.\n const inner = u[\"axis\"];\n if (!isObject(inner) || [\"where\", \"reverse\", \"table\"].includes(inner[\"t\"] as string)) return item;\n push(true, [inner]);\n } else if (![\"all\", \"others\", \"other\", \"children\", \"ancestors\", \"descendants\", \"siblings\", \"successors\", \"predecessors\", \"reachable\"].includes(t as string)) {\n return item;\n }\n continue;\n }\n switch (u[\"tag\"]) {\n case \"lit\":\n if (!(\"value\" in u)) return item;\n break;\n case \"ref\": {\n const at = addrParts(u[\"at\"], moveNumber);\n if (!isStringArray(u[\"path\"]) || at === undefined) return item;\n push(false, at);\n break;\n }\n case \"app\":\n if (typeof u[\"op\"] !== \"string\" || !Array.isArray(u[\"args\"])) return item;\n push(false, u[\"args\"]);\n break;\n case \"let\": {\n if (!isObject(u[\"bind\"]) || Array.isArray(u[\"bind\"])) return item;\n // A binding can be a function (FN.BIND): its parameters are distinct names, and its body is an expression.\n const values = Object.values(u[\"bind\"]).map((b) => (isObject(b) && b[\"tag\"] === \"fn\" && isStringArray(b[\"params\"]) && new Set(b[\"params\"]).size === b[\"params\"].length ? b[\"body\"] : b));\n push(false, [...values, u[\"body\"]]);\n break;\n }\n case \"call\":\n if (typeof u[\"fn\"] !== \"string\" || !Array.isArray(u[\"args\"])) return item;\n push(false, u[\"args\"]);\n break;\n case \"var\":\n if (typeof u[\"name\"] !== \"string\") return item;\n break;\n case \"rec\":\n if (!isObject(u[\"fields\"]) || Array.isArray(u[\"fields\"])) return item;\n push(false, Object.values(u[\"fields\"]));\n break;\n case \"each\": {\n const at = addrParts(u[\"at\"], moveNumber);\n if (at === undefined || itemNamesError(u) !== undefined) return item;\n push(true, [u[\"axis\"]]);\n push(false, [u[\"body\"], ...at]);\n break;\n }\n case \"fold\": {\n const at = addrParts(u[\"at\"], moveNumber);\n const names = loopParts(u);\n if (at === undefined || names === undefined || itemNamesError(u) !== undefined) return item;\n push(true, [u[\"axis\"]]);\n push(false, [...names, ...at]);\n break;\n }\n case \"iterate\": {\n const limit = u[\"limit\"];\n const names = loopParts(u);\n if (names === undefined) return item;\n if (isObject(limit)) push(true, [limit[\"axis\"]]);\n else if (typeof limit !== \"number\" || !Number.isInteger(limit) || limit < 0 || limit > MAX_ITERATIONS) return item;\n push(false, [...names, ...(u[\"until\"] === undefined ? [] : [u[\"until\"]])]);\n break;\n }\n case \"fix\":\n if (typeof u[\"name\"] !== \"string\" || !JOINS.has(u[\"join\"])) return item;\n push(false, [u[\"init\"], u[\"step\"]]);\n break;\n case \"last\":\n if (typeof u[\"name\"] !== \"string\") return item;\n break;\n case \"ext\":\n if (typeof u[\"kind\"] !== \"string\" || !(\"data\" in u)) return item;\n break;\n default:\n return item;\n }\n }\n return undefined;\n}\n\n/**\n * This function gives the child expressions of an expression, in the order of their child index. The expressions of\n * the computed moves of an address come last. They evaluate at the position of their node, also for an axis.\n */\nexport function children(e: Expr): readonly Expr[] {\n switch (e.tag) {\n case \"app\":\n case \"call\":\n return e.args;\n case \"fn\":\n return [e.body];\n case \"let\":\n return [...Object.values(e.bind), e.body];\n case \"rec\":\n return Object.values(e.fields);\n case \"each\":\n return [e.body, ...axisExprs(e.axis), ...addrExprs(e.at)];\n case \"fold\":\n return [...Object.values(e.init), ...Object.values(e.step), ...axisExprs(e.axis), ...addrExprs(e.at), e.result];\n case \"iterate\": {\n const axis = limitAxis(e);\n return [...Object.values(e.init), ...Object.values(e.step), ...(axis === undefined ? [] : axisExprs(axis)), ...(e.until === undefined ? [] : [e.until]), e.result];\n }\n case \"fix\":\n return [e.init, e.step];\n case \"ref\":\n return addrExprs(e.at);\n case \"lit\":\n case \"var\":\n case \"last\":\n case \"ext\":\n return [];\n }\n}\n\n/**\n * This function gives the expressions of an axis, in the order of their child indexes. The expression of the axis\n * `list` comes first, and then the tests of the `where` axes from the inside out. It uses a loop, not recursion.\n */\nexport function axisExprs(a: Axis): readonly Expr[] {\n const out: Expr[] = [];\n for (let x = a; x.t === \"where\"; x = x.axis) out.unshift(x.test);\n const list = listOf(a);\n return list === undefined ? out : [list, ...out];\n}\n\n/** This function gives the expression of the axis `list` inside an axis, through `where` and `reverse`, if it has one. */\nexport function listOf(a: Axis): Expr | undefined {\n let x = a;\n while (x.t === \"where\") x = x.axis;\n const base = x.t === \"reverse\" ? x.axis : x;\n return base.t === \"list\" ? base.list : undefined;\n}\n","import { vexError } from \"./errors.ts\";\nimport { moveExpr, type Addr, type Axis, type FixedMove } from \"./ir.ts\";\nimport { fail, ok, type Result } from \"./result.ts\";\n\n/** The kind of a space. The kind sets which moves and axes are valid. */\nexport type SpaceKind = \"record\" | \"array\" | \"grid\" | \"tree\" | \"graph\";\n\n/**\n * A space: an immutable collection of records with keys. A Vex program evaluates at one key of a space.\n * Nothing changes a space after it is made.\n */\nexport interface Space<K extends string = string, O = unknown> {\n readonly kind: SpaceKind;\n /** The keys, in their order. */\n readonly keys: readonly K[];\n /**\n * The record of each key, in the order of `keys` (SPACE.RECORDS). A compiler reads a record by its index with it.\n * A space without it gives each record with `get` only.\n */\n readonly records?: readonly (O | undefined)[];\n /** This function tells if the space has the key `k`. */\n has(k: string): k is K;\n /** This function gives the record at the key `k`, or `undefined`. */\n get(k: string): O | undefined;\n /** The position of each key, for array and grid spaces. An array key has one number, a grid key has two. */\n coords(k: string): readonly number[] | undefined;\n /** The key at a position, or `undefined`. */\n keyAt(coords: readonly number[]): K | undefined;\n /** The parent of the key `k` in a tree space, or `undefined` for a root. Other spaces do not have it. */\n parentOf?(k: string): K | undefined;\n /** The children of the key `k` in a tree space, in key order. Other spaces do not have it. */\n childrenOf?(k: string): readonly K[];\n /** The keys at the ends of the edges from `k`, in a graph space or a tree space. Other spaces do not have it. */\n successorsOf?(k: string): readonly K[];\n /** The keys with an edge to `k`, in key order, in a graph space or a tree space. Other spaces do not have it. */\n predecessorsOf?(k: string): readonly K[];\n}\n\n/** The key type of a grid space. */\nexport type GridKey = `${number},${number}`;\n\n/** The key type of an array space. */\nexport type ArrayKey = `${number}`;\n\nclass RecordSpace<K extends string, O> implements Space<K, O> {\n readonly kind: SpaceKind = \"record\";\n readonly keys: readonly K[];\n readonly records: readonly O[];\n readonly #records: ReadonlyMap<string, O>;\n\n constructor(records: Readonly<Record<K, O>>) {\n const entries = Object.entries(records) as [K, O][];\n this.keys = Object.freeze(entries.map(([k]) => k));\n this.records = Object.freeze(entries.map(([, o]) => o));\n this.#records = new Map(entries);\n }\n\n has(k: string): k is K {\n return this.#records.has(k);\n }\n get(k: string): O | undefined {\n return this.#records.get(k);\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n coords(): readonly number[] | undefined {\n return undefined;\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n keyAt(): K | undefined {\n return undefined;\n }\n}\n\nclass ArraySpace<O> implements Space<ArrayKey, O> {\n readonly kind: SpaceKind = \"array\";\n readonly keys: readonly ArrayKey[];\n readonly records: readonly O[];\n\n constructor(items: readonly O[]) {\n this.keys = Object.freeze(Array.from(items, (_item, i): ArrayKey => `${i}`));\n this.records = Object.freeze(Array.from(items));\n }\n\n // The key at the position i is the text of i, so the position of a key finds it. A text that is not a key of the\n // space, for example \"01\" or \"1.0\", has no key at its position.\n has(k: string): k is ArrayKey {\n return this.keys[Number(k)] === k;\n }\n get(k: string): O | undefined {\n return this.has(k) ? this.records[Number(k)] : undefined;\n }\n coords(k: string): readonly number[] | undefined {\n return this.has(k) ? [Number(k)] : undefined;\n }\n keyAt(coords: readonly number[]): ArrayKey | undefined {\n return coords.length === 1 ? this.keys[Number(coords[0])] : undefined;\n }\n}\n\nclass GridSpace<O> implements Space<GridKey, O> {\n readonly kind: SpaceKind = \"grid\";\n readonly keys: readonly GridKey[];\n readonly records: readonly O[];\n readonly #cells: ReadonlyMap<string, O>;\n readonly #coords: ReadonlyMap<string, readonly number[]>;\n\n constructor(rows: readonly (readonly O[])[]) {\n const entries = rows.flatMap((row, i) => row.map((cell, j): [GridKey, O, readonly number[]] => [`${i},${j}`, cell, Object.freeze([i, j])]));\n this.keys = Object.freeze(entries.map(([k]) => k));\n this.records = Object.freeze(entries.map(([, o]) => o));\n this.#cells = new Map(entries.map(([k, cell]) => [k, cell]));\n this.#coords = new Map(entries.map(([k, , c]) => [k, c]));\n }\n\n has(k: string): k is GridKey {\n return this.#cells.has(k);\n }\n get(k: string): O | undefined {\n return this.#cells.get(k);\n }\n coords(k: string): readonly number[] | undefined {\n return this.#coords.get(k);\n }\n keyAt(coords: readonly number[]): GridKey | undefined {\n // Each key has two coordinates, so a list with more or fewer coordinates gives no key.\n const k = coords.join(\",\");\n return this.has(k) ? k : undefined;\n }\n}\n\nclass TreeSpace<K extends string, O> implements Space<K, O> {\n readonly kind: SpaceKind = \"tree\";\n readonly keys: readonly K[];\n readonly records: readonly O[];\n readonly #records: ReadonlyMap<string, O>;\n readonly #parents: ReadonlyMap<string, K>;\n readonly #children: ReadonlyMap<string, readonly K[]>;\n\n constructor(records: Readonly<Record<K, O>>, parents: Readonly<Partial<Record<K, K | null>>>) {\n const entries = Object.entries(records) as [K, O][];\n this.keys = Object.freeze(entries.map(([k]) => k));\n this.records = Object.freeze(entries.map(([, o]) => o));\n this.#records = new Map(entries);\n const parentOf = new Map<string, K>();\n for (const [k, p] of Object.entries(parents) as [K, K | null | undefined][]) {\n if (!this.#records.has(k)) throw new TypeError(`the tree has no key \"${k}\", but the parents name it`);\n if (p === null || p === undefined) continue;\n if (!this.#records.has(p)) throw new TypeError(`the parent \"${p}\" of \"${k}\" is not a key of the tree`);\n parentOf.set(k, p);\n }\n // A parent chain that comes back to a key of the same walk is a cycle, not a tree. Each key is in one walk\n // only: a walk stops at a key that an earlier walk proved to reach a root. Thus the check is linear.\n const reachesRoot = new Set<string>();\n for (const k of this.keys) {\n const walk = new Set<string>();\n for (let p: string | undefined = k; p !== undefined && !reachesRoot.has(p); p = parentOf.get(p)) {\n if (walk.has(p)) throw new TypeError(`the parents of \"${k}\" make a cycle, so the space is not a tree`);\n walk.add(p);\n }\n for (const w of walk) reachesRoot.add(w);\n }\n this.#parents = parentOf;\n const children = new Map<string, K[]>(this.keys.map((k) => [k, []]));\n for (const k of this.keys) {\n const p = parentOf.get(k);\n // Each parent is a key, so its list exists, and the test of p only skips the roots.\n // Stryker disable next-line ConditionalExpression,OptionalChaining: a root has no list to push to\n if (p !== undefined) children.get(p)?.push(k);\n }\n this.#children = new Map([...children].map(([k, c]) => [k, Object.freeze(c)]));\n }\n\n has(k: string): k is K {\n return this.#records.has(k);\n }\n get(k: string): O | undefined {\n return this.#records.get(k);\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n coords(): readonly number[] | undefined {\n return undefined;\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n keyAt(): K | undefined {\n return undefined;\n }\n // In a tree, the edges go from a parent to its children.\n successorsOf(k: string): readonly K[] {\n return this.childrenOf(k);\n }\n predecessorsOf(k: string): readonly K[] {\n const p = this.#parents.get(k);\n return p === undefined ? [] : [p];\n }\n parentOf(k: string): K | undefined {\n return this.#parents.get(k);\n }\n childrenOf(k: string): readonly K[] {\n return this.#children.get(k) ?? [];\n }\n}\n\n/** The constructors of spaces. */\n/** The empty list of keys. */\nconst NO_KEYS: readonly never[] = Object.freeze([]);\n\nclass GraphSpace<K extends string, O> implements Space<K, O> {\n readonly kind: SpaceKind = \"graph\";\n readonly keys: readonly K[];\n readonly records: readonly O[];\n readonly #records: ReadonlyMap<string, O>;\n readonly #out: ReadonlyMap<string, readonly K[]>;\n readonly #in: ReadonlyMap<string, readonly K[]>;\n\n constructor(records: Readonly<Record<K, O>>, edges: Readonly<Partial<Record<K, readonly K[]>>>) {\n const entries = Object.entries(records) as [K, O][];\n this.keys = Object.freeze(entries.map(([k]) => k));\n this.records = Object.freeze(entries.map(([, o]) => o));\n this.#records = new Map(entries);\n const out = new Map<string, readonly K[]>();\n for (const [k, to] of Object.entries(edges) as [K, readonly K[] | undefined][]) {\n if (!this.#records.has(k)) throw new TypeError(`the graph has no key \"${k}\", but the edges name it`);\n // A second edge to the same key is the same edge.\n const ends = [...new Set(to ?? NO_KEYS)];\n for (const t of ends) if (!this.#records.has(t)) throw new TypeError(`the edge from \"${k}\" goes to \"${t}\", which is not a key of the graph`);\n out.set(k, Object.freeze(ends));\n }\n this.#out = out;\n // The predecessors in key order: the keys in key order, and the ends of the edges of each key.\n const into = new Map<string, K[]>();\n for (const k of this.keys) {\n for (const t of out.get(k) ?? NO_KEYS) {\n const from = into.get(t);\n if (from === undefined) into.set(t, [k]);\n else from.push(k);\n }\n }\n this.#in = new Map([...into].map(([k, from]) => [k, Object.freeze(from)]));\n }\n\n has(k: string): k is K {\n return this.#records.has(k);\n }\n get(k: string): O | undefined {\n return this.#records.get(k);\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n coords(): readonly number[] | undefined {\n return undefined;\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n keyAt(): K | undefined {\n return undefined;\n }\n successorsOf(k: string): readonly K[] {\n return this.#out.get(k) ?? NO_KEYS;\n }\n predecessorsOf(k: string): readonly K[] {\n return this.#in.get(k) ?? NO_KEYS;\n }\n}\n\nexport const space = {\n /** This function makes a space from the entries of an object. The keys are the property names. */\n record<const R extends Readonly<Record<string, unknown>>>(records: R): Space<keyof R & string, R[keyof R]> {\n return new RecordSpace<keyof R & string, R[keyof R]>(records);\n },\n /** This function makes a space from an array. The keys are `\"0\"`, `\"1\"` and so on. */\n array<O>(items: readonly O[]): Space<ArrayKey, O> {\n return new ArraySpace(items);\n },\n /** This function makes a space from rows of cells. The key of a cell is `\"row,column\"`. */\n grid<O>(rows: readonly (readonly O[])[]): Space<GridKey, O> {\n return new GridSpace(rows);\n },\n /**\n * This function makes a tree space: the records by key, and the parent of each key. A key without a parent, or\n * with the parent `null`, is a root. A parent that is not a key, or a cycle of parents, throws a `TypeError`.\n */\n tree<const R extends Readonly<Record<string, unknown>>>(records: R, parents: Readonly<Partial<Record<keyof R & string, (keyof R & string) | null>>>): Space<keyof R & string, R[keyof R]> {\n return new TreeSpace<keyof R & string, R[keyof R]>(records, parents);\n },\n /**\n * This function makes a graph space: the records by key, and the edges from each key, in order. An edge to a key\n * that is not in the graph throws a `TypeError`. A graph can have cycles, and an edge can go from a key to itself.\n */\n graph<const R extends Readonly<Record<string, unknown>>>(records: R, edges: Readonly<Partial<Record<keyof R & string, readonly (keyof R & string)[]>>>): Space<keyof R & string, R[keyof R]> {\n return new GraphSpace<keyof R & string, R[keyof R]>(records, edges);\n },\n} as const;\n\n/** The position of an evaluation: the key where it started, and the key where relative references read. */\nexport interface Position {\n readonly origin: string;\n readonly focus: string;\n}\n\n/** This function applies one move to the focus. It gives the new focus, or a `#REF!` error. */\nexport function applyMove(s: Space, at: Position, m: FixedMove): Result<string> {\n const refError = (kind: \"unknown-key\" | \"not-a-pair\" | \"out-of-bounds\" | \"no-offset\" | \"no-tree\", message: string): Result<string> =>\n fail(vexError(kind, message, { origin: at.origin, focus: at.focus }));\n switch (m.t) {\n case \"key\":\n return s.has(m.key) ? ok(m.key) : refError(\"unknown-key\", `the space has no key \"${m.key}\"`);\n case \"index\": {\n const k = s.keys[m.i];\n return k !== undefined ? ok(k) : refError(\"out-of-bounds\", `the space has no key at index ${m.i}`);\n }\n case \"other\": {\n if (s.keys.length !== 2) return refError(\"not-a-pair\", `\"other\" needs a space with 2 keys, but this space has ${s.keys.length}`);\n const [a, b] = s.keys;\n // A pair has two keys, so `a` and `b` are defined.\n /* v8 ignore next -- @preserve */\n return ok(at.focus === a ? (b ?? at.focus) : (a ?? at.focus));\n }\n case \"offset\": {\n // In a tree space, an offset with one number moves among the siblings in key order. The roots are siblings.\n const parentOf = s.parentOf?.bind(s);\n const childrenOf = s.childrenOf?.bind(s);\n if (parentOf !== undefined && childrenOf !== undefined && m.d.length === 1) {\n const p = parentOf(at.focus);\n const group = p === undefined ? s.keys.filter((k) => parentOf(k) === undefined) : childrenOf(p);\n const i = group.indexOf(at.focus);\n const k = i < 0 ? undefined : group[i + (m.d[0] ?? 0)];\n return k === undefined ? refError(\"out-of-bounds\", `the offset [${m.d.join(\",\")}] from \"${at.focus}\" is outside its siblings`) : ok(k);\n }\n const c = s.coords(at.focus);\n if (c === undefined || c.length !== m.d.length) {\n return refError(\"no-offset\", `an offset of length ${m.d.length} is not valid in a ${s.kind} space`);\n }\n // The lengths are equal, so each index of `c` is also an index of `m.d`.\n /* v8 ignore next -- @preserve */\n const target = c.map((x, i) => x + (m.d[i] ?? 0));\n const k = s.keyAt(target);\n return k === undefined ? refError(\"out-of-bounds\", `the offset [${m.d.join(\",\")}] from \"${at.focus}\" is outside the space`) : ok(k);\n }\n case \"origin\":\n return ok(at.origin);\n case \"parent\": {\n if (s.parentOf === undefined) return refError(\"no-tree\", `\"parent\" needs a tree space, but this space is a ${s.kind}`);\n const p = s.parentOf(at.focus);\n return p === undefined ? refError(\"out-of-bounds\", `the key \"${at.focus}\" is a root, so it has no parent`) : ok(p);\n }\n }\n}\n\n/**\n * This function gives the fixed moves of an address. `values` has the value of the expression of each computed move,\n * in order (NAV.COMPUTED). A key that is not a text, or a position that is not a number, gives `#VALUE!`.\n */\nexport function fixAddr(addr: Addr, values: readonly unknown[], at: Position): Result<readonly FixedMove[]> {\n const out: FixedMove[] = [];\n let next = 0;\n for (const m of addr) {\n if (moveExpr(m) === undefined) {\n out.push(m as FixedMove);\n continue;\n }\n const u = values[next++];\n if (m.t === \"key\" && typeof u === \"string\") out.push({ t: \"key\", key: u });\n else if (m.t === \"index\" && typeof u === \"number\") out.push({ t: \"index\", i: u });\n else return fail(vexError(\"kind-mismatch\", m.t === \"key\" ? `the key of a move is a ${typeof u}, not a text` : `the position of a move is a ${typeof u}, not a number`, at));\n }\n return ok(out);\n}\n\n/** This function applies the moves of an address in order. It gives the key where the address points. */\nexport function resolveAddr(s: Space, at: Position, addr: readonly FixedMove[] | undefined): Result<string> {\n let focus = at.focus;\n for (const m of addr ?? []) {\n const r = applyMove(s, { origin: at.origin, focus }, m);\n if (!r.ok) return r;\n focus = r.value;\n }\n return ok(focus);\n}\n\nconst NEIGHBORS_4: readonly (readonly [number, number])[] = [[-1, 0], [0, -1], [0, 1], [1, 0]];\nconst NEIGHBORS_8: readonly (readonly [number, number])[] = [\n [-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1],\n];\n\n/** The axes of a tree space. */\ntype TreeAxis = \"children\" | \"ancestors\" | \"descendants\" | \"siblings\";\n\nfunction treeTargets(s: Space, at: Position, t: TreeAxis): Result<readonly string[]> {\n const parentOf = s.parentOf?.bind(s);\n const childrenOf = s.childrenOf?.bind(s);\n if (parentOf === undefined || childrenOf === undefined) {\n return fail(vexError(\"no-tree\", `\"${t}\" needs a tree space, but this space is a ${s.kind}`, at));\n }\n switch (t) {\n case \"children\":\n return ok(childrenOf(at.focus));\n case \"ancestors\": {\n const out: string[] = [];\n for (let p = parentOf(at.focus); p !== undefined; p = parentOf(p)) out.push(p);\n return ok(out);\n }\n case \"descendants\": {\n // A depth-first walk with a stack, so a deep tree does not need a deep call stack.\n const out: string[] = [];\n const stack = childrenOf(at.focus).toReversed();\n for (let k = stack.pop(); k !== undefined; k = stack.pop()) {\n out.push(k);\n stack.push(...childrenOf(k).toReversed());\n }\n return ok(out);\n }\n case \"siblings\": {\n const p = parentOf(at.focus);\n const group = p === undefined ? s.keys.filter((k) => parentOf(k) === undefined) : childrenOf(p);\n return ok(group.filter((k) => k !== at.focus));\n }\n }\n}\n\n/**\n * This function gives the targets of a base axis at a focus. It does not handle `where`, because the\n * interpreter must evaluate the test.\n */\nexport function axisTargets(s: Space, at: Position, a: Exclude<Axis, { readonly t: \"where\" }>): Result<readonly string[]> {\n switch (a.t) {\n case \"all\":\n return ok(s.keys);\n case \"others\":\n return ok(s.keys.filter((k) => k !== at.focus));\n case \"other\": {\n const r = applyMove(s, at, { t: \"other\" });\n return r.ok ? ok([r.value]) : r;\n }\n case \"neighbors\": {\n if (s.kind !== \"grid\") return fail(vexError(\"no-grid\", `\"neighbors\" needs a grid space, but this space is a ${s.kind}`, at));\n const deltas = a.n === 4 ? NEIGHBORS_4 : NEIGHBORS_8;\n return ok(\n deltas.flatMap((d) => {\n const r = applyMove(s, at, { t: \"offset\", d });\n return r.ok ? [r.value] : [];\n }),\n );\n }\n case \"children\":\n case \"ancestors\":\n case \"descendants\":\n case \"siblings\":\n return treeTargets(s, at, a.t);\n case \"window\":\n return windowTargets(s, at, a.from, a.to);\n case \"successors\":\n case \"predecessors\":\n case \"reachable\":\n return graphTargets(s, at, a.t);\n case \"reverse\": {\n // The validation of the IR keeps a base axis inside reverse: not where, reverse or table.\n const r = axisTargets(s, at, a.axis as Exclude<Axis, { readonly t: \"where\" }>);\n return r.ok ? ok(r.value.toReversed()) : r;\n }\n case \"table\":\n // The evaluator gives the axis table the space of its table. Here, without the tables, it has no targets.\n return fail(vexError(\"no-table\", `the axis \"table\" needs the tables of the evaluation, and \"${a.name}\" is not one of them`, at));\n case \"list\":\n // The evaluator gives the targets of the axis list from the value of its expression. A space alone has no list.\n return fail(vexError(\"bad-expression\", 'the axis \"list\" needs the evaluator, which gives the value of its list', at));\n }\n}\n\n/**\n * This function gives the targets of an axis of a graph. `reachable` has each key that a path of one or more edges\n * reaches from the focus, once, in the order of a breadth-first search. The focus is not a target of `reachable`.\n */\nfunction graphTargets(s: Space, at: Position, t: \"successors\" | \"predecessors\" | \"reachable\"): Result<readonly string[]> {\n const successorsOf = s.successorsOf?.bind(s);\n const predecessorsOf = s.predecessorsOf?.bind(s);\n if (successorsOf === undefined || predecessorsOf === undefined) {\n return fail(vexError(\"no-graph\", `\"${t}\" needs a graph space or a tree space, but this space is a ${s.kind}`, at));\n }\n if (t === \"successors\") return ok(successorsOf(at.focus));\n if (t === \"predecessors\") return ok(predecessorsOf(at.focus));\n // A queue, not recursion, so a long path does not need a deep call stack. A loop over an array also reads the\n // keys that the loop adds to it.\n const seen = new Set<string>([at.focus]);\n const queue: string[] = [at.focus];\n for (const k of queue) {\n for (const next of successorsOf(k)) {\n if (seen.has(next)) continue;\n seen.add(next);\n queue.push(next);\n }\n }\n return ok(queue.slice(1));\n}\n\n/**\n * This function gives the targets of the axis `window(from, to)`: the keys of the moves `offset(d)` for each `d`\n * from `from` to `to`, in order. An offset outside the space has no target. The axis needs an array space or a tree\n * space, where an offset has one number.\n */\nfunction windowTargets(s: Space, at: Position, from: number, to: number): Result<readonly string[]> {\n const tree = s.parentOf !== undefined && s.childrenOf !== undefined;\n if (!tree && s.coords(at.focus)?.length !== 1) {\n return fail(vexError(\"no-offset\", `\"window\" needs an array space or a tree space, but this space is a ${s.kind}`, at));\n }\n // An offset larger than the number of keys has no target, so the loop stays in the size of the space.\n const out: string[] = [];\n for (let d = Math.max(from, -s.keys.length); d <= Math.min(to, s.keys.length); d++) {\n const r = applyMove(s, at, { t: \"offset\", d: [d] });\n if (r.ok) out.push(r.value);\n }\n return ok(out);\n}\n","/**\n * Domains. A domain tells which values belong to it and which ops it has. The domain object owns this data.\n * Vex does not write to the prototypes of domain classes, and an import has no side effects.\n */\n\n/** An algebraic law that an op claims. `@mark1russell7/vex-testkit` checks each claim with property tests. */\nexport type Law = \"commutative\" | \"associative\" | \"idempotent\";\n\n/** The kind of a parameter. The interpreter checks the arguments of an op that declares its parameters. */\nexport type ParamKind = \"domain\" | \"number\" | \"boolean\" | \"string\" | \"any\";\n\n/**\n * The kind of the result of an op. It is a kind of a parameter, or `domain:Name` for a value of the domain `Name`. It is\n * `list:Kind` for a `vex.list` with items of a primitive type.\n */\nexport type ReturnKind = ParamKind | `domain:${string}` | `list:${PrimitiveKind}`;\n\n/**\n * How the size of one argument adds to the size of the result of an op (LOOP.SIZE.OPS). The size of a value counts the\n * texts, the fields, the keys and the items in it.\n *\n * - `0`: the argument does not add to the size.\n * - `1`: the size of the argument adds one time.\n * - `\"scaled\"`: the size of the argument adds a fixed number of times, for example two times.\n * - `\"many\"`: the size of the argument adds more than one time.\n * - `\"unbounded\"`: the size of the result has no bound in the size of the argument.\n * - `\"text\"`: the size adds one time for a text, and a fixed number of times for another value, as its JSON text.\n * - `\"copies\"`: the size adds one time for each copy. The first argument is the number of the copies.\n * - `\"each\"`: the size adds one time for each item of the first argument.\n * - `\"number\"`: the argument is a number that sets a count. A literal number gives that count, and another number\n * gives a fixed bound.\n * - `\"limit\"`: the size adds one time for each item that the literal number at the position `limit` keeps. Each item\n * adds a key with a fixed bound. Without a literal number, this use is the same as `\"many\"`.\n */\nexport type SizeUse = 0 | 1 | \"scaled\" | \"many\" | \"unbounded\" | \"text\" | \"copies\" | \"each\" | \"number\" | \"limit\";\n\n/**\n * A measure of a value for the check of sizes (LOOP.SIZE.OPS). `size` is the size of the value, and `count` is the\n * number of its items. `inner` is the sum of the counts of the values of its items. `item` is the size of its largest\n * item. The items of a record are its fields, and a text is its own item. `part` is the largest `item` of its items. It is\n * not larger than `item`.\n */\nexport type SizeMeasure = \"size\" | \"count\" | \"inner\" | \"item\" | \"part\";\n\n/** One term of a size rule: a use of the same measure of the argument, or a use of the measure that the pair names. */\nexport type SizeTerm = SizeUse | readonly [use: SizeUse, of: SizeMeasure];\n\n/**\n * The size rule of an op: how the measures of its result follow from its arguments (LOOP.SIZE.OPS). The check of sizes\n * reads it in the steps of `fold` and `iterate` (LOOP.SIZE).\n *\n * - `\"scalar\"`: the result is a number or a boolean.\n * - `\"fixed\"`: the result has a size with a fixed bound, for example a 2D vector.\n * - `\"reduce\"`: the rule of the list op `reduce`. The op that its second argument names gives the size.\n * - A record: `SizeTerms`.\n */\nexport type SizeRule = \"scalar\" | \"fixed\" | \"reduce\" | SizeTerms;\n\n/**\n * The size rule of an op as data (LOOP.SIZE.OPS). `size`, `count`, `inner`, `item` and `part` have one term for each\n * argument. `rest` is the use of the arguments after them, and its default is `\"many\"`. Without `count`, `inner` or `item`,\n * that measure of the result is its size. Without `part`, the largest part of the result is its largest item. The terms of\n * `item` and `part` give the largest bound of the arguments, because the largest item comes from one argument. A literal\n * number at the position `limit` sets the count. With `keys: \"position\"`, the items get their positions as new keys. With\n * `constant: true`, the result can also hold a part with a fixed size. With `union: true`, the result holds each key of\n * its arguments one time, so the bound of the result is the largest bound of the arguments.\n *\n * `byParts` is a second rule for a result that is a part of an argument, or that holds a fixed number of its items. The\n * second reading of the check uses this rule (LOOP.SIZE.READINGS). A rule with `limit` keeps the first rule when the limit\n * is not a literal number or when a key can be long.\n */\nexport interface SizeTerms {\n readonly size: readonly SizeTerm[];\n readonly count?: readonly SizeTerm[];\n readonly inner?: readonly SizeTerm[];\n readonly item?: readonly SizeTerm[];\n readonly part?: readonly SizeTerm[];\n readonly rest?: SizeUse;\n readonly limit?: number;\n readonly keys?: \"position\";\n readonly constant?: true;\n readonly union?: true;\n readonly byParts?: SizeTerms;\n}\n\n/** The description of one op of a domain. */\nexport interface OpSpec<D = never> {\n /**\n * The implementation, for an op that is not a method of the value (static-land style). The first argument\n * is the receiver. Without `fn`, the interpreter calls the method of the receiver with the same name.\n */\n readonly fn?: (self: D, ...args: never[]) => unknown;\n /** The laws that the op claims. */\n readonly laws?: readonly Law[];\n /** The identity element of the op, for reductions over an empty list. */\n readonly identity?: () => D;\n /** Scalar lifting: `true` lifts each number argument with `fromScalar`. An array sets it for each argument. */\n readonly liftScalar?: boolean | readonly boolean[];\n /** The kinds of the parameters after the receiver. When set, the interpreter checks the arguments. */\n readonly params?: readonly ParamKind[];\n /**\n * The kind of the result. It is `domain` for a value of this domain, or `domain:Name` for a value of the domain `Name`.\n * It is `list:Kind` for a `vex.list` with items of that primitive type (KIND.RETURNS.LIST). A compiler reads it to know\n * the kinds of the values of a program (KIND.RETURNS). The interpreter does not check it, and the law checker of the\n * test kit does.\n */\n readonly returns?: ReturnKind;\n /**\n * The size rule of the op (LOOP.SIZE.OPS). Without it, an op whose result is a number or a boolean has the rule\n * `\"scalar\"`. An op of a domain with `size: \"fixed\"` has the rule `\"fixed\"`. Another op has no rule, so a step of a\n * loop cannot use its result in the size of a list name (LOOP.SIZE).\n */\n readonly size?: SizeRule;\n /**\n * This field gives the direction of the result of the op for each argument, with the receiver first (FIX.OPS). `up`\n * means that the result does not fall as the argument rises. `down` means that the result does not rise. An op without\n * it cannot take a value that reads `last`, and an argument without a direction must not read `last`.\n */\n readonly monotone?: readonly Monotone[];\n}\n\n/** A direction of an op: the result follows the argument (`up`) or moves against it (`down`). */\nexport type Monotone = \"up\" | \"down\";\n\n/**\n * The form of a domain in a standalone module (COMPILE.MODULE.FORM). A module has no import, so it cannot hold a value of\n * a class. Each part replaces the part of the domain with the same name, only in a module. A compiler copies the text of\n * each function, so a function reads only its parameters.\n */\nexport interface ModuleForm {\n /** The test of a value in a module. */\n readonly is?: (u: unknown) => boolean;\n /** The scalar lift in a module. */\n readonly fromScalar?: (n: number) => unknown;\n /** Some values of the module form. A compiler checks each copy with them. */\n readonly samples?: () => readonly unknown[];\n /**\n * The plain data of a literal of the program, or `undefined` for a value of another domain. This function runs in the\n * compiler, not in a module, so it can read a class.\n */\n readonly literal?: (value: unknown) => Readonly<Record<string, unknown>> | undefined;\n /** The parts of each op in a module. */\n readonly ops?: Readonly<Record<string, { readonly fn?: (self: never, ...args: never[]) => unknown; readonly identity?: () => unknown; readonly returns?: ReturnKind }>>;\n}\n\n/** A JavaScript type of primitive values that a domain can accept. */\nexport type PrimitiveKind = \"number\" | \"string\" | \"boolean\";\n\n/** This function gives the kind of the items of a result of the kind `list:Kind`, or `undefined` for another kind. */\nexport const listItemKind = (r: ReturnKind | undefined): PrimitiveKind | undefined => (r?.startsWith(\"list:\") === true ? (r.slice(\"list:\".length) as PrimitiveKind) : undefined);\n\n/** The type of an op that lifts number arguments. Use it to type the ops of a domain under `isolatedDeclarations`. */\nexport type LiftedOp<D> = OpSpec<D> & { readonly liftScalar: true };\n\n/** The type of an op with an implementation function `F`. */\nexport type FnOp<D, F extends (self: D, ...args: never[]) => unknown> = OpSpec<D> & { readonly fn: F };\n\n/**\n * The type of an op table: each name in `Names` is an op, and each name in `Lifted` lifts number arguments.\n * Use it to type the ops of a domain under `isolatedDeclarations`.\n */\nexport type OpTable<D, Names extends string, Lifted extends string = never> = {\n readonly [N in Names]: N extends Lifted ? LiftedOp<D> : OpSpec<D>;\n};\n\n/** The description of a domain, as a caller gives it to `defineDomain`. */\nexport interface DomainSpec<Name extends string, D, Ops extends Readonly<Record<string, OpSpec<D>>>> {\n /** The name of the domain. */\n readonly name: Name;\n /** The runtime test for the values of the domain. It must not give false positives. */\n readonly is: (u: unknown) => u is D;\n /**\n * The JavaScript type of the values of the domain, if `is` accepts each value of that type and no other value\n * (KIND.PRIMITIVE). A compiler then finds the op of such a value before a run.\n */\n readonly primitive?: PrimitiveKind;\n /**\n * The field names of a value, if `is` accepts only plain objects with exactly these fields (KIND.FIELDS). Two domains\n * with different names have no common value, so a compiler finds the domain of such a value before a run.\n */\n readonly fields?: readonly string[];\n /** The ops of the domain, with their metadata. */\n readonly ops: Ops;\n /**\n * With `\"fixed\"`, each value of the domain has a size with a fixed bound, for example a 2D vector. Then each op of the\n * domain has the size rule `\"fixed\"` or `\"scalar\"`, unless the op has its own rule (LOOP.SIZE.OPS).\n */\n readonly size?: \"fixed\";\n /** With `\"all\"`, each method of a value is an op, also without an entry in `ops`. The default is `\"declared\"`. */\n readonly methods?: \"declared\" | \"all\";\n /** The scalar lift: it makes a domain value from a number. */\n readonly fromScalar?: (n: number) => D;\n /** A check of the values that ops give. A value that fails the check gives the error `#NUM!`. */\n readonly valid?: (d: D) => boolean;\n /** A short text for a value, for traces and the site. */\n readonly show?: (d: D) => string;\n /** The JSON form of a value, for literals in serialized programs. */\n readonly encode?: (d: D) => unknown;\n /** The value of a JSON form that `encode` made. */\n readonly decode?: (json: unknown) => D;\n /**\n * Some values of the domain. A compiler gives them to an op and to its copy in a module: the two must give the same\n * results (KIND.DOMAIN).\n */\n readonly samples?: () => readonly D[];\n /** The form of the domain in a standalone module, for a domain with values of a class (COMPILE.MODULE.FORM). */\n readonly moduleForm?: ModuleForm;\n}\n\n/** A domain. Make one with `defineDomain`. */\nexport interface Domain<Name extends string = string, D = unknown, Ops extends Readonly<Record<string, OpSpec<D>>> = Readonly<Record<string, OpSpec<D>>>>\n extends DomainSpec<Name, D, Ops> {\n readonly kind: \"vex.domain\";\n}\n\n/** A domain with any value type. The interpreter uses this type. */\n// oxlint-disable-next-line typescript/no-explicit-any -- a list of domains with different value types needs `any`: `fn` is contravariant in the value type.\nexport type AnyDomain = Domain<string, any, Readonly<Record<string, OpSpec<any>>>>;\n\n/** This function makes a domain. The result is frozen. */\nexport function defineDomain<const Name extends string, D, const Ops extends Readonly<Record<string, OpSpec<D>>>>(\n spec: DomainSpec<Name, D, Ops>,\n): Domain<Name, D, Ops> {\n return Object.freeze({ ...spec, kind: \"vex.domain\" as const });\n}\n\nconst FORBIDDEN = new Set([\"constructor\", \"__proto__\", \"prototype\", \"__defineGetter__\", \"__defineSetter__\", \"__lookupGetter__\", \"__lookupSetter__\"]);\n\n/** This function tells if a name can be an op name. */\nexport const isOpName = (name: string): boolean => name.length > 0 && !FORBIDDEN.has(name);\n\n/**\n * This function finds a method on a value: an own function property, or a function on the prototype chain.\n * It stops at `Object.prototype` and `Function.prototype`, so inherited members (for example `toString`) are not ops.\n */\nexport function findMethod(self: unknown, name: string): ((...args: unknown[]) => unknown) | undefined {\n if (!isOpName(name)) return undefined;\n // A primitive has no own methods. The loop below stops at null, so null needs no test here.\n if (typeof self !== \"object\" && typeof self !== \"function\") return undefined;\n let o: object | null = self;\n while (o !== null && o !== Object.prototype && o !== Function.prototype) {\n const d = Object.getOwnPropertyDescriptor(o, name);\n if (d !== undefined) {\n return typeof d.value === \"function\" ? (d.value as (...args: unknown[]) => unknown) : undefined;\n }\n o = Object.getPrototypeOf(o) as object | null;\n }\n return undefined;\n}\n\n/** An op that the interpreter found for a receiver. */\nexport interface ResolvedOp {\n readonly domain: AnyDomain;\n readonly spec: OpSpec<unknown>;\n readonly call: (args: readonly unknown[]) => unknown;\n}\n\nconst EMPTY_SPEC: OpSpec<unknown> = Object.freeze({});\n\n/** This function finds the op `name` for `self` in one domain. It gives `undefined` if the domain does not have it. */\nexport function resolveOp(domain: AnyDomain, self: unknown, name: string): ResolvedOp | undefined {\n if (!isOpName(name)) return undefined;\n const declared = Object.hasOwn(domain.ops, name) ? (domain.ops[name] as OpSpec<unknown>) : undefined;\n if (declared?.fn !== undefined) {\n const fn = declared.fn as (self: unknown, ...args: unknown[]) => unknown;\n return { domain, spec: declared, call: (args) => fn(self, ...args) };\n }\n if (declared === undefined && domain.methods !== \"all\") return undefined;\n const method = findMethod(self, name);\n if (method === undefined) return undefined;\n return { domain, spec: declared ?? EMPTY_SPEC, call: (args) => method.apply(self, [...args]) };\n}\n\n/** This function gives the domain of a value: the first domain whose `is` accepts it. */\nexport function domainOf(domains: readonly AnyDomain[], value: unknown): AnyDomain | undefined {\n return domains.find((d) => d.is(value));\n}\n\n/** This function tells if the `liftScalar` setting lifts the argument at `index`. */\nexport const liftsAt = (lift: OpSpec<unknown>[\"liftScalar\"], index: number): boolean =>\n lift === true || (Array.isArray(lift) && lift[index] === true);\n","/**\n * Arrays as lists (LIST.ARRAY). A JSON array of a field or of a name reads as a list where a list op or the axis `list`\n * needs a list. The package index does not export this module: `evaluate.ts` and `kernel.ts` use it.\n */\nimport type { VexError } from \"./errors.ts\";\nimport { MAX_ITERATIONS } from \"./ir.ts\";\nimport { isVexList, vexList, type ListItem, type VexList } from \"./list.ts\";\nimport { fail, ok } from \"./result.ts\";\n\n/**\n * This function gives the list of an array (LIST.ARRAY). The key of each item is its position, from \"0\". A position\n * without a value, or with `null`, gives an error item from `missing`, as a missing field does (REF.MISSING).\n */\nexport function listOfArray(array: readonly unknown[], missing: (message: string) => VexError): VexList {\n const items: ListItem[] = [];\n // A loop over the positions, not `map`, so a hole of a sparse array is an error item too.\n for (let i = 0; i < array.length; i++) {\n const x = array[i];\n items.push({ key: String(i), result: x === undefined || x === null ? fail(missing(`the array has no value at the position ${String(i)}`)) : ok(x) });\n }\n return vexList(items);\n}\n\n/** This function gives a list, the list of an array, or `undefined` for another value (LIST.ARRAY). */\nexport const asList = (u: unknown, missing: (message: string) => VexError): VexList | undefined => (isVexList(u) ? u : Array.isArray(u) ? listOfArray(u, missing) : undefined);\n\n/**\n * This function tells if a value is a count of `fill`: a whole number from 0 to the limit of `iterate`, 100000\n * (LIST.FILL). Thus a list of `fill` is not larger than the steps of a loop.\n */\nexport const isFillCount = (n: unknown): n is number => Number.isSafeInteger(n) && (n as number) >= 0 && (n as number) <= MAX_ITERATIONS;\n\n/** This function gives the list of `fill` (LIST.FILL): `n` items with the value `value`, and the keys \"0\" to \"n - 1\". */\nexport const fillList = (n: number, value: unknown): VexList => vexList(Array.from({ length: n }, (_x, i): ListItem => ({ key: String(i), result: ok(value) })));\n\n/** This function tells if a value can be the value of `indexOf`: a number, a text or a boolean (LIST.INDEXOF). */\nexport const isIndexValue = (u: unknown): u is number | string | boolean => typeof u === \"number\" || typeof u === \"string\" || typeof u === \"boolean\";\n","/**\n * The JSON form of the values of a literal. `serialize`, `parse`, `toDocument` and `fromDocument` share it. The package\n * index does not export this module.\n */\nimport type { AnyDomain } from \"./domain.ts\";\nimport { vexError } from \"./errors.ts\";\nimport { fail, ok, type Result } from \"./result.ts\";\n\n/**\n * The JSON form of the values in a literal. JSON data stays as it is, with three exceptions. Each exception is a record\n * with the key `$vex`:\n *\n * - `{ \"$vex\": \"domain\", \"domain\": name, \"value\": v }`: a value of a domain, with the `encode` of the domain.\n * - `{ \"$vex\": \"number\", \"value\": \"-0\" }`: a number that JSON has no text for: `-0`, `NaN`, `Infinity` or `-Infinity`.\n * - `{ \"$vex\": \"escape\", \"value\": record }`: a record of the data that has the key `$vex` itself (IR.JSON.ESCAPE).\n *\n * A record with the key `$vex` and another form stays data, so a file from an older version reads as before.\n *\n * The functions walk the tree of the expression, so only the value of a literal gets this form. A field of a literal\n * that looks like an expression stays data. The data of an extension is plain JSON, as before. A document has the same\n * form for the value of a literal (DOC.LITERAL).\n */\ntype Encoded =\n | { readonly $vex: \"domain\"; readonly domain: string; readonly value: unknown }\n | { readonly $vex: \"number\"; readonly value: \"-0\" | \"NaN\" | \"Infinity\" | \"-Infinity\" }\n | { readonly $vex: \"escape\"; readonly value: Readonly<Record<string, unknown>> };\n\n/** This function tells if a value is a record: an object that is not an array. */\nexport const isRecord = (u: unknown): u is Readonly<Record<string, unknown>> => typeof u === \"object\" && u !== null && !Array.isArray(u);\n\nconst isPlainRecord = (u: unknown): u is Readonly<Record<string, unknown>> => {\n if (!isRecord(u)) return false;\n const proto: unknown = Object.getPrototypeOf(u);\n return proto === Object.prototype || proto === null;\n};\n\n/** This function gives the JSON form of a value, or the reason why the value has no JSON form. */\nexport function encodeValue(u: unknown, domains: readonly AnyDomain[]): Result<unknown> {\n if (u === null || typeof u === \"string\" || typeof u === \"boolean\") return ok(u);\n if (typeof u === \"number\") {\n if (Object.is(u, -0)) return ok({ $vex: \"number\", value: \"-0\" } satisfies Encoded);\n // Stryker disable next-line EqualityOperator: here u is an infinity, so u > 0 and u >= 0 are the same test\n return Number.isFinite(u) ? ok(u) : ok({ $vex: \"number\", value: Number.isNaN(u) ? \"NaN\" : u > 0 ? \"Infinity\" : \"-Infinity\" } satisfies Encoded);\n }\n if (Array.isArray(u)) {\n const out: unknown[] = [];\n for (const x of u) {\n const r = encodeValue(x, domains);\n if (!r.ok) return r;\n out.push(r.value);\n }\n return ok(out);\n }\n if (isPlainRecord(u)) {\n const entries: [string, unknown][] = [];\n for (const [k, x] of Object.entries(u)) {\n const r = encodeValue(x, domains);\n if (!r.ok) return r;\n entries.push([k, r.value]);\n }\n // Object.fromEntries gives an own field for each key, also for \"__proto__\" (V-062).\n const out = Object.fromEntries(entries);\n return ok(Object.hasOwn(u, \"$vex\") ? ({ $vex: \"escape\", value: out } satisfies Encoded) : out);\n }\n // A plain array or record stays data. Another object is a value of a domain, or it has no JSON form.\n const d = domains.find((dom) => dom.encode !== undefined && dom.is(u));\n if (d?.encode !== undefined) return ok({ $vex: \"domain\", domain: d.name, value: d.encode(u) } satisfies Encoded);\n return fail(vexError(\"bad-expression\", \"a literal value is not JSON data and no domain encodes it\"));\n}\n\nconst NUMBERS: Readonly<Record<string, number>> = { \"-0\": -0, NaN: Number.NaN, Infinity: Number.POSITIVE_INFINITY, \"-Infinity\": Number.NEGATIVE_INFINITY };\n\n/** This function reads a value from its JSON form. */\nexport function decodeValue(u: unknown, domains: readonly AnyDomain[]): Result<unknown> {\n if (Array.isArray(u)) {\n const out: unknown[] = [];\n for (const x of u) {\n const r = decodeValue(x, domains);\n if (!r.ok) return r;\n out.push(r.value);\n }\n return ok(out);\n }\n if (!isRecord(u)) return ok(u);\n const fields = (record: Readonly<Record<string, unknown>>): Result<unknown> => {\n const entries: [string, unknown][] = [];\n for (const [k, x] of Object.entries(record)) {\n const r = decodeValue(x, domains);\n if (!r.ok) return r;\n entries.push([k, r.value]);\n }\n // A key \"__proto__\" of the data is an own field too (V-062).\n return ok(Object.fromEntries(entries));\n };\n // A record without the key $vex matches none of the forms below, so it stays data too.\n const kind = u[\"$vex\"];\n if (kind === \"escape\" && isRecord(u[\"value\"])) return fields(u[\"value\"]);\n if (kind === \"number\" && typeof u[\"value\"] === \"string\" && Object.hasOwn(NUMBERS, u[\"value\"])) return ok(NUMBERS[u[\"value\"]]);\n if (kind === \"domain\" && typeof u[\"domain\"] === \"string\") {\n const name = u[\"domain\"];\n const d = domains.find((dom) => dom.name === name);\n if (d?.decode === undefined) return fail(vexError(\"bad-expression\", `no domain \"${name}\" decodes a literal`));\n return ok(d.decode(u[\"value\"]));\n }\n // A form that this version does not know stays data, so a file from an older version reads as before.\n return fields(u);\n}\n","import { isDepthError, vexError, type ErrorDetails, type VexError } from \"./errors.ts\";\n\n/** This function gives the error that decides for a list of errors: `#DEPTH!`, or else the first (EVAL.DEPTH). */\nexport const worstError = (errors: readonly VexError[]): VexError | undefined => errors.find(isDepthError) ?? errors[0];\n\n/** This function gives the message of a data limit above the cap (ITERATE.LIMIT.ERROR). */\nexport const overLimitMessage = (count: number): string => `the data limit of \"iterate\" is ${String(count)}, above the cap of 100000`;\n\n/**\n * This function gives the error of a data limit that is not valid, with its cause (ITERATE.LIMIT.ERROR). An error of the\n * run stays as it is: the engine failed or a cycle of cells stopped, not the limit.\n */\nexport const limitError = (cause: VexError, details: Omit<ErrorDetails, \"causes\"> = {}): VexError =>\n isDepthError(cause) || cause.kind === \"cycle\" ? cause : vexError(\"limit\", 'the data limit of \"iterate\" is not valid', { ...details, causes: [cause] });\n","/**\n * These are the rules of a fixed-point column that the closure compiler and the kernel share (FIX.ROUNDS, FIX.JOIN,\n * FIX.LIMIT). They are the limit of the rounds, the kinds of the values of a row and the join of a row. The package\n * index exports the rules that the compiler needs too (COMPILE.FIX).\n */\nimport { errorText, type ErrorText } from \"./error-text.ts\";\nimport { MAX_ITERATIONS, type FixJoin } from \"./ir.ts\";\n\n/**\n * This function gives the largest number of rounds of a column of `rows` rows. A boolean column changes at least one row\n * in each round before the last, and a row changes one time. A path has fewer rows than the column, so a number\n * column stops in this bound when its steps follow paths (FIX.LIMIT).\n */\nexport const fixRounds = (rows: number): number => Math.min(rows + 1, MAX_ITERATIONS);\n\n/** This function gives the kind of the values of a join. */\nexport const joinKind = (join: FixJoin): \"boolean\" | \"number\" => (join === \"or\" || join === \"and\" ? \"boolean\" : \"number\");\n\n/** This function gives the reason that a value cannot be a value of a row, or `undefined` for a good value (FIX.KIND). */\nexport function fixValueError(name: string, join: FixJoin, value: unknown): ErrorText | undefined {\n const kind = joinKind(join);\n if (typeof value !== kind) return errorText.fixKind(name, join, kind, value);\n return kind === \"boolean\" || Number.isFinite(value) ? undefined : errorText.fixNumber(name, value);\n}\n\n/**\n * This function gives the error that stands for the failed rows of a round, or `undefined` when `#ARGS` must collect them\n * (FIX.ERROR). `#DEPTH!` wins. `#CYCLE!` comes next, so a cell on a cycle reports the cycle (SHEET.CYCLE).\n */\nexport function worstRow<E extends { readonly code: string }>(errors: readonly E[]): E | undefined {\n return errors.find((x) => x.code === \"#DEPTH!\") ?? errors.find((x) => x.code === \"#CYCLE!\") ?? (errors.length === 1 ? errors[0] : undefined);\n}\n\n/** This function joins the next value of a row to its old value (FIX.JOIN). The values have the kind of the join. */\nexport function joinValues(join: FixJoin, old: unknown, next: unknown): unknown {\n switch (join) {\n case \"or\":\n return old === true || next === true;\n case \"and\":\n return old === true && next === true;\n case \"max\":\n return Math.max(old as number, next as number);\n case \"min\":\n return Math.min(old as number, next as number);\n }\n}\n","/**\n * The comparison of the values of Vex for `agree` of the kernel (EVAL.AGREE), and the test of a Vex error. The package\n * index does not export this module: `kernel.ts` and `plan.ts` use it.\n */\nimport { sameValue } from \"@mark1russell7/coeval\";\nimport type { VexError } from \"./errors.ts\";\n\n/** This function tells if a value is a Vex error: it has a code, a kind, a message and a path. */\nexport function isVexError(u: unknown): u is VexError {\n const e = u as Partial<VexError> | null | undefined;\n return typeof e?.code === \"string\" && typeof e.kind === \"string\" && typeof e.message === \"string\" && Array.isArray(e.path);\n}\n\n/** This function tells if a value is a value of a class: an object that is not a plain record and not an array. */\nfunction isInstance(u: unknown): u is object {\n if (typeof u !== \"object\" || u === null || Array.isArray(u)) return false;\n const proto: unknown = Object.getPrototypeOf(u);\n return proto !== Object.prototype && proto !== null;\n}\n\n/**\n * This function compares two values of Vex for `agree`. Two Vex errors agree when they have the same code, because\n * only the closure compiler gives the location of an error (EVAL.LOCATION). Two values of one class agree when their\n * fields agree, for example two values of a domain from two decodes of a literal. The rules of `sameValue` compare\n * each other pair.\n */\nexport function sameVex(a: unknown, b: unknown): boolean | undefined {\n if (isVexError(a) && isVexError(b)) return a.code === b.code;\n if (!isInstance(a) || !isInstance(b)) return undefined;\n return Object.getPrototypeOf(a) === Object.getPrototypeOf(b) && sameValue({ ...a }, { ...b }, sameVex);\n}\n","/**\n * Vex in the kernel of coeval (decision D13 of coeval, and decision D13 of Vex in `docs/REVIEW.md`). This module gives\n * the contracts of the kinds of Vex as data, and a machine of the kernel that evaluates the documents of Vex.\n *\n * - The static kit of the kernel checks a document by these contracts (`fromDocument`, DOC.ERROR) and finds its\n * references (`deps`, DEPS.READS).\n * - The machine is the reference tier of Vex. The closure compiler and the loop compiler give its results\n * (EVAL.REFERENCE). It evaluates the shared constructs with the formula kit of the kernel, and a profile gives the\n * rules of Vex. Vex adds only what is its own: the moves, the axes, the loops and the dispatch on the domains.\n */\nimport {\n type Context,\n type Definitions,\n type EvalError,\n type EvalFn,\n type Failed,\n type ExtFn,\n type FormulaProfile,\n type HostThing,\n type Key,\n type Kind,\n type LazyOp,\n type Machine,\n type PartShape,\n type Part,\n type Result as Outcome,\n type Walker,\n type World,\n Failure,\n Held,\n STD_EXT,\n THING,\n formulaDefinitions,\n formulaEvaluators,\n ok,\n} from \"@mark1russell7/coeval\";\nimport { asList, fillList, isFillCount, isIndexValue, listOfArray } from \"./array-list.ts\";\nimport { decodeValue } from \"./codec.ts\";\nimport type { AnyDomain } from \"./domain.ts\";\nimport { vexError, type ErrorCode, type ErrorDetails, type ErrorKind, type VexError } from \"./errors.ts\";\nimport { limitError, overLimitMessage, worstError } from \"./limit-error.ts\";\nimport type { CompileOptions } from \"./evaluate.ts\";\nimport { errorText } from \"./error-text.ts\";\nimport { fixRounds, fixValueError, joinValues, worstRow } from \"./fix.ts\";\nimport { MAX_ITERATIONS, type Axis, type FixJoin, type FixedMove } from \"./ir.ts\";\nimport { isVexList, LIST_OPS, vexList, type ListItem } from \"./list.ts\";\nimport { fail as vexFail, ok as vexOk, type Result } from \"./result.ts\";\nimport { isVexError } from \"./same.ts\";\nimport { applyMove, axisTargets, type Space } from \"./space.ts\";\n\n// ---------------------------------------------------------------- the contracts\n\n/** The kinds of the terms of Vex. A part in the position of a term has one of these kinds (DOC.TERM). */\nexport const TERM_KINDS: readonly (readonly string[])[] = [[\"lit\"], [\"ref\"], [\"record\"], [\"let\"], [\"call\"], [\"each\"], [\"fold\"], [\"iterate\"], [\"fix\"], [\"last\"], [\"ops\"], [\"ext\"]];\n\n/** A term: an envelope of a term kind, or a bare value, which is a literal. */\nconst TERM: PartShape = { shape: \"term\", of: \"lit\", kinds: TERM_KINDS };\nconst TERMS: PartShape = { shape: \"list\", item: TERM };\nconst NAMES: PartShape = { shape: \"map\", item: TERM };\nconst AXIS: PartShape = { shape: \"term\", kinds: [[\"axes\"]] };\n/** The address of `each` and `fold`: a reference that gives a key of the space, not a value (DOC.ADDRESS). */\nconst ADDRESS: PartShape = { shape: \"term\", kinds: [[\"ref\"]], address: true };\nconst NO_VALUE: PartShape = { shape: \"one\", values: [null] };\n/** The limit of `iterate`: a bare whole number, or the size of an axis (ITERATE.LIMIT.DATA). */\nconst LIMIT: PartShape = { shape: \"term\", of: \"limit\", kinds: [[\"limit\"], [\"size\"]] };\n\n/** This function gives the shape of a record with these fields and no other fields (DOC.CONSTRUCT). */\nconst closed = (fields: Readonly<Record<string, PartShape>>, required: readonly string[]): PartShape => ({ shape: \"record\", fields, required, closed: true });\n\n/** The axes without parameters. */\nconst PLAIN_AXES = [\"all\", \"others\", \"other\", \"children\", \"ancestors\", \"descendants\", \"siblings\", \"successors\", \"predecessors\", \"reachable\"] as const;\n\n/** This function gives the kind of an axis with these parameters (DOC.AXIS). */\nconst axisKind = (fields: Readonly<Record<string, PartShape>>): Kind => ({ verbs: { eval: \"vex.axis\" }, parts: closed(fields, Object.keys(fields)), summary: \"An axis of Vex: the targets of a body.\" });\n\n/** This function gives the kind of a move. Its document is a step of a path, and a computed key is its part (DOC.MOVE). */\nconst move = (walker: string, parts: PartShape): Kind => ({ verbs: { eval: \"formula.step\", step: walker }, parts, summary: \"A move of Vex: a step to another key of the space.\" });\n\n/** The scope of a loop: the names of `init`, for the steps, the test `until` and the result (LOOP.NAMES). */\nconst LOOP_SCOPE = [{ names: { keysAt: [\"init\"] }, in: [[\"step\", \"*\"], [\"until\"], [\"result\"]] }] as const;\n\n/** The names of the items of a loop over the axis `list`: one or two distinct texts (AXIS.LIST.SCOPE). */\nconst ITEM_NAMES: PartShape = { shape: \"list\", item: { shape: \"text\" }, distinct: true };\n\n/**\n * This function gives the world of Vex. The module uses it one time, and the annotation `__PURE__` lets a bundler\n * remove the world from a program that does not use it.\n */\nfunction worldOfVex(): World {\n /** A binding of a `let`: a term, or a function (FN.BIND). */\n const BIND: PartShape = { shape: \"term\", of: \"lit\", kinds: [...TERM_KINDS, [\"fn\"]] };\n /** The axes that `reverse` can hold: each axis but `where`, `reverse` and `table` (AXIS.REVERSE). */\n const BASE_AXES: readonly string[] = [...PLAIN_AXES, \"neighbors\", \"window\", \"list\"];\n return {\n kinds: {\n lit: { verbs: { eval: \"vex.lit\" }, summary: \"A literal: its value in the JSON form of IR.JSON.\" },\n ref: { verbs: { eval: \"formula.ref\" }, parts: { shape: \"deep\" }, summary: \"A reference: the fields of self after its moves, or a name.\" },\n record: { verbs: { eval: \"formula.record\" }, parts: NAMES, summary: \"A record of the values of its fields.\" },\n let: {\n verbs: { eval: \"formula.let\" },\n parts: closed({ bind: { shape: \"map\", item: BIND }, body: TERM }, [\"bind\", \"body\"]),\n scope: [{ names: { keysAt: [\"bind\"] }, in: [[\"body\"]] }],\n summary: \"Names for the body. A binding does not see the other bindings.\",\n },\n fn: {\n verbs: { eval: \"vex.fn\" },\n parts: closed({ params: { shape: \"list\", item: { shape: \"text\" }, distinct: true }, body: TERM }, [\"params\", \"body\"]),\n scope: [{ names: { listAt: [\"params\"] }, in: [[\"body\"]] }],\n summary: \"A function of a let. Its body evaluates at the position of each call.\",\n },\n call: { verbs: { eval: \"vex.call\" }, parts: closed({ fn: { shape: \"term\", kinds: [[\"ref\"]] }, args: TERMS }, [\"fn\", \"args\"]), summary: \"A call of a function of a let.\" },\n each: {\n verbs: { eval: \"vex.each\" },\n parts: closed({ axis: AXIS, as: ITEM_NAMES, body: TERM, at: ADDRESS }, [\"axis\", \"body\"]),\n // The names of the items are names of the body only. The test of where does not see them (AXIS.LIST.SCOPE).\n scope: [{ names: { listAt: [\"as\"] }, in: [[\"body\"]] }],\n summary: \"The body at each target of an axis: a list.\",\n },\n fold: {\n verbs: { eval: \"vex.fold\" },\n parts: closed({ axis: AXIS, as: ITEM_NAMES, init: NAMES, step: NAMES, result: TERM, at: ADDRESS }, [\"axis\", \"init\", \"step\", \"result\"]),\n scope: [...LOOP_SCOPE, { names: { listAt: [\"as\"] }, in: [[\"step\", \"*\"]] }],\n summary: \"A step at each target of an axis, in order, and a result.\",\n },\n iterate: {\n verbs: { eval: \"vex.iterate\" },\n parts: closed({ limit: LIMIT, init: NAMES, step: NAMES, until: TERM, result: TERM }, [\"limit\", \"init\", \"step\", \"result\"]),\n scope: LOOP_SCOPE,\n summary: \"Up to limit steps, until a test is true, and a result.\",\n },\n fix: {\n verbs: { eval: \"vex.fix\" },\n parts: closed({ name: { shape: \"text\" }, join: { shape: \"one\", values: [\"or\", \"and\", \"max\", \"min\"] }, init: TERM, step: TERM }, [\"name\", \"join\", \"init\", \"step\"]),\n summary: \"A column: a step at each row in rounds, until no row changes (step B).\",\n },\n last: {\n verbs: { eval: \"vex.last\" },\n parts: { shape: \"text\" },\n summary: \"The value of the focus in the last round of a fix (step B).\",\n },\n limit: {\n verbs: { eval: \"vex.limit\" },\n parts: { shape: \"number\", whole: true, min: 0, max: MAX_ITERATIONS },\n summary: \"The limit of iterate as a whole number: the bare number of step A.\",\n },\n size: {\n verbs: { eval: \"vex.size\" },\n parts: closed({ axis: AXIS }, [\"axis\"]),\n summary: \"The limit of iterate from the data: the number of targets of an axis (step B).\",\n },\n ops: { kinds: {}, fallback: { verbs: { eval: \"formula.op\" }, parts: TERMS, summary: \"An op, applied to the values of its arguments.\" } },\n ext: { kinds: {}, fallback: { verbs: { eval: \"formula.ext\" }, summary: \"An extension: its handler gives the value of its data.\" } },\n axes: {\n kinds: {\n ...Object.fromEntries(PLAIN_AXES.map((name) => [name, axisKind({})])),\n neighbors: axisKind({ n: { shape: \"one\", values: [4, 8] } }),\n window: axisKind({ from: { shape: \"number\" }, to: { shape: \"number\" } }),\n table: axisKind({ name: { shape: \"text\" } }),\n list: axisKind({ list: TERM }),\n reverse: axisKind({ axis: { shape: \"term\", kinds: BASE_AXES.map((name) => [\"axes\", name]) } }),\n where: axisKind({ axis: AXIS, test: TERM }),\n },\n },\n moves: {\n kinds: {\n key: move(\"vex.move.key\", TERM),\n index: move(\"vex.move.index\", TERM),\n offset: move(\"vex.move.offset\", { shape: \"list\", item: { shape: \"number\" } }),\n other: move(\"vex.move.other\", NO_VALUE),\n origin: move(\"vex.move.origin\", NO_VALUE),\n parent: move(\"vex.move.parent\", NO_VALUE),\n },\n },\n },\n defaults: {},\n };\n}\n\n/**\n * The world of Vex: the contract of each kind of a document of Vex, as data. A contract gives the shape of the parts,\n * the data of the fields and the names that the kind binds. The static kit of the kernel reads it.\n */\nexport const VEX_WORLD: World = /* @__PURE__ */ worldOfVex();\n\n/** The deepest nesting of documents that the machine takes. A deeper document gives `#DEPTH!` (DOC.ERROR). */\nexport const MAX_DOCUMENT_DEPTH = 4096;\n\n// ---------------------------------------------------------------- errors\n\n/** The kind of a Vex error for each code of the kernel. Another code is a document that is not valid. */\nconst KIND_OF: Readonly<Partial<Record<string, ErrorKind>>> = {\n \"#REF!\": \"unknown-key\",\n \"#N/A\": \"missing-field\",\n \"#VALUE!\": \"kind-mismatch\",\n \"#NAME?\": \"unbound\",\n \"#NUM!\": \"not-finite\",\n \"#CALC!\": \"threw\",\n \"#ARGS\": \"args\",\n \"#CYCLE!\": \"cycle\",\n \"#DEPTH!\": \"depth\",\n};\n\n/** This function gives the error of the kernel for a Vex error. The Vex error is its cause, so no detail is lost. */\nexport const toKernelError = (e: VexError): EvalError => ({ code: e.code, reason: e.message, cause: e });\n\n/** This function gives the Vex error of an error of the kernel. A code that Vex does not have gives `#VALUE!`. */\nexport function toVexError(e: EvalError): VexError {\n if (isVexError(e.cause)) return e.cause;\n return vexError(KIND_OF[e.code] ?? \"bad-expression\", e.reason, e.cause === undefined ? {} : { thrown: e.cause });\n}\n\n/** This function gives the Vex result of a result of the kernel. */\nexport const toVexResult = (r: Outcome): Result<unknown> => (r.ok ? vexOk(r.value) : vexFail(toVexError(r.error)));\n\n/** This function makes an error of the kernel from a kind of Vex error. */\nconst kernelError = (kind: ErrorKind, message: string, details: ErrorDetails = {}): EvalError => toKernelError(vexError(kind, message, details));\n\n/** This function makes a failed result of the kernel. */\nconst failed = (kind: ErrorKind, message: string): Failed => ({ ok: false, error: kernelError(kind, message) });\n\n/** This function gives the error of a position of an array without a value (LIST.ARRAY). */\nconst missing = (message: string): VexError => vexError(\"missing-field\", message);\n\n/** This function stops host code with an error of the kernel. The kernel catches the `Failure` and gives its error. */\nconst stop = (kind: ErrorKind, message: string): never => {\n throw new Failure(kernelError(kind, message));\n};\n\n/** This function tells if an error is `#DEPTH!`. Some rules do not hide it (EVAL.DEPTH). */\nconst isDepth = (e: EvalError): boolean => e.code === (\"#DEPTH!\" satisfies ErrorCode);\n\n// ---------------------------------------------------------------- the position\n\n/** The segments that are not fields (REF.FORBIDDEN). */\nconst FORBIDDEN: ReadonlySet<string> = /* @__PURE__ */ new Set([\"__proto__\", \"constructor\", \"prototype\"]);\n\n/**\n * A position of an evaluation, as a host thing of the kernel: the space, the tables, the origin and the focus. It is the\n * root `self` of the context. A move gives a new position, and a field step reads the record at the focus. A move that\n * fails gives a position with the failure. The failure is the result when a reader uses the position, so the checks of\n * the computed keys come first (NAV.COMPUTED).\n */\nclass Place implements HostThing {\n // The constructor sets the brand. A computed field of the class makes a bundler keep the class in each program.\n declare readonly [THING]: true;\n readonly space: Space;\n readonly tables: Readonly<Record<string, Space>>;\n readonly origin: string;\n readonly focus: string;\n readonly failure: EvalError | undefined;\n /** The columns of the `fix` nodes around this position, by name (FIX.LAST). A column is no name of the program. */\n readonly columns: ReadonlyMap<string, ReadonlyMap<string, unknown>> | undefined;\n\n constructor(space: Space, tables: Readonly<Record<string, Space>>, origin: string, focus: string, failure?: EvalError, columns?: ReadonlyMap<string, ReadonlyMap<string, unknown>>) {\n (this as { [THING]: true })[THING] = true;\n this.space = space;\n this.tables = tables;\n this.origin = origin;\n this.focus = focus;\n this.failure = failure;\n this.columns = columns;\n }\n\n /** The text of the position for a trace. */\n get label(): string {\n return `key ${this.focus}`;\n }\n\n /** This method gives the position of a key of the same space, with the same origin. */\n to(focus: string): Place {\n return new Place(this.space, this.tables, this.origin, focus, undefined, this.columns);\n }\n\n /** This method gives this position with a new column of a `fix`. */\n withColumn(name: string, column: ReadonlyMap<string, unknown>): Place {\n return new Place(this.space, this.tables, this.origin, this.focus, undefined, new Map(this.columns).set(name, column));\n }\n\n /** This method gives the position with a failure, for a move that failed. */\n failed(failure: EvalError): Place {\n return new Place(this.space, this.tables, this.origin, this.focus, failure, this.columns);\n }\n\n /** This method reads one field of the record at the focus. */\n deref(key: Key): unknown {\n return this.resolve([key])?.thing;\n }\n\n /**\n * This method reads the fields of a path in the record at the focus (REF.PATH). A missing field, `null` and a segment\n * that is not a field reach nothing, and the kernel gives `#N/A` (REF.MISSING, REF.FORBIDDEN). A getter that throws\n * gives `#CALC!`, because the kernel catches the exception.\n */\n resolve(keys: readonly Key[]): { readonly thing: unknown } | undefined {\n if (this.failure !== undefined) throw new Failure(this.failure);\n let value: unknown = this.space.get(this.focus);\n if (value === undefined || value === null) return undefined;\n for (const key of keys) {\n const seg = String(key);\n if ((typeof value !== \"object\" && typeof value !== \"function\") || seg === \"\" || FORBIDDEN.has(seg)) return undefined;\n value = Reflect.get(value, seg);\n if (value === undefined || value === null) return undefined;\n }\n return { thing: value };\n }\n\n /** This method gives the record at the focus: the value of a reference without fields. */\n toJson(): unknown {\n if (this.failure !== undefined) throw new Failure(this.failure);\n const record = this.space.get(this.focus);\n return record === undefined || record === null ? stop(\"missing-field\", `the record at \"${this.focus}\" has no value`) : record;\n }\n}\n\n/**\n * This function gives the root `self` of an evaluation in the kernel. It is the position at the origin of a space,\n * with the tables of the axis table (AXIS.TABLE).\n */\nexport function vexSelf(space: Space, origin: string, tables: Readonly<Record<string, Space>> = {}): HostThing {\n return new Place(space, tables, origin, origin);\n}\n\n/**\n * This function gives the walker of a kind of move. `fix` gives the fixed move of the value of the step, or the reason\n * why the value is not valid, which gives `#VALUE!` (NAV.COMPUTED).\n */\nfunction moveWalker(fix: (data: unknown) => FixedMove | string): Walker {\n return ({ data, here }) => {\n if (!(here instanceof Place)) return { ok: false, reason: \"a move starts at a key of a space\", code: \"#REF!\" };\n const fixed = fix(data);\n if (typeof fixed === \"string\") return { ok: false, reason: fixed, code: \"#VALUE!\" };\n // A move after a failed move keeps the first failure, as the address of the closure compiler does (NAV.SEQUENCE).\n if (here.failure !== undefined) return { ok: true, thing: here };\n const r = applyMove(here.space, here, fixed);\n return { ok: true, thing: r.ok ? here.to(r.value) : here.failed(toKernelError(r.error)) };\n };\n}\n\n/** The walkers of the moves of Vex. */\nconst WALKERS: Readonly<Record<string, Walker>> = {\n \"vex.move.key\": /* @__PURE__ */ moveWalker((d) => (typeof d === \"string\" ? { t: \"key\", key: d } : `the key of a move is a ${typeof d}, not a text`)),\n \"vex.move.index\": /* @__PURE__ */ moveWalker((d) => (typeof d === \"number\" ? { t: \"index\", i: d } : `the position of a move is a ${typeof d}, not a number`)),\n \"vex.move.offset\": /* @__PURE__ */ moveWalker((d) => ({ t: \"offset\", d: d as readonly number[] })),\n \"vex.move.other\": /* @__PURE__ */ moveWalker(() => ({ t: \"other\" })),\n \"vex.move.origin\": /* @__PURE__ */ moveWalker(() => ({ t: \"origin\" })),\n \"vex.move.parent\": /* @__PURE__ */ moveWalker(() => ({ t: \"parent\" })),\n};\n\n// ---------------------------------------------------------------- the axes and the loops\n\n/*\n * The evaluators of Vex are functions of their input, not compilers. Thus a plan of the kernel and the reference\n * interpreter of the kernel use the same code for them, and the reference needs a definition only for the formula kit\n * (`vexDefinitions`).\n */\n\n/**\n * A target of an axis: its key, or its key and an error (AXIS.WHERE, AXIS.LIST). A target of the axis `list` also has\n * the value of its item and its position as `nth` counts it (AXIS.LIST.ITEM, AXIS.LIST.INDEX).\n */\ninterface Target {\n readonly key: string;\n readonly error?: VexError;\n readonly value?: unknown;\n readonly index?: number;\n}\n\n/** The value of an axis document: the targets from a position. `table` names the table of the axis table. */\ninterface Targets {\n readonly table: string | undefined;\n targets(from: Place): Outcome<readonly Target[]>;\n}\n\n/** This function gives the position of a target. In the space of the axis table, the origin is the target (AXIS.TABLE). */\nconst placeOf = (axis: Targets, from: Place, key: string): Place => (axis.table === undefined ? from.to(key) : new Place(from.space, from.tables, key, key));\n\n/** This function gives the parts of a record value, by name. */\nconst partsOf = (value: unknown): Readonly<Record<string, Part | undefined>> => (value ?? {}) as Readonly<Record<string, Part | undefined>>;\n\n/** This function gives the part of a field that the contract makes necessary. */\nconst partAt = (value: unknown, name: string): Part => partsOf(value)[name] as Part;\n\n/** This function gives the position of a context. A context without a position gives an error. */\nfunction selfOf(ctx: Context): Place | EvalError {\n return ctx.self instanceof Place ? ctx.self : kernelError(\"unknown-key\", \"the context has no key of a space\");\n}\n\n/** This function gives the position where an axis finds its targets: the key of the address, or the focus (AXIS.ADDRESS). */\nfunction startOf(at: Part | undefined, ctx: Context): Place | EvalError {\n if (at === undefined) return selfOf(ctx);\n const r = at.evaluate();\n if (!r.ok) return r.error;\n const where = r.value as Place;\n return where.failure ?? where;\n}\n\n/** This function gives the position in the space of the axis: the space of its table for the axis table (AXIS.TABLE). */\nfunction spaceOf(axis: Targets, from: Place): Place | EvalError {\n if (axis.table === undefined) return from;\n const space = Object.hasOwn(from.tables, axis.table) ? from.tables[axis.table] : undefined;\n return space === undefined ? kernelError(\"no-table\", `the evaluation has no table \"${axis.table}\"`) : new Place(space, from.tables, from.origin, from.focus);\n}\n\n/**\n * This function is the evaluator of the axes. An axis document gives a value that finds the targets from a position.\n * The list of `list` evaluates at that position, and the test of `where` at each target (AXIS.LIST, AXIS.WHERE).\n */\nconst axisEvaluator: EvalFn = ({ typePath, value, context }) => {\n const name = String(typePath[1]);\n const fields = partsOf(value);\n if (name === \"table\") {\n const table = (value as { readonly name: string }).name;\n return ok<Targets>({ table, targets: (from) => ok(from.space.keys.map((key) => ({ key }))) });\n }\n if (name === \"list\") {\n const list = fields[\"list\"] as Part;\n return ok<Targets>({\n table: undefined,\n targets: (from) => {\n const r = list.evaluate({ ...context, self: from });\n if (!r.ok) return r;\n // LIST.ARRAY: an array is a list with the positions as keys.\n const items = asList(r.value, missing);\n if (items === undefined) return failed(\"kind-mismatch\", `the axis \"list\" needs a list, not a ${describe(r.value)}`);\n // The index counts the items with a value, as nth does: nth skips the error items (LIST.LENIENT).\n let index = 0;\n return ok(items.items.map(({ key, result }): Target => (result.ok ? { key, value: result.value, index: index++ } : { key, error: result.error })));\n },\n });\n }\n if (name === \"reverse\" || name === \"where\") {\n const r = (fields[\"axis\"] as Part).evaluate();\n // Stryker disable next-line ConditionalExpression: an axis document fails only when the call stack of the engine is full\n if (!r.ok) return r;\n const base = r.value as Targets;\n const test = fields[\"test\"];\n if (test === undefined) {\n return ok<Targets>({\n table: base.table,\n targets: (from) => {\n const ts = base.targets(from);\n return ts.ok ? ok(ts.value.toReversed()) : ts;\n },\n });\n }\n return ok<Targets>({ table: base.table, targets: (from) => whereTargets(base, test, context, from) });\n }\n const ir = { t: name, ...(value as object) } as Exclude<Axis, { readonly t: \"where\" }>;\n return ok<Targets>({\n table: undefined,\n targets: (from) => {\n const keys = axisTargets(from.space, from, ir);\n return keys.ok ? ok(keys.value.map((key) => ({ key }))) : { ok: false, error: toKernelError(keys.error) };\n },\n });\n};\n\n/** This function keeps the targets where the test gives `true`. A failed test, or a value that is not a boolean, gives an error item. */\nfunction whereTargets(base: Targets, test: Part, ctx: Context, from: Place): Outcome<readonly Target[]> {\n const ts = base.targets(from);\n if (!ts.ok) return ts;\n const out: Target[] = [];\n for (const t of ts.value) {\n if (t.error !== undefined) {\n out.push(t);\n continue;\n }\n const r = test.evaluate({ ...ctx, self: placeOf(base, from, t.key) });\n if (!r.ok) out.push({ key: t.key, error: toVexError(r.error) });\n // The target keeps the value and the index of its item (AXIS.LIST.ITEM).\n else if (r.value === true) out.push(t);\n else if (r.value !== false) out.push({ key: t.key, error: vexError(\"kind-mismatch\", `the test of \"where\" gave a ${typeof r.value}, not a boolean`) });\n }\n return ok(out);\n}\n\n/** This function finds the targets of the axis of a loop, from the address or the focus, in the space of the axis. */\nfunction targetsOf(value: unknown, ctx: Context): Outcome<{ readonly axis: Targets; readonly from: Place; readonly targets: readonly Target[] }> {\n const start = startOf(partsOf(value)[\"at\"], ctx);\n if (!(start instanceof Place)) return { ok: false, error: start };\n const a = partAt(value, \"axis\").evaluate();\n // Stryker disable next-line ConditionalExpression: an axis document fails only when the call stack of the engine is full\n if (!a.ok) return a;\n const axis = a.value as Targets;\n const from = spaceOf(axis, start);\n if (!(from instanceof Place)) return { ok: false, error: from };\n const ts = axis.targets(from);\n return ts.ok ? ok({ axis, from, targets: ts.value }) : ts;\n}\n\n/**\n * This function sets a name of a new record of names, also the name `__proto__`. The record is new and gets each\n * name one time, so the property needs no other attributes. A later record copies it with a spread, so it is enumerable.\n */\nfunction setName(names: Record<string, unknown>, name: string, value: unknown): void {\n Object.defineProperty(names, name, { value, enumerable: true });\n}\n\n/**\n * This function evaluates the parts of a record of names in order (LOOP.NAMES). It gives the names with their new\n * values, or the first error. Each value reads the names before the step, so the names change only after all values.\n */\nfunction bindAll(record: Part | undefined, ctx: Context, names: Readonly<Record<string, unknown>>): Outcome<Readonly<Record<string, unknown>>> {\n const values: [string, unknown][] = [];\n for (const [name, part] of Object.entries(partsOf(record))) {\n const r = (part as Part).evaluate(ctx);\n if (!r.ok) return r;\n values.push([name, r.value]);\n }\n const out: Record<string, unknown> = { ...names };\n for (const [name, v] of values) setName(out, name, v);\n return ok(out);\n}\n\n/**\n * This function adds the names `as` of a loop to the names of a body or of a step. The first name holds the value of\n * the item, and the second its index (AXIS.LIST.ITEM, AXIS.LIST.INDEX). A loop without `as` keeps its names.\n */\nfunction withItem(names: Readonly<Record<string, unknown>>, as: readonly string[] | undefined, t: Target): Readonly<Record<string, unknown>> {\n if (as === undefined) return names;\n const out: Record<string, unknown> = { ...names };\n const [item, index] = as;\n setName(out, item as string, t.value);\n if (index !== undefined) setName(out, index, t.index);\n return out;\n}\n\n/** This function gives the names `as` of a loop, or `undefined` (AXIS.LIST.SCOPE). */\nconst itemNamesOf = (value: unknown): readonly string[] | undefined => (value as { readonly as?: readonly string[] }).as;\n\n/**\n * This function evaluates a part at each row of a column. Each row runs, also after an error (FIX.ERROR).\n */\nfunction rowsOf(part: Part, at: Place, context: Context, name: string, join: FixJoin): Outcome<ReadonlyMap<string, unknown>> {\n const out = new Map<string, unknown>();\n const errors: EvalError[] = [];\n for (const key of at.space.keys) {\n const r = part.evaluate({ ...context, self: at.to(key) });\n const wrong = r.ok ? fixValueError(name, join, r.value) : undefined;\n if (!r.ok) errors.push(r.error);\n else if (wrong !== undefined) errors.push(kernelError(wrong.kind, wrong.message));\n else out.set(key, r.value);\n }\n if (errors.length === 0) return ok(out);\n return { ok: false, error: worstRow(errors) ?? kernelError(\"args\", `${String(errors.length)} rows failed`, { causes: errors.map(toVexError) }) };\n}\n\n/** This function gives the value of the row of the focus. The focus of an item of the axis `list` can be no row (FIX.LAST). */\nfunction rowAt(name: string, column: ReadonlyMap<string, unknown> | undefined, at: Place): Outcome {\n const value = column?.get(at.focus);\n if (value !== undefined) return ok(value);\n const { kind, message } = errorText.lastKey(name, at.focus);\n return failed(kind, message);\n}\n\n/** The evaluators of the loops: each, fold, iterate and fix (LOOP.NAMES, FOLD.ORDER, ITERATE.LIMIT, FIX.ROUNDS). */\nconst LOOPS: Readonly<Record<string, EvalFn>> = {\n \"vex.each\": ({ value, context }) => {\n const found = targetsOf(value, context);\n if (!found.ok) return found;\n const { axis, from, targets } = found.value;\n const body = partAt(value, \"body\");\n const as = itemNamesOf(value);\n const items: ListItem[] = targets.map((t) => ({\n key: t.key,\n result: t.error === undefined ? toVexResult(body.evaluate({ ...context, self: placeOf(axis, from, t.key), names: withItem(context.names, as, t) })) : vexFail(t.error),\n }));\n return ok(vexList(items));\n },\n\n \"vex.fold\": ({ value, context }) => {\n const { init, step } = partsOf(value);\n // The first values come at the node, before the address and the targets (FOLD.ORDER).\n const first = bindAll(init, context, context.names);\n if (!first.ok) return first;\n let names = first.value;\n const found = targetsOf(value, context);\n if (!found.ok) return found;\n const { axis, from, targets } = found.value;\n const as = itemNamesOf(value);\n for (const t of targets) {\n if (t.error !== undefined) return { ok: false, error: toKernelError(t.error) };\n // The step sees the names of the item, and the next names do not keep them (AXIS.LIST.SCOPE).\n const next = bindAll(step, { ...context, self: placeOf(axis, from, t.key), names: withItem(names, as, t) }, names);\n if (!next.ok) return next;\n names = next.value;\n }\n return partAt(value, \"result\").evaluate({ ...context, names });\n },\n\n \"vex.limit\": ({ value }) => ok(value),\n\n // ITERATE.LIMIT.ERROR: each failure of the size of an axis is one error. Only an error of the run stays as it is.\n \"vex.size\": ({ value, context }) => {\n const found = targetsOf(value, context);\n if (!found.ok) return { ok: false, error: toKernelError(limitError(toVexError(found.error))) };\n const { targets } = found.value;\n const cause = worstError(targets.flatMap((t) => t.error ?? []));\n if (cause !== undefined) return { ok: false, error: toKernelError(limitError(cause)) };\n return targets.length > MAX_ITERATIONS ? failed(\"limit\", overLimitMessage(targets.length)) : ok(targets.length);\n },\n\n \"vex.iterate\": ({ value, context }) => {\n const { init, limit: bound, step, until } = partsOf(value);\n const first = bindAll(init, context, context.names);\n if (!first.ok) return first;\n let names = first.value;\n // The limit evaluates at the node, after the first values and before the steps (ITERATE.LIMIT.DATA).\n const counted = (bound as Part).evaluate(context);\n if (!counted.ok) return counted;\n const limit = counted.value as number;\n for (let k = 0; ; k++) {\n const here: Context = { ...context, names };\n if (until !== undefined) {\n const t = until.evaluate(here);\n if (!t.ok) return t;\n if (t.value === true) break;\n if (t.value !== false) return failed(\"kind-mismatch\", `the test \"until\" of \"iterate\" gave a ${typeof t.value}, not a boolean`);\n }\n if (k === limit) {\n if (until !== undefined) return failed(\"limit\", `\"iterate\" made its ${String(limit)} steps, and its test \"until\" is not true`);\n break;\n }\n const next = bindAll(step, here, names);\n if (!next.ok) return next;\n names = next.value;\n }\n return partAt(value, \"result\").evaluate({ ...context, names });\n },\n\n \"vex.fix\": ({ value, context }) => {\n const self = selfOf(context);\n if (!(self instanceof Place)) return { ok: false, error: self };\n const { name, join } = value as { readonly name: string; readonly join: FixJoin };\n const first = rowsOf(partAt(value, \"init\"), self, context, name, join);\n if (!first.ok) return first;\n let column = first.value;\n const { keys } = self.space;\n const limit = fixRounds(keys.length);\n for (let round = 1; round <= limit; round++) {\n const stepped = rowsOf(partAt(value, \"step\"), self.withColumn(name, column), context, name, join);\n if (!stepped.ok) return stepped;\n const next = new Map<string, unknown>();\n let changed = false;\n for (const key of keys) {\n const joined = joinValues(join, column.get(key), stepped.value.get(key));\n changed ||= joined !== column.get(key);\n next.set(key, joined);\n }\n if (!changed) return rowAt(name, column, self);\n column = next;\n }\n const { kind, message } = errorText.fixLimit(name, limit);\n return failed(kind, message);\n },\n\n \"vex.last\": ({ value, context }) => {\n const self = selfOf(context);\n if (!(self instanceof Place)) return { ok: false, error: self };\n const name = value as string;\n return rowAt(name, self.columns?.get(name), self);\n },\n};\n\n// ---------------------------------------------------------------- functions\n\n/**\n * A function of a `let` (FN.BIND). A reference to its name is an error, because a function is not a value (FN.VALUE).\n * It keeps the names of the place of its binding, and its body evaluates at the position of each call (FN.CALL).\n */\nclass Bound extends Held {\n readonly params: readonly string[];\n readonly body: Part;\n readonly names: Readonly<Record<string, unknown>>;\n\n constructor(params: readonly string[], body: Part, names: Readonly<Record<string, unknown>>) {\n super(kernelError(\"kind-mismatch\", \"the name is a function, not a value\"));\n this.params = params;\n this.body = body;\n this.names = names;\n }\n}\n\n/** The evaluators of the functions of Vex (FN.BIND, FN.CALL, FN.ARGS). */\nconst FUNCTIONS: Readonly<Record<string, EvalFn>> = {\n \"vex.fn\": ({ value, context }) => ok(new Bound((value as { readonly params: readonly string[] }).params, partAt(value, \"body\"), context.names)),\n\n \"vex.call\": ({ doc, value, context }) => {\n // The contract and fromDocument make the function a reference to a name: [\"names\", name] (DOC.CALL).\n const name = String((doc.value as { readonly fn: { readonly value: readonly unknown[] } }).fn.value[1]);\n const args = partsOf(value)[\"args\"] as unknown as readonly Part[];\n if (!Object.hasOwn(context.names, name)) return failed(\"unbound\", `the function \"${name}\" has no binding`);\n const bound = context.names[name];\n if (!(bound instanceof Bound)) return bound instanceof Held ? { ok: false, error: bound.error } : failed(\"kind-mismatch\", `the name \"${name}\" is a value, not a function`);\n if (bound.params.length !== args.length) return failed(\"bad-expression\", `the function \"${name}\" takes ${String(bound.params.length)} arguments, not ${String(args.length)}`);\n // Each parameter gets the result of its argument at the call. An error has an effect only where the body reads it.\n const names: Record<string, unknown> = { ...bound.names };\n bound.params.forEach((p, i) => {\n const r = (args[i] as Part).evaluate();\n setName(names, p, r.ok ? r.value : new Held(r.error));\n });\n return bound.body.evaluate({ ...context, names });\n },\n};\n\n// ---------------------------------------------------------------- ops\n\n/** This function gives a short name for the type of a value, for a message. */\nfunction describe(u: unknown): string {\n if (u === null) return \"null\";\n if (Array.isArray(u)) return \"array\";\n if (isVexList(u)) return \"list\";\n return typeof u;\n}\n\n/** This function applies the test of a domain to a value. A test that throws rejects the value. */\nfunction accepts(d: AnyDomain, x: unknown): boolean {\n let accepted = false;\n try {\n accepted = d.is(x);\n } catch {\n // The value stays rejected.\n }\n return accepted;\n}\n\n/** This function finds an own method of a receiver or of its prototypes, but not of `Object` or `Function` (CALL.METHOD). */\nfunction methodOf(self: unknown, name: string): ((...a: unknown[]) => unknown) | undefined {\n // The loop stops at null, so a null receiver gives undefined too.\n if (FORBIDDEN.has(name) || (typeof self !== \"object\" && typeof self !== \"function\")) return undefined;\n for (let o: object | null = self; o !== null && o !== Object.prototype && o !== Function.prototype; o = Object.getPrototypeOf(o) as object | null) {\n const d = Object.getOwnPropertyDescriptor(o, name);\n if (d !== undefined) return typeof d.value === \"function\" ? (d.value as (...a: unknown[]) => unknown) : undefined;\n }\n return undefined;\n}\n\n/** This function checks the value of an op (CALL.RESULT): a value, a finite number, and a valid value of its domain. */\nfunction checked(x: unknown, op: string, domains: readonly AnyDomain[]): unknown {\n if (x === undefined || x === null) return stop(\"undefined-result\", `\"${op}\" gave no value`);\n if (typeof x === \"number\" && !Number.isFinite(x)) return stop(\"not-finite\", `\"${op}\" gave ${String(x)}`);\n const d = domains.find((dom) => accepts(dom, x));\n if (d?.valid !== undefined && !d.valid(x)) return stop(\"invalid-value\", `\"${op}\" gave a value that is not a valid ${d.name}`);\n return x;\n}\n\n/** The op of a domain for a receiver: its spec, and the method of the receiver for an op without `fn`. */\ninterface Found {\n readonly domain: AnyDomain;\n readonly spec: { readonly fn?: (...a: unknown[]) => unknown; readonly liftScalar?: boolean | readonly boolean[]; readonly params?: readonly string[] } | undefined;\n readonly method: ((...a: unknown[]) => unknown) | undefined;\n}\n\n/** This function finds the op of a domain for a receiver, or `undefined` (CALL.UNKNOWN-OP). */\nfunction opOf(d: AnyDomain, self: unknown, op: string): Found | undefined {\n const spec = Object.hasOwn(d.ops, op) && !FORBIDDEN.has(op) ? (d.ops[op] as Found[\"spec\"]) : undefined;\n // An op with a function does not use the method, so the search of the method only adds work there.\n const method = spec !== undefined || d.methods === \"all\" ? methodOf(self, op) : undefined;\n return spec?.fn === undefined && method === undefined ? undefined : { domain: d, spec, method };\n}\n\n/** This function applies the op of a domain: it lifts the numbers, checks the kinds of the arguments and checks the value. */\nfunction callFound(found: Found, op: string, self: unknown, args: readonly unknown[], domains: readonly AnyDomain[]): unknown {\n const { domain, spec } = found;\n const lift = spec?.liftScalar;\n const from = domain.fromScalar;\n const rest = from === undefined ? args : args.map((a, i): unknown => (typeof a === \"number\" && (lift === true || (Array.isArray(lift) && lift[i] === true)) ? from(a) : a));\n const params = spec?.params;\n if (params !== undefined) {\n rest.forEach((a, i) => {\n const k = params[i] ?? \"any\";\n if (k !== \"any\" && !(k === \"domain\" ? accepts(domain, a) : typeof a === k)) {\n stop(k === \"domain\" ? \"not-instance\" : \"kind-mismatch\", `argument ${String(i + 1)} of \"${op}\" is a ${describe(a)}, not a ${k === \"domain\" ? domain.name : k}`);\n }\n });\n }\n const out = spec?.fn !== undefined ? spec.fn(self, ...rest) : (found.method as (...a: unknown[]) => unknown).call(self, ...rest);\n return checked(out, op, domains);\n}\n\n/** The list ops with a second argument before their options: a count, a position, an op name or a list. */\nconst WITH_ARGUMENT: ReadonlySet<string> = /* @__PURE__ */ new Set([\"reduce\", \"take\", \"nth\", \"drop\", \"append\", \"without\", \"get\", \"indexOf\", \"group\", \"join\"]);\n\n/**\n * This function gives the items of a list that have a value (LIST.LENIENT). A list op does not skip `#DEPTH!`, so that\n * error comes first (EVAL.DEPTH). With `strict`, the first error item is the result.\n */\nfunction goodOf(items: readonly ListItem[], strict: boolean): readonly ListItem[] {\n const depth = items.find((it) => !it.result.ok && it.result.error.code === \"#DEPTH!\");\n if (depth !== undefined && !depth.result.ok) throw new Failure(toKernelError(depth.result.error));\n const firstBad = items.find((it) => !it.result.ok);\n if (strict && firstBad !== undefined && !firstBad.result.ok) throw new Failure(toKernelError(firstBad.result.error));\n return items.filter((it) => it.result.ok);\n}\n\n/** This function gives the items of the list `other` of `append` and `without` (LIST.BUILD). Another value gives `#VALUE!`. */\nfunction otherOf(op: string, other: unknown, strict: boolean): readonly ListItem[] {\n const list = asList(other, missing);\n return list !== undefined ? goodOf(list.items, strict) : stop(\"kind-mismatch\", `\"${op}\" needs a list as its second argument, not a ${describe(other)}`);\n}\n\n/** This function joins the lists that are the values of the items, in order (LIST.FLAT). Each list follows LIST.BUILD. */\nfunction flat(vs: readonly unknown[], strict: boolean): unknown {\n const out: ListItem[] = [];\n for (const v of vs) {\n const inner = asList(v, missing);\n if (inner === undefined) return stop(\"kind-mismatch\", `\"flat\" needs a list as the value of each item, but an item is a ${describe(v)}`);\n out.push(...goodOf(inner.items, strict));\n }\n return vexList(out);\n}\n\n/**\n * This function gives the groups of `group(list, keys)` (LIST.GROUP). The item at a position has the key at the same\n * position. A pair with an error item or an error key is not in a group.\n */\nfunction group(items: readonly ListItem[], keys: unknown, strict: boolean): unknown {\n goodOf(items, strict);\n const list = asList(keys, missing);\n if (list === undefined) return stop(\"kind-mismatch\", `\"group\" needs a list of keys, not a ${describe(keys)}`);\n goodOf(list.items, strict);\n if (list.items.length !== items.length) return stop(\"kind-mismatch\", '\"group\" needs one key for each item');\n const groups = new Map<string, ListItem[]>();\n items.forEach((it, i) => {\n const k = (list.items[i] as ListItem).result;\n if (!it.result.ok || !k.ok) return;\n if (typeof k.value !== \"string\") stop(\"kind-mismatch\", '\"group\" needs text keys');\n groups.set(k.value as string, [...(groups.get(k.value as string) ?? []), it]);\n });\n return vexList([...groups].map(([key, g]): ListItem => ({ key, result: vexOk(vexList(g)) })));\n}\n\n/** This function applies a list op (LIST.*). The error items are skipped, except with `{ strict: true }`, and except `#DEPTH!`. */\nfunction listOp(op: string, items: readonly ListItem[], rest: readonly unknown[], domains: readonly AnyDomain[]): unknown {\n const o = op === \"setNth\" ? rest[2] : WITH_ARGUMENT.has(op) ? rest[1] : rest[0];\n const strict = (o as { strict?: unknown } | null | undefined)?.strict === true;\n if (op === \"group\") return group(items, rest[0], strict);\n const good = goodOf(items, strict);\n const vs = good.map((it) => (it.result.ok ? it.result.value : undefined));\n const nums = (): readonly number[] => (vs.every((x) => typeof x === \"number\") ? vs : stop(\"kind-mismatch\", `\"${op}\" needs numbers`));\n const bools = (): readonly boolean[] => (vs.every((x) => typeof x === \"boolean\") ? vs : stop(\"kind-mismatch\", `\"${op}\" needs booleans`));\n const empty = (): never => stop(\"empty\", `\"${op}\" has no values to work with`);\n switch (op) {\n case \"count\":\n return vs.length;\n case \"values\":\n return Object.freeze([...vs]);\n case \"keys\":\n return Object.freeze(good.map((it) => it.key));\n case \"errors\":\n return Object.freeze(items.flatMap((it) => (it.result.ok ? [] : [it.result.error])));\n case \"first\":\n return vs.length > 0 ? vs[0] : empty();\n case \"sortBy\": {\n const ks = sortValues(o, vs, domains);\n const kind = typeof ks[0];\n if (ks.some((x) => typeof x !== kind || (kind !== \"number\" && kind !== \"string\") || Number.isNaN(x))) stop(\"kind-mismatch\", '\"sortBy\" needs numbers without NaN or texts, all of one kind');\n return vexList(good.map((it, i) => ({ it, i })).toSorted((a, b) => compare(ks[a.i], ks[b.i])).map(({ it }) => it));\n }\n case \"take\":\n case \"drop\":\n case \"nth\": {\n const n = rest[0] as number;\n if (!Number.isSafeInteger(n) || n < 0) return stop(\"kind-mismatch\", `\"${op}\" needs a whole number from 0`);\n if (op === \"take\") return vexList(good.slice(0, n));\n if (op === \"drop\") return vexList(good.slice(n));\n return n < vs.length ? vs[n] : stop(\"empty\", `\"nth\" has no item at the position ${String(n)}`);\n }\n case \"setNth\": {\n const n = rest[0] as number;\n if (!Number.isSafeInteger(n) || n < 0) return stop(\"kind-mismatch\", '\"setNth\" needs a whole number from 0');\n const old = good[n];\n if (old === undefined) return stop(\"empty\", `\"setNth\" has no item at the position ${String(n)}`);\n if (rest[1] === undefined) return stop(\"bad-expression\", '\"setNth\" needs argument 3');\n const next = [...good];\n next[n] = { key: old.key, result: vexOk(rest[1]) };\n return vexList(next);\n }\n case \"append\":\n return vexList([...good, ...otherOf(op, rest[0], strict)]);\n case \"without\": {\n const gone = new Set(otherOf(op, rest[0], strict).map((it) => it.key));\n return vexList(good.filter((it) => !gone.has(it.key)));\n }\n case \"flat\":\n return flat(vs, strict);\n case \"get\": {\n // The first item of the key gives its value. An error item is not an item of its key (LIST.GET).\n const key = rest[0];\n if (typeof key !== \"string\") return stop(\"kind-mismatch\", `\"get\" needs a text key, not a ${describe(key)}`);\n const i = good.findIndex((it) => it.key === key);\n return i >= 0 ? vs[i] : stop(\"missing-field\", `the list has no item with the key ${JSON.stringify(key)}`);\n }\n case \"distinct\": {\n // The first item of each value, by ===, as for indexOf. Thus each NaN stays (LIST.DISTINCT).\n if (!vs.every(isIndexValue)) return stop(\"kind-mismatch\", '\"distinct\" needs numbers, texts or booleans');\n const keep = vs.map((x, i) => vs.indexOf(x) === i || Number.isNaN(x));\n return vexList(good.filter((_it, i) => keep[i]));\n }\n case \"join\": {\n // The texts of the items with the text sep between them (LIST.JOIN).\n const sep = rest[0];\n if (typeof sep !== \"string\") return stop(\"kind-mismatch\", `\"join\" needs a text separator, not a ${describe(sep)}`);\n return vs.every((x) => typeof x === \"string\") ? vs.join(sep) : stop(\"kind-mismatch\", '\"join\" needs texts');\n }\n case \"indexOf\": {\n // The position of the first value, among the items with a value (LIST.INDEXOF).\n const x = rest[0];\n if (!isIndexValue(x)) return stop(\"kind-mismatch\", `\"indexOf\" needs a number, a text or a boolean, not a ${describe(x)}`);\n const i = vs.indexOf(x);\n return i >= 0 ? i : stop(\"missing-field\", `the list has no item with the value ${JSON.stringify(x)}`);\n }\n case \"sum\":\n // Stryker disable next-line ArrayDeclaration: a sum needs no domain, and a text in the list accepts no value\n return checked(nums().reduce((s, x) => s + x, 0), op, []);\n case \"mean\": {\n const n = nums();\n // Stryker disable next-line ArrayDeclaration: a mean needs no domain, and a text in the list accepts no value\n return n.length === 0 ? empty() : checked(n.reduce((s, x) => s + x, 0) / n.length, op, []);\n }\n case \"min\":\n case \"max\": {\n const n = nums();\n return n.length === 0 ? empty() : n.reduce((best, x) => (op === \"min\" ? Math.min(best, x) : Math.max(best, x)));\n }\n case \"any\":\n return bools().some(Boolean);\n case \"all\":\n return bools().every(Boolean);\n case \"none\":\n return !bools().some(Boolean);\n default:\n return reduce(rest[0], vs, o, domains);\n }\n}\n\n/**\n * This function gives the sort values of `sortBy` (LIST.SORT.BY). Without the option `by`, they are the values. With\n * it, the op of that name applies to each value, in order, and the first error stops the sort.\n */\nfunction sortValues(o: unknown, vs: readonly unknown[], domains: readonly AnyDomain[]): readonly unknown[] {\n const by = (o as { readonly by?: unknown } | null | undefined)?.by;\n if (by === undefined) return vs;\n if (typeof by !== \"string\") return stop(\"kind-mismatch\", '\"sortBy\" needs an op name in the option \"by\"');\n return vs.map((x) => {\n const found = domains.filter((d) => accepts(d, x)).map((d) => opOf(d, x, by)).find((f) => f !== undefined);\n return found === undefined ? stop(\"unknown-op\", `no domain gives \"${by}\" for a ${describe(x)}`) : callFound(found, by, x, [], domains);\n });\n}\n\n/** This function compares two numbers or two texts for `sortBy`. Equal values keep their order (LIST.SORT). */\nconst compare = (a: unknown, b: unknown): number => ((a as number) < (b as number) ? -1 : (a as number) > (b as number) ? 1 : 0);\n\n/** This function folds the values of a list with a domain op, from the left (LIST.REDUCE, LIST.REDUCE.EMPTY). */\nfunction reduce(name: unknown, vs: readonly unknown[], o: unknown, domains: readonly AnyDomain[]): unknown {\n if (typeof name !== \"string\") return stop(\"kind-mismatch\", '\"reduce\" needs an op name');\n if (vs.length === 0) {\n const named = (o as { domain?: unknown } | null | undefined)?.domain;\n if (named !== undefined && !domains.some((d) => d.name === named)) return stop(\"unknown-op\", `\"reduce\" names the domain ${JSON.stringify(named) ?? \"?\"}, but the program has no such domain`);\n const ds = domains.filter((d) => Object.hasOwn(d.ops, name) && (d.ops[name] as { identity?: unknown }).identity !== undefined && (named === undefined || d.name === named));\n const only = ds.length === 1 ? (ds[0]?.ops[name] as { identity: () => unknown }) : undefined;\n return only === undefined ? stop(\"empty\", `\"reduce\" with \"${name}\" has no values, and no one identity`) : only.identity();\n }\n let acc: unknown = vs[0];\n for (const x of vs.slice(1)) {\n const found = domains.filter((d) => accepts(d, acc)).map((d) => opOf(d, acc, name)).find((f) => f !== undefined);\n if (found === undefined) return stop(\"unknown-op\", `no domain gives \"${name}\" for a ${describe(acc)}`);\n acc = callFound(found, name, acc, [x], domains);\n }\n return acc;\n}\n\n/**\n * This function gives the op of a name: the dispatch of Vex at run time. A list op applies to a list. Else the first\n * domain that accepts the receiver and has the op applies it. Else a free function applies (CALL.FREE).\n */\nfunction dispatch(op: string, domains: readonly AnyDomain[], fns: Readonly<Record<string, (...a: readonly unknown[]) => unknown>>): (...values: unknown[]) => unknown {\n const free = Object.hasOwn(fns, op) ? fns[op] : undefined;\n const listed = LIST_OPS.has(op);\n return (...values) => {\n const self = values[0];\n if (listed && isVexList(self)) return listOp(op, self.items, values.slice(1), domains);\n let accepted = false;\n if (values.length > 0) {\n for (const d of domains) {\n if (!accepts(d, self)) continue;\n accepted = true;\n const found = opOf(d, self, op);\n if (found !== undefined) return callFound(found, op, self, values.slice(1), domains);\n }\n }\n if (free !== undefined) return checked(free(...values), op, domains);\n // LIST.ARRAY and LIST.FILL come after the domains and the functions of the host, so each of their results stays.\n if (listed && Array.isArray(self)) return listOp(op, listOfArray(self, missing).items, values.slice(1), domains);\n if (op === \"fill\") return fill(values);\n if (accepted || values.length === 0) return stop(\"unknown-op\", accepted ? `the domain of the receiver has no op \"${op}\"` : `there is no function \"${op}\"`);\n return stop(\"not-instance\", `no domain accepts the receiver of \"${op}\" (${describe(self)})`);\n };\n}\n\n/** This function gives the list of `fill(n, value)` (LIST.FILL). A count that is not a whole number from 0 to 100000 gives `#VALUE!`. */\nfunction fill([n, value]: readonly unknown[]): unknown {\n if (!isFillCount(n)) return stop(\"kind-mismatch\", `\"fill\" needs a whole number from 0 to 100000, not ${describe(n)}`);\n return value === undefined ? stop(\"bad-expression\", '\"fill\" needs argument 2') : fillList(n, value);\n}\n\n/** This function gives an argument of a special form. A missing argument gives `#VALUE!`. */\nconst argOf = (args: readonly (() => Outcome)[], i: number, op: string): Outcome => args[i]?.() ?? failed(\"bad-expression\", `\"${op}\" needs argument ${String(i + 1)}`);\n\n/** This function gives an argument of a special form that must be a boolean (FORM.IF, FORM.AND-OR). */\nfunction boolOf(args: readonly (() => Outcome)[], i: number, op: string): Outcome {\n const r = argOf(args, i, op);\n return !r.ok || typeof r.value === \"boolean\" ? r : failed(\"kind-mismatch\", `argument ${String(i + 1)} of \"${op}\" is a ${describe(r.value)}, not a boolean`);\n}\n\n/** This function gives `and` or `or`: they stop at the first argument that decides (FORM.AND-OR). */\nconst logic = (op: \"and\" | \"or\"): LazyOp => (args) => {\n if (args.length === 0) return failed(\"bad-expression\", `\"${op}\" needs at least 1 argument`);\n for (let i = 0; i < args.length; i++) {\n const b = boolOf(args, i, op);\n if (!b.ok || b.value === (op === \"or\")) return b;\n }\n return ok(op === \"and\");\n};\n\n/** The special forms of Vex: lazy ops of the formula kit (FORM.IF, FORM.AND-OR, FORM.IFERROR). */\nconst FORMS: Readonly<Record<string, LazyOp>> = {\n if: (args) => {\n const c = boolOf(args, 0, \"if\");\n return c.ok ? argOf(args, c.value === true ? 1 : 2, \"if\") : c;\n },\n and: /* @__PURE__ */ logic(\"and\"),\n or: /* @__PURE__ */ logic(\"or\"),\n // EVAL.DEPTH: ifError does not hide #DEPTH!, because the engine failed, not the data.\n ifError: (args) => {\n // Stryker disable next-line StringLiteral: ifError replaces the error of a missing first argument, so no one sees this name\n const first = argOf(args, 0, \"ifError\");\n return first.ok || isDepth(first.error) ? first : argOf(args, 1, \"ifError\");\n },\n};\n\n/**\n * This function gives the profile of Vex for the formula kit: the dispatch of the ops, the special forms and the\n * extensions. Two or more failed arguments or fields give `#ARGS` (CALL.ARGS, REC.FIELDS).\n */\nfunction profileOf(opts: CompileOptions): FormulaProfile {\n // Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain matches no value\n const domains = opts.domains ?? [];\n const fns = opts.fns ?? {};\n const extensions = opts.extensions ?? {};\n // Vex has no standard extension: each extension kind needs its handler, so the standard names give #NAME? too.\n // A record without a prototype, so an extension kind such as `__proto__` is an own entry too.\n const ext = Object.create(null) as Record<string, ExtFn>;\n for (const name of Object.keys(STD_EXT)) ext[name] = () => failed(\"unknown-op\", `no handler for the extension kind \"${name}\"`);\n for (const [name, handler] of Object.entries(extensions)) {\n ext[name] = (data, ctx) => {\n const self = selfOf(ctx);\n if (!(self instanceof Place)) return { ok: false, error: self };\n // The kernel does not know the path of a node in the tagged IR, so the path is empty.\n const r = handler(data, { space: self.space, position: { origin: self.origin, focus: self.focus }, path: [] });\n if (r.ok) return r;\n // An error without an origin gets the position of the extension (EVAL.LOCATION).\n return { ok: false, error: toKernelError(r.error.origin === undefined ? { ...r.error, origin: self.origin, focus: self.focus } : r.error) };\n };\n }\n return {\n ops: (name) => dispatch(name, domains, fns),\n lazy: FORMS,\n ext,\n // A #DEPTH! argument is the result: #ARGS does not wrap it (EVAL.DEPTH).\n combine: (errors) => errors.find(isDepth) ?? kernelError(\"args\", `${String(errors.length)} arguments failed`, { causes: errors.map(toVexError) }),\n };\n}\n\n/** The evaluators of the literals: the JSON form of IR.JSON, and a value of the host (DOC.LITERAL). */\nfunction literals(domains: readonly AnyDomain[]): Readonly<Record<string, EvalFn>> {\n return {\n // The kernel catches a decoder that throws, and gives #CALC! (CALL.THROW) or #DEPTH! (EVAL.DEPTH).\n \"vex.lit\": ({ doc }) => {\n const decoded = decodeValue(doc.value, domains);\n return decoded.ok ? ok(decoded.value) : { ok: false, error: toKernelError(decoded.error) };\n },\n // A literal of an expression without a JSON form: its document holds the value of the host, with this own entry.\n \"vex.host\": ({ doc }) => ok(doc.value),\n };\n}\n\n/**\n * The rules of the machines of Vex. The values of a space are data, so a field that has the shape of a reference stays\n * a value. A reference starts at `self` or `names`, and a document has a limit of nesting.\n */\nconst RULES = { plain: true, roots: [\"self\", \"names\"], maxDepth: MAX_DOCUMENT_DEPTH } as const;\n\n/**\n * This function makes the machine of the kernel for Vex: the world of Vex, and the formula kit with the profile of\n * Vex. Vex adds its evaluators and its walkers. It is the reference tier of Vex (EVAL.REFERENCE).\n */\nexport function vexMachine(opts: CompileOptions = {}): Machine {\n // Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain matches no value\n return { world: VEX_WORLD, evaluators: { ...formulaEvaluators(profileOf(opts)), ...literals(opts.domains ?? []), ...LOOPS, ...FUNCTIONS, \"vex.axis\": axisEvaluator }, walkers: WALKERS, ...RULES };\n}\n\n/** The code of each evaluator and walker of the machine of the checks. A check uses only their names. */\nconst NO_CODE = (): never => stop(\"bad-expression\", \"the machine of the checks evaluates nothing\");\n\n/**\n * This function makes the machine of the checks (DOC.CHECK). It has the world of Vex, and the names of the evaluators\n * and the walkers of `vexMachine` without their code. The static kit of the kernel needs only the names. Thus a\n * program that only reads documents does not hold the evaluators.\n */\nexport function vexChecker(): Machine {\n const evaluators: Record<string, EvalFn> = {};\n const walkers: Record<string, Walker> = {};\n const todo: unknown[] = Object.values(VEX_WORLD.kinds);\n for (let x = todo.pop(); x !== undefined; x = todo.pop()) {\n const kind = x as { readonly verbs?: Readonly<Record<string, string>>; readonly kinds?: Readonly<Record<string, unknown>>; readonly fallback?: unknown };\n const { eval: name, step } = kind.verbs ?? {};\n if (name !== undefined) evaluators[name] = NO_CODE;\n if (step !== undefined) walkers[step] = NO_CODE;\n todo.push(...Object.values(kind.kinds ?? {}), ...(kind.fallback === undefined ? [] : [kind.fallback]));\n }\n return { world: VEX_WORLD, evaluators, walkers, ...RULES };\n}\n\n/**\n * This function gives the definitions of the machine of Vex for the reference interpreter of the kernel. The formula\n * kit gets its definitions with the profile of Vex. The evaluators of Vex are functions, so they need no definition.\n */\nexport function vexDefinitions(opts: CompileOptions = {}): Definitions {\n return formulaDefinitions(profileOf(opts));\n}\n","/**\n * The writer of the documents of Vex: the coeval document of an expression (DOC.TERM). It uses a stack, not recursion,\n * so an expression of any depth has a document. The package index does not export this module: `toDocument`, `deps`\n * and `kernelPlan` use it.\n */\nimport { isEnvelope, ref as path, typed, type Envelope, type Json, type JsonRecord } from \"@mark1russell7/coeval\";\nimport { encodeValue } from \"./codec.ts\";\nimport type { AnyDomain } from \"./domain.ts\";\nimport type { VexError } from \"./errors.ts\";\nimport { limitAxis, type Axis, type Expr, type Move } from \"./ir.ts\";\n\n/** The options of the writer. */\nexport interface WriteOptions {\n /** The domains that encode the values of the literals. */\n readonly domains: readonly AnyDomain[];\n /**\n * The form of a literal without a JSON form. `\"json\"` stops the writer with its error. `\"host\"` keeps the value of the\n * host in a literal with the own entry `vex.host`, for an evaluation in the kernel.\n */\n readonly literals: \"json\" | \"host\";\n /**\n * The order of the fields of `each` and `fold`. `\"document\"` is the order of DOC.CONSTRUCT. `\"reads\"` puts the body or\n * the steps before the axis, in the order of the reads of `deps`.\n */\n readonly order: \"document\" | \"reads\";\n /** A map that gets the expression of each envelope of a reference, an axis loop and a call. */\n readonly nodes?: Map<object, Expr>;\n}\n\n/** The stop of a write: a literal without a JSON form. The caller gives its error. */\nexport class WriteStop {\n readonly error: VexError;\n\n constructor(error: VexError) {\n this.error = error;\n }\n}\n\n/** A job of the writer: an expression in the position of a term or of an envelope, an axis or a move. */\ntype Job = { readonly t: \"term\" | \"envelope\"; readonly e: Expr } | { readonly t: \"axis\"; readonly a: Axis } | { readonly t: \"move\"; readonly m: Move };\n\n/** The plan of a job: the jobs of its parts, and the function that makes its document from their documents. */\ninterface Plan {\n readonly jobs: readonly Job[];\n readonly make: (docs: readonly Json[]) => Json;\n}\n\nconst NONE: readonly Job[] = [];\n// Stryker disable next-line StringLiteral: the writer tests only the kind \"envelope\", so each other kind is the kind \"term\"\nconst term = (e: Expr): Job => ({ t: \"term\", e });\nconst envelope = (e: Expr): Job => ({ t: \"envelope\", e });\n\n/** This function gives the field `as` of a loop: a new list of its names, or no field (AXIS.LIST.SCOPE). */\nconst itemsOf = (as: readonly string[] | undefined): { readonly as?: Json } => (as === undefined ? {} : { as: [...as] });\n\n/** This function gives a record from names and the documents of their values, from an index of the documents. */\nfunction namesOf(names: readonly string[], docs: readonly Json[], from: number): JsonRecord {\n const out: Record<string, Json> = {};\n names.forEach((name, i) => {\n Object.defineProperty(out, name, { value: docs[from + i], enumerable: true, writable: true, configurable: true });\n });\n return out;\n}\n\n/** The writer of one document. */\nclass Writer {\n readonly #opts: WriteOptions;\n\n constructor(opts: WriteOptions) {\n this.#opts = opts;\n }\n\n /** This method writes the document of a job, with a stack of plans. */\n write(root: Job): Json {\n const stack: { readonly plan: Plan; readonly docs: Json[] }[] = [{ plan: this.#plan(root), docs: [] }];\n for (;;) {\n const top = stack[stack.length - 1] as (typeof stack)[number];\n const next = top.plan.jobs[top.docs.length];\n if (next !== undefined) {\n stack.push({ plan: this.#plan(next), docs: [] });\n continue;\n }\n const doc = top.plan.make(top.docs);\n stack.pop();\n const parent = stack[stack.length - 1];\n if (parent === undefined) return doc;\n parent.docs.push(doc);\n }\n }\n\n /** This method keeps the expression of an envelope, for `deps`. */\n #keep<T extends Json>(doc: T, e: Expr): T {\n this.#opts.nodes?.set(doc as object, e);\n return doc;\n }\n\n /** This method gives the document of a literal: its JSON form, or a value of the host (DOC.LITERAL). */\n #literal(value: unknown, root: boolean): Json {\n const host: Json = { type: \"lit\", value: value as Json, own: { eval: \"vex.host\" } };\n let r: ReturnType<typeof encodeValue>;\n try {\n r = encodeValue(value, this.#opts.domains);\n } catch (thrown) {\n // A getter of the value threw. In the mode \"host\", the literal keeps the value of the host.\n if (this.#opts.literals === \"json\") throw thrown;\n return host;\n }\n if (!r.ok) {\n if (this.#opts.literals === \"json\") throw new WriteStop(r.error);\n return host;\n }\n const json = r.value as Json;\n // In the position of a term, a literal is its JSON value, except a value with the shape of an envelope (DOC.TERM).\n return root || isEnvelope(json) ? typed(\"lit\", json) : json;\n }\n\n #plan(job: Job): Plan {\n if (job.t === \"axis\") return this.#axis(job.a);\n if (job.t === \"move\") return this.#move(job.m);\n const e = job.e;\n if (e.tag === \"lit\") return { jobs: NONE, make: () => this.#literal(e.value, job.t === \"envelope\") };\n return this.#envelope(e);\n }\n\n #envelope(e: Exclude<Expr, { readonly tag: \"lit\" }>): Plan {\n const reads = this.#opts.order === \"reads\";\n switch (e.tag) {\n case \"ref\":\n return { jobs: (e.at ?? []).map((m): Job => ({ t: \"move\", m })), make: (docs) => this.#keep(path(\"self\", ...docs, ...e.path), e) };\n case \"var\":\n return { jobs: NONE, make: () => path(\"names\", e.name) };\n case \"app\":\n return { jobs: e.args.map(term), make: (docs) => typed([\"ops\", ...e.op.split(\".\")], [...docs]) };\n case \"let\": {\n const names = Object.keys(e.bind);\n return { jobs: [...Object.values(e.bind).map(term), term(e.body)], make: (docs) => typed(\"let\", { bind: namesOf(names, docs, 0), body: docs[names.length] as Json }) };\n }\n case \"fn\":\n return { jobs: [term(e.body)], make: (docs) => typed(\"fn\", { params: [...e.params], body: docs[0] as Json }) };\n case \"call\":\n return { jobs: e.args.map(term), make: (docs) => this.#keep(typed(\"call\", { fn: path(\"names\", e.fn), args: [...docs] }), e) };\n case \"rec\": {\n const names = Object.keys(e.fields);\n return { jobs: Object.values(e.fields).map(term), make: (docs) => typed(\"record\", namesOf(names, docs, 0)) };\n }\n case \"each\": {\n const at = this.#at(e.at);\n return {\n jobs: [{ t: \"axis\", a: e.axis }, term(e.body), ...at.jobs],\n make: (docs) => {\n const axis = docs[0] as Json;\n const body = docs[1] as Json;\n const address = at.make(docs.slice(2));\n const as = itemsOf(e.as);\n return this.#keep(typed(\"each\", reads ? { body, axis, ...as, ...address } : { axis, ...as, body, ...address }), e);\n },\n };\n }\n case \"fold\": {\n const init = Object.keys(e.init);\n const step = Object.keys(e.step);\n const at = this.#at(e.at);\n const after = 1 + init.length + step.length;\n return {\n jobs: [{ t: \"axis\", a: e.axis }, ...Object.values(e.init).map(term), ...Object.values(e.step).map(term), term(e.result), ...at.jobs],\n make: (docs) => {\n const axis = docs[0] as Json;\n const names = { init: namesOf(init, docs, 1), step: namesOf(step, docs, 1 + init.length) };\n const result = docs[after] as Json;\n const address = at.make(docs.slice(after + 1));\n const as = itemsOf(e.as);\n return this.#keep(typed(\"fold\", reads ? { ...names, axis, ...as, ...address, result } : { axis, ...as, ...names, result, ...address }), e);\n },\n };\n }\n case \"iterate\": {\n const init = Object.keys(e.init);\n const step = Object.keys(e.step);\n const until = e.until === undefined ? NONE : [term(e.until)];\n const after = init.length + step.length;\n const axis = limitAxis(e);\n return {\n jobs: [...Object.values(e.init).map(term), ...Object.values(e.step).map(term), ...until, term(e.result), ...(axis === undefined ? [] : [{ t: \"axis\" as const, a: axis }])],\n make: (docs) => {\n const first = { init: namesOf(init, docs, 0) };\n const limit = axis === undefined ? (e.limit as number) : this.#keep(typed(\"size\", { axis: docs[after + until.length + 1] as Json }), e);\n return typed(\"iterate\", {\n // The limit evaluates after the first values, so the order \"reads\" gives its reads after them.\n ...(reads ? { ...first, limit } : { limit, ...first }),\n step: namesOf(step, docs, init.length),\n ...(e.until === undefined ? {} : { until: docs[after] as Json }),\n result: docs[after + until.length] as Json,\n });\n },\n };\n }\n case \"fix\":\n return {\n jobs: [term(e.init), term(e.step)],\n make: (docs) => typed(\"fix\", { name: e.name, join: e.join, init: docs[0] as Json, step: docs[1] as Json }),\n };\n case \"last\":\n return { jobs: NONE, make: () => typed(\"last\", e.name) };\n case \"ext\":\n return { jobs: NONE, make: () => typed([\"ext\", ...e.kind.split(\".\")], e.data as Json) };\n }\n }\n\n /** This method gives the plan of the field `at` of `each` and `fold`: a reference from `self` with moves only (DOC.ADDRESS). */\n #at(at: readonly Move[] | undefined): { readonly jobs: readonly Job[]; readonly make: (docs: readonly Json[]) => { readonly at?: Envelope } } {\n // Stryker disable next-line ArrowFunction: a spread of no value adds no fields, as a spread of an empty record does\n if (at === undefined || at.length === 0) return { jobs: NONE, make: () => ({}) };\n return { jobs: at.map((m): Job => ({ t: \"move\", m })), make: (docs) => ({ at: path(\"self\", ...docs) }) };\n }\n\n /** This method gives the plan of a move. A computed key or position is an envelope (DOC.MOVE). */\n #move(m: Move): Plan {\n switch (m.t) {\n case \"key\":\n return typeof m.key === \"string\" ? this.#fixed([\"moves\", \"key\"], m.key) : { jobs: [envelope(m.key)], make: (docs) => typed([\"moves\", \"key\"], docs[0] as Json) };\n case \"index\":\n return typeof m.i === \"number\" ? this.#fixed([\"moves\", \"index\"], m.i) : { jobs: [envelope(m.i)], make: (docs) => typed([\"moves\", \"index\"], docs[0] as Json) };\n case \"offset\":\n return this.#fixed([\"moves\", \"offset\"], [...m.d]);\n case \"other\":\n case \"origin\":\n case \"parent\":\n return this.#fixed([\"moves\", m.t], null);\n }\n }\n\n #fixed(type: readonly string[], value: Json): Plan {\n return { jobs: NONE, make: () => typed(type, value) };\n }\n\n /** This method gives the plan of an axis (DOC.AXIS). */\n #axis(a: Axis): Plan {\n const type = [\"axes\", a.t];\n switch (a.t) {\n case \"neighbors\":\n return this.#fixed(type, { n: a.n });\n case \"window\":\n return this.#fixed(type, { from: a.from, to: a.to });\n case \"table\":\n return this.#fixed(type, { name: a.name });\n case \"list\":\n return { jobs: [term(a.list)], make: (docs) => typed(type, { list: docs[0] as Json }) };\n case \"reverse\":\n return { jobs: [{ t: \"axis\", a: a.axis }], make: (docs) => typed(type, { axis: docs[0] as Json }) };\n case \"where\":\n return { jobs: [{ t: \"axis\", a: a.axis }, term(a.test)], make: (docs) => typed(type, { axis: docs[0] as Json, test: docs[1] as Json }) };\n case \"all\":\n case \"others\":\n case \"other\":\n case \"children\":\n case \"ancestors\":\n case \"descendants\":\n case \"siblings\":\n case \"successors\":\n case \"predecessors\":\n case \"reachable\":\n return this.#fixed(type, {});\n }\n }\n}\n\n/**\n * This function writes the document of a valid expression. The root is always an envelope. It throws a `WriteStop` for\n * a literal without a JSON form in the mode `\"json\"`, and an exception of a getter of a literal value.\n */\nexport function writeDocument(e: Expr, opts: WriteOptions): Envelope {\n return new Writer(opts).write({ t: \"envelope\", e }) as Envelope;\n}\n","/**\n * The documents of Vex. A document is the form of an expression in coeval, the kernel of the family. Each term is an\n * envelope `{ type, value }`, and a reference is a path from a root. The rules are decision D12 of coeval:\n * <https://github.com/mark1russell7/coeval/blob/main/docs/DECISIONS.md>.\n *\n * | Expression | Document |\n * |---|---|\n * | `lit` | the JSON value of the literal. A value with the shape of an envelope is `{ \"type\": \"lit\", \"value\": x }`. |\n * | `ref` | `{ \"type\": \"ref\", \"value\": [\"self\", ...moves, ...fields] }` |\n * | `var` | `{ \"type\": \"ref\", \"value\": [\"names\", name] }` |\n * | `app` | `{ \"type\": [\"ops\", ...keys], \"value\": [...args] }`. The keys are the name of the op, split at its dots. |\n * | `let` | `{ \"type\": \"let\", \"value\": { \"bind\", \"body\" } }` |\n * | `fn` | `{ \"type\": \"fn\", \"value\": { \"params\", \"body\" } }` |\n * | `call` | `{ \"type\": \"call\", \"value\": { \"fn\": { \"type\": \"ref\", \"value\": [\"names\", name] }, \"args\" } }` |\n * | `rec` | `{ \"type\": \"record\", \"value\": { ...fields } }` |\n * | `each` | `{ \"type\": \"each\", \"value\": { \"axis\", \"as\"?, \"body\", \"at\"? } }` |\n * | `fold` | `{ \"type\": \"fold\", \"value\": { \"axis\", \"as\"?, \"init\", \"step\", \"result\", \"at\"? } }` |\n * | `iterate` | `{ \"type\": \"iterate\", \"value\": { \"limit\", \"init\", \"step\", \"until\"?, \"result\" } }`. A data limit is `{ \"type\": \"size\", \"value\": { \"axis\" } }`. |\n * | `fix` | `{ \"type\": \"fix\", \"value\": { \"name\", \"join\", \"init\", \"step\" } }` |\n * | `last` | `{ \"type\": \"last\", \"value\": name }` |\n * | `ext` | `{ \"type\": [\"ext\", ...keys], \"value\": data }` |\n * | a move | `{ \"type\": [\"moves\", kind], \"value\": v }` |\n * | an axis | `{ \"type\": [\"axes\", name], \"value\": { ...parameters } }` |\n *\n * The address `at` of `each` and `fold` is a reference from `self` with moves only. An empty address is no address.\n * The field `as` of `each` and `fold` names the item of a loop over the axis `list`, and then its index (AXIS.LIST.SCOPE).\n *\n * The kernel checks a document by the contracts of `VEX_WORLD` (DOC.CHECK). A contract gives the shape of a kind, the\n * data of its fields and the kinds of each position. Then `fromDocument` reads the expression. It checks only the grammar\n * of Vex: the steps of a reference, the address, the function of a call and the names of a loop. It also checks the\n * names of the items.\n */\nimport { check, isEnvelope, typeName, typePath, type Envelope, type Issue, type Key, type Machine } from \"@mark1russell7/coeval\";\nimport { decodeValue } from \"./codec.ts\";\nimport type { AnyDomain } from \"./domain.ts\";\nimport { isStackOverflow, vexError, type VexError } from \"./errors.ts\";\nimport { app, call, dataLimit, each, ext, fix, fn, fold, index, iterate, key, last, let_, lit, offset, origin, other, parent, rec, ref, shapeError, v, type Addr, type Axis, type DataLimit, type Expr, type FixJoin, type ItemNames, type Move, type Names } from \"./ir.ts\";\nimport { MAX_DOCUMENT_DEPTH, TERM_KINDS, vexChecker } from \"./kernel.ts\";\nimport { fail, ok, type Result } from \"./result.ts\";\nimport { itemNamesError } from \"./item-names.ts\";\nimport { WriteStop, writeDocument, type WriteOptions } from \"./write.ts\";\n\nexport type { Envelope, Json } from \"@mark1russell7/coeval\";\n\n/** The stop of a reading. The functions of this module throw it, and the top of the reading gives its error. */\nclass Stop {\n readonly error: VexError;\n\n constructor(error: VexError) {\n this.error = error;\n }\n}\n\n/** This function gives the location of a child: a JSON Pointer, with the escapes of RFC 6901. */\nconst into = (where: string, step: Key): string => `${where}/${String(step).replaceAll(\"~\", \"~0\").replaceAll(\"/\", \"~1\")}`;\n\n/** This function gives the JSON Pointer of a path of keys. */\nconst pointer = (keys: readonly Key[]): string => keys.reduce<string>(into, \"\");\n\n/** This function gives the message of a document that is not valid at `where`. */\nconst notValid = (where: string, reason: string): string => `the document is not valid at ${where === \"\" ? \"its root\" : `\"${where}\"`}: ${reason}`;\n\n/** This function stops the reading of a document that is not valid at `where`. */\nfunction bad(where: string, reason: string): never {\n throw new Stop(vexError(\"bad-expression\", notValid(where, reason)));\n}\n\n/** This function does a conversion. It gives its value, or the error of the conversion. It does not throw. */\nfunction attempt<T>(work: () => T, threw: string, deep: string): Result<T> {\n try {\n return ok(work());\n } catch (thrown) {\n if (thrown instanceof Stop || thrown instanceof WriteStop) return fail(thrown.error);\n if (isStackOverflow(thrown)) return fail(vexError(\"depth\", deep, { thrown }));\n return fail(vexError(\"threw\", threw, { thrown }));\n }\n}\n\n/**\n * This function tells if a value is a document: an envelope `{ type, value }`. A node of the tagged IR is not an\n * envelope, because it has the key `tag`. Thus `compile` and `evaluate` can take either one (DOC.ENTRY).\n */\nexport function isDocument(u: unknown): u is Envelope {\n return isEnvelope(u);\n}\n\n/**\n * This function gives the document of an expression (DOC.TERM). The root is always an envelope, so `compile` can tell a\n * document from the tagged IR. A literal value has the JSON form of IR.JSON, so a domain value needs `encode` (DOC.LITERAL).\n * An expression that is not valid, or a literal without a JSON form, gives the error `#VALUE!` (DOC.ERROR).\n */\n// Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain encodes no value\nexport function toDocument(e: Expr, domains: readonly AnyDomain[] = []): Result<Envelope> {\n const shape = shapeError(e);\n if (shape !== undefined) return fail(vexError(\"bad-expression\", shape));\n const options: WriteOptions = {\n domains,\n literals: \"json\",\n // Stryker disable next-line StringLiteral: the writer tests only the order \"reads\", and each other order is the order of DOC.CONSTRUCT\n order: \"document\",\n };\n // A getter of a literal value can throw, so the conversion is inside the attempt.\n return attempt(() => writeDocument(e, options), \"the expression has no document\", \"a literal value is too deep for the call stack of the engine\");\n}\n\n// The machine of the checks: the contracts of Vex, and the names of its evaluators and walkers, without their code.\nlet checker: Machine | undefined;\n\n/** This function gives the first problem of a document that the kernel finds by the contracts of Vex (DOC.CHECK). */\nfunction problemOf(doc: unknown): Issue | undefined {\n checker ??= vexChecker();\n // A bare value at the root is a literal. The names of a let, a function, a loop and the caller are free names.\n return check(checker, doc, { declaredType: \"lit\", names: \"any\" })[0];\n}\n\n/**\n * This function reads an expression from a document (DOC.TERM). It is the inverse of `toDocument`. The kernel checks\n * the document first (DOC.CHECK). A document that is not valid gives `#VALUE!` with its location, and a document nested\n * deeper than the kernel takes gives `#DEPTH!` (DOC.ERROR). The expression of a valid document is valid (EVAL.SHAPE).\n */\n// Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain decodes no value\nexport function fromDocument(doc: unknown, domains: readonly AnyDomain[] = []): Result<Expr> {\n const problem = attempt(() => problemOf(doc), \"the check of the document threw an exception\", \"the document is too deep for the call stack of the engine\");\n if (!problem.ok) return problem;\n const issue = problem.value;\n if (issue?.code === \"#DEPTH!\") return fail(vexError(\"depth\", `the document is nested deeper than ${String(MAX_DOCUMENT_DEPTH)} documents`));\n // Stryker disable next-line ArrayDeclaration: the check of coeval gives each issue the keys of its value\n if (issue !== undefined) return fail(vexError(\"bad-expression\", notValid(pointer(issue.at ?? []), issue.reason)));\n return attempt(() => new Reader(domains).term(doc, \"\"), \"a decoder of a domain threw an exception\", \"the document is too deep for the call stack of the engine\");\n}\n\n/** The kinds of the terms, as the first key of their type. */\nconst TERMS: ReadonlySet<string> = /* @__PURE__ */ new Set(/* @__PURE__ */ TERM_KINDS.map((k) => k[0] as string));\n\n/**\n * The reader of documents. The kernel checked the document, so each kind has the shape of its contract. The reader\n * checks the grammar of Vex, and its methods throw a `Stop` at the first part that is not valid.\n */\nclass Reader {\n readonly #domains: readonly AnyDomain[];\n\n constructor(domains: readonly AnyDomain[]) {\n this.#domains = domains;\n }\n\n /** This method reads a term. An envelope is a term, and another value is a literal (DOC.TERM). */\n term(u: unknown, where: string): Expr {\n return isDocument(u) ? this.#envelope(u, where) : lit(this.#value(u, where));\n }\n\n /** This method reads a term in an envelope. */\n #envelope(u: Envelope, where: string): Expr {\n const at = into(where, \"value\");\n const keys = this.#type(u, where);\n const head = String(keys[0]);\n // The contracts permit only the kinds of the terms in the position of a term. The root has no position. The check gave\n // the type a kind of the world, so the first key tells if the type is a term.\n if (!TERMS.has(head)) return bad(where, `the type \"${typeName(u.type)}\" is not a term of Vex`);\n if (head === \"ops\" || head === \"ext\") {\n const name = this.#name(keys.slice(1), into(where, \"type\"));\n return head === \"ops\" ? app(name, ...(u.value as readonly unknown[]).map((x, i) => this.term(x, into(at, i)))) : ext(name, u.value);\n }\n const f = u.value as Readonly<Record<string, unknown>>;\n switch (head) {\n case \"lit\":\n return lit(this.#value(u.value, at));\n case \"ref\":\n return this.#ref(u.value as readonly unknown[], at);\n case \"let\":\n return let_(this.#binds(f[\"bind\"], into(at, \"bind\")), this.term(f[\"body\"], into(at, \"body\")));\n case \"call\": {\n const name = this.#function(f[\"fn\"] as Envelope, into(at, \"fn\"));\n return call(name, ...(f[\"args\"] as readonly unknown[]).map((x, i) => this.term(x, into(into(at, \"args\"), i))));\n }\n case \"record\":\n return rec(this.#names(u.value, at));\n case \"each\": {\n const axis = this.#axis(f[\"axis\"] as Envelope, into(at, \"axis\"));\n const as = this.#items(f, axis, at);\n return each(axis, this.term(f[\"body\"], into(at, \"body\")), this.#address(f[\"at\"], into(at, \"at\")), as);\n }\n case \"fold\": {\n const [init, step] = this.#loop(f, at);\n const axis = this.#axis(f[\"axis\"] as Envelope, into(at, \"axis\"));\n const as = this.#items(f, axis, at);\n return fold(axis, init, step, this.term(f[\"result\"], into(at, \"result\")), this.#address(f[\"at\"], into(at, \"at\")), as);\n }\n case \"fix\":\n // The contract gives the name and one of the joins (DOC.CONSTRUCT).\n return fix(f[\"name\"] as string, f[\"join\"] as FixJoin, this.term(f[\"init\"], into(at, \"init\")), this.term(f[\"step\"], into(at, \"step\")));\n case \"last\":\n return last(u.value as string);\n default: {\n // iterate: the contract gives a whole number from 0 to MAX_ITERATIONS, or an envelope of a limit (ITERATE.LIMIT).\n const [init, step] = this.#loop(f, at);\n const until = f[\"until\"] === undefined ? undefined : this.term(f[\"until\"], into(at, \"until\"));\n return iterate(this.#limit(f[\"limit\"], into(at, \"limit\")), init, step, this.term(f[\"result\"], into(at, \"result\")), until);\n }\n }\n }\n\n /** This method gives the keys of the type of an envelope. A term of Vex has no header (DOC.TERM). */\n #type(u: Envelope, where: string): readonly Key[] {\n if (u.name !== undefined || u.own !== undefined) return bad(where, \"a term of Vex has no name and no own entries\");\n // The check found the kind of the type, so the type has no computed step.\n return typePath(u.type) as readonly Key[];\n }\n\n /** This method gives the name of an op or an extension: its keys, joined with dots (DOC.OPS, DOC.EXT). */\n #name(keys: readonly Key[], where: string): string {\n return keys.every((k) => typeof k === \"string\") ? keys.join(\".\") : bad(where, \"a key of the name is not a text\");\n }\n\n /** This method gives the value of a literal from its JSON form (DOC.LITERAL). */\n #value(u: unknown, where: string): unknown {\n const r = decodeValue(u, this.#domains);\n return r.ok ? r.value : bad(where, r.error.message);\n }\n\n /** This method reads a record of names and the term of each name. */\n #names(u: unknown, where: string): Names {\n return Object.fromEntries(Object.entries(u as Readonly<Record<string, unknown>>).map(([name, x]) => [name, this.term(x, into(where, name))]));\n }\n\n /** This method reads the bindings of a let. A binding can be a function (FN.BIND). */\n #binds(u: unknown, where: string): Names {\n return Object.fromEntries(\n Object.entries(u as Readonly<Record<string, unknown>>).map(([name, x]) => {\n const at = into(where, name);\n if (!isDocument(x) || typeName(x.type) !== \"fn\") return [name, this.term(x, at)];\n this.#type(x, at);\n const f = x.value as { readonly params: readonly string[]; readonly body: unknown };\n return [name, fn(f.params, this.term(f.body, into(into(at, \"value\"), \"body\")))];\n }),\n );\n }\n\n /** This method reads the names of a loop. Each name of `step` is a name of `init` (LOOP.NAMES). */\n #loop(f: Readonly<Record<string, unknown>>, at: string): readonly [Names, Names] {\n const init = this.#names(f[\"init\"], into(at, \"init\"));\n const step = this.#names(f[\"step\"], into(at, \"step\"));\n const extra = Object.keys(step).find((name) => !Object.hasOwn(init, name));\n return extra === undefined ? [init, step] : bad(into(into(at, \"step\"), extra), `the name \"${extra}\" of step is not a name of init`);\n }\n\n /**\n * This method reads the names `as` of a loop (AXIS.LIST.SCOPE). The contract gives a list of distinct texts. The\n * grammar of Vex needs one or two names, the axis `list` and no name of `init`.\n */\n /** This method reads the limit of `iterate`: a bare number, the envelope of a number, or the size of an axis (ITERATE.LIMIT.DATA). */\n #limit(u: unknown, where: string): number | DataLimit {\n if (!isEnvelope(u)) return u as number;\n const value = u.value as number | { readonly axis: Envelope };\n return typeof value === \"number\" ? value : dataLimit(this.#axis(value.axis, into(into(where, \"value\"), \"axis\")));\n }\n\n #items(f: Readonly<Record<string, unknown>>, axis: Axis, at: string): ItemNames | undefined {\n const reason = itemNamesError({ as: f[\"as\"], axis, init: f[\"init\"] });\n return reason === undefined ? (f[\"as\"] as ItemNames | undefined) : bad(into(at, \"as\"), reason);\n }\n\n /** This method reads a reference: the fields of `self` after its moves, or a name of `names` (DOC.REF). */\n #ref(path: readonly unknown[], where: string): Expr {\n const [root, ...steps] = path;\n // The check gives each reference a root that Vex reads: \"self\" or \"names\".\n if (root === \"names\") return steps.length === 1 && typeof steps[0] === \"string\" ? v(steps[0]) : bad(where, \"a reference to a name has one step: the name\");\n const moves: Move[] = [];\n const names: string[] = [];\n steps.forEach((step, i) => {\n const at = into(where, i + 1);\n if (typeof step === \"string\") names.push(step);\n else if (!isDocument(step)) bad(at, \"a step is not a text and not a move\");\n else if (names.length > 0) bad(at, \"a move comes after a field. Vex reads the fields at the end of the path\");\n else moves.push(this.#move(step, at));\n });\n return ref(names, moves);\n }\n\n /** This method reads the function of a call: a reference to a name (DOC.CALL). */\n #function(u: Envelope, where: string): string {\n const steps = u.value as readonly unknown[];\n return steps[0] === \"names\" && steps.length === 2 && typeof steps[1] === \"string\" ? steps[1] : bad(where, 'the function of a call is a reference to a name: { \"type\": \"ref\", \"value\": [\"names\", name] }');\n }\n\n /** This method reads the field `at` of `each` and `fold`: a reference from `self` with moves only (DOC.ADDRESS). */\n #address(u: unknown, where: string): Addr | undefined {\n if (u === undefined) return undefined;\n const e = this.#envelope(u as Envelope, where);\n return e.tag === \"ref\" && e.path.length === 0 ? (e.at ?? []) : bad(where, 'the address is a reference from \"self\" with moves only: { \"type\": \"ref\", \"value\": [\"self\", ...moves] }');\n }\n\n /**\n * This method reads a move (DOC.MOVE). The value of `key` and `index` is a term: a text key and a number position are\n * fixed, and another term is computed. The check gave the other moves their values.\n */\n #move(u: Envelope, where: string): Move {\n const kind = String(this.#type(u, where)[1]);\n const at = into(where, \"value\");\n const value = u.value;\n switch (kind) {\n case \"key\":\n return typeof value === \"string\" ? key(value) : key(this.term(value, at));\n case \"index\":\n return typeof value === \"number\" ? index(value) : index(this.term(value, at));\n case \"offset\":\n return offset(...(value as readonly number[]));\n case \"other\":\n return other;\n case \"origin\":\n return origin;\n default:\n return parent;\n }\n }\n\n /** This method reads an axis (DOC.AXIS). The check gave it the parameters of its kind. */\n #axis(u: Envelope, where: string): Axis {\n const name = String(this.#type(u, where)[1]);\n const at = into(where, \"value\");\n const f = u.value as Readonly<Record<string, unknown>>;\n switch (name) {\n case \"list\":\n return { t: name, list: this.term(f[\"list\"], into(at, \"list\")) };\n case \"reverse\":\n return { t: name, axis: this.#axis(f[\"axis\"] as Envelope, into(at, \"axis\")) };\n case \"where\":\n return { t: name, axis: this.#axis(f[\"axis\"] as Envelope, into(at, \"axis\")), test: this.term(f[\"test\"], into(at, \"test\")) };\n default:\n return { t: name, ...f } as Axis;\n }\n }\n}\n","/**\n * The check of the steps of `fix` (FIX.MONOTONE). The check proves from the kinds of the ops that the step of each `fix`\n * does not fall when the last round rises. The rounds then reach the least fixed point above `init`, and the dual\n * for `and` and `min`. A program without a proof does not run (fail closed).\n *\n * The proof follows the reads of `last` through the program. Each part has a direction: it does not depend on the last\n * round, it follows the last round, or it moves against the last round. An op states the direction of each argument\n * as data (FIX.OPS). A part that the rules do not cover and that reads `last` ends the check with a reason.\n */\nimport type { AnyDomain, Monotone, OpSpec, ReturnKind } from \"./domain.ts\";\nimport { joinKind } from \"./fix.ts\";\nimport { addrExprs, axisExprs, children, type Axis, type Expr, type ExprOf } from \"./ir.ts\";\n\n/** The options of the check: the domains and the functions of the host, as the options of a compilation give them. */\nexport interface MonotoneOptions {\n readonly domains?: readonly AnyDomain[];\n readonly fns?: Readonly<Record<string, unknown>>;\n}\n\n/** The direction of a part: 1 follows the last round, -1 moves against it, and 0 does not read it. */\ntype Direction = -1 | 0 | 1;\n\n/** What the check knows of a part: its direction, and the kind of its value if the check knows it. */\ninterface Flow {\n readonly dir: Direction;\n readonly tag: \"boolean\" | \"number\" | \"list\" | undefined;\n}\n\n/** A rule of an op: the direction of each argument, and the kind of the result. */\ninterface Rule {\n readonly args: readonly Monotone[];\n readonly returns: ReturnKind | undefined;\n}\n\n/** The names of a program and the flow of each. A name that the map does not have does not read the last round. */\ntype Names = ReadonlyMap<string, Flow>;\n\n/** The end of a proof. The methods of `Proof` throw it, and `monotoneError` gives its reason. */\nclass Refusal {\n readonly reason: string;\n\n constructor(reason: string) {\n this.reason = reason;\n }\n}\n\nconst STEADY: Flow = { dir: 0, tag: undefined };\n\n/**\n * The rules of the list ops. The items of a list come from an axis that does not read the last round. Thus the set of\n * the items stays the same in each round. Each of these ops ignores the order of the items. `sum` has no rule. The\n * rounding of a sum of floats depends on the order of the items (FIX.ORDER).\n */\nconst LIST_RULES: Readonly<Record<string, Rule>> = {\n any: { args: [\"up\"], returns: \"boolean\" },\n all: { args: [\"up\"], returns: \"boolean\" },\n none: { args: [\"down\"], returns: \"boolean\" },\n min: { args: [\"up\"], returns: \"number\" },\n max: { args: [\"up\"], returns: \"number\" },\n};\n\n/** This function gives the flow of a literal. The kind of a number or a boolean is known. */\nfunction steadyValue(value: unknown): Flow {\n if (typeof value === \"number\") return { dir: 0, tag: \"number\" };\n return typeof value === \"boolean\" ? { dir: 0, tag: \"boolean\" } : STEADY;\n}\n\n/** This function gives the axis inside the `where` axes of an axis. */\nconst baseOf = (a: Axis): Axis => (a.t === \"where\" ? baseOf(a.axis) : a);\n\n/** This function gives the names without the names that a part of the program hides. */\nfunction without(names: Names, hidden: readonly string[]): Names {\n const out = new Map(names);\n for (const name of hidden) out.delete(name);\n return out;\n}\n\n/** The proof of the step of one `fix`. */\nclass Proof {\n readonly #fix: ExprOf<\"fix\">;\n readonly #domains: readonly AnyDomain[];\n readonly #fns: Readonly<Record<string, unknown>>;\n /** This field is `true` inside a `fix` of the same name: a read there reads that `fix`. */\n #hidden = false;\n\n constructor(fix: ExprOf<\"fix\">, opts: MonotoneOptions) {\n this.#fix = fix;\n this.#domains = opts.domains ?? [];\n this.#fns = opts.fns ?? {};\n }\n\n /** This method proves the step. It throws a refusal, or it returns. */\n prove(): void {\n if (this.#flow(this.#fix.step, new Map()).dir < 0) this.#refuse(\"it moves against the last round\");\n }\n\n #refuse(why: string): never {\n throw new Refusal(`the step of the \"fix\" \"${this.#fix.name}\" does not move one way: ${why}`);\n }\n\n #flow(e: Expr, names: Names): Flow {\n switch (e.tag) {\n case \"lit\":\n return steadyValue(e.value);\n case \"var\":\n return names.get(e.name) ?? STEADY;\n case \"last\":\n return e.name === this.#fix.name && !this.#hidden ? { dir: 1, tag: joinKind(this.#fix.join) } : STEADY;\n case \"let\": {\n const bound = new Map(names);\n for (const [name, x] of Object.entries(e.bind)) bound.set(name, this.#flow(x, names));\n return this.#flow(e.body, bound);\n }\n case \"fn\":\n return this.#flow(e.body, without(names, e.params));\n case \"call\":\n if ((names.get(e.fn)?.dir ?? 0) !== 0) this.#refuse(`the function \"${e.fn}\" reads the last round`);\n return this.#steady(e.args, names, `an argument of the function \"${e.fn}\"`);\n case \"each\":\n return this.#each(e, names);\n case \"app\":\n return this.#app(e, names);\n case \"fix\":\n return this.#inner(e, names);\n // The fields of a record, the moves of a reference and the parts of a fold and of an iterate have no rule.\n case \"rec\":\n case \"ref\":\n case \"fold\":\n case \"iterate\":\n case \"ext\":\n return this.#steady(children(e), names, `a node \"${e.tag}\"`);\n }\n }\n\n /** This method refuses a part that reads the last round. Only an op or a loop with a rule can take such a part. */\n #steady(parts: readonly Expr[], names: Names, what: string): Flow {\n for (const x of parts) if (this.#flow(x, names).dir !== 0) this.#refuse(`${what} reads the last round`);\n return STEADY;\n }\n\n /**\n * This method reads a `fix` inside the step. Its rounds end in each round of the outer `fix`. Thus a column of the\n * outer `fix` as an input of the inner `fix` has no proof.\n */\n #inner(e: ExprOf<\"fix\">, names: Names): Flow {\n this.#steady([e.init], names, `the start of the \"fix\" \"${e.name}\"`);\n const outer = this.#hidden;\n this.#hidden ||= e.name === this.#fix.name;\n this.#steady([e.step], names, `the step of the \"fix\" \"${e.name}\"`);\n this.#hidden = outer;\n return { dir: 0, tag: joinKind(e.join) };\n }\n\n /** This method reads an `each`. The targets must not read the last round, so each round has the same items. */\n #each(e: ExprOf<\"each\">, names: Names): Flow {\n this.#steady([...axisExprs(e.axis), ...addrExprs(e.at)], names, \"an axis\");\n const body = this.#flow(e.body, without(names, e.as ?? []));\n if (body.dir !== 0 && baseOf(e.axis).t === \"table\") this.#refuse(\"the axis table leaves the rows of the column\");\n return { dir: body.dir, tag: \"list\" };\n }\n\n #app(e: ExprOf<\"app\">, names: Names): Flow {\n const flows = e.args.map((x) => this.#flow(x, names));\n const [head] = flows;\n switch (e.op) {\n case \"if\":\n if ((head?.dir ?? 0) !== 0) this.#refuse('the test of \"if\" reads the last round');\n return this.#joined(flows.slice(1), e.op);\n case \"and\":\n case \"or\":\n case \"ifError\":\n return this.#joined(flows, e.op);\n }\n if (flows.every((x) => x.dir === 0)) return STEADY;\n const rule = this.#rule(e.op, head?.tag);\n const moves = flows.map((x, i): number => {\n const move = rule.args[i];\n if (x.dir !== 0 && move === undefined) this.#refuse(`the argument ${String(i + 1)} of the op \"${e.op}\" reads the last round`);\n return move === \"down\" ? -x.dir : x.dir;\n });\n const { returns } = rule;\n return { dir: this.#one(moves, e.op), tag: returns === \"number\" || returns === \"boolean\" ? returns : undefined };\n }\n\n /** This method gives the flow of the branches of a form. Each branch can be the result. */\n #joined(flows: readonly Flow[], op: string): Flow {\n const [head] = flows;\n const dir = this.#one(\n flows.map((x) => x.dir),\n op,\n );\n return { dir, tag: flows.every((x) => x.tag === head?.tag) ? head?.tag : undefined };\n }\n\n /** This method gives the one direction of the moves of a node. Two directions have no proof. */\n #one(moves: readonly number[], op: string): Direction {\n const up = moves.some((m) => m > 0);\n if (up && moves.some((m) => m < 0)) this.#refuse(`the op \"${op}\" reads the last round in both directions`);\n return up ? 1 : moves.some((m) => m < 0) ? -1 : 0;\n }\n\n /**\n * This method gives the rule of an op for a receiver of a known kind, in the order of the interpreter. A list op on a\n * list comes first, then the domains in order, then a function of the host. A receiver of another kind has no rule.\n */\n #rule(op: string, tag: Flow[\"tag\"]): Rule {\n if (tag === undefined) this.#refuse(`the kind of the first argument of the op \"${op}\" does not decide the op. Put an argument of a known kind first`);\n if (tag === \"list\") return Object.hasOwn(LIST_RULES, op) ? (LIST_RULES[op] as Rule) : this.#noRule(op);\n const found: Rule[] = [];\n for (const d of this.#domains) {\n if (d.primitive !== undefined && d.primitive !== tag) continue;\n const spec = Object.hasOwn(d.ops, op) ? (d.ops[op] as OpSpec<unknown>) : undefined;\n if (spec?.fn === undefined) continue;\n found.push(this.#declared(spec, op));\n if (d.primitive === tag) return this.#same(found, op);\n }\n if (Object.hasOwn(this.#fns, op)) found.push(this.#declared(this.#fns[op] as Pick<OpSpec<unknown>, \"monotone\" | \"returns\">, op));\n return found.length > 0 ? this.#same(found, op) : this.#noRule(op);\n }\n\n #declared(spec: Pick<OpSpec<unknown>, \"monotone\" | \"returns\">, op: string): Rule {\n return spec.monotone === undefined ? this.#noRule(op) : { args: spec.monotone, returns: spec.returns };\n }\n\n /** This method gives the rule of the ops that can apply. They must have the same rule, because the data decides among them. */\n #same(rules: readonly Rule[], op: string): Rule {\n const first = rules[0] as Rule;\n if (rules.some((r) => r.args.join() !== first.args.join())) this.#refuse(`the op \"${op}\" has two rules, and the data decides among them`);\n return first;\n }\n\n #noRule(op: string): never {\n this.#refuse(`the op \"${op}\" has no rule of direction`);\n }\n}\n\n/** This function walks a program. `open` has the names of the `fix` nodes around a node (FIX.LAST). */\nfunction walk(e: Expr, open: ReadonlySet<string>, opts: MonotoneOptions): void {\n if (e.tag === \"last\" && !open.has(e.name)) throw new Refusal(`the read \"last\" of \"${e.name}\" has no \"fix\" of that name around it`);\n if (e.tag !== \"fix\") {\n for (const x of children(e)) walk(x, open, opts);\n return;\n }\n walk(e.init, open, opts);\n walk(e.step, new Set([...open, e.name]), opts);\n new Proof(e, opts).prove();\n}\n\n/** This function gives the reason that a program breaks a rule of `fix`, or `undefined` for a program that keeps them (FIX.LAST, FIX.MONOTONE). */\nexport function monotoneError(e: Expr, opts: MonotoneOptions): string | undefined {\n try {\n walk(e, new Set(), opts);\n return undefined;\n } catch (thrown) {\n // Stryker disable next-line ConditionalExpression: only a Refusal comes here, and a mutant that always takes it reads its field\n if (thrown instanceof Refusal) return thrown.reason;\n throw thrown;\n }\n}\n","/**\n * The check of sizes in the loops of a program (LOOP.SIZE). A step of `fold` or `iterate` gives each name a new value\n * from the values before the step. When a new value holds two copies of the old lists, the size can double at each step.\n * For example, a fold over 12 records with the step `append(xs, xs)` makes a list of 4096 items. The check finds such\n * steps before a run, from the size rules of the ops (LOOP.SIZE.OPS).\n *\n * The check is an abstract interpretation. It gives each value five measures: its size, its count, its inner count (the\n * sum of the counts of the values of its items), the size of its largest item, and its largest part (the largest item of\n * an item). Each measure is a bound: the largest value of some sums. A sum is a constant, and the measures of the old\n * values of the loops, each with a coefficient. A coefficient tells one use, a fixed number of uses, more uses, or no\n * bound. The check also keeps the kinds of each value, because the kind of the receiver selects the op.\n *\n * The check reads a program in two ways (LOOP.SIZE.READINGS). The first reading counts a read of a part of a value as a\n * use of the whole value. The second reading uses the bound of the part. Each reading gives a sound bound, so one\n * reading that accepts a program makes the program valid.\n */\nimport { isOpName, listItemKind, type AnyDomain, type OpSpec, type ReturnKind, type SizeMeasure, type SizeRule, type SizeTerm, type SizeUse } from \"./domain.ts\";\nimport { addrExprs, children, limitAxis, listOf, type Axis, type Expr, type ExprOf, type ItemNames } from \"./ir.ts\";\nimport { joinKind as kindOfJoin } from \"./fix.ts\";\nimport { isListOp, isVexList, LIST_SIZES, type ListOp } from \"./list.ts\";\n\n/** The options of the check of sizes: the domains and the functions of the host, as for `compile`. */\nexport interface SizeOptions {\n readonly domains?: readonly AnyDomain[];\n /** The functions of the host. A function with the property `size` has that size rule, and another function has none. */\n readonly fns?: Readonly<Record<string, unknown>>;\n}\n\n/** A coefficient: 1 for one use, 2 for a fixed number of uses, 3 for more uses, and 4 for no bound. */\ntype Coef = 1 | 2 | 3 | 4;\n\n/** A sum: a constant (`Infinity` for a constant without a known value) and a coefficient for each variable. */\ninterface Sum {\n readonly base: number;\n readonly terms: ReadonlyMap<string, Coef>;\n}\n\n/** A bound: the largest value of some sums (LOOP.SIZE.BRANCH). A bound has at least one sum, and no sum covers another. */\ntype Form = readonly Sum[];\n\n/** The kinds of a value: a set of tags, or `undefined` for each kind. `item` is the kind of the items of a list. */\ninterface Kind {\n readonly tags: ReadonlySet<string> | undefined;\n readonly item?: Kind;\n}\n\n/**\n * The measures and the kinds of a value. `long` tells that a key in the value can be long. A key of a record, of a\n * position or of a literal has a fixed bound. A key of `group` is a value of the program.\n */\ninterface Shape {\n readonly size: Form;\n readonly count: Form;\n readonly inner: Form;\n readonly item: Form;\n readonly part: Form;\n readonly kind: Kind;\n readonly long: boolean;\n}\n\nconst NO_TERMS: ReadonlyMap<string, Coef> = new Map();\nconst NONE: Form = [{ base: 0, terms: NO_TERMS }];\nconst constant = (base: number): Form => (base === 0 ? NONE : [{ base, terms: NO_TERMS }]);\nconst SOME = constant(Infinity);\nconst MEASURES: readonly SizeMeasure[] = [\"size\", \"count\", \"inner\", \"item\", \"part\"];\n/** The most sums of a bound. A bound with more sums becomes one sum, so the work of the check has a limit. */\nconst MOST_SUMS = 8;\n\nconst ANY: Kind = { tags: undefined };\nconst NO_KIND: Kind = { tags: new Set() };\nconst kindOf = (tag: string): Kind => ({ tags: new Set([tag]) });\nconst listKind = (item: Kind, tag = \"list\"): Kind => ({\n tags: new Set([tag]),\n item,\n});\nconst NUMBER = kindOf(\"number\");\nconst BOOLEAN = kindOf(\"boolean\");\nconst STRING = kindOf(\"string\");\nconst SCALAR: Kind = { tags: new Set([\"number\", \"boolean\"]) };\n/** The tags of the values that have no methods: an op of a domain needs its function for them. */\nconst PRIMITIVES: ReadonlySet<string> = new Set([\"number\", \"string\", \"boolean\", \"null\"]);\n/** The tags of the values without a size. */\nconst SCALARS: ReadonlySet<string> = new Set([\"number\", \"boolean\", \"null\"]);\n\n/** The shape of a value without a size, and the shape of a value with a fixed bound. */\nconst zero = (kind: Kind): Shape => ({\n size: NONE,\n count: NONE,\n inner: NONE,\n item: NONE,\n part: NONE,\n kind,\n long: false,\n});\nconst fixed = (kind: Kind): Shape => ({\n size: SOME,\n count: SOME,\n inner: SOME,\n item: SOME,\n part: SOME,\n kind,\n long: false,\n});\n\nconst isZero = (s: Sum): boolean => s.base === 0 && s.terms.size === 0;\nconst isNone = (f: Form): boolean => f.every(isZero);\nconst term = (v: string, c: Coef): Form => [{ base: 0, terms: new Map([[v, c]]) }];\n\n/** This function tells if the sum `a` is at least the sum `b` for each value of the variables. */\nconst covers = (a: Sum, b: Sum): boolean => a.base >= b.base && [...b.terms].every(([v, c]) => (a.terms.get(v) ?? 0) >= c);\n\n/** This function gives one sum that is at least each sum of a bound: the largest constant and the largest coefficients. */\nfunction cover(f: Form): Sum {\n const terms = new Map<string, Coef>();\n let base = 0;\n for (const s of f) {\n base = Math.max(base, s.base);\n for (const [v, c] of s.terms) terms.set(v, Math.max(terms.get(v) ?? 0, c) as Coef);\n }\n return { base, terms };\n}\n\n/** This function gives the bound of some sums, without a sum that another sum covers, and with at most `MOST_SUMS` sums. */\nfunction bound(sums: readonly Sum[]): Form {\n let out: readonly Sum[] = [];\n for (const s of sums) if (!out.some((o) => covers(o, s))) out = [...out.filter((o) => !covers(s, o)), s];\n if (out.length > MOST_SUMS) return [cover(out)];\n return out.length === 0 ? NONE : out;\n}\n\n/** This function gives the sum of two sums: the coefficients of a variable in both sums give more uses. */\nfunction add(a: Sum, b: Sum): Sum {\n const terms = new Map(a.terms);\n for (const [v, c] of b.terms) {\n const o = terms.get(v);\n terms.set(v, o === undefined ? c : (Math.max(3, o, c) as Coef));\n }\n return { base: a.base + b.base, terms };\n}\n\n/** This function gives the bound of a sum of two values. */\nfunction plus(a: Form, b: Form): Form {\n if (isNone(a)) return b;\n if (isNone(b)) return a;\n return bound(a.flatMap((x) => b.map((y) => add(x, y))));\n}\n\n/** This function gives the bound of the larger of two values. */\nconst join = (a: Form, b: Form): Form => bound([...a, ...b]);\n\n/** This function gives the bound of a union of two values: each variable with its largest coefficient, and the sum of the constants. */\nconst union = (a: Form, b: Form): Form => {\n const all = cover([...a, ...b]);\n return [{ base: cover(a).base + cover(b).base, terms: all.terms }];\n};\n\n/** This function gives the bound of `k` uses of a bound. */\nfunction scale(f: Form, k: 0 | Coef): Form {\n if (k === 0) return NONE;\n if (k === 1) return f;\n return bound(f.map((s) => ({ base: s.base === 0 ? 0 : Infinity, terms: new Map([...s.terms].map(([v, c]) => [v, Math.max(c, k) as Coef])) })));\n}\n\n/** This function gives a bound of a product of two sums. A product of two variables gives more uses of both. */\nfunction multiply(a: Sum, b: Sum): Form {\n if (isZero(a) || isZero(b)) return NONE;\n if (a.terms.size === 0) return a.base <= 1 ? [b] : scale([b], 2);\n if (b.terms.size === 0) return b.base <= 1 ? [a] : scale([a], 2);\n return scale([add(a, b)], 3);\n}\n\n/** This function gives a bound of a product of two values. */\nconst times = (a: Form, b: Form): Form => bound(a.flatMap((x) => b.flatMap((y) => multiply(x, y))));\n\n/** This function puts a bound in the place of each variable that `sigma` knows. */\nfunction subst(f: Form, sigma: (v: string) => Form | undefined): Form {\n const one = (s: Sum): Form => {\n let out = constant(s.base);\n for (const [v, c] of s.terms) {\n const u = sigma(v);\n out = plus(out, u === undefined ? term(v, c) : scale(u, c));\n }\n return out;\n };\n return bound(f.flatMap(one));\n}\n\n/** This function gives the sum without the variables that `drop` names, and the coefficients of these variables. */\nfunction split(s: Sum, drop: (v: string) => boolean): { readonly rest: Sum; readonly dropped: ReadonlyMap<string, Coef> } {\n const terms = new Map<string, Coef>();\n const dropped = new Map<string, Coef>();\n for (const [v, c] of s.terms) (drop(v) ? dropped : terms).set(v, c);\n return { rest: { base: s.base, terms }, dropped };\n}\n\nconst sameSum = (a: Sum, b: Sum): boolean => a.base === b.base && a.terms.size === b.terms.size && [...a.terms].every(([v, c]) => b.terms.get(v) === c);\nconst sameForm = (a: Form, b: Form): boolean => a.length === b.length && a.every((x) => b.some((y) => sameSum(x, y)));\n\n/** This function tells if a kind can be a list or an array. */\nconst listy = (k: Kind): boolean => k.tags === undefined || k.tags.has(\"list\") || k.tags.has(\"array\");\n\n/** This function gives the kind of the items of a value: no kind for a value that is not a list. */\nconst itemOf = (k: Kind): Kind => (listy(k) ? (k.item ?? ANY) : NO_KIND);\n\n/** This function gives the kind of a value of two kinds. */\nfunction joinKind(a: Kind, b: Kind): Kind {\n if (a.tags === undefined || b.tags === undefined) return ANY;\n const tags = new Set([...a.tags, ...b.tags]);\n return listy(a) || listy(b) ? { tags, item: joinKind(itemOf(a), itemOf(b)) } : { tags };\n}\n\n/** This function tells if each value of the kind `a` has the kind `b`. */\nfunction within(a: Kind, b: Kind): boolean {\n if (b.tags === undefined) return true;\n if (a.tags === undefined) return false;\n for (const t of a.tags) if (!b.tags.has(t)) return false;\n return !listy(a) || within(itemOf(a), itemOf(b));\n}\n\nconst isText = (k: Kind | undefined): boolean => k?.tags !== undefined && k.tags.size === 1 && k.tags.has(\"string\");\n\nconst joinShape = (a: Shape, b: Shape): Shape => ({\n size: join(a.size, b.size),\n count: join(a.count, b.count),\n inner: join(a.inner, b.inner),\n item: join(a.item, b.item),\n part: join(a.part, b.part),\n kind: joinKind(a.kind, b.kind),\n long: a.long || b.long,\n});\n\n/** This function puts a bound in the place of each variable that `sigma` knows, in each measure of a shape. */\nconst substShape = (s: Shape, sigma: (v: string) => Form | undefined): Shape => ({\n ...s,\n size: subst(s.size, sigma),\n count: subst(s.count, sigma),\n inner: subst(s.inner, sigma),\n item: subst(s.item, sigma),\n part: subst(s.part, sigma),\n});\n\n/** This function gives the coefficient of a use. */\nfunction coefOf(use: SizeUse): 0 | Coef {\n switch (use) {\n case 0:\n case \"number\":\n return 0;\n case 1:\n return 1;\n case \"scaled\":\n case \"copies\":\n case \"text\":\n return 2;\n case \"many\":\n case \"each\":\n case \"limit\":\n return 3;\n case \"unbounded\":\n return 4;\n }\n}\n\n/** The letters of the variables of the measures. */\nconst LETTERS: Readonly<Record<SizeMeasure, string>> = { size: \"s\", count: \"c\", inner: \"n\", item: \"t\", part: \"p\" };\n/** The name of the variable of a measure of a value with the number `id`, for example `s1` for its size. */\nconst variable = (m: SizeMeasure, id: number): string => `${LETTERS[m]}${String(id)}`;\n/** The shape of a value with a variable for each measure. A number, a boolean and null have no size. */\nconst shapeOfVar = (id: number, kind: Kind, long: boolean): Shape =>\n kind.tags !== undefined && [...kind.tags].every((t) => SCALARS.has(t))\n ? zero(kind)\n : {\n size: term(variable(\"size\", id), 1),\n count: term(variable(\"count\", id), 1),\n inner: term(variable(\"inner\", id), 1),\n item: term(variable(\"item\", id), 1),\n part: term(variable(\"part\", id), 1),\n kind,\n long,\n };\n\n/** The value of a name in the check: a shape, or the summary of a function (FN.BIND). */\ntype Entry =\n | { readonly t: \"value\"; readonly shape: Shape }\n | {\n readonly t: \"fn\";\n readonly params: readonly number[];\n readonly result: Shape;\n };\ntype Env = ReadonlyMap<string, Entry>;\n\n/** A refusal of the check. The check throws it, and `sizeError` gives its message. */\nclass Refusal {\n readonly message: string;\n constructor(message: string) {\n this.message = message;\n }\n}\n\n/** The literal number of an argument, if the argument is a literal number. */\nconst literalNumber = (e: Expr | undefined): number | undefined => (e?.tag === \"lit\" && typeof e.value === \"number\" ? e.value : undefined);\n\n/** The tag of the values of a domain: its primitive kind, or its name. */\nconst tagOf = (d: AnyDomain): string => d.primitive ?? `d:${d.name}`;\n\n/** This function tells if a domain accepts a value with a tag: surely, maybe or no. `undefined` is each tag. */\nfunction accepts(d: AnyDomain, tag: string | undefined): \"sure\" | \"maybe\" | \"no\" {\n if (tag === undefined) return \"maybe\";\n if (tag === tagOf(d)) return \"sure\";\n // KIND.PRIMITIVE: a domain with a primitive kind accepts each value of that type and no other value.\n if (d.primitive !== undefined) return tag.startsWith(\"d:\") ? \"maybe\" : \"no\";\n return \"maybe\";\n}\n\n/** The number of the nodes that the check reads with the kinds of the names of the loops, before it uses each kind. */\nconst BUDGET = 50_000;\n\n/** The check of one program. It keeps the shape of each node, to name the op of a refusal. */\nclass Checker {\n readonly #domains: readonly AnyDomain[];\n readonly #fns: Readonly<Record<string, unknown>> | undefined;\n readonly #shapes = new Map<Expr, Shape>();\n readonly #open = new Map<Expr, boolean>();\n /** With `true`, the check keeps the largest part as a measure and reads the rules `byParts` (LOOP.SIZE.READINGS). */\n readonly #parts: boolean;\n #next = 0;\n #visits = 0;\n\n constructor(opts: SizeOptions, parts: boolean) {\n this.#domains = opts.domains ?? [];\n this.#fns = opts.fns;\n this.#parts = parts;\n }\n\n shape(e: Expr, env: Env): Shape {\n this.#visits++;\n const found = this.#shape(e, env);\n // The first reading has no measure under the largest item, so the largest part of a value is its largest item.\n const s = this.#parts ? found : { ...found, part: found.item };\n this.#shapes.set(e, s);\n return s;\n }\n\n #fresh(): number {\n return this.#next++;\n }\n\n #shape(e: Expr, env: Env): Shape {\n switch (e.tag) {\n case \"lit\":\n return this.#literal(e.value);\n case \"ref\":\n for (const x of addrExprs(e.at)) this.shape(x, env);\n return fixed(ANY);\n case \"var\": {\n const entry = env.get(e.name);\n // A free name is a variable of the caller, so its value does not change in a loop. A function is not a value.\n return entry === undefined ? fixed(ANY) : entry.t === \"value\" ? entry.shape : zero(NO_KIND);\n }\n case \"ext\":\n return fixed(ANY);\n case \"rec\": {\n const fields = Object.values(e.fields).map((x) => this.shape(x, env));\n const size = fields.reduce((acc, x) => plus(acc, x.size), SOME);\n // LOOP.SIZE.PART: the items of a record are its fields, so one field gives the largest item.\n const item = fields.reduce((acc, x) => join(acc, x.size), NONE);\n const part = fields.reduce((acc, x) => join(acc, x.item), NONE);\n return { ...fixed(kindOf(\"object\")), size, item, part, long: fields.some((x) => x.long) };\n }\n case \"let\":\n return this.#let(e, env);\n case \"call\":\n return this.#call(e, env);\n case \"app\":\n return this.#app(e, env);\n case \"each\":\n return this.#each(e, env);\n case \"fold\":\n case \"iterate\":\n return this.#loop(e, env);\n case \"fix\":\n // A column gives a boolean or a number, so a list of the program cannot grow through it.\n this.shape(e.init, env);\n this.shape(e.step, env);\n return zero(kindOfJoin(e.join) === \"boolean\" ? BOOLEAN : NUMBER);\n case \"last\":\n return zero(SCALAR);\n case \"fn\":\n return zero(NO_KIND);\n }\n }\n\n /** This method gives the shape of a literal value: a constant, and its kind. */\n #literal(value: unknown): Shape {\n if (typeof value === \"number\") return zero(NUMBER);\n if (typeof value === \"boolean\") return zero(BOOLEAN);\n if (value === null || value === undefined) return zero(kindOf(\"null\"));\n if (typeof value === \"string\") {\n const length = constant(value.length);\n return { ...zero(STRING), size: length, item: length, part: length };\n }\n if (isVexList(value)) {\n const item = value.items.reduce((k, it) => (it.result.ok ? joinKind(k, this.#literal(it.result.value).kind) : k), NO_KIND);\n return { ...fixed(listKind(item)), count: constant(value.items.length) };\n }\n if (Array.isArray(value))\n return {\n ...fixed(\n listKind(\n value.reduce((k: Kind, x: unknown) => joinKind(k, this.#literal(x).kind), NO_KIND),\n \"array\",\n ),\n ),\n count: constant(value.length),\n };\n const d = this.#domains.find((x) => {\n try {\n return x.is(value);\n } catch {\n return false;\n }\n });\n return fixed(d === undefined ? kindOf(\"object\") : kindOf(tagOf(d)));\n }\n\n #let(e: ExprOf<\"let\">, env: Env): Shape {\n const inner = new Map(env);\n // FN.TOTAL: a binding does not see the other bindings of its let.\n for (const [name, b] of Object.entries(e.bind)) {\n if (b.tag === \"fn\") {\n // FN.CALL: the check reads the body one time, with a variable for each parameter. A call puts the shapes of\n // its arguments in the place of the variables.\n const params = b.params.map((p) => [p, this.#fresh()] as const);\n const fenv = new Map(env);\n for (const [p, id] of params) fenv.set(p, { t: \"value\", shape: shapeOfVar(id, ANY, true) });\n inner.set(name, { t: \"fn\", params: params.map(([, id]) => id), result: this.shape(b.body, fenv) });\n } else inner.set(name, { t: \"value\", shape: this.shape(b, env) });\n }\n return this.shape(e.body, inner);\n }\n\n #call(e: ExprOf<\"call\">, env: Env): Shape {\n const args = e.args.map((a) => this.shape(a, env));\n const entry = env.get(e.fn);\n // FN.ARGS: a call of a value, of a missing name or with another number of arguments gives an error.\n if (entry?.t !== \"fn\" || entry.params.length !== args.length) return zero(NO_KIND);\n const bindings = new Map<string, Form>();\n entry.params.forEach((id, i) => {\n for (const m of MEASURES) bindings.set(variable(m, id), (args[i] as Shape)[m]);\n });\n const sigma = (v: string): Form | undefined => bindings.get(v);\n return { ...substShape(entry.result, sigma), long: entry.result.long || args.some((a) => a.long) };\n }\n\n #app(e: ExprOf<\"app\">, env: Env): Shape {\n const args = e.args.map((a) => this.shape(a, env));\n switch (e.op) {\n case \"if\":\n case \"ifError\": {\n // FORM.IF: the test does not add to the size. A missing argument gives an error, which has no size.\n const outs = e.op === \"if\" ? args.slice(1, 3) : args.slice(0, 2);\n const [head = zero(NO_KIND), ...rest] = outs;\n return rest.reduce(joinShape, head);\n }\n case \"and\":\n case \"or\":\n return zero(BOOLEAN);\n }\n const { op } = e;\n const outs: Shape[] = [];\n let open = false;\n const listOp = isListOp(op) ? op : undefined;\n const fn = this.#fns !== undefined && Object.hasOwn(this.#fns, op) ? this.#fns[op] : undefined;\n const byFn = (): void => {\n const host = fn as { readonly size?: SizeRule; readonly returns?: ReturnKind };\n if (host.size === undefined) open = true;\n else outs.push(this.#apply(host.size, args, e.args, kindOfReturn(host.returns, undefined, this.#domains)));\n };\n const self = args[0]?.kind;\n // The order of the interpreter: a list op on a list, the domains in order, a function of the host, a list op on an\n // array (LIST.ARRAY), and fill.\n const tags = self === undefined ? [] : self.tags === undefined ? [undefined] : [...self.tags];\n for (const tag of tags) {\n if (listOp !== undefined && (tag === undefined || tag === \"list\")) {\n outs.push(this.#list(listOp, args, e.args));\n if (tag === \"list\") continue;\n }\n const d = this.#domain(op, tag, args, e.args, outs);\n open ||= d.open;\n if (d.done) continue;\n if (fn !== undefined) byFn();\n else if (listOp !== undefined && (tag === undefined || tag === \"array\")) outs.push(this.#list(listOp, args, e.args));\n else if (op === \"fill\") outs.push(this.#list(\"fill\", args, e.args));\n }\n if (self === undefined && fn !== undefined) byFn();\n // LOOP.SIZE.OPS: an op without a size rule has no bound (fail closed).\n if (open) outs.push(unbounded(args));\n this.#open.set(e, open);\n // An op that no domain and no function has gives an error, and an error has no size.\n return outs.slice(1).reduce(joinShape, outs[0] ?? zero(NO_KIND));\n }\n\n /**\n * This method adds the shapes of the ops of the domains that can take a receiver with the tag. It gives `true` for an\n * op without a size rule. A domain that surely takes the receiver and has a function for the op is the last domain,\n * and then `done` is `true`.\n */\n #domain(\n op: string,\n tag: string | undefined,\n args: readonly Shape[],\n exprs: readonly Expr[],\n outs: Shape[],\n ): { readonly open: boolean; readonly done: boolean } {\n if (!isOpName(op)) return { open: false, done: false };\n let open = false;\n for (const d of this.#domains) {\n const a = accepts(d, tag);\n if (a === \"no\") continue;\n const spec = Object.hasOwn(d.ops, op) ? (d.ops[op] as OpSpec<unknown>) : undefined;\n // A method needs an object: a number, a text, a boolean and null have no methods (findMethod).\n const method = (spec !== undefined || d.methods === \"all\") && (tag === undefined || !PRIMITIVES.has(tag));\n if (spec?.fn === undefined && !method) continue;\n const rule = spec === undefined ? undefined : ruleOf(d, spec, this.#domains);\n if (rule === undefined) open = true;\n else outs.push(this.#apply(rule, args, exprs, kindOfReturn(spec?.returns, d, this.#domains)));\n if (a === \"sure\" && spec?.fn !== undefined) return { open, done: true };\n }\n return { open, done: false };\n }\n\n /** This method gives the shape of a list op, and the kind of its result. */\n #list(op: ListOp | \"fill\", args: readonly Shape[], exprs: readonly Expr[]): Shape {\n // The receiver selects a list op, so the op has a first argument.\n const item = itemOf((args[0] as Shape).kind);\n const s = this.#apply(LIST_SIZES[op], args, exprs, listResult(op, item, args));\n return op === \"group\" ? { ...s, long: true } : s;\n }\n\n #apply(rule: SizeRule, args: readonly Shape[], exprs: readonly Expr[], kind: Kind): Shape {\n // The rule \"scalar\" tells that the result is a number or a boolean.\n if (rule === \"scalar\") return zero(kind.tags === undefined ? SCALAR : kind);\n if (rule === \"fixed\") return fixed(kind);\n if (rule === \"reduce\") return { ...this.#reduce(args, exprs), kind };\n const limit = rule.limit === undefined ? undefined : literalNumber(exprs[rule.limit]);\n // LOOP.SIZE.PART: a rule with a limit gives a bound for each item, so it needs a literal limit and short keys.\n const open = rule.limit !== undefined && (limit === undefined || args.some((a) => a.long));\n const r = this.#parts && !open ? (rule.byParts ?? rule) : rule;\n const sum = (terms: readonly SizeTerm[], own: SizeMeasure): Form =>\n args.reduce((acc, a, i) => {\n const t = terms[i] ?? r.rest ?? \"many\";\n const [use, of] = typeof t === \"object\" ? t : [t, own];\n const f = useForm(use, i, a[of], args, exprs, limit);\n // The largest item of the result is an item of one argument, so the arguments give the largest bound.\n if (own === \"item\" || own === \"part\") return join(acc, f);\n return r.union === true ? union(acc, f) : plus(acc, f);\n }, NONE);\n let size = sum(r.size, \"size\");\n let count = r.count === undefined ? size : sum(r.count, \"count\");\n const inner = r.inner === undefined ? size : sum(r.inner, \"inner\");\n if (limit !== undefined) count = constant(limit);\n if (r.constant === true) {\n size = plus(size, SOME);\n count = plus(count, SOME);\n }\n if (r.keys === \"position\") size = plus(size, times(count, SOME));\n const item = r.item === undefined ? size : sum(r.item, \"item\");\n const part = r.part === undefined ? item : sum(r.part, \"part\");\n return { size, count, inner, item, part, kind, long: args.some((a) => a.long) };\n }\n\n /** The rule of `reduce`: the op that the second argument names folds the values of the list (LIST.REDUCE). */\n #reduce(args: readonly Shape[], exprs: readonly Expr[]): Shape {\n const list = args[0] as Shape;\n const name = exprs[1]?.tag === \"lit\" ? exprs[1].value : undefined;\n if (typeof name !== \"string\" || !isOpName(name)) return unbounded([list]);\n // The empty list gives the identity of the op: a constant.\n let out: Shape = fixed(ANY);\n for (const d of this.#domains) {\n if (!Object.hasOwn(d.ops, name)) {\n if (d.methods === \"all\") return unbounded([list]);\n continue;\n }\n const rule = ruleOf(d, d.ops[name] as OpSpec<unknown>, this.#domains);\n if (rule === undefined || rule === \"reduce\") return unbounded([list]);\n if (rule === \"scalar\" || rule === \"fixed\") continue;\n const use = (i: number): 0 | Coef => {\n const t = rule.size[i] ?? rule.rest ?? \"many\";\n return coefOf(typeof t === \"object\" ? t[0] : t);\n };\n // The first argument is the result of the steps before. More than one use of it doubles at each value.\n const first = use(0);\n if (first > 1) return unbounded([list]);\n // A union holds each key one time, so the result is not larger than the list.\n const k = rule.union === true ? 1 : (Math.max(1, use(1)) as Coef);\n const size = rule.constant === true ? plus(scale(list.size, k), SOME) : scale(list.size, k);\n out = joinShape(out, {\n size,\n count: size,\n inner: size,\n item: size,\n part: size,\n kind: ANY,\n long: list.long,\n });\n }\n return out;\n }\n\n #each(e: ExprOf<\"each\">, env: Env): Shape {\n const list = this.#axis(e.axis, e.at, env);\n if (list === undefined) {\n const body = this.shape(e.body, bindItem(env, e.as, fixed(ANY)));\n // A fixed number of targets: the records of the space.\n return {\n size: plus(SOME, times(body.size, SOME)),\n count: SOME,\n inner: times(body.count, SOME),\n item: body.size,\n part: body.item,\n kind: listKind(body.kind),\n long: body.long,\n };\n }\n const id = this.#fresh();\n const body = this.shape(e.body, bindItem(env, e.as, shapeOfVar(id, itemOf(list.kind), list.long)));\n const vars = new Map(MEASURES.map((m) => [variable(m, id), m]));\n // The sum over the items of a bound of the body: a use of the item adds the measures of the list.\n const over = (f: Form, keys: boolean): Form => {\n // Each item can take another sum of the bound, so the sum over the items uses one sum that covers each sum.\n const { rest, dropped } = split(cover(f), (v) => vars.has(v));\n const c = (m: SizeMeasure): 0 | Coef => dropped.get(variable(m, id)) ?? 0;\n // The inner count, the largest item and the largest part of an item are not larger than its size.\n const uses = [c(\"size\"), c(\"inner\"), c(\"item\"), c(\"part\")].filter((x) => x > 0);\n const sizes = uses.length === 0 ? 0 : uses.length === 1 ? (uses[0] as Coef) : 3;\n // The items keep the keys of the list. A key with a fixed bound adds a constant for each item, and a long key is a\n // part of the size of the list.\n const whole = scale(list.size, keys && list.long ? (Math.max(1, sizes) as Coef) : sizes);\n // LOOP.SIZE.PART: more than one use of each item has the bound of the count of the items times the largest item.\n const values = this.#parts && sizes > 1 && !(keys && list.long) ? scale(times(c(\"size\") > 0 || c(\"inner\") > 0 ? list.item : list.part, list.count), sizes) : whole;\n const short = keys && !list.long ? times(list.count, SOME) : NONE;\n return plus(plus(plus(values, short), scale(list.inner, c(\"count\"))), times([rest], list.count));\n };\n // The largest item of the result is the value of the body for one item of the list.\n const one = itemMeasures(list);\n const sigma = (v: string): Form | undefined => {\n const m = vars.get(v);\n return m === undefined ? undefined : one[m];\n };\n return {\n size: over(body.size, true),\n count: list.count,\n inner: over(body.count, false),\n item: subst(body.size, sigma),\n part: subst(body.item, sigma),\n kind: listKind(body.kind),\n long: list.long || body.long,\n };\n }\n\n /** This method checks the parts of an axis and of an address. It gives the shape of the list of the axis `list`. */\n #axis(axis: Axis, at: ExprOf<\"each\">[\"at\"], env: Env): Shape | undefined {\n const list = listOf(axis);\n const shape = list === undefined ? undefined : this.shape(list, env);\n // The tests of `where` and the address do not add to the size.\n for (let x = axis; x.t === \"where\" || x.t === \"reverse\"; x = x.axis) if (x.t === \"where\") this.shape(x.test, env);\n for (const x of addrExprs(at)) this.shape(x, env);\n return shape;\n }\n\n #loop(e: ExprOf<\"fold\"> | ExprOf<\"iterate\">, env: Env): Shape {\n const list = e.tag === \"fold\" ? this.#axis(e.axis, e.at, env) : undefined;\n // ITERATE.LIMIT.DATA: a data limit has the bound of a fold over its axis, and the steps of iterate have no item.\n const axis = e.tag === \"iterate\" ? limitAxis(e) : undefined;\n const sized = axis === undefined ? undefined : this.#axis(axis, undefined, env);\n const names = Object.keys(e.init);\n const init = new Map(names.map((n) => [n, this.shape(e.init[n] as Expr, env)]));\n const ids = new Map(names.map((n) => [n, this.#fresh()]));\n const stepped = Object.keys(e.step);\n // AXIS.LIST.ITEM: the item of a fold over a list is the value of one item of the list.\n const item: Shape =\n list === undefined\n ? fixed(ANY)\n : { ...itemMeasures(list), kind: itemOf(list.kind), long: list.long };\n // The kinds of the names. The first step reads the values of init. The other steps read the values of the steps: the\n // kinds of the first step, then also the kinds of the next steps, then each kind. A large program uses each kind\n // at once, for each step.\n type Assumed = { readonly kind: Kind; readonly long: boolean };\n const each: Assumed = { kind: ANY, long: true };\n const start = (n: string): Shape => init.get(n) as Shape;\n const fromInit = (n: string): Assumed => ({ kind: start(n).kind, long: start(n).long });\n const always = (): Map<string, Assumed> => new Map(names.map((n) => [n, stepped.includes(n) ? each : fromInit(n)]));\n const run = (assumed: ReadonlyMap<string, Assumed>): { readonly senv: Env; readonly steps: Map<string, Shape> } => {\n const senv = new Map(env);\n for (const n of names) {\n const a = assumed.get(n) as Assumed;\n senv.set(n, { t: \"value\", shape: shapeOfVar(ids.get(n) as number, a.kind, a.long) });\n }\n const ienv = e.tag === \"fold\" ? bindItem(senv, e.as, item) : senv;\n return { senv, steps: new Map(stepped.map((n) => [n, this.shape(e.step[n] as Expr, ienv)])) };\n };\n let first: ReadonlyMap<string, Shape> | undefined;\n let assumed: Map<string, Assumed>;\n if (stepped.length > 0 && this.#visits < BUDGET) {\n first = run(new Map(names.map((n) => [n, fromInit(n)]))).steps;\n assumed = new Map(\n names.map((n): [string, Assumed] => {\n const s = first?.get(n);\n return [n, s === undefined ? fromInit(n) : { kind: s.kind, long: s.long }];\n }),\n );\n } else assumed = always();\n let senv: Env;\n let steps: Map<string, Shape>;\n for (let pass = 0; ; pass++) {\n ({ senv, steps } = run(assumed));\n const next = new Map(\n names.map((n): [string, Assumed] => {\n const a = assumed.get(n) as Assumed;\n const s = steps.get(n);\n return [n, s === undefined ? a : { kind: joinKind(a.kind, s.kind), long: a.long || s.long }];\n }),\n );\n const stable = names.every((n) => {\n const a = assumed.get(n) as Assumed;\n const b = next.get(n) as Assumed;\n return within(b.kind, a.kind) && (a.long || !b.long);\n });\n if (stable) break;\n // The second reading keeps the keys that the steps can give: `take` needs them (LOOP.SIZE.PART). Each pass after the\n // first pass only changes the keys from short to long, so the loop ends.\n assumed = pass === 0 && this.#visits < BUDGET ? next : this.#parts ? new Map(names.map((n): [string, Assumed] => {\n const b = next.get(n) as Assumed;\n return [n, stepped.includes(n) ? { kind: ANY, long: b.long } : b];\n })) : always();\n }\n if (e.tag === \"iterate\" && e.until !== undefined) this.shape(e.until, senv);\n const loop = new Loop(e, names, ids, steps);\n // LOOP.SIZE: the rule applies to the steps after the first step. One step can multiply the values one time.\n loop.check(this.#shapes, this.#open);\n // The values after the first step: the first step reads the values of init.\n const sigma = (v: string): Form | undefined => {\n for (const n of names) {\n const id = ids.get(n) as number;\n const m = MEASURES.find((x) => variable(x, id) === v);\n if (m !== undefined) return start(n)[m];\n }\n return undefined;\n };\n const starts = new Map(\n names.map((n): [string, Shape] => {\n const a = start(n);\n const s = first?.get(n);\n if (s === undefined) return [n, a];\n return [n, joinShape(a, substShape(s, sigma))];\n }),\n );\n const last = loop.last(starts, list?.count ?? sized?.count ?? (e.tag === \"iterate\" && typeof e.limit === \"number\" ? constant(e.limit) : SOME));\n const renv = new Map(env);\n for (const n of names) {\n const a = assumed.get(n) as Assumed;\n const s = last.get(n) as Shape;\n const i = start(n);\n // With no step, the result reads the values of init.\n renv.set(n, { t: \"value\", shape: stepped.includes(n) ? { ...s, kind: joinKind(i.kind, a.kind), long: i.long || a.long } : i });\n }\n return this.shape(e.result, renv);\n }\n}\n\n/** This function gives the kind of the result of an op of the domain `d`, or of a function of the host, from `returns` (KIND.RETURNS). */\nfunction kindOfReturn(r: ReturnKind | undefined, d: AnyDomain | undefined, domains: readonly AnyDomain[]): Kind {\n if (r === \"number\" || r === \"boolean\" || r === \"string\") return kindOf(r);\n if (r === \"domain\") return d === undefined ? ANY : kindOf(tagOf(d));\n if (r?.startsWith(\"domain:\") === true) {\n const target = domains.find((x) => x.name === r.slice(\"domain:\".length));\n return target === undefined ? ANY : kindOf(tagOf(target));\n }\n const item = listItemKind(r);\n return item === undefined ? ANY : listKind(kindOf(item));\n}\n\n/** This function gives the kind of the result of a list op. `item` is the kind of the items of the receiver. */\nfunction listResult(op: ListOp | \"fill\", item: Kind, args: readonly Shape[]): Kind {\n switch (op) {\n case \"count\":\n case \"sum\":\n case \"mean\":\n case \"min\":\n case \"max\":\n case \"indexOf\":\n return NUMBER;\n case \"any\":\n case \"all\":\n case \"none\":\n return BOOLEAN;\n case \"join\":\n return STRING;\n case \"values\":\n return listKind(item, \"array\");\n case \"keys\":\n return listKind(STRING, \"array\");\n case \"first\":\n case \"nth\":\n case \"get\":\n return item;\n case \"sortBy\":\n case \"take\":\n case \"drop\":\n case \"without\":\n case \"distinct\":\n return listKind(item);\n case \"append\":\n return listKind(joinKind(item, itemOf(args[1]?.kind ?? ANY)));\n case \"setNth\":\n return listKind(joinKind(item, args[2]?.kind ?? ANY));\n case \"flat\":\n return listKind(itemOf(item));\n case \"group\":\n return listKind(listKind(item));\n case \"fill\":\n return listKind(args[1]?.kind ?? ANY);\n case \"errors\":\n case \"reduce\":\n return ANY;\n }\n}\n\n/** This function binds the names `as` of a loop: the item gets `item`, and the index is a number. */\nfunction bindItem(env: Env, as: ItemNames | undefined, item: Shape): Env {\n if (as === undefined) return env;\n const out = new Map(env);\n out.set(as[0], { t: \"value\", shape: item });\n if (as[1] !== undefined) out.set(as[1], { t: \"value\", shape: zero(NUMBER) });\n return out;\n}\n\n/** The shape of the result of an op without a size rule: no bound in the sizes of its arguments. */\nfunction unbounded(args: readonly Shape[]): Shape {\n const f = scale(\n args.reduce((acc, a) => plus(acc, a.size), SOME),\n 4,\n );\n return { size: f, count: f, inner: f, item: f, part: f, kind: ANY, long: true };\n}\n\n/** The measures of one item of a list. The largest item of the list bounds its size, and the largest part bounds the rest. */\nconst itemMeasures = (list: Shape): Readonly<Record<SizeMeasure, Form>> => ({ size: list.item, count: list.item, inner: list.item, item: list.part, part: list.part });\n\n/** This function gives the bound of one use of an argument. */\nfunction useForm(use: SizeUse, i: number, form: Form, args: readonly Shape[], exprs: readonly Expr[], limit: number | undefined): Form {\n switch (use) {\n case \"text\":\n return isText(args[i]?.kind) ? form : scale(form, 2);\n case \"copies\": {\n const n = literalNumber(exprs[0]);\n return n === 0 ? NONE : n === 1 ? form : scale(form, 2);\n }\n case \"each\":\n return times(form, (args[0] as Shape).count);\n case \"number\":\n // LIST.FILL: a count has the bound 100000.\n return constant(Math.min(100_000, literalNumber(exprs[i]) ?? Infinity));\n case \"limit\":\n // LOOP.SIZE.PART: each item that the limit keeps has a key with a fixed bound and a value.\n return limit === undefined ? scale(form, 3) : times(plus(form, SOME), constant(limit));\n case 0:\n case 1:\n case \"scaled\":\n case \"many\":\n case \"unbounded\":\n return scale(form, coefOf(use));\n }\n}\n\n/** This function tells if a domain holds numbers or booleans. */\nfunction scalar(x: AnyDomain | undefined): boolean {\n return x?.primitive === \"number\" || x?.primitive === \"boolean\";\n}\n\n/**\n * This function gives the size rule of an op of a domain (LOOP.SIZE.OPS). The rule is the rule of the op, or a rule\n * from its result kind and from the domain. The function gives `undefined` for an op without a rule.\n */\nexport function ruleOf(d: AnyDomain, spec: OpSpec<unknown>, domains: readonly AnyDomain[]): SizeRule | undefined {\n if (spec.size !== undefined) return spec.size;\n const r = spec.returns;\n if (r === \"number\" || r === \"boolean\" || (r === \"domain\" && scalar(d))) return \"scalar\";\n if (d.size === \"fixed\") return \"fixed\";\n if (r?.startsWith(\"domain:\") === true) {\n const target = domains.find((x) => x.name === r.slice(\"domain:\".length));\n if (scalar(target)) return \"scalar\";\n if (target?.size === \"fixed\") return \"fixed\";\n }\n return undefined;\n}\n\n/** The terms of a sum that read a variable of a cycle. */\nconst inside = (s: Sum, cycle: ReadonlySet<string>): readonly (readonly [string, Coef])[] => [...s.terms].filter(([u]) => cycle.has(u));\n\n/** This function tells if a sum of a bound reads its cycle more than one time, or with a coefficient other than 1. */\nconst loose = (f: Form, cycle: ReadonlySet<string>): boolean =>\n f.some((s) => {\n const terms = inside(s, cycle);\n return terms.length > 1 || terms.some(([, c]) => c !== 1);\n });\n\n/** The variable of a measure of a name of a loop. */\ninterface Owner {\n readonly name: string;\n readonly measure: SizeMeasure;\n}\n\n/** The words of a measure in a message. */\nconst WORDS: Readonly<Record<SizeMeasure, string>> = {\n size: \"size\",\n count: \"number of items\",\n inner: \"number of inner items\",\n item: \"largest item\",\n part: \"largest part\",\n};\n\n/** This function gives the label of the node of a refusal: an op, a function, a name or a node. */\nfunction label(e: Expr): string {\n switch (e.tag) {\n case \"app\":\n return `the op \"${e.op}\"`;\n case \"call\":\n return `the function \"${e.fn}\"`;\n case \"var\":\n return `the name \"${e.name}\"`;\n case \"each\":\n case \"ext\":\n case \"fn\":\n case \"fix\":\n case \"fold\":\n case \"iterate\":\n case \"last\":\n case \"let\":\n case \"lit\":\n case \"rec\":\n case \"ref\":\n return `a node \"${e.tag}\"`;\n }\n}\n\n/** The names of one loop, their steps, and the rule of LOOP.SIZE. */\nclass Loop {\n readonly #owners = new Map<string, Owner>();\n /** The cycle of each variable: the variables that its new value reads, and that read it in turn. */\n readonly #cycles = new Map<string, ReadonlySet<string>>();\n\n readonly node: ExprOf<\"fold\"> | ExprOf<\"iterate\">;\n readonly names: readonly string[];\n readonly steps: ReadonlyMap<string, Shape>;\n\n // Node.js starts the speed gate from this source with the types removed, so the class has no parameter properties.\n constructor(node: ExprOf<\"fold\"> | ExprOf<\"iterate\">, names: readonly string[], ids: ReadonlyMap<string, number>, steps: ReadonlyMap<string, Shape>) {\n this.node = node;\n this.names = names;\n this.steps = steps;\n for (const name of names)\n for (const measure of MEASURES)\n this.#owners.set(variable(measure, ids.get(name) as number), {\n name,\n measure,\n });\n }\n\n /**\n * This method applies the rule of LOOP.SIZE to the steps, and it throws a refusal. Each sum of a measure of a new value\n * reads its cycle at most one time, with the coefficient 1. A name without a step keeps its value.\n */\n check(shapes: ReadonlyMap<Expr, Shape>, open: ReadonlyMap<Expr, boolean>): void {\n // The graph of the measures: an edge from each variable of a bound of a step to the measure of its name.\n const into = new Map<string, Form>();\n const out = new Map<string, string[]>();\n for (const [v, o] of this.#owners) {\n const form = this.steps.get(o.name)?.[o.measure] ?? term(v, 1);\n into.set(v, form);\n for (const u of new Set(form.flatMap((s) => [...s.terms.keys()]))) if (this.#owners.has(u)) out.set(u, [...(out.get(u) ?? []), v]);\n }\n const reach = (from: string): ReadonlySet<string> => {\n const seen = new Set<string>();\n const todo = [from];\n for (let x = todo.pop(); x !== undefined; x = todo.pop()) {\n for (const y of out.get(x) ?? []) {\n if (seen.has(y)) continue;\n seen.add(y);\n todo.push(y);\n }\n }\n return seen;\n };\n const reached = new Map([...this.#owners.keys()].map((v): [string, ReadonlySet<string>] => [v, reach(v)]));\n for (const [v, form] of into) {\n const cycle = new Set([...(reached.get(v) as ReadonlySet<string>)].filter((u) => (reached.get(u) as ReadonlySet<string>).has(v)));\n this.#cycles.set(v, cycle);\n if (!loose(form, cycle)) continue;\n const o = this.#owners.get(v) as Owner;\n const twice = form.some((s) => {\n const terms = inside(s, cycle);\n return terms.length > 1 || terms.some(([, c]) => c > 2);\n });\n const what = twice\n ? `a value that uses the lists of the loop more than one time in its ${WORDS[o.measure]}`\n : `a ${WORDS[o.measure]} that can grow by a factor at each step`;\n this.#refuse(o.name, (s) => loose(s[o.measure], cycle), what, shapes, open);\n }\n }\n\n #refuse(name: string, bad: (s: Shape) => boolean, what: string, shapes: ReadonlyMap<Expr, Shape>, open: ReadonlyMap<Expr, boolean>): never {\n // The node of the refusal: the deepest node on a path of bad nodes from the step.\n const worse = (at: Expr): Expr | undefined =>\n children(at).find((k) => {\n const s = shapes.get(k);\n return s !== undefined && bad(s);\n });\n let at = this.node.step[name] as Expr;\n for (let next = worse(at); next !== undefined; next = worse(at)) at = next;\n const source = findOpen(at, open);\n const head = `the expression has a node \"${this.node.tag}\" whose step gives the name \"${name}\" ${what}, at ${label(source ?? at)} (LOOP.SIZE)`;\n throw new Refusal(source === undefined ? head : `${head}. The op \"${source.op}\" has no size rule (LOOP.SIZE.OPS)`);\n }\n\n /**\n * This method gives a bound of the last value of each name, from the values of `init` and the steps. The number of the\n * steps is `steps`. Each sum of a measure in a cycle gets at most one measure of its cycle at each step. A sum with a\n * measure of the cycle adds its other parts one time for each step. A sum without such a measure sets the value again,\n * so it adds to the bound one time (LOOP.SIZE.BRANCH). The last value starts from the largest first value of the cycle\n * or of these sums. It adds the parts of the other sums one time for each step. A measure outside a cycle has its first\n * value or the value of its step.\n */\n last(init: ReadonlyMap<string, Shape>, steps: Form): ReadonlyMap<string, Shape> {\n const first = (v: string): Form => {\n const o = this.#owners.get(v) as Owner;\n return (init.get(o.name) as Shape)[o.measure];\n };\n const bounds = new Map([...this.#owners.keys()].map((v) => [v, first(v)]));\n const sigma = (v: string): Form | undefined => bounds.get(v);\n // Each pass makes the bounds larger, and the bounds have a finite number of values, so the loop ends. A constant\n // that is new in a bound becomes a constant without a known value.\n const widen = (old: Form, more: Form): Form => bound(join(old, more).map((s) => (s.base === 0 || old.some((o) => o.base === s.base) ? s : { base: Infinity, terms: s.terms })));\n const stepOf = (v: string): Form | undefined => {\n const o = this.#owners.get(v) as Owner;\n return this.steps.get(o.name)?.[o.measure];\n };\n for (let changed = true; changed;) {\n changed = false;\n for (const [v, old] of bounds) {\n const step = stepOf(v);\n if (step === undefined) continue;\n const cycle = this.#cycles.get(v) as ReadonlySet<string>;\n let next: Form;\n if (cycle.has(v)) {\n const members = [...cycle];\n const start = members.reduce((acc, u) => join(acc, first(u)), NONE);\n const sums = members.flatMap((u) => (stepOf(u) as Form).map((x) => split(x, (y) => cycle.has(y))));\n const sets = subst(bound(sums.filter((x) => x.dropped.size === 0).map((x) => x.rest)), sigma);\n const adds = subst(bound(sums.filter((x) => x.dropped.size > 0).map((x) => x.rest)), sigma);\n next = plus(join(start, sets), times(adds, steps));\n } else next = join(first(v), subst(step, sigma));\n const wide = widen(old, next);\n if (sameForm(old, wide)) continue;\n bounds.set(v, wide);\n changed = true;\n }\n }\n const values = new Map(this.names.map((n) => [n, init.get(n) as Shape]));\n for (const [v, o] of this.#owners) values.set(o.name, { ...(values.get(o.name) as Shape), [o.measure]: bounds.get(v) as Form });\n return values;\n }\n}\n\n/** This function finds an op without a size rule in a node or in its children. */\nfunction findOpen(at: Expr, open: ReadonlyMap<Expr, boolean>): ExprOf<\"app\"> | undefined {\n const todo = [at];\n for (let x = todo.pop(); x !== undefined; x = todo.pop()) {\n if (x.tag === \"app\" && open.get(x) === true) return x;\n todo.push(...children(x));\n }\n return undefined;\n}\n\n/** This function reads an expression one time, and it gives the reason of a refusal or `undefined`. */\nfunction refusalOf(e: Expr, opts: SizeOptions, parts: boolean): string | undefined {\n try {\n new Checker(opts, parts).shape(e, new Map());\n return undefined;\n } catch (thrown) {\n if (thrown instanceof Refusal) return thrown.message;\n throw thrown;\n }\n}\n\n/**\n * This function checks the sizes of the loops of an expression (LOOP.SIZE). It gives the reason of a refusal, or\n * `undefined`. The expression must pass `shapeError` and the limit of the nesting first. Each reading gives a sound\n * bound, so one reading that accepts the expression makes it valid. A refusal tells the reason of the first reading\n * (LOOP.SIZE.READINGS).\n */\nexport function sizeError(e: Expr, opts: SizeOptions = {}): string | undefined {\n const reason = refusalOf(e, opts, false);\n return reason === undefined || refusalOf(e, opts, true) === undefined ? undefined : reason;\n}\n","/**\n * The step of each construct of Vex (STEP.LADDER). The construct of a node is its tag. An `iterate` with a limit from\n * the data has its own construct `iterate.size` (ITERATE.LIMIT.DATA). The step of this construct, of `fix` and of `last` is\n * `B`. The step of each other construct is `A`. A function cannot call itself (FN.TOTAL). The table is its own module, so a test can declare a construct of a higher step.\n */\nimport type { ExprTag } from \"./ir.ts\";\n\n/** A step of Vex. Step A has loops with a fixed count. Step B adds limits from the data and fixed points. Step C adds functions that call themselves, with a budget. */\nexport type VexStep = \"A\" | \"B\" | \"C\";\n\n/** The construct of an `iterate` with a limit from the data. */\nexport const ITERATE_SIZE = \"iterate.size\";\n\n/** The step that each construct of Vex needs. The name of a construct is the tag of its node, or `ITERATE_SIZE`. */\nexport const CONSTRUCT_STEPS: Readonly<Record<ExprTag | typeof ITERATE_SIZE, VexStep>> = {\n lit: \"A\",\n ref: \"A\",\n app: \"A\",\n let: \"A\",\n var: \"A\",\n rec: \"A\",\n each: \"A\",\n fold: \"A\",\n iterate: \"A\",\n [ITERATE_SIZE]: \"B\",\n fix: \"B\",\n last: \"B\",\n fn: \"A\",\n call: \"A\",\n ext: \"A\",\n};\n","/**\n * The steps of Vex (STEP.LADDER, STEP.LOWEST, STEP.MAX). A step is a level of the power of the language. Step A is a\n * total formula language. Step B adds limits from the data and fixed points. Step C adds functions that call\n * themselves. The checker gives the lowest step that a program needs, with the reason. The host option `maxStep` sets\n * the highest step that the host accepts. The default is B. A program has no field for its step, so a document cannot\n * raise its own step. The ladder is the ladder of steps of coeval (D116 of coeval), with the table of `constructs.ts`.\n */\nimport { checkStep, isStep, stepLadder, stepOf, stepRank, type StepLadder, type StepReason, type StepWalk } from \"@mark1russell7/coeval\";\nimport { CONSTRUCT_STEPS, ITERATE_SIZE, type VexStep } from \"./constructs.ts\";\nimport { children, limitAxis, type Expr } from \"./ir.ts\";\n\nexport { CONSTRUCT_STEPS, type VexStep } from \"./constructs.ts\";\n\n/** The steps of Vex, from the lowest to the highest. */\nexport const VEX_STEP_NAMES: readonly VexStep[] = [\"A\", \"B\", \"C\"];\n\n/** The ladder of the steps of Vex: the steps and the step of each construct. */\nexport const VEX_STEPS: StepLadder<VexStep> = /* @__PURE__ */ stepLadder<VexStep>(VEX_STEP_NAMES, CONSTRUCT_STEPS);\n\n/** The highest step that a host accepts without the option `maxStep`. */\nexport const DEFAULT_MAX_STEP: VexStep = \"B\";\n\n/** The options of the check of steps: the highest step that the host accepts. */\nexport interface StepOptions {\n /** The highest step that the host accepts. The default is `DEFAULT_MAX_STEP`, step B. */\n readonly maxStep?: VexStep;\n}\n\n/** The step of a program, with the reason as text, and the construct and the path of the node that needs the step. */\nexport interface ProgramStep {\n readonly step: VexStep;\n /** The reason as text. */\n readonly reason: string;\n /** The construct that needs the step. A program of step A has none. */\n readonly construct?: string;\n /** The path of the node of the construct, as child indexes (EVAL.LOCATION). A program of step A has none. */\n readonly path?: readonly number[];\n}\n\n/**\n * The walk of an expression: the construct of a node is its tag, and the key of a child is its child index. An\n * `iterate` with a limit from the data is its own construct (ITERATE.LIMIT.DATA).\n */\nconst WALK: StepWalk<Expr> = {\n construct: (e) => (e.tag === \"iterate\" && limitAxis(e) !== undefined ? ITERATE_SIZE : e.tag),\n children: (e) => children(e).map((child, i) => [i, child] as const),\n};\n\n/** The position of the highest step of a construct of the table. A limit at that step or higher accepts each program without a walk. The table is frozen, so the module computes this value one time. */\nconst HIGHEST: number = Math.max(0, ...Object.values(VEX_STEPS.constructs).map((s) => stepRank(VEX_STEPS, s)));\n\nconst at = (path: readonly unknown[]): string => (path.length === 0 ? \"at the root\" : `at the path [${path.join(\", \")}]`);\n\n/**\n * This function gives the lowest step that a program needs, with the reason (STEP.LOWEST). The reason names the first\n * node in the order of `children` whose construct needs that step. The program must have a valid shape (EVAL.SHAPE).\n */\nexport function programStep(e: Expr): ProgramStep {\n const need = stepOf(VEX_STEPS, WALK, e);\n if (need.reason === undefined) return { step: need.step, reason: `each construct of the program is of step ${need.step}` };\n const { construct, path } = need.reason;\n return { step: need.step, reason: `the node \"${construct}\" ${at(path)} needs step ${need.step}`, construct, path: path as readonly number[] };\n}\n\n/**\n * This function gives the reason that a host refuses a program for its step, or `undefined` (STEP.MAX). A program of a\n * step above the option `maxStep` is not valid, and the reason names the step that it needs. A value of `maxStep` that\n * is not a step of Vex is not valid too. The program must have a valid shape (EVAL.SHAPE).\n */\nexport function stepError(e: Expr, opts: StepOptions = {}): string | undefined {\n const maxStep: unknown = opts.maxStep ?? DEFAULT_MAX_STEP;\n if (!isStep(VEX_STEPS, maxStep)) {\n const shown = typeof maxStep === \"string\" ? JSON.stringify(maxStep) : `of the type ${typeof maxStep}`;\n return `the option maxStep ${shown} is not a step of Vex. The steps are ${VEX_STEP_NAMES.join(\", \")} (STEP.MAX)`;\n }\n // Stryker disable next-line ConditionalExpression: without the shortcut, the walk gives the same answer\n if (stepRank(VEX_STEPS, maxStep) >= HIGHEST) return undefined;\n const refusal = checkStep(VEX_STEPS, stepOf(VEX_STEPS, WALK, e), maxStep);\n if (refusal === undefined) return undefined;\n // A refusal of `stepOf` has a reason, because its step is above the lowest step.\n const { construct, path } = refusal.reason as StepReason<Expr, VexStep>;\n return `the program needs step ${refusal.needed}, and the host accepts the steps up to ${maxStep}: the node \"${construct}\" ${at(path)} needs step ${refusal.needed} (STEP.MAX)`;\n}\n","import { CHECKED } from \"./checked.ts\";\nimport { fromDocument, isDocument, type Envelope } from \"./document.ts\";\nimport { fixRounds, fixValueError, joinValues, worstRow } from \"./fix.ts\";\nimport { findMethod, isOpName, liftsAt, resolveOp, type AnyDomain, type Monotone, type OpSpec, type ParamKind, type PrimitiveKind, type ResolvedOp, type ReturnKind, type SizeRule } from \"./domain.ts\";\nimport { describeType, errorAt, errorText, type ErrorExtra, type ErrorText } from \"./error-text.ts\";\nimport { formatError, isDepthError, isStackOverflow, vexError, type ErrorKind, type VexError } from \"./errors.ts\";\nimport { limitError, overLimitMessage, worstError } from \"./limit-error.ts\";\nimport { addrExprs, children, limitAxis, MAX_ITERATIONS, shapeError, type Addr, type Axis, type Expr, type ExprOf, type FixedMove, type ItemNames, type Move } from \"./ir.ts\";\nimport { asList, fillList, isFillCount, isIndexValue, listOfArray } from \"./array-list.ts\";\nimport { monotoneError } from \"./monotone.ts\";\nimport { sizeError } from \"./size.ts\";\nimport { stepError, type VexStep } from \"./steps.ts\";\nimport { isListOp, isVexList, vexList, type ListItem, type ListOp, type ListOptions, type VexList } from \"./list.ts\";\nimport { fail, ok, type Result } from \"./result.ts\";\nimport { axisTargets, fixAddr, resolveAddr, type Position, type Space } from \"./space.ts\";\nimport type { Read, Trace, TraceEvent, TraceSink } from \"./trace.ts\";\n\nexport { describeType };\n\n/**\n * A free function op. The interpreter gives it the values of all arguments. The property `size` is its size rule\n * (LOOP.SIZE.OPS). Without it, a step of a loop cannot use its result in the size of a list name. The property\n * `returns` is the kind of its result, as in `OpSpec`. The interpreter does not examine it.\n */\nexport type FreeFn = ((...args: readonly unknown[]) => unknown) & { readonly size?: SizeRule; readonly returns?: ReturnKind; readonly monotone?: readonly Monotone[] };\n\n/** The context of an extension handler. */\nexport interface ExtContext {\n readonly space: Space;\n readonly position: Position;\n readonly path: readonly number[];\n}\n\n/** The handler of an extension expression kind. */\nexport type ExtHandler = (data: unknown, ctx: ExtContext) => Result<unknown>;\n\n/** The options of an evaluation. */\nexport interface EvalOptions {\n /** The space that the program reads. */\n readonly space: Space;\n /** The key where the evaluation starts. Relative references read here. */\n readonly origin: string;\n /** The domains. The interpreter finds the op of a value in the first domain that accepts the value. */\n readonly domains?: readonly AnyDomain[];\n /** Free function ops, for ops that are not domain ops. */\n readonly fns?: Readonly<Record<string, FreeFn>>;\n /** The handlers of extension expression kinds. */\n readonly extensions?: Readonly<Record<string, ExtHandler>>;\n /** Variables that the program can read with `v(name)`. */\n readonly vars?: Readonly<Record<string, unknown>>;\n /** The other spaces of the evaluation, by name. The axis `table(name)` reads them. */\n readonly tables?: Readonly<Record<string, Space>>;\n /** A receiver of trace events. */\n readonly trace?: TraceSink;\n /**\n * The highest step of the language that the host accepts (STEP.MAX). The default is B. A program that needs a higher\n * step gives `#VALUE!` before the evaluation, and the reason names its step.\n */\n readonly maxStep?: VexStep;\n}\n\n/** The names of a frame: a map of the variables of the caller, or a scope inside it. */\ninterface Env {\n get(name: string | symbol): Result<unknown> | undefined;\n}\n\n/**\n * A scope: the names of one `let`, a function, an item or a loop. It is in front of the outer names, and it does not\n * copy them. A name of a scope hides an outer name of the same name. The names of one\n * scope are distinct (FN.BIND, LOOP.NAMES, AXIS.LIST.SCOPE).\n */\nclass Scope implements Env {\n readonly #outer: Env;\n readonly #names: readonly (string | symbol)[];\n readonly #values: readonly Result<unknown>[];\n\n constructor(outer: Env, names: readonly (string | symbol)[], values: readonly Result<unknown>[]) {\n this.#outer = outer;\n this.#names = names;\n this.#values = values;\n }\n\n get(name: string | symbol): Result<unknown> | undefined {\n const at = this.#names.indexOf(name);\n return at >= 0 ? this.#values[at] : this.#outer.get(name);\n }\n\n /** This method gives a copy of this scope with the values `values` at the positions `at` (LOOP.NAMES). */\n with(at: readonly number[], values: readonly Result<unknown>[]): Scope {\n const next = [...this.#values];\n at.forEach((position, i) => {\n next[position] = values[i] as Result<unknown>;\n });\n return new Scope(this.#outer, this.#names, next);\n }\n}\n\ninterface Frame {\n readonly pos: Position;\n readonly env: Env;\n}\n\n/** The name of a special form. */\nexport type SpecialForm = \"if\" | \"and\" | \"or\" | \"ifError\";\n\n/** The names of the special forms. Their arguments are not evaluated before the call. */\nexport const SPECIAL_FORMS: ReadonlySet<string> = new Set<SpecialForm>([\"if\", \"and\", \"or\", \"ifError\"]);\n\nconst isSpecialForm = (op: string): op is SpecialForm => SPECIAL_FORMS.has(op);\n\n/** The options that a compiled program keeps: the domains, the free functions and the extension handlers. */\nexport type CompileOptions = Pick<EvalOptions, \"domains\" | \"fns\" | \"extensions\" | \"maxStep\">;\n\n/** The options of one run of a compiled program. */\nexport type RunOptions = Pick<EvalOptions, \"space\" | \"origin\" | \"vars\" | \"trace\" | \"tables\">;\n\n/**\n * A compiled program: the expression as a tree of functions. A program evaluates many times at different origins,\n * and over different spaces, without a new walk of the expression.\n */\nexport interface Program {\n /**\n * The expression of the program. For a document, it is the expression of the document. A document that is not valid\n * stays as it is, as an expression that is not valid stays (DOC.ENTRY).\n */\n readonly expr: Expr;\n /** This method evaluates the program at an origin. It does not throw. */\n run(opts: RunOptions): Result<unknown>;\n /** This method evaluates the program at an origin, with a trace of each node. */\n explain(opts: Omit<RunOptions, \"trace\">): Trace;\n}\n\n/** A bound function (FN.BIND): its parameters, its compiled body and the names of the place of its binding. */\nclass Closure {\n readonly params: readonly string[];\n readonly body: Node;\n readonly env: Env;\n\n constructor(params: readonly string[], body: Node, env: Env) {\n this.params = params;\n this.body = body;\n this.env = env;\n }\n}\n\n/** This function gives the error of an origin that is not a key of the space (EVAL.ORIGIN). */\nexport const noKeyError = (origin: string): VexError => vexError(\"unknown-key\", `the space has no key \"${origin}\"`, { origin, focus: origin });\n\n/** The deepest nesting of an expression that `compile` accepts (EVAL.NESTING). */\nexport const MAX_NESTING = 500;\n\nconst DEPTH_MESSAGE = \"the evaluation is too deep for the call stack of the engine\";\n\n/** This function gives the number of nodes on the longest path from the root of `e`. It uses a stack, not recursion. */\nexport function nestingOf(e: Expr): number {\n let deepest = 0;\n const todo: [Expr, number][] = [[e, 1]];\n for (let item = todo.pop(); item !== undefined; item = todo.pop()) {\n const [x, d] = item;\n if (d > deepest) deepest = d;\n for (const child of children(x)) todo.push([child, d + 1]);\n }\n return deepest;\n}\n\n/** This function gives the reason of the refusal of an expression that is nested too deep (EVAL.NESTING), or undefined. */\nexport function nestingError(e: Expr): string | undefined {\n const nesting = nestingOf(e);\n return nesting > MAX_NESTING ? `the expression is nested ${String(nesting)} levels deep, and the limit is ${String(MAX_NESTING)}` : undefined;\n}\n\n/**\n * This function compiles an expression or a document (DOC.ENTRY). The result gives the same results and the same traces\n * as `evaluate`, because `evaluate` uses it too.\n */\n/**\n * The list ops of `compile` for the values of a host (LIST.OPS). A result has the rules of the interpreter. An error of\n * the op has the position and the path of the call, and an error of an item keeps its own.\n */\nexport interface ListOps {\n /** This function gives the result of a list op on a list. The list is the receiver, and `rest` has the other arguments. */\n readonly list: (op: ListOp, list: VexList, rest: readonly unknown[], position: Position, path: readonly number[]) => Result<unknown>;\n /** This function gives the result of a list op on an array (LIST.ARRAY). A missing item is an error item with the position and the path. */\n readonly array: (op: ListOp, array: readonly unknown[], rest: readonly unknown[], position: Position, path: readonly number[]) => Result<unknown>;\n /** This function gives the result of `fill` (LIST.FILL). */\n readonly fill: (values: readonly unknown[], position: Position, path: readonly number[]) => Result<VexList>;\n}\n\n/** This function gives the list ops of `compile` for the options. It keeps the index of each list that `get` read. */\nexport function listOps(opts: CompileOptions = {}): ListOps {\n const compiler = new Compiler(opts);\n const names = new Map<string, Result<unknown>>();\n return {\n list: (op, list, rest, pos, path) => compiler.listOp(op, list, rest, { pos, env: names }, path),\n array: (op, array, rest, pos, path) => compiler.arrayOp(op, array, rest, { pos, env: names }, path),\n fill: (values, pos, path) => compiler.fill(values, { pos, env: names }, path),\n };\n}\n\nexport function compile(source: Expr | Envelope, opts: CompileOptions = {}): Program {\n // DOC.ENTRY: a document gives its expression first. A document that is not valid gives the error of fromDocument.\n const read = isDocument(source) ? fromDocument(source, opts.domains) : ok(source);\n const expr = read.ok ? read.value : (source as unknown as Expr);\n // EVAL.SHAPE: an expression that is not valid, for example from a newer version of Vex, gives an error before a walk.\n // EVAL.NESTING: a program nested too deep gives an error before the compiler walks it with recursion.\n const shape = read.ok ? shapeError(expr) : read.error.message;\n const deep = shape ?? nestingError(expr);\n // LOOP.SIZE: a step of a loop that can double the size of a list at each step gives an error before a run.\n // STEP.MAX: a program above the highest step of the host gives an error before a run.\n // FIX.MONOTONE: a step of a fixed point without a proof that it moves one way gives an error before a run.\n const bad = deep ?? sizeError(expr, opts) ?? stepError(expr, opts) ?? monotoneError(expr, opts);\n const kind = read.ok ? \"bad-expression\" : read.error.kind;\n const root: Node = bad === undefined ? new Compiler(opts).node(expr, []) : (f) => fail(vexError(kind, bad, { path: [], origin: f.pos.origin, focus: f.pos.focus }));\n const run = (r: RunOptions): Result<unknown> => {\n const { space, origin } = r;\n if (!space.has(origin)) return fail(noKeyError(origin));\n const env = new Map<string, Result<unknown>>(Object.entries(r.vars ?? {}).map(([k, val]) => [k, ok(val)]));\n try {\n return root({ pos: { origin, focus: origin }, env }, { space, trace: r.trace, tables: r.tables });\n } catch (thrown) {\n // A defect in an extension handler or in a test of the interpreter itself. Totality still holds.\n if (isStackOverflow(thrown)) return fail(vexError(\"depth\", DEPTH_MESSAGE, { origin, focus: origin, thrown }));\n return fail(vexError(\"threw\", \"the evaluation threw an exception\", { origin, focus: origin, thrown }));\n }\n };\n return {\n expr,\n run,\n explain: (r) => {\n const sink: TraceSink = { events: [] };\n const result = run({ ...r, trace: sink });\n return { events: sink.events, result };\n },\n };\n}\n\n// The cache of compiled programs: one entry for each expression object or document, for the last options.\nconst CACHE = new WeakMap<Expr | Envelope, { readonly domains: unknown; readonly fns: unknown; readonly extensions: unknown; readonly maxStep: unknown; readonly program: Program }>();\n\nfunction compiled(expr: Expr | Envelope, opts: CompileOptions): Program {\n // V-056: a program that is not an object cannot be a key of the cache. Its compilation gives #VALUE! (EVAL.SHAPE).\n if (typeof expr !== \"object\" || expr === null) return compile(expr, opts);\n const hit = CACHE.get(expr);\n // Without the cache, each evaluation compiles again: the result is the same, so a mutant that removes a hit is\n // equivalent. A false hit changes results, and the tests find it.\n // Stryker disable next-line ConditionalExpression: a missed hit only compiles again\n if (hit !== undefined && hit.domains === opts.domains && hit.fns === opts.fns && hit.extensions === opts.extensions && hit.maxStep === opts.maxStep) return hit.program;\n const program = compile(expr, opts);\n CACHE.set(expr, { domains: opts.domains, fns: opts.fns, extensions: opts.extensions, maxStep: opts.maxStep, program });\n return program;\n}\n\n/** This function evaluates an expression or a document at the origin of a space. It does not throw. */\nexport function evaluate(expr: Expr | Envelope, opts: EvalOptions): Result<unknown> {\n return compiled(expr, opts).run(opts);\n}\n\n/** This function evaluates an expression or a document and records a trace of each node. */\nexport function explain(expr: Expr | Envelope, opts: Omit<EvalOptions, \"trace\">): Trace {\n return compiled(expr, opts).explain(opts);\n}\n\n/** The state of one run that the nodes read: the space, the trace sink and the other spaces. */\ninterface Ctx {\n readonly space: Space;\n readonly trace: TraceSink | undefined;\n readonly tables: Readonly<Record<string, Space>> | undefined;\n}\n\n/** This function gives the axis inside the `where` axes of an axis. */\nconst baseAxis = (a: Axis): Exclude<Axis, { readonly t: \"where\" }> => (a.t === \"where\" ? baseAxis(a.axis) : a);\n\n/** A compiled node: it evaluates in a frame of a run. */\ntype Node = (f: Frame, c: Ctx) => Result<unknown>;\n\n/** This function evaluates the nodes in order. The first error stops it and is the result. */\nfunction allValues(ns: readonly Node[], f: Frame, c: Ctx): Result<Result<unknown>[]> {\n const values: Result<unknown>[] = [];\n for (const n of ns) {\n const r = n(f, c);\n if (!r.ok) return r;\n values.push(r);\n }\n return ok(values);\n}\n\n/** The primitive types of KIND.PRIMITIVE. */\nconst PRIMITIVE_TYPES: readonly PrimitiveKind[] = [\"number\", \"string\", \"boolean\"];\n\n/** The spec of an op without an entry in the op table of a domain with `methods: \"all\"`. */\nconst NO_SPEC: OpSpec<unknown> = Object.freeze({});\n\n/** The function of an op: the receiver comes first, then the arguments. */\ntype OpFn = (self: unknown, ...args: readonly unknown[]) => unknown;\n\n/**\n * A target of an axis: its key, and the error of a test of `where` or of an error item. A target of the axis `list` also\n * has the value of its item and its position as `nth` counts it (AXIS.LIST.ITEM, AXIS.LIST.INDEX).\n */\ninterface Target {\n readonly key: string;\n readonly test?: Result<unknown>;\n readonly value?: unknown;\n readonly index?: number;\n}\n\n/** The targets of an axis from a frame, or the error of the axis. */\ntype Targets = (f: Frame, c: Ctx) => Result<readonly Target[]>;\n\n/**\n * This function adds the names `as` of a loop to the names of a body or of a step. The first name holds the value of\n * the item, and the second its index (AXIS.LIST.ITEM, AXIS.LIST.INDEX). A loop without `as` keeps its names.\n */\nfunction withItem(env: Env, as: ItemNames | undefined, t: Target): Env {\n // A scope with one name reads only the first value.\n return as === undefined ? env : new Scope(env, as, [ok(t.value), ok(t.index)]);\n}\n\n/** The static facts of a node for its trace events. */\ninterface Info {\n readonly path: readonly number[];\n readonly tag: Expr[\"tag\"];\n readonly label: string;\n}\n\nclass Compiler {\n readonly #domains: readonly AnyDomain[];\n readonly #fns: Readonly<Record<string, FreeFn>> | undefined;\n readonly #extensions: Readonly<Record<string, ExtHandler>> | undefined;\n /** The index of the keys of each list that `get` read (LIST.GET). A list does not change, so its index stays right. */\n readonly #keyIndex = new WeakMap<VexList, KeyIndex>();\n /**\n * The domains that can accept a value of each primitive type, in order (KIND.PRIMITIVE). These are the domains of\n * that type and the domains without a primitive type.\n */\n readonly #ofType = new Map<string, readonly AnyDomain[]>();\n /** The domains without a primitive type. Only they can accept a value of another type, for example an object. */\n readonly #open: readonly AnyDomain[];\n /** The slot of the column of each `fix` around the node that the compiler reads (FIX.LAST). A symbol is no name of the program. */\n #columns: ReadonlyMap<string, symbol> = new Map();\n\n constructor(opts: CompileOptions) {\n // Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain matches no value\n this.#domains = opts.domains ?? [];\n this.#fns = opts.fns;\n this.#extensions = opts.extensions;\n this.#open = this.#domains.filter((d) => d.primitive === undefined);\n for (const t of PRIMITIVE_TYPES) this.#ofType.set(t, this.#domains.filter((d) => d.primitive === undefined || d.primitive === t));\n }\n\n #err(kind: ErrorKind, message: string, f: Frame, path: readonly number[], extra: { op?: string; causes?: readonly VexError[]; thrown?: unknown } = {}): Result<never> {\n return fail(vexError(kind, message, { path, origin: f.pos.origin, focus: f.pos.focus, ...extra }));\n }\n\n /** This method gives the error of a text at a node (`errorAt`). */\n #at(text: ErrorText, f: Frame, path: readonly number[], extra?: ErrorExtra): Result<never> {\n return fail(errorAt(text, f.pos, path, extra));\n }\n\n /** This method gives the error of a position of an array without a value (LIST.ARRAY), at a node. */\n #missing(f: Frame, path: readonly number[]): (message: string) => VexError {\n return (message) => vexError(\"missing-field\", message, { path, origin: f.pos.origin, focus: f.pos.focus });\n }\n\n /** This method gives the list of `fill(n, value)` (LIST.FILL). A count that is not a whole number from 0 to 100000 gives `#VALUE!`. */\n fill(values: readonly unknown[], f: Frame, path: readonly number[]): Result<VexList> {\n const [n, value] = values;\n if (!isFillCount(n)) return this.#err(\"kind-mismatch\", `\"fill\" needs a whole number from 0 to 100000, not ${describeType(n)}`, f, path, { op: \"fill\" });\n if (value === undefined) return this.#err(\"bad-expression\", '\"fill\" needs argument 2', f, path, { op: \"fill\" });\n // Each item of the list has the value, so the list has the shape of LIST.SHAPE.\n const list = fillList(n, value);\n CHECKED.add(list);\n return ok(list);\n }\n\n #emit(c: Ctx, info: Info, f: Frame, result: Result<unknown>, reads?: readonly Read[]): Result<unknown> {\n if (c.trace !== undefined) {\n const event: TraceEvent = {\n path: info.path,\n tag: info.tag,\n label: info.label,\n origin: f.pos.origin,\n focus: f.pos.focus,\n ...(reads === undefined ? {} : { reads }),\n result,\n };\n c.trace.events.push(event);\n }\n return result;\n }\n\n /** This method compiles the expression `e` at the position `path` of the tree. */\n node(e: Expr, path: readonly number[]): Node {\n const info: Info = { path, tag: e.tag, label: labelOf(e) };\n switch (e.tag) {\n case \"lit\": {\n const r = ok(e.value);\n return (f, c) => this.#emit(c, info, f, r);\n }\n case \"ref\":\n return this.#ref(e, info);\n case \"var\": {\n const name = e.name;\n return (f, c) => {\n const bound = f.env.get(name);\n // A function is not a value (FN.VALUE).\n if (bound?.ok === true && bound.value instanceof Closure) return this.#emit(c, info, f, this.#at(errorText.functionValue(name), f, path));\n return this.#emit(c, info, f, bound ?? this.#at(errorText.unbound(name), f, path));\n };\n }\n case \"fn\":\n return this.#fn(e, path);\n case \"call\":\n return this.#callFn(e, info);\n case \"let\": {\n const names = Object.keys(e.bind);\n const binds = this.#nodes(Object.values(e.bind), path);\n const body = this.node(e.body, [...path, binds.length]);\n return (f, c) => {\n // Each binding evaluates with the outer names, so a binding does not see the other bindings.\n const values: Result<unknown>[] = [];\n for (const n of binds) values.push(n(f, c));\n return this.#emit(c, info, f, body({ pos: f.pos, env: new Scope(f.env, names, values) }, c));\n };\n }\n case \"rec\": {\n const names = Object.keys(e.fields);\n const fields = this.#nodes(Object.values(e.fields), path);\n return (f, c) => {\n const values = this.#all(fields, f, c, path, \"fields\");\n if (!values.ok) return this.#emit(c, info, f, values);\n // Object.fromEntries gives an own field for each name, also for \"__proto__\" (V-062).\n const out = Object.fromEntries(names.map((n, i) => [n, values.value[i]]));\n return this.#emit(c, info, f, ok(Object.freeze(out)));\n };\n }\n case \"app\":\n return isSpecialForm(e.op) ? this.#special(e.op, this.#nodes(e.args, path), info) : this.#app(e.op, this.#nodes(e.args, path), info);\n case \"each\":\n return this.#each(e, info);\n case \"fold\":\n return this.#fold(e, info);\n case \"iterate\":\n return this.#iterate(e, info);\n case \"fix\":\n return this.#fix(e, info);\n case \"last\":\n return this.#last(e, info);\n case \"ext\": {\n const extensions = this.#extensions ?? {};\n const handler = Object.hasOwn(extensions, e.kind) ? extensions[e.kind] : undefined;\n const { kind, data } = e;\n if (handler === undefined) return (f, c) => this.#emit(c, info, f, this.#at(errorText.noHandler(kind), f, path));\n return (f, c) =>\n this.#emit(c, info, f, this.#locate(this.#guard(() => handler(data, { space: c.space, position: f.pos, path }), f, path, kind), f, path));\n }\n }\n }\n\n #nodes(es: readonly Expr[], path: readonly number[]): readonly Node[] {\n return es.map((x, i) => this.node(x, [...path, i]));\n }\n\n /**\n * This method compiles a function (FN.BIND). Its value is a closure: the parameters, the body, and the names of the\n * place of its binding. A binding of `let` does not see the other bindings, so a function cannot call itself.\n */\n #fn(e: ExprOf<\"fn\">, path: readonly number[]): Node {\n const body = this.node(e.body, [...path, 0]);\n return (f) => ok(new Closure(e.params, body, f.env));\n }\n\n /**\n * This method compiles a call (FN.CALL, FN.ARGS). Each parameter gets the result of its argument at the call, so an\n * argument that fails has an effect only where the body reads it. The body evaluates at the position of the call.\n */\n #callFn(e: ExprOf<\"call\">, info: Info): Node {\n const { path } = info;\n const args = this.#nodes(e.args, path);\n return (f, c) => {\n const bound = f.env.get(e.fn);\n if (bound === undefined) return this.#emit(c, info, f, this.#at(errorText.noFunction(e.fn), f, path));\n if (!bound.ok) return this.#emit(c, info, f, bound);\n const callee = bound.value;\n if (!(callee instanceof Closure)) return this.#emit(c, info, f, this.#at(errorText.notFunction(e.fn), f, path));\n if (callee.params.length !== args.length) return this.#emit(c, info, f, this.#at(errorText.arity(e.fn, callee.params.length, args.length), f, path));\n const values: Result<unknown>[] = [];\n for (const n of args) values.push(n(f, c));\n return this.#emit(c, info, f, callee.body({ pos: f.pos, env: new Scope(callee.env, callee.params, values) }, c));\n };\n }\n\n /** This method gives an error of a handler the path, the origin and the focus of its node, if it has no origin. */\n #locate(r: Result<unknown>, f: Frame, path: readonly number[]): Result<unknown> {\n if (r.ok || r.error.origin !== undefined) return r;\n return fail({ ...r.error, path, origin: f.pos.origin, focus: f.pos.focus });\n }\n\n #guard(run: () => Result<unknown>, f: Frame, path: readonly number[], op: string): Result<unknown> {\n try {\n return run();\n } catch (thrown) {\n return this.#threw(thrown, errorText.threw(op), f, path);\n }\n }\n\n /** This method gives the error of an exception: `#DEPTH!` for a full call stack, and `#CALC!` for each other exception. */\n #threw(thrown: unknown, text: ErrorText, f: Frame, path: readonly number[]): Result<never> {\n return this.#at(isStackOverflow(thrown) ? { ...text, kind: \"depth\", message: DEPTH_MESSAGE } : text, f, path, { thrown });\n }\n\n /**\n * This method compiles an address. Its function gives the key where the address points. The expressions of the\n * computed moves evaluate first, at the position of the node, and their child indexes start at `first`. An error of\n * an expression keeps its path, and an error of a move gets the path of the node.\n */\n #address(at: Addr, path: readonly number[], first: number): (f: Frame, c: Ctx) => Result<string> {\n const nodes = addrExprs(at).map((x, i) => this.node(x, [...path, first + i]));\n const moved = (r: Result<string>): Result<string> => (r.ok ? r : fail({ ...r.error, path }));\n if (nodes.length === 0) return (f, c) => moved(resolveAddr(c.space, f.pos, at as readonly FixedMove[]));\n return (f, c) => {\n const values: unknown[] = [];\n for (const n of nodes) {\n const r = n(f, c);\n if (!r.ok) return r;\n values.push(r.value);\n }\n const fixed = fixAddr(at, values, f.pos);\n return fixed.ok ? moved(resolveAddr(c.space, f.pos, fixed.value)) : moved(fixed);\n };\n }\n\n #ref(e: ExprOf<\"ref\">, info: Info): Node {\n const { path } = info;\n const segs = e.path;\n const at = e.at ?? [];\n const address = this.#address(at, path, 0);\n const label = segs.join(\".\");\n const steps = segs.map((seg, i) => ({ seg, where: segs.slice(0, i + 1).join(\".\"), valid: isFieldName(seg) }));\n return (f, c) => {\n let key = f.pos.focus;\n // The empty address resolves to the focus, so this fast path changes no result.\n // Stryker disable next-line ConditionalExpression,EqualityOperator: resolveAddr of [] gives the focus too\n if (at.length > 0) {\n const where = address(f, c);\n if (!where.ok) return this.#emit(c, info, f, where);\n key = where.value;\n }\n const failed = (r: Result<unknown>): Result<unknown> => this.#emit(c, info, f, r, [{ key, path: segs, ok: false }]);\n const missing = (where: string): Result<unknown> => failed(this.#at(errorText.missing(key, where), f, path));\n let value: unknown = c.space.get(key);\n if (value === undefined || value === null) return missing(label === \"\" ? \"(record)\" : label);\n for (const { seg, where, valid } of steps) {\n if ((typeof value !== \"object\" && typeof value !== \"function\") || !valid) return missing(where);\n try {\n value = Reflect.get(value, seg);\n } catch (thrown) {\n return failed(this.#threw(thrown, errorText.readThrew(key, where), f, path));\n }\n if (value === undefined || value === null) return missing(where);\n }\n return this.#emit(c, info, f, ok(value), [{ key, path: segs, ok: true }]);\n };\n }\n\n /** This method evaluates nodes applicatively. One failure stays as it is. Two or more give `#ARGS`. */\n #all(nodes: readonly Node[], f: Frame, c: Ctx, path: readonly number[], what: string): Result<readonly unknown[]> {\n const values: unknown[] = [];\n let first: VexError | undefined;\n let errors: VexError[] | undefined;\n for (const n of nodes) {\n const r = n(f, c);\n if (r.ok) values.push(r.value);\n else if (first === undefined) first = r.error;\n else (errors ??= [first]).push(r.error);\n }\n if (first === undefined) return ok(values);\n // A #DEPTH! argument is the result, so #ARGS does not wrap it, and ifError cannot hide it.\n const depth = [first, ...(errors ?? [])].find(isDepthError);\n if (depth !== undefined) return fail(depth);\n return errors === undefined ? fail(first) : this.#at(errorText.args(errors.length, what), f, path, { causes: errors });\n }\n\n #each(e: ExprOf<\"each\">, info: Info): Node {\n const { path } = info;\n const at = e.at ?? [];\n const counter = { next: 1 };\n const targets = this.#targets(e.axis, path, counter);\n const body = this.node(e.body, [...path, 0]);\n const address = this.#address(at, path, counter.next);\n return (f, c) => {\n // An axis with an address finds its targets from the key of the address. The origin does not change.\n let from = f;\n // Stryker disable next-line ConditionalExpression,EqualityOperator: resolveAddr of [] gives the focus too\n if (at.length > 0) {\n const where = address(f, c);\n if (!where.ok) return this.#emit(c, info, f, where);\n from = { pos: { origin: f.pos.origin, focus: where.value }, env: f.env };\n }\n // The axis table moves the evaluation to the space of its table, where the origin of this space is not a key.\n // Thus there the origin is the target, and a value of this space goes in through a variable.\n const base = baseAxis(e.axis);\n const axisCtx = this.#axisCtx(base, f, c, path);\n if (!axisCtx.ok) return this.#emit(c, info, f, axisCtx);\n const inner = axisCtx.value;\n const ts = targets(from, inner);\n if (!ts.ok) return this.#emit(c, info, f, ts);\n const items: ListItem[] = ts.value.map((t) => {\n const { key, test } = t;\n if (test !== undefined && !test.ok) return { key, result: test };\n return { key, result: body({ pos: { origin: base.t === \"table\" ? key : f.pos.origin, focus: key }, env: withItem(f.env, e.as, t) }, inner) };\n });\n return this.#emit(c, info, f, ok(vexList(items)));\n };\n }\n\n /**\n * This method compiles the names of a loop: `init` at the indexes from 0, and `step` after them (LOOP.NAMES). Its\n * functions give the first values, and the values after one step. The first error stops each of them.\n */\n #names(e: ExprOf<\"fold\"> | ExprOf<\"iterate\">, path: readonly number[]): {\n readonly first: (f: Frame, c: Ctx) => Result<Scope>;\n readonly next: (f: Frame, c: Ctx, scope: Scope) => Result<Scope>;\n } {\n const names = Object.keys(e.init);\n const inits = this.#nodes(Object.values(e.init), path);\n const steps = Object.values(e.step).map((x, i) => this.node(x, [...path, inits.length + i]));\n // Each name of a step is a name of init (LOOP.NAMES), so a step changes the value at a position of the scope.\n const at = Object.keys(e.step).map((name) => names.indexOf(name));\n return {\n first: (f, c) => {\n const values = allValues(inits, f, c);\n return values.ok ? ok(new Scope(f.env, names, values.value)) : values;\n },\n // Each value of a step reads the values before the step, so the names change only after all the values. The new\n // names come from `scope`, the scope of the loop, because the frame can have more names, for example the names of\n // an item (AXIS.LIST.SCOPE).\n next: (f, c, scope) => {\n const values = allValues(steps, f, c);\n return values.ok ? ok(scope.with(at, values.value)) : values;\n },\n };\n }\n\n /**\n * This method compiles a fold (FOLD.ORDER, FOLD.ERROR). `init` evaluates at the node, then the address and the\n * targets. A step evaluates at each target in order. `result` evaluates at the node with the last values.\n */\n #fold(e: ExprOf<\"fold\">, info: Info): Node {\n const { path } = info;\n const at = e.at ?? [];\n const names = this.#names(e, path);\n const counter = { next: Object.keys(e.init).length + Object.keys(e.step).length };\n const targets = this.#targets(e.axis, path, counter);\n const address = this.#address(at, path, counter.next);\n const result = this.node(e.result, [...path, counter.next + addrExprs(at).length]);\n const base = baseAxis(e.axis);\n return (f, c) => {\n const first = names.first(f, c);\n if (!first.ok) return this.#emit(c, info, f, first);\n let env = first.value;\n let from = f;\n // Stryker disable next-line ConditionalExpression,EqualityOperator: resolveAddr of [] gives the focus too\n if (at.length > 0) {\n const where = address(f, c);\n if (!where.ok) return this.#emit(c, info, f, where);\n from = { pos: { origin: f.pos.origin, focus: where.value }, env: f.env };\n }\n const axisCtx = this.#axisCtx(base, f, c, path);\n if (!axisCtx.ok) return this.#emit(c, info, f, axisCtx);\n const inner = axisCtx.value;\n const ts = targets(from, inner);\n if (!ts.ok) return this.#emit(c, info, f, ts);\n for (const t of ts.value) {\n const { key, test } = t;\n if (test !== undefined && !test.ok) return this.#emit(c, info, f, test);\n const after = names.next({ pos: { origin: base.t === \"table\" ? key : f.pos.origin, focus: key }, env: withItem(env, e.as, t) }, inner, env);\n if (!after.ok) return this.#emit(c, info, f, after);\n env = after.value;\n }\n return this.#emit(c, info, f, result({ pos: f.pos, env }, c));\n };\n }\n\n /**\n * This method compiles an iteration (ITERATE.LIMIT, ITERATE.UNTIL, ITERATE.ERROR). The test `until` evaluates before\n * each step and after the last step. `result` evaluates with the last values.\n */\n /**\n * This method compiles a fixed-point column (FIX.ROUNDS). Each round evaluates each row from the column of the last\n * round, so the order of the rows has no effect. The first round without a change ends the rounds.\n */\n #fix(e: ExprOf<\"fix\">, info: Info): Node {\n const { path } = info;\n const { name, join } = e;\n const init = this.node(e.init, [...path, 0]);\n const slot = Symbol(name);\n const outer = this.#columns;\n this.#columns = new Map(outer).set(name, slot);\n const step = this.node(e.step, [...path, 1]);\n this.#columns = outer;\n return (f, c) => {\n const { keys } = c.space;\n const first = this.#rows(e, init, f, f.env, c, path);\n if (!first.ok) return this.#emit(c, info, f, first);\n let column = first.value;\n this.#round(c, info, f, 0, keys, column);\n const limit = fixRounds(keys.length);\n for (let round = 1; round <= limit; round++) {\n const stepped = this.#rows(e, step, f, new Scope(f.env, [slot], [ok(column)]), c, path);\n if (!stepped.ok) return this.#emit(c, info, f, stepped);\n const next = new Map<string, unknown>();\n const changed: string[] = [];\n for (const key of keys) {\n const old = column.get(key);\n const value = joinValues(join, old, stepped.value.get(key));\n if (value !== old) changed.push(key);\n next.set(key, value);\n }\n this.#round(c, info, f, round, changed, next);\n if (changed.length === 0) return this.#emit(c, info, f, this.#rowOf(name, column, f, path));\n column = next;\n }\n return this.#emit(c, info, f, this.#at(errorText.fixLimit(name, limit), f, path));\n };\n }\n\n /** This method evaluates a node at each row (FIX.ERROR). Each row runs, also after an error, so the rule of the errors has all of them. */\n #rows(e: ExprOf<\"fix\">, node: Node, f: Frame, env: Env, c: Ctx, path: readonly number[]): Result<ReadonlyMap<string, unknown>> {\n const out = new Map<string, unknown>();\n const errors: VexError[] = [];\n for (const key of c.space.keys) {\n const frame: Frame = { pos: { origin: f.pos.origin, focus: key }, env };\n const r = node(frame, c);\n const wrong = r.ok ? fixValueError(e.name, e.join, r.value) : undefined;\n if (!r.ok) errors.push(r.error);\n else if (wrong !== undefined) errors.push(errorAt(wrong, frame.pos, path));\n else out.set(key, r.value);\n }\n if (errors.length === 0) return ok(out);\n const worst = worstRow(errors);\n return worst === undefined ? this.#at(errorText.args(errors.length, \"rows\"), f, path, { causes: errors }) : fail(worst);\n }\n\n /** This method adds a round to the trace: the count of the round, the rows that it changed and the column (FIX.TRACE). */\n #round(c: Ctx, info: Info, f: Frame, round: number, changed: readonly string[], column: ReadonlyMap<string, unknown>): void {\n if (c.trace === undefined) return;\n const items = [...column].map(([key, value]): ListItem => ({ key, result: ok(value) }));\n c.trace.events.push({\n path: info.path,\n tag: info.tag,\n label: `${info.label}: round ${String(round)}, ${String(changed.length)} rows changed`,\n origin: f.pos.origin,\n focus: f.pos.focus,\n round: { index: round, changed },\n result: ok(vexList(items)),\n });\n }\n\n /** This method gives the value of the row of the focus. The focus of an item of the axis `list` can be no row (FIX.LAST). */\n #rowOf(name: string, column: ReadonlyMap<string, unknown>, f: Frame, path: readonly number[]): Result<unknown> {\n const value = column.get(f.pos.focus);\n return value === undefined ? this.#at(errorText.lastKey(name, f.pos.focus), f, path) : ok(value);\n }\n\n /** This method compiles a read of the last round at the focus (FIX.LAST). The check gives each read a `fix`. */\n #last(e: ExprOf<\"last\">, info: Info): Node {\n const { path } = info;\n const slot = this.#columns.get(e.name) as symbol;\n return (f, c) => {\n const column = f.env.get(slot) as { readonly value: ReadonlyMap<string, unknown> };\n return this.#emit(c, info, f, this.#rowOf(e.name, column.value, f, path));\n };\n }\n\n #iterate(e: ExprOf<\"iterate\">, info: Info): Node {\n const { path } = info;\n const names = this.#names(e, path);\n const counter = { next: Object.keys(e.init).length + Object.keys(e.step).length };\n const axis = limitAxis(e);\n const size = axis === undefined ? undefined : this.#size(axis, path, counter);\n const untilAt = counter.next;\n const untilPath = [...path, untilAt];\n const until = e.until === undefined ? undefined : this.node(e.until, untilPath);\n const result = this.node(e.result, [...path, untilAt + (until === undefined ? 0 : 1)]);\n const fixed = e.limit as number;\n return (f, c) => {\n const first = names.first(f, c);\n if (!first.ok) return this.#emit(c, info, f, first);\n let env = first.value;\n let limit = fixed;\n // The data limit evaluates at the node, after the first values and before the steps (ITERATE.LIMIT.DATA).\n if (size !== undefined) {\n const counted = size(f, c);\n if (!counted.ok) return this.#emit(c, info, f, counted);\n limit = counted.value;\n }\n for (let k = 0; ; k++) {\n const frame: Frame = { pos: f.pos, env };\n if (until !== undefined) {\n const t = until(frame, c);\n if (!t.ok) return this.#emit(c, info, f, t);\n if (t.value === true) break;\n if (t.value !== false) return this.#emit(c, info, f, this.#at(errorText.untilKind(t.value), f, untilPath));\n }\n if (k === limit) {\n if (until !== undefined) return this.#emit(c, info, f, this.#at(errorText.limit(limit), f, path));\n break;\n }\n const after = names.next(frame, c, env);\n if (!after.ok) return this.#emit(c, info, f, after);\n env = after.value;\n }\n return this.#emit(c, info, f, result({ pos: f.pos, env }, c));\n };\n }\n\n /**\n * This method compiles a data limit: the number of targets of an axis (ITERATE.LIMIT.DATA). Each failure of the axis, of\n * a test or of an item, and a count above the cap, is one error (ITERATE.LIMIT.ERROR).\n */\n #size(axis: Axis, path: readonly number[], counter: { next: number }): (f: Frame, c: Ctx) => Result<number> {\n const targets = this.#targets(axis, path, counter);\n const base = baseAxis(axis);\n const invalid = (f: Frame, cause: VexError): Result<never> => fail(limitError(cause, { path, origin: f.pos.origin, focus: f.pos.focus }));\n return (f, c) => {\n const inner = this.#axisCtx(base, f, c, path);\n if (!inner.ok) return invalid(f, inner.error);\n const ts = targets(f, inner.value);\n if (!ts.ok) return invalid(f, ts.error);\n const cause = worstError(ts.value.flatMap(({ test }) => (test === undefined || test.ok ? [] : test.error)));\n if (cause !== undefined) return invalid(f, cause);\n const count = ts.value.length;\n return count > MAX_ITERATIONS ? this.#err(\"limit\", overLimitMessage(count), f, path) : ok(count);\n };\n }\n\n /** This method gives the context of an axis: the space of its table for the axis `table`, or `c` (AXIS.TABLE). */\n #axisCtx(base: Axis, f: Frame, c: Ctx, path: readonly number[]): Result<Ctx> {\n if (base.t !== \"table\") return ok(c);\n const space = c.tables !== undefined && Object.hasOwn(c.tables, base.name) ? c.tables[base.name] : undefined;\n return space === undefined ? this.#at(errorText.noTable(base.name), f, path) : ok({ ...c, space });\n }\n\n /** This method compiles the targets of an axis. For `where`, a failed test keeps the target with its error. */\n #targets(a: Axis, path: readonly number[], counter: { next: number }): Targets {\n if (a.t === \"table\") return (_f, c) => ok(c.space.keys.map((key) => ({ key })));\n const base = a.t === \"reverse\" ? a.axis : a;\n if (base.t === \"list\") return this.#listTargets(base.list, a.t === \"reverse\", path, counter);\n if (a.t !== \"where\") {\n return (f, c) => {\n const keys = axisTargets(c.space, f.pos, a);\n return keys.ok ? ok(keys.value.map((key) => ({ key }))) : fail({ ...keys.error, path });\n };\n }\n const inner = this.#targets(a.axis, path, counter);\n const testPath = [...path, counter.next++];\n const test = this.node(a.test, testPath);\n // In the space of the axis table, the origin of the test is the target, as for the body.\n const sameOrigin = baseAxis(a).t === \"table\";\n return (f, c) => {\n const ts = inner(f, c);\n if (!ts.ok) return ts;\n const out: Target[] = [];\n for (const t of ts.value) {\n if (t.test !== undefined && !t.test.ok) {\n out.push(t);\n continue;\n }\n const at: Frame = { pos: { origin: sameOrigin ? t.key : f.pos.origin, focus: t.key }, env: f.env };\n const r = test(at, c);\n if (!r.ok) out.push({ key: t.key, test: r });\n // The target keeps the value and the index of its item (AXIS.LIST.ITEM).\n else if (r.value === true) out.push(t);\n else if (r.value !== false) {\n out.push({ key: t.key, test: this.#at(errorText.whereKind(r.value), at, testPath) });\n }\n }\n return ok(out);\n };\n }\n\n /**\n * This method compiles the targets of the axis list (AXIS.LIST): the keys of the items of a list, in its order. The\n * expression evaluates at the key of the address. An error item keeps its target with its error.\n */\n #listTargets(list: Expr, reverse: boolean, path: readonly number[], counter: { next: number }): Targets {\n const node = this.node(list, [...path, counter.next++]);\n return (f, c) => {\n const r = node(f, c);\n if (!r.ok) return r;\n // LIST.ARRAY: an array is a list with the positions as keys.\n const listed = asList(r.value, this.#missing(f, path));\n if (listed === undefined) return this.#at(errorText.axisList(r.value), f, path);\n // The index counts the items with a value, as nth does: nth skips the error items (LIST.LENIENT).\n let index = 0;\n const items = listed.items.map(({ key, result }): Target => (result.ok ? { key, value: result.value, index: index++ } : { key, test: result }));\n return ok(reverse ? items.toReversed() : items);\n };\n }\n\n #app(op: string, args: readonly Node[], info: Info): Node {\n const { path } = info;\n const listOp = isListOp(op) ? op : undefined;\n const fn = this.#fns !== undefined && Object.hasOwn(this.#fns, op) ? this.#fns[op] : undefined;\n // A name that cannot be an op name has no op, also with an own entry in an op table (resolveOp).\n const named = isOpName(op);\n return (f, c) => {\n const all = this.#all(args, f, c, path, \"arguments\");\n if (!all.ok) return this.#emit(c, info, f, all);\n const values = all.value;\n const self = values[0];\n if (listOp !== undefined && isVexList(self)) return this.#emit(c, info, f, this.listOp(listOp, self, values.slice(1), f, path));\n let accepted: AnyDomain | undefined;\n // Without arguments, the receiver is undefined, and no domain of a test accepts it.\n // Stryker disable next-line ConditionalExpression,EqualityOperator: the loop finds no domain for undefined\n if (values.length > 0) {\n for (const d of this.#domains) {\n if (!safeIs(d, self)) continue;\n accepted ??= d;\n // The rules of resolveOp, without a closure for each call: the function of the spec, or a method of the\n // receiver for a declared op without a function, or for each op of a domain with `methods: \"all\"`.\n const spec = named && Object.hasOwn(d.ops, op) ? (d.ops[op] as OpSpec<unknown>) : undefined;\n if (spec?.fn !== undefined) return this.#emit(c, info, f, this.#call(d, spec, spec.fn as OpFn, self, op, values.slice(1), f, path));\n const method = spec !== undefined || d.methods === \"all\" ? findMethod(self, op) : undefined;\n if (method !== undefined) return this.#emit(c, info, f, this.#call(d, spec ?? NO_SPEC, (receiver, ...given) => method.apply(receiver, [...given]), self, op, values.slice(1), f, path));\n }\n }\n if (fn !== undefined) return this.#emit(c, info, f, this.#checkResult(this.#invoke(() => fn(...values), op, f, path), f, path, op));\n // LIST.ARRAY and LIST.FILL come after the domains and the functions of the host, so each of their results stays.\n if (listOp !== undefined && Array.isArray(self)) return this.#emit(c, info, f, this.arrayOp(listOp, self, values.slice(1), f, path));\n if (op === \"fill\") return this.#emit(c, info, f, this.fill(values, f, path));\n if (accepted !== undefined) return this.#emit(c, info, f, this.#at(errorText.domainNoOp(accepted.name, op), f, path));\n if (values.length === 0) return this.#emit(c, info, f, this.#at(errorText.noOp(op), f, path));\n return this.#emit(c, info, f, this.#at(errorText.noDomain(op, self), f, path));\n };\n }\n\n #special(op: SpecialForm, args: readonly Node[], info: Info): Node {\n const { path } = info;\n const arg = (i: number, f: Frame, c: Ctx): Result<unknown> => {\n const n = args[i];\n return n === undefined ? this.#at(errorText.needsArgument(op, i), f, path) : n(f, c);\n };\n const bool = (i: number, f: Frame, c: Ctx): Result<boolean> => {\n const r = arg(i, f, c);\n if (!r.ok) return r;\n return typeof r.value === \"boolean\" ? ok(r.value) : this.#at(errorText.notBoolean(op, i, r.value), f, path);\n };\n switch (op) {\n case \"if\":\n return (f, c) => {\n const cond = bool(0, f, c);\n return this.#emit(c, info, f, cond.ok ? arg(cond.value ? 1 : 2, f, c) : cond);\n };\n case \"and\":\n case \"or\": {\n const stop = op === \"or\";\n return (f, c) => {\n if (args.length === 0) return this.#emit(c, info, f, this.#at(errorText.needsArguments(op), f, path));\n for (let i = 0; i < args.length; i++) {\n const b = bool(i, f, c);\n if (!b.ok) return this.#emit(c, info, f, b);\n if (b.value === stop) return this.#emit(c, info, f, ok(b.value));\n }\n return this.#emit(c, info, f, ok(!stop));\n };\n }\n case \"ifError\":\n return (f, c) => {\n const first = arg(0, f, c);\n // EVAL.DEPTH: ifError does not hide #DEPTH!, because the engine, not the data, failed.\n return this.#emit(c, info, f, first.ok || isDepthError(first.error) ? first : arg(1, f, c));\n };\n }\n }\n\n /** This method starts an op that resolveOp found, for example a method of the receiver. */\n #callResolved(op: ResolvedOp, self: unknown, name: string, rest: readonly unknown[], f: Frame, path: readonly number[]): Result<unknown> {\n return this.#call(op.domain, op.spec, (_self, ...args) => op.call(args), self, name, rest, f, path);\n }\n\n /**\n * This method starts the op `name` of the domain `domain` with the receiver `self` and the arguments `rest`. It lifts\n * the numbers, checks the arguments and checks the result.\n */\n #call(domain: AnyDomain, spec: OpSpec<unknown>, run: OpFn, self: unknown, name: string, rest: readonly unknown[], f: Frame, path: readonly number[]): Result<unknown> {\n const lift = spec.liftScalar;\n const from = domain.fromScalar;\n let callArgs: readonly unknown[] = rest;\n if (lift && from !== undefined) {\n const lifted = this.#invoke(() => rest.map((a, i): unknown => (typeof a === \"number\" && liftsAt(lift, i) ? from(a) : a)), `${domain.name}.fromScalar`, f, path);\n if (!lifted.ok) return lifted;\n callArgs = lifted.value as readonly unknown[];\n }\n if (spec.params !== undefined) {\n for (let i = 0; i < callArgs.length; i++) {\n const kind = spec.params[i] ?? \"any\";\n if (!matchesKind(kind, callArgs[i], domain)) return this.#at(errorText.badParam(name, i, callArgs[i], kind, domain.name), f, path);\n }\n }\n let value: unknown;\n try {\n value = run(self, ...callArgs);\n } catch (thrown) {\n return this.#threw(thrown, errorText.threw(name), f, path);\n }\n return this.#checkResult(ok(value), f, path, name);\n }\n\n #invoke(run: () => unknown, op: string, f: Frame, path: readonly number[]): Result<unknown> {\n try {\n return ok(run());\n } catch (thrown) {\n return this.#threw(thrown, errorText.threw(op), f, path);\n }\n }\n\n /**\n * This method gives the first domain that accepts a value. It starts only the tests of the domains without a primitive\n * type: a domain of the type of the value accepts it (KIND.PRIMITIVE).\n */\n #domainOf(value: unknown): AnyDomain | undefined {\n const candidates = this.#ofType.get(typeof value) ?? this.#open;\n for (const d of candidates) if (d.primitive !== undefined || testIs(d, value)) return d;\n return undefined;\n }\n\n /** This method checks the value that an op gave: no `undefined`, finite numbers, and valid domain values. */\n #checkResult(r: Result<unknown>, f: Frame, path: readonly number[], op: string): Result<unknown> {\n if (!r.ok) return r;\n const value = r.value;\n if (value === undefined || value === null) return this.#at(errorText.noValue(op), f, path);\n if (typeof value === \"number\" && !Number.isFinite(value)) return this.#at(errorText.notFinite(op, value), f, path);\n const d = this.#domainOf(value);\n if (d?.valid !== undefined) {\n let valid: boolean;\n try {\n valid = d.valid(value);\n } catch (thrown) {\n return this.#threw(thrown, errorText.validThrew(op, d.name), f, path);\n }\n if (!valid) return this.#at(errorText.invalid(op, d.name), f, path);\n }\n return r;\n }\n\n /** This method gives the result of a list op on an array (LIST.ARRAY): the list op on the list of its items. */\n arrayOp(op: ListOp, array: readonly unknown[], rest: readonly unknown[], f: Frame, path: readonly number[]): Result<unknown> {\n return this.listOp(op, listOfArray(array, this.#missing(f, path)), rest, f, path);\n }\n\n listOp(op: ListOp, list: VexList, rest: readonly unknown[], f: Frame, path: readonly number[]): Result<unknown> {\n // The options come after the second argument of an op with one, for example the count of take.\n const optsArg = op === \"setNth\" ? rest[2] : WITH_ARGUMENT.has(op) ? rest[1] : rest[0];\n const strict = (optsArg as ListOptions | null | undefined)?.strict === true;\n if (op === \"get\") return this.#get(list, rest[0], strict, f, path);\n if (op === \"group\") return this.#group(list, rest[0], strict, f, path);\n const good = goodItems(list, strict);\n if (!good.ok) return good;\n const okItems = good.value;\n const okValues: unknown[] = [];\n for (const it of okItems) okValues.push(valueOf(it));\n const numbers = (): Result<readonly number[]> => {\n const bad = okValues.find((x) => typeof x !== \"number\");\n return bad === undefined ? ok(okValues as readonly number[]) : this.#at(errorText.needsItems(op, \"numbers\", bad), f, path);\n };\n const booleans = (): Result<readonly boolean[]> => {\n const bad = okValues.find((x) => typeof x !== \"boolean\");\n return bad === undefined ? ok(okValues as readonly boolean[]) : this.#at(errorText.needsItems(op, \"booleans\", bad), f, path);\n };\n const empty = (): Result<never> => this.#at(errorText.empty(op), f, path);\n // A count or a position of take, drop and nth is a whole number from 0.\n const whole = (): Result<number> => {\n const n = rest[0] as number;\n return Number.isSafeInteger(n) && n >= 0 ? ok(n) : this.#err(\"kind-mismatch\", `\"${op}\" needs a whole number from 0, not ${describeType(n)}`, f, path, { op });\n };\n // The second list of append and without follows the rules of the first list (LIST.BUILD).\n const other = (): Result<readonly ListItem[]> => {\n const second = asList(rest[0], this.#missing(f, path));\n return second !== undefined ? goodItems(second, strict) : this.#err(\"kind-mismatch\", `\"${op}\" needs a list as its second argument, not a ${describeType(rest[0])}`, f, path, { op });\n };\n switch (op) {\n case \"sortBy\":\n return this.#sortBy(okItems, okValues, optsArg, f, path);\n case \"take\":\n case \"drop\": {\n const n = whole();\n if (!n.ok) return n;\n return ok(checkedList(op === \"take\" ? okItems.slice(0, n.value) : okItems.slice(n.value)));\n }\n case \"append\": {\n const more = other();\n return more.ok ? ok(checkedList([...okItems, ...more.value])) : more;\n }\n case \"without\": {\n const more = other();\n if (!more.ok) return more;\n const gone = new Set(more.value.map((it) => it.key));\n return ok(checkedList(okItems.filter((it) => !gone.has(it.key))));\n }\n case \"flat\":\n return this.#flat(okValues, strict, f, path);\n case \"distinct\": {\n // The first item of each value, in the order of the list (LIST.DISTINCT). === compares the values, as for\n // indexOf, so each NaN stays.\n const seen = new Set<unknown>();\n const out: ListItem[] = [];\n for (let i = 0; i < okValues.length; i++) {\n const x = okValues[i];\n if (!isIndexValue(x)) return this.#err(\"kind-mismatch\", `\"distinct\" needs numbers, texts or booleans, but an item is a ${describeType(x)}`, f, path, { op });\n if (Number.isNaN(x) || !seen.has(x)) out.push(okItems[i] as ListItem);\n seen.add(x);\n }\n return ok(checkedList(out));\n }\n case \"join\": {\n // The texts of the items with the text sep between them (LIST.JOIN).\n const sep = rest[0];\n if (typeof sep !== \"string\") return this.#err(\"kind-mismatch\", `\"join\" needs a text separator, not a ${describeType(sep)}`, f, path, { op });\n const bad = okValues.find((x) => typeof x !== \"string\");\n return bad === undefined ? ok(okValues.join(sep)) : this.#err(\"kind-mismatch\", `\"join\" needs texts, but an item is a ${describeType(bad)}`, f, path, { op });\n }\n case \"indexOf\": {\n const x = rest[0];\n if (!isIndexValue(x)) return this.#err(\"kind-mismatch\", `\"indexOf\" needs a number, a text or a boolean, not a ${describeType(x)}`, f, path, { op });\n const i = okValues.indexOf(x);\n return i >= 0 ? ok(i) : this.#err(\"missing-field\", `the list has no item with the value ${JSON.stringify(x)}`, f, path, { op });\n }\n case \"nth\": {\n const i = whole();\n if (!i.ok) return i;\n return i.value < okValues.length ? ok(okValues[i.value]) : this.#err(\"empty\", `\"nth\" has no item at the position ${String(i.value)}, and the list has ${String(okValues.length)} items`, f, path, { op });\n }\n case \"setNth\": {\n const i = whole();\n if (!i.ok) return i;\n const old = okItems[i.value];\n if (old === undefined) return this.#err(\"empty\", `\"setNth\" has no item at the position ${String(i.value)}, and the list has ${String(okItems.length)} items`, f, path, { op });\n if (rest[1] === undefined) return this.#err(\"bad-expression\", '\"setNth\" needs argument 3', f, path, { op });\n const items = [...okItems];\n items[i.value] = { key: old.key, result: ok(rest[1]) };\n return ok(checkedList(items));\n }\n case \"count\":\n return ok(okValues.length);\n case \"values\":\n return ok(Object.freeze([...okValues]));\n case \"keys\":\n return ok(Object.freeze(okItems.map((it) => it.key)));\n case \"errors\":\n return ok(Object.freeze(list.items.flatMap((it) => (it.result.ok ? [] : [it.result.error]))));\n case \"first\":\n return okValues.length > 0 ? ok(okValues[0]) : empty();\n case \"sum\": {\n const n = numbers();\n return n.ok ? this.#checkResult(ok(n.value.reduce((s, x) => s + x, 0)), f, path, op) : n;\n }\n case \"mean\": {\n const n = numbers();\n if (!n.ok) return n;\n return n.value.length === 0 ? empty() : this.#checkResult(ok(n.value.reduce((s, x) => s + x, 0) / n.value.length), f, path, op);\n }\n case \"min\":\n case \"max\": {\n const n = numbers();\n if (!n.ok) return n;\n if (n.value.length === 0) return empty();\n return ok(n.value.reduce((best, x) => (op === \"min\" ? Math.min(best, x) : Math.max(best, x))));\n }\n case \"any\":\n case \"all\":\n case \"none\": {\n const b = booleans();\n if (!b.ok) return b;\n if (op === \"any\") return ok(b.value.some((x) => x));\n if (op === \"all\") return ok(b.value.every((x) => x));\n return ok(!b.value.some((x) => x));\n }\n case \"reduce\":\n return this.#reduce(rest[0], okValues, f, path, optsArg);\n }\n }\n\n /**\n * This method gives the value of the first item with a key (LIST.GET). LIST.LENIENT applies, so an error item is not\n * an item of the key. The program keeps the index of each list, so a step that reads each key of a list reads it once.\n */\n #get(list: VexList, key: unknown, strict: boolean, f: Frame, path: readonly number[]): Result<unknown> {\n let index = this.#keyIndex.get(list);\n // Stryker disable next-line ConditionalExpression: a new index of the same list has the same values\n if (index === undefined) {\n index = keyIndexOf(list);\n this.#keyIndex.set(list, index);\n }\n // As goodItems: #DEPTH! comes first, and with strict, the first error item is the result.\n const stop = index.depth ?? (strict ? index.first : undefined);\n if (stop !== undefined) return fail(stop);\n if (typeof key !== \"string\") return this.#err(\"kind-mismatch\", `\"get\" needs a text key, not a ${describeType(key)}`, f, path, { op: \"get\" });\n return index.values.has(key) ? ok(index.values.get(key)) : this.#err(\"missing-field\", `the list has no item with the key ${JSON.stringify(key)}`, f, path, { op: \"get\" });\n }\n\n /**\n * This method gives the groups of a list (LIST.GROUP). The item at a position has the key at the same position of\n * `keys`, so the two lists must have the same number of items. A pair with an error item or an error key is not in a\n * group (LIST.LENIENT). Each key gives one item, in the order of its first pair, and its value is a list of its items.\n */\n #group(list: VexList, keys: unknown, strict: boolean, f: Frame, path: readonly number[]): Result<VexList> {\n const good = goodItems(list, strict);\n if (!good.ok) return good;\n const listed = asList(keys, this.#missing(f, path));\n if (listed === undefined) return this.#err(\"kind-mismatch\", `\"group\" needs a list of keys as its second argument, not a ${describeType(keys)}`, f, path, { op: \"group\" });\n const goodKeys = goodItems(listed, strict);\n if (!goodKeys.ok) return goodKeys;\n const { items } = list;\n const keyItems = listed.items;\n if (keyItems.length !== items.length) return this.#err(\"kind-mismatch\", `\"group\" needs one key for each item, but the list has ${String(items.length)} items and ${String(keyItems.length)} keys`, f, path, { op: \"group\" });\n const groups = new Map<string, ListItem[]>();\n for (let i = 0; i < items.length; i++) {\n const it = items[i] as ListItem;\n const k = (keyItems[i] as ListItem).result;\n if (!it.result.ok || !k.ok) continue;\n if (typeof k.value !== \"string\") return this.#err(\"kind-mismatch\", `\"group\" needs text keys, but a key is a ${describeType(k.value)}`, f, path, { op: \"group\" });\n const g = groups.get(k.value);\n if (g === undefined) groups.set(k.value, [it]);\n else g.push(it);\n }\n const out: ListItem[] = [];\n for (const [key, g] of groups) out.push({ key, result: ok(checkedList(g)) });\n return ok(checkedList(out));\n }\n\n /**\n * This method joins the lists that are the values of the items of a list, in order (LIST.FLAT). Each list follows the\n * rules of LIST.BUILD. A value that is not a list gives `#VALUE!`.\n */\n #flat(values: readonly unknown[], strict: boolean, f: Frame, path: readonly number[]): Result<VexList> {\n const out: ListItem[] = [];\n for (const value of values) {\n const inner = asList(value, this.#missing(f, path));\n if (inner === undefined) return this.#err(\"kind-mismatch\", `\"flat\" needs a list as the value of each item, but an item is a ${describeType(value)}`, f, path, { op: \"flat\" });\n const good = goodItems(inner, strict);\n if (!good.ok) return good;\n out.push(...good.value);\n }\n return ok(checkedList(out));\n }\n\n /**\n * This method sorts the items of a list by their sort values, from the smallest (LIST.SORT). The sort is stable. The\n * sort values are all numbers without NaN, or all texts. Texts compare by their UTF-16 code units. Without the option\n * `by`, the sort value of an item is its value (LIST.SORT.BY).\n */\n #sortBy(items: readonly ListItem[], values: readonly unknown[], opts: unknown, f: Frame, path: readonly number[]): Result<VexList> {\n const by = (opts as { readonly by?: unknown } | null | undefined)?.by;\n const sorted = by === undefined ? ok(values) : this.#sortValues(by, values, f, path);\n if (!sorted.ok) return sorted;\n const keys = sorted.value;\n const kind = typeof keys[0];\n const bad = keys.findIndex((x) => typeof x !== kind || (kind !== \"number\" && kind !== \"string\") || Number.isNaN(x));\n if (bad >= 0) {\n const what = typeof by === \"string\" ? `\"${by}\" of an item` : \"an item\";\n return this.#err(\"kind-mismatch\", `\"sortBy\" needs numbers without NaN or texts, all of one kind, but ${what} is ${Number.isNaN(keys[bad]) ? \"NaN\" : `a ${describeType(keys[bad])}`}`, f, path, { op: \"sortBy\" });\n }\n const order = keys.map((_x, i) => i).toSorted((i, j) => {\n const a = keys[i] as number | string;\n const b = keys[j] as number | string;\n // The sort of Node reads only a negative result, and the sort of another engine needs the whole comparison.\n // Stryker disable next-line ConditionalExpression,EqualityOperator: see the comment above\n return a < b ? -1 : a > b ? 1 : 0;\n });\n return ok(checkedList(order.map((i) => items[i] as ListItem)));\n }\n\n /**\n * This method gives the sort value of each item for the option `by` of `sortBy` (LIST.SORT.BY). The op of the name\n * `by` applies to the value of each item, in the order of the list. The first error is the result.\n */\n #sortValues(by: unknown, values: readonly unknown[], f: Frame, path: readonly number[]): Result<readonly unknown[]> {\n if (typeof by !== \"string\") return this.#err(\"kind-mismatch\", `the option \"by\" of \"sortBy\" needs an op name, but got a ${describeType(by)}`, f, path, { op: \"sortBy\" });\n const out: unknown[] = [];\n for (const x of values) {\n let op: ResolvedOp | undefined;\n for (const d of this.#domains) {\n op = safeIs(d, x) ? resolveOp(d, x, by) : undefined;\n if (op !== undefined) break;\n }\n if (op === undefined) return this.#at(errorText.noStep(by, x), f, path);\n const r = this.#callResolved(op, x, by, [], f, path);\n if (!r.ok) return r;\n out.push(r.value);\n }\n return ok(out);\n }\n\n /**\n * This method folds the values with a domain op, from the left. An empty list gives the identity of the op, if one\n * domain has an identity for the op (LIST.EMPTY). The option `domain` names that domain when more domains have one.\n */\n #reduce(opName: unknown, values: readonly unknown[], f: Frame, path: readonly number[], opts: unknown): Result<unknown> {\n if (typeof opName !== \"string\") return this.#at(errorText.reduceName(opName), f, path);\n if (values.length === 0) {\n const named = (opts as { domain?: unknown } | null | undefined)?.domain;\n const candidates = this.#domains.filter((d) => Object.hasOwn(d.ops, opName) && (d.ops[opName] as { identity?: () => unknown }).identity !== undefined && (named === undefined || d.name === named));\n if (named !== undefined && !this.#domains.some((d) => d.name === named)) {\n return this.#err(\"unknown-op\", `\"reduce\" names the domain ${JSON.stringify(named)}, but the program has no such domain`, f, path, { op: opName });\n }\n const [only, second] = candidates;\n if (only === undefined) return this.#err(\"empty\", `\"reduce\" with \"${opName}\" has no values and the op has no identity`, f, path, { op: opName });\n if (second !== undefined) {\n const names = candidates.map((d) => d.name).join(\", \");\n return this.#err(\"empty\", `\"reduce\" with \"${opName}\" has no values, and more domains have an identity for it (${names}). Name one with { domain }`, f, path, { op: opName });\n }\n return this.#invoke((only.ops[opName] as { identity: () => unknown }).identity, opName, f, path);\n }\n let acc: unknown = values[0];\n for (let i = 1; i < values.length; i++) {\n const d = this.#domains.find((dom) => safeIs(dom, acc) && resolveOp(dom, acc, opName) !== undefined);\n const op = d === undefined ? undefined : resolveOp(d, acc, opName);\n if (op === undefined) return this.#at(errorText.noStep(opName, acc), f, path);\n const r = this.#callResolved(op, acc, opName, [values[i]], f, path);\n if (!r.ok) return r;\n acc = r.value;\n }\n return ok(acc);\n }\n}\n\n/** The list ops with a second argument before their options: a count, a position, an op name or a list. */\nconst WITH_ARGUMENT: ReadonlySet<ListOp> = new Set<ListOp>([\"reduce\", \"take\", \"nth\", \"drop\", \"append\", \"without\", \"get\", \"indexOf\", \"group\", \"join\"]);\n\n/**\n * This function gives the items of a list that have a value (LIST.LENIENT). A list op does not skip `#DEPTH!`, so that\n * error comes first (EVAL.DEPTH). With `strict`, the first error item is the result.\n */\nfunction goodItems(list: VexList, strict: boolean): Result<readonly ListItem[]> {\n const { items } = list;\n let first: VexError | undefined;\n for (const it of items) {\n if (it.result.ok) continue;\n if (isDepthError(it.result.error)) return fail(it.result.error);\n first ??= it.result.error;\n }\n // A list without error items gives its own items: no copy. Nothing changes them: the items of `vexList` are frozen,\n // and each list op makes a new array.\n if (first === undefined) return ok(items);\n if (strict) return fail(first);\n const out: ListItem[] = [];\n for (const it of items) if (it.result.ok) out.push(it);\n return ok(out);\n}\n\n/**\n * This function makes a list from the items of lists that passed the check of LIST.SHAPE, or from items of the same\n * shape. Thus the list skips the check of `isVexList`.\n */\nfunction checkedList(items: readonly ListItem[]): VexList {\n const list = vexList(items);\n CHECKED.add(list);\n return list;\n}\n\n/** This function gives the value of an item with a value. */\nconst valueOf = (it: ListItem): unknown => (it.result as { readonly value: unknown }).value;\n\n/** The index of the keys of a list (LIST.GET): the value of the first item of each key, and the first errors. */\ninterface KeyIndex {\n readonly values: ReadonlyMap<string, unknown>;\n /** The first error item. With strict, it is the result. */\n readonly first: VexError | undefined;\n /** The first item of `#DEPTH!`. A list op does not skip it (EVAL.DEPTH). */\n readonly depth: VexError | undefined;\n}\n\n/** This function makes the index of the keys of a list. An error item is not an item of its key (LIST.LENIENT). */\nfunction keyIndexOf(list: VexList): KeyIndex {\n const values = new Map<string, unknown>();\n let first: VexError | undefined;\n let depth: VexError | undefined;\n for (const it of list.items) {\n if (it.result.ok) {\n // The first item of a key gives its value. A later item with the same key does not replace it.\n if (!values.has(it.key)) values.set(it.key, it.result.value);\n } else {\n first ??= it.result.error;\n if (isDepthError(it.result.error)) depth ??= it.result.error;\n }\n }\n return { values, first, depth };\n}\n\nconst FORBIDDEN_FIELDS = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\n/** This function tells if a segment of a path can name a field. A compiler uses the same rule as the interpreter. */\nexport const isFieldName = (seg: string): boolean => seg.length > 0 && !FORBIDDEN_FIELDS.has(seg);\n\n/**\n * This function tells if a domain accepts a value. A domain with a primitive type accepts each value of that type and\n * no other value (KIND.PRIMITIVE), so its test `is` does not start. For another domain, a test that throws counts as\n * `false`.\n */\nexport function safeIs(d: AnyDomain, value: unknown): boolean {\n return d.primitive !== undefined ? typeof value === d.primitive : testIs(d, value);\n}\n\n/** This function starts the `is` test of a domain. A test that throws counts as `false`. */\n// Stryker disable BlockStatement: an empty catch gives undefined, which also counts as false\nfunction testIs(d: AnyDomain, value: unknown): boolean {\n try {\n return d.is(value);\n } catch {\n return false;\n }\n}\n// Stryker restore BlockStatement\n\n\n/** This function tells if an argument has the kind of a parameter of an op of the domain `domain`. */\nexport function matchesKind(kind: ParamKind, value: unknown, domain: AnyDomain): boolean {\n switch (kind) {\n case \"domain\":\n return safeIs(domain, value);\n case \"number\":\n return typeof value === \"number\";\n case \"boolean\":\n return typeof value === \"boolean\";\n case \"string\":\n return typeof value === \"string\";\n case \"any\":\n return true;\n }\n}\n\n/** This function gives the label of a node, for traces. */\nexport function labelOf(e: Expr): string {\n switch (e.tag) {\n case \"lit\":\n return previewValue(e.value);\n case \"ref\":\n return e.path.length === 0 ? \"(record)\" : e.path.join(\".\");\n case \"app\":\n return e.op;\n case \"let\":\n return `let ${Object.keys(e.bind).join(\", \")}`;\n // A function makes no event of the trace, so its label only completes the switch.\n // Stryker disable next-line all: see the comment above\n case \"fn\": return `fn (${e.params.join(\", \")})`;\n case \"call\":\n return `call ${e.fn}`;\n case \"var\":\n return e.name;\n case \"rec\":\n return `{ ${Object.keys(e.fields).join(\", \")} }`;\n case \"each\":\n case \"fold\":\n return e.at === undefined ? `${e.tag} ${e.axis.t}` : `${e.tag} ${e.axis.t} from ${e.at.map(moveText).join(\".\")}`;\n case \"iterate\":\n return `iterate ${typeof e.limit === \"number\" ? String(e.limit) : `size of ${e.limit.axis.t}`}`;\n case \"fix\":\n return `fix ${e.name} ${e.join}`;\n case \"last\":\n return `last ${e.name}`;\n case \"ext\":\n return e.kind;\n }\n}\n\n/** This function gives a short text for a move, for the label of an axis with an address. */\nfunction moveText(m: Move): string {\n switch (m.t) {\n case \"key\":\n return `key(${typeof m.key === \"string\" ? m.key : labelOf(m.key)})`;\n case \"index\":\n return `index(${typeof m.i === \"number\" ? String(m.i) : labelOf(m.i)})`;\n case \"offset\":\n return `offset(${m.d.join(\", \")})`;\n case \"other\":\n case \"origin\":\n case \"parent\":\n return m.t;\n }\n}\n\n/** This function gives a short text for a value. */\nexport function previewValue(u: unknown): string {\n // JSON has no NaN and no Infinity, so a number gets its own text. JSON gives the text of the other primitives.\n if (typeof u === \"number\") return String(u);\n if (isVexList(u)) return `list(${u.items.length})`;\n try {\n const json = JSON.stringify(u);\n // A function, a symbol and undefined have no JSON form.\n // Stryker disable next-line ConditionalExpression: without the test, undefined.length throws, and the catch gives the same text\n if (json !== undefined) return json.length > 60 ? `${json.slice(0, 57)}...` : json;\n } catch {\n // A value with cycles has no JSON form.\n }\n return describeType(u);\n}\n\n// The reads of a reference show the key and the path, for example \"read B.position\" or \"no value at A.mass\".\nconst formatRead = (r: Read): string => `${r.ok ? \"read\" : \"no value at\"} ${r.key}.${r.path.length === 0 ? \"(record)\" : r.path.join(\".\")}`;\n\n/**\n * This function gives a text form of a trace. Each event has one line, in finish order. The indent of a line\n * shows the depth of the node. A domain with `show` gives the text of its values. The golden tests compare this text.\n */\n// Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain shows no value\nexport function formatTrace(trace: Trace, domains: readonly AnyDomain[] = []): string {\n const show = (u: unknown): string => {\n if (isVexList(u)) return `[${u.items.map((it) => `${it.key}: ${result(it.result)}`).join(\", \")}]`;\n const d = domains.find((dom) => dom.show !== undefined && safeIs(dom, u));\n try {\n // Stryker disable next-line ConditionalExpression,OptionalChaining: without a domain, d.show throws, and the catch gives the same text\n if (d?.show !== undefined) return d.show(u);\n } catch {\n // A show function that throws gives the default text.\n }\n return previewValue(u);\n };\n const result = (r: Result<unknown>): string => (r.ok ? show(r.value) : formatError(r.error));\n const line = (e: TraceEvent): string => {\n const reads = e.reads === undefined ? \"\" : ` [${e.reads.map(formatRead).join(\", \")}]`;\n return `${\" \".repeat(e.path.length)}${e.label} @${e.focus}${reads} = ${result(e.result)}`;\n };\n const lines = trace.events.map(line);\n return [...lines, `result = ${result(trace.result)}`, \"\"].join(\"\\n\");\n}\n\n/** This function gives the number of nodes of an expression. */\nexport const sizeOf = (e: Expr): number => 1 + children(e).reduce((s, c) => s + sizeOf(c), 0);\n","/**\n * The static reads of a program (DEPS.READS). The static kit of coeval finds the references of the document of the\n * program, by the contracts of Vex (`refsOf`). Vex adds only what is its own: the axes around a read, and the reads of\n * a function at each of its calls (FN.CALL).\n */\nimport { pathMatches, refsOf, type DocVisit, type Key, type RefUse } from \"@mark1russell7/coeval\";\nimport type { Addr, Axis, DataLimit, Expr, ExprOf } from \"./ir.ts\";\nimport { VEX_WORLD } from \"./kernel.ts\";\nimport { writeDocument } from \"./write.ts\";\n\n/** One static read of a program: a field path at an address, inside zero or more axes. */\nexport interface Dependency {\n /** The address of the read. The empty address is the focus. */\n readonly at: Addr;\n /** The field path of the read. */\n readonly path: readonly string[];\n /** The axes around the read, from the outside to the inside. Inside an axis, the focus is the target. */\n readonly axes: readonly Axis[\"t\"][];\n /** The address of each axis in `axes`, in the same order. The empty address is the focus. */\n readonly axisAt: readonly Addr[];\n}\n\n/** An axis around a read: the kind of the axis of a loop, and the address of the loop. */\ninterface Around {\n readonly t: Axis[\"t\"];\n readonly at: Addr;\n}\n\n/** A chain of items, the innermost first. The chains of two documents share the items of the documents around both. */\ninterface Chain<T> {\n readonly item: T;\n readonly up: Chain<T> | undefined;\n}\n\n/** The context of a document for its reads. */\ninterface Context {\n /** The axes around the document, the innermost first. */\n readonly axes: Chain<Around> | undefined;\n /** Inside the axis document of a loop: the axis of that loop. A test of `where` there is inside the axis. */\n readonly axis: Around | undefined;\n /** The nearest function around the document: a binding of a let. Its reads happen at its calls, not here. */\n readonly fn: DocVisit | undefined;\n /** The calls around the document whose function is a binding of a let, the innermost first. */\n readonly calls: Chain<DocVisit> | undefined;\n}\n\nconst ROOT: Context = { axes: undefined, axis: undefined, fn: undefined, calls: undefined };\n\n/** This function gives the items of a chain until the chain `end`, from the outside to the inside. */\nfunction itemsUntil<T>(chain: Chain<T> | undefined, end: Chain<T> | undefined): T[] {\n const out: T[] = [];\n for (let c = chain; c !== undefined && c !== end; c = c.up) out.push(c.item);\n return out.toReversed();\n}\n\n/** This function gives the kind of a visit, as its keys joined with dots, for example `each` or `axes.where`. */\n// Stryker disable next-line ArrayDeclaration: each document of the writer has a type of the world, so each visit has a type path\nconst kindOf = (v: DocVisit): string => (v.typePath ?? []).join(\".\");\n\n/**\n * This function gives the static reads of an expression. A host can use them to recompute a program only when a field\n * that it reads changes. A computed move reads a key that only a run knows. Its address keeps the expression, and the\n * reads of that expression are in the list too (DEPS.COMPUTED). The kernel walks the document with a stack, so an\n * expression of any depth works (EVAL.NESTING).\n */\nexport function deps(e: Expr): readonly Dependency[] {\n const nodes = new Map<object, Expr>();\n // The order \"reads\" puts the body or the steps of a loop before its axis, as the reads of an evaluation come.\n const doc = writeDocument(e, {\n // Stryker disable next-line ArrayDeclaration: the reads come from the references, not from the form of a literal\n domains: [],\n // Stryker disable next-line StringLiteral: the writer tests only the mode \"json\", and each other mode keeps the value\n literals: \"host\",\n order: \"reads\",\n nodes,\n });\n const uses = refsOf(VEX_WORLD, doc);\n const memo = new WeakMap<DocVisit, Context>();\n const functions = new WeakMap<DocVisit, DocVisit | null>();\n const fnVisits = new Map<unknown, DocVisit>();\n\n /** This function gives the function of a call: the visit of the binding of a let, or `undefined` (FN.CALL). */\n const functionOf = (call: DocVisit): DocVisit | undefined => {\n const known = functions.get(call);\n if (known !== undefined) return known ?? undefined;\n const name = (call.doc.value as { readonly fn: { readonly value: readonly [string, string] } }).fn.value[1];\n let found: DocVisit | undefined;\n // The innermost kind that binds the name decides. A parameter, a binding or a name of a loop hides a function.\n search: for (let child: DocVisit = call, around = call.parent; around !== undefined; child = around, around = around.parent) {\n // Stryker disable next-line OptionalChaining: each document around a call is a term or a function, so it has a kind\n for (const rule of around.kind?.scope ?? []) {\n if (!rule.in.some((pattern) => pathMatches(child.slot, pattern))) continue;\n const source = rule.names as { readonly keysAt?: readonly Key[]; readonly listAt?: readonly Key[] };\n // Stryker disable next-line ArrayDeclaration: each rule of the scopes of Vex gives its names with keysAt or listAt\n const at = (source.keysAt ?? source.listAt ?? []).reduce<unknown>((x, k) => (x as Readonly<Record<string, unknown>>)[String(k)], around.doc.value);\n // A loop without the names `as` of its items has no list there (AXIS.LIST.SCOPE).\n // Stryker disable next-line ArrayDeclaration: a name that no program binds does not hide a function\n const names = source.keysAt !== undefined ? Object.keys(at as object) : ((at as readonly string[] | undefined) ?? []);\n if (!names.includes(name)) continue;\n // Only a binding of a let is a function (FN.BIND), and the map has only the documents of the functions.\n found = fnVisits.get((at as Readonly<Record<string, unknown>>)[name]);\n break search;\n }\n }\n functions.set(call, found ?? null);\n return found;\n };\n\n /** This function gives the context of a child from the context of its parent. */\n const step = (outer: Context, parent: DocVisit, child: DocVisit): Context => {\n const kind = kindOf(parent);\n const head = child.slot[0];\n let { axes, fn, calls } = outer;\n let axis: Around | undefined;\n if (outer.axis !== undefined) {\n // In the axis document of a loop: a test of where is inside the axis, and the list of the axis list is outside.\n // Only the axis where has a test.\n if (head === \"test\") axes = { item: outer.axis, up: axes };\n else if (head === \"axis\") axis = outer.axis;\n } else if (kind === \"each\" || kind === \"fold\") {\n const node = nodes.get(parent.doc) as ExprOf<\"each\" | \"fold\">;\n const around: Around = { t: node.axis.t, at: node.at ?? [] };\n if (head === \"body\" || head === \"step\") axes = { item: around, up: axes };\n else if (head === \"axis\") axis = around;\n } else if (kind === \"fix\") {\n // The start and the step of a column read at each row (FIX.ROWS).\n axes = { item: { t: \"all\", at: [] }, up: axes };\n } else if (kind === \"size\") {\n // The size of the writer is the data limit of its node, so the axis has no address (ITERATE.LIMIT.DATA).\n axis = { t: ((nodes.get(parent.doc) as ExprOf<\"iterate\">).limit as DataLimit).axis.t, at: [] };\n }\n if (kind === \"fn\") {\n fn = parent;\n fnVisits.set(parent.doc, parent);\n }\n // Each call goes in the chain, also a call of a name that is not a function: inCall looks for one call of a function.\n if (kind === \"call\") calls = { item: parent, up: calls };\n return { axes, axis, fn, calls };\n };\n\n /**\n * This function gives the context of a visit. It walks up to a known context with a loop, not with recursion. The\n * context of no visit is the context of the root.\n */\n const contextOf = (v: DocVisit | undefined): Context => {\n const todo: DocVisit[] = [];\n let x: DocVisit | undefined = v;\n while (x !== undefined && !memo.has(x)) {\n todo.push(x);\n x = x.parent;\n }\n let ctx = x === undefined ? ROOT : (memo.get(x) as Context);\n for (let i = todo.length - 1; i >= 0; i--) {\n const child = todo[i] as DocVisit;\n ctx = child.parent === undefined ? ROOT : step(ctx, child.parent, child);\n memo.set(child, ctx);\n }\n return ctx;\n };\n\n // The references of each function, apart from the others: they read at each call of the function.\n const groups = new Map<DocVisit | undefined, RefUse[]>();\n for (const use of uses) {\n const fn = contextOf(use.visit).fn;\n const group = groups.get(fn) ?? [];\n group.push(use);\n groups.set(fn, group);\n }\n\n const out: Dependency[] = [];\n /** This function gives the reads of the references of a function at a call, inside the axes of the call. */\n const emit = (group: readonly RefUse[], base: DocVisit | undefined, outside: readonly Around[]): void => {\n const baseAxes = contextOf(base).axes;\n const inside = (v: DocVisit): readonly Around[] => [...outside, ...itemsUntil(contextOf(v).axes, baseAxes)];\n // The reads of a call come after the reads of its arguments, so a call waits until the walk leaves it.\n const pending: { readonly call: DocVisit; readonly fn: DocVisit; readonly axes: readonly Around[] }[] = [];\n const inCall = (v: DocVisit | undefined, call: DocVisit): boolean => {\n for (let c = contextOf(v).calls; c !== undefined && c.item.depth >= call.depth; c = c.up) if (c.item === call) return true;\n return false;\n };\n const flush = (until?: DocVisit): void => {\n for (;;) {\n const top = pending.at(-1);\n if (top === undefined || inCall(until, top.call)) return;\n pending.pop();\n emit(groups.get(top.fn) ?? [], top.fn, top.axes);\n }\n };\n for (const use of group) {\n flush(use.visit);\n if (use.root === \"self\" && !use.address) {\n const node = nodes.get(use.visit.doc) as ExprOf<\"ref\">;\n const axes = inside(use.visit);\n out.push({ at: node.at ?? [], path: node.path, axes: axes.map((a) => a.t), axisAt: axes.map((a) => a.at) });\n }\n const call = use.visit.parent;\n if (call !== undefined && kindOf(call) === \"call\" && use.visit.slot[0] === \"fn\") {\n const fn = functionOf(call);\n if (fn !== undefined) pending.push({ call, fn, axes: inside(call) });\n }\n }\n flush();\n };\n emit(groups.get(undefined) ?? [], undefined, []);\n return out;\n}\n","import { decodeValue, encodeValue, isRecord } from \"./codec.ts\";\nimport { fromDocument, isDocument } from \"./document.ts\";\nimport type { AnyDomain } from \"./domain.ts\";\nimport { isStackOverflow, vexError } from \"./errors.ts\";\nimport { isExpr, type Expr } from \"./ir.ts\";\nimport { fail, ok, type Result } from \"./result.ts\";\n\n/** This function applies `f` to each literal value of a JSON tree of an expression. */\nfunction mapValues(u: unknown, f: (value: unknown) => Result<unknown>): Result<unknown> {\n if (!isRecord(u)) return ok(u);\n const out: Record<string, unknown> = { ...u };\n const child = (key: string): Result<unknown> | undefined => {\n const r = mapValues(u[key], f);\n if (r.ok) out[key] = r.value;\n return r.ok ? undefined : r;\n };\n const each = (key: string): Result<unknown> | undefined => {\n const list = u[key];\n if (Array.isArray(list)) {\n const items: unknown[] = [];\n for (const x of list) {\n const r = mapValues(x, f);\n if (!r.ok) return r;\n items.push(r.value);\n }\n out[key] = items;\n } else if (isRecord(list)) {\n const entries: [string, unknown][] = [];\n for (const [k, x] of Object.entries(list)) {\n const r = mapValues(x, f);\n if (!r.ok) return r;\n entries.push([k, r.value]);\n }\n // A binding or a field with the name \"__proto__\" is an own field too (V-062).\n out[key] = Object.fromEntries(entries);\n }\n return undefined;\n };\n // The expression of a computed move is a tree of the expression too (NAV.COMPUTED).\n const address = (): Result<unknown> | undefined => {\n const at = u[\"at\"];\n if (!Array.isArray(at)) return undefined;\n const moves: unknown[] = [];\n for (const m of at) {\n const field = isRecord(m) ? (m[\"t\"] === \"key\" ? \"key\" : m[\"t\"] === \"index\" ? \"i\" : undefined) : undefined;\n if (field === undefined || !isRecord(m) || !isRecord(m[field])) {\n moves.push(m);\n continue;\n }\n const r = mapValues(m[field], f);\n if (!r.ok) return r;\n moves.push({ ...m, [field]: r.value });\n }\n out[\"at\"] = moves;\n return undefined;\n };\n // The test of where and the list of the axis list are expressions, also inside reverse.\n const axis = (a: unknown): Result<unknown> => {\n if (!isRecord(a)) return ok(a);\n if (a[\"t\"] === \"list\") {\n const list = mapValues(a[\"list\"], f);\n return list.ok ? ok({ ...a, list: list.value }) : list;\n }\n if (a[\"t\"] === \"reverse\") {\n const inner = axis(a[\"axis\"]);\n return inner.ok ? ok({ ...a, axis: inner.value }) : inner;\n }\n if (a[\"t\"] !== \"where\") return ok(a);\n const inner = axis(a[\"axis\"]);\n if (!inner.ok) return inner;\n const test = mapValues(a[\"test\"], f);\n return test.ok ? ok({ ...a, axis: inner.value, test: test.value }) : test;\n };\n switch (u[\"tag\"]) {\n case \"lit\": {\n if (!Object.hasOwn(u, \"value\")) return ok(out);\n const r = f(u[\"value\"]);\n if (!r.ok) return r;\n out[\"value\"] = r.value;\n return ok(out);\n }\n case \"app\":\n return each(\"args\") ?? ok(out);\n case \"let\":\n return each(\"bind\") ?? child(\"body\") ?? ok(out);\n case \"rec\":\n return each(\"fields\") ?? ok(out);\n case \"each\": {\n const a = axis(u[\"axis\"]);\n if (!a.ok) return a;\n out[\"axis\"] = a.value;\n return child(\"body\") ?? address() ?? ok(out);\n }\n case \"fold\": {\n const a = axis(u[\"axis\"]);\n if (!a.ok) return a;\n out[\"axis\"] = a.value;\n return each(\"init\") ?? each(\"step\") ?? child(\"result\") ?? address() ?? ok(out);\n }\n case \"iterate\": {\n const limit = u[\"limit\"];\n if (isRecord(limit)) {\n const a = axis(limit[\"axis\"]);\n if (!a.ok) return a;\n out[\"limit\"] = { ...limit, axis: a.value };\n }\n return each(\"init\") ?? each(\"step\") ?? (u[\"until\"] === undefined ? undefined : child(\"until\")) ?? child(\"result\") ?? ok(out);\n }\n case \"fix\":\n return child(\"init\") ?? child(\"step\") ?? ok(out);\n case \"fn\":\n return child(\"body\") ?? ok(out);\n case \"call\":\n return each(\"args\") ?? ok(out);\n case \"ref\":\n return address() ?? ok(out);\n default:\n return ok(out);\n }\n}\n\n/**\n * This function gives the JSON text of an expression. A literal value that is a domain value needs a domain with\n * `encode`. A literal value that is not JSON data and has no such domain gives the error `#VALUE!`.\n */\n// Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain encodes no value\nexport function serialize(e: Expr, domains: readonly AnyDomain[] = []): Result<string> {\n try {\n // A getter of a literal value can throw, so the encoding is inside the try too.\n const tree = mapValues(e, (v) => encodeValue(v, domains));\n return tree.ok ? ok(JSON.stringify(tree.value)) : fail(tree.error);\n } catch (thrown) {\n if (isStackOverflow(thrown)) return fail(vexError(\"depth\", \"the expression is too deep for the call stack of the engine\", { thrown }));\n return fail(vexError(\"threw\", \"the expression has no JSON form\", { thrown }));\n }\n}\n\n/**\n * This function reads an expression from JSON text. It checks the whole tree. The text can also be a document: then\n * `fromDocument` reads it (DOC.ENTRY).\n */\n// Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain decodes no value\nexport function parse(text: string, domains: readonly AnyDomain[] = []): Result<Expr> {\n let raw: unknown;\n try {\n raw = JSON.parse(text);\n } catch (thrown) {\n return fail(vexError(\"bad-expression\", \"the text is not JSON\", { thrown }));\n }\n if (isDocument(raw)) {\n const read = fromDocument(raw, domains);\n // The JSON form needs whole numbers in the moves and the windows, as isExpr does.\n return !read.ok || isExpr(read.value) ? read : fail(vexError(\"bad-expression\", \"the JSON is not a valid Vex expression\"));\n }\n try {\n const tree = mapValues(raw, (v) => decodeValue(v, domains));\n if (!tree.ok) return fail(tree.error);\n return isExpr(tree.value) ? ok(tree.value) : fail(vexError(\"bad-expression\", \"the JSON is not a valid Vex expression\"));\n } catch (thrown) {\n // A JSON text nested deeper than the call stack, or a decoder of a domain that throws.\n if (isStackOverflow(thrown)) return fail(vexError(\"depth\", \"the JSON is too deep for the call stack of the engine\", { thrown }));\n return fail(vexError(\"threw\", \"a decoder of a domain threw an exception\", { thrown }));\n }\n}\n","/**\n * The reference tier of Vex: a program as a plan of the kernel of coeval (decision D13 of coeval). The kernel evaluates\n * the document of the program with the machine of `kernel.ts`. The closure compiler and the loop compiler give its\n * results (EVAL.REFERENCE), and the test kit compares them on random programs.\n */\nimport { agree as kernelAgree, context, prepare, reference as kernelReference, type Agreement, type Context, type Failed, type Result as Outcome } from \"@mark1russell7/coeval\";\nimport { fromDocument, isDocument, type Envelope } from \"./document.ts\";\nimport { vexError, type VexError } from \"./errors.ts\";\nimport { nestingError, type CompileOptions, type RunOptions } from \"./evaluate.ts\";\nimport { shapeError, type Expr } from \"./ir.ts\";\nimport { toKernelError, toVexResult, vexDefinitions, vexMachine, vexSelf } from \"./kernel.ts\";\nimport type { Result } from \"./result.ts\";\nimport { sameVex } from \"./same.ts\";\nimport { monotoneError } from \"./monotone.ts\";\nimport { sizeError } from \"./size.ts\";\nimport { stepError } from \"./steps.ts\";\nimport { writeDocument } from \"./write.ts\";\n\n/** The options of a run of a plan of the kernel: the options of a run without a trace. */\nexport type KernelRunOptions = Omit<RunOptions, \"trace\">;\n\n/** A program in the kernel: its document, and a run at an origin of a space. */\nexport interface KernelPlan {\n /** The document that the kernel evaluates, or `undefined` for a program that is not valid. */\n readonly doc: Envelope | undefined;\n /** This method evaluates the program at an origin. It does not throw. */\n run(opts: KernelRunOptions): Result<unknown>;\n /** This method evaluates the program at an origin, and gives the result of the kernel with its own code. */\n evaluate(opts: KernelRunOptions): Outcome;\n /**\n * This method evaluates the program at an origin with the reference interpreter of the kernel. The reference reads\n * the document by the rules of the kernel, and it compiles nothing. Thus it shares no compiler with `evaluate`.\n */\n reference(opts: KernelRunOptions): Outcome;\n /**\n * This method compares the tiers of the kernel at an origin (`agree` of coeval). The tiers are `evaluate`, the\n * reference interpreter, the traced evaluation and a second evaluation. The tier `other` of the caller is the last\n * tier. The method gives the result, or the first tier that gives another result. Two errors agree when they have the\n * same code.\n */\n agree(opts: KernelRunOptions, other?: () => Result<unknown>): Agreement;\n}\n\n/** This function gives the context of the kernel at an origin: the position of the origin, and the names of the caller. */\nconst contextOf = ({ space, origin, vars, tables }: KernelRunOptions): Context => context({ self: vexSelf(space, origin, tables), names: vars ?? {} });\n\n/** This function gives the result of the kernel for a result of Vex. */\nconst toOutcome = (r: Result<unknown>): Outcome => (r.ok ? { ok: true, value: r.value } : { ok: false, error: toKernelError(r.error) });\n\n/**\n * This function gives the plan of a program in the kernel (EVAL.REFERENCE). A document stays as it is, after the check\n * of `fromDocument`. An expression gets its document: a literal has its JSON form, or the value of the host when it has\n * no JSON form. A program that is not valid gives the error of `compile` at each run (EVAL.SHAPE, EVAL.NESTING).\n */\nexport function kernelPlan(source: Expr | Envelope, opts: CompileOptions = {}): KernelPlan {\n // Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain matches no value\n const domains = opts.domains ?? [];\n let doc: Envelope | undefined;\n let bad: VexError | undefined;\n if (isDocument(source)) {\n const read = fromDocument(source, domains);\n // LOOP.SIZE, STEP.MAX: the plan refuses the same programs as `compile`.\n const size = read.ok ? (sizeError(read.value, opts) ?? stepError(read.value, opts) ?? monotoneError(read.value, opts)) : undefined;\n if (read.ok && size === undefined) doc = source;\n else bad = read.ok ? vexError(\"bad-expression\", size ?? \"\") : read.error;\n } else {\n const shape = shapeError(source);\n const deep = shape ?? nestingError(source);\n const reason = deep ?? sizeError(source, opts) ?? stepError(source, opts) ?? monotoneError(source, opts);\n // Stryker disable next-line StringLiteral: the writer tests only the mode \"json\" and the order \"reads\"\n if (reason === undefined) doc = writeDocument(source, { domains, literals: \"host\", order: \"document\" });\n else bad = vexError(\"bad-expression\", reason);\n }\n const machine = vexMachine(opts);\n // A program that is not valid has no document. Its plan does not run, because each run fails before the kernel.\n const plan = prepare(machine, doc);\n // An origin outside the space and a program that is not valid fail before the kernel (EVAL.ORIGIN, EVAL.SHAPE).\n const early = ({ space, origin }: KernelRunOptions): Failed | undefined => {\n if (!space.has(origin)) return { ok: false, error: toKernelError(vexError(\"unknown-key\", `the space has no key \"${origin}\"`, { origin, focus: origin })) };\n return bad === undefined ? undefined : { ok: false, error: toKernelError(bad) };\n };\n const evaluate = (r: KernelRunOptions): Outcome => early(r) ?? plan.evaluate(contextOf(r));\n const reference = (r: KernelRunOptions): Outcome => early(r) ?? kernelReference(machine, doc, contextOf(r), { definitions: vexDefinitions(opts) });\n const agree = (r: KernelRunOptions, other?: () => Result<unknown>): Agreement => {\n const tier = other === undefined ? {} : { other: (): Outcome => toOutcome(other()) };\n const first = early(r);\n if (first === undefined) return kernelAgree(machine, doc, contextOf(r), { definitions: vexDefinitions(opts), equal: sameVex, ...tier });\n // The kernel does not evaluate the program, so only the tier can give another result.\n const second = tier.other?.() ?? first;\n return !second.ok && second.error.code === first.error.code ? { ok: true, result: first, effects: [] } : { ok: false, tier: \"other\", plan: first, other: second, reason: \"The plan does not evaluate the program, and the tier gives another result.\" };\n };\n return { doc, evaluate, reference, agree, run: (r) => toVexResult(evaluate(r)) };\n}\n","import type { AnyDomain } from \"./domain.ts\";\nimport { vexError, type VexError } from \"./errors.ts\";\nimport { evaluate, type FreeFn } from \"./evaluate.ts\";\nimport { app, lit, v } from \"./ir.ts\";\nimport { vexList, type ListItem } from \"./list.ts\";\nimport { fail, none, ok, toOptional, type Optional, type Result } from \"./result.ts\";\nimport { space as spaces, type Space } from \"./space.ts\";\n\n/** A monoid: an associative `concat` with an identity element `empty`. */\nexport interface Monoid<M> {\n readonly empty: M;\n readonly concat: (a: M, b: M) => M;\n}\n\n/** Standard monoids. */\nexport const monoids: {\n readonly sum: Monoid<number>;\n readonly product: Monoid<number>;\n readonly all: Monoid<boolean>;\n readonly any: Monoid<boolean>;\n} = {\n sum: { empty: 0, concat: (a, b) => a + b },\n product: { empty: 1, concat: (a, b) => a * b },\n all: { empty: true, concat: (a, b) => a && b },\n any: { empty: false, concat: (a, b) => a || b },\n};\n\n/** One item of a traversal: the start key and the result there. */\nexport interface TraversalItem<K extends string, T> {\n readonly key: K;\n readonly result: Result<T>;\n}\n\n/**\n * A traversal: the results of one program at each start key. The reductions skip error items by default.\n * After `strict()`, an error item makes the reduction that error.\n */\nexport interface Traversal<K extends string, T> {\n readonly items: readonly TraversalItem<K, T>[];\n /** This method gives a traversal whose reductions fail on the first error item. */\n strict(): Traversal<K, T>;\n /** This method gives the result at one key. */\n get(k: K): Optional<T>;\n /** The values of the items without errors. */\n values(): readonly T[];\n /** The keys of the items without errors. */\n keys(): readonly K[];\n /** The errors of the items with errors. */\n errors(): readonly VexError[];\n count(): Optional<number>;\n sum(this: Traversal<K, number>): Optional<number>;\n mean(this: Traversal<K, number>): Optional<number>;\n min(this: Traversal<K, number>): Optional<number>;\n max(this: Traversal<K, number>): Optional<number>;\n any(this: Traversal<K, boolean>): Optional<boolean>;\n all(this: Traversal<K, boolean>): Optional<boolean>;\n none(this: Traversal<K, boolean>): Optional<boolean>;\n /** This method folds the values with a domain op, from the left. */\n reduce(op: string): Optional<T>;\n /** This method gives the result of a reduction, with its error. */\n reduceResult(op: \"count\" | \"sum\" | \"mean\" | \"min\" | \"max\" | \"any\" | \"all\" | \"none\" | \"reduce\", reduceOp?: string): Result<unknown>;\n /** This method maps each value with `f`. If `f` throws, the item has the error `#CALC!`. */\n map<U>(f: (value: T, key: K) => U): Traversal<K, U>;\n /** This method folds the values with a monoid. */\n fold<M>(monoid: Monoid<M>, f: (value: T) => M): M;\n}\n\ninterface TraversalEnv {\n readonly domains: readonly AnyDomain[];\n readonly options?: { readonly fns?: Readonly<Record<string, FreeFn>> };\n}\n\nconst EMPTY_SPACE: Space = spaces.record({ $: {} });\n\nconst opt = <U>(r: Result<unknown>): Optional<U> => toOptional(r as Result<U>);\n\n/** This function makes a traversal from items. */\nexport function traversal<K extends string, T>(items: readonly TraversalItem<K, T>[], env: TraversalEnv, isStrict = false): Traversal<K, T> {\n const reduce = (op: string, reduceOp?: string): Result<unknown> => {\n const list = vexList(items as readonly ListItem[]);\n const args = [v(\"$list\"), ...(reduceOp === undefined ? [] : [lit(reduceOp)]), ...(isStrict ? [lit({ strict: true })] : [])];\n return evaluate(app(op, ...args), {\n space: EMPTY_SPACE,\n origin: \"$\",\n domains: env.domains,\n vars: { $list: list },\n });\n };\n const t: Traversal<K, T> = {\n items,\n strict: () => traversal(items, env, true),\n get: (k) => {\n const item = items.find((it) => it.key === k);\n return item === undefined ? none() : toOptional(item.result);\n },\n values: () => items.flatMap((it) => (it.result.ok ? [it.result.value] : [])),\n keys: () => items.flatMap((it) => (it.result.ok ? [it.key] : [])),\n errors: () => items.flatMap((it) => (it.result.ok ? [] : [it.result.error])),\n count: () => opt(reduce(\"count\")),\n sum: () => opt(reduce(\"sum\")),\n mean: () => opt(reduce(\"mean\")),\n min: () => opt(reduce(\"min\")),\n max: () => opt(reduce(\"max\")),\n any: () => opt(reduce(\"any\")),\n all: () => opt(reduce(\"all\")),\n none: () => opt(reduce(\"none\")),\n reduce: (op) => opt(reduce(\"reduce\", op)),\n reduceResult: (op, reduceOp) => reduce(op, reduceOp),\n map: <U>(f: (value: T, key: K) => U): Traversal<K, U> =>\n traversal(\n items.map((it): TraversalItem<K, U> => {\n if (!it.result.ok) return { key: it.key, result: it.result };\n try {\n return { key: it.key, result: ok(f(it.result.value, it.key)) };\n } catch (thrown) {\n return { key: it.key, result: fail(vexError(\"threw\", \"the map function threw an exception\", { thrown, focus: it.key })) };\n }\n }),\n env,\n isStrict,\n ),\n fold: <M>(monoid: Monoid<M>, f: (value: T) => M): M => t.values().reduce((acc, x) => monoid.concat(acc, f(x)), monoid.empty),\n };\n return t;\n}\n","/**\n * Sheets: named columns of formulas over a space. A formula can read a column at an address, like a cell\n * reference of a spreadsheet. A cell is one column at one key. A run evaluates each cell once, and each cell on a\n * cycle of reads gives `#CYCLE!`.\n *\n * A cell reference is the extension node `ext(\"vex.cell\", { column, at })`. Thus the IR has no new kind, and the\n * JSON form, `deps` and the traces work without a change.\n *\n * A cell can have its own formula. That formula replaces the formula of the column at the key of the cell. A\n * spreadsheet has the same thing: a cell with a formula that is different from the other formulas of its column.\n */\nimport { vexError } from \"./errors.ts\";\nimport { evaluate, explain, nestingOf, type CompileOptions, type EvalOptions, type ExtHandler, type Program } from \"./evaluate.ts\";\nimport { addrExprs, app, axes, children, each, ext, isFixedAddr, isMove, listOf, lit, moveExpr, shapeError, splitLimit, type Addr, type Axis, type Expr, type FixedMove, type Move } from \"./ir.ts\";\nimport { fail, type Result } from \"./result.ts\";\nimport { resolveAddr, type Space } from \"./space.ts\";\nimport type { Trace } from \"./trace.ts\";\n\n/** The extension kind of a cell reference. */\nexport const CELL_KIND = \"vex.cell\";\n\n/**\n * The data of a cell reference: the column, and the address from the focus. The data of an extension is not an\n * expression, so the address has only fixed moves. `cell` takes computed moves in another form.\n */\nexport interface CellRef {\n readonly column: string;\n readonly at: readonly FixedMove[];\n}\n\n/** This function makes the extension node of a cell reference. */\nconst cellRef = (column: string, at: readonly FixedMove[]): Expr => ext(CELL_KIND, { column, at } satisfies CellRef);\n\n/**\n * This function makes a read of the column `column` at the address `at` from the focus. An address of fixed moves gives\n * a cell reference. A computed move is an expression, not data (SHEET.CELL.COMPUTED). Thus it goes in the address of the\n * axis `window(0, 0)`, and the read is the one item of that axis. Each tier and the JSON form have this form.\n */\nexport const cell = (column: string, at: Addr = []): Expr => (isFixedAddr(at) ? cellRef(column, at) : app(\"first\", each(axes.window(0, 0), cellRef(column, []), at), lit({ strict: true })));\n\n/** This function tells if the data of an extension is a cell reference: a column, and an address of fixed moves. */\nexport const isCellRef = (u: unknown): u is CellRef =>\n typeof u === \"object\" &&\n u !== null &&\n typeof (u as { column?: unknown }).column === \"string\" &&\n Array.isArray((u as { at?: unknown }).at) &&\n (u as { at: readonly unknown[] }).at.every((m) => isMove(m) && moveExpr(m) === undefined);\n\n/** The formulas of single cells: for each column, the formula of each key that has its own formula. */\nexport type CellFormulas = ReadonlyMap<string, ReadonlyMap<string, Expr>>;\n\n/** A table of a run: its space, the formulas of its columns, and the formulas of its cells. */\nexport interface SheetTable {\n readonly space: Space;\n readonly columns: ReadonlyMap<string, Expr>;\n readonly cells?: CellFormulas;\n}\n\n/** The options of a sheet run: the evaluation options without the origin and the trace, and the tables. */\nexport type SheetOptions = Omit<EvalOptions, \"origin\" | \"trace\" | \"tables\"> & {\n /** The cells with their own formula. The formula of a cell replaces the formula of its column at its key. */\n readonly cells?: CellFormulas;\n /** The name of this table, so the axis `table(name)` in a formula of another table can read it. */\n readonly name?: string;\n /** The other tables, by name (SHEET.TABLES). A cell reference reads the table of the space where it evaluates. */\n readonly tables?: ReadonlyMap<string, SheetTable>;\n /**\n * The compiler of the formulas of the columns (SHEET.COMPILE), for example `tiered` of `@mark1russell7/vex-compiler`.\n * Without a compiler, the interpreter evaluates each formula. The compiled program must give the results of the\n * interpreter.\n */\n readonly compile?: CompileFn;\n};\n\n/** A compiler of the formulas of the columns of a run. */\nexport type CompileFn = (expr: Expr, options: CompileOptions) => Program;\n\n/**\n * The compiled programs of the formulas of the columns: one entry for each formula, for the last compiler and options.\n * A compiled program reads the cells of the active run, so each run with the same compiler and options can use it.\n */\nconst PROGRAMS = new WeakMap<Expr, { readonly compile: CompileFn; readonly domains: unknown; readonly fns: unknown; readonly extensions: unknown; readonly program: Program }>();\n\n/** The key of the options without extensions, for the extensions of the compiled programs. */\nconst NO_EXTENSIONS = {};\n\n/** The state of one table in a run. */\ninterface Table {\n /** The words for the table in a message: \"the sheet\" for the main table, or the table and its name. */\n readonly where: string;\n /** A short text for the ids of the cells of the table. */\n readonly tag: string;\n readonly space: Space;\n readonly columns: ReadonlyMap<string, Expr>;\n readonly cells: CellFormulas;\n // For each column, the number of keys at the start of the key order that a warm-up evaluated.\n readonly warmed: Map<string, number>;\n // The position of each key in the key order, made at the first warm-up.\n index: ReadonlyMap<string, number> | undefined;\n /** The result of each finished cell: for each column, the result at each key. */\n readonly done: Map<string, Map<string, Result<unknown>>>;\n}\n\nconst cycleError = (column: string, key: string): Result<never> =>\n fail(vexError(\"cycle\", `the cell \"${column}\" at \"${key}\" is on a cycle of cell references`, { origin: key, focus: key }));\n\n/** The id of a cell. */\nconst idOf = (t: Table, column: string, key: string): string => `${t.tag}\\u0001${column}\\u0000${key}`;\n\n/** This function gives the state of a table at the start of a run. */\nconst tableState = (where: string, i: number, t: SheetTable): Table => ({ where, tag: String(i), space: t.space, columns: t.columns, cells: t.cells ?? new Map(), warmed: new Map(), index: undefined, done: new Map() });\n\n/** This function gives the result of a finished cell, or `undefined`. */\nconst doneOf = (t: Table, column: string, key: string): Result<unknown> | undefined => t.done.get(column)?.get(key);\n\n/** This function keeps the result of a finished cell. */\nfunction setDone(t: Table, column: string, key: string, result: Result<unknown>): void {\n let results = t.done.get(column);\n if (results === undefined) {\n results = new Map();\n t.done.set(column, results);\n }\n results.set(key, result);\n}\n\n/** A direction of the reads of a column from itself: to an earlier key, to a later key, or down a tree to the children. */\nexport type Direction = \"before\" | \"after\" | \"down\";\n\n/** This function adds the direction of one move or one axis of a read of a column from itself. */\nfunction addDirection(d: Set<Direction>, m: Move | Axis): void {\n // The reverse order reads the same keys as its axis.\n if (m.t === \"reverse\") {\n addDirection(d, m.axis);\n return;\n }\n if (m.t === \"offset\" || m.t === \"window\") {\n // An offset moves by its first step that is not 0. A window reads the keys from `from` to `to`.\n const steps = m.t === \"offset\" ? [m.d.find((x) => x !== 0) ?? 0] : [m.from, m.to];\n // A step of 0 reads the cell itself, which is a cycle in each order.\n // Stryker disable next-line EqualityOperator: see the comment above\n if (steps.some((x) => x < 0)) d.add(\"before\");\n // Stryker disable next-line EqualityOperator: see the comment above\n if (steps.some((x) => x > 0)) d.add(\"after\");\n } else if (m.t === \"children\" || m.t === \"descendants\") d.add(\"down\");\n // The items of a list can be at each key, so the axis list gives no direction, and the other reads decide the order.\n}\n\n/** This function gives the base axis of an axis, and the tests of its `where` axes. */\nfunction partsOf(axis: Axis): { readonly base: Axis; readonly tests: readonly Expr[] } {\n const tests: Expr[] = [];\n let base = axis;\n while (base.t === \"where\") {\n tests.push(base.test);\n base = base.axis;\n }\n return { base, tests };\n}\n\n/**\n * This function gives the columns that the formulas of the column `self` read with a cell reference: its formula and\n * the formulas of its cells. It also gives the directions of their reads of the column itself. A read in the body or\n * in a test of an axis also has the direction of that axis. It walks each expression with a stack, not with recursion.\n */\nexport function readsOf(columns: ReadonlyMap<string, Expr>, cells: CellFormulas, self: string): { readonly columns: ReadonlySet<string>; readonly directions: ReadonlySet<Direction> } {\n const read = new Set<string>();\n const directions = new Set<Direction>();\n const formula = columns.get(self);\n // An expression that is not valid reads no column. Its evaluation gives the error (EVAL.SHAPE).\n const todo: [Expr, Axis | undefined][] = [...(formula === undefined ? [] : [formula]), ...(cells.get(self)?.values() ?? [])].filter((e) => shapeError(e) === undefined).map((e) => [e, undefined]);\n for (let item = todo.pop(); item !== undefined; item = todo.pop()) {\n const [e, axis] = item;\n // A test of the axis of a data limit reads at each target, as the test of an `each` does.\n const split = e.tag === \"iterate\" ? splitLimit(e) : undefined;\n if (split !== undefined) for (const x of split) todo.push([x, axis]);\n else if (e.tag === \"each\" || e.tag === \"fold\") {\n const { base, tests } = partsOf(e.axis);\n for (const x of [...(e.tag === \"each\" ? [e.body] : Object.values(e.step)), ...tests]) todo.push([x, base]);\n // The values of init, the result of a fold, the list of the axis list and the expressions of the address evaluate\n // at the node, so they keep the outer direction.\n const list = listOf(e.axis);\n for (const x of [...(e.tag === \"fold\" ? [...Object.values(e.init), e.result] : []), ...addrExprs(e.at), ...(list === undefined ? [] : [list])]) todo.push([x, axis]);\n } else if (e.tag !== \"ext\") {\n for (const child of children(e)) todo.push([child, axis]);\n // The data of an extension of another kind can look like a cell reference. It only changes the order of a fill.\n // Stryker disable next-line ConditionalExpression,LogicalOperator: see the comment above\n } else if (e.kind === CELL_KIND && isCellRef(e.data)) {\n read.add(e.data.column);\n // The directions of the reads of another column only change the order of a fill, because that column comes first.\n // Stryker disable next-line ConditionalExpression: see the comment above\n if (e.data.column === self) for (const m of [...(axis === undefined ? [] : [axis]), ...e.data.at]) addDirection(directions, m);\n }\n }\n return { columns: read, directions };\n}\n\n/**\n * This function gives the columns of a sheet in an order where each column comes after the columns that it reads.\n * The columns of a cycle keep their order. The columns with formulas of cells only come last.\n */\nexport function columnOrder(columns: ReadonlyMap<string, Expr>, cells: CellFormulas): readonly string[] {\n const names = new Set([...columns.keys(), ...cells.keys()]);\n let left = [...names].map((c) => ({ c, needs: [...readsOf(columns, cells, c).columns].filter((x) => x !== c && names.has(x)) }));\n const order: string[] = [];\n const placed = new Set<string>();\n // Each pass places each column whose reads are placed. A pass that places no column leaves a cycle, so it places\n // the first column that is left.\n while (left.length > 0) {\n const ready = left.filter((x) => x.needs.every((n) => placed.has(n)));\n for (const x of ready.length > 0 ? ready : left.slice(0, 1)) {\n order.push(x.c);\n placed.add(x.c);\n }\n left = left.filter((x) => !placed.has(x.c));\n }\n return order;\n}\n\n/**\n * This function gives the keys of a space in the order of the reads of a column from itself. A read of a later key\n * reverses the order. In a tree, a read of the children puts the children before their parent.\n */\nfunction keyOrder(s: Space, d: ReadonlySet<Direction>): readonly string[] {\n const reverse = d.has(\"after\") && !d.has(\"before\");\n const childrenOf = s.childrenOf?.bind(s);\n if (childrenOf === undefined) return reverse ? s.keys.toReversed() : s.keys;\n const post = d.has(\"down\");\n // The order with each parent before its children, and the order after the children is that order from the end, with\n // the siblings in the other order. `push` puts the next key to visit at the end of the stack.\n const backwards = post !== reverse;\n const push = (stack: string[], keys: readonly string[]): void => {\n for (const k of backwards ? keys : keys.toReversed()) stack.push(k);\n };\n const isChild = new Set(s.keys.flatMap((k) => childrenOf(k)));\n const stack: string[] = [];\n push(stack, s.keys.filter((k) => !isChild.has(k)));\n const out: string[] = [];\n for (let k = stack.pop(); k !== undefined; k = stack.pop()) {\n out.push(k);\n push(stack, childrenOf(k));\n }\n return post ? out.toReversed() : out;\n}\n\n/** The state of one cell in the search. */\ninterface Visit {\n readonly id: string;\n readonly table: Table;\n readonly column: string;\n readonly key: string;\n readonly index: number;\n low: number;\n reread: boolean;\n result: Result<unknown>;\n /** True when the last evaluation paused, because a cell that it reads is not finished. */\n paused: boolean;\n /** The cell that the evaluation waits for: a cell that the run started, or a cell that paused too. */\n need: Visit | undefined;\n}\n\n/**\n * The budget of the stack for the recursion of a run, in estimated frames. Each engine has more stack than this, so\n * the recursion of a run cannot fill the stack (SHEET.DEEP).\n */\nconst STACK_BUDGET = 3000;\n\n/**\n * One run of a sheet. It keeps the result of each cell that it evaluated. The space does not change, so a cell has\n * one result in a run.\n *\n * The run is a depth-first search with the algorithm of Tarjan for strongly connected components. A cell finishes\n * when its component finishes. Each cell of a component with two or more cells, or with a reference to itself,\n * gives `#CYCLE!`. A read of a cell that is not finished gives `#CYCLE!` too. Thus the order of the evaluations\n * does not change a result, also when `ifError` catches the error of a cycle.\n *\n * The search does not depend on the call stack of the engine (SHEET.DEEP). A read of a cell evaluates that cell\n * with recursion while the stack of the run stays in a budget. When a read is over the budget, the run starts the\n * cell, and the cell that reads it pauses. A paused evaluation reads no other cell and changes no state of the\n * search. The run then evaluates the started cell from its own list, and it evaluates the paused cell again after\n * that cell. A formula is pure (EVAL.PURE), so the second evaluation gives the result of one evaluation.\n *\n * A run can have more tables (SHEET.TABLES). Each table has its own space, and one search covers the cells of all\n * the tables. Thus a cycle across tables gives `#CYCLE!` too.\n */\nexport class SheetRun {\n readonly #main: Table;\n // The tables by name and by space. A cell reference reads the table of the space where it evaluates.\n readonly #byName = new Map<string, Table>();\n readonly #bySpace = new Map<Space, Table>();\n readonly #opts: Omit<EvalOptions, \"origin\" | \"trace\" | \"space\">;\n // The cells on the stack of the search: started, but their component is not finished.\n readonly #visits = new Map<string, Visit>();\n // Stryker disable next-line ArrayDeclaration: the search never reads below the root of a component\n readonly #stack: Visit[] = [];\n // The cell whose formula is in evaluation. At the top level, it is a placeholder that is not a cell.\n #top: Visit;\n // The placeholder at the top in a fill, and true when the evaluation of a fill reads a cell that is not finished.\n readonly #filling: Visit;\n #missed = false;\n #next = 0;\n // The estimated frames of the stack that the evaluations in progress use, and the cost of each program.\n #used = 0;\n readonly #cost = new Map<Expr, number>();\n readonly #budget: number;\n readonly #compile: CompileFn | undefined;\n readonly #compileOptions: CompileOptions;\n // The run that evaluates a formula with a compiled program. Each run is synchronous, so a run inside the evaluation\n // of another run gives the active run back when it ends.\n static #active: SheetRun | undefined;\n // The extensions of the compiled programs, for each object of extensions of the options. Their cell handler reads\n // the cells of the active run, so a compiled program does not depend on one run.\n static readonly #shared = new WeakMap<object, Readonly<Record<string, ExtHandler>>>();\n\n /** `budget` is the budget of the stack in estimated frames. A test can make it small, so the run pauses often. */\n constructor(columns: ReadonlyMap<string, Expr>, opts: SheetOptions, budget: number = STACK_BUDGET) {\n const { cells, name, tables, space, compile, ...rest } = opts;\n this.#main = { where: \"the sheet\", tag: \"0\", space, columns, cells: cells ?? new Map(), warmed: new Map(), index: undefined, done: new Map() };\n this.#bySpace.set(space, this.#main);\n if (name !== undefined) this.#byName.set(name, this.#main);\n if (tables !== undefined) {\n let i = 0;\n for (const [n, t] of tables) {\n if (this.#byName.has(n)) continue;\n const other = tableState(`the table \"${n}\"`, ++i, t);\n this.#byName.set(n, other);\n // A table with the space of an earlier table does not take its cells: the first table keeps the space.\n if (!this.#bySpace.has(t.space)) this.#bySpace.set(t.space, other);\n }\n }\n // Stryker disable next-line all: the placeholder is not a cell, so the search reads none of its fields\n this.#top = { id: \"\", table: this.#main, column: \"\", key: \"\", index: -1, low: -1, reread: false, result: cycleError(\"\", \"\"), paused: false, need: undefined };\n // Stryker disable next-line all: the placeholder is not a cell, so the search reads none of its fields\n this.#filling = { id: \"\", table: this.#main, column: \"\", key: \"\", index: 0, low: 0, reread: false, result: cycleError(\"\", \"\"), paused: false, need: undefined };\n this.#budget = budget;\n this.#compile = compile;\n const spaces = Object.fromEntries([...this.#byName].map(([n, t]) => [n, t.space]));\n this.#opts = { ...rest, tables: spaces, extensions: { ...rest.extensions, [CELL_KIND]: this.#handler } };\n const outer = rest.extensions ?? NO_EXTENSIONS;\n let shared = SheetRun.#shared.get(outer);\n if (shared === undefined) {\n shared = { ...rest.extensions, [CELL_KIND]: SheetRun.#cellOfActive };\n SheetRun.#shared.set(outer, shared);\n }\n this.#compileOptions = { ...this.#opts, extensions: shared };\n }\n\n /** The cell handler of the compiled programs: it reads the cells of the active run. */\n static readonly #cellOfActive: ExtHandler = (data, ctx) => {\n const run = SheetRun.#active;\n return run === undefined ? fail(vexError(\"unbound\", \"a compiled formula reads cells only in the evaluation of a sheet run\")) : run.#handler(data, ctx);\n };\n\n /** This method gives the program of a cell: its own formula, or the formula of its column (SHEET.CELL.FORMULA). */\n #programOf(t: Table, column: string, key: string): Expr | undefined {\n // Stryker disable next-line ConditionalExpression: without formulas of cells, the lookup gives undefined anyway\n const own = t.cells.size === 0 ? undefined : t.cells.get(column)?.get(key);\n return own ?? t.columns.get(column);\n }\n\n /** This method gives the error of a cell without a program. */\n #unbound(t: Table, column: string, key: string): Result<never> {\n const message = t.cells.has(column) ? `the cell \"${column}\" at \"${key}\" has no formula` : `${t.where} has no column \"${column}\"`;\n return fail(vexError(\"unbound\", message, { origin: key, focus: key }));\n }\n\n /** This method gives the table of a name for a read from a host. Without a name, it is the main table. */\n #named(table: string | undefined, key: string): Table | Result<never> {\n if (table === undefined) return this.#main;\n return this.#byName.get(table) ?? fail(vexError(\"no-table\", `the run has no table \"${table}\"`, { origin: key, focus: key }));\n }\n\n readonly #handler: ExtHandler = (data, ctx) => {\n // The interpreter gives an error without an origin the path and the position of its node.\n if (!isCellRef(data)) return fail(vexError(\"bad-expression\", \"a cell reference needs a column name and an address of fixed moves\"));\n const where = resolveAddr(ctx.space, ctx.position, data.at);\n if (!where.ok) return fail({ ...where.error, path: ctx.path });\n // The evaluation of a cell has the space of its table, and the body of the axis table has the space of that table.\n /* v8 ignore next -- @preserve: each space of an evaluation of the run is the space of a table */\n return this.#read(this.#bySpace.get(ctx.space) ?? this.#main, data.column, where.value);\n };\n\n /**\n * This method gives the result of one cell: the column `column` at the key `key` of the main table, or of the table\n * `table`. A read from a host first evaluates the column at the keys before `key`, in key order. Thus a recurrence\n * over the keys reads finished cells.\n */\n cell(column: string, key: string, table?: string): Result<unknown> {\n const t = this.#named(table, key);\n if (!(\"space\" in t)) return t;\n // The placeholder at the top has the index -1. A read inside a formula has a cell at the top, so it does not warm.\n if (this.#top.index >= 0) return this.#read(t, column, key);\n // A finished cell needs no warm-up.\n const done = doneOf(t, column, key);\n if (done !== undefined) return done;\n this.#warmTo(t, column, key);\n return this.#drive(t, column, key);\n }\n\n /** This method evaluates the column `column` at each key before `key` that it did not evaluate before, in key order. */\n #warmTo(t: Table, column: string, key: string): void {\n if (!t.columns.has(column)) return;\n const keys = t.space.keys;\n t.index ??= new Map(keys.map((k, i) => [k, i]));\n const end = t.index.get(key) ?? 0;\n const start = t.warmed.get(column) ?? 0;\n for (let i = start; i < end; i++) this.#drive(t, column, keys[i] ?? key);\n if (end > start) t.warmed.set(column, end);\n }\n\n /** This method gives the estimated frames of the stack that one evaluation of the program `program` uses. */\n #costOf(program: Expr): number {\n let cost = this.#cost.get(program);\n if (cost === undefined) {\n cost = 3 * (shapeError(program) === undefined ? nestingOf(program) : 1) + 16;\n this.#cost.set(program, cost);\n }\n return cost;\n }\n\n /** This method puts a new cell on the stack of the search. */\n #start(t: Table, column: string, key: string): Visit {\n const n = this.#next++;\n const visit: Visit = { id: idOf(t, column, key), table: t, column, key, index: n, low: n, reread: false, result: cycleError(column, key), paused: false, need: undefined };\n this.#visits.set(visit.id, visit);\n this.#stack.push(visit);\n return visit;\n }\n\n /** This method evaluates the formula of a cell once. When the evaluation pauses, the result of the cell does not change. */\n #evaluate(visit: Visit, program: Expr): void {\n const caller = this.#top;\n const cost = this.#costOf(program);\n visit.paused = false;\n visit.need = undefined;\n this.#top = visit;\n this.#used += cost;\n const result = this.#run(visit.table, visit.column, visit.key, program);\n this.#used -= cost;\n this.#top = caller;\n if (!visit.paused) visit.result = result;\n }\n\n /** This method evaluates the formula `program` of a cell, with its compiled program or with the interpreter. */\n #run(t: Table, column: string, key: string, program: Expr): Result<unknown> {\n const options = { ...this.#opts, space: t.space, origin: key };\n const compiled = this.#compiled(t, column, program);\n if (compiled === undefined) return evaluate(program, options);\n const active = SheetRun.#active;\n SheetRun.#active = this;\n const result = compiled.run(options);\n SheetRun.#active = active;\n return result;\n }\n\n /**\n * This method gives the compiled program of the formula of a column, or `undefined` for the interpreter. A formula\n * compiles once for each compiler and options, also across runs.\n */\n #compiled(t: Table, column: string, program: Expr): Program | undefined {\n const compile = this.#compile;\n // The formula of a cell evaluates once in a run, so the run compiles only the formulas of the columns.\n // V-056: a formula that is not an object cannot be a key of the cache, so the interpreter gives its error.\n if (compile === undefined || t.columns.get(column) !== program || typeof program !== \"object\" || program === null) return undefined;\n const { domains, fns, extensions } = this.#compileOptions;\n const hit = PROGRAMS.get(program);\n if (hit !== undefined && hit.compile === compile && hit.domains === domains && hit.fns === fns && hit.extensions === extensions) return hit.program;\n const compiled = compile(program, this.#compileOptions);\n PROGRAMS.set(program, { compile, domains, fns, extensions, program: compiled });\n return compiled;\n }\n\n /** This method ends a cell whose evaluation did not pause: it finishes its component, or it gives its low to the caller. */\n #end(visit: Visit, caller: Visit | undefined): void {\n if (visit.low === visit.index) this.#finish(visit);\n else if (caller !== undefined) caller.low = Math.min(caller.low, visit.low);\n }\n\n /** This method reads a cell from the formula of the cell at the top. */\n #read(t: Table, column: string, key: string): Result<unknown> {\n const done = doneOf(t, column, key);\n if (done !== undefined) return done;\n const caller = this.#top;\n // A paused evaluation reads no other cell, so it does not follow a path that its final evaluation does not follow.\n // In a fill, the cell goes to the search after the evaluation (SHEET.FILL).\n if (caller.paused) return cycleError(column, key);\n if (caller === this.#filling) {\n this.#missed = true;\n return cycleError(column, key);\n }\n const id = idOf(t, column, key);\n const seen = this.#visits.get(id);\n if (seen !== undefined) {\n // A read of a cell that is not finished: the caller and this cell are on one cycle. The cell is on the\n // stack of the search, so it is in the component of the caller. Thus a component with one cell is cyclic\n // only if that cell reads itself.\n caller.low = Math.min(caller.low, seen.index);\n seen.reread = true;\n return cycleError(column, key);\n }\n const program = this.#programOf(t, column, key);\n if (program === undefined) return this.#unbound(t, column, key);\n const visit = this.#start(t, column, key);\n if (this.#used + this.#costOf(program) > this.#budget) {\n // Over the budget: the caller pauses, and the run evaluates the new cell from its own list.\n caller.paused = true;\n caller.need = visit;\n return cycleError(column, key);\n }\n this.#evaluate(visit, program);\n if (visit.paused) {\n caller.paused = true;\n caller.need = visit;\n return cycleError(column, key);\n }\n this.#end(visit, caller);\n return doneOf(t, column, key) ?? cycleError(column, key);\n }\n\n /** This method evaluates a cell from the top level. The cells that pause go on a list, not on the call stack. */\n #drive(t: Table, column: string, key: string): Result<unknown> {\n const done = doneOf(t, column, key);\n if (done !== undefined) return done;\n if (this.#programOf(t, column, key) === undefined) return this.#unbound(t, column, key);\n const work: Visit[] = [this.#start(t, column, key)];\n for (let visit = work.at(-1); visit !== undefined; visit = work.at(-1)) {\n const program = this.#programOf(visit.table, visit.column, visit.key);\n /* v8 ignore next -- @preserve: a visit exists only for a cell with a program */\n if (program === undefined) break;\n this.#evaluate(visit, program);\n if (visit.paused) {\n // The cells that the evaluation waits for go on the list, the last one on the top.\n for (let need = visit.need; need !== undefined; need = need.need) work.push(need);\n continue;\n }\n work.pop();\n this.#end(visit, work.at(-1));\n }\n return doneOf(t, column, key) ?? cycleError(column, key);\n }\n\n /** This method takes the component of `root` from the stack, and sets the final result of each of its cells. */\n #finish(root: Visit): void {\n // The root is near the top of the stack, so the search starts at the top: a deep chain needs no long scan.\n const members = this.#stack.splice(this.#stack.lastIndexOf(root));\n // A component of two or more cells reads its root again, so root.reread alone decides. The length test is a guard.\n // Stryker disable next-line ConditionalExpression,LogicalOperator: members.length > 1 implies root.reread\n const cyclic = members.length > 1 || root.reread;\n for (const m of members) {\n // Stryker disable next-line CallExpression: a finished cell has a result, and a read looks for the result first\n this.#visits.delete(m.id);\n setDone(m.table, m.column, m.key, cyclic ? cycleError(m.column, m.key) : m.result);\n }\n }\n\n /** This method evaluates one cell with a trace of the nodes of its program. The result is the result of the cell. */\n explain(column: string, key: string, table?: string): Trace {\n const result = this.cell(column, key, table);\n const t = this.#named(table, key);\n const program = \"space\" in t ? this.#programOf(t, column, key) : undefined;\n if (program === undefined || !(\"space\" in t)) return { events: [], result };\n return { events: explain(program, { ...this.#opts, space: t.space, origin: key }).events, result };\n }\n\n /**\n * This method evaluates each cell of the table `table`, or of the main table (SHEET.FILL). Each column comes after\n * the columns that it reads, and the keys of a column come in the order of its reads from itself. Thus most reads\n * find a finished cell. An evaluation that reads a cell that is not finished has no effect, and the search then\n * evaluates its cell. A read of a cell gives the same result after a fill.\n */\n fill(table?: string): void {\n const t = table === undefined ? this.#main : this.#byName.get(table);\n // A read inside a formula has a cell at the top. A fill there has no effect.\n if (t === undefined || this.#top.index >= 0) return;\n const host = this.#top;\n for (const column of columnOrder(t.columns, t.cells)) {\n for (const key of keyOrder(t.space, readsOf(t.columns, t.cells, column).directions)) {\n const program = this.#programOf(t, column, key);\n if (program === undefined || doneOf(t, column, key) !== undefined) continue;\n this.#top = this.#filling;\n this.#missed = false;\n const result = this.#run(t, column, key, program);\n this.#top = host;\n if (this.#missed) this.#drive(t, column, key);\n else setDone(t, column, key, result);\n }\n }\n }\n\n /**\n * This method evaluates the column `column` at each key before `key`, in key order. A recurrence over the keys,\n * for example a running total, then reads finished cells.\n */\n warm(column: string, key: string, table?: string): void {\n const t = this.#named(table, key);\n // Stryker disable next-line all: a warm-up changes no result, only the depth of the recursion (SHEET.ORDER)\n if (\"space\" in t) this.#warmTo(t, column, key);\n }\n}\n","/**\n * The typed builder. Method calls make an expression of the IR. The builder has no other job: it does not\n * evaluate anything until a caller asks for a value.\n */\nimport type { AnyDomain, Domain, OpSpec, PrimitiveKind } from \"./domain.ts\";\nimport type { VexError } from \"./errors.ts\";\nimport { evaluate, explain, type EvalOptions, type ExtHandler, type FreeFn } from \"./evaluate.ts\";\nimport { addrExprs, app, axisExprs, call as callExpr, children, dataLimit, each, ext, fix as fixExpr, fn as fnExpr, fold as foldExpr, index as indexMove, iterate as iterateExpr, key as keyMove, last as lastExpr, let_, lit, listOf, offset as offsetMove, other as otherMove, origin as originMove, parent as parentMove, rec, ref, toPath, v, type Addr, type Axis, type DataLimit, type Expr, type FixJoin, type ItemNames, type Move } from \"./ir.ts\";\nimport { cell as cellRef, SheetRun, type CellFormulas } from \"./sheet.ts\";\nimport { ok, toOptional, type Optional, type Result } from \"./result.ts\";\nimport type { Space } from \"./space.ts\";\nimport type { Trace } from \"./trace.ts\";\nimport { vexList, type VexList } from \"./list.ts\";\nimport { traversal, type Traversal } from \"./traversal.ts\";\n\n// ---------------------------------------------------------------- argument tokens\n\ndeclare const ARG_TYPE: unique symbol;\ndeclare const CHAIN_VALUE: unique symbol;\ndeclare const FN_RESULT: unique symbol;\n\n/** An argument token: an expression with the static type `T` of its value. */\nexport interface Arg<T> {\n readonly kind: \"vex.arg\";\n readonly expr: Expr;\n /** This phantom member carries the type. It is not present at run time. */\n readonly [ARG_TYPE]?: T;\n}\n\nconst argToken = <T>(expr: Expr): Arg<T> => ({ kind: \"vex.arg\", expr });\n\n\n// ---------------------------------------------------------------- type helpers\n\n/**\n * The value of a column with the join `J`: a boolean for `or` and `and`, and a number for `max` and `min` (FIX.KIND). A\n * union of joins has no one kind, so it gives `never`.\n */\nexport type FixValue<J extends FixJoin> = [J] extends [\"or\" | \"and\"] ? boolean : [J] extends [\"max\" | \"min\"] ? number : never;\n\n/** The keys of any member of a union of record types. */\ntype AllKeys<O> = O extends unknown ? keyof O : never;\n\n/** The type of field `P` in the members of `O` that have it. */\ntype FieldType<O, P extends PropertyKey> = O extends unknown ? (P extends keyof O ? O[P] : never) : never;\n\n/**\n * The merged view of a union of record types: each field of any member, with the union of its types. A record\n * without the field gives `#N/A` at run time.\n */\nexport type Merge<O> = { readonly [P in AllKeys<O>]: FieldType<O, P> };\n\n/** The keys of `O` whose values have the type `T`. */\nexport type KeysOfType<O, T> = { [P in keyof O]-?: [NonNullable<O[P]>] extends [never] ? never : NonNullable<O[P]> extends T ? P : never }[keyof O] & string;\n\n/** The method names of `D`. */\nexport type MethodKeys<D> = { [P in keyof D]-?: D[P] extends (...args: never[]) => unknown ? P : never }[keyof D] & string;\n\n/** The value type of a domain. */\nexport type DomainValue<Dm> = Dm extends Domain<string, infer D, infer _Ops> ? D : never;\n\ntype OpsOf<Dm> = Dm extends Domain<string, unknown, infer Ops> ? Ops : Dm extends { readonly ops: infer Ops } ? Ops : never;\n\n/** The op names that a chain over a value of domain `Dm` can use. */\nexport type OpNames<Dm> =\n | (keyof OpsOf<Dm> & string)\n | (Dm extends { readonly methods: \"all\" } ? MethodKeys<DomainValue<Dm>> : never);\n\ntype FnOf<Dm, M extends string> = M extends keyof OpsOf<Dm>\n ? OpsOf<Dm>[M] extends { readonly fn: (self: never, ...args: infer P) => infer R }\n ? (...args: P) => R\n : M extends keyof DomainValue<Dm>\n ? DomainValue<Dm>[M]\n : never\n : M extends keyof DomainValue<Dm>\n ? DomainValue<Dm>[M]\n : never;\n\n/** The parameters of op `M` after the receiver. */\nexport type OpParams<Dm, M extends string> = FnOf<Dm, M> extends (...args: infer P) => unknown ? P : never;\n\n/** The value type that op `M` gives. */\nexport type OpReturn<Dm, M extends string> = FnOf<Dm, M> extends (...args: never[]) => infer R ? R : never;\n\ntype Lifts<Dm, M extends string> = M extends keyof OpsOf<Dm> ? (OpsOf<Dm>[M] extends { readonly liftScalar: true } ? true : false) : false;\n\n/** The first domain of `Dms` whose values include `T`, or `never`. */\nexport type DomainFor<Dms extends readonly AnyDomain[], T> = Dms extends readonly [infer H, ...infer R extends readonly AnyDomain[]]\n ? [T] extends [never]\n ? never\n : [T] extends [DomainValue<H>]\n ? H\n : DomainFor<R, T>\n : never;\n\ntype UnionToIntersection<U> = (U extends unknown ? (x: U) => void : never) extends (x: infer I) => void ? I : never;\ntype LastOf<U> = UnionToIntersection<U extends unknown ? () => U : never> extends () => infer R ? R : never;\n\n/** `true` if `other()` is permitted for the key type: a pair of keys, or keys that the compiler does not know. */\nexport type AllowsOther<K extends string> = string extends K\n ? true\n : `${number}` extends K\n ? true\n : [Exclude<K, LastOf<K>>] extends [never]\n ? false\n : [Exclude<Exclude<K, LastOf<K>>, LastOf<Exclude<K, LastOf<K>>>>] extends [never]\n ? true\n : false;\n\n/**\n * The inputs for an argument with the parameter type `P`. The input can be a literal of type `P`, but not a bare\n * string. It can be a field of the record with type `P`, an argument token, or a chain that gives `P`. If the op\n * lifts scalars, it can also be a number.\n */\nexport type ArgInput<P, Ctx extends ChainContext, Lift extends boolean> =\n | (P extends string ? never : P)\n | KeysOfType<Ctx[\"record\"], P>\n | Arg<P>\n | ChainOf<Ctx, P>\n | (Lift extends true ? ([P] extends [DomainValue<DomainFor<Ctx[\"domains\"], P>>] ? LiftedNumber<Ctx> : never) : never);\n\n/**\n * A number argument for a domain parameter of an op with `liftScalar` (TYPE.LIFT): a number, a field with numbers, an\n * argument or a chain. The interpreter lifts each of them with `fromScalar` (CALL.LIFT).\n */\ntype LiftedNumber<Ctx extends ChainContext> = number | KeysOfType<Ctx[\"record\"], number> | Arg<number> | ChainOf<Ctx, number>;\n\ntype MapArgs<P extends readonly unknown[], Ctx extends ChainContext, Lift extends boolean> = { [I in keyof P]: ArgInput<P[I], Ctx, Lift> };\n\n/** A table of free functions. The first parameter of a function gets the current value of the chain. */\nexport type FnTable = Readonly<Record<string, (...args: never[]) => unknown>>;\n\n/** The free functions of a builder without `withOptions`: none, so `call` accepts no name. */\n// oxlint-disable-next-line typescript/no-generated-empty-object-type -- an empty table is the intent.\nexport type NoFns = Record<never, never>;\n\n/** The static context of a chain: its domains, its key type, its record type and its free functions. */\nexport interface ChainContext {\n readonly domains: readonly AnyDomain[];\n readonly keys: string;\n readonly record: unknown;\n readonly fns?: FnTable;\n}\n\ntype FnsOf<Ctx extends ChainContext> = NonNullable<Ctx[\"fns\"]>;\ntype FnParams<F> = F extends (...args: infer P) => unknown ? P : never;\ntype FirstParam<P> = P extends readonly [infer A, ...unknown[]] ? A : unknown;\ntype RestParams<P> = P extends readonly [unknown, ...infer R] ? R : [];\n\n/** The names of the free functions whose first parameter accepts a value of type `T`. */\nexport type CallableFns<Ctx extends ChainContext, T> = {\n [K in keyof FnsOf<Ctx>]: [T] extends [FirstParam<FnParams<FnsOf<Ctx>[K]>>] ? K : never;\n}[keyof FnsOf<Ctx>] &\n string;\n\n/** The inputs for the parameters of the free function `N` after its first parameter. */\nexport type CallArgs<Ctx extends ChainContext, N extends keyof FnsOf<Ctx>> = MapArgs<RestParams<FnParams<FnsOf<Ctx>[N]>>, Ctx, false>;\n\n/** The return type of the free function `N`. */\nexport type CallReturn<Ctx extends ChainContext, N extends keyof FnsOf<Ctx>> = FnsOf<Ctx>[N] extends (...args: never[]) => infer R ? R : unknown;\n\n/** The ops section `._` of a chain whose value has domain `Dm`. */\nexport type OpsProxy<Ctx extends ChainContext, Dm> = {\n readonly [M in OpNames<Dm>]: (...args: MapArgs<OpParams<Dm, M>, Ctx, Lifts<Dm, M>>) => ChainOf<Ctx, OpReturn<Dm, M>>;\n};\n\n// ---------------------------------------------------------------- chain types\n\n/** The members of every chain. */\nexport interface ChainBase<Ctx extends ChainContext, T> {\n readonly kind: \"vex.chain\";\n /** This phantom member carries the value type. It is not present at run time. */\n readonly [CHAIN_VALUE]?: T;\n /** The expression of the chain, as plain data. */\n readonly program: Expr;\n /** This method evaluates the chain at a key. An error gives `none`. */\n at(k: Ctx[\"keys\"]): Optional<T>;\n /** This method is the same as `at`. The v0.9 spec calls it `value`. */\n value(k: Ctx[\"keys\"]): Optional<T>;\n /** This method evaluates the chain at a key, and gives the error if there is one. */\n result(k: Ctx[\"keys\"]): Result<T>;\n /** This method evaluates the chain at a key, with a trace of each node. */\n explain(k: Ctx[\"keys\"]): Trace;\n /** This method evaluates the chain at each key of the space (the start axis). */\n all(): Traversal<Ctx[\"keys\"], T>;\n /** This method gives a chain whose value is a field of the record at the current address. */\n from<P extends keyof Ctx[\"record\"] & string>(field: P): ChainOf<Ctx, NonNullable<Ctx[\"record\"][P]>>;\n /**\n * Navigation: later field references read at the key `k`. A chain of a text gives the key, and it evaluates at the\n * focus before the moves (NAV.COMPUTED).\n */\n to(k: Ctx[\"keys\"] | ChainBase<Ctx, string>): ChainOf<Ctx, T>;\n /**\n * Navigation: later field references read at the key with this position in the key order. A chain of a number gives\n * the position, and it evaluates at the focus before the moves (NAV.COMPUTED).\n */\n index(i: number | ChainBase<Ctx, number>): ChainOf<Ctx, T>;\n /** Navigation: later field references read at a relative position in an array or a grid. */\n offset(...d: readonly number[]): ChainOf<Ctx, T>;\n /** Navigation: later field references read at the origin again. */\n origin(): ChainOf<Ctx, T>;\n /** Navigation: later field references read at the parent of the focus, in a tree space. A root gives `#REF!`. */\n parent(): ChainOf<Ctx, T>;\n /** This method uses `fallback` when the chain gives an error. */\n ifError<U>(fallback: ArgInput<U, Ctx, false> | T): ChainOf<Ctx, T | U>;\n /**\n * This method gives `then` when the boolean value is true, and `otherwise` when it is false (the form `if`). Only\n * the selected branch evaluates.\n */\n if<U, V>(this: ChainBase<Ctx, boolean>, then: ArgInput<U, Ctx, false>, otherwise: ArgInput<V, Ctx, false>): ChainOf<Ctx, U | V>;\n /**\n * This method applies the free function `name` of `withOptions`. The function gets the current value as its first\n * argument, then `args`. The types accept only the functions whose first parameter accepts the current value.\n */\n call<N extends CallableFns<Ctx, T>>(name: N, ...args: CallArgs<Ctx, N>): ChainOf<Ctx, CallReturn<Ctx, N>>;\n /** This method evaluates each branch with the current value, and gives a record of the results. */\n fork<const B extends Readonly<Record<string, (c: ChainOf<Ctx, T>) => ChainBase<Ctx, unknown>>>>(branches: B): ChainOf<Ctx, { readonly [N in keyof B]: ValueOf<ReturnType<B[N]>> }>;\n /**\n * This method makes up to `limit` steps (ITERATE.LIMIT). A list chain or a `DataLimit` gives a limit from the data\n * (ITERATE.LIMIT.DATA). `init` gives the names and their first values, and `step` gives the next values. A true\n * `until` stops the steps (ITERATE.UNTIL). `result` gives the value of the chain. A name with a list chain as its\n * first value is a list chain (BUILD.LIST.LOOP), and a list result gives a list chain.\n */\n iterate<const I extends Readonly<Record<string, unknown>>, U>(\n limit: number | DataLimit | ListChain<Ctx, unknown>,\n init: I,\n step: (vars: LoopVars<Ctx, I>) => NoInfer<LoopStep<Ctx, I>>,\n result: (vars: LoopVars<Ctx, I>) => ListChain<Ctx, U>,\n opts?: { readonly until?: (vars: LoopVars<Ctx, I>) => ArgInput<boolean, Ctx, false> },\n ): ListChain<Ctx, U>;\n iterate<const I extends Readonly<Record<string, unknown>>, R>(\n limit: number | DataLimit | ListChain<Ctx, unknown>,\n init: I,\n step: (vars: LoopVars<Ctx, I>) => NoInfer<LoopStep<Ctx, I>>,\n result: (vars: LoopVars<Ctx, I>) => ArgInput<R, Ctx, false>,\n opts?: { readonly until?: (vars: LoopVars<Ctx, I>) => ArgInput<boolean, Ctx, false> },\n ): ChainOf<Ctx, R>;\n /**\n * This method makes a fixed-point column (BUILD.FIX). `init` gives each row its value of round 0. `step` gets a chain\n * of the last round at the focus, and it gives the next value of the row. `join` keeps each row on one way (FIX.JOIN).\n * The value of the chain is the row of the focus, and the rounds end when no row changes (FIX.ROUNDS).\n */\n fix<J extends FixJoin>(\n name: string,\n join: J,\n init: ArgInput<FixValue<J>, Ctx, false>,\n step: (last: ChainOf<Ctx, FixValue<J>>) => NoInfer<ArgInput<FixValue<J>, Ctx, false>>,\n ): ChainOf<Ctx, FixValue<J>>;\n /** This method binds names for the body. The body gets a variable token for each name. */\n with<const B extends Readonly<Record<string, unknown>>, U>(\n binds: B,\n body: (c: ChainOf<Ctx, T>, vars: { readonly [N in keyof B]: Arg<ArgValue<Ctx, B[N]>> }) => ChainBase<Ctx, U>,\n ): ChainOf<Ctx, U>;\n /**\n * This method binds functions of `root.fn` (BUILD.FN) and gives the value of `body`. `call` gives a chain of a call of\n * each function. A function cannot call another function of the same `functions`, so it uses an outer one (FN.TOTAL).\n */\n functions<const F extends Readonly<Record<string, FnDef<readonly FnParamKind[], unknown>>>, U>(fns: F, body: (c: ChainOf<Ctx, T>, call: FnCalls<Ctx, F>) => ChainBase<Ctx, U>): ChainOf<Ctx, U>;\n /** The others axis: the body evaluates at each key except the focus. Its start value is the current value. */\n others<U>(body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The neighbors axis of a grid. */\n neighbors<U>(n: 4 | 8, body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The all axis inside the expression: the body evaluates at each key, with the current value as start value. */\n each<U>(body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The children axis of a tree space: the body evaluates at each child of the focus. */\n children<U>(body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The ancestors axis of a tree space: the parent first, the root last. */\n ancestors<U>(body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The descendants axis of a tree space: depth first, each parent before its children. */\n descendants<U>(body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The siblings axis of a tree space: the other children of the parent, or the other roots for a root. */\n siblings<U>(body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /**\n * The window axis of an array space or a tree space: the keys at the offsets from `from` to `to` of the focus, in\n * order. The offset 0 is the focus. An offset outside the space has no target.\n */\n window<U>(from: number, to: number, body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /**\n * The table axis: the body evaluates at each key of the table `name` of the evaluation, in the space of that table.\n * The body reads the fields of that table, but the types of the chain are the types of this space.\n */\n table<U>(name: string, body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The successors axis of a graph space: the ends of the edges from the focus. In a tree space, the children. */\n successors<U>(body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The predecessors axis of a graph space: the keys with an edge to the focus. In a tree space, the parent. */\n predecessors<U>(body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The reachable axis of a graph space: each key that a path of edges reaches, in breadth-first order. */\n reachable<U>(body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n}\n\n/** The options of an axis. */\nexport interface AxisOpts<Ctx extends ChainContext, T> {\n /** A test at each target. The body evaluates only at the targets where the test gives `true`. */\n readonly where?: (c: ChainOf<Ctx, T>) => ChainBase<Ctx, boolean>;\n /** With `true`, the targets come in the reverse order (AXIS.REVERSE). The axis table has no reverse order. */\n readonly reverse?: boolean;\n}\n\n/** A function of the builder in its implementation: the kinds of its parameters, and the function that gives its body. */\ninterface FnDefImpl {\n readonly kind: \"vex.fn\";\n readonly params: readonly string[];\n readonly build: (...params: ChainImpl[]) => { readonly program: Expr };\n}\n\n/** The options of an axis in the implementation of the builder. */\ntype AxisOptsImpl = { readonly where?: (c: ChainImpl) => { readonly program: Expr }; readonly reverse?: boolean };\n\n/** The members of a chain whose value has a domain. */\nexport interface DomainMembers<Ctx extends ChainContext, Dm> {\n /** The ops of the domain of the current value. */\n readonly _: OpsProxy<Ctx, Dm>;\n}\n\n/** The members of a chain over a space whose keys permit `other()`. */\nexport interface OtherMembers<Ctx extends ChainContext, T> {\n /** Navigation: later field references read at the other key of the pair. */\n other(): ChainOf<Ctx, T>;\n}\n\n/** A chain with the current value type `T`. */\nexport type ChainOf<Ctx extends ChainContext, T> = ChainBase<Ctx, T> &\n ([DomainFor<Ctx[\"domains\"], T>] extends [never] ? unknown : DomainMembers<Ctx, DomainFor<Ctx[\"domains\"], T>>) &\n (AllowsOther<Ctx[\"keys\"]> extends true ? OtherMembers<Ctx, T> : unknown);\n\n/** The value type of a chain. */\nexport type ValueOf<C> = C extends { readonly [CHAIN_VALUE]?: infer T } ? T : never;\n\n/** The value type of an argument input. */\nexport type ArgValue<Ctx extends ChainContext, A> = A extends Arg<infer T>\n ? T\n : A extends { readonly kind: \"vex.chain\" }\n ? ValueOf<A>\n : A extends keyof Ctx[\"record\"] & string\n ? NonNullable<Ctx[\"record\"][A]>\n : A;\n\n/** The type of a value of a name of a loop: a literal of `init` gives its primitive type. */\ntype LoopValue<Ctx extends ChainContext, A> = ArgValue<Ctx, A> extends infer T ? (T extends number ? number : T extends string ? string : T extends boolean ? boolean : T) : never;\n\n/** The type of the items of a list chain, or `never` for another value. */\ntype ItemsOf<A> = A extends { readonly kind: \"vex.list-chain\"; readonly [CHAIN_VALUE]?: VexList<infer U> } ? U : never;\n\n/** A value of `init` that is a list chain: then the name of the loop holds a list (LOOP.LIST). */\ntype IsList<A> = A extends { readonly kind: \"vex.list-chain\" } ? true : false;\n\n/**\n * The chain of a name of a loop: a list chain for a list chain of `init` (BUILD.LIST.LOOP), and else a chain of its\n * value.\n */\nexport type LoopVar<Ctx extends ChainContext, A> = IsList<A> extends true ? ListChain<Ctx, ItemsOf<A>> : ChainOf<Ctx, LoopValue<Ctx, A>>;\n\n/** The names of a loop of the builder: a chain of the value of each name of `init` (LOOP.NAMES). */\nexport type LoopVars<Ctx extends ChainContext, I> = { readonly [N in keyof I]: LoopVar<Ctx, I[N]> };\n\n/** The next value of a name of a loop. A name of a list takes a list chain with items of the same type. */\nexport type LoopNext<Ctx extends ChainContext, A> = IsList<A> extends true ? ListChain<Ctx, ItemsOf<A>> : ArgInput<LoopValue<Ctx, A>, Ctx, false>;\n\n/** The next values of a step of a loop: a value for some of the names of `init`. */\nexport type LoopStep<Ctx extends ChainContext, I> = { readonly [N in keyof I]?: LoopNext<Ctx, I[N]> };\n\n/** The kind of a parameter of a function of the builder (BUILD.FN): a primitive type, or `any`. */\nexport type FnParamKind = PrimitiveKind | \"any\";\n\n/** The type of a value of a kind of a parameter. */\nexport type KindValue<K> = K extends \"number\" ? number : K extends \"string\" ? string : K extends \"boolean\" ? boolean : unknown;\n\n/** A chain of each parameter of a function of the builder. */\nexport type ParamChains<Ctx extends ChainContext, P extends readonly FnParamKind[]> = { readonly [I in keyof P]: ChainOf<Ctx, KindValue<P[I]>> };\n\n/** A function of the builder (BUILD.FN): the kinds of its parameters and its body. `functions` binds it. */\nexport interface FnDef<P extends readonly FnParamKind[], R> {\n readonly kind: \"vex.fn\";\n readonly params: P;\n /** This phantom member carries the type of the result. It is not present at run time. */\n readonly [FN_RESULT]?: R;\n}\n\n/** The calls of the functions of `functions`: each gives a chain of a call (FN.CALL). */\nexport type FnCalls<Ctx extends ChainContext, F> = {\n readonly [N in keyof F]: F[N] extends FnDef<infer P, infer R> ? (...args: { readonly [I in keyof P]: ArgInput<KindValue<P[I]>, Ctx, false> }) => ChainOf<Ctx, R> : never;\n};\n\n/**\n * The value of the body of an axis: a chain, or a list chain (BUILD.LIST.BUILD). For a list chain, the value of each\n * item of the axis is a list, so `flat` joins the lists.\n */\nexport type AxisBody<Ctx extends ChainContext, U> = ChainBase<Ctx, U> | ListBody<U>;\n\n/** A list chain as the body of an axis. Its phantom member carries the list. */\nexport interface ListBody<U> {\n readonly kind: \"vex.list-chain\";\n readonly [CHAIN_VALUE]?: U;\n readonly program: Expr;\n}\n\n/** A chain whose value is a list: the result of an axis, of a list op or of a list literal. */\nexport interface ListChain<Ctx extends ChainContext, U> {\n readonly kind: \"vex.list-chain\";\n /** This phantom member carries the type of the list. It is not present at run time. */\n readonly [CHAIN_VALUE]?: VexList<U>;\n /** The expression of the chain, as plain data. */\n readonly program: Expr;\n /**\n * This method folds the items in the order of the axis (FOLD.ORDER). `init` gives the names and their first values.\n * `step` gives the next values from the names and the item, a chain at the target. `result` gives the value. In a\n * fold over the axis `list`, `step` also gets the index of the item (BUILD.LIST.ITEM).\n */\n fold<const I extends Readonly<Record<string, unknown>>, V>(\n init: I,\n step: (vars: LoopVars<Ctx, I>, item: ChainOf<Ctx, U>, index: ChainOf<Ctx, number>) => NoInfer<LoopStep<Ctx, I>>,\n result: (vars: LoopVars<Ctx, I>) => ListChain<Ctx, V>,\n ): ListChain<Ctx, V>;\n fold<const I extends Readonly<Record<string, unknown>>, R>(\n init: I,\n step: (vars: LoopVars<Ctx, I>, item: ChainOf<Ctx, U>, index: ChainOf<Ctx, number>) => NoInfer<LoopStep<Ctx, I>>,\n result: (vars: LoopVars<Ctx, I>) => ArgInput<R, Ctx, false>,\n ): ChainOf<Ctx, R>;\n count(opts?: ListOpts): ChainOf<Ctx, number>;\n sum(this: ListChain<Ctx, number>, opts?: ListOpts): ChainOf<Ctx, number>;\n mean(this: ListChain<Ctx, number>, opts?: ListOpts): ChainOf<Ctx, number>;\n min(this: ListChain<Ctx, number>, opts?: ListOpts): ChainOf<Ctx, number>;\n max(this: ListChain<Ctx, number>, opts?: ListOpts): ChainOf<Ctx, number>;\n any(this: ListChain<Ctx, boolean>, opts?: ListOpts): ChainOf<Ctx, boolean>;\n all(this: ListChain<Ctx, boolean>, opts?: ListOpts): ChainOf<Ctx, boolean>;\n none(this: ListChain<Ctx, boolean>, opts?: ListOpts): ChainOf<Ctx, boolean>;\n values(opts?: ListOpts): ChainOf<Ctx, readonly U[]>;\n /** The keys of the items with a value, in the order of the axis. */\n keys(opts?: ListOpts): ChainOf<Ctx, readonly Ctx[\"keys\"][]>;\n /** The error of each item that failed, in the order of the axis. */\n errors(): ChainOf<Ctx, readonly VexError[]>;\n first(opts?: ListOpts): ChainOf<Ctx, U>;\n reduce(op: OpNames<DomainFor<Ctx[\"domains\"], U>>, opts?: ReduceOpts<Ctx>): ChainOf<Ctx, U>;\n /** The items in the order of their values, from the smallest (LIST.SORT). The values are numbers or texts of one kind. */\n sortBy(opts?: ListOpts): ListChain<Ctx, U>;\n /** The first `n` items (LIST.TAKE). */\n take(n: number, opts?: ListOpts): ListChain<Ctx, U>;\n /** The value of the item at the position `i`, from 0 (LIST.NTH). */\n nth(i: number, opts?: ListOpts): ChainOf<Ctx, U>;\n /**\n * This list with `value` as the value of the item at the position `i`, from 0 (LIST.SETNTH). The item keeps its key.\n * A chain or `lit` gives the value, and a chain can give the position. Both evaluate at the focus.\n */\n setNth<V>(i: number | ChainBase<Ctx, number>, value: ChainBase<Ctx, V> | Arg<V>, opts?: ListOpts): ListChain<Ctx, U | V>;\n /**\n * The value of the first item with the key `k` (LIST.GET). A chain of a text gives the key, and it evaluates at the\n * focus. A key that no item has gives `#N/A`. Thus a step reads the old value of each key.\n */\n get(k: Ctx[\"keys\"] | ChainBase<Ctx, string>, opts?: ListOpts): ChainOf<Ctx, U>;\n /** The items after the first `n` items (LIST.DROP). Thus `drop(1)` removes the first item of a stack. */\n drop(n: number, opts?: ListOpts): ListChain<Ctx, U>;\n /** The items of this list, and then the items of `other` (LIST.APPEND). Two items can have the same key. */\n append<V>(other: ListChain<Ctx, V>, opts?: ListOpts): ListChain<Ctx, U | V>;\n /** The items of this list whose key is not the key of an item of `other` (LIST.WITHOUT). */\n without<V>(other: ListChain<Ctx, V>, opts?: ListOpts): ListChain<Ctx, U>;\n /** The items of the lists that are the values of the items, in order (LIST.FLAT). The values must be lists. */\n flat<V>(this: ListChain<Ctx, VexList<V>>, opts?: ListOpts): ListChain<Ctx, V>;\n /** The first item of each value, in the order of the list (LIST.DISTINCT). The values are numbers, texts or booleans. */\n distinct(opts?: ListOpts): ListChain<Ctx, U>;\n /**\n * The groups of the items by the text keys of `keys` (LIST.GROUP). The key at a position is the key of the item at\n * the same position. Each key gives one item, and its value is the list of its items (BUILD.LIST.GROUP).\n */\n group(keys: ListChain<Ctx, string>, opts?: ListOpts): ListChain<Ctx, VexList<U>>;\n /** The texts of the items with the text `sep` between them (LIST.JOIN). A chain of a text gives the separator. */\n join(this: ListChain<Ctx, string>, sep: string | ChainBase<Ctx, string>, opts?: ListOpts): ChainOf<Ctx, string>;\n /**\n * The axis list (AXIS.LIST): the body evaluates at the key of each item, in the order of the list. The body reads the\n * fields of the record of the item. The chain of the body has no value of its own. The body also gets a chain of the\n * value of the item and a chain of its index, from 0 (BUILD.LIST.ITEM).\n */\n each<V>(body: (c: ChainOf<Ctx, null>, item: ChainOf<Ctx, U>, index: ChainOf<Ctx, number>) => AxisBody<Ctx, V>, opts?: AxisOpts<Ctx, null>): ListChain<Ctx, V>;\n /** The list at the origin `k`: one item for each target of the axis, with its key and its result. */\n result(k: Ctx[\"keys\"]): Result<VexList<U>>;\n /** The list at the origin `k`, as an `Optional`. */\n at(k: Ctx[\"keys\"]): Optional<VexList<U>>;\n /** The trace of the evaluation of the list at the origin `k`. */\n explain(k: Ctx[\"keys\"]): Trace;\n}\n\n/** The options of a list reduction. */\nexport interface ListOpts {\n /** With `true`, an error item makes the result that error. The default skips error items. */\n readonly strict?: boolean;\n}\n\n/** The options of `reduce`. `domain` names the domain whose identity an empty list gives (LIST.EMPTY). */\nexport interface ReduceOpts<Ctx extends ChainContext> extends ListOpts {\n readonly domain?: Ctx[\"domains\"][number][\"name\"];\n}\n\n/** The root of the builder for one space. */\nexport interface Root<Ctx extends ChainContext> {\n /** This method starts a chain with a field of the record at the focus. */\n from<P extends keyof Ctx[\"record\"] & string>(field: P): ChainOf<Ctx, NonNullable<Ctx[\"record\"][P]>>;\n /** This method starts a chain with a value. A string is a field reference, as in an argument. */\n start<const T>(value: T): ChainOf<Ctx, ArgValue<Ctx, T>>;\n /** This method makes an absolute reference: the field of the record at key `k`. */\n of<P extends keyof Ctx[\"record\"] & string>(k: Ctx[\"keys\"], field: P): Arg<NonNullable<Ctx[\"record\"][P]>>;\n /** This method makes a reference to a dotted path at the focus, with the type that the caller gives. */\n field<T>(path: string): Arg<T>;\n /** This method makes a literal argument. Use it for a string or an array: a bare string is a field reference. */\n lit<const T>(value: T): Arg<T>;\n /** This method makes an absolute reference to a dotted path at key `k`, with the type that the caller gives. */\n ofPath<T>(k: Ctx[\"keys\"], path: string): Arg<T>;\n /** This method makes a record argument from field arguments. */\n rec<const F extends Readonly<Record<string, unknown>>>(fields: F): Arg<{ readonly [N in keyof F]: ArgValue<Ctx, F[N]> }>;\n /**\n * This method makes a list literal (LIST.LITERAL, BUILD.LIST.LOOP): an item for each pair of a key and a value, in\n * order. Without pairs, it gives the empty list. Thus a loop can start a stack or a seen set.\n */\n list<U = unknown>(items?: readonly (readonly [Ctx[\"keys\"], U])[]): ListChain<Ctx, U>;\n /**\n * This method makes an extension argument: the node `ext(kind, data)`. The handler of `kind` in the options of\n * `withOptions` gives its value. The caller gives the type `T` of that value.\n */\n ext<T>(kind: string, data?: unknown): Arg<T>;\n /** This method starts a sheet over the space: named columns of formulas. Refer to `Sheet`. */\n sheet(): Sheet<Ctx, object>;\n /**\n * This method makes a function (BUILD.FN) with the kinds of its parameters. The body gets a chain of each parameter,\n * and it evaluates at the focus of each call. The method `functions` of a chain binds the function.\n */\n fn<const P extends readonly FnParamKind[], R>(params: P, body: (...params: ParamChains<Ctx, P>) => ChainBase<Ctx, R>): FnDef<P, R>;\n /** The space of the root. */\n readonly space: Space<Ctx[\"keys\"], Ctx[\"record\"]>;\n}\n\n/** The root of a column formula: the root of the builder, and references to the cells of the sheet. */\nexport interface SheetRoot<Ctx extends ChainContext, Cols> extends Root<Ctx> {\n /**\n * This method reads a cell: the column `column` at the key `at`, or at the address `at` from the focus. The address\n * can have computed moves (SHEET.CELL.COMPUTED). Without `at`, it reads at the focus. The type is the type of a column\n * before this one.\n */\n cell<N extends keyof Cols & string>(column: N, at?: Ctx[\"keys\"] | Addr): Arg<Cols[N]>;\n /** This method makes a cell reference to any column, also this column or a later one. The caller gives the type. */\n cell<T>(column: string, at?: Ctx[\"keys\"] | Addr): Arg<T>;\n}\n\n/** One row of a sheet: the key and the result of each column. */\nexport interface SheetRow<K extends string, Cols> {\n readonly key: K;\n readonly cells: { readonly [N in keyof Cols]: Result<Cols[N]> };\n}\n\n/**\n * A sheet: named columns of formulas over a space, like the computed columns of a spreadsheet. A formula reads the\n * other columns with `cell`. Each evaluation evaluates a cell once, and each cell on a cycle of references gives\n * `#CYCLE!`. A sheet is immutable: `column` gives a new sheet.\n */\nexport interface Sheet<Ctx extends ChainContext, Cols, Decl = object> {\n /**\n * This method gives a new sheet with one more column. The formula gets a root with `cell`. If `declare` gave the\n * column a type, the formula must give a value of that type.\n */\n column<const N extends string, C extends ChainBase<Ctx, DeclaredType<Decl, N>>>(\n name: N,\n formula: (r: SheetRoot<Ctx, Cols & Decl>) => C,\n ): Sheet<Ctx, Cols & { readonly [P in N]: ValueOf<C> }, Decl>;\n /**\n * This method gives the types of columns before their formulas. A formula can then read a declared column with\n * `cell` and its type: the column itself (a recurrence) or a later column. It has no effect at run time.\n */\n declare<D extends Readonly<Record<string, unknown>>>(): Sheet<Ctx, Cols, Decl & D>;\n /**\n * This method gives a new sheet in which the cell of the column `column` at the key `k` has its own formula. That\n * formula replaces the formula of the column at the key `k`. It must give a value of the type of the column.\n */\n cellFormula<const N extends keyof (Cols & Decl) & string>(\n k: Ctx[\"keys\"],\n column: N,\n formula: (r: SheetRoot<Ctx, Cols & Decl>) => ChainBase<Ctx, (Cols & Decl)[N]>,\n ): Sheet<Ctx, Cols, Decl>;\n /** The program of each column. */\n readonly columns: Readonly<Record<string, Expr>>;\n /** The program of each cell with its own formula, by column and then by key. */\n readonly cellFormulas: Readonly<Record<string, Readonly<Record<string, Expr>>>>;\n /** This method evaluates one cell, and gives the error if there is one. */\n result<N extends keyof Cols & string>(k: Ctx[\"keys\"], column: N): Result<Cols[N]>;\n /** This method evaluates one cell. An error gives `none`. */\n at<N extends keyof Cols & string>(k: Ctx[\"keys\"], column: N): Optional<Cols[N]>;\n /** This method evaluates one cell, with a trace of the nodes of its column. */\n explain(k: Ctx[\"keys\"], column: keyof Cols & string): Trace;\n /** This method evaluates each cell, in key order, with one result for each cell. */\n table(): readonly SheetRow<Ctx[\"keys\"], Cols>[];\n}\n\n/** The declared type of the column `N`, or `unknown` for a column without a declaration. */\nexport type DeclaredType<Decl, N extends string> = N extends keyof Decl ? Decl[N] : unknown;\n\n/** The options of the builder. */\nexport interface VexOptions<F extends FnTable = FnTable> {\n /** Free function ops. A chain applies them with `call`. */\n readonly fns?: F;\n /** Handlers of extension expression kinds. */\n readonly extensions?: Readonly<Record<string, ExtHandler>>;\n}\n\n/** The entry point for a list of domains. */\nexport interface VexEntry<Dms extends readonly AnyDomain[], F extends FnTable = NoFns> {\n /** This method gives the root of the builder for a space. */\n over<K extends string, O>(s: Space<K, O>): Root<{ readonly domains: Dms; readonly keys: K; readonly record: Merge<O>; readonly fns: F }>;\n /** The domains. */\n readonly domains: Dms;\n}\n\n// ---------------------------------------------------------------- run time\n\n/** The options as the interpreter takes them: free functions get untyped arguments at run time. */\ninterface RuntimeOptions {\n readonly fns?: Readonly<Record<string, FreeFn>>;\n readonly extensions?: Readonly<Record<string, ExtHandler>>;\n}\n\n/** This function gives the run-time form of the options. A typed free function gets the values that the types promise. */\nconst runtimeOptions = (options: VexOptions): RuntimeOptions => ({\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(options.fns === undefined ? {} : { fns: options.fns as Readonly<Record<string, FreeFn>> }),\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(options.extensions === undefined ? {} : { extensions: options.extensions }),\n});\n\ninterface Env {\n readonly space: Space;\n readonly domains: readonly AnyDomain[];\n readonly options: RuntimeOptions;\n}\n\ninterface State {\n readonly env: Env;\n /** The current value. */\n readonly expr: Expr;\n /** The address where later field references read. */\n readonly addr: readonly Move[];\n /** The depth of nested axis and binding bodies, for unique variable names. */\n readonly depth: number;\n}\n\nconst kindOf = (u: unknown): unknown => (u as { kind?: unknown } | null | undefined)?.kind;\nconst isArg = (u: unknown): u is Arg<unknown> => kindOf(u) === \"vex.arg\";\nconst isChainLike = (u: unknown): u is { readonly program: Expr } => kindOf(u) === \"vex.chain\" || kindOf(u) === \"vex.list-chain\";\n\n/** This function gives the expression of the list of `append` and `without`. The list is a chain, not a literal. */\nfunction listProgram(op: string, other: unknown): Expr {\n if (!isChainLike(other)) throw new TypeError(`${op} needs a list chain`);\n return other.program;\n}\n\n/** This function turns a builder argument into an expression. A bare string is a field reference at `addr`. */\nfunction toExpr(a: unknown, addr: readonly Move[]): Expr {\n if (typeof a === \"string\") return ref(toPath(a), addr);\n if (isArg(a)) return a.expr;\n if (isChainLike(a)) return a.program;\n return lit(a);\n}\n\n/** This function gives the expressions of a step of a loop, with the unique names of the loop. */\nfunction stepExprs(step: Readonly<Record<string, unknown>>, unique: ReadonlyMap<string, string>, addr: readonly Move[]): Readonly<Record<string, Expr>> {\n const out: Record<string, Expr> = {};\n for (const [n, a] of Object.entries(step)) {\n const name = unique.get(n);\n if (name === undefined) throw new TypeError(`the name \"${n}\" of the step is not a name of init`);\n out[name] = toExpr(a, addr);\n }\n return out;\n}\n\n/**\n * The number of the open bodies of `each` and steps of `fold` of a list chain. The names `as` of a loop end with this\n * number, so a loop inside a body has other names than the loop around it (BUILD.LIST.ITEM).\n */\nlet itemDepth = 0;\n\n/** This function gives the value of `build`, with the next number for the names `as` inside it. */\nfunction inItemLoop<T>(build: () => T): T {\n itemDepth += 1;\n try {\n return build();\n } finally {\n itemDepth -= 1;\n }\n}\n\n/**\n * The number of the open steps of `fix`. The name of a column ends with this number. Thus an inner `fix` does not hide\n * the column around it, also when the chain of the inner `fix` starts at the root (BUILD.FIX).\n */\nlet fixDepth = 0;\n\n/** This function gives the value of `build`, with the next number for the columns inside it. */\nfunction inFixStep<T>(build: () => T): T {\n fixDepth += 1;\n try {\n return build();\n } finally {\n fixDepth -= 1;\n }\n}\n\n/**\n * This function tells if the expression reads the name, in one of its parts. It uses a stack, not recursion. An `each`\n * or a `fold` can have the name in its item names (`as`). Then it binds the name again for its body or its step, and\n * those parts do not count (V-065). A chain made at the same depth of the loops has the same names, so a fold can hold such a chain in its step.\n */\nfunction reads(e: Expr, name: string): boolean {\n const todo: Expr[] = [e];\n for (let x = todo.pop(); x !== undefined; x = todo.pop()) {\n if (x.tag === \"var\" && x.name === name) return true;\n if (x.tag === \"each\" && x.as?.includes(name) === true) todo.push(...axisExprs(x.axis), ...addrExprs(x.at));\n else if (x.tag === \"fold\" && x.as?.includes(name) === true) todo.push(...Object.values(x.init), ...axisExprs(x.axis), ...addrExprs(x.at), x.result);\n else todo.push(...children(x));\n }\n return false;\n}\n\n/**\n * This function gives the names `as` of a fold whose step reads the index. The axis must be `list`. The name of the item\n * of the loop of `each` stays, so the item of the step keeps its value (BUILD.LIST.ITEM).\n */\nfunction foldItemNames(loop: { readonly axis: Axis; readonly as?: ItemNames }, index: string): ItemNames {\n if (listOf(loop.axis) === undefined) throw new TypeError(\"the index of a fold needs the axis list: go over the items of a list with each first\");\n return [loop.as?.[0] ?? `$item${itemDepth}`, index];\n}\n\nconst PROXY_RESERVED = new Set([\"then\", \"catch\", \"finally\", \"toJSON\", \"valueOf\", \"toString\", \"constructor\", \"inspect\", \"asymmetricMatch\", \"$$typeof\", \"nodeType\"]);\n\nclass ChainImpl {\n readonly kind = \"vex.chain\" as const;\n readonly #s: State;\n\n constructor(s: State) {\n this.#s = s;\n }\n\n get program(): Expr {\n return this.#s.expr;\n }\n\n get _(): Readonly<Record<string, (...args: readonly unknown[]) => ChainImpl>> {\n const s = this.#s;\n return new Proxy(Object.create(null) as Record<string, never>, {\n get: (_t, prop): unknown => {\n if (typeof prop !== \"string\" || PROXY_RESERVED.has(prop)) return undefined;\n return (...args: readonly unknown[]): ChainImpl => new ChainImpl({ ...s, expr: app(prop, s.expr, ...args.map((a) => toExpr(a, s.addr))) });\n },\n });\n }\n\n #opts(k: string): EvalOptions {\n return evalOptions(this.#s, k);\n }\n\n result(k: string): Result<unknown> {\n return evaluate(this.#s.expr, this.#opts(k));\n }\n at(k: string): Optional<unknown> {\n return toOptional(this.result(k));\n }\n value(k: string): Optional<unknown> {\n return this.at(k);\n }\n explain(k: string): Trace {\n return explain(this.#s.expr, this.#opts(k));\n }\n all(): Traversal<string, unknown> {\n const { env } = this.#s;\n const items = env.space.keys.map((k) => ({ key: k, result: this.result(k) }));\n return traversal(items, env);\n }\n\n from(field: string): ChainImpl {\n return new ChainImpl({ ...this.#s, expr: ref(toPath(field), this.#s.addr) });\n }\n\n #move(m: Move): ChainImpl {\n return new ChainImpl({ ...this.#s, addr: [...this.#s.addr, m] });\n }\n to(k: string | { readonly program: Expr }): ChainImpl {\n return this.#move(keyMove(typeof k === \"string\" ? k : k.program));\n }\n index(i: number | { readonly program: Expr }): ChainImpl {\n return this.#move(indexMove(typeof i === \"number\" ? i : i.program));\n }\n offset(...d: readonly number[]): ChainImpl {\n return this.#move(offsetMove(...d));\n }\n other(): ChainImpl {\n return this.#move(otherMove);\n }\n origin(): ChainImpl {\n return this.#move(originMove);\n }\n parent(): ChainImpl {\n return this.#move(parentMove);\n }\n\n call(name: string, ...args: readonly unknown[]): ChainImpl {\n return new ChainImpl({ ...this.#s, expr: app(name, this.#s.expr, ...args.map((a) => toExpr(a, this.#s.addr))) });\n }\n if(then: unknown, otherwise: unknown): ChainImpl {\n return new ChainImpl({ ...this.#s, expr: app(\"if\", this.#s.expr, toExpr(then, this.#s.addr), toExpr(otherwise, this.#s.addr)) });\n }\n ifError(fallback: unknown): ChainImpl {\n return new ChainImpl({ ...this.#s, expr: app(\"ifError\", this.#s.expr, toExpr(fallback, this.#s.addr)) });\n }\n\n /** This method binds the current value to a fresh name, and gives a chain that starts from that name. */\n #bound(): { readonly name: string; readonly start: ChainImpl } {\n const name = `$${this.#s.depth}`;\n return { name, start: new ChainImpl({ ...this.#s, expr: v(name), depth: this.#s.depth + 1 }) };\n }\n\n fork(branches: Readonly<Record<string, (c: ChainImpl) => { readonly program: Expr }>>): ChainImpl {\n const { name, start } = this.#bound();\n // Object.fromEntries gives an own field for each name, also for \"__proto__\" (V-062).\n const fields = Object.fromEntries(Object.entries(branches).map(([n, f]) => [n, f(start).program]));\n return new ChainImpl({ ...this.#s, expr: let_({ [name]: this.#s.expr }, rec(fields)) });\n }\n\n with(binds: Readonly<Record<string, unknown>>, body: (c: ChainImpl, vars: Readonly<Record<string, Arg<unknown>>>) => { readonly program: Expr }): ChainImpl {\n const depth = this.#s.depth;\n const bindExprs: Record<string, Expr> = {};\n const vars: Record<string, Arg<unknown>> = {};\n for (const [n, a] of Object.entries(binds)) {\n const unique = `${n}$${depth}`;\n bindExprs[unique] = toExpr(a, this.#s.addr);\n vars[n] = argToken(v(unique));\n }\n const inner = body(new ChainImpl({ ...this.#s, depth: depth + 1 }), vars);\n return new ChainImpl({ ...this.#s, expr: let_(bindExprs, inner.program) });\n }\n\n functions(fns: Readonly<Record<string, FnDefImpl>>, body: (c: ChainImpl, call: Readonly<Record<string, (...args: readonly unknown[]) => ChainImpl>>) => { readonly program: Expr }): ChainImpl {\n const depth = this.#s.depth;\n const binds: Record<string, Expr> = {};\n const calls: Record<string, (...args: readonly unknown[]) => ChainImpl> = {};\n for (const [n, def] of Object.entries(fns)) {\n if ((def as { readonly kind?: unknown }).kind !== \"vex.fn\") throw new TypeError(`the function \"${n}\" is not a function of root.fn`);\n const unique = `${n}$${depth}`;\n const params = def.params.map((_k, i) => `${unique}$${i}`);\n // A parameter is a chain at the focus of the call, so a field of the body reads at the call.\n const chains = params.map((p) => new ChainImpl({ ...this.#s, expr: v(p), addr: [], depth: depth + 1 }));\n binds[unique] = fnExpr(params, def.build(...chains).program);\n calls[n] = (...args) => new ChainImpl({ ...this.#s, expr: callExpr(unique, ...args.map((a) => toExpr(a, []))), addr: [], depth: depth + 1 });\n }\n const inner = body(new ChainImpl({ ...this.#s, depth: depth + 1 }), calls);\n return new ChainImpl({ ...this.#s, expr: let_(binds, inner.program) });\n }\n\n /**\n * This method gives the names of a loop. Each name of `init` gets a name that is unique at the depth of the chain.\n * It also gets its first value at the address of the chain, and a chain of its value.\n */\n loopNames(init: Readonly<Record<string, unknown>>): { readonly unique: ReadonlyMap<string, string>; readonly first: Readonly<Record<string, Expr>>; readonly vars: Readonly<Record<string, ChainImpl | ListChainImpl>> } {\n const depth = this.#s.depth;\n const unique = new Map<string, string>();\n const first: Record<string, Expr> = {};\n const vars: Record<string, ChainImpl | ListChainImpl> = {};\n for (const [n, a] of Object.entries(init)) {\n const name = `${n}$${depth}`;\n unique.set(n, name);\n first[name] = toExpr(a, this.#s.addr);\n // A name of a list is a list chain, so a step can use the list ops on it (BUILD.LIST.LOOP).\n const s: State = { ...this.#s, expr: v(name), addr: [], depth: depth + 1 };\n vars[n] = kindOf(a) === \"vex.list-chain\" ? new ListChainImpl(s) : new ChainImpl(s);\n }\n return { unique, first, vars };\n }\n\n iterate(\n limit: number | DataLimit | ListChainImpl,\n init: Readonly<Record<string, unknown>>,\n step: (vars: Readonly<Record<string, ChainImpl | ListChainImpl>>) => Readonly<Record<string, unknown>>,\n result: (vars: Readonly<Record<string, ChainImpl | ListChainImpl>>) => unknown,\n opts?: { readonly until?: (vars: Readonly<Record<string, ChainImpl | ListChainImpl>>) => unknown },\n ): ChainImpl | ListChainImpl {\n const { unique, first, vars } = this.loopNames(init);\n const next = stepExprs(step(vars), unique, this.#s.addr);\n const until = opts?.until === undefined ? undefined : toExpr(opts.until(vars), this.#s.addr);\n const r = result(vars);\n // The list of a limit reads the names outside the iteration, so the chain of the limit comes first (ITERATE.LIMIT.DATA).\n const bound = isChainLike(limit) ? dataLimit({ t: \"list\", list: toExpr(limit, this.#s.addr) }) : limit;\n return chainOf({ ...this.#s, expr: iterateExpr(bound, first, next, toExpr(r, this.#s.addr), until) }, r);\n }\n\n fix(name: string, join: FixJoin, init: unknown, step: (last: ChainImpl) => unknown): ChainImpl {\n const { addr, depth } = this.#s;\n const column = `${name}$${String(fixDepth)}`;\n // The read has no address, and an axis moves the focus of the read (FIX.LAST).\n const read = new ChainImpl({ ...this.#s, expr: lastExpr(column), addr: [], depth: depth + 1 });\n const next = inFixStep(() => toExpr(step(read), addr));\n return new ChainImpl({ ...this.#s, expr: fixExpr(column, join, toExpr(init, addr), next) });\n }\n\n #axis(a: Axis, body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n const { name, start } = this.#bound();\n // Inside the axis, the focus is the target, so the address of the body starts empty.\n const inTarget = new ChainImpl({ ...start.#s, addr: [] });\n const inner = body(inTarget);\n const ordered: Axis = opts?.reverse === true ? { t: \"reverse\", axis: a } : a;\n const axis: Axis = opts?.where === undefined ? ordered : { t: \"where\", axis: ordered, test: opts.where(inTarget).program };\n // The moves before the axis are its address: parent().children(f) gives f at each child of the parent.\n return new ListChainImpl({ ...this.#s, expr: let_({ [name]: this.#s.expr }, each(axis, inner.program, this.#s.addr)) });\n }\n others(body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"others\" }, body, opts);\n }\n neighbors(n: 4 | 8, body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"neighbors\", n }, body, opts);\n }\n each(body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"all\" }, body, opts);\n }\n children(body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"children\" }, body, opts);\n }\n ancestors(body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"ancestors\" }, body, opts);\n }\n descendants(body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"descendants\" }, body, opts);\n }\n siblings(body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"siblings\" }, body, opts);\n }\n window(from: number, to: number, body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"window\", from, to }, body, opts);\n }\n table(name: string, body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"table\", name }, body, opts);\n }\n successors(body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"successors\" }, body, opts);\n }\n predecessors(body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"predecessors\" }, body, opts);\n }\n reachable(body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"reachable\" }, body, opts);\n }\n}\n\n/** This function gives the chain of a loop: a list chain when its result is a list chain (BUILD.LIST.LOOP). */\nconst chainOf = (s: State, result: unknown): ChainImpl | ListChainImpl => (kindOf(result) === \"vex.list-chain\" ? new ListChainImpl(s) : new ChainImpl(s));\n\n/** This function gives the options of an evaluation of a chain or a list chain at the origin `k`. */\nfunction evalOptions(s: State, k: string): EvalOptions {\n const { env } = s;\n return {\n space: env.space,\n origin: k,\n domains: env.domains,\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(env.options.fns === undefined ? {} : { fns: env.options.fns }),\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(env.options.extensions === undefined ? {} : { extensions: env.options.extensions }),\n };\n}\n\nclass ListChainImpl {\n readonly kind = \"vex.list-chain\" as const;\n readonly #s: State;\n constructor(s: State) {\n this.#s = s;\n }\n get program(): Expr {\n return this.#s.expr;\n }\n fold(\n init: Readonly<Record<string, unknown>>,\n step: (vars: Readonly<Record<string, ChainImpl | ListChainImpl>>, item: ChainImpl, index: ChainImpl) => Readonly<Record<string, unknown>>,\n result: (vars: Readonly<Record<string, ChainImpl | ListChainImpl>>) => unknown,\n ): ChainImpl | ListChainImpl {\n // The list of an axis is a let of the start value around the axis, and the list of `each` of a list is the axis\n // alone. The fold keeps the let, and the body of the axis is the item of each step.\n const e = this.#s.expr;\n const loop = e.tag === \"let\" ? e.body : e;\n if (loop.tag !== \"each\") throw new TypeError(\"fold needs the list of an axis: go over the items of the list with each first\");\n const names = new ChainImpl({ ...this.#s, expr: lit(null) }).loopNames(init);\n const item = new ChainImpl({ ...this.#s, expr: loop.body, addr: [] });\n // The names as of the loop of each stay. A step that reads the index adds a name for it (BUILD.LIST.ITEM).\n const index = loop.as?.[1] ?? `$index${itemDepth}`;\n const next = stepExprs(inItemLoop(() => step(names.vars, item, new ChainImpl({ ...this.#s, expr: v(index), addr: [] }))), names.unique, []);\n const as = Object.values(next).some((x) => reads(x, index)) ? foldItemNames(loop, index) : loop.as;\n const r = result(names.vars);\n const folded = foldExpr(loop.axis, names.first, next, toExpr(r, this.#s.addr), loop.at, as);\n return chainOf({ ...this.#s, expr: e.tag === \"let\" ? let_(e.bind, folded) : folded }, r);\n }\n\n #op(op: string, extra: readonly Expr[], opts?: ListOpts & { readonly domain?: string }): ChainImpl {\n const options = { ...(opts?.strict === true ? { strict: true } : {}), ...(opts?.domain === undefined ? {} : { domain: opts.domain }) };\n const args = Object.keys(options).length > 0 ? [...extra, lit(options)] : extra;\n return new ChainImpl({ ...this.#s, expr: app(op, this.#s.expr, ...args) });\n }\n count(opts?: ListOpts): ChainImpl {\n return this.#op(\"count\", [], opts);\n }\n sum(opts?: ListOpts): ChainImpl {\n return this.#op(\"sum\", [], opts);\n }\n mean(opts?: ListOpts): ChainImpl {\n return this.#op(\"mean\", [], opts);\n }\n min(opts?: ListOpts): ChainImpl {\n return this.#op(\"min\", [], opts);\n }\n max(opts?: ListOpts): ChainImpl {\n return this.#op(\"max\", [], opts);\n }\n any(opts?: ListOpts): ChainImpl {\n return this.#op(\"any\", [], opts);\n }\n all(opts?: ListOpts): ChainImpl {\n return this.#op(\"all\", [], opts);\n }\n none(opts?: ListOpts): ChainImpl {\n return this.#op(\"none\", [], opts);\n }\n values(opts?: ListOpts): ChainImpl {\n return this.#op(\"values\", [], opts);\n }\n keys(opts?: ListOpts): ChainImpl {\n return this.#op(\"keys\", [], opts);\n }\n errors(): ChainImpl {\n return this.#op(\"errors\", []);\n }\n first(opts?: ListOpts): ChainImpl {\n return this.#op(\"first\", [], opts);\n }\n reduce(op: string, opts?: ListOpts & { readonly domain?: string }): ChainImpl {\n return this.#op(\"reduce\", [lit(op)], opts);\n }\n #list(op: string, extra: readonly Expr[], opts?: ListOpts): ListChainImpl {\n return new ListChainImpl({ ...this.#s, expr: this.#op(op, extra, opts).program });\n }\n sortBy(opts?: ListOpts): ListChainImpl {\n return this.#list(\"sortBy\", [], opts);\n }\n take(n: number, opts?: ListOpts): ListChainImpl {\n return this.#list(\"take\", [lit(n)], opts);\n }\n nth(i: number, opts?: ListOpts): ChainImpl {\n return this.#op(\"nth\", [lit(i)], opts);\n }\n setNth(i: number | { readonly program: Expr }, value: unknown, opts?: ListOpts): ListChainImpl {\n return this.#list(\"setNth\", [typeof i === \"number\" ? lit(i) : i.program, toExpr(value, this.#s.addr)], opts);\n }\n get(k: string | { readonly program: Expr }, opts?: ListOpts): ChainImpl {\n // A text is a key, not a field reference, as for the move to(k).\n return this.#op(\"get\", [typeof k === \"string\" ? lit(k) : k.program], opts);\n }\n drop(n: number, opts?: ListOpts): ListChainImpl {\n return this.#list(\"drop\", [lit(n)], opts);\n }\n append(other: unknown, opts?: ListOpts): ListChainImpl {\n return this.#list(\"append\", [listProgram(\"append\", other)], opts);\n }\n without(other: unknown, opts?: ListOpts): ListChainImpl {\n return this.#list(\"without\", [listProgram(\"without\", other)], opts);\n }\n flat(opts?: ListOpts): ListChainImpl {\n return this.#list(\"flat\", [], opts);\n }\n distinct(opts?: ListOpts): ListChainImpl {\n return this.#list(\"distinct\", [], opts);\n }\n group(keys: unknown, opts?: ListOpts): ListChainImpl {\n return this.#list(\"group\", [listProgram(\"group\", keys)], opts);\n }\n join(sep: string | { readonly program: Expr }, opts?: ListOpts): ChainImpl {\n return this.#op(\"join\", [typeof sep === \"string\" ? lit(sep) : sep.program], opts);\n }\n each(body: (c: ChainImpl, item: ChainImpl, index: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n // The chains of the body are at the key of the item. The chain of the body has no value of its own.\n const inner: State = { ...this.#s, addr: [], depth: this.#s.depth + 1 };\n const start = new ChainImpl({ ...inner, expr: lit(null) });\n const list: Axis = { t: \"list\", list: this.#s.expr };\n const ordered: Axis = opts?.reverse === true ? { t: \"reverse\", axis: list } : list;\n const axis: Axis = opts?.where === undefined ? ordered : { t: \"where\", axis: ordered, test: opts.where(start).program };\n const names = [`$item${itemDepth}`, `$index${itemDepth}`] as const;\n const program = inItemLoop(() => body(start, new ChainImpl({ ...inner, expr: v(names[0]) }), new ChainImpl({ ...inner, expr: v(names[1]) })).program);\n // BUILD.LIST.ITEM: the field as has only the names that the body reads.\n const as: ItemNames | undefined = reads(program, names[1]) ? names : reads(program, names[0]) ? [names[0]] : undefined;\n return new ListChainImpl({ ...this.#s, expr: each(axis, program, undefined, as) });\n }\n result(k: string): Result<unknown> {\n return evaluate(this.#s.expr, evalOptions(this.#s, k));\n }\n at(k: string): Optional<unknown> {\n return toOptional(this.result(k));\n }\n explain(k: string): Trace {\n return explain(this.#s.expr, evalOptions(this.#s, k));\n }\n}\n\nclass RootImpl {\n readonly #env: Env;\n constructor(env: Env) {\n this.#env = env;\n }\n get space(): Space {\n return this.#env.space;\n }\n #chain(expr: Expr): ChainImpl {\n return new ChainImpl({ env: this.#env, expr, addr: [], depth: 0 });\n }\n from(field: string): ChainImpl {\n return this.#chain(ref(toPath(field)));\n }\n start(value: unknown): ChainImpl {\n return this.#chain(toExpr(value, []));\n }\n of(k: string, field: string): Arg<unknown> {\n return argToken(ref(toPath(field), [keyMove(k)]));\n }\n field(path: string): Arg<unknown> {\n return argToken(ref(toPath(path)));\n }\n lit(value: unknown): Arg<unknown> {\n return argToken(lit(value));\n }\n ofPath(k: string, path: string): Arg<unknown> {\n return argToken(ref(toPath(path), [keyMove(k)]));\n }\n ext(kind: string, data: unknown = null): Arg<unknown> {\n return argToken(ext(kind, data));\n }\n sheet(): SheetImpl {\n return new SheetImpl(this.#env, new Map());\n }\n fn(params: readonly string[], build: (...params: ChainImpl[]) => { readonly program: Expr }): FnDefImpl {\n return { kind: \"vex.fn\", params, build };\n }\n rec(fields: Readonly<Record<string, unknown>>): Arg<unknown> {\n return argToken(rec(Object.fromEntries(Object.entries(fields).map(([n, a]) => [n, toExpr(a, [])]))));\n }\n list(items: readonly (readonly [string, unknown])[] = []): ListChainImpl {\n // LIST.LITERAL: a literal of the list, with a value for each item.\n return new ListChainImpl({ env: this.#env, expr: lit(vexList(items.map(([key, value]) => ({ key, result: ok(value) })))), addr: [], depth: 0 });\n }\n}\n\nclass SheetRootImpl extends RootImpl {\n cell(column: string, at?: string | Addr): Arg<unknown> {\n return argToken(cellRef(column, typeof at === \"string\" ? [keyMove(at)] : at));\n }\n}\n\nclass SheetImpl {\n readonly #env: Env;\n readonly #columns: ReadonlyMap<string, Expr>;\n readonly #cells: CellFormulas;\n constructor(env: Env, columns: ReadonlyMap<string, Expr>, cells: CellFormulas = new Map()) {\n this.#env = env;\n this.#columns = columns;\n this.#cells = cells;\n }\n get columns(): Readonly<Record<string, Expr>> {\n return Object.freeze(Object.fromEntries(this.#columns));\n }\n get cellFormulas(): Readonly<Record<string, Readonly<Record<string, Expr>>>> {\n return Object.freeze(Object.fromEntries([...this.#cells].map(([c, keys]) => [c, Object.freeze(Object.fromEntries(keys))])));\n }\n declare(): SheetImpl {\n return this;\n }\n column(name: string, formula: (r: SheetRootImpl) => { readonly program: Expr }): SheetImpl {\n const program = formula(new SheetRootImpl(this.#env)).program;\n return new SheetImpl(this.#env, new Map([...this.#columns, [name, program]]), this.#cells);\n }\n cellFormula(k: string, column: string, formula: (r: SheetRootImpl) => { readonly program: Expr }): SheetImpl {\n const program = formula(new SheetRootImpl(this.#env)).program;\n const keys = new Map([...(this.#cells.get(column) ?? []), [k, program]]);\n return new SheetImpl(this.#env, this.#columns, new Map([...this.#cells, [column, keys]]));\n }\n #run(): SheetRun {\n const { space: s, domains, options } = this.#env;\n return new SheetRun(this.#columns, {\n space: s,\n domains,\n cells: this.#cells,\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(options.fns === undefined ? {} : { fns: options.fns }),\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(options.extensions === undefined ? {} : { extensions: options.extensions }),\n });\n }\n result(k: string, column: string): Result<unknown> {\n const run = this.#run();\n run.warm(column, k);\n return run.cell(column, k);\n }\n at(k: string, column: string): Optional<unknown> {\n return toOptional(this.result(k, column));\n }\n explain(k: string, column: string): Trace {\n const run = this.#run();\n run.warm(column, k);\n return run.explain(column, k);\n }\n table(): readonly SheetRow<string, Record<string, unknown>>[] {\n const run = this.#run();\n // The table reads each cell, so a fill evaluates them in the order of their reads first (SHEET.FILL).\n run.fill();\n const names = [...this.#columns.keys()];\n return this.#env.space.keys.map((key) => ({ key, cells: Object.fromEntries(names.map((c) => [c, run.cell(c, key)])) }));\n }\n}\n\n/**\n * This function gives the entry point of the builder for a list of domains. The interpreter finds the op of a\n * value in the first domain that accepts the value.\n */\nexport function vex<const Dms extends readonly AnyDomain[]>(\n ...domains: Dms\n): VexEntry<Dms> & { withOptions<const F extends FnTable = NoFns>(options: VexOptions<F>): VexEntry<Dms, F> } {\n const make = <F extends FnTable>(options: VexOptions<F>): VexEntry<Dms, F> => ({\n domains,\n over: <K extends string, O>(s: Space<K, O>): Root<{ readonly domains: Dms; readonly keys: K; readonly record: Merge<O>; readonly fns: F }> =>\n new RootImpl({ space: s, domains, options: runtimeOptions(options) }) as unknown as Root<{\n readonly domains: Dms;\n readonly keys: K;\n readonly record: Merge<O>;\n readonly fns: F;\n }>,\n });\n return { ...make<NoFns>({}), withOptions: make };\n}\n\n/** The type of a domain value, from the domain object. */\nexport type ValueOfDomain<Dm> = DomainValue<Dm>;\n\n/** An op specification type, for domain authors. */\nexport type { OpSp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,OAAO,GAAG,MAAM,CAAC;CAC1C;CACA,QAAQ,GAAW,QAAuB;EACxC,MAAM,MAAM,KAAK,KAAK;EACtB,IAAI,KAAK,QAAQ,CAAC;EAClB,OAAO,IAAI,QAAQ,QAAQ,CAAC;CAC9B;CACA,QAA8D;EAC5D,MAAM,MAAM,KAAK,KAAK;EAEtB,IAAI,KAAK;EACT,MAAM,QAAQ,CAAC,GAAG,KAAK,SAAS,KAAK,CAAC;EACtC,OAAO,KAAK,KAAK,MAAM,KAAK,KAAK,SAAS;GAAE;GAAK,OAAO,OAAO,YAAY,MAAM,KAAK,MAAM,CAAC,GAAG,IAAI,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC;EAAE,EAAE;CACxH;AACF;;;;;AAMA,SAAgB,IACd,GAAG,SACyG;CAC5G,MAAM,QAA2B,aAA8C;EAC7E;EACA,OAA4B,MAC1B,IAAI,SAAS;GAAE,OAAO;GAAG;GAAS,SAAS,eAAe,OAAO;EAAE,CAAC;CAMxE;CACA,OAAO;EAAE,GAAG,KAAY,CAAC,CAAC;EAAG,aAAa;CAAK;AACjD"}
1
+ {"version":3,"file":"index.js","names":["NONE","isObject","FORBIDDEN","TERMS","vexOk","vexFail","partsOf","ok","withItem","accepts","WITH_ARGUMENT","NONE","term","path","Refusal","kindOf","isNone","joinKind","kindOfJoin","kindOf","reference","kernelReference","agree","kernelAgree","spaces","keyMove","indexMove","offsetMove","otherMove","originMove","parentMove","fnExpr","callExpr","iterateExpr","lastExpr","fixExpr","foldExpr","cellRef"],"sources":["../src/result.ts","../src/errors.ts","../src/checked.ts","../src/list.ts","../src/error-text.ts","../src/item-names.ts","../src/ir.ts","../src/space.ts","../src/domain.ts","../src/array-list.ts","../src/codec.ts","../src/limit-error.ts","../src/fix.ts","../src/same.ts","../src/kernel.ts","../src/write.ts","../src/document.ts","../src/monotone.ts","../src/size.ts","../src/constructs.ts","../src/steps.ts","../src/evaluate.ts","../src/deps.ts","../src/json.ts","../src/plan.ts","../src/traversal.ts","../src/sheet.ts","../src/builder.ts"],"sourcesContent":["import type { Optional as FamilyOptional } from \"@mark1russell7/optional\";\nimport type { VexError } from \"./errors.ts\";\n\n/**\n * A value that is there, or not there. This is the public result of a Vex program. It is the Optional of the\n * family (`@mark1russell7/optional`), so render and Vex give and take the same values. The import is a type import\n * only: the build copies the type into the declarations, so the package has no runtime dependency.\n */\nexport type Optional<T> = FamilyOptional<T>;\n\n/** A value, or the error that tells why there is no value. The interpreter uses this type. */\nexport type Result<T> = { readonly ok: true; readonly value: T } | { readonly ok: false; readonly error: VexError };\n\nconst NONE: Optional<never> = Object.freeze({ tag: \"none\" });\n\n/** This function makes an `Optional` that holds `value`. */\nexport const some = <T>(value: T): Optional<T> => ({ tag: \"some\", value });\n\n/** This function gives the shared empty `Optional`. */\nexport const none = <T = never>(): Optional<T> => NONE;\n\n/** This function makes a successful `Result`. */\nexport const ok = <T>(value: T): Result<T> => ({ ok: true, value });\n\n/** This function makes a failed `Result`. */\nexport const fail = <T = never>(error: VexError): Result<T> => ({ ok: false, error });\n\n/** This function tells if an `Optional` holds a value. */\nexport const isSome = <T>(o: Optional<T>): o is { readonly tag: \"some\"; readonly value: T } => o.tag === \"some\";\n\n/** This function tells if an `Optional` is empty. */\nexport const isNone = <T>(o: Optional<T>): o is { readonly tag: \"none\" } => o.tag === \"none\";\n\n/** This function changes a `Result` into an `Optional`. The error is lost. */\nexport const toOptional = <T>(r: Result<T>): Optional<T> => (r.ok ? some(r.value) : none());\n\n/** This function gives the value of an `Optional`, or `fallback` if it is empty. */\nexport const getOr = <T, U>(o: Optional<T>, fallback: U): T | U => (o.tag === \"some\" ? o.value : fallback);\n\n/** This function applies `f` to the value of a `Result`. An error stays the same. */\nexport const mapResult = <T, U>(r: Result<T>, f: (value: T) => U): Result<U> => (r.ok ? ok(f(r.value)) : r);\n\n/** This function applies `f` to the value of a `Result`, and `f` gives a `Result`. An error stays the same. */\nexport const chainResult = <T, U>(r: Result<T>, f: (value: T) => Result<U>): Result<U> => (r.ok ? f(r.value) : r);\n","import type { KernelCode } from \"@mark1russell7/coeval\";\n\n/**\n * The error codes of Vex. The names come from the spreadsheet error values, because a Vex program is a spreadsheet\n * formula over records. Each code is a code of the kernel of coeval with the same meaning. For example, `#N/A` is a step\n * that reaches nothing, and `#DEPTH!` is a full call stack. The type checks it: a code that the kernel does not have is\n * not a member.\n */\nexport type ErrorCode = Extract<KernelCode, \"#REF!\" | \"#N/A\" | \"#VALUE!\" | \"#NAME?\" | \"#NUM!\" | \"#CALC!\" | \"#ARGS\" | \"#CYCLE!\" | \"#DEPTH!\">;\n\n/** The cause of an error, in more detail than the code. */\nexport type ErrorKind =\n | \"unknown-key\"\n | \"not-a-pair\"\n | \"out-of-bounds\"\n | \"no-offset\"\n | \"no-grid\"\n | \"no-tree\"\n | \"no-table\"\n | \"no-graph\"\n | \"missing-field\"\n | \"empty\"\n | \"not-instance\"\n | \"kind-mismatch\"\n | \"unknown-op\"\n | \"unbound\"\n | \"not-finite\"\n | \"invalid-value\"\n | \"threw\"\n | \"undefined-result\"\n | \"args\"\n | \"cycle\"\n | \"depth\"\n | \"bad-expression\"\n | \"limit\";\n\nconst CODE_OF: Readonly<Record<ErrorKind, ErrorCode>> = {\n \"unknown-key\": \"#REF!\",\n \"not-a-pair\": \"#REF!\",\n \"out-of-bounds\": \"#REF!\",\n \"no-offset\": \"#REF!\",\n \"no-grid\": \"#REF!\",\n \"no-tree\": \"#REF!\",\n \"no-table\": \"#REF!\",\n \"no-graph\": \"#REF!\",\n \"missing-field\": \"#N/A\",\n empty: \"#N/A\",\n \"not-instance\": \"#VALUE!\",\n \"kind-mismatch\": \"#VALUE!\",\n \"bad-expression\": \"#VALUE!\",\n \"unknown-op\": \"#NAME?\",\n unbound: \"#NAME?\",\n \"not-finite\": \"#NUM!\",\n \"invalid-value\": \"#NUM!\",\n limit: \"#NUM!\",\n threw: \"#CALC!\",\n \"undefined-result\": \"#CALC!\",\n args: \"#ARGS\",\n cycle: \"#CYCLE!\",\n depth: \"#DEPTH!\",\n};\n\n/**\n * This function tells if an exception is the report of the engine that the call stack is full. V8 and JavaScriptCore\n * throw a `RangeError`. SpiderMonkey throws an `InternalError` (\"too much recursion\").\n */\nexport function isStackOverflow(thrown: unknown): boolean {\n if (!(thrown instanceof Error)) return false;\n return (thrown instanceof RangeError && /call stack/i.test(thrown.message)) || (thrown.name === \"InternalError\" && /recursion/i.test(thrown.message));\n}\n\n/** This function tells if an error is `#DEPTH!`. `ifError` and the reductions that skip errors do not hide it (EVAL.DEPTH). */\nexport const isDepthError = (e: VexError): boolean => e.kind === \"depth\";\n\n/** A Vex error. It is a value: a program can catch it with `ifError`, except `#DEPTH!`. */\nexport interface VexError {\n /** The spreadsheet-style code, for example `#REF!`. */\n readonly code: ErrorCode;\n /** The cause in more detail. */\n readonly kind: ErrorKind;\n /** A sentence that tells what went wrong. */\n readonly message: string;\n /** The position of the failed node in the expression tree. The root is `[]`. */\n readonly path: readonly number[];\n /** The key where the evaluation started. */\n readonly origin?: string;\n /** The key where relative references read when the error occurred. */\n readonly focus?: string;\n /** The op name, for errors of an op. */\n readonly op?: string;\n /** The errors of the arguments, for the code `#ARGS`. */\n readonly causes?: readonly VexError[];\n /** The value that an op threw, for the kind `threw`. */\n readonly thrown?: unknown;\n}\n\n/** The details that a caller can give to `vexError`. */\nexport interface ErrorDetails {\n readonly path?: readonly number[];\n readonly origin?: string;\n readonly focus?: string;\n readonly op?: string;\n readonly causes?: readonly VexError[];\n readonly thrown?: unknown;\n}\n\n/** This function gives the code of an error kind. */\nexport const codeOf = (kind: ErrorKind): ErrorCode => CODE_OF[kind];\n\n/** This function makes a `VexError`. */\nexport function vexError(kind: ErrorKind, message: string, details: ErrorDetails = {}): VexError {\n return {\n code: CODE_OF[kind],\n kind,\n message,\n path: details.path ?? [],\n ...(details.origin === undefined ? {} : { origin: details.origin }),\n ...(details.focus === undefined ? {} : { focus: details.focus }),\n ...(details.op === undefined ? {} : { op: details.op }),\n ...(details.causes === undefined ? {} : { causes: details.causes }),\n ...(details.thrown === undefined ? {} : { thrown: details.thrown }),\n };\n}\n\n/** This function gives a short text for an error, for example `#REF! unknown-key: there is no key \"Z\"`. */\nexport const formatError = (e: VexError): string => `${e.code} ${e.kind}: ${e.message}`;\n","/**\n * The cache of the lists that passed the check of LIST.SHAPE. `isVexList` adds each frozen list that passes its check.\n * The interpreter adds each list that it makes from the items of such lists, because these items passed the check.\n * The package index does not export this module.\n */\nexport const CHECKED: WeakSet<object> = new WeakSet<object>();\n","import { CHECKED } from \"./checked.ts\";\nimport type { SizeRule } from \"./domain.ts\";\nimport type { Result } from \"./result.ts\";\n\n/** One item of a list: the key of the target and the result of the body there. */\nexport interface ListItem<T = unknown> {\n readonly key: string;\n readonly result: Result<T>;\n}\n\n/** The value of an `each` expression: one item for each target of the axis. */\nexport interface VexList<T = unknown> {\n readonly kind: \"vex.list\";\n readonly items: readonly ListItem<T>[];\n}\n\n/** This function makes a list. */\nexport const vexList = <T>(items: readonly ListItem<T>[]): VexList<T> => Object.freeze({ kind: \"vex.list\", items: Object.freeze([...items]) });\n\n/** This function tells if a value is an error value: a text `code`, `kind` and `message`, and a `path` (LIST.SHAPE). */\nconst isErrorValue = (u: unknown): boolean => {\n if (typeof u !== \"object\" || u === null) return false;\n const e = u as { code?: unknown; kind?: unknown; message?: unknown; path?: unknown };\n return typeof e.code === \"string\" && typeof e.kind === \"string\" && typeof e.message === \"string\" && Array.isArray(e.path);\n};\n\n/** This function tells if a value is an item of a list: a text key, and a value or an error value (LIST.SHAPE). */\nconst isListItem = (u: unknown): boolean => {\n if (typeof u !== \"object\" || u === null) return false;\n const { key, result } = u as { key?: unknown; result?: unknown };\n if (typeof key !== \"string\" || typeof result !== \"object\" || result === null) return false;\n const r = result as { ok?: unknown; value?: unknown; error?: unknown };\n return r.ok === true ? r.value !== undefined : r.ok === false && isErrorValue(r.error);\n};\n\n/**\n * This function tells if a value is a Vex list (LIST.SHAPE). A list has the kind `vex.list`, and each item has a text key\n * and a result. Another value with the kind `vex.list` is a record, so no list op applies to it. A frozen\n * list passes the check once.\n */\nexport const isVexList = (u: unknown): u is VexList => {\n if (typeof u !== \"object\" || u === null) return false;\n // Stryker disable next-line ConditionalExpression,BlockStatement: the cache holds only lists that pass the check again\n if (CHECKED.has(u)) return true;\n const { kind, items } = u as { kind?: unknown; items?: unknown };\n if (kind !== \"vex.list\" || !Array.isArray(items)) return false;\n // A loop over the positions, not `every`, so a hole of a sparse array is not an item.\n for (let i = 0; i < items.length; i++) if (!isListItem(items[i])) return false;\n if (Object.isFrozen(u) && Object.isFrozen(items)) CHECKED.add(u);\n return true;\n};\n\n/**\n * The name of a core list op. `sortBy`, `take`, `drop`, `append`, `flat` and `without` give a list (LIST.BUILD), and\n * the other ops give a value. `get` gives the value at a key (LIST.GET), and `indexOf` gives the position of a value\n * (LIST.INDEXOF). `distinct` and `group` give a list, and `join` gives a text (LIST.DISTINCT, LIST.GROUP, LIST.JOIN).\n * `setNth` gives a list with a new value at one position (LIST.SETNTH).\n */\nexport type ListOp = \"count\" | \"sum\" | \"min\" | \"max\" | \"mean\" | \"any\" | \"all\" | \"none\" | \"values\" | \"keys\" | \"reduce\" | \"first\" | \"errors\" | \"sortBy\" | \"take\" | \"nth\" | \"setNth\" | \"drop\" | \"append\" | \"flat\" | \"without\" | \"get\" | \"indexOf\" | \"distinct\" | \"group\" | \"join\";\n\n/**\n * The names of the core list ops. They apply when the first argument is a list. They apply to an array too, when no\n * domain and no function of the host has the op for it (LIST.ARRAY).\n */\nexport const LIST_OPS: ReadonlySet<string> = new Set<ListOp>([\"count\", \"sum\", \"min\", \"max\", \"mean\", \"any\", \"all\", \"none\", \"values\", \"keys\", \"reduce\", \"first\", \"errors\", \"sortBy\", \"take\", \"nth\", \"setNth\", \"drop\", \"append\", \"flat\", \"without\", \"get\", \"indexOf\", \"distinct\", \"group\", \"join\"]);\n\n/**\n * The size rules of the core list ops and of `fill` (LOOP.SIZE.OPS). Each op that gives a list has a rule here. An\n * error item has no size, so `errors` has no bound: the messages of the errors can hold texts.\n */\nexport const LIST_SIZES: Readonly<Record<ListOp | \"fill\", SizeRule>> = Object.freeze<Record<ListOp | \"fill\", SizeRule>>({\n count: \"scalar\",\n sum: \"scalar\",\n min: \"scalar\",\n max: \"scalar\",\n mean: \"scalar\",\n any: \"scalar\",\n all: \"scalar\",\n none: \"scalar\",\n indexOf: \"scalar\",\n values: { size: [1], count: [1], inner: [1], item: [1], part: [1], keys: \"position\" },\n keys: { size: [1], count: [1], keys: \"position\" },\n errors: { size: [\"unbounded\"] },\n reduce: \"reduce\",\n first: { size: [[1, \"item\"]], count: [[1, \"item\"]], inner: [[1, \"item\"]], item: [[1, \"part\"]] },\n nth: { size: [[1, \"item\"], 0], count: [[1, \"item\"], 0], inner: [[1, \"item\"], 0], item: [[1, \"part\"], 0] },\n get: { size: [[1, \"item\"], 0], count: [[1, \"item\"], 0], inner: [[1, \"item\"], 0], item: [[1, \"part\"], 0] },\n // LOOP.SIZE.SETNTH: the bound counts the list and the value one time each. A bound cannot subtract the old item.\n setNth: { size: [1, 0, 1], count: [1, 0, 0], inner: [1, 0, [1, \"count\"]], item: [1, 0, [1, \"size\"]], part: [1, 0, [1, \"item\"]] },\n sortBy: { size: [1, 0], count: [1, 0], inner: [1, 0], item: [1, 0], part: [1, 0] },\n // LOOP.SIZE.PART: the second reading counts the items that a literal limit keeps.\n take: {\n size: [1, 0],\n count: [1, 0],\n inner: [1, 0],\n item: [1, 0],\n part: [1, 0],\n limit: 1,\n byParts: { size: [[\"limit\", \"item\"], 0], count: [1, 0], inner: [[\"limit\", \"item\"], 0], item: [1, 0], part: [1, 0] },\n },\n drop: { size: [1, 0], count: [1, 0], inner: [1, 0], item: [1, 0], part: [1, 0] },\n without: { size: [1, 0], count: [1, 0], inner: [1, 0], item: [1, 0], part: [1, 0] },\n append: { size: [1, 1], count: [1, 1], inner: [1, 1], item: [1, 1], part: [1, 1] },\n flat: { size: [1], count: [[1, \"inner\"]], item: [[1, \"part\"]] },\n distinct: { size: [1], count: [1], inner: [1], item: [1], part: [1] },\n group: { size: [1, \"scaled\"], count: [0, 1], inner: [[1, \"count\"], 0] },\n join: { size: [1, \"each\"] },\n fill: { size: [0, \"copies\"], count: [\"number\", 0], inner: [0, [\"copies\", \"count\"]], item: [0, [1, \"size\"]], part: [0, [1, \"item\"]], keys: \"position\" },\n});\n\n/** This function tells if a name is the name of a core list op. */\nexport const isListOp = (op: string): op is ListOp => LIST_OPS.has(op);\n\n/** The options of a list op. */\nexport interface ListOptions {\n /** With `true`, any error item makes the result that error. The default skips error items. */\n readonly strict?: boolean;\n}\n","/**\n * The texts of the errors of the nodes of a program. The interpreter and the materialize step of the compiler use them.\n * Thus tier 1 and tier 2 give the same error (docs/COMPILER.md §4.1).\n */\nimport type { ParamKind } from \"./domain.ts\";\nimport { vexError, type ErrorKind, type VexError } from \"./errors.ts\";\nimport { isVexList } from \"./list.ts\";\nimport type { Position } from \"./space.ts\";\n\n/** The part of an error that does not depend on the position of its node: the kind, the sentence and the op name. */\nexport interface ErrorText {\n readonly kind: ErrorKind;\n readonly message: string;\n readonly op?: string;\n}\n\n/** This function gives a short name for the type of a value, for error messages. */\nexport function describeType(u: unknown): string {\n if (u === null) return \"null\";\n if (Array.isArray(u)) return \"array\";\n if (isVexList(u)) return \"list\";\n if (typeof u === \"object\") {\n const name = (Object.getPrototypeOf(u) as { constructor?: { name?: unknown } } | null)?.constructor?.name;\n return typeof name === \"string\" && name !== \"Object\" ? name : \"object\";\n }\n return typeof u;\n}\n\n/** The texts of the errors. Each function takes the facts of the error that do not come from the position of its node. */\nexport const errorText = {\n /** A name without a binding (`var`). */\n unbound: (name: string): ErrorText => ({ kind: \"unbound\", message: `the name \"${name}\" has no binding` }),\n /** A read of a function as a value (FN.VALUE). */\n functionValue: (name: string): ErrorText => ({ kind: \"kind-mismatch\", message: `the name \"${name}\" is a function, not a value` }),\n /** A call of a name without a binding (FN.CALL). */\n noFunction: (name: string): ErrorText => ({ kind: \"unbound\", message: `the function \"${name}\" has no binding` }),\n /** A call of a name that holds a value (FN.CALL). */\n notFunction: (name: string): ErrorText => ({ kind: \"kind-mismatch\", message: `the name \"${name}\" is a value, not a function` }),\n /** A call with the wrong number of arguments (FN.CALL). */\n arity: (name: string, params: number, args: number): ErrorText => ({ kind: \"bad-expression\", message: `the function \"${name}\" takes ${String(params)} arguments, not ${String(args)}` }),\n /** An extension kind without a handler. */\n noHandler: (kind: string): ErrorText => ({ kind: \"unknown-op\", message: `no handler for the extension kind \"${kind}\"` }),\n /** An exception of an op, of an extension or of `fromScalar`. */\n threw: (op: string): ErrorText => ({ kind: \"threw\", message: `\"${op}\" threw an exception`, op }),\n /** A reference that reads no value. `where` is the part of the path that failed. */\n missing: (key: string, where: string): ErrorText => ({ kind: \"missing-field\", message: `the record at \"${key}\" has no value at \"${where}\"` }),\n /** A reference whose getter threw. */\n readThrew: (key: string, where: string): ErrorText => ({ kind: \"threw\", message: `reading \"${where}\" at \"${key}\" threw an exception` }),\n /** Two or more arguments or fields that failed (CALL.ARGS, REC.FIELDS). */\n args: (count: number, what: string): ErrorText => ({ kind: \"args\", message: `${String(count)} ${what} failed` }),\n /** The axis table of an evaluation without that table. */\n noTable: (name: string): ErrorText => ({ kind: \"no-table\", message: `the evaluation has no table \"${name}\"` }),\n /** The test `until` of `iterate`, with a value that is not a boolean. */\n untilKind: (value: unknown): ErrorText => ({ kind: \"kind-mismatch\", message: `the test \"until\" of \"iterate\" gave a ${typeof value}, not a boolean` }),\n /** The limit of `iterate` with a test that is not true. */\n limit: (limit: number): ErrorText => ({ kind: \"limit\", message: `\"iterate\" made its ${String(limit)} steps, and its test \"until\" is not true` }),\n /** A value of a row of `fix` of the wrong kind for its join. */\n fixKind: (name: string, join: string, kind: string, value: unknown): ErrorText => ({ kind: \"kind-mismatch\", message: `the \"fix\" \"${name}\" with the join \"${join}\" needs a ${kind}, not a ${describeType(value)}` }),\n /** A value of a row of `fix` that is not a finite number. */\n fixNumber: (name: string, value: unknown): ErrorText => ({ kind: \"not-finite\", message: `the \"fix\" \"${name}\" gave the value ${String(value)}, not a finite number` }),\n /** The limit of the rounds of `fix`. */\n fixLimit: (name: string, rounds: number): ErrorText => ({ kind: \"limit\", message: `the \"fix\" \"${name}\" made its ${String(rounds)} rounds, and its values still change` }),\n /** A read of `last` at a key that is not a row. */\n lastKey: (name: string, key: string): ErrorText => ({ kind: \"unknown-key\", message: `the \"fix\" \"${name}\" has no row \"${key}\"` }),\n /** The test of `where`, with a value that is not a boolean. */\n whereKind: (value: unknown): ErrorText => ({ kind: \"kind-mismatch\", message: `the test of \"where\" gave a ${typeof value}, not a boolean` }),\n /** A domain that accepts the receiver of an op and has no such op. */\n domainNoOp: (domain: string, op: string): ErrorText => ({ kind: \"unknown-op\", message: `the domain \"${domain}\" has no op \"${op}\"`, op }),\n /** An op without arguments and without a free function. */\n noOp: (op: string): ErrorText => ({ kind: \"unknown-op\", message: `there is no function \"${op}\"`, op }),\n /** An op whose receiver no domain accepts. */\n noDomain: (op: string, self: unknown): ErrorText => ({ kind: \"not-instance\", message: `no domain accepts the receiver of \"${op}\" (${describeType(self)})`, op }),\n /** A special form without the argument at the index `i`. */\n needsArgument: (op: string, i: number): ErrorText => ({ kind: \"bad-expression\", message: `\"${op}\" needs argument ${String(i + 1)}`, op }),\n /** `and` or `or` without arguments. */\n needsArguments: (op: string): ErrorText => ({ kind: \"bad-expression\", message: `\"${op}\" needs at least 1 argument`, op }),\n /** An argument of a special form that is not a boolean. */\n notBoolean: (op: string, i: number, value: unknown): ErrorText => ({ kind: \"kind-mismatch\", message: `argument ${String(i + 1)} of \"${op}\" is a ${describeType(value)}, not a boolean`, op }),\n /** An argument of an op that does not have the kind of its parameter. */\n badParam: (op: string, i: number, value: unknown, kind: ParamKind, domain: string): ErrorText => ({\n kind: kind === \"domain\" ? \"not-instance\" : \"kind-mismatch\",\n message: `argument ${String(i + 1)} of \"${op}\" is a ${describeType(value)}, not a ${kind === \"domain\" ? domain : kind}`,\n op,\n }),\n /** An op that gave `undefined` or `null`. */\n noValue: (op: string): ErrorText => ({ kind: \"undefined-result\", message: `\"${op}\" gave no value`, op }),\n /** An op that gave a number that is not finite. */\n notFinite: (op: string, value: number): ErrorText => ({ kind: \"not-finite\", message: `\"${op}\" gave ${String(value)}`, op }),\n /** An op that gave a value that its domain does not accept as valid. */\n invalid: (op: string, domain: string): ErrorText => ({ kind: \"invalid-value\", message: `\"${op}\" gave a value that is not a valid ${domain}`, op }),\n /** A check `valid` of a domain that threw. */\n validThrew: (op: string, domain: string): ErrorText => ({ kind: \"threw\", message: `the \"valid\" check of \"${domain}\" threw an exception`, op }),\n /** A list op whose items must have one kind, with an item of another kind. */\n /** The axis `list` over a value that is not a list (AXIS.LIST). */\n axisList: (value: unknown): ErrorText => ({ kind: \"kind-mismatch\", message: `the axis \"list\" needs a list, not a ${describeType(value)}` }),\n needsItems: (op: string, what: \"numbers\" | \"booleans\", item: unknown): ErrorText => ({ kind: \"kind-mismatch\", message: `\"${op}\" needs ${what}, but an item is a ${describeType(item)}`, op }),\n /** A list op that has no items to work with. */\n empty: (op: string): ErrorText => ({ kind: \"empty\", message: `\"${op}\" has no values to work with`, op }),\n /** `reduce` with an op name that is not a text. */\n reduceName: (name: unknown): ErrorText => ({ kind: \"kind-mismatch\", message: `\"reduce\" needs an op name, but got a ${describeType(name)}`, op: \"reduce\" }),\n /** A step of `reduce` or of `sortBy` that no domain gives. */\n noStep: (op: string, value: unknown): ErrorText => ({ kind: \"unknown-op\", message: `no domain gives \"${op}\" for a ${describeType(value)}`, op }),\n} as const;\n\n/** The details of an error that come from its evaluation, and not from its text. */\nexport interface ErrorExtra {\n readonly causes?: readonly VexError[];\n readonly thrown?: unknown;\n}\n\n/** This function makes the error of a text at a node: the path of the node, with its origin and its focus. */\nexport function errorAt(t: ErrorText, pos: Position, path: readonly number[], extra: ErrorExtra = {}): VexError {\n return vexError(t.kind, t.message, { path, origin: pos.origin, focus: pos.focus, ...(t.op === undefined ? {} : { op: t.op }), ...extra });\n}\n","/**\n * The check of the names `as` of a loop over the axis `list` (AXIS.LIST.SCOPE). The package index does not export this\n * module: `isExpr`, `shapeError` and `fromDocument` use it, so an expression and a document follow the same rule.\n */\n\nconst isObject = (u: unknown): u is Readonly<Record<string, unknown>> => typeof u === \"object\" && u !== null;\n\n/** This function tells if the base axis of an axis is `list`, through `where` and `reverse`. It uses a loop, not recursion. */\nfunction isListAxis(u: unknown): boolean {\n let x = u;\n while (isObject(x) && x[\"t\"] === \"where\") x = x[\"axis\"];\n if (isObject(x) && x[\"t\"] === \"reverse\") x = x[\"axis\"];\n return isObject(x) && x[\"t\"] === \"list\";\n}\n\n/**\n * This function gives the reason that the names `as` of a loop are not valid, or `undefined` for valid names or no\n * names (AXIS.LIST.SCOPE). The names are one or two distinct texts, the axis is `list`, and no name is a name of `init`.\n */\nexport function itemNamesError(u: Readonly<Record<string, unknown>>): string | undefined {\n const as = u[\"as\"];\n if (as === undefined) return undefined;\n if (!Array.isArray(as) || as.length === 0 || as.length > 2 || !as.every((n) => typeof n === \"string\")) return '\"as\" is a list of one or two names: the item, and then its index';\n if (as[0] === as[1]) return `the two names of \"as\" are the same name \"${String(as[0])}\"`;\n if (!isListAxis(u[\"axis\"])) return '\"as\" needs the axis \"list\", also inside \"reverse\" and \"where\"';\n const init = u[\"init\"];\n const clash = isObject(init) ? (as as readonly string[]).find((n) => Object.hasOwn(init, n)) : undefined;\n return clash === undefined ? undefined : `the name \"${clash}\" of \"as\" is a name of \"init\" too`;\n}\n","/**\n * The expression IR of Vex. It is plain JSON data. Its first three kinds (`lit`, `ref`, `app`) have the same\n * shape as the expressions of `render`.\n */\n\nimport { itemNamesError } from \"./item-names.ts\";\n\n/**\n * One move of an address. The moves of an address apply in order, from the focus of the evaluation. The key of `key`\n * and the position of `index` can be an expression, which evaluates before the moves (NAV.COMPUTED).\n */\nexport type Move =\n | { readonly t: \"key\"; readonly key: string | Expr }\n | { readonly t: \"index\"; readonly i: number | Expr }\n | { readonly t: \"other\" }\n | { readonly t: \"offset\"; readonly d: readonly number[] }\n | { readonly t: \"origin\" }\n | { readonly t: \"parent\" };\n\n/** A move with a fixed key or position: a move with no expression. */\nexport type FixedMove = Exclude<Move, { readonly t: \"key\" | \"index\" }> | { readonly t: \"key\"; readonly key: string } | { readonly t: \"index\"; readonly i: number };\n\n/** An address: a list of moves. The empty list is the focus. */\nexport type Addr = readonly Move[];\n\n/** An axis: the relation between a position and the targets that a body reads. */\nexport type Axis =\n | { readonly t: \"all\" }\n | { readonly t: \"others\" }\n | { readonly t: \"other\" }\n | { readonly t: \"neighbors\"; readonly n: 4 | 8 }\n | { readonly t: \"children\" }\n | { readonly t: \"ancestors\" }\n | { readonly t: \"descendants\" }\n | { readonly t: \"siblings\" }\n | { readonly t: \"window\"; readonly from: number; readonly to: number }\n | { readonly t: \"table\"; readonly name: string }\n | { readonly t: \"successors\" }\n | { readonly t: \"predecessors\" }\n | { readonly t: \"reachable\" }\n | { readonly t: \"list\"; readonly list: Expr }\n | { readonly t: \"reverse\"; readonly axis: Axis }\n | { readonly t: \"where\"; readonly axis: Axis; readonly test: Expr };\n\n/** A Vex expression. */\nexport type Expr =\n | { readonly tag: \"lit\"; readonly value: unknown }\n | { readonly tag: \"ref\"; readonly path: readonly string[]; readonly at?: Addr }\n | { readonly tag: \"app\"; readonly op: string; readonly args: readonly Expr[] }\n | { readonly tag: \"let\"; readonly bind: Readonly<Record<string, Expr>>; readonly body: Expr }\n | { readonly tag: \"var\"; readonly name: string }\n | { readonly tag: \"rec\"; readonly fields: Readonly<Record<string, Expr>> }\n | { readonly tag: \"each\"; readonly axis: Axis; readonly body: Expr; readonly at?: Addr; readonly as?: ItemNames }\n | { readonly tag: \"fold\"; readonly axis: Axis; readonly init: Names; readonly step: Names; readonly result: Expr; readonly at?: Addr; readonly as?: ItemNames }\n | { readonly tag: \"iterate\"; readonly limit: number | DataLimit; readonly init: Names; readonly step: Names; readonly until?: Expr; readonly result: Expr }\n | { readonly tag: \"fix\"; readonly name: string; readonly join: FixJoin; readonly init: Expr; readonly step: Expr }\n | { readonly tag: \"last\"; readonly name: string }\n | { readonly tag: \"fn\"; readonly params: readonly string[]; readonly body: Expr }\n | { readonly tag: \"call\"; readonly fn: string; readonly args: readonly Expr[] }\n | { readonly tag: \"ext\"; readonly kind: string; readonly data: unknown };\n\n/** The names of a loop and an expression for each (LOOP.NAMES). */\nexport type Names = Readonly<Record<string, Expr>>;\n\n/**\n * The names of the items of a loop over the axis `list`. The first name holds the value of the item, and the second\n * its position (AXIS.LIST.ITEM, AXIS.LIST.INDEX). The body of `each` and the steps of `fold` see them (AXIS.LIST.SCOPE).\n */\nexport type ItemNames = readonly [item: string] | readonly [item: string, index: string];\n\n/** The joins of `fix`. The join `or` or `max` moves a row up, and `and` or `min` moves a row down (FIX.JOIN). */\nexport type FixJoin = \"or\" | \"and\" | \"max\" | \"min\";\n\n/** The largest number of steps of `iterate` (ITERATE.LIMIT). */\nexport const MAX_ITERATIONS = 100_000;\n\n/**\n * The limit of `iterate` from the size of the data (ITERATE.LIMIT.DATA): the number of targets of an axis. This is the\n * number of steps that a `fold` over the axis makes. The axis `list` gives the count of a list. This limit needs step B.\n */\nexport interface DataLimit {\n readonly axis: Axis;\n}\n\n/** The tag of an expression kind. */\nexport type ExprTag = Expr[\"tag\"];\n\n/** An expression of one kind. */\nexport type ExprOf<T extends ExprTag> = Extract<Expr, { readonly tag: T }>;\n\n// ---------------------------------------------------------------- constructors\n\n/** This function makes a literal. */\nexport const lit = (value: unknown): ExprOf<\"lit\"> => ({ tag: \"lit\", value });\n\n/** This function splits a dotted path, for example `\"pos.x\"`, into its segments. */\nexport const toPath = (path: string | readonly string[]): readonly string[] =>\n typeof path === \"string\" ? path.split(\".\").filter((s) => s.length > 0) : path;\n\n/** This function makes a reference to a field path. With `at`, the reference reads at that address. */\nexport function ref(path: string | readonly string[], at?: Addr): ExprOf<\"ref\"> {\n const segments = toPath(path);\n return at === undefined || at.length === 0 ? { tag: \"ref\", path: segments } : { tag: \"ref\", path: segments, at };\n}\n\n/** This function makes the application of an op to arguments. For a method op, the first argument is the receiver. */\nexport const app = (op: string, ...args: readonly Expr[]): ExprOf<\"app\"> => ({ tag: \"app\", op, args });\n\n/** This function binds names to expressions for the body. */\nexport const let_ = (bind: Readonly<Record<string, Expr>>, body: Expr): ExprOf<\"let\"> => ({ tag: \"let\", bind, body });\n\n/** This function makes a reference to a bound name. */\nexport const v = (name: string): ExprOf<\"var\"> => ({ tag: \"var\", name });\n\n/** This function makes a record from field expressions. */\nexport const rec = (fields: Readonly<Record<string, Expr>>): ExprOf<\"rec\"> => ({ tag: \"rec\", fields });\n\n/**\n * This function evaluates `body` once for each target of `axis`. The result is a list. With `at`, the axis finds its\n * targets from the key of that address, not from the focus. With `as`, the body of a loop over the axis `list` reads the\n * value of each item and its position by these names (AXIS.LIST.ITEM, AXIS.LIST.INDEX).\n */\nexport function each(axis: Axis, body: Expr, at?: Addr, as?: ItemNames): ExprOf<\"each\"> {\n const named = as === undefined ? {} : { as };\n return at === undefined || at.length === 0 ? { tag: \"each\", axis, body, ...named } : { tag: \"each\", axis, body, at, ...named };\n}\n\n/**\n * This function makes a fold: a step at each target of `axis`, in order. `init` gives the names and their first\n * values, and `step` gives the next values. `result` gives the value from the last values (LOOP.NAMES, FOLD.ORDER). With\n * `as`, the steps of a fold over the axis `list` read the value of each item and its position by these names\n * (AXIS.LIST.ITEM, AXIS.LIST.INDEX).\n */\nexport function fold(axis: Axis, init: Names, step: Names, result: Expr, at?: Addr, as?: ItemNames): ExprOf<\"fold\"> {\n const named = as === undefined ? {} : { as };\n return at === undefined || at.length === 0 ? { tag: \"fold\", axis, init, step, result, ...named } : { tag: \"fold\", axis, init, step, result, at, ...named };\n}\n\n/**\n * This function makes an iteration: up to `limit` steps. `init` gives the names and their first values, and `step`\n * gives the next values. A true `until` stops it, and `result` gives the value (ITERATE.LIMIT, ITERATE.UNTIL).\n */\nexport function iterate(limit: number | DataLimit, init: Names, step: Names, result: Expr, until?: Expr): ExprOf<\"iterate\"> {\n return until === undefined ? { tag: \"iterate\", limit, init, step, result } : { tag: \"iterate\", limit, init, step, until, result };\n}\n\n/**\n * This function makes a fixed-point column (FIX.ROUNDS). `init` gives the first value of each row. `step` gives the next\n * value of each row, and it reads the last round with `last`. `join` joins each next value to the old value of its row.\n */\nexport function fix(name: string, join: FixJoin, init: Expr, step: Expr): ExprOf<\"fix\"> {\n return { tag: \"fix\", name, join, init, step };\n}\n\n/** This function makes a read of the value of the focus in the last round of the `fix` with the name `name` (FIX.LAST). */\nexport function last(name: string): ExprOf<\"last\"> {\n return { tag: \"last\", name };\n}\n\n/** This function makes the limit of `iterate` from the size of the data: the number of targets of an axis (ITERATE.LIMIT.DATA). */\nexport const dataLimit = (axis: Axis): DataLimit => ({ axis });\n\n/** This function gives the axis of the data limit of an iteration, or `undefined` for a limit that is a number. */\nexport const limitAxis = (e: ExprOf<\"iterate\">): Axis | undefined => (typeof e.limit === \"number\" ? undefined : e.limit.axis);\n\n/**\n * This function gives the parts of an iteration with a data limit, for a walk that tells the axes apart. The parts are\n * an `each` over the axis, and the iteration without its axis. An iteration with a number has `undefined`.\n */\nexport function splitLimit(e: ExprOf<\"iterate\">): readonly [ExprOf<\"each\">, ExprOf<\"iterate\">] | undefined {\n const axis = limitAxis(e);\n return axis === undefined ? undefined : [each(axis, lit(0)), { ...e, limit: 0 }];\n}\n\n/**\n * This function makes a function (FN.BIND): the names of its parameters and its body. A function is only the value of\n * a binding of `let`. The body sees the names of the place of that `let`, so a function cannot call itself.\n */\nexport const fn = (params: readonly string[], body: Expr): ExprOf<\"fn\"> => ({ tag: \"fn\", params, body });\n\n/** This function makes a call of a bound function (FN.CALL). The body evaluates at the position of the call. */\nexport const call = (name: string, ...args: Expr[]): ExprOf<\"call\"> => ({ tag: \"call\", fn: name, args });\n\n/** This function makes an expression of an extension kind. */\nexport const ext = (kind: string, data: unknown): ExprOf<\"ext\"> => ({ tag: \"ext\", kind, data });\n\n// ---------------------------------------------------------------- moves and axes\n\n/** The move to an absolute key. The key can be an expression that gives a text. */\nexport function key(k: string): FixedMove;\nexport function key(k: string | Expr): Move;\nexport function key(k: string | Expr): Move {\n return { t: \"key\", key: k };\n}\n/** The move to a position in the key order. The position can be an expression that gives a number. */\nexport function index(i: number): FixedMove;\nexport function index(i: number | Expr): Move;\nexport function index(i: number | Expr): Move {\n return { t: \"index\", i };\n}\n\n/** This function gives the expression of a move with a computed key or position, or `undefined`. */\nexport function moveExpr(m: Move): Expr | undefined {\n if (m.t === \"key\") return typeof m.key === \"string\" ? undefined : m.key;\n return m.t === \"index\" && typeof m.i !== \"number\" ? m.i : undefined;\n}\n\n/** This function gives the expressions of the computed moves of an address, in the order of the moves. */\nexport const addrExprs = (at: Addr | undefined): readonly Expr[] => (at ?? []).flatMap((m) => moveExpr(m) ?? []);\n\n/** This function tells if each move of an address is fixed. */\nexport const isFixedAddr = (at: Addr | undefined): at is readonly FixedMove[] => addrExprs(at).length === 0;\n/** The move to the other key of a space with two keys. */\nexport const other: FixedMove = Object.freeze({ t: \"other\" });\n/** The relative move in an array (one number) or a grid (two numbers). */\nexport const offset = (...d: readonly number[]): FixedMove => ({ t: \"offset\", d });\n/** The move back to the origin of the evaluation. */\nexport const origin: FixedMove = Object.freeze({ t: \"origin\" });\n/** The move to the parent of the focus in a tree space. */\nexport const parent: FixedMove = Object.freeze({ t: \"parent\" });\n\n/** The axes. */\nexport const axes = {\n /** Each key of the space. */\n all: Object.freeze({ t: \"all\" }) as Axis,\n /** Each key except the focus. */\n others: Object.freeze({ t: \"others\" }) as Axis,\n /** The other key of a pair. */\n other: Object.freeze({ t: \"other\" }) as Axis,\n /** The neighbors of the focus in a grid. */\n neighbors: (n: 4 | 8 = 8): Axis => ({ t: \"neighbors\", n }),\n /** The children of the focus in a tree, in key order. */\n children: Object.freeze({ t: \"children\" }) as Axis,\n /** The ancestors of the focus in a tree: the parent first, the root last. */\n ancestors: Object.freeze({ t: \"ancestors\" }) as Axis,\n /** The descendants of the focus in a tree, depth first, each parent before its children. */\n descendants: Object.freeze({ t: \"descendants\" }) as Axis,\n /** The other children of the parent of the focus. For a root, the other roots. */\n siblings: Object.freeze({ t: \"siblings\" }) as Axis,\n /**\n * The keys at the offsets from `from` to `to` of the focus, in order: a window of rows. The offset 0 is the focus. In\n * a tree space, the offsets go among the siblings. An offset outside the space has no target.\n */\n window: (from: number, to: number): Axis => ({ t: \"window\", from, to }),\n /**\n * Each key of the table `name` of the evaluation, in key order. The body evaluates in the space of that table, and\n * there the origin is the target.\n */\n table: (name: string): Axis => ({ t: \"table\", name }),\n /** The keys at the ends of the edges from the focus, in a graph space. In a tree space, the children. */\n successors: Object.freeze({ t: \"successors\" }) as Axis,\n /** The keys with an edge to the focus, in key order. In a tree space, the parent. */\n predecessors: Object.freeze({ t: \"predecessors\" }) as Axis,\n /** Each key that a path of edges reaches from the focus, in breadth-first order, without the focus. */\n reachable: Object.freeze({ t: \"reachable\" }) as Axis,\n /**\n * The targets of `axis` in the reverse order (AXIS.REVERSE). The inner axis is a base axis: not `where`, `reverse` or\n * `table`. A test goes outside: `where(reverse(axis), test)`.\n */\n reverse: (axis: Axis): Axis => ({ t: \"reverse\", axis }),\n /**\n * The keys of the items of the list that `list` gives, in the order of the list (AXIS.LIST). The expression evaluates\n * before the targets. An error item gives an error item for its target.\n */\n list: (list: Expr): Axis => ({ t: \"list\", list }),\n /** The targets of `axis` where `test` gives `true`. */\n where: (axis: Axis, test: Expr): Axis => ({ t: \"where\", axis, test }),\n} as const;\n\n// ---------------------------------------------------------------- validation\n\nconst isObject = (u: unknown): u is Readonly<Record<string, unknown>> => typeof u === \"object\" && u !== null;\n\nconst isStringArray = (u: unknown): u is readonly string[] => Array.isArray(u) && u.every((s) => typeof s === \"string\");\n\n/** This function tells if a value is a valid move. The expression of a computed move must be valid too. */\nexport function isMove(u: unknown): u is Move {\n const exprs = moveParts(u);\n return exprs !== undefined && exprs.every(isExpr);\n}\n\n/**\n * A test of the numbers of a move or of a window. The JSON form needs whole numbers. An expression in code can have any\n * number, and a number that is not whole has a meaning at run time (EVAL.SHAPE).\n */\ntype NumberTest = (x: unknown) => boolean;\n\nconst anyNumber: NumberTest = (x) => typeof x === \"number\";\n\n/** This function checks the fixed parts of a move. It gives the expressions of the move, or `undefined` for a bad move. */\nfunction moveParts(u: unknown, isNumber: NumberTest = Number.isInteger): readonly unknown[] | undefined {\n if (!isObject(u)) return undefined;\n switch (u[\"t\"]) {\n case \"key\":\n return typeof u[\"key\"] === \"string\" ? [] : isObject(u[\"key\"]) ? [u[\"key\"]] : undefined;\n case \"index\":\n return isNumber(u[\"i\"]) ? [] : isObject(u[\"i\"]) ? [u[\"i\"]] : undefined;\n case \"offset\":\n return Array.isArray(u[\"d\"]) && u[\"d\"].every((n) => isNumber(n)) ? [] : undefined;\n case \"other\":\n case \"origin\":\n case \"parent\":\n return [];\n default:\n return undefined;\n }\n}\n\n/** This function tells if a value is a valid axis. It checks the tests of `where` too. */\nexport function isAxis(u: unknown): u is Axis {\n return badPart([{ axis: true, u }], true) === undefined;\n}\n\n/** This function tells if a value is a valid expression. It checks the whole tree. */\nexport function isExpr(u: unknown): u is Expr {\n return badPart([{ axis: false, u }], true) === undefined;\n}\n\n/** The tags of the expressions of this version of Vex. */\nconst TAGS: ReadonlySet<unknown> = new Set([\"lit\", \"ref\", \"app\", \"let\", \"var\", \"rec\", \"each\", \"fold\", \"iterate\", \"fix\", \"last\", \"fn\", \"call\", \"ext\"]);\n\n/** The joins of `fix`. */\nconst JOINS: ReadonlySet<unknown> = new Set<FixJoin>([\"or\", \"and\", \"max\", \"min\"]);\n\n/**\n * This function gives the reason that a value is not a valid expression, or `undefined` for a valid expression\n * (EVAL.SHAPE). An expression from a newer version of Vex can have a tag that this version does not know. Unlike\n * `isExpr`, it accepts a number that is not whole in a move or in a window, because it has a meaning at run time.\n */\nexport function shapeError(u: unknown): string | undefined {\n const bad = badPart([{ axis: false, u }], false);\n if (bad === undefined) return undefined;\n const tag = isObject(bad.u) ? bad.u[\"tag\"] : undefined;\n if (bad.axis) return \"the expression has an axis that is not valid\";\n if (typeof tag === \"string\" && !TAGS.has(tag)) return `the expression has a node with the tag \"${tag}\", and this version of Vex does not know it`;\n if (tag === \"fn\") return \"the expression has a function outside the bindings of a let, or a function with parameters that are not distinct names\";\n const named = tag === \"each\" || tag === \"fold\" ? itemNamesError(bad.u as Readonly<Record<string, unknown>>) : undefined;\n if (named !== undefined) return `the expression has a node \"${String(tag)}\" with names \"as\" that are not valid: ${named}`;\n return typeof tag === \"string\" ? `the expression has a node \"${tag}\" with parts that are not valid` : \"the expression has a part that is not a node\";\n}\n\n/**\n * This function checks the names of a loop: `init` and `step` are records, and each name of `step` is a name of `init`.\n * It gives the expressions of `init`, of `step` and `result`, or `undefined` (LOOP.NAMES).\n */\nfunction loopParts(u: Readonly<Record<string, unknown>>): readonly unknown[] | undefined {\n const { init, step } = u;\n if (!isObject(init) || Array.isArray(init) || !isObject(step) || Array.isArray(step)) return undefined;\n if (!Object.keys(step).every((n) => Object.hasOwn(init, n))) return undefined;\n return [...Object.values(init), ...Object.values(step), u[\"result\"]];\n}\n\n/** This function checks the fixed parts of an address. It gives the expressions of its moves, or `undefined`. */\nfunction addrParts(u: unknown, isNumber: NumberTest): readonly unknown[] | undefined {\n if (u === undefined) return [];\n if (!Array.isArray(u)) return undefined;\n const out: unknown[] = [];\n for (const m of u) {\n const parts = moveParts(m, isNumber);\n if (parts === undefined) return undefined;\n out.push(...parts);\n }\n return out;\n}\n\n/**\n * This function checks a tree of expressions and axes, and it gives the first part that is not valid. It uses a stack,\n * not recursion, so the input can be deep. For example, a deep JSON file from a stranger does not need a deep call\n * stack (EVAL.NESTING). With `whole`, the numbers of the moves and of the windows must be whole, as the JSON form needs.\n */\nfunction badPart(todo: { readonly axis: boolean; readonly u: unknown }[], whole: boolean): { readonly axis: boolean; readonly u: unknown } | undefined {\n const moveNumber = whole ? Number.isInteger : anyNumber;\n const windowNumber = whole ? Number.isSafeInteger : anyNumber;\n const push = (axis: boolean, values: readonly unknown[]): void => {\n for (const u of values) todo.push({ axis, u });\n };\n for (let item = todo.pop(); item !== undefined; item = todo.pop()) {\n const { u } = item;\n if (!isObject(u)) return item;\n if (item.axis) {\n const t = u[\"t\"];\n if (t === \"neighbors\") {\n if (u[\"n\"] !== 4 && u[\"n\"] !== 8) return item;\n } else if (t === \"window\") {\n if (!windowNumber(u[\"from\"]) || !windowNumber(u[\"to\"])) return item;\n } else if (t === \"table\") {\n if (typeof u[\"name\"] !== \"string\") return item;\n } else if (t === \"where\") {\n push(true, [u[\"axis\"]]);\n push(false, [u[\"test\"]]);\n } else if (t === \"list\") {\n push(false, [u[\"list\"]]);\n } else if (t === \"reverse\") {\n // The inner axis of reverse is a base axis.\n const inner = u[\"axis\"];\n if (!isObject(inner) || [\"where\", \"reverse\", \"table\"].includes(inner[\"t\"] as string)) return item;\n push(true, [inner]);\n } else if (![\"all\", \"others\", \"other\", \"children\", \"ancestors\", \"descendants\", \"siblings\", \"successors\", \"predecessors\", \"reachable\"].includes(t as string)) {\n return item;\n }\n continue;\n }\n switch (u[\"tag\"]) {\n case \"lit\":\n if (!(\"value\" in u)) return item;\n break;\n case \"ref\": {\n const at = addrParts(u[\"at\"], moveNumber);\n if (!isStringArray(u[\"path\"]) || at === undefined) return item;\n push(false, at);\n break;\n }\n case \"app\":\n if (typeof u[\"op\"] !== \"string\" || !Array.isArray(u[\"args\"])) return item;\n push(false, u[\"args\"]);\n break;\n case \"let\": {\n if (!isObject(u[\"bind\"]) || Array.isArray(u[\"bind\"])) return item;\n // A binding can be a function (FN.BIND): its parameters are distinct names, and its body is an expression.\n const values = Object.values(u[\"bind\"]).map((b) => (isObject(b) && b[\"tag\"] === \"fn\" && isStringArray(b[\"params\"]) && new Set(b[\"params\"]).size === b[\"params\"].length ? b[\"body\"] : b));\n push(false, [...values, u[\"body\"]]);\n break;\n }\n case \"call\":\n if (typeof u[\"fn\"] !== \"string\" || !Array.isArray(u[\"args\"])) return item;\n push(false, u[\"args\"]);\n break;\n case \"var\":\n if (typeof u[\"name\"] !== \"string\") return item;\n break;\n case \"rec\":\n if (!isObject(u[\"fields\"]) || Array.isArray(u[\"fields\"])) return item;\n push(false, Object.values(u[\"fields\"]));\n break;\n case \"each\": {\n const at = addrParts(u[\"at\"], moveNumber);\n if (at === undefined || itemNamesError(u) !== undefined) return item;\n push(true, [u[\"axis\"]]);\n push(false, [u[\"body\"], ...at]);\n break;\n }\n case \"fold\": {\n const at = addrParts(u[\"at\"], moveNumber);\n const names = loopParts(u);\n if (at === undefined || names === undefined || itemNamesError(u) !== undefined) return item;\n push(true, [u[\"axis\"]]);\n push(false, [...names, ...at]);\n break;\n }\n case \"iterate\": {\n const limit = u[\"limit\"];\n const names = loopParts(u);\n if (names === undefined) return item;\n if (isObject(limit)) push(true, [limit[\"axis\"]]);\n else if (typeof limit !== \"number\" || !Number.isInteger(limit) || limit < 0 || limit > MAX_ITERATIONS) return item;\n push(false, [...names, ...(u[\"until\"] === undefined ? [] : [u[\"until\"]])]);\n break;\n }\n case \"fix\":\n if (typeof u[\"name\"] !== \"string\" || !JOINS.has(u[\"join\"])) return item;\n push(false, [u[\"init\"], u[\"step\"]]);\n break;\n case \"last\":\n if (typeof u[\"name\"] !== \"string\") return item;\n break;\n case \"ext\":\n if (typeof u[\"kind\"] !== \"string\" || !(\"data\" in u)) return item;\n break;\n default:\n return item;\n }\n }\n return undefined;\n}\n\n/**\n * This function gives the child expressions of an expression, in the order of their child index. The expressions of\n * the computed moves of an address come last. They evaluate at the position of their node, also for an axis.\n */\nexport function children(e: Expr): readonly Expr[] {\n switch (e.tag) {\n case \"app\":\n case \"call\":\n return e.args;\n case \"fn\":\n return [e.body];\n case \"let\":\n return [...Object.values(e.bind), e.body];\n case \"rec\":\n return Object.values(e.fields);\n case \"each\":\n return [e.body, ...axisExprs(e.axis), ...addrExprs(e.at)];\n case \"fold\":\n return [...Object.values(e.init), ...Object.values(e.step), ...axisExprs(e.axis), ...addrExprs(e.at), e.result];\n case \"iterate\": {\n const axis = limitAxis(e);\n return [...Object.values(e.init), ...Object.values(e.step), ...(axis === undefined ? [] : axisExprs(axis)), ...(e.until === undefined ? [] : [e.until]), e.result];\n }\n case \"fix\":\n return [e.init, e.step];\n case \"ref\":\n return addrExprs(e.at);\n case \"lit\":\n case \"var\":\n case \"last\":\n case \"ext\":\n return [];\n }\n}\n\n/**\n * This function gives the expressions of an axis, in the order of their child indexes. The expression of the axis\n * `list` comes first, and then the tests of the `where` axes from the inside out. It uses a loop, not recursion.\n */\nexport function axisExprs(a: Axis): readonly Expr[] {\n const out: Expr[] = [];\n for (let x = a; x.t === \"where\"; x = x.axis) out.unshift(x.test);\n const list = listOf(a);\n return list === undefined ? out : [list, ...out];\n}\n\n/** This function gives the expression of the axis `list` inside an axis, through `where` and `reverse`, if it has one. */\nexport function listOf(a: Axis): Expr | undefined {\n let x = a;\n while (x.t === \"where\") x = x.axis;\n const base = x.t === \"reverse\" ? x.axis : x;\n return base.t === \"list\" ? base.list : undefined;\n}\n","import { vexError } from \"./errors.ts\";\nimport { moveExpr, type Addr, type Axis, type FixedMove } from \"./ir.ts\";\nimport { fail, ok, type Result } from \"./result.ts\";\n\n/** The kind of a space. The kind sets which moves and axes are valid. */\nexport type SpaceKind = \"record\" | \"array\" | \"grid\" | \"tree\" | \"graph\";\n\n/**\n * A space: an immutable collection of records with keys. A Vex program evaluates at one key of a space.\n * Nothing changes a space after it is made.\n */\nexport interface Space<K extends string = string, O = unknown> {\n readonly kind: SpaceKind;\n /** The keys, in their order. */\n readonly keys: readonly K[];\n /**\n * The record of each key, in the order of `keys` (SPACE.RECORDS). A compiler reads a record by its index with it.\n * A space without it gives each record with `get` only.\n */\n readonly records?: readonly (O | undefined)[];\n /** This function tells if the space has the key `k`. */\n has(k: string): k is K;\n /** This function gives the record at the key `k`, or `undefined`. */\n get(k: string): O | undefined;\n /** The position of each key, for array and grid spaces. An array key has one number, a grid key has two. */\n coords(k: string): readonly number[] | undefined;\n /** The key at a position, or `undefined`. */\n keyAt(coords: readonly number[]): K | undefined;\n /** The parent of the key `k` in a tree space, or `undefined` for a root. Other spaces do not have it. */\n parentOf?(k: string): K | undefined;\n /** The children of the key `k` in a tree space, in key order. Other spaces do not have it. */\n childrenOf?(k: string): readonly K[];\n /** The keys at the ends of the edges from `k`, in a graph space or a tree space. Other spaces do not have it. */\n successorsOf?(k: string): readonly K[];\n /** The keys with an edge to `k`, in key order, in a graph space or a tree space. Other spaces do not have it. */\n predecessorsOf?(k: string): readonly K[];\n}\n\n/** The key type of a grid space. */\nexport type GridKey = `${number},${number}`;\n\n/** The key type of an array space. */\nexport type ArrayKey = `${number}`;\n\nclass RecordSpace<K extends string, O> implements Space<K, O> {\n readonly kind: SpaceKind = \"record\";\n readonly keys: readonly K[];\n readonly records: readonly O[];\n readonly #records: ReadonlyMap<string, O>;\n\n constructor(records: Readonly<Record<K, O>>) {\n const entries = Object.entries(records) as [K, O][];\n this.keys = Object.freeze(entries.map(([k]) => k));\n this.records = Object.freeze(entries.map(([, o]) => o));\n this.#records = new Map(entries);\n }\n\n has(k: string): k is K {\n return this.#records.has(k);\n }\n get(k: string): O | undefined {\n return this.#records.get(k);\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n coords(): readonly number[] | undefined {\n return undefined;\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n keyAt(): K | undefined {\n return undefined;\n }\n}\n\nclass ArraySpace<O> implements Space<ArrayKey, O> {\n readonly kind: SpaceKind = \"array\";\n readonly keys: readonly ArrayKey[];\n readonly records: readonly O[];\n\n constructor(items: readonly O[]) {\n this.keys = Object.freeze(Array.from(items, (_item, i): ArrayKey => `${i}`));\n this.records = Object.freeze(Array.from(items));\n }\n\n // The key at the position i is the text of i, so the position of a key finds it. A text that is not a key of the\n // space, for example \"01\" or \"1.0\", has no key at its position.\n has(k: string): k is ArrayKey {\n return this.keys[Number(k)] === k;\n }\n get(k: string): O | undefined {\n return this.has(k) ? this.records[Number(k)] : undefined;\n }\n coords(k: string): readonly number[] | undefined {\n return this.has(k) ? [Number(k)] : undefined;\n }\n keyAt(coords: readonly number[]): ArrayKey | undefined {\n return coords.length === 1 ? this.keys[Number(coords[0])] : undefined;\n }\n}\n\nclass GridSpace<O> implements Space<GridKey, O> {\n readonly kind: SpaceKind = \"grid\";\n readonly keys: readonly GridKey[];\n readonly records: readonly O[];\n readonly #cells: ReadonlyMap<string, O>;\n readonly #coords: ReadonlyMap<string, readonly number[]>;\n\n constructor(rows: readonly (readonly O[])[]) {\n const entries = rows.flatMap((row, i) => row.map((cell, j): [GridKey, O, readonly number[]] => [`${i},${j}`, cell, Object.freeze([i, j])]));\n this.keys = Object.freeze(entries.map(([k]) => k));\n this.records = Object.freeze(entries.map(([, o]) => o));\n this.#cells = new Map(entries.map(([k, cell]) => [k, cell]));\n this.#coords = new Map(entries.map(([k, , c]) => [k, c]));\n }\n\n has(k: string): k is GridKey {\n return this.#cells.has(k);\n }\n get(k: string): O | undefined {\n return this.#cells.get(k);\n }\n coords(k: string): readonly number[] | undefined {\n return this.#coords.get(k);\n }\n keyAt(coords: readonly number[]): GridKey | undefined {\n // Each key has two coordinates, so a list with more or fewer coordinates gives no key.\n const k = coords.join(\",\");\n return this.has(k) ? k : undefined;\n }\n}\n\nclass TreeSpace<K extends string, O> implements Space<K, O> {\n readonly kind: SpaceKind = \"tree\";\n readonly keys: readonly K[];\n readonly records: readonly O[];\n readonly #records: ReadonlyMap<string, O>;\n readonly #parents: ReadonlyMap<string, K>;\n readonly #children: ReadonlyMap<string, readonly K[]>;\n\n constructor(records: Readonly<Record<K, O>>, parents: Readonly<Partial<Record<K, K | null>>>) {\n const entries = Object.entries(records) as [K, O][];\n this.keys = Object.freeze(entries.map(([k]) => k));\n this.records = Object.freeze(entries.map(([, o]) => o));\n this.#records = new Map(entries);\n const parentOf = new Map<string, K>();\n for (const [k, p] of Object.entries(parents) as [K, K | null | undefined][]) {\n if (!this.#records.has(k)) throw new TypeError(`the tree has no key \"${k}\", but the parents name it`);\n if (p === null || p === undefined) continue;\n if (!this.#records.has(p)) throw new TypeError(`the parent \"${p}\" of \"${k}\" is not a key of the tree`);\n parentOf.set(k, p);\n }\n // A parent chain that comes back to a key of the same walk is a cycle, not a tree. Each key is in one walk\n // only: a walk stops at a key that an earlier walk proved to reach a root. Thus the check is linear.\n const reachesRoot = new Set<string>();\n for (const k of this.keys) {\n const walk = new Set<string>();\n for (let p: string | undefined = k; p !== undefined && !reachesRoot.has(p); p = parentOf.get(p)) {\n if (walk.has(p)) throw new TypeError(`the parents of \"${k}\" make a cycle, so the space is not a tree`);\n walk.add(p);\n }\n for (const w of walk) reachesRoot.add(w);\n }\n this.#parents = parentOf;\n const children = new Map<string, K[]>(this.keys.map((k) => [k, []]));\n for (const k of this.keys) {\n const p = parentOf.get(k);\n // Each parent is a key, so its list exists, and the test of p only skips the roots.\n // Stryker disable next-line ConditionalExpression,OptionalChaining: a root has no list to push to\n if (p !== undefined) children.get(p)?.push(k);\n }\n this.#children = new Map([...children].map(([k, c]) => [k, Object.freeze(c)]));\n }\n\n has(k: string): k is K {\n return this.#records.has(k);\n }\n get(k: string): O | undefined {\n return this.#records.get(k);\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n coords(): readonly number[] | undefined {\n return undefined;\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n keyAt(): K | undefined {\n return undefined;\n }\n // In a tree, the edges go from a parent to its children.\n successorsOf(k: string): readonly K[] {\n return this.childrenOf(k);\n }\n predecessorsOf(k: string): readonly K[] {\n const p = this.#parents.get(k);\n return p === undefined ? [] : [p];\n }\n parentOf(k: string): K | undefined {\n return this.#parents.get(k);\n }\n childrenOf(k: string): readonly K[] {\n return this.#children.get(k) ?? [];\n }\n}\n\n/** The constructors of spaces. */\n/** The empty list of keys. */\nconst NO_KEYS: readonly never[] = Object.freeze([]);\n\nclass GraphSpace<K extends string, O> implements Space<K, O> {\n readonly kind: SpaceKind = \"graph\";\n readonly keys: readonly K[];\n readonly records: readonly O[];\n readonly #records: ReadonlyMap<string, O>;\n readonly #out: ReadonlyMap<string, readonly K[]>;\n readonly #in: ReadonlyMap<string, readonly K[]>;\n\n constructor(records: Readonly<Record<K, O>>, edges: Readonly<Partial<Record<K, readonly K[]>>>) {\n const entries = Object.entries(records) as [K, O][];\n this.keys = Object.freeze(entries.map(([k]) => k));\n this.records = Object.freeze(entries.map(([, o]) => o));\n this.#records = new Map(entries);\n const out = new Map<string, readonly K[]>();\n for (const [k, to] of Object.entries(edges) as [K, readonly K[] | undefined][]) {\n if (!this.#records.has(k)) throw new TypeError(`the graph has no key \"${k}\", but the edges name it`);\n // A second edge to the same key is the same edge.\n const ends = [...new Set(to ?? NO_KEYS)];\n for (const t of ends) if (!this.#records.has(t)) throw new TypeError(`the edge from \"${k}\" goes to \"${t}\", which is not a key of the graph`);\n out.set(k, Object.freeze(ends));\n }\n this.#out = out;\n // The predecessors in key order: the keys in key order, and the ends of the edges of each key.\n const into = new Map<string, K[]>();\n for (const k of this.keys) {\n for (const t of out.get(k) ?? NO_KEYS) {\n const from = into.get(t);\n if (from === undefined) into.set(t, [k]);\n else from.push(k);\n }\n }\n this.#in = new Map([...into].map(([k, from]) => [k, Object.freeze(from)]));\n }\n\n has(k: string): k is K {\n return this.#records.has(k);\n }\n get(k: string): O | undefined {\n return this.#records.get(k);\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n coords(): readonly number[] | undefined {\n return undefined;\n }\n // Stryker disable next-line BlockStatement: the body gives undefined, and an empty body gives undefined too\n keyAt(): K | undefined {\n return undefined;\n }\n successorsOf(k: string): readonly K[] {\n return this.#out.get(k) ?? NO_KEYS;\n }\n predecessorsOf(k: string): readonly K[] {\n return this.#in.get(k) ?? NO_KEYS;\n }\n}\n\nexport const space = {\n /** This function makes a space from the entries of an object. The keys are the property names. */\n record<const R extends Readonly<Record<string, unknown>>>(records: R): Space<keyof R & string, R[keyof R]> {\n return new RecordSpace<keyof R & string, R[keyof R]>(records);\n },\n /** This function makes a space from an array. The keys are `\"0\"`, `\"1\"` and so on. */\n array<O>(items: readonly O[]): Space<ArrayKey, O> {\n return new ArraySpace(items);\n },\n /** This function makes a space from rows of cells. The key of a cell is `\"row,column\"`. */\n grid<O>(rows: readonly (readonly O[])[]): Space<GridKey, O> {\n return new GridSpace(rows);\n },\n /**\n * This function makes a tree space: the records by key, and the parent of each key. A key without a parent, or\n * with the parent `null`, is a root. A parent that is not a key, or a cycle of parents, throws a `TypeError`.\n */\n tree<const R extends Readonly<Record<string, unknown>>>(records: R, parents: Readonly<Partial<Record<keyof R & string, (keyof R & string) | null>>>): Space<keyof R & string, R[keyof R]> {\n return new TreeSpace<keyof R & string, R[keyof R]>(records, parents);\n },\n /**\n * This function makes a graph space: the records by key, and the edges from each key, in order. An edge to a key\n * that is not in the graph throws a `TypeError`. A graph can have cycles, and an edge can go from a key to itself.\n */\n graph<const R extends Readonly<Record<string, unknown>>>(records: R, edges: Readonly<Partial<Record<keyof R & string, readonly (keyof R & string)[]>>>): Space<keyof R & string, R[keyof R]> {\n return new GraphSpace<keyof R & string, R[keyof R]>(records, edges);\n },\n} as const;\n\n/** The position of an evaluation: the key where it started, and the key where relative references read. */\nexport interface Position {\n readonly origin: string;\n readonly focus: string;\n}\n\n/** This function applies one move to the focus. It gives the new focus, or a `#REF!` error. */\nexport function applyMove(s: Space, at: Position, m: FixedMove): Result<string> {\n const refError = (kind: \"unknown-key\" | \"not-a-pair\" | \"out-of-bounds\" | \"no-offset\" | \"no-tree\", message: string): Result<string> =>\n fail(vexError(kind, message, { origin: at.origin, focus: at.focus }));\n switch (m.t) {\n case \"key\":\n return s.has(m.key) ? ok(m.key) : refError(\"unknown-key\", `the space has no key \"${m.key}\"`);\n case \"index\": {\n const k = s.keys[m.i];\n return k !== undefined ? ok(k) : refError(\"out-of-bounds\", `the space has no key at index ${m.i}`);\n }\n case \"other\": {\n if (s.keys.length !== 2) return refError(\"not-a-pair\", `\"other\" needs a space with 2 keys, but this space has ${s.keys.length}`);\n const [a, b] = s.keys;\n // A pair has two keys, so `a` and `b` are defined.\n /* v8 ignore next -- @preserve */\n return ok(at.focus === a ? (b ?? at.focus) : (a ?? at.focus));\n }\n case \"offset\": {\n // In a tree space, an offset with one number moves among the siblings in key order. The roots are siblings.\n const parentOf = s.parentOf?.bind(s);\n const childrenOf = s.childrenOf?.bind(s);\n if (parentOf !== undefined && childrenOf !== undefined && m.d.length === 1) {\n const p = parentOf(at.focus);\n const group = p === undefined ? s.keys.filter((k) => parentOf(k) === undefined) : childrenOf(p);\n const i = group.indexOf(at.focus);\n const k = i < 0 ? undefined : group[i + (m.d[0] ?? 0)];\n return k === undefined ? refError(\"out-of-bounds\", `the offset [${m.d.join(\",\")}] from \"${at.focus}\" is outside its siblings`) : ok(k);\n }\n const c = s.coords(at.focus);\n if (c === undefined || c.length !== m.d.length) {\n return refError(\"no-offset\", `an offset of length ${m.d.length} is not valid in a ${s.kind} space`);\n }\n // The lengths are equal, so each index of `c` is also an index of `m.d`.\n /* v8 ignore next -- @preserve */\n const target = c.map((x, i) => x + (m.d[i] ?? 0));\n const k = s.keyAt(target);\n return k === undefined ? refError(\"out-of-bounds\", `the offset [${m.d.join(\",\")}] from \"${at.focus}\" is outside the space`) : ok(k);\n }\n case \"origin\":\n return ok(at.origin);\n case \"parent\": {\n if (s.parentOf === undefined) return refError(\"no-tree\", `\"parent\" needs a tree space, but this space is a ${s.kind}`);\n const p = s.parentOf(at.focus);\n return p === undefined ? refError(\"out-of-bounds\", `the key \"${at.focus}\" is a root, so it has no parent`) : ok(p);\n }\n }\n}\n\n/**\n * This function gives the fixed moves of an address. `values` has the value of the expression of each computed move,\n * in order (NAV.COMPUTED). A key that is not a text, or a position that is not a number, gives `#VALUE!`.\n */\nexport function fixAddr(addr: Addr, values: readonly unknown[], at: Position): Result<readonly FixedMove[]> {\n const out: FixedMove[] = [];\n let next = 0;\n for (const m of addr) {\n if (moveExpr(m) === undefined) {\n out.push(m as FixedMove);\n continue;\n }\n const u = values[next++];\n if (m.t === \"key\" && typeof u === \"string\") out.push({ t: \"key\", key: u });\n else if (m.t === \"index\" && typeof u === \"number\") out.push({ t: \"index\", i: u });\n else return fail(vexError(\"kind-mismatch\", m.t === \"key\" ? `the key of a move is a ${typeof u}, not a text` : `the position of a move is a ${typeof u}, not a number`, at));\n }\n return ok(out);\n}\n\n/** This function applies the moves of an address in order. It gives the key where the address points. */\nexport function resolveAddr(s: Space, at: Position, addr: readonly FixedMove[] | undefined): Result<string> {\n let focus = at.focus;\n for (const m of addr ?? []) {\n const r = applyMove(s, { origin: at.origin, focus }, m);\n if (!r.ok) return r;\n focus = r.value;\n }\n return ok(focus);\n}\n\nconst NEIGHBORS_4: readonly (readonly [number, number])[] = [[-1, 0], [0, -1], [0, 1], [1, 0]];\nconst NEIGHBORS_8: readonly (readonly [number, number])[] = [\n [-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1],\n];\n\n/** The axes of a tree space. */\ntype TreeAxis = \"children\" | \"ancestors\" | \"descendants\" | \"siblings\";\n\nfunction treeTargets(s: Space, at: Position, t: TreeAxis): Result<readonly string[]> {\n const parentOf = s.parentOf?.bind(s);\n const childrenOf = s.childrenOf?.bind(s);\n if (parentOf === undefined || childrenOf === undefined) {\n return fail(vexError(\"no-tree\", `\"${t}\" needs a tree space, but this space is a ${s.kind}`, at));\n }\n switch (t) {\n case \"children\":\n return ok(childrenOf(at.focus));\n case \"ancestors\": {\n const out: string[] = [];\n for (let p = parentOf(at.focus); p !== undefined; p = parentOf(p)) out.push(p);\n return ok(out);\n }\n case \"descendants\": {\n // A depth-first walk with a stack, so a deep tree does not need a deep call stack.\n const out: string[] = [];\n const stack = childrenOf(at.focus).toReversed();\n for (let k = stack.pop(); k !== undefined; k = stack.pop()) {\n out.push(k);\n stack.push(...childrenOf(k).toReversed());\n }\n return ok(out);\n }\n case \"siblings\": {\n const p = parentOf(at.focus);\n const group = p === undefined ? s.keys.filter((k) => parentOf(k) === undefined) : childrenOf(p);\n return ok(group.filter((k) => k !== at.focus));\n }\n }\n}\n\n/**\n * This function gives the targets of a base axis at a focus. It does not handle `where`, because the\n * interpreter must evaluate the test.\n */\nexport function axisTargets(s: Space, at: Position, a: Exclude<Axis, { readonly t: \"where\" }>): Result<readonly string[]> {\n switch (a.t) {\n case \"all\":\n return ok(s.keys);\n case \"others\":\n return ok(s.keys.filter((k) => k !== at.focus));\n case \"other\": {\n const r = applyMove(s, at, { t: \"other\" });\n return r.ok ? ok([r.value]) : r;\n }\n case \"neighbors\": {\n if (s.kind !== \"grid\") return fail(vexError(\"no-grid\", `\"neighbors\" needs a grid space, but this space is a ${s.kind}`, at));\n const deltas = a.n === 4 ? NEIGHBORS_4 : NEIGHBORS_8;\n return ok(\n deltas.flatMap((d) => {\n const r = applyMove(s, at, { t: \"offset\", d });\n return r.ok ? [r.value] : [];\n }),\n );\n }\n case \"children\":\n case \"ancestors\":\n case \"descendants\":\n case \"siblings\":\n return treeTargets(s, at, a.t);\n case \"window\":\n return windowTargets(s, at, a.from, a.to);\n case \"successors\":\n case \"predecessors\":\n case \"reachable\":\n return graphTargets(s, at, a.t);\n case \"reverse\": {\n // The validation of the IR keeps a base axis inside reverse: not where, reverse or table.\n const r = axisTargets(s, at, a.axis as Exclude<Axis, { readonly t: \"where\" }>);\n return r.ok ? ok(r.value.toReversed()) : r;\n }\n case \"table\":\n // The evaluator gives the axis table the space of its table. Here, without the tables, it has no targets.\n return fail(vexError(\"no-table\", `the axis \"table\" needs the tables of the evaluation, and \"${a.name}\" is not one of them`, at));\n case \"list\":\n // The evaluator gives the targets of the axis list from the value of its expression. A space alone has no list.\n return fail(vexError(\"bad-expression\", 'the axis \"list\" needs the evaluator, which gives the value of its list', at));\n }\n}\n\n/**\n * This function gives the targets of an axis of a graph. `reachable` has each key that a path of one or more edges\n * reaches from the focus, once, in the order of a breadth-first search. The focus is not a target of `reachable`.\n */\nfunction graphTargets(s: Space, at: Position, t: \"successors\" | \"predecessors\" | \"reachable\"): Result<readonly string[]> {\n const successorsOf = s.successorsOf?.bind(s);\n const predecessorsOf = s.predecessorsOf?.bind(s);\n if (successorsOf === undefined || predecessorsOf === undefined) {\n return fail(vexError(\"no-graph\", `\"${t}\" needs a graph space or a tree space, but this space is a ${s.kind}`, at));\n }\n if (t === \"successors\") return ok(successorsOf(at.focus));\n if (t === \"predecessors\") return ok(predecessorsOf(at.focus));\n // A queue, not recursion, so a long path does not need a deep call stack. A loop over an array also reads the\n // keys that the loop adds to it.\n const seen = new Set<string>([at.focus]);\n const queue: string[] = [at.focus];\n for (const k of queue) {\n for (const next of successorsOf(k)) {\n if (seen.has(next)) continue;\n seen.add(next);\n queue.push(next);\n }\n }\n return ok(queue.slice(1));\n}\n\n/**\n * This function gives the targets of the axis `window(from, to)`: the keys of the moves `offset(d)` for each `d`\n * from `from` to `to`, in order. An offset outside the space has no target. The axis needs an array space or a tree\n * space, where an offset has one number.\n */\nfunction windowTargets(s: Space, at: Position, from: number, to: number): Result<readonly string[]> {\n const tree = s.parentOf !== undefined && s.childrenOf !== undefined;\n if (!tree && s.coords(at.focus)?.length !== 1) {\n return fail(vexError(\"no-offset\", `\"window\" needs an array space or a tree space, but this space is a ${s.kind}`, at));\n }\n // An offset larger than the number of keys has no target, so the loop stays in the size of the space.\n const out: string[] = [];\n for (let d = Math.max(from, -s.keys.length); d <= Math.min(to, s.keys.length); d++) {\n const r = applyMove(s, at, { t: \"offset\", d: [d] });\n if (r.ok) out.push(r.value);\n }\n return ok(out);\n}\n","/**\n * Domains. A domain tells which values belong to it and which ops it has. The domain object owns this data.\n * Vex does not write to the prototypes of domain classes, and an import has no side effects.\n */\n\n/** An algebraic law that an op claims. `@mark1russell7/vex-testkit` checks each claim with property tests. */\nexport type Law = \"commutative\" | \"associative\" | \"idempotent\";\n\n/** The kind of a parameter. The interpreter checks the arguments of an op that declares its parameters. */\nexport type ParamKind = \"domain\" | \"number\" | \"boolean\" | \"string\" | \"any\";\n\n/**\n * The kind of the result of an op. It is a kind of a parameter, or `domain:Name` for a value of the domain `Name`. It is\n * `list:Kind` for a `vex.list` with items of a primitive type.\n */\nexport type ReturnKind = ParamKind | `domain:${string}` | `list:${PrimitiveKind}`;\n\n/**\n * How the size of one argument adds to the size of the result of an op (LOOP.SIZE.OPS). The size of a value counts the\n * texts, the fields, the keys and the items in it.\n *\n * - `0`: the argument does not add to the size.\n * - `1`: the size of the argument adds one time.\n * - `\"scaled\"`: the size of the argument adds a fixed number of times, for example two times.\n * - `\"many\"`: the size of the argument adds more than one time.\n * - `\"unbounded\"`: the size of the result has no bound in the size of the argument.\n * - `\"text\"`: the size adds one time for a text, and a fixed number of times for another value, as its JSON text.\n * - `\"copies\"`: the size adds one time for each copy. The first argument is the number of the copies.\n * - `\"each\"`: the size adds one time for each item of the first argument.\n * - `\"number\"`: the argument is a number that sets a count. A literal number gives that count, and another number\n * gives a fixed bound.\n * - `\"limit\"`: the size adds one time for each item that the literal number at the position `limit` keeps. Each item\n * adds a key with a fixed bound. Without a literal number, this use is the same as `\"many\"`.\n */\nexport type SizeUse = 0 | 1 | \"scaled\" | \"many\" | \"unbounded\" | \"text\" | \"copies\" | \"each\" | \"number\" | \"limit\";\n\n/**\n * A measure of a value for the check of sizes (LOOP.SIZE.OPS). `size` is the size of the value, and `count` is the\n * number of its items. `inner` is the sum of the counts of the values of its items. `item` is the size of its largest\n * item. The items of a record are its fields, and a text is its own item. `part` is the largest `item` of its items. It is\n * not larger than `item`.\n */\nexport type SizeMeasure = \"size\" | \"count\" | \"inner\" | \"item\" | \"part\";\n\n/** One term of a size rule: a use of the same measure of the argument, or a use of the measure that the pair names. */\nexport type SizeTerm = SizeUse | readonly [use: SizeUse, of: SizeMeasure];\n\n/**\n * The size rule of an op: how the measures of its result follow from its arguments (LOOP.SIZE.OPS). The check of sizes\n * reads it in the steps of `fold` and `iterate` (LOOP.SIZE).\n *\n * - `\"scalar\"`: the result is a number or a boolean.\n * - `\"fixed\"`: the result has a size with a fixed bound, for example a 2D vector.\n * - `\"reduce\"`: the rule of the list op `reduce`. The op that its second argument names gives the size.\n * - A record: `SizeTerms`.\n */\nexport type SizeRule = \"scalar\" | \"fixed\" | \"reduce\" | SizeTerms;\n\n/**\n * The size rule of an op as data (LOOP.SIZE.OPS). `size`, `count`, `inner`, `item` and `part` have one term for each\n * argument. `rest` is the use of the arguments after them, and its default is `\"many\"`. Without `count`, `inner` or `item`,\n * that measure of the result is its size. Without `part`, the largest part of the result is its largest item. The terms of\n * `item` and `part` give the largest bound of the arguments, because the largest item comes from one argument. A literal\n * number at the position `limit` sets the count. With `keys: \"position\"`, the items get their positions as new keys. With\n * `constant: true`, the result can also hold a part with a fixed size. With `union: true`, the result holds each key of\n * its arguments one time, so the bound of the result is the largest bound of the arguments.\n *\n * `byParts` is a second rule for a result that is a part of an argument, or that holds a fixed number of its items. The\n * second reading of the check uses this rule (LOOP.SIZE.READINGS). A rule with `limit` keeps the first rule when the limit\n * is not a literal number or when a key can be long.\n */\nexport interface SizeTerms {\n readonly size: readonly SizeTerm[];\n readonly count?: readonly SizeTerm[];\n readonly inner?: readonly SizeTerm[];\n readonly item?: readonly SizeTerm[];\n readonly part?: readonly SizeTerm[];\n readonly rest?: SizeUse;\n readonly limit?: number;\n readonly keys?: \"position\";\n readonly constant?: true;\n readonly union?: true;\n readonly byParts?: SizeTerms;\n}\n\n/** The description of one op of a domain. */\nexport interface OpSpec<D = never> {\n /**\n * The implementation, for an op that is not a method of the value (static-land style). The first argument\n * is the receiver. Without `fn`, the interpreter calls the method of the receiver with the same name.\n */\n readonly fn?: (self: D, ...args: never[]) => unknown;\n /** The laws that the op claims. */\n readonly laws?: readonly Law[];\n /** The identity element of the op, for reductions over an empty list. */\n readonly identity?: () => D;\n /** Scalar lifting: `true` lifts each number argument with `fromScalar`. An array sets it for each argument. */\n readonly liftScalar?: boolean | readonly boolean[];\n /** The kinds of the parameters after the receiver. When set, the interpreter checks the arguments. */\n readonly params?: readonly ParamKind[];\n /**\n * The kind of the result. It is `domain` for a value of this domain, or `domain:Name` for a value of the domain `Name`.\n * It is `list:Kind` for a `vex.list` with items of that primitive type (KIND.RETURNS.LIST). A compiler reads it to know\n * the kinds of the values of a program (KIND.RETURNS). The interpreter does not check it, and the law checker of the\n * test kit does.\n */\n readonly returns?: ReturnKind;\n /**\n * The size rule of the op (LOOP.SIZE.OPS). Without it, an op whose result is a number or a boolean has the rule\n * `\"scalar\"`. An op of a domain with `size: \"fixed\"` has the rule `\"fixed\"`. Another op has no rule, so a step of a\n * loop cannot use its result in the size of a list name (LOOP.SIZE).\n */\n readonly size?: SizeRule;\n /**\n * This field gives the direction of the result of the op for each argument, with the receiver first (FIX.OPS). `up`\n * means that the result does not fall as the argument rises. `down` means that the result does not rise. An op without\n * it cannot take a value that reads `last`, and an argument without a direction must not read `last`.\n */\n readonly monotone?: readonly Monotone[];\n}\n\n/** A direction of an op: the result follows the argument (`up`) or moves against it (`down`). */\nexport type Monotone = \"up\" | \"down\";\n\n/**\n * The form of a domain in a standalone module (COMPILE.MODULE.FORM). A module has no import, so it cannot hold a value of\n * a class. Each part replaces the part of the domain with the same name, only in a module. A compiler copies the text of\n * each function, so a function reads only its parameters.\n */\nexport interface ModuleForm {\n /** The test of a value in a module. */\n readonly is?: (u: unknown) => boolean;\n /** The scalar lift in a module. */\n readonly fromScalar?: (n: number) => unknown;\n /** Some values of the module form. A compiler checks each copy with them. */\n readonly samples?: () => readonly unknown[];\n /**\n * The plain data of a literal of the program, or `undefined` for a value of another domain. This function runs in the\n * compiler, not in a module, so it can read a class.\n */\n readonly literal?: (value: unknown) => Readonly<Record<string, unknown>> | undefined;\n /** The parts of each op in a module. */\n readonly ops?: Readonly<Record<string, { readonly fn?: (self: never, ...args: never[]) => unknown; readonly identity?: () => unknown; readonly returns?: ReturnKind }>>;\n}\n\n/** A JavaScript type of primitive values that a domain can accept. */\nexport type PrimitiveKind = \"number\" | \"string\" | \"boolean\";\n\n/** This function gives the kind of the items of a result of the kind `list:Kind`, or `undefined` for another kind. */\nexport const listItemKind = (r: ReturnKind | undefined): PrimitiveKind | undefined => (r?.startsWith(\"list:\") === true ? (r.slice(\"list:\".length) as PrimitiveKind) : undefined);\n\n/** The type of an op that lifts number arguments. Use it to type the ops of a domain under `isolatedDeclarations`. */\nexport type LiftedOp<D> = OpSpec<D> & { readonly liftScalar: true };\n\n/** The type of an op with an implementation function `F`. */\nexport type FnOp<D, F extends (self: D, ...args: never[]) => unknown> = OpSpec<D> & { readonly fn: F };\n\n/**\n * The type of an op table: each name in `Names` is an op, and each name in `Lifted` lifts number arguments.\n * Use it to type the ops of a domain under `isolatedDeclarations`.\n */\nexport type OpTable<D, Names extends string, Lifted extends string = never> = {\n readonly [N in Names]: N extends Lifted ? LiftedOp<D> : OpSpec<D>;\n};\n\n/** The description of a domain, as a caller gives it to `defineDomain`. */\nexport interface DomainSpec<Name extends string, D, Ops extends Readonly<Record<string, OpSpec<D>>>> {\n /** The name of the domain. */\n readonly name: Name;\n /** The runtime test for the values of the domain. It must not give false positives. */\n readonly is: (u: unknown) => u is D;\n /**\n * The JavaScript type of the values of the domain, if `is` accepts each value of that type and no other value\n * (KIND.PRIMITIVE). A compiler then finds the op of such a value before a run.\n */\n readonly primitive?: PrimitiveKind;\n /**\n * The field names of a value, if `is` accepts only plain objects with exactly these fields (KIND.FIELDS). Two domains\n * with different names have no common value, so a compiler finds the domain of such a value before a run.\n */\n readonly fields?: readonly string[];\n /** The ops of the domain, with their metadata. */\n readonly ops: Ops;\n /**\n * With `\"fixed\"`, each value of the domain has a size with a fixed bound, for example a 2D vector. Then each op of the\n * domain has the size rule `\"fixed\"` or `\"scalar\"`, unless the op has its own rule (LOOP.SIZE.OPS).\n */\n readonly size?: \"fixed\";\n /** With `\"all\"`, each method of a value is an op, also without an entry in `ops`. The default is `\"declared\"`. */\n readonly methods?: \"declared\" | \"all\";\n /** The scalar lift: it makes a domain value from a number. */\n readonly fromScalar?: (n: number) => D;\n /** A check of the values that ops give. A value that fails the check gives the error `#NUM!`. */\n readonly valid?: (d: D) => boolean;\n /** A short text for a value, for traces and the site. */\n readonly show?: (d: D) => string;\n /** The JSON form of a value, for literals in serialized programs. */\n readonly encode?: (d: D) => unknown;\n /** The value of a JSON form that `encode` made. */\n readonly decode?: (json: unknown) => D;\n /**\n * Some values of the domain. A compiler gives them to an op and to its copy in a module: the two must give the same\n * results (KIND.DOMAIN).\n */\n readonly samples?: () => readonly D[];\n /** The form of the domain in a standalone module, for a domain with values of a class (COMPILE.MODULE.FORM). */\n readonly moduleForm?: ModuleForm;\n}\n\n/** A domain. Make one with `defineDomain`. */\nexport interface Domain<Name extends string = string, D = unknown, Ops extends Readonly<Record<string, OpSpec<D>>> = Readonly<Record<string, OpSpec<D>>>>\n extends DomainSpec<Name, D, Ops> {\n readonly kind: \"vex.domain\";\n}\n\n/** A domain with any value type. The interpreter uses this type. */\n// oxlint-disable-next-line typescript/no-explicit-any -- a list of domains with different value types needs `any`: `fn` is contravariant in the value type.\nexport type AnyDomain = Domain<string, any, Readonly<Record<string, OpSpec<any>>>>;\n\n/** This function makes a domain. The result is frozen. */\nexport function defineDomain<const Name extends string, D, const Ops extends Readonly<Record<string, OpSpec<D>>>>(\n spec: DomainSpec<Name, D, Ops>,\n): Domain<Name, D, Ops> {\n return Object.freeze({ ...spec, kind: \"vex.domain\" as const });\n}\n\nconst FORBIDDEN = new Set([\"constructor\", \"__proto__\", \"prototype\", \"__defineGetter__\", \"__defineSetter__\", \"__lookupGetter__\", \"__lookupSetter__\"]);\n\n/** This function tells if a name can be an op name. */\nexport const isOpName = (name: string): boolean => name.length > 0 && !FORBIDDEN.has(name);\n\n/**\n * This function finds a method on a value: an own function property, or a function on the prototype chain.\n * It stops at `Object.prototype` and `Function.prototype`, so inherited members (for example `toString`) are not ops.\n */\nexport function findMethod(self: unknown, name: string): ((...args: unknown[]) => unknown) | undefined {\n if (!isOpName(name)) return undefined;\n // A primitive has no own methods. The loop below stops at null, so null needs no test here.\n if (typeof self !== \"object\" && typeof self !== \"function\") return undefined;\n let o: object | null = self;\n while (o !== null && o !== Object.prototype && o !== Function.prototype) {\n const d = Object.getOwnPropertyDescriptor(o, name);\n if (d !== undefined) {\n return typeof d.value === \"function\" ? (d.value as (...args: unknown[]) => unknown) : undefined;\n }\n o = Object.getPrototypeOf(o) as object | null;\n }\n return undefined;\n}\n\n/** An op that the interpreter found for a receiver. */\nexport interface ResolvedOp {\n readonly domain: AnyDomain;\n readonly spec: OpSpec<unknown>;\n readonly call: (args: readonly unknown[]) => unknown;\n}\n\nconst EMPTY_SPEC: OpSpec<unknown> = Object.freeze({});\n\n/** This function finds the op `name` for `self` in one domain. It gives `undefined` if the domain does not have it. */\nexport function resolveOp(domain: AnyDomain, self: unknown, name: string): ResolvedOp | undefined {\n if (!isOpName(name)) return undefined;\n const declared = Object.hasOwn(domain.ops, name) ? (domain.ops[name] as OpSpec<unknown>) : undefined;\n if (declared?.fn !== undefined) {\n const fn = declared.fn as (self: unknown, ...args: unknown[]) => unknown;\n return { domain, spec: declared, call: (args) => fn(self, ...args) };\n }\n if (declared === undefined && domain.methods !== \"all\") return undefined;\n const method = findMethod(self, name);\n if (method === undefined) return undefined;\n return { domain, spec: declared ?? EMPTY_SPEC, call: (args) => method.apply(self, [...args]) };\n}\n\n/** This function gives the domain of a value: the first domain whose `is` accepts it. */\nexport function domainOf(domains: readonly AnyDomain[], value: unknown): AnyDomain | undefined {\n return domains.find((d) => d.is(value));\n}\n\n/** This function tells if the `liftScalar` setting lifts the argument at `index`. */\nexport const liftsAt = (lift: OpSpec<unknown>[\"liftScalar\"], index: number): boolean =>\n lift === true || (Array.isArray(lift) && lift[index] === true);\n","/**\n * Arrays as lists (LIST.ARRAY). A JSON array of a field or of a name reads as a list where a list op or the axis `list`\n * needs a list. The package index does not export this module: `evaluate.ts` and `kernel.ts` use it.\n */\nimport type { VexError } from \"./errors.ts\";\nimport { MAX_ITERATIONS } from \"./ir.ts\";\nimport { isVexList, vexList, type ListItem, type VexList } from \"./list.ts\";\nimport { fail, ok } from \"./result.ts\";\n\n/**\n * This function gives the list of an array (LIST.ARRAY). The key of each item is its position, from \"0\". A position\n * without a value, or with `null`, gives an error item from `missing`, as a missing field does (REF.MISSING).\n */\nexport function listOfArray(array: readonly unknown[], missing: (message: string) => VexError): VexList {\n const items: ListItem[] = [];\n // A loop over the positions, not `map`, so a hole of a sparse array is an error item too.\n for (let i = 0; i < array.length; i++) {\n const x = array[i];\n items.push({ key: String(i), result: x === undefined || x === null ? fail(missing(`the array has no value at the position ${String(i)}`)) : ok(x) });\n }\n return vexList(items);\n}\n\n/** This function gives a list, the list of an array, or `undefined` for another value (LIST.ARRAY). */\nexport const asList = (u: unknown, missing: (message: string) => VexError): VexList | undefined => (isVexList(u) ? u : Array.isArray(u) ? listOfArray(u, missing) : undefined);\n\n/**\n * This function tells if a value is a count of `fill`: a whole number from 0 to the limit of `iterate`, 100000\n * (LIST.FILL). Thus a list of `fill` is not larger than the steps of a loop.\n */\nexport const isFillCount = (n: unknown): n is number => Number.isSafeInteger(n) && (n as number) >= 0 && (n as number) <= MAX_ITERATIONS;\n\n/** This function gives the list of `fill` (LIST.FILL): `n` items with the value `value`, and the keys \"0\" to \"n - 1\". */\nexport const fillList = (n: number, value: unknown): VexList => vexList(Array.from({ length: n }, (_x, i): ListItem => ({ key: String(i), result: ok(value) })));\n\n/** This function tells if a value can be the value of `indexOf`: a number, a text or a boolean (LIST.INDEXOF). */\nexport const isIndexValue = (u: unknown): u is number | string | boolean => typeof u === \"number\" || typeof u === \"string\" || typeof u === \"boolean\";\n","/**\n * The JSON form of the values of a literal. `serialize`, `parse`, `toDocument` and `fromDocument` share it. The package\n * index does not export this module.\n */\nimport type { AnyDomain } from \"./domain.ts\";\nimport { vexError } from \"./errors.ts\";\nimport { fail, ok, type Result } from \"./result.ts\";\n\n/**\n * The JSON form of the values in a literal. JSON data stays as it is, with three exceptions. Each exception is a record\n * with the key `$vex`:\n *\n * - `{ \"$vex\": \"domain\", \"domain\": name, \"value\": v }`: a value of a domain, with the `encode` of the domain.\n * - `{ \"$vex\": \"number\", \"value\": \"-0\" }`: a number that JSON has no text for: `-0`, `NaN`, `Infinity` or `-Infinity`.\n * - `{ \"$vex\": \"escape\", \"value\": record }`: a record of the data that has the key `$vex` itself (IR.JSON.ESCAPE).\n *\n * A record with the key `$vex` and another form stays data, so a file from an older version reads as before.\n *\n * The functions walk the tree of the expression, so only the value of a literal gets this form. A field of a literal\n * that looks like an expression stays data. The data of an extension is plain JSON, as before. A document has the same\n * form for the value of a literal (DOC.LITERAL).\n */\ntype Encoded =\n | { readonly $vex: \"domain\"; readonly domain: string; readonly value: unknown }\n | { readonly $vex: \"number\"; readonly value: \"-0\" | \"NaN\" | \"Infinity\" | \"-Infinity\" }\n | { readonly $vex: \"escape\"; readonly value: Readonly<Record<string, unknown>> };\n\n/** This function tells if a value is a record: an object that is not an array. */\nexport const isRecord = (u: unknown): u is Readonly<Record<string, unknown>> => typeof u === \"object\" && u !== null && !Array.isArray(u);\n\nconst isPlainRecord = (u: unknown): u is Readonly<Record<string, unknown>> => {\n if (!isRecord(u)) return false;\n const proto: unknown = Object.getPrototypeOf(u);\n return proto === Object.prototype || proto === null;\n};\n\n/** This function gives the JSON form of a value, or the reason why the value has no JSON form. */\nexport function encodeValue(u: unknown, domains: readonly AnyDomain[]): Result<unknown> {\n if (u === null || typeof u === \"string\" || typeof u === \"boolean\") return ok(u);\n if (typeof u === \"number\") {\n if (Object.is(u, -0)) return ok({ $vex: \"number\", value: \"-0\" } satisfies Encoded);\n // Stryker disable next-line EqualityOperator: here u is an infinity, so u > 0 and u >= 0 are the same test\n return Number.isFinite(u) ? ok(u) : ok({ $vex: \"number\", value: Number.isNaN(u) ? \"NaN\" : u > 0 ? \"Infinity\" : \"-Infinity\" } satisfies Encoded);\n }\n if (Array.isArray(u)) {\n const out: unknown[] = [];\n for (const x of u) {\n const r = encodeValue(x, domains);\n if (!r.ok) return r;\n out.push(r.value);\n }\n return ok(out);\n }\n if (isPlainRecord(u)) {\n const entries: [string, unknown][] = [];\n for (const [k, x] of Object.entries(u)) {\n const r = encodeValue(x, domains);\n if (!r.ok) return r;\n entries.push([k, r.value]);\n }\n // Object.fromEntries gives an own field for each key, also for \"__proto__\" (V-062).\n const out = Object.fromEntries(entries);\n return ok(Object.hasOwn(u, \"$vex\") ? ({ $vex: \"escape\", value: out } satisfies Encoded) : out);\n }\n // A plain array or record stays data. Another object is a value of a domain, or it has no JSON form.\n const d = domains.find((dom) => dom.encode !== undefined && dom.is(u));\n if (d?.encode !== undefined) return ok({ $vex: \"domain\", domain: d.name, value: d.encode(u) } satisfies Encoded);\n return fail(vexError(\"bad-expression\", \"a literal value is not JSON data and no domain encodes it\"));\n}\n\nconst NUMBERS: Readonly<Record<string, number>> = { \"-0\": -0, NaN: Number.NaN, Infinity: Number.POSITIVE_INFINITY, \"-Infinity\": Number.NEGATIVE_INFINITY };\n\n/** This function reads a value from its JSON form. */\nexport function decodeValue(u: unknown, domains: readonly AnyDomain[]): Result<unknown> {\n if (Array.isArray(u)) {\n const out: unknown[] = [];\n for (const x of u) {\n const r = decodeValue(x, domains);\n if (!r.ok) return r;\n out.push(r.value);\n }\n return ok(out);\n }\n if (!isRecord(u)) return ok(u);\n const fields = (record: Readonly<Record<string, unknown>>): Result<unknown> => {\n const entries: [string, unknown][] = [];\n for (const [k, x] of Object.entries(record)) {\n const r = decodeValue(x, domains);\n if (!r.ok) return r;\n entries.push([k, r.value]);\n }\n // A key \"__proto__\" of the data is an own field too (V-062).\n return ok(Object.fromEntries(entries));\n };\n // A record without the key $vex matches none of the forms below, so it stays data too.\n const kind = u[\"$vex\"];\n if (kind === \"escape\" && isRecord(u[\"value\"])) return fields(u[\"value\"]);\n if (kind === \"number\" && typeof u[\"value\"] === \"string\" && Object.hasOwn(NUMBERS, u[\"value\"])) return ok(NUMBERS[u[\"value\"]]);\n if (kind === \"domain\" && typeof u[\"domain\"] === \"string\") {\n const name = u[\"domain\"];\n const d = domains.find((dom) => dom.name === name);\n if (d?.decode === undefined) return fail(vexError(\"bad-expression\", `no domain \"${name}\" decodes a literal`));\n return ok(d.decode(u[\"value\"]));\n }\n // A form that this version does not know stays data, so a file from an older version reads as before.\n return fields(u);\n}\n","import { isDepthError, vexError, type ErrorDetails, type VexError } from \"./errors.ts\";\n\n/** This function gives the error that decides for a list of errors: `#DEPTH!`, or else the first (EVAL.DEPTH). */\nexport const worstError = (errors: readonly VexError[]): VexError | undefined => errors.find(isDepthError) ?? errors[0];\n\n/** This function gives the message of a data limit above the cap (ITERATE.LIMIT.ERROR). */\nexport const overLimitMessage = (count: number): string => `the data limit of \"iterate\" is ${String(count)}, above the cap of 100000`;\n\n/**\n * This function gives the error of a data limit that is not valid, with its cause (ITERATE.LIMIT.ERROR). An error of the\n * run stays as it is: the engine failed or a cycle of cells stopped, not the limit.\n */\nexport const limitError = (cause: VexError, details: Omit<ErrorDetails, \"causes\"> = {}): VexError =>\n isDepthError(cause) || cause.kind === \"cycle\" ? cause : vexError(\"limit\", 'the data limit of \"iterate\" is not valid', { ...details, causes: [cause] });\n","/**\n * These are the rules of a fixed-point column that the closure compiler and the kernel share (FIX.ROUNDS, FIX.JOIN,\n * FIX.LIMIT). They are the limit of the rounds, the kinds of the values of a row and the join of a row. The package\n * index exports the rules that the compiler needs too (COMPILE.FIX).\n */\nimport { errorText, type ErrorText } from \"./error-text.ts\";\nimport { MAX_ITERATIONS, type FixJoin } from \"./ir.ts\";\n\n/**\n * This function gives the largest number of rounds of a column of `rows` rows. A boolean column changes at least one row\n * in each round before the last, and a row changes one time. A path has fewer rows than the column, so a number\n * column stops in this bound when its steps follow paths (FIX.LIMIT).\n */\nexport const fixRounds = (rows: number): number => Math.min(rows + 1, MAX_ITERATIONS);\n\n/** This function gives the kind of the values of a join. */\nexport const joinKind = (join: FixJoin): \"boolean\" | \"number\" => (join === \"or\" || join === \"and\" ? \"boolean\" : \"number\");\n\n/** This function gives the reason that a value cannot be a value of a row, or `undefined` for a good value (FIX.KIND). */\nexport function fixValueError(name: string, join: FixJoin, value: unknown): ErrorText | undefined {\n const kind = joinKind(join);\n if (typeof value !== kind) return errorText.fixKind(name, join, kind, value);\n return kind === \"boolean\" || Number.isFinite(value) ? undefined : errorText.fixNumber(name, value);\n}\n\n/**\n * This function gives the error that stands for the failed rows of a round, or `undefined` when `#ARGS` must collect them\n * (FIX.ERROR). `#DEPTH!` wins. `#CYCLE!` comes next, so a cell on a cycle reports the cycle (SHEET.CYCLE).\n */\nexport function worstRow<E extends { readonly code: string }>(errors: readonly E[]): E | undefined {\n return errors.find((x) => x.code === \"#DEPTH!\") ?? errors.find((x) => x.code === \"#CYCLE!\") ?? (errors.length === 1 ? errors[0] : undefined);\n}\n\n/** This function joins the next value of a row to its old value (FIX.JOIN). The values have the kind of the join. */\nexport function joinValues(join: FixJoin, old: unknown, next: unknown): unknown {\n switch (join) {\n case \"or\":\n return old === true || next === true;\n case \"and\":\n return old === true && next === true;\n case \"max\":\n return Math.max(old as number, next as number);\n case \"min\":\n return Math.min(old as number, next as number);\n }\n}\n","/**\n * The comparison of the values of Vex for `agree` of the kernel (EVAL.AGREE), and the test of a Vex error. The package\n * index does not export this module: `kernel.ts` and `plan.ts` use it.\n */\nimport { sameValue } from \"@mark1russell7/coeval\";\nimport type { VexError } from \"./errors.ts\";\n\n/** This function tells if a value is a Vex error: it has a code, a kind, a message and a path. */\nexport function isVexError(u: unknown): u is VexError {\n const e = u as Partial<VexError> | null | undefined;\n return typeof e?.code === \"string\" && typeof e.kind === \"string\" && typeof e.message === \"string\" && Array.isArray(e.path);\n}\n\n/** This function tells if a value is a value of a class: an object that is not a plain record and not an array. */\nfunction isInstance(u: unknown): u is object {\n if (typeof u !== \"object\" || u === null || Array.isArray(u)) return false;\n const proto: unknown = Object.getPrototypeOf(u);\n return proto !== Object.prototype && proto !== null;\n}\n\n/**\n * This function compares two values of Vex for `agree`. Two Vex errors agree when they have the same code, because\n * only the closure compiler gives the location of an error (EVAL.LOCATION). Two values of one class agree when their\n * fields agree, for example two values of a domain from two decodes of a literal. The rules of `sameValue` compare\n * each other pair.\n */\nexport function sameVex(a: unknown, b: unknown): boolean | undefined {\n if (isVexError(a) && isVexError(b)) return a.code === b.code;\n if (!isInstance(a) || !isInstance(b)) return undefined;\n return Object.getPrototypeOf(a) === Object.getPrototypeOf(b) && sameValue({ ...a }, { ...b }, sameVex);\n}\n","/**\n * Vex in the kernel of coeval (decision D13 of coeval, and decision D13 of Vex in `docs/REVIEW.md`). This module gives\n * the contracts of the kinds of Vex as data, and a machine of the kernel that evaluates the documents of Vex.\n *\n * - The static kit of the kernel checks a document by these contracts (`fromDocument`, DOC.ERROR) and finds its\n * references (`deps`, DEPS.READS).\n * - The machine is the reference tier of Vex. The closure compiler and the loop compiler give its results\n * (EVAL.REFERENCE). It evaluates the shared constructs with the formula kit of the kernel, and a profile gives the\n * rules of Vex. Vex adds only what is its own: the moves, the axes, the loops and the dispatch on the domains.\n */\nimport {\n type Context,\n type Definitions,\n type EvalError,\n type EvalFn,\n type Failed,\n type ExtFn,\n type FormulaProfile,\n type HostThing,\n type Key,\n type Kind,\n type LazyOp,\n type Machine,\n type PartShape,\n type Part,\n type Result as Outcome,\n type Walker,\n type World,\n Failure,\n Held,\n STD_EXT,\n THING,\n formulaDefinitions,\n formulaEvaluators,\n ok,\n} from \"@mark1russell7/coeval\";\nimport { asList, fillList, isFillCount, isIndexValue, listOfArray } from \"./array-list.ts\";\nimport { decodeValue } from \"./codec.ts\";\nimport type { AnyDomain } from \"./domain.ts\";\nimport { vexError, type ErrorCode, type ErrorDetails, type ErrorKind, type VexError } from \"./errors.ts\";\nimport { limitError, overLimitMessage, worstError } from \"./limit-error.ts\";\nimport type { CompileOptions } from \"./evaluate.ts\";\nimport { errorText } from \"./error-text.ts\";\nimport { fixRounds, fixValueError, joinValues, worstRow } from \"./fix.ts\";\nimport { MAX_ITERATIONS, type Axis, type FixJoin, type FixedMove } from \"./ir.ts\";\nimport { isVexList, LIST_OPS, vexList, type ListItem } from \"./list.ts\";\nimport { fail as vexFail, ok as vexOk, type Result } from \"./result.ts\";\nimport { isVexError } from \"./same.ts\";\nimport { applyMove, axisTargets, type Space } from \"./space.ts\";\n\n// ---------------------------------------------------------------- the contracts\n\n/** The kinds of the terms of Vex. A part in the position of a term has one of these kinds (DOC.TERM). */\nexport const TERM_KINDS: readonly (readonly string[])[] = [[\"lit\"], [\"ref\"], [\"record\"], [\"let\"], [\"call\"], [\"each\"], [\"fold\"], [\"iterate\"], [\"fix\"], [\"last\"], [\"ops\"], [\"ext\"]];\n\n/** A term: an envelope of a term kind, or a bare value, which is a literal. */\nconst TERM: PartShape = { shape: \"term\", of: \"lit\", kinds: TERM_KINDS };\nconst TERMS: PartShape = { shape: \"list\", item: TERM };\nconst NAMES: PartShape = { shape: \"map\", item: TERM };\nconst AXIS: PartShape = { shape: \"term\", kinds: [[\"axes\"]] };\n/** The address of `each` and `fold`: a reference that gives a key of the space, not a value (DOC.ADDRESS). */\nconst ADDRESS: PartShape = { shape: \"term\", kinds: [[\"ref\"]], address: true };\nconst NO_VALUE: PartShape = { shape: \"one\", values: [null] };\n/** The limit of `iterate`: a bare whole number, or the size of an axis (ITERATE.LIMIT.DATA). */\nconst LIMIT: PartShape = { shape: \"term\", of: \"limit\", kinds: [[\"limit\"], [\"size\"]] };\n\n/** This function gives the shape of a record with these fields and no other fields (DOC.CONSTRUCT). */\nconst closed = (fields: Readonly<Record<string, PartShape>>, required: readonly string[]): PartShape => ({ shape: \"record\", fields, required, closed: true });\n\n/** The axes without parameters. */\nconst PLAIN_AXES = [\"all\", \"others\", \"other\", \"children\", \"ancestors\", \"descendants\", \"siblings\", \"successors\", \"predecessors\", \"reachable\"] as const;\n\n/** This function gives the kind of an axis with these parameters (DOC.AXIS). */\nconst axisKind = (fields: Readonly<Record<string, PartShape>>): Kind => ({ verbs: { eval: \"vex.axis\" }, parts: closed(fields, Object.keys(fields)), summary: \"An axis of Vex: the targets of a body.\" });\n\n/** This function gives the kind of a move. Its document is a step of a path, and a computed key is its part (DOC.MOVE). */\nconst move = (walker: string, parts: PartShape): Kind => ({ verbs: { eval: \"formula.step\", step: walker }, parts, summary: \"A move of Vex: a step to another key of the space.\" });\n\n/** The scope of a loop: the names of `init`, for the steps, the test `until` and the result (LOOP.NAMES). */\nconst LOOP_SCOPE = [{ names: { keysAt: [\"init\"] }, in: [[\"step\", \"*\"], [\"until\"], [\"result\"]] }] as const;\n\n/** The names of the items of a loop over the axis `list`: one or two distinct texts (AXIS.LIST.SCOPE). */\nconst ITEM_NAMES: PartShape = { shape: \"list\", item: { shape: \"text\" }, distinct: true };\n\n/**\n * This function gives the world of Vex. The module uses it one time, and the annotation `__PURE__` lets a bundler\n * remove the world from a program that does not use it.\n */\nfunction worldOfVex(): World {\n /** A binding of a `let`: a term, or a function (FN.BIND). */\n const BIND: PartShape = { shape: \"term\", of: \"lit\", kinds: [...TERM_KINDS, [\"fn\"]] };\n /** The axes that `reverse` can hold: each axis but `where`, `reverse` and `table` (AXIS.REVERSE). */\n const BASE_AXES: readonly string[] = [...PLAIN_AXES, \"neighbors\", \"window\", \"list\"];\n return {\n kinds: {\n lit: { verbs: { eval: \"vex.lit\" }, summary: \"A literal: its value in the JSON form of IR.JSON.\" },\n ref: { verbs: { eval: \"formula.ref\" }, parts: { shape: \"deep\" }, summary: \"A reference: the fields of self after its moves, or a name.\" },\n record: { verbs: { eval: \"formula.record\" }, parts: NAMES, summary: \"A record of the values of its fields.\" },\n let: {\n verbs: { eval: \"formula.let\" },\n parts: closed({ bind: { shape: \"map\", item: BIND }, body: TERM }, [\"bind\", \"body\"]),\n scope: [{ names: { keysAt: [\"bind\"] }, in: [[\"body\"]] }],\n summary: \"Names for the body. A binding does not see the other bindings.\",\n },\n fn: {\n verbs: { eval: \"vex.fn\" },\n parts: closed({ params: { shape: \"list\", item: { shape: \"text\" }, distinct: true }, body: TERM }, [\"params\", \"body\"]),\n scope: [{ names: { listAt: [\"params\"] }, in: [[\"body\"]] }],\n summary: \"A function of a let. Its body evaluates at the position of each call.\",\n },\n call: { verbs: { eval: \"vex.call\" }, parts: closed({ fn: { shape: \"term\", kinds: [[\"ref\"]] }, args: TERMS }, [\"fn\", \"args\"]), summary: \"A call of a function of a let.\" },\n each: {\n verbs: { eval: \"vex.each\" },\n parts: closed({ axis: AXIS, as: ITEM_NAMES, body: TERM, at: ADDRESS }, [\"axis\", \"body\"]),\n // The names of the items are names of the body only. The test of where does not see them (AXIS.LIST.SCOPE).\n scope: [{ names: { listAt: [\"as\"] }, in: [[\"body\"]] }],\n summary: \"The body at each target of an axis: a list.\",\n },\n fold: {\n verbs: { eval: \"vex.fold\" },\n parts: closed({ axis: AXIS, as: ITEM_NAMES, init: NAMES, step: NAMES, result: TERM, at: ADDRESS }, [\"axis\", \"init\", \"step\", \"result\"]),\n scope: [...LOOP_SCOPE, { names: { listAt: [\"as\"] }, in: [[\"step\", \"*\"]] }],\n summary: \"A step at each target of an axis, in order, and a result.\",\n },\n iterate: {\n verbs: { eval: \"vex.iterate\" },\n parts: closed({ limit: LIMIT, init: NAMES, step: NAMES, until: TERM, result: TERM }, [\"limit\", \"init\", \"step\", \"result\"]),\n scope: LOOP_SCOPE,\n summary: \"Up to limit steps, until a test is true, and a result.\",\n },\n fix: {\n verbs: { eval: \"vex.fix\" },\n parts: closed({ name: { shape: \"text\" }, join: { shape: \"one\", values: [\"or\", \"and\", \"max\", \"min\"] }, init: TERM, step: TERM }, [\"name\", \"join\", \"init\", \"step\"]),\n summary: \"A column: a step at each row in rounds, until no row changes (step B).\",\n },\n last: {\n verbs: { eval: \"vex.last\" },\n parts: { shape: \"text\" },\n summary: \"The value of the focus in the last round of a fix (step B).\",\n },\n limit: {\n verbs: { eval: \"vex.limit\" },\n parts: { shape: \"number\", whole: true, min: 0, max: MAX_ITERATIONS },\n summary: \"The limit of iterate as a whole number: the bare number of step A.\",\n },\n size: {\n verbs: { eval: \"vex.size\" },\n parts: closed({ axis: AXIS }, [\"axis\"]),\n summary: \"The limit of iterate from the data: the number of targets of an axis (step B).\",\n },\n ops: { kinds: {}, fallback: { verbs: { eval: \"formula.op\" }, parts: TERMS, summary: \"An op, applied to the values of its arguments.\" } },\n ext: { kinds: {}, fallback: { verbs: { eval: \"formula.ext\" }, summary: \"An extension: its handler gives the value of its data.\" } },\n axes: {\n kinds: {\n ...Object.fromEntries(PLAIN_AXES.map((name) => [name, axisKind({})])),\n neighbors: axisKind({ n: { shape: \"one\", values: [4, 8] } }),\n window: axisKind({ from: { shape: \"number\" }, to: { shape: \"number\" } }),\n table: axisKind({ name: { shape: \"text\" } }),\n list: axisKind({ list: TERM }),\n reverse: axisKind({ axis: { shape: \"term\", kinds: BASE_AXES.map((name) => [\"axes\", name]) } }),\n where: axisKind({ axis: AXIS, test: TERM }),\n },\n },\n moves: {\n kinds: {\n key: move(\"vex.move.key\", TERM),\n index: move(\"vex.move.index\", TERM),\n offset: move(\"vex.move.offset\", { shape: \"list\", item: { shape: \"number\" } }),\n other: move(\"vex.move.other\", NO_VALUE),\n origin: move(\"vex.move.origin\", NO_VALUE),\n parent: move(\"vex.move.parent\", NO_VALUE),\n },\n },\n },\n defaults: {},\n };\n}\n\n/**\n * The world of Vex: the contract of each kind of a document of Vex, as data. A contract gives the shape of the parts,\n * the data of the fields and the names that the kind binds. The static kit of the kernel reads it.\n */\nexport const VEX_WORLD: World = /* @__PURE__ */ worldOfVex();\n\n/** The deepest nesting of documents that the machine takes. A deeper document gives `#DEPTH!` (DOC.ERROR). */\nexport const MAX_DOCUMENT_DEPTH = 4096;\n\n// ---------------------------------------------------------------- errors\n\n/** The kind of a Vex error for each code of the kernel. Another code is a document that is not valid. */\nconst KIND_OF: Readonly<Partial<Record<string, ErrorKind>>> = {\n \"#REF!\": \"unknown-key\",\n \"#N/A\": \"missing-field\",\n \"#VALUE!\": \"kind-mismatch\",\n \"#NAME?\": \"unbound\",\n \"#NUM!\": \"not-finite\",\n \"#CALC!\": \"threw\",\n \"#ARGS\": \"args\",\n \"#CYCLE!\": \"cycle\",\n \"#DEPTH!\": \"depth\",\n};\n\n/** This function gives the error of the kernel for a Vex error. The Vex error is its cause, so no detail is lost. */\nexport const toKernelError = (e: VexError): EvalError => ({ code: e.code, reason: e.message, cause: e });\n\n/** This function gives the Vex error of an error of the kernel. A code that Vex does not have gives `#VALUE!`. */\nexport function toVexError(e: EvalError): VexError {\n if (isVexError(e.cause)) return e.cause;\n return vexError(KIND_OF[e.code] ?? \"bad-expression\", e.reason, e.cause === undefined ? {} : { thrown: e.cause });\n}\n\n/** This function gives the Vex result of a result of the kernel. */\nexport const toVexResult = (r: Outcome): Result<unknown> => (r.ok ? vexOk(r.value) : vexFail(toVexError(r.error)));\n\n/** This function makes an error of the kernel from a kind of Vex error. */\nconst kernelError = (kind: ErrorKind, message: string, details: ErrorDetails = {}): EvalError => toKernelError(vexError(kind, message, details));\n\n/** This function makes a failed result of the kernel. */\nconst failed = (kind: ErrorKind, message: string): Failed => ({ ok: false, error: kernelError(kind, message) });\n\n/** This function gives the error of a position of an array without a value (LIST.ARRAY). */\nconst missing = (message: string): VexError => vexError(\"missing-field\", message);\n\n/** This function stops host code with an error of the kernel. The kernel catches the `Failure` and gives its error. */\nconst stop = (kind: ErrorKind, message: string): never => {\n throw new Failure(kernelError(kind, message));\n};\n\n/** This function tells if an error is `#DEPTH!`. Some rules do not hide it (EVAL.DEPTH). */\nconst isDepth = (e: EvalError): boolean => e.code === (\"#DEPTH!\" satisfies ErrorCode);\n\n// ---------------------------------------------------------------- the position\n\n/** The segments that are not fields (REF.FORBIDDEN). */\nconst FORBIDDEN: ReadonlySet<string> = /* @__PURE__ */ new Set([\"__proto__\", \"constructor\", \"prototype\"]);\n\n/**\n * A position of an evaluation, as a host thing of the kernel: the space, the tables, the origin and the focus. It is the\n * root `self` of the context. A move gives a new position, and a field step reads the record at the focus. A move that\n * fails gives a position with the failure. The failure is the result when a reader uses the position, so the checks of\n * the computed keys come first (NAV.COMPUTED).\n */\nclass Place implements HostThing {\n // The constructor sets the brand. A computed field of the class makes a bundler keep the class in each program.\n declare readonly [THING]: true;\n readonly space: Space;\n readonly tables: Readonly<Record<string, Space>>;\n readonly origin: string;\n readonly focus: string;\n readonly failure: EvalError | undefined;\n /** The columns of the `fix` nodes around this position, by name (FIX.LAST). A column is no name of the program. */\n readonly columns: ReadonlyMap<string, ReadonlyMap<string, unknown>> | undefined;\n\n constructor(space: Space, tables: Readonly<Record<string, Space>>, origin: string, focus: string, failure?: EvalError, columns?: ReadonlyMap<string, ReadonlyMap<string, unknown>>) {\n (this as { [THING]: true })[THING] = true;\n this.space = space;\n this.tables = tables;\n this.origin = origin;\n this.focus = focus;\n this.failure = failure;\n this.columns = columns;\n }\n\n /** The text of the position for a trace. */\n get label(): string {\n return `key ${this.focus}`;\n }\n\n /** This method gives the position of a key of the same space, with the same origin. */\n to(focus: string): Place {\n return new Place(this.space, this.tables, this.origin, focus, undefined, this.columns);\n }\n\n /** This method gives this position with a new column of a `fix`. */\n withColumn(name: string, column: ReadonlyMap<string, unknown>): Place {\n return new Place(this.space, this.tables, this.origin, this.focus, undefined, new Map(this.columns).set(name, column));\n }\n\n /** This method gives the position with a failure, for a move that failed. */\n failed(failure: EvalError): Place {\n return new Place(this.space, this.tables, this.origin, this.focus, failure, this.columns);\n }\n\n /** This method reads one field of the record at the focus. */\n deref(key: Key): unknown {\n return this.resolve([key])?.thing;\n }\n\n /**\n * This method reads the fields of a path in the record at the focus (REF.PATH). A missing field, `null` and a segment\n * that is not a field reach nothing, and the kernel gives `#N/A` (REF.MISSING, REF.FORBIDDEN). A getter that throws\n * gives `#CALC!`, because the kernel catches the exception.\n */\n resolve(keys: readonly Key[]): { readonly thing: unknown } | undefined {\n if (this.failure !== undefined) throw new Failure(this.failure);\n let value: unknown = this.space.get(this.focus);\n if (value === undefined || value === null) return undefined;\n for (const key of keys) {\n const seg = String(key);\n if ((typeof value !== \"object\" && typeof value !== \"function\") || seg === \"\" || FORBIDDEN.has(seg)) return undefined;\n value = Reflect.get(value, seg);\n if (value === undefined || value === null) return undefined;\n }\n return { thing: value };\n }\n\n /** This method gives the record at the focus: the value of a reference without fields. */\n toJson(): unknown {\n if (this.failure !== undefined) throw new Failure(this.failure);\n const record = this.space.get(this.focus);\n return record === undefined || record === null ? stop(\"missing-field\", `the record at \"${this.focus}\" has no value`) : record;\n }\n}\n\n/**\n * This function gives the root `self` of an evaluation in the kernel. It is the position at the origin of a space,\n * with the tables of the axis table (AXIS.TABLE).\n */\nexport function vexSelf(space: Space, origin: string, tables: Readonly<Record<string, Space>> = {}): HostThing {\n return new Place(space, tables, origin, origin);\n}\n\n/**\n * This function gives the walker of a kind of move. `fix` gives the fixed move of the value of the step, or the reason\n * why the value is not valid, which gives `#VALUE!` (NAV.COMPUTED).\n */\nfunction moveWalker(fix: (data: unknown) => FixedMove | string): Walker {\n return ({ data, here }) => {\n if (!(here instanceof Place)) return { ok: false, reason: \"a move starts at a key of a space\", code: \"#REF!\" };\n const fixed = fix(data);\n if (typeof fixed === \"string\") return { ok: false, reason: fixed, code: \"#VALUE!\" };\n // A move after a failed move keeps the first failure, as the address of the closure compiler does (NAV.SEQUENCE).\n if (here.failure !== undefined) return { ok: true, thing: here };\n const r = applyMove(here.space, here, fixed);\n return { ok: true, thing: r.ok ? here.to(r.value) : here.failed(toKernelError(r.error)) };\n };\n}\n\n/** The walkers of the moves of Vex. */\nconst WALKERS: Readonly<Record<string, Walker>> = {\n \"vex.move.key\": /* @__PURE__ */ moveWalker((d) => (typeof d === \"string\" ? { t: \"key\", key: d } : `the key of a move is a ${typeof d}, not a text`)),\n \"vex.move.index\": /* @__PURE__ */ moveWalker((d) => (typeof d === \"number\" ? { t: \"index\", i: d } : `the position of a move is a ${typeof d}, not a number`)),\n \"vex.move.offset\": /* @__PURE__ */ moveWalker((d) => ({ t: \"offset\", d: d as readonly number[] })),\n \"vex.move.other\": /* @__PURE__ */ moveWalker(() => ({ t: \"other\" })),\n \"vex.move.origin\": /* @__PURE__ */ moveWalker(() => ({ t: \"origin\" })),\n \"vex.move.parent\": /* @__PURE__ */ moveWalker(() => ({ t: \"parent\" })),\n};\n\n// ---------------------------------------------------------------- the axes and the loops\n\n/*\n * The evaluators of Vex are functions of their input, not compilers. Thus a plan of the kernel and the reference\n * interpreter of the kernel use the same code for them, and the reference needs a definition only for the formula kit\n * (`vexDefinitions`).\n */\n\n/**\n * A target of an axis: its key, or its key and an error (AXIS.WHERE, AXIS.LIST). A target of the axis `list` also has\n * the value of its item and its position as `nth` counts it (AXIS.LIST.ITEM, AXIS.LIST.INDEX).\n */\ninterface Target {\n readonly key: string;\n readonly error?: VexError;\n readonly value?: unknown;\n readonly index?: number;\n}\n\n/** The value of an axis document: the targets from a position. `table` names the table of the axis table. */\ninterface Targets {\n readonly table: string | undefined;\n targets(from: Place): Outcome<readonly Target[]>;\n}\n\n/** This function gives the position of a target. In the space of the axis table, the origin is the target (AXIS.TABLE). */\nconst placeOf = (axis: Targets, from: Place, key: string): Place => (axis.table === undefined ? from.to(key) : new Place(from.space, from.tables, key, key));\n\n/** This function gives the parts of a record value, by name. */\nconst partsOf = (value: unknown): Readonly<Record<string, Part | undefined>> => (value ?? {}) as Readonly<Record<string, Part | undefined>>;\n\n/** This function gives the part of a field that the contract makes necessary. */\nconst partAt = (value: unknown, name: string): Part => partsOf(value)[name] as Part;\n\n/** This function gives the position of a context. A context without a position gives an error. */\nfunction selfOf(ctx: Context): Place | EvalError {\n return ctx.self instanceof Place ? ctx.self : kernelError(\"unknown-key\", \"the context has no key of a space\");\n}\n\n/** This function gives the position where an axis finds its targets: the key of the address, or the focus (AXIS.ADDRESS). */\nfunction startOf(at: Part | undefined, ctx: Context): Place | EvalError {\n if (at === undefined) return selfOf(ctx);\n const r = at.evaluate();\n if (!r.ok) return r.error;\n const where = r.value as Place;\n return where.failure ?? where;\n}\n\n/** This function gives the position in the space of the axis: the space of its table for the axis table (AXIS.TABLE). */\nfunction spaceOf(axis: Targets, from: Place): Place | EvalError {\n if (axis.table === undefined) return from;\n const space = Object.hasOwn(from.tables, axis.table) ? from.tables[axis.table] : undefined;\n return space === undefined ? kernelError(\"no-table\", `the evaluation has no table \"${axis.table}\"`) : new Place(space, from.tables, from.origin, from.focus);\n}\n\n/**\n * This function is the evaluator of the axes. An axis document gives a value that finds the targets from a position.\n * The list of `list` evaluates at that position, and the test of `where` at each target (AXIS.LIST, AXIS.WHERE).\n */\nconst axisEvaluator: EvalFn = ({ typePath, value, context }) => {\n const name = String(typePath[1]);\n const fields = partsOf(value);\n if (name === \"table\") {\n const table = (value as { readonly name: string }).name;\n return ok<Targets>({ table, targets: (from) => ok(from.space.keys.map((key) => ({ key }))) });\n }\n if (name === \"list\") {\n const list = fields[\"list\"] as Part;\n return ok<Targets>({\n table: undefined,\n targets: (from) => {\n const r = list.evaluate({ ...context, self: from });\n if (!r.ok) return r;\n // LIST.ARRAY: an array is a list with the positions as keys.\n const items = asList(r.value, missing);\n if (items === undefined) return failed(\"kind-mismatch\", `the axis \"list\" needs a list, not a ${describe(r.value)}`);\n // The index counts the items with a value, as nth does: nth skips the error items (LIST.LENIENT).\n let index = 0;\n return ok(items.items.map(({ key, result }): Target => (result.ok ? { key, value: result.value, index: index++ } : { key, error: result.error })));\n },\n });\n }\n if (name === \"reverse\" || name === \"where\") {\n const r = (fields[\"axis\"] as Part).evaluate();\n // Stryker disable next-line ConditionalExpression: an axis document fails only when the call stack of the engine is full\n if (!r.ok) return r;\n const base = r.value as Targets;\n const test = fields[\"test\"];\n if (test === undefined) {\n return ok<Targets>({\n table: base.table,\n targets: (from) => {\n const ts = base.targets(from);\n return ts.ok ? ok(ts.value.toReversed()) : ts;\n },\n });\n }\n return ok<Targets>({ table: base.table, targets: (from) => whereTargets(base, test, context, from) });\n }\n const ir = { t: name, ...(value as object) } as Exclude<Axis, { readonly t: \"where\" }>;\n return ok<Targets>({\n table: undefined,\n targets: (from) => {\n const keys = axisTargets(from.space, from, ir);\n return keys.ok ? ok(keys.value.map((key) => ({ key }))) : { ok: false, error: toKernelError(keys.error) };\n },\n });\n};\n\n/** This function keeps the targets where the test gives `true`. A failed test, or a value that is not a boolean, gives an error item. */\nfunction whereTargets(base: Targets, test: Part, ctx: Context, from: Place): Outcome<readonly Target[]> {\n const ts = base.targets(from);\n if (!ts.ok) return ts;\n const out: Target[] = [];\n for (const t of ts.value) {\n if (t.error !== undefined) {\n out.push(t);\n continue;\n }\n const r = test.evaluate({ ...ctx, self: placeOf(base, from, t.key) });\n if (!r.ok) out.push({ key: t.key, error: toVexError(r.error) });\n // The target keeps the value and the index of its item (AXIS.LIST.ITEM).\n else if (r.value === true) out.push(t);\n else if (r.value !== false) out.push({ key: t.key, error: vexError(\"kind-mismatch\", `the test of \"where\" gave a ${typeof r.value}, not a boolean`) });\n }\n return ok(out);\n}\n\n/** This function finds the targets of the axis of a loop, from the address or the focus, in the space of the axis. */\nfunction targetsOf(value: unknown, ctx: Context): Outcome<{ readonly axis: Targets; readonly from: Place; readonly targets: readonly Target[] }> {\n const start = startOf(partsOf(value)[\"at\"], ctx);\n if (!(start instanceof Place)) return { ok: false, error: start };\n const a = partAt(value, \"axis\").evaluate();\n // Stryker disable next-line ConditionalExpression: an axis document fails only when the call stack of the engine is full\n if (!a.ok) return a;\n const axis = a.value as Targets;\n const from = spaceOf(axis, start);\n if (!(from instanceof Place)) return { ok: false, error: from };\n const ts = axis.targets(from);\n return ts.ok ? ok({ axis, from, targets: ts.value }) : ts;\n}\n\n/**\n * This function sets a name of a new record of names, also the name `__proto__`. The record is new and gets each\n * name one time, so the property needs no other attributes. A later record copies it with a spread, so it is enumerable.\n */\nfunction setName(names: Record<string, unknown>, name: string, value: unknown): void {\n Object.defineProperty(names, name, { value, enumerable: true });\n}\n\n/**\n * This function evaluates the parts of a record of names in order (LOOP.NAMES). It gives the names with their new\n * values, or the first error. Each value reads the names before the step, so the names change only after all values.\n */\nfunction bindAll(record: Part | undefined, ctx: Context, names: Readonly<Record<string, unknown>>): Outcome<Readonly<Record<string, unknown>>> {\n const values: [string, unknown][] = [];\n for (const [name, part] of Object.entries(partsOf(record))) {\n const r = (part as Part).evaluate(ctx);\n if (!r.ok) return r;\n values.push([name, r.value]);\n }\n const out: Record<string, unknown> = { ...names };\n for (const [name, v] of values) setName(out, name, v);\n return ok(out);\n}\n\n/**\n * This function adds the names `as` of a loop to the names of a body or of a step. The first name holds the value of\n * the item, and the second its index (AXIS.LIST.ITEM, AXIS.LIST.INDEX). A loop without `as` keeps its names.\n */\nfunction withItem(names: Readonly<Record<string, unknown>>, as: readonly string[] | undefined, t: Target): Readonly<Record<string, unknown>> {\n if (as === undefined) return names;\n const out: Record<string, unknown> = { ...names };\n const [item, index] = as;\n setName(out, item as string, t.value);\n if (index !== undefined) setName(out, index, t.index);\n return out;\n}\n\n/** This function gives the names `as` of a loop, or `undefined` (AXIS.LIST.SCOPE). */\nconst itemNamesOf = (value: unknown): readonly string[] | undefined => (value as { readonly as?: readonly string[] }).as;\n\n/**\n * This function evaluates a part at each row of a column. Each row runs, also after an error (FIX.ERROR).\n */\nfunction rowsOf(part: Part, at: Place, context: Context, name: string, join: FixJoin): Outcome<ReadonlyMap<string, unknown>> {\n const out = new Map<string, unknown>();\n const errors: EvalError[] = [];\n for (const key of at.space.keys) {\n const r = part.evaluate({ ...context, self: at.to(key) });\n const wrong = r.ok ? fixValueError(name, join, r.value) : undefined;\n if (!r.ok) errors.push(r.error);\n else if (wrong !== undefined) errors.push(kernelError(wrong.kind, wrong.message));\n else out.set(key, r.value);\n }\n if (errors.length === 0) return ok(out);\n return { ok: false, error: worstRow(errors) ?? kernelError(\"args\", `${String(errors.length)} rows failed`, { causes: errors.map(toVexError) }) };\n}\n\n/** This function gives the value of the row of the focus. The focus of an item of the axis `list` can be no row (FIX.LAST). */\nfunction rowAt(name: string, column: ReadonlyMap<string, unknown> | undefined, at: Place): Outcome {\n const value = column?.get(at.focus);\n if (value !== undefined) return ok(value);\n const { kind, message } = errorText.lastKey(name, at.focus);\n return failed(kind, message);\n}\n\n/** The evaluators of the loops: each, fold, iterate and fix (LOOP.NAMES, FOLD.ORDER, ITERATE.LIMIT, FIX.ROUNDS). */\nconst LOOPS: Readonly<Record<string, EvalFn>> = {\n \"vex.each\": ({ value, context }) => {\n const found = targetsOf(value, context);\n if (!found.ok) return found;\n const { axis, from, targets } = found.value;\n const body = partAt(value, \"body\");\n const as = itemNamesOf(value);\n const items: ListItem[] = targets.map((t) => ({\n key: t.key,\n result: t.error === undefined ? toVexResult(body.evaluate({ ...context, self: placeOf(axis, from, t.key), names: withItem(context.names, as, t) })) : vexFail(t.error),\n }));\n return ok(vexList(items));\n },\n\n \"vex.fold\": ({ value, context }) => {\n const { init, step } = partsOf(value);\n // The first values come at the node, before the address and the targets (FOLD.ORDER).\n const first = bindAll(init, context, context.names);\n if (!first.ok) return first;\n let names = first.value;\n const found = targetsOf(value, context);\n if (!found.ok) return found;\n const { axis, from, targets } = found.value;\n const as = itemNamesOf(value);\n for (const t of targets) {\n if (t.error !== undefined) return { ok: false, error: toKernelError(t.error) };\n // The step sees the names of the item, and the next names do not keep them (AXIS.LIST.SCOPE).\n const next = bindAll(step, { ...context, self: placeOf(axis, from, t.key), names: withItem(names, as, t) }, names);\n if (!next.ok) return next;\n names = next.value;\n }\n return partAt(value, \"result\").evaluate({ ...context, names });\n },\n\n \"vex.limit\": ({ value }) => ok(value),\n\n // ITERATE.LIMIT.ERROR: each failure of the size of an axis is one error. Only an error of the run stays as it is.\n \"vex.size\": ({ value, context }) => {\n const found = targetsOf(value, context);\n if (!found.ok) return { ok: false, error: toKernelError(limitError(toVexError(found.error))) };\n const { targets } = found.value;\n const cause = worstError(targets.flatMap((t) => t.error ?? []));\n if (cause !== undefined) return { ok: false, error: toKernelError(limitError(cause)) };\n return targets.length > MAX_ITERATIONS ? failed(\"limit\", overLimitMessage(targets.length)) : ok(targets.length);\n },\n\n \"vex.iterate\": ({ value, context }) => {\n const { init, limit: bound, step, until } = partsOf(value);\n const first = bindAll(init, context, context.names);\n if (!first.ok) return first;\n let names = first.value;\n // The limit evaluates at the node, after the first values and before the steps (ITERATE.LIMIT.DATA).\n const counted = (bound as Part).evaluate(context);\n if (!counted.ok) return counted;\n const limit = counted.value as number;\n for (let k = 0; ; k++) {\n const here: Context = { ...context, names };\n if (until !== undefined) {\n const t = until.evaluate(here);\n if (!t.ok) return t;\n if (t.value === true) break;\n if (t.value !== false) return failed(\"kind-mismatch\", `the test \"until\" of \"iterate\" gave a ${typeof t.value}, not a boolean`);\n }\n if (k === limit) {\n if (until !== undefined) return failed(\"limit\", `\"iterate\" made its ${String(limit)} steps, and its test \"until\" is not true`);\n break;\n }\n const next = bindAll(step, here, names);\n if (!next.ok) return next;\n names = next.value;\n }\n return partAt(value, \"result\").evaluate({ ...context, names });\n },\n\n \"vex.fix\": ({ value, context }) => {\n const self = selfOf(context);\n if (!(self instanceof Place)) return { ok: false, error: self };\n const { name, join } = value as { readonly name: string; readonly join: FixJoin };\n const first = rowsOf(partAt(value, \"init\"), self, context, name, join);\n if (!first.ok) return first;\n let column = first.value;\n const { keys } = self.space;\n const limit = fixRounds(keys.length);\n for (let round = 1; round <= limit; round++) {\n const stepped = rowsOf(partAt(value, \"step\"), self.withColumn(name, column), context, name, join);\n if (!stepped.ok) return stepped;\n const next = new Map<string, unknown>();\n let changed = false;\n for (const key of keys) {\n const joined = joinValues(join, column.get(key), stepped.value.get(key));\n changed ||= joined !== column.get(key);\n next.set(key, joined);\n }\n if (!changed) return rowAt(name, column, self);\n column = next;\n }\n const { kind, message } = errorText.fixLimit(name, limit);\n return failed(kind, message);\n },\n\n \"vex.last\": ({ value, context }) => {\n const self = selfOf(context);\n if (!(self instanceof Place)) return { ok: false, error: self };\n const name = value as string;\n return rowAt(name, self.columns?.get(name), self);\n },\n};\n\n// ---------------------------------------------------------------- functions\n\n/**\n * A function of a `let` (FN.BIND). A reference to its name is an error, because a function is not a value (FN.VALUE).\n * It keeps the names of the place of its binding, and its body evaluates at the position of each call (FN.CALL).\n */\nclass Bound extends Held {\n readonly params: readonly string[];\n readonly body: Part;\n readonly names: Readonly<Record<string, unknown>>;\n\n constructor(params: readonly string[], body: Part, names: Readonly<Record<string, unknown>>) {\n super(kernelError(\"kind-mismatch\", \"the name is a function, not a value\"));\n this.params = params;\n this.body = body;\n this.names = names;\n }\n}\n\n/** The evaluators of the functions of Vex (FN.BIND, FN.CALL, FN.ARGS). */\nconst FUNCTIONS: Readonly<Record<string, EvalFn>> = {\n \"vex.fn\": ({ value, context }) => ok(new Bound((value as { readonly params: readonly string[] }).params, partAt(value, \"body\"), context.names)),\n\n \"vex.call\": ({ doc, value, context }) => {\n // The contract and fromDocument make the function a reference to a name: [\"names\", name] (DOC.CALL).\n const name = String((doc.value as { readonly fn: { readonly value: readonly unknown[] } }).fn.value[1]);\n const args = partsOf(value)[\"args\"] as unknown as readonly Part[];\n if (!Object.hasOwn(context.names, name)) return failed(\"unbound\", `the function \"${name}\" has no binding`);\n const bound = context.names[name];\n if (!(bound instanceof Bound)) return bound instanceof Held ? { ok: false, error: bound.error } : failed(\"kind-mismatch\", `the name \"${name}\" is a value, not a function`);\n if (bound.params.length !== args.length) return failed(\"bad-expression\", `the function \"${name}\" takes ${String(bound.params.length)} arguments, not ${String(args.length)}`);\n // Each parameter gets the result of its argument at the call. An error has an effect only where the body reads it.\n const names: Record<string, unknown> = { ...bound.names };\n bound.params.forEach((p, i) => {\n const r = (args[i] as Part).evaluate();\n setName(names, p, r.ok ? r.value : new Held(r.error));\n });\n return bound.body.evaluate({ ...context, names });\n },\n};\n\n// ---------------------------------------------------------------- ops\n\n/** This function gives a short name for the type of a value, for a message. */\nfunction describe(u: unknown): string {\n if (u === null) return \"null\";\n if (Array.isArray(u)) return \"array\";\n if (isVexList(u)) return \"list\";\n return typeof u;\n}\n\n/** This function applies the test of a domain to a value. A test that throws rejects the value. */\nfunction accepts(d: AnyDomain, x: unknown): boolean {\n let accepted = false;\n try {\n accepted = d.is(x);\n } catch {\n // The value stays rejected.\n }\n return accepted;\n}\n\n/** This function finds an own method of a receiver or of its prototypes, but not of `Object` or `Function` (CALL.METHOD). */\nfunction methodOf(self: unknown, name: string): ((...a: unknown[]) => unknown) | undefined {\n // The loop stops at null, so a null receiver gives undefined too.\n if (FORBIDDEN.has(name) || (typeof self !== \"object\" && typeof self !== \"function\")) return undefined;\n for (let o: object | null = self; o !== null && o !== Object.prototype && o !== Function.prototype; o = Object.getPrototypeOf(o) as object | null) {\n const d = Object.getOwnPropertyDescriptor(o, name);\n if (d !== undefined) return typeof d.value === \"function\" ? (d.value as (...a: unknown[]) => unknown) : undefined;\n }\n return undefined;\n}\n\n/** This function checks the value of an op (CALL.RESULT): a value, a finite number, and a valid value of its domain. */\nfunction checked(x: unknown, op: string, domains: readonly AnyDomain[]): unknown {\n if (x === undefined || x === null) return stop(\"undefined-result\", `\"${op}\" gave no value`);\n if (typeof x === \"number\" && !Number.isFinite(x)) return stop(\"not-finite\", `\"${op}\" gave ${String(x)}`);\n const d = domains.find((dom) => accepts(dom, x));\n if (d?.valid !== undefined && !d.valid(x)) return stop(\"invalid-value\", `\"${op}\" gave a value that is not a valid ${d.name}`);\n return x;\n}\n\n/** The op of a domain for a receiver: its spec, and the method of the receiver for an op without `fn`. */\ninterface Found {\n readonly domain: AnyDomain;\n readonly spec: { readonly fn?: (...a: unknown[]) => unknown; readonly liftScalar?: boolean | readonly boolean[]; readonly params?: readonly string[] } | undefined;\n readonly method: ((...a: unknown[]) => unknown) | undefined;\n}\n\n/** This function finds the op of a domain for a receiver, or `undefined` (CALL.UNKNOWN-OP). */\nfunction opOf(d: AnyDomain, self: unknown, op: string): Found | undefined {\n const spec = Object.hasOwn(d.ops, op) && !FORBIDDEN.has(op) ? (d.ops[op] as Found[\"spec\"]) : undefined;\n // An op with a function does not use the method, so the search of the method only adds work there.\n const method = spec !== undefined || d.methods === \"all\" ? methodOf(self, op) : undefined;\n return spec?.fn === undefined && method === undefined ? undefined : { domain: d, spec, method };\n}\n\n/** This function applies the op of a domain: it lifts the numbers, checks the kinds of the arguments and checks the value. */\nfunction callFound(found: Found, op: string, self: unknown, args: readonly unknown[], domains: readonly AnyDomain[]): unknown {\n const { domain, spec } = found;\n const lift = spec?.liftScalar;\n const from = domain.fromScalar;\n const rest = from === undefined ? args : args.map((a, i): unknown => (typeof a === \"number\" && (lift === true || (Array.isArray(lift) && lift[i] === true)) ? from(a) : a));\n const params = spec?.params;\n if (params !== undefined) {\n rest.forEach((a, i) => {\n const k = params[i] ?? \"any\";\n if (k !== \"any\" && !(k === \"domain\" ? accepts(domain, a) : typeof a === k)) {\n stop(k === \"domain\" ? \"not-instance\" : \"kind-mismatch\", `argument ${String(i + 1)} of \"${op}\" is a ${describe(a)}, not a ${k === \"domain\" ? domain.name : k}`);\n }\n });\n }\n const out = spec?.fn !== undefined ? spec.fn(self, ...rest) : (found.method as (...a: unknown[]) => unknown).call(self, ...rest);\n return checked(out, op, domains);\n}\n\n/** The list ops with a second argument before their options: a count, a position, an op name or a list. */\nconst WITH_ARGUMENT: ReadonlySet<string> = /* @__PURE__ */ new Set([\"reduce\", \"take\", \"nth\", \"drop\", \"append\", \"without\", \"get\", \"indexOf\", \"group\", \"join\"]);\n\n/**\n * This function gives the items of a list that have a value (LIST.LENIENT). A list op does not skip `#DEPTH!`, so that\n * error comes first (EVAL.DEPTH). With `strict`, the first error item is the result.\n */\nfunction goodOf(items: readonly ListItem[], strict: boolean): readonly ListItem[] {\n const depth = items.find((it) => !it.result.ok && it.result.error.code === \"#DEPTH!\");\n if (depth !== undefined && !depth.result.ok) throw new Failure(toKernelError(depth.result.error));\n const firstBad = items.find((it) => !it.result.ok);\n if (strict && firstBad !== undefined && !firstBad.result.ok) throw new Failure(toKernelError(firstBad.result.error));\n return items.filter((it) => it.result.ok);\n}\n\n/** This function gives the items of the list `other` of `append` and `without` (LIST.BUILD). Another value gives `#VALUE!`. */\nfunction otherOf(op: string, other: unknown, strict: boolean): readonly ListItem[] {\n const list = asList(other, missing);\n return list !== undefined ? goodOf(list.items, strict) : stop(\"kind-mismatch\", `\"${op}\" needs a list as its second argument, not a ${describe(other)}`);\n}\n\n/** This function joins the lists that are the values of the items, in order (LIST.FLAT). Each list follows LIST.BUILD. */\nfunction flat(vs: readonly unknown[], strict: boolean): unknown {\n const out: ListItem[] = [];\n for (const v of vs) {\n const inner = asList(v, missing);\n if (inner === undefined) return stop(\"kind-mismatch\", `\"flat\" needs a list as the value of each item, but an item is a ${describe(v)}`);\n out.push(...goodOf(inner.items, strict));\n }\n return vexList(out);\n}\n\n/**\n * This function gives the groups of `group(list, keys)` (LIST.GROUP). The item at a position has the key at the same\n * position. A pair with an error item or an error key is not in a group.\n */\nfunction group(items: readonly ListItem[], keys: unknown, strict: boolean): unknown {\n goodOf(items, strict);\n const list = asList(keys, missing);\n if (list === undefined) return stop(\"kind-mismatch\", `\"group\" needs a list of keys, not a ${describe(keys)}`);\n goodOf(list.items, strict);\n if (list.items.length !== items.length) return stop(\"kind-mismatch\", '\"group\" needs one key for each item');\n const groups = new Map<string, ListItem[]>();\n items.forEach((it, i) => {\n const k = (list.items[i] as ListItem).result;\n if (!it.result.ok || !k.ok) return;\n if (typeof k.value !== \"string\") stop(\"kind-mismatch\", '\"group\" needs text keys');\n groups.set(k.value as string, [...(groups.get(k.value as string) ?? []), it]);\n });\n return vexList([...groups].map(([key, g]): ListItem => ({ key, result: vexOk(vexList(g)) })));\n}\n\n/** This function applies a list op (LIST.*). The error items are skipped, except with `{ strict: true }`, and except `#DEPTH!`. */\nfunction listOp(op: string, items: readonly ListItem[], rest: readonly unknown[], domains: readonly AnyDomain[]): unknown {\n const o = op === \"setNth\" ? rest[2] : WITH_ARGUMENT.has(op) ? rest[1] : rest[0];\n const strict = (o as { strict?: unknown } | null | undefined)?.strict === true;\n if (op === \"group\") return group(items, rest[0], strict);\n const good = goodOf(items, strict);\n const vs = good.map((it) => (it.result.ok ? it.result.value : undefined));\n const nums = (): readonly number[] => (vs.every((x) => typeof x === \"number\") ? vs : stop(\"kind-mismatch\", `\"${op}\" needs numbers`));\n const bools = (): readonly boolean[] => (vs.every((x) => typeof x === \"boolean\") ? vs : stop(\"kind-mismatch\", `\"${op}\" needs booleans`));\n const empty = (): never => stop(\"empty\", `\"${op}\" has no values to work with`);\n switch (op) {\n case \"count\":\n return vs.length;\n case \"values\":\n return Object.freeze([...vs]);\n case \"keys\":\n return Object.freeze(good.map((it) => it.key));\n case \"errors\":\n return Object.freeze(items.flatMap((it) => (it.result.ok ? [] : [it.result.error])));\n case \"first\":\n return vs.length > 0 ? vs[0] : empty();\n case \"sortBy\": {\n const ks = sortValues(o, vs, domains);\n const kind = typeof ks[0];\n if (ks.some((x) => typeof x !== kind || (kind !== \"number\" && kind !== \"string\") || Number.isNaN(x))) stop(\"kind-mismatch\", '\"sortBy\" needs numbers without NaN or texts, all of one kind');\n return vexList(good.map((it, i) => ({ it, i })).toSorted((a, b) => compare(ks[a.i], ks[b.i])).map(({ it }) => it));\n }\n case \"take\":\n case \"drop\":\n case \"nth\": {\n const n = rest[0] as number;\n if (!Number.isSafeInteger(n) || n < 0) return stop(\"kind-mismatch\", `\"${op}\" needs a whole number from 0`);\n if (op === \"take\") return vexList(good.slice(0, n));\n if (op === \"drop\") return vexList(good.slice(n));\n return n < vs.length ? vs[n] : stop(\"empty\", `\"nth\" has no item at the position ${String(n)}`);\n }\n case \"setNth\": {\n const n = rest[0] as number;\n if (!Number.isSafeInteger(n) || n < 0) return stop(\"kind-mismatch\", '\"setNth\" needs a whole number from 0');\n const old = good[n];\n if (old === undefined) return stop(\"empty\", `\"setNth\" has no item at the position ${String(n)}`);\n if (rest[1] === undefined) return stop(\"bad-expression\", '\"setNth\" needs argument 3');\n const next = [...good];\n next[n] = { key: old.key, result: vexOk(rest[1]) };\n return vexList(next);\n }\n case \"append\":\n return vexList([...good, ...otherOf(op, rest[0], strict)]);\n case \"without\": {\n const gone = new Set(otherOf(op, rest[0], strict).map((it) => it.key));\n return vexList(good.filter((it) => !gone.has(it.key)));\n }\n case \"flat\":\n return flat(vs, strict);\n case \"get\": {\n // The first item of the key gives its value. An error item is not an item of its key (LIST.GET).\n const key = rest[0];\n if (typeof key !== \"string\") return stop(\"kind-mismatch\", `\"get\" needs a text key, not a ${describe(key)}`);\n const i = good.findIndex((it) => it.key === key);\n return i >= 0 ? vs[i] : stop(\"missing-field\", `the list has no item with the key ${JSON.stringify(key)}`);\n }\n case \"distinct\": {\n // The first item of each value, by ===, as for indexOf. Thus each NaN stays (LIST.DISTINCT).\n if (!vs.every(isIndexValue)) return stop(\"kind-mismatch\", '\"distinct\" needs numbers, texts or booleans');\n const keep = vs.map((x, i) => vs.indexOf(x) === i || Number.isNaN(x));\n return vexList(good.filter((_it, i) => keep[i]));\n }\n case \"join\": {\n // The texts of the items with the text sep between them (LIST.JOIN).\n const sep = rest[0];\n if (typeof sep !== \"string\") return stop(\"kind-mismatch\", `\"join\" needs a text separator, not a ${describe(sep)}`);\n return vs.every((x) => typeof x === \"string\") ? vs.join(sep) : stop(\"kind-mismatch\", '\"join\" needs texts');\n }\n case \"indexOf\": {\n // The position of the first value, among the items with a value (LIST.INDEXOF).\n const x = rest[0];\n if (!isIndexValue(x)) return stop(\"kind-mismatch\", `\"indexOf\" needs a number, a text or a boolean, not a ${describe(x)}`);\n const i = vs.indexOf(x);\n return i >= 0 ? i : stop(\"missing-field\", `the list has no item with the value ${JSON.stringify(x)}`);\n }\n case \"sum\":\n // Stryker disable next-line ArrayDeclaration: a sum needs no domain, and a text in the list accepts no value\n return checked(nums().reduce((s, x) => s + x, 0), op, []);\n case \"mean\": {\n const n = nums();\n // Stryker disable next-line ArrayDeclaration: a mean needs no domain, and a text in the list accepts no value\n return n.length === 0 ? empty() : checked(n.reduce((s, x) => s + x, 0) / n.length, op, []);\n }\n case \"min\":\n case \"max\": {\n const n = nums();\n return n.length === 0 ? empty() : n.reduce((best, x) => (op === \"min\" ? Math.min(best, x) : Math.max(best, x)));\n }\n case \"any\":\n return bools().some(Boolean);\n case \"all\":\n return bools().every(Boolean);\n case \"none\":\n return !bools().some(Boolean);\n default:\n return reduce(rest[0], vs, o, domains);\n }\n}\n\n/**\n * This function gives the sort values of `sortBy` (LIST.SORT.BY). Without the option `by`, they are the values. With\n * it, the op of that name applies to each value, in order, and the first error stops the sort.\n */\nfunction sortValues(o: unknown, vs: readonly unknown[], domains: readonly AnyDomain[]): readonly unknown[] {\n const by = (o as { readonly by?: unknown } | null | undefined)?.by;\n if (by === undefined) return vs;\n if (typeof by !== \"string\") return stop(\"kind-mismatch\", '\"sortBy\" needs an op name in the option \"by\"');\n return vs.map((x) => {\n const found = domains.filter((d) => accepts(d, x)).map((d) => opOf(d, x, by)).find((f) => f !== undefined);\n return found === undefined ? stop(\"unknown-op\", `no domain gives \"${by}\" for a ${describe(x)}`) : callFound(found, by, x, [], domains);\n });\n}\n\n/** This function compares two numbers or two texts for `sortBy`. Equal values keep their order (LIST.SORT). */\nconst compare = (a: unknown, b: unknown): number => ((a as number) < (b as number) ? -1 : (a as number) > (b as number) ? 1 : 0);\n\n/** This function folds the values of a list with a domain op, from the left (LIST.REDUCE, LIST.REDUCE.EMPTY). */\nfunction reduce(name: unknown, vs: readonly unknown[], o: unknown, domains: readonly AnyDomain[]): unknown {\n if (typeof name !== \"string\") return stop(\"kind-mismatch\", '\"reduce\" needs an op name');\n if (vs.length === 0) {\n const named = (o as { domain?: unknown } | null | undefined)?.domain;\n if (named !== undefined && !domains.some((d) => d.name === named)) return stop(\"unknown-op\", `\"reduce\" names the domain ${JSON.stringify(named) ?? \"?\"}, but the program has no such domain`);\n const ds = domains.filter((d) => Object.hasOwn(d.ops, name) && (d.ops[name] as { identity?: unknown }).identity !== undefined && (named === undefined || d.name === named));\n const only = ds.length === 1 ? (ds[0]?.ops[name] as { identity: () => unknown }) : undefined;\n return only === undefined ? stop(\"empty\", `\"reduce\" with \"${name}\" has no values, and no one identity`) : only.identity();\n }\n let acc: unknown = vs[0];\n for (const x of vs.slice(1)) {\n const found = domains.filter((d) => accepts(d, acc)).map((d) => opOf(d, acc, name)).find((f) => f !== undefined);\n if (found === undefined) return stop(\"unknown-op\", `no domain gives \"${name}\" for a ${describe(acc)}`);\n acc = callFound(found, name, acc, [x], domains);\n }\n return acc;\n}\n\n/**\n * This function gives the op of a name: the dispatch of Vex at run time. A list op applies to a list. Else the first\n * domain that accepts the receiver and has the op applies it. Else a free function applies (CALL.FREE).\n */\nfunction dispatch(op: string, domains: readonly AnyDomain[], fns: Readonly<Record<string, (...a: readonly unknown[]) => unknown>>): (...values: unknown[]) => unknown {\n const free = Object.hasOwn(fns, op) ? fns[op] : undefined;\n const listed = LIST_OPS.has(op);\n return (...values) => {\n const self = values[0];\n if (listed && isVexList(self)) return listOp(op, self.items, values.slice(1), domains);\n let accepted = false;\n if (values.length > 0) {\n for (const d of domains) {\n if (!accepts(d, self)) continue;\n accepted = true;\n const found = opOf(d, self, op);\n if (found !== undefined) return callFound(found, op, self, values.slice(1), domains);\n }\n }\n if (free !== undefined) return checked(free(...values), op, domains);\n // LIST.ARRAY and LIST.FILL come after the domains and the functions of the host, so each of their results stays.\n if (listed && Array.isArray(self)) return listOp(op, listOfArray(self, missing).items, values.slice(1), domains);\n if (op === \"fill\") return fill(values);\n if (accepted || values.length === 0) return stop(\"unknown-op\", accepted ? `the domain of the receiver has no op \"${op}\"` : `there is no function \"${op}\"`);\n return stop(\"not-instance\", `no domain accepts the receiver of \"${op}\" (${describe(self)})`);\n };\n}\n\n/** This function gives the list of `fill(n, value)` (LIST.FILL). A count that is not a whole number from 0 to 100000 gives `#VALUE!`. */\nfunction fill([n, value]: readonly unknown[]): unknown {\n if (!isFillCount(n)) return stop(\"kind-mismatch\", `\"fill\" needs a whole number from 0 to 100000, not ${describe(n)}`);\n return value === undefined ? stop(\"bad-expression\", '\"fill\" needs argument 2') : fillList(n, value);\n}\n\n/** This function gives an argument of a special form. A missing argument gives `#VALUE!`. */\nconst argOf = (args: readonly (() => Outcome)[], i: number, op: string): Outcome => args[i]?.() ?? failed(\"bad-expression\", `\"${op}\" needs argument ${String(i + 1)}`);\n\n/** This function gives an argument of a special form that must be a boolean (FORM.IF, FORM.AND-OR). */\nfunction boolOf(args: readonly (() => Outcome)[], i: number, op: string): Outcome {\n const r = argOf(args, i, op);\n return !r.ok || typeof r.value === \"boolean\" ? r : failed(\"kind-mismatch\", `argument ${String(i + 1)} of \"${op}\" is a ${describe(r.value)}, not a boolean`);\n}\n\n/** This function gives `and` or `or`: they stop at the first argument that decides (FORM.AND-OR). */\nconst logic = (op: \"and\" | \"or\"): LazyOp => (args) => {\n if (args.length === 0) return failed(\"bad-expression\", `\"${op}\" needs at least 1 argument`);\n for (let i = 0; i < args.length; i++) {\n const b = boolOf(args, i, op);\n if (!b.ok || b.value === (op === \"or\")) return b;\n }\n return ok(op === \"and\");\n};\n\n/** The special forms of Vex: lazy ops of the formula kit (FORM.IF, FORM.AND-OR, FORM.IFERROR). */\nconst FORMS: Readonly<Record<string, LazyOp>> = {\n if: (args) => {\n const c = boolOf(args, 0, \"if\");\n return c.ok ? argOf(args, c.value === true ? 1 : 2, \"if\") : c;\n },\n and: /* @__PURE__ */ logic(\"and\"),\n or: /* @__PURE__ */ logic(\"or\"),\n // EVAL.DEPTH: ifError does not hide #DEPTH!, because the engine failed, not the data.\n ifError: (args) => {\n // Stryker disable next-line StringLiteral: ifError replaces the error of a missing first argument, so no one sees this name\n const first = argOf(args, 0, \"ifError\");\n return first.ok || isDepth(first.error) ? first : argOf(args, 1, \"ifError\");\n },\n};\n\n/**\n * This function gives the profile of Vex for the formula kit: the dispatch of the ops, the special forms and the\n * extensions. Two or more failed arguments or fields give `#ARGS` (CALL.ARGS, REC.FIELDS).\n */\nfunction profileOf(opts: CompileOptions): FormulaProfile {\n // Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain matches no value\n const domains = opts.domains ?? [];\n const fns = opts.fns ?? {};\n const extensions = opts.extensions ?? {};\n // Vex has no standard extension: each extension kind needs its handler, so the standard names give #NAME? too.\n // A record without a prototype, so an extension kind such as `__proto__` is an own entry too.\n const ext = Object.create(null) as Record<string, ExtFn>;\n for (const name of Object.keys(STD_EXT)) ext[name] = () => failed(\"unknown-op\", `no handler for the extension kind \"${name}\"`);\n for (const [name, handler] of Object.entries(extensions)) {\n ext[name] = (data, ctx) => {\n const self = selfOf(ctx);\n if (!(self instanceof Place)) return { ok: false, error: self };\n // The kernel does not know the path of a node in the tagged IR, so the path is empty.\n const r = handler(data, { space: self.space, position: { origin: self.origin, focus: self.focus }, path: [] });\n if (r.ok) return r;\n // An error without an origin gets the position of the extension (EVAL.LOCATION).\n return { ok: false, error: toKernelError(r.error.origin === undefined ? { ...r.error, origin: self.origin, focus: self.focus } : r.error) };\n };\n }\n return {\n ops: (name) => dispatch(name, domains, fns),\n lazy: FORMS,\n ext,\n // A #DEPTH! argument is the result: #ARGS does not wrap it (EVAL.DEPTH).\n combine: (errors) => errors.find(isDepth) ?? kernelError(\"args\", `${String(errors.length)} arguments failed`, { causes: errors.map(toVexError) }),\n };\n}\n\n/** The evaluators of the literals: the JSON form of IR.JSON, and a value of the host (DOC.LITERAL). */\nfunction literals(domains: readonly AnyDomain[]): Readonly<Record<string, EvalFn>> {\n return {\n // The kernel catches a decoder that throws, and gives #CALC! (CALL.THROW) or #DEPTH! (EVAL.DEPTH).\n \"vex.lit\": ({ doc }) => {\n const decoded = decodeValue(doc.value, domains);\n return decoded.ok ? ok(decoded.value) : { ok: false, error: toKernelError(decoded.error) };\n },\n // A literal of an expression without a JSON form: its document holds the value of the host, with this own entry.\n \"vex.host\": ({ doc }) => ok(doc.value),\n };\n}\n\n/**\n * The rules of the machines of Vex. The values of a space are data, so a field that has the shape of a reference stays\n * a value. A reference starts at `self` or `names`, and a document has a limit of nesting.\n */\nconst RULES = { plain: true, roots: [\"self\", \"names\"], maxDepth: MAX_DOCUMENT_DEPTH } as const;\n\n/**\n * This function makes the machine of the kernel for Vex: the world of Vex, and the formula kit with the profile of\n * Vex. Vex adds its evaluators and its walkers. It is the reference tier of Vex (EVAL.REFERENCE).\n */\nexport function vexMachine(opts: CompileOptions = {}): Machine {\n // Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain matches no value\n return { world: VEX_WORLD, evaluators: { ...formulaEvaluators(profileOf(opts)), ...literals(opts.domains ?? []), ...LOOPS, ...FUNCTIONS, \"vex.axis\": axisEvaluator }, walkers: WALKERS, ...RULES };\n}\n\n/** The code of each evaluator and walker of the machine of the checks. A check uses only their names. */\nconst NO_CODE = (): never => stop(\"bad-expression\", \"the machine of the checks evaluates nothing\");\n\n/**\n * This function makes the machine of the checks (DOC.CHECK). It has the world of Vex, and the names of the evaluators\n * and the walkers of `vexMachine` without their code. The static kit of the kernel needs only the names. Thus a\n * program that only reads documents does not hold the evaluators.\n */\nexport function vexChecker(): Machine {\n const evaluators: Record<string, EvalFn> = {};\n const walkers: Record<string, Walker> = {};\n const todo: unknown[] = Object.values(VEX_WORLD.kinds);\n for (let x = todo.pop(); x !== undefined; x = todo.pop()) {\n const kind = x as { readonly verbs?: Readonly<Record<string, string>>; readonly kinds?: Readonly<Record<string, unknown>>; readonly fallback?: unknown };\n const { eval: name, step } = kind.verbs ?? {};\n if (name !== undefined) evaluators[name] = NO_CODE;\n if (step !== undefined) walkers[step] = NO_CODE;\n todo.push(...Object.values(kind.kinds ?? {}), ...(kind.fallback === undefined ? [] : [kind.fallback]));\n }\n return { world: VEX_WORLD, evaluators, walkers, ...RULES };\n}\n\n/**\n * This function gives the definitions of the machine of Vex for the reference interpreter of the kernel. The formula\n * kit gets its definitions with the profile of Vex. The evaluators of Vex are functions, so they need no definition.\n */\nexport function vexDefinitions(opts: CompileOptions = {}): Definitions {\n return formulaDefinitions(profileOf(opts));\n}\n","/**\n * The writer of the documents of Vex: the coeval document of an expression (DOC.TERM). It uses a stack, not recursion,\n * so an expression of any depth has a document. The package index does not export this module: `toDocument`, `deps`\n * and `kernelPlan` use it.\n */\nimport { isEnvelope, ref as path, typed, type Envelope, type Json, type JsonRecord } from \"@mark1russell7/coeval\";\nimport { encodeValue } from \"./codec.ts\";\nimport type { AnyDomain } from \"./domain.ts\";\nimport type { VexError } from \"./errors.ts\";\nimport { limitAxis, type Axis, type Expr, type Move } from \"./ir.ts\";\n\n/** The options of the writer. */\nexport interface WriteOptions {\n /** The domains that encode the values of the literals. */\n readonly domains: readonly AnyDomain[];\n /**\n * The form of a literal without a JSON form. `\"json\"` stops the writer with its error. `\"host\"` keeps the value of the\n * host in a literal with the own entry `vex.host`, for an evaluation in the kernel.\n */\n readonly literals: \"json\" | \"host\";\n /**\n * The order of the fields of `each` and `fold`. `\"document\"` is the order of DOC.CONSTRUCT. `\"reads\"` puts the body or\n * the steps before the axis, in the order of the reads of `deps`.\n */\n readonly order: \"document\" | \"reads\";\n /** A map that gets the expression of each envelope of a reference, an axis loop and a call. */\n readonly nodes?: Map<object, Expr>;\n}\n\n/** The stop of a write: a literal without a JSON form. The caller gives its error. */\nexport class WriteStop {\n readonly error: VexError;\n\n constructor(error: VexError) {\n this.error = error;\n }\n}\n\n/** A job of the writer: an expression in the position of a term or of an envelope, an axis or a move. */\ntype Job = { readonly t: \"term\" | \"envelope\"; readonly e: Expr } | { readonly t: \"axis\"; readonly a: Axis } | { readonly t: \"move\"; readonly m: Move };\n\n/** The plan of a job: the jobs of its parts, and the function that makes its document from their documents. */\ninterface Plan {\n readonly jobs: readonly Job[];\n readonly make: (docs: readonly Json[]) => Json;\n}\n\nconst NONE: readonly Job[] = [];\n// Stryker disable next-line StringLiteral: the writer tests only the kind \"envelope\", so each other kind is the kind \"term\"\nconst term = (e: Expr): Job => ({ t: \"term\", e });\nconst envelope = (e: Expr): Job => ({ t: \"envelope\", e });\n\n/** This function gives the field `as` of a loop: a new list of its names, or no field (AXIS.LIST.SCOPE). */\nconst itemsOf = (as: readonly string[] | undefined): { readonly as?: Json } => (as === undefined ? {} : { as: [...as] });\n\n/** This function gives a record from names and the documents of their values, from an index of the documents. */\nfunction namesOf(names: readonly string[], docs: readonly Json[], from: number): JsonRecord {\n const out: Record<string, Json> = {};\n names.forEach((name, i) => {\n Object.defineProperty(out, name, { value: docs[from + i], enumerable: true, writable: true, configurable: true });\n });\n return out;\n}\n\n/** The writer of one document. */\nclass Writer {\n readonly #opts: WriteOptions;\n\n constructor(opts: WriteOptions) {\n this.#opts = opts;\n }\n\n /** This method writes the document of a job, with a stack of plans. */\n write(root: Job): Json {\n const stack: { readonly plan: Plan; readonly docs: Json[] }[] = [{ plan: this.#plan(root), docs: [] }];\n for (;;) {\n const top = stack[stack.length - 1] as (typeof stack)[number];\n const next = top.plan.jobs[top.docs.length];\n if (next !== undefined) {\n stack.push({ plan: this.#plan(next), docs: [] });\n continue;\n }\n const doc = top.plan.make(top.docs);\n stack.pop();\n const parent = stack[stack.length - 1];\n if (parent === undefined) return doc;\n parent.docs.push(doc);\n }\n }\n\n /** This method keeps the expression of an envelope, for `deps`. */\n #keep<T extends Json>(doc: T, e: Expr): T {\n this.#opts.nodes?.set(doc as object, e);\n return doc;\n }\n\n /** This method gives the document of a literal: its JSON form, or a value of the host (DOC.LITERAL). */\n #literal(value: unknown, root: boolean): Json {\n const host: Json = { type: \"lit\", value: value as Json, own: { eval: \"vex.host\" } };\n let r: ReturnType<typeof encodeValue>;\n try {\n r = encodeValue(value, this.#opts.domains);\n } catch (thrown) {\n // A getter of the value threw. In the mode \"host\", the literal keeps the value of the host.\n if (this.#opts.literals === \"json\") throw thrown;\n return host;\n }\n if (!r.ok) {\n if (this.#opts.literals === \"json\") throw new WriteStop(r.error);\n return host;\n }\n const json = r.value as Json;\n // In the position of a term, a literal is its JSON value, except a value with the shape of an envelope (DOC.TERM).\n return root || isEnvelope(json) ? typed(\"lit\", json) : json;\n }\n\n #plan(job: Job): Plan {\n if (job.t === \"axis\") return this.#axis(job.a);\n if (job.t === \"move\") return this.#move(job.m);\n const e = job.e;\n if (e.tag === \"lit\") return { jobs: NONE, make: () => this.#literal(e.value, job.t === \"envelope\") };\n return this.#envelope(e);\n }\n\n #envelope(e: Exclude<Expr, { readonly tag: \"lit\" }>): Plan {\n const reads = this.#opts.order === \"reads\";\n switch (e.tag) {\n case \"ref\":\n return { jobs: (e.at ?? []).map((m): Job => ({ t: \"move\", m })), make: (docs) => this.#keep(path(\"self\", ...docs, ...e.path), e) };\n case \"var\":\n return { jobs: NONE, make: () => path(\"names\", e.name) };\n case \"app\":\n return { jobs: e.args.map(term), make: (docs) => typed([\"ops\", ...e.op.split(\".\")], [...docs]) };\n case \"let\": {\n const names = Object.keys(e.bind);\n return { jobs: [...Object.values(e.bind).map(term), term(e.body)], make: (docs) => typed(\"let\", { bind: namesOf(names, docs, 0), body: docs[names.length] as Json }) };\n }\n case \"fn\":\n return { jobs: [term(e.body)], make: (docs) => typed(\"fn\", { params: [...e.params], body: docs[0] as Json }) };\n case \"call\":\n return { jobs: e.args.map(term), make: (docs) => this.#keep(typed(\"call\", { fn: path(\"names\", e.fn), args: [...docs] }), e) };\n case \"rec\": {\n const names = Object.keys(e.fields);\n return { jobs: Object.values(e.fields).map(term), make: (docs) => typed(\"record\", namesOf(names, docs, 0)) };\n }\n case \"each\": {\n const at = this.#at(e.at);\n return {\n jobs: [{ t: \"axis\", a: e.axis }, term(e.body), ...at.jobs],\n make: (docs) => {\n const axis = docs[0] as Json;\n const body = docs[1] as Json;\n const address = at.make(docs.slice(2));\n const as = itemsOf(e.as);\n return this.#keep(typed(\"each\", reads ? { body, axis, ...as, ...address } : { axis, ...as, body, ...address }), e);\n },\n };\n }\n case \"fold\": {\n const init = Object.keys(e.init);\n const step = Object.keys(e.step);\n const at = this.#at(e.at);\n const after = 1 + init.length + step.length;\n return {\n jobs: [{ t: \"axis\", a: e.axis }, ...Object.values(e.init).map(term), ...Object.values(e.step).map(term), term(e.result), ...at.jobs],\n make: (docs) => {\n const axis = docs[0] as Json;\n const names = { init: namesOf(init, docs, 1), step: namesOf(step, docs, 1 + init.length) };\n const result = docs[after] as Json;\n const address = at.make(docs.slice(after + 1));\n const as = itemsOf(e.as);\n return this.#keep(typed(\"fold\", reads ? { ...names, axis, ...as, ...address, result } : { axis, ...as, ...names, result, ...address }), e);\n },\n };\n }\n case \"iterate\": {\n const init = Object.keys(e.init);\n const step = Object.keys(e.step);\n const until = e.until === undefined ? NONE : [term(e.until)];\n const after = init.length + step.length;\n const axis = limitAxis(e);\n return {\n jobs: [...Object.values(e.init).map(term), ...Object.values(e.step).map(term), ...until, term(e.result), ...(axis === undefined ? [] : [{ t: \"axis\" as const, a: axis }])],\n make: (docs) => {\n const first = { init: namesOf(init, docs, 0) };\n const limit = axis === undefined ? (e.limit as number) : this.#keep(typed(\"size\", { axis: docs[after + until.length + 1] as Json }), e);\n return typed(\"iterate\", {\n // The limit evaluates after the first values, so the order \"reads\" gives its reads after them.\n ...(reads ? { ...first, limit } : { limit, ...first }),\n step: namesOf(step, docs, init.length),\n ...(e.until === undefined ? {} : { until: docs[after] as Json }),\n result: docs[after + until.length] as Json,\n });\n },\n };\n }\n case \"fix\":\n return {\n jobs: [term(e.init), term(e.step)],\n make: (docs) => typed(\"fix\", { name: e.name, join: e.join, init: docs[0] as Json, step: docs[1] as Json }),\n };\n case \"last\":\n return { jobs: NONE, make: () => typed(\"last\", e.name) };\n case \"ext\":\n return { jobs: NONE, make: () => typed([\"ext\", ...e.kind.split(\".\")], e.data as Json) };\n }\n }\n\n /** This method gives the plan of the field `at` of `each` and `fold`: a reference from `self` with moves only (DOC.ADDRESS). */\n #at(at: readonly Move[] | undefined): { readonly jobs: readonly Job[]; readonly make: (docs: readonly Json[]) => { readonly at?: Envelope } } {\n // Stryker disable next-line ArrowFunction: a spread of no value adds no fields, as a spread of an empty record does\n if (at === undefined || at.length === 0) return { jobs: NONE, make: () => ({}) };\n return { jobs: at.map((m): Job => ({ t: \"move\", m })), make: (docs) => ({ at: path(\"self\", ...docs) }) };\n }\n\n /** This method gives the plan of a move. A computed key or position is an envelope (DOC.MOVE). */\n #move(m: Move): Plan {\n switch (m.t) {\n case \"key\":\n return typeof m.key === \"string\" ? this.#fixed([\"moves\", \"key\"], m.key) : { jobs: [envelope(m.key)], make: (docs) => typed([\"moves\", \"key\"], docs[0] as Json) };\n case \"index\":\n return typeof m.i === \"number\" ? this.#fixed([\"moves\", \"index\"], m.i) : { jobs: [envelope(m.i)], make: (docs) => typed([\"moves\", \"index\"], docs[0] as Json) };\n case \"offset\":\n return this.#fixed([\"moves\", \"offset\"], [...m.d]);\n case \"other\":\n case \"origin\":\n case \"parent\":\n return this.#fixed([\"moves\", m.t], null);\n }\n }\n\n #fixed(type: readonly string[], value: Json): Plan {\n return { jobs: NONE, make: () => typed(type, value) };\n }\n\n /** This method gives the plan of an axis (DOC.AXIS). */\n #axis(a: Axis): Plan {\n const type = [\"axes\", a.t];\n switch (a.t) {\n case \"neighbors\":\n return this.#fixed(type, { n: a.n });\n case \"window\":\n return this.#fixed(type, { from: a.from, to: a.to });\n case \"table\":\n return this.#fixed(type, { name: a.name });\n case \"list\":\n return { jobs: [term(a.list)], make: (docs) => typed(type, { list: docs[0] as Json }) };\n case \"reverse\":\n return { jobs: [{ t: \"axis\", a: a.axis }], make: (docs) => typed(type, { axis: docs[0] as Json }) };\n case \"where\":\n return { jobs: [{ t: \"axis\", a: a.axis }, term(a.test)], make: (docs) => typed(type, { axis: docs[0] as Json, test: docs[1] as Json }) };\n case \"all\":\n case \"others\":\n case \"other\":\n case \"children\":\n case \"ancestors\":\n case \"descendants\":\n case \"siblings\":\n case \"successors\":\n case \"predecessors\":\n case \"reachable\":\n return this.#fixed(type, {});\n }\n }\n}\n\n/**\n * This function writes the document of a valid expression. The root is always an envelope. It throws a `WriteStop` for\n * a literal without a JSON form in the mode `\"json\"`, and an exception of a getter of a literal value.\n */\nexport function writeDocument(e: Expr, opts: WriteOptions): Envelope {\n return new Writer(opts).write({ t: \"envelope\", e }) as Envelope;\n}\n","/**\n * The documents of Vex. A document is the form of an expression in coeval, the kernel of the family. Each term is an\n * envelope `{ type, value }`, and a reference is a path from a root. The rules are decision D12 of coeval:\n * <https://github.com/mark1russell7/coeval/blob/main/docs/DECISIONS.md>.\n *\n * | Expression | Document |\n * |---|---|\n * | `lit` | the JSON value of the literal. A value with the shape of an envelope is `{ \"type\": \"lit\", \"value\": x }`. |\n * | `ref` | `{ \"type\": \"ref\", \"value\": [\"self\", ...moves, ...fields] }` |\n * | `var` | `{ \"type\": \"ref\", \"value\": [\"names\", name] }` |\n * | `app` | `{ \"type\": [\"ops\", ...keys], \"value\": [...args] }`. The keys are the name of the op, split at its dots. |\n * | `let` | `{ \"type\": \"let\", \"value\": { \"bind\", \"body\" } }` |\n * | `fn` | `{ \"type\": \"fn\", \"value\": { \"params\", \"body\" } }` |\n * | `call` | `{ \"type\": \"call\", \"value\": { \"fn\": { \"type\": \"ref\", \"value\": [\"names\", name] }, \"args\" } }` |\n * | `rec` | `{ \"type\": \"record\", \"value\": { ...fields } }` |\n * | `each` | `{ \"type\": \"each\", \"value\": { \"axis\", \"as\"?, \"body\", \"at\"? } }` |\n * | `fold` | `{ \"type\": \"fold\", \"value\": { \"axis\", \"as\"?, \"init\", \"step\", \"result\", \"at\"? } }` |\n * | `iterate` | `{ \"type\": \"iterate\", \"value\": { \"limit\", \"init\", \"step\", \"until\"?, \"result\" } }`. A data limit is `{ \"type\": \"size\", \"value\": { \"axis\" } }`. |\n * | `fix` | `{ \"type\": \"fix\", \"value\": { \"name\", \"join\", \"init\", \"step\" } }` |\n * | `last` | `{ \"type\": \"last\", \"value\": name }` |\n * | `ext` | `{ \"type\": [\"ext\", ...keys], \"value\": data }` |\n * | a move | `{ \"type\": [\"moves\", kind], \"value\": v }` |\n * | an axis | `{ \"type\": [\"axes\", name], \"value\": { ...parameters } }` |\n *\n * The address `at` of `each` and `fold` is a reference from `self` with moves only. An empty address is no address.\n * The field `as` of `each` and `fold` names the item of a loop over the axis `list`, and then its index (AXIS.LIST.SCOPE).\n *\n * The kernel checks a document by the contracts of `VEX_WORLD` (DOC.CHECK). A contract gives the shape of a kind, the\n * data of its fields and the kinds of each position. Then `fromDocument` reads the expression. It checks only the grammar\n * of Vex: the steps of a reference, the address, the function of a call and the names of a loop. It also checks the\n * names of the items.\n */\nimport { check, isEnvelope, typeName, typePath, type Envelope, type Issue, type Key, type Machine } from \"@mark1russell7/coeval\";\nimport { decodeValue } from \"./codec.ts\";\nimport type { AnyDomain } from \"./domain.ts\";\nimport { isStackOverflow, vexError, type VexError } from \"./errors.ts\";\nimport { app, call, dataLimit, each, ext, fix, fn, fold, index, iterate, key, last, let_, lit, offset, origin, other, parent, rec, ref, shapeError, v, type Addr, type Axis, type DataLimit, type Expr, type FixJoin, type ItemNames, type Move, type Names } from \"./ir.ts\";\nimport { MAX_DOCUMENT_DEPTH, TERM_KINDS, vexChecker } from \"./kernel.ts\";\nimport { fail, ok, type Result } from \"./result.ts\";\nimport { itemNamesError } from \"./item-names.ts\";\nimport { WriteStop, writeDocument, type WriteOptions } from \"./write.ts\";\n\nexport type { Envelope, Json } from \"@mark1russell7/coeval\";\n\n/** The stop of a reading. The functions of this module throw it, and the top of the reading gives its error. */\nclass Stop {\n readonly error: VexError;\n\n constructor(error: VexError) {\n this.error = error;\n }\n}\n\n/** This function gives the location of a child: a JSON Pointer, with the escapes of RFC 6901. */\nconst into = (where: string, step: Key): string => `${where}/${String(step).replaceAll(\"~\", \"~0\").replaceAll(\"/\", \"~1\")}`;\n\n/** This function gives the JSON Pointer of a path of keys. */\nconst pointer = (keys: readonly Key[]): string => keys.reduce<string>(into, \"\");\n\n/** This function gives the message of a document that is not valid at `where`. */\nconst notValid = (where: string, reason: string): string => `the document is not valid at ${where === \"\" ? \"its root\" : `\"${where}\"`}: ${reason}`;\n\n/** This function stops the reading of a document that is not valid at `where`. */\nfunction bad(where: string, reason: string): never {\n throw new Stop(vexError(\"bad-expression\", notValid(where, reason)));\n}\n\n/** This function does a conversion. It gives its value, or the error of the conversion. It does not throw. */\nfunction attempt<T>(work: () => T, threw: string, deep: string): Result<T> {\n try {\n return ok(work());\n } catch (thrown) {\n if (thrown instanceof Stop || thrown instanceof WriteStop) return fail(thrown.error);\n if (isStackOverflow(thrown)) return fail(vexError(\"depth\", deep, { thrown }));\n return fail(vexError(\"threw\", threw, { thrown }));\n }\n}\n\n/**\n * This function tells if a value is a document: an envelope `{ type, value }`. A node of the tagged IR is not an\n * envelope, because it has the key `tag`. Thus `compile` and `evaluate` can take either one (DOC.ENTRY).\n */\nexport function isDocument(u: unknown): u is Envelope {\n return isEnvelope(u);\n}\n\n/**\n * This function gives the document of an expression (DOC.TERM). The root is always an envelope, so `compile` can tell a\n * document from the tagged IR. A literal value has the JSON form of IR.JSON, so a domain value needs `encode` (DOC.LITERAL).\n * An expression that is not valid, or a literal without a JSON form, gives the error `#VALUE!` (DOC.ERROR).\n */\n// Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain encodes no value\nexport function toDocument(e: Expr, domains: readonly AnyDomain[] = []): Result<Envelope> {\n const shape = shapeError(e);\n if (shape !== undefined) return fail(vexError(\"bad-expression\", shape));\n const options: WriteOptions = {\n domains,\n literals: \"json\",\n // Stryker disable next-line StringLiteral: the writer tests only the order \"reads\", and each other order is the order of DOC.CONSTRUCT\n order: \"document\",\n };\n // A getter of a literal value can throw, so the conversion is inside the attempt.\n return attempt(() => writeDocument(e, options), \"the expression has no document\", \"a literal value is too deep for the call stack of the engine\");\n}\n\n// The machine of the checks: the contracts of Vex, and the names of its evaluators and walkers, without their code.\nlet checker: Machine | undefined;\n\n/** This function gives the first problem of a document that the kernel finds by the contracts of Vex (DOC.CHECK). */\nfunction problemOf(doc: unknown): Issue | undefined {\n checker ??= vexChecker();\n // A bare value at the root is a literal. The names of a let, a function, a loop and the caller are free names.\n return check(checker, doc, { declaredType: \"lit\", names: \"any\" })[0];\n}\n\n/**\n * This function reads an expression from a document (DOC.TERM). It is the inverse of `toDocument`. The kernel checks\n * the document first (DOC.CHECK). A document that is not valid gives `#VALUE!` with its location, and a document nested\n * deeper than the kernel takes gives `#DEPTH!` (DOC.ERROR). The expression of a valid document is valid (EVAL.SHAPE).\n */\n// Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain decodes no value\nexport function fromDocument(doc: unknown, domains: readonly AnyDomain[] = []): Result<Expr> {\n const problem = attempt(() => problemOf(doc), \"the check of the document threw an exception\", \"the document is too deep for the call stack of the engine\");\n if (!problem.ok) return problem;\n const issue = problem.value;\n if (issue?.code === \"#DEPTH!\") return fail(vexError(\"depth\", `the document is nested deeper than ${String(MAX_DOCUMENT_DEPTH)} documents`));\n // Stryker disable next-line ArrayDeclaration: the check of coeval gives each issue the keys of its value\n if (issue !== undefined) return fail(vexError(\"bad-expression\", notValid(pointer(issue.at ?? []), issue.reason)));\n return attempt(() => new Reader(domains).term(doc, \"\"), \"a decoder of a domain threw an exception\", \"the document is too deep for the call stack of the engine\");\n}\n\n/** The kinds of the terms, as the first key of their type. */\nconst TERMS: ReadonlySet<string> = /* @__PURE__ */ new Set(/* @__PURE__ */ TERM_KINDS.map((k) => k[0] as string));\n\n/**\n * The reader of documents. The kernel checked the document, so each kind has the shape of its contract. The reader\n * checks the grammar of Vex, and its methods throw a `Stop` at the first part that is not valid.\n */\nclass Reader {\n readonly #domains: readonly AnyDomain[];\n\n constructor(domains: readonly AnyDomain[]) {\n this.#domains = domains;\n }\n\n /** This method reads a term. An envelope is a term, and another value is a literal (DOC.TERM). */\n term(u: unknown, where: string): Expr {\n return isDocument(u) ? this.#envelope(u, where) : lit(this.#value(u, where));\n }\n\n /** This method reads a term in an envelope. */\n #envelope(u: Envelope, where: string): Expr {\n const at = into(where, \"value\");\n const keys = this.#type(u, where);\n const head = String(keys[0]);\n // The contracts permit only the kinds of the terms in the position of a term. The root has no position. The check gave\n // the type a kind of the world, so the first key tells if the type is a term.\n if (!TERMS.has(head)) return bad(where, `the type \"${typeName(u.type)}\" is not a term of Vex`);\n if (head === \"ops\" || head === \"ext\") {\n const name = this.#name(keys.slice(1), into(where, \"type\"));\n return head === \"ops\" ? app(name, ...(u.value as readonly unknown[]).map((x, i) => this.term(x, into(at, i)))) : ext(name, u.value);\n }\n const f = u.value as Readonly<Record<string, unknown>>;\n switch (head) {\n case \"lit\":\n return lit(this.#value(u.value, at));\n case \"ref\":\n return this.#ref(u.value as readonly unknown[], at);\n case \"let\":\n return let_(this.#binds(f[\"bind\"], into(at, \"bind\")), this.term(f[\"body\"], into(at, \"body\")));\n case \"call\": {\n const name = this.#function(f[\"fn\"] as Envelope, into(at, \"fn\"));\n return call(name, ...(f[\"args\"] as readonly unknown[]).map((x, i) => this.term(x, into(into(at, \"args\"), i))));\n }\n case \"record\":\n return rec(this.#names(u.value, at));\n case \"each\": {\n const axis = this.#axis(f[\"axis\"] as Envelope, into(at, \"axis\"));\n const as = this.#items(f, axis, at);\n return each(axis, this.term(f[\"body\"], into(at, \"body\")), this.#address(f[\"at\"], into(at, \"at\")), as);\n }\n case \"fold\": {\n const [init, step] = this.#loop(f, at);\n const axis = this.#axis(f[\"axis\"] as Envelope, into(at, \"axis\"));\n const as = this.#items(f, axis, at);\n return fold(axis, init, step, this.term(f[\"result\"], into(at, \"result\")), this.#address(f[\"at\"], into(at, \"at\")), as);\n }\n case \"fix\":\n // The contract gives the name and one of the joins (DOC.CONSTRUCT).\n return fix(f[\"name\"] as string, f[\"join\"] as FixJoin, this.term(f[\"init\"], into(at, \"init\")), this.term(f[\"step\"], into(at, \"step\")));\n case \"last\":\n return last(u.value as string);\n default: {\n // iterate: the contract gives a whole number from 0 to MAX_ITERATIONS, or an envelope of a limit (ITERATE.LIMIT).\n const [init, step] = this.#loop(f, at);\n const until = f[\"until\"] === undefined ? undefined : this.term(f[\"until\"], into(at, \"until\"));\n return iterate(this.#limit(f[\"limit\"], into(at, \"limit\")), init, step, this.term(f[\"result\"], into(at, \"result\")), until);\n }\n }\n }\n\n /** This method gives the keys of the type of an envelope. A term of Vex has no header (DOC.TERM). */\n #type(u: Envelope, where: string): readonly Key[] {\n if (u.name !== undefined || u.own !== undefined) return bad(where, \"a term of Vex has no name and no own entries\");\n // The check found the kind of the type, so the type has no computed step.\n return typePath(u.type) as readonly Key[];\n }\n\n /** This method gives the name of an op or an extension: its keys, joined with dots (DOC.OPS, DOC.EXT). */\n #name(keys: readonly Key[], where: string): string {\n return keys.every((k) => typeof k === \"string\") ? keys.join(\".\") : bad(where, \"a key of the name is not a text\");\n }\n\n /** This method gives the value of a literal from its JSON form (DOC.LITERAL). */\n #value(u: unknown, where: string): unknown {\n const r = decodeValue(u, this.#domains);\n return r.ok ? r.value : bad(where, r.error.message);\n }\n\n /** This method reads a record of names and the term of each name. */\n #names(u: unknown, where: string): Names {\n return Object.fromEntries(Object.entries(u as Readonly<Record<string, unknown>>).map(([name, x]) => [name, this.term(x, into(where, name))]));\n }\n\n /** This method reads the bindings of a let. A binding can be a function (FN.BIND). */\n #binds(u: unknown, where: string): Names {\n return Object.fromEntries(\n Object.entries(u as Readonly<Record<string, unknown>>).map(([name, x]) => {\n const at = into(where, name);\n if (!isDocument(x) || typeName(x.type) !== \"fn\") return [name, this.term(x, at)];\n this.#type(x, at);\n const f = x.value as { readonly params: readonly string[]; readonly body: unknown };\n return [name, fn(f.params, this.term(f.body, into(into(at, \"value\"), \"body\")))];\n }),\n );\n }\n\n /** This method reads the names of a loop. Each name of `step` is a name of `init` (LOOP.NAMES). */\n #loop(f: Readonly<Record<string, unknown>>, at: string): readonly [Names, Names] {\n const init = this.#names(f[\"init\"], into(at, \"init\"));\n const step = this.#names(f[\"step\"], into(at, \"step\"));\n const extra = Object.keys(step).find((name) => !Object.hasOwn(init, name));\n return extra === undefined ? [init, step] : bad(into(into(at, \"step\"), extra), `the name \"${extra}\" of step is not a name of init`);\n }\n\n /**\n * This method reads the names `as` of a loop (AXIS.LIST.SCOPE). The contract gives a list of distinct texts. The\n * grammar of Vex needs one or two names, the axis `list` and no name of `init`.\n */\n /** This method reads the limit of `iterate`: a bare number, the envelope of a number, or the size of an axis (ITERATE.LIMIT.DATA). */\n #limit(u: unknown, where: string): number | DataLimit {\n if (!isEnvelope(u)) return u as number;\n const value = u.value as number | { readonly axis: Envelope };\n return typeof value === \"number\" ? value : dataLimit(this.#axis(value.axis, into(into(where, \"value\"), \"axis\")));\n }\n\n #items(f: Readonly<Record<string, unknown>>, axis: Axis, at: string): ItemNames | undefined {\n const reason = itemNamesError({ as: f[\"as\"], axis, init: f[\"init\"] });\n return reason === undefined ? (f[\"as\"] as ItemNames | undefined) : bad(into(at, \"as\"), reason);\n }\n\n /** This method reads a reference: the fields of `self` after its moves, or a name of `names` (DOC.REF). */\n #ref(path: readonly unknown[], where: string): Expr {\n const [root, ...steps] = path;\n // The check gives each reference a root that Vex reads: \"self\" or \"names\".\n if (root === \"names\") return steps.length === 1 && typeof steps[0] === \"string\" ? v(steps[0]) : bad(where, \"a reference to a name has one step: the name\");\n const moves: Move[] = [];\n const names: string[] = [];\n steps.forEach((step, i) => {\n const at = into(where, i + 1);\n if (typeof step === \"string\") names.push(step);\n else if (!isDocument(step)) bad(at, \"a step is not a text and not a move\");\n else if (names.length > 0) bad(at, \"a move comes after a field. Vex reads the fields at the end of the path\");\n else moves.push(this.#move(step, at));\n });\n return ref(names, moves);\n }\n\n /** This method reads the function of a call: a reference to a name (DOC.CALL). */\n #function(u: Envelope, where: string): string {\n const steps = u.value as readonly unknown[];\n return steps[0] === \"names\" && steps.length === 2 && typeof steps[1] === \"string\" ? steps[1] : bad(where, 'the function of a call is a reference to a name: { \"type\": \"ref\", \"value\": [\"names\", name] }');\n }\n\n /** This method reads the field `at` of `each` and `fold`: a reference from `self` with moves only (DOC.ADDRESS). */\n #address(u: unknown, where: string): Addr | undefined {\n if (u === undefined) return undefined;\n const e = this.#envelope(u as Envelope, where);\n return e.tag === \"ref\" && e.path.length === 0 ? (e.at ?? []) : bad(where, 'the address is a reference from \"self\" with moves only: { \"type\": \"ref\", \"value\": [\"self\", ...moves] }');\n }\n\n /**\n * This method reads a move (DOC.MOVE). The value of `key` and `index` is a term: a text key and a number position are\n * fixed, and another term is computed. The check gave the other moves their values.\n */\n #move(u: Envelope, where: string): Move {\n const kind = String(this.#type(u, where)[1]);\n const at = into(where, \"value\");\n const value = u.value;\n switch (kind) {\n case \"key\":\n return typeof value === \"string\" ? key(value) : key(this.term(value, at));\n case \"index\":\n return typeof value === \"number\" ? index(value) : index(this.term(value, at));\n case \"offset\":\n return offset(...(value as readonly number[]));\n case \"other\":\n return other;\n case \"origin\":\n return origin;\n default:\n return parent;\n }\n }\n\n /** This method reads an axis (DOC.AXIS). The check gave it the parameters of its kind. */\n #axis(u: Envelope, where: string): Axis {\n const name = String(this.#type(u, where)[1]);\n const at = into(where, \"value\");\n const f = u.value as Readonly<Record<string, unknown>>;\n switch (name) {\n case \"list\":\n return { t: name, list: this.term(f[\"list\"], into(at, \"list\")) };\n case \"reverse\":\n return { t: name, axis: this.#axis(f[\"axis\"] as Envelope, into(at, \"axis\")) };\n case \"where\":\n return { t: name, axis: this.#axis(f[\"axis\"] as Envelope, into(at, \"axis\")), test: this.term(f[\"test\"], into(at, \"test\")) };\n default:\n return { t: name, ...f } as Axis;\n }\n }\n}\n","/**\n * The check of the steps of `fix` (FIX.MONOTONE). The check proves from the kinds of the ops that the step of each `fix`\n * does not fall when the last round rises. The rounds then reach the least fixed point above `init`, and the dual\n * for `and` and `min`. A program without a proof does not run (fail closed).\n *\n * The proof follows the reads of `last` through the program. Each part has a direction: it does not depend on the last\n * round, it follows the last round, or it moves against the last round. An op states the direction of each argument\n * as data (FIX.OPS). A part that the rules do not cover and that reads `last` ends the check with a reason.\n */\nimport type { AnyDomain, Monotone, OpSpec, ReturnKind } from \"./domain.ts\";\nimport { joinKind } from \"./fix.ts\";\nimport { addrExprs, axisExprs, children, type Axis, type Expr, type ExprOf } from \"./ir.ts\";\n\n/** The options of the check: the domains and the functions of the host, as the options of a compilation give them. */\nexport interface MonotoneOptions {\n readonly domains?: readonly AnyDomain[];\n readonly fns?: Readonly<Record<string, unknown>>;\n}\n\n/** The direction of a part: 1 follows the last round, -1 moves against it, and 0 does not read it. */\ntype Direction = -1 | 0 | 1;\n\n/** What the check knows of a part: its direction, and the kind of its value if the check knows it. */\ninterface Flow {\n readonly dir: Direction;\n readonly tag: \"boolean\" | \"number\" | \"list\" | undefined;\n}\n\n/** A rule of an op: the direction of each argument, and the kind of the result. */\ninterface Rule {\n readonly args: readonly Monotone[];\n readonly returns: ReturnKind | undefined;\n}\n\n/** The names of a program and the flow of each. A name that the map does not have does not read the last round. */\ntype Names = ReadonlyMap<string, Flow>;\n\n/** The end of a proof. The methods of `Proof` throw it, and `monotoneError` gives its reason. */\nclass Refusal {\n readonly reason: string;\n\n constructor(reason: string) {\n this.reason = reason;\n }\n}\n\nconst STEADY: Flow = { dir: 0, tag: undefined };\n\n/**\n * The rules of the list ops. The items of a list come from an axis that does not read the last round. Thus the set of\n * the items stays the same in each round. Each of these ops ignores the order of the items. `sum` has no rule. The\n * rounding of a sum of floats depends on the order of the items (FIX.ORDER).\n */\nconst LIST_RULES: Readonly<Record<string, Rule>> = {\n any: { args: [\"up\"], returns: \"boolean\" },\n all: { args: [\"up\"], returns: \"boolean\" },\n none: { args: [\"down\"], returns: \"boolean\" },\n min: { args: [\"up\"], returns: \"number\" },\n max: { args: [\"up\"], returns: \"number\" },\n};\n\n/** This function gives the flow of a literal. The kind of a number or a boolean is known. */\nfunction steadyValue(value: unknown): Flow {\n if (typeof value === \"number\") return { dir: 0, tag: \"number\" };\n return typeof value === \"boolean\" ? { dir: 0, tag: \"boolean\" } : STEADY;\n}\n\n/** This function gives the axis inside the `where` axes of an axis. */\nconst baseOf = (a: Axis): Axis => (a.t === \"where\" ? baseOf(a.axis) : a);\n\n/** This function gives the names without the names that a part of the program hides. */\nfunction without(names: Names, hidden: readonly string[]): Names {\n const out = new Map(names);\n for (const name of hidden) out.delete(name);\n return out;\n}\n\n/** The proof of the step of one `fix`. */\nclass Proof {\n readonly #fix: ExprOf<\"fix\">;\n readonly #domains: readonly AnyDomain[];\n readonly #fns: Readonly<Record<string, unknown>>;\n /** This field is `true` inside a `fix` of the same name: a read there reads that `fix`. */\n #hidden = false;\n\n constructor(fix: ExprOf<\"fix\">, opts: MonotoneOptions) {\n this.#fix = fix;\n this.#domains = opts.domains ?? [];\n this.#fns = opts.fns ?? {};\n }\n\n /** This method proves the step. It throws a refusal, or it returns. */\n prove(): void {\n if (this.#flow(this.#fix.step, new Map()).dir < 0) this.#refuse(\"it moves against the last round\");\n }\n\n #refuse(why: string): never {\n throw new Refusal(`the step of the \"fix\" \"${this.#fix.name}\" does not move one way: ${why}`);\n }\n\n #flow(e: Expr, names: Names): Flow {\n switch (e.tag) {\n case \"lit\":\n return steadyValue(e.value);\n case \"var\":\n return names.get(e.name) ?? STEADY;\n case \"last\":\n return e.name === this.#fix.name && !this.#hidden ? { dir: 1, tag: joinKind(this.#fix.join) } : STEADY;\n case \"let\": {\n const bound = new Map(names);\n for (const [name, x] of Object.entries(e.bind)) bound.set(name, this.#flow(x, names));\n return this.#flow(e.body, bound);\n }\n case \"fn\":\n return this.#flow(e.body, without(names, e.params));\n case \"call\":\n if ((names.get(e.fn)?.dir ?? 0) !== 0) this.#refuse(`the function \"${e.fn}\" reads the last round`);\n return this.#steady(e.args, names, `an argument of the function \"${e.fn}\"`);\n case \"each\":\n return this.#each(e, names);\n case \"app\":\n return this.#app(e, names);\n case \"fix\":\n return this.#inner(e, names);\n // The fields of a record, the moves of a reference and the parts of a fold and of an iterate have no rule.\n case \"rec\":\n case \"ref\":\n case \"fold\":\n case \"iterate\":\n case \"ext\":\n return this.#steady(children(e), names, `a node \"${e.tag}\"`);\n }\n }\n\n /** This method refuses a part that reads the last round. Only an op or a loop with a rule can take such a part. */\n #steady(parts: readonly Expr[], names: Names, what: string): Flow {\n for (const x of parts) if (this.#flow(x, names).dir !== 0) this.#refuse(`${what} reads the last round`);\n return STEADY;\n }\n\n /**\n * This method reads a `fix` inside the step. Its rounds end in each round of the outer `fix`. Thus a column of the\n * outer `fix` as an input of the inner `fix` has no proof.\n */\n #inner(e: ExprOf<\"fix\">, names: Names): Flow {\n this.#steady([e.init], names, `the start of the \"fix\" \"${e.name}\"`);\n const outer = this.#hidden;\n this.#hidden ||= e.name === this.#fix.name;\n this.#steady([e.step], names, `the step of the \"fix\" \"${e.name}\"`);\n this.#hidden = outer;\n return { dir: 0, tag: joinKind(e.join) };\n }\n\n /** This method reads an `each`. The targets must not read the last round, so each round has the same items. */\n #each(e: ExprOf<\"each\">, names: Names): Flow {\n this.#steady([...axisExprs(e.axis), ...addrExprs(e.at)], names, \"an axis\");\n const body = this.#flow(e.body, without(names, e.as ?? []));\n if (body.dir !== 0 && baseOf(e.axis).t === \"table\") this.#refuse(\"the axis table leaves the rows of the column\");\n return { dir: body.dir, tag: \"list\" };\n }\n\n #app(e: ExprOf<\"app\">, names: Names): Flow {\n const flows = e.args.map((x) => this.#flow(x, names));\n const [head] = flows;\n switch (e.op) {\n case \"if\":\n if ((head?.dir ?? 0) !== 0) this.#refuse('the test of \"if\" reads the last round');\n return this.#joined(flows.slice(1), e.op);\n case \"and\":\n case \"or\":\n case \"ifError\":\n return this.#joined(flows, e.op);\n }\n if (flows.every((x) => x.dir === 0)) return STEADY;\n const rule = this.#rule(e.op, head?.tag);\n const moves = flows.map((x, i): number => {\n const move = rule.args[i];\n if (x.dir !== 0 && move === undefined) this.#refuse(`the argument ${String(i + 1)} of the op \"${e.op}\" reads the last round`);\n return move === \"down\" ? -x.dir : x.dir;\n });\n const { returns } = rule;\n return { dir: this.#one(moves, e.op), tag: returns === \"number\" || returns === \"boolean\" ? returns : undefined };\n }\n\n /** This method gives the flow of the branches of a form. Each branch can be the result. */\n #joined(flows: readonly Flow[], op: string): Flow {\n const [head] = flows;\n const dir = this.#one(\n flows.map((x) => x.dir),\n op,\n );\n return { dir, tag: flows.every((x) => x.tag === head?.tag) ? head?.tag : undefined };\n }\n\n /** This method gives the one direction of the moves of a node. Two directions have no proof. */\n #one(moves: readonly number[], op: string): Direction {\n const up = moves.some((m) => m > 0);\n if (up && moves.some((m) => m < 0)) this.#refuse(`the op \"${op}\" reads the last round in both directions`);\n return up ? 1 : moves.some((m) => m < 0) ? -1 : 0;\n }\n\n /**\n * This method gives the rule of an op for a receiver of a known kind, in the order of the interpreter. A list op on a\n * list comes first, then the domains in order, then a function of the host. A receiver of another kind has no rule.\n */\n #rule(op: string, tag: Flow[\"tag\"]): Rule {\n if (tag === undefined) this.#refuse(`the kind of the first argument of the op \"${op}\" does not decide the op. Put an argument of a known kind first`);\n if (tag === \"list\") return Object.hasOwn(LIST_RULES, op) ? (LIST_RULES[op] as Rule) : this.#noRule(op);\n const found: Rule[] = [];\n for (const d of this.#domains) {\n if (d.primitive !== undefined && d.primitive !== tag) continue;\n const spec = Object.hasOwn(d.ops, op) ? (d.ops[op] as OpSpec<unknown>) : undefined;\n if (spec?.fn === undefined) continue;\n found.push(this.#declared(spec, op));\n if (d.primitive === tag) return this.#same(found, op);\n }\n if (Object.hasOwn(this.#fns, op)) found.push(this.#declared(this.#fns[op] as Pick<OpSpec<unknown>, \"monotone\" | \"returns\">, op));\n return found.length > 0 ? this.#same(found, op) : this.#noRule(op);\n }\n\n #declared(spec: Pick<OpSpec<unknown>, \"monotone\" | \"returns\">, op: string): Rule {\n return spec.monotone === undefined ? this.#noRule(op) : { args: spec.monotone, returns: spec.returns };\n }\n\n /** This method gives the rule of the ops that can apply. They must have the same rule, because the data decides among them. */\n #same(rules: readonly Rule[], op: string): Rule {\n const first = rules[0] as Rule;\n if (rules.some((r) => r.args.join() !== first.args.join())) this.#refuse(`the op \"${op}\" has two rules, and the data decides among them`);\n return first;\n }\n\n #noRule(op: string): never {\n this.#refuse(`the op \"${op}\" has no rule of direction`);\n }\n}\n\n/** This function walks a program. `open` has the names of the `fix` nodes around a node (FIX.LAST). */\nfunction walk(e: Expr, open: ReadonlySet<string>, opts: MonotoneOptions): void {\n if (e.tag === \"last\" && !open.has(e.name)) throw new Refusal(`the read \"last\" of \"${e.name}\" has no \"fix\" of that name around it`);\n if (e.tag !== \"fix\") {\n for (const x of children(e)) walk(x, open, opts);\n return;\n }\n walk(e.init, open, opts);\n walk(e.step, new Set([...open, e.name]), opts);\n new Proof(e, opts).prove();\n}\n\n/** This function gives the reason that a program breaks a rule of `fix`, or `undefined` for a program that keeps them (FIX.LAST, FIX.MONOTONE). */\nexport function monotoneError(e: Expr, opts: MonotoneOptions): string | undefined {\n try {\n walk(e, new Set(), opts);\n return undefined;\n } catch (thrown) {\n // Stryker disable next-line ConditionalExpression: only a Refusal comes here, and a mutant that always takes it reads its field\n if (thrown instanceof Refusal) return thrown.reason;\n throw thrown;\n }\n}\n","/**\n * The check of sizes in the loops of a program (LOOP.SIZE). A step of `fold` or `iterate` gives each name a new value\n * from the values before the step. When a new value holds two copies of the old lists, the size can double at each step.\n * For example, a fold over 12 records with the step `append(xs, xs)` makes a list of 4096 items. The check finds such\n * steps before a run, from the size rules of the ops (LOOP.SIZE.OPS).\n *\n * The check is an abstract interpretation. It gives each value five measures: its size, its count, its inner count (the\n * sum of the counts of the values of its items), the size of its largest item, and its largest part (the largest item of\n * an item). Each measure is a bound: the largest value of some sums. A sum is a constant, and the measures of the old\n * values of the loops, each with a coefficient. A coefficient tells one use, a fixed number of uses, more uses, or no\n * bound. The check also keeps the kinds of each value, because the kind of the receiver selects the op.\n *\n * The check reads a program in two ways (LOOP.SIZE.READINGS). The first reading counts a read of a part of a value as a\n * use of the whole value. The second reading uses the bound of the part. Each reading gives a sound bound, so one\n * reading that accepts a program makes the program valid.\n */\nimport { isOpName, listItemKind, type AnyDomain, type OpSpec, type ReturnKind, type SizeMeasure, type SizeRule, type SizeTerm, type SizeUse } from \"./domain.ts\";\nimport { addrExprs, children, limitAxis, listOf, type Axis, type Expr, type ExprOf, type ItemNames } from \"./ir.ts\";\nimport { joinKind as kindOfJoin } from \"./fix.ts\";\nimport { isListOp, isVexList, LIST_SIZES, type ListOp } from \"./list.ts\";\n\n/** The options of the check of sizes: the domains and the functions of the host, as for `compile`. */\nexport interface SizeOptions {\n readonly domains?: readonly AnyDomain[];\n /** The functions of the host. A function with the property `size` has that size rule, and another function has none. */\n readonly fns?: Readonly<Record<string, unknown>>;\n}\n\n/** A coefficient: 1 for one use, 2 for a fixed number of uses, 3 for more uses, and 4 for no bound. */\ntype Coef = 1 | 2 | 3 | 4;\n\n/** A sum: a constant (`Infinity` for a constant without a known value) and a coefficient for each variable. */\ninterface Sum {\n readonly base: number;\n readonly terms: ReadonlyMap<string, Coef>;\n}\n\n/** A bound: the largest value of some sums (LOOP.SIZE.BRANCH). A bound has at least one sum, and no sum covers another. */\ntype Form = readonly Sum[];\n\n/** The kinds of a value: a set of tags, or `undefined` for each kind. `item` is the kind of the items of a list. */\ninterface Kind {\n readonly tags: ReadonlySet<string> | undefined;\n readonly item?: Kind;\n}\n\n/**\n * The measures and the kinds of a value. `long` tells that a key in the value can be long. A key of a record, of a\n * position or of a literal has a fixed bound. A key of `group` is a value of the program.\n */\ninterface Shape {\n readonly size: Form;\n readonly count: Form;\n readonly inner: Form;\n readonly item: Form;\n readonly part: Form;\n readonly kind: Kind;\n readonly long: boolean;\n}\n\nconst NO_TERMS: ReadonlyMap<string, Coef> = new Map();\nconst NONE: Form = [{ base: 0, terms: NO_TERMS }];\nconst constant = (base: number): Form => (base === 0 ? NONE : [{ base, terms: NO_TERMS }]);\nconst SOME = constant(Infinity);\nconst MEASURES: readonly SizeMeasure[] = [\"size\", \"count\", \"inner\", \"item\", \"part\"];\n/** The most sums of a bound. A bound with more sums becomes one sum, so the work of the check has a limit. */\nconst MOST_SUMS = 8;\n\nconst ANY: Kind = { tags: undefined };\nconst NO_KIND: Kind = { tags: new Set() };\nconst kindOf = (tag: string): Kind => ({ tags: new Set([tag]) });\nconst listKind = (item: Kind, tag = \"list\"): Kind => ({\n tags: new Set([tag]),\n item,\n});\nconst NUMBER = kindOf(\"number\");\nconst BOOLEAN = kindOf(\"boolean\");\nconst STRING = kindOf(\"string\");\nconst SCALAR: Kind = { tags: new Set([\"number\", \"boolean\"]) };\n/** The tags of the values that have no methods: an op of a domain needs its function for them. */\nconst PRIMITIVES: ReadonlySet<string> = new Set([\"number\", \"string\", \"boolean\", \"null\"]);\n/** The tags of the values without a size. */\nconst SCALARS: ReadonlySet<string> = new Set([\"number\", \"boolean\", \"null\"]);\n\n/** The shape of a value without a size, and the shape of a value with a fixed bound. */\nconst zero = (kind: Kind): Shape => ({\n size: NONE,\n count: NONE,\n inner: NONE,\n item: NONE,\n part: NONE,\n kind,\n long: false,\n});\nconst fixed = (kind: Kind): Shape => ({\n size: SOME,\n count: SOME,\n inner: SOME,\n item: SOME,\n part: SOME,\n kind,\n long: false,\n});\n\nconst isZero = (s: Sum): boolean => s.base === 0 && s.terms.size === 0;\nconst isNone = (f: Form): boolean => f.every(isZero);\nconst term = (v: string, c: Coef): Form => [{ base: 0, terms: new Map([[v, c]]) }];\n\n/** This function tells if the sum `a` is at least the sum `b` for each value of the variables. */\nconst covers = (a: Sum, b: Sum): boolean => a.base >= b.base && [...b.terms].every(([v, c]) => (a.terms.get(v) ?? 0) >= c);\n\n/** This function gives one sum that is at least each sum of a bound: the largest constant and the largest coefficients. */\nfunction cover(f: Form): Sum {\n const terms = new Map<string, Coef>();\n let base = 0;\n for (const s of f) {\n base = Math.max(base, s.base);\n for (const [v, c] of s.terms) terms.set(v, Math.max(terms.get(v) ?? 0, c) as Coef);\n }\n return { base, terms };\n}\n\n/** This function gives the bound of some sums, without a sum that another sum covers, and with at most `MOST_SUMS` sums. */\nfunction bound(sums: readonly Sum[]): Form {\n let out: readonly Sum[] = [];\n for (const s of sums) if (!out.some((o) => covers(o, s))) out = [...out.filter((o) => !covers(s, o)), s];\n if (out.length > MOST_SUMS) return [cover(out)];\n return out.length === 0 ? NONE : out;\n}\n\n/** This function gives the sum of two sums: the coefficients of a variable in both sums give more uses. */\nfunction add(a: Sum, b: Sum): Sum {\n const terms = new Map(a.terms);\n for (const [v, c] of b.terms) {\n const o = terms.get(v);\n terms.set(v, o === undefined ? c : (Math.max(3, o, c) as Coef));\n }\n return { base: a.base + b.base, terms };\n}\n\n/** This function gives the bound of a sum of two values. */\nfunction plus(a: Form, b: Form): Form {\n if (isNone(a)) return b;\n if (isNone(b)) return a;\n return bound(a.flatMap((x) => b.map((y) => add(x, y))));\n}\n\n/** This function gives the bound of the larger of two values. */\nconst join = (a: Form, b: Form): Form => bound([...a, ...b]);\n\n/** This function gives the bound of a union of two values: each variable with its largest coefficient, and the sum of the constants. */\nconst union = (a: Form, b: Form): Form => {\n const all = cover([...a, ...b]);\n return [{ base: cover(a).base + cover(b).base, terms: all.terms }];\n};\n\n/** This function gives the bound of `k` uses of a bound. */\nfunction scale(f: Form, k: 0 | Coef): Form {\n if (k === 0) return NONE;\n if (k === 1) return f;\n return bound(f.map((s) => ({ base: s.base === 0 ? 0 : Infinity, terms: new Map([...s.terms].map(([v, c]) => [v, Math.max(c, k) as Coef])) })));\n}\n\n/** This function gives a bound of a product of two sums. A product of two variables gives more uses of both. */\nfunction multiply(a: Sum, b: Sum): Form {\n if (isZero(a) || isZero(b)) return NONE;\n if (a.terms.size === 0) return a.base <= 1 ? [b] : scale([b], 2);\n if (b.terms.size === 0) return b.base <= 1 ? [a] : scale([a], 2);\n return scale([add(a, b)], 3);\n}\n\n/** This function gives a bound of a product of two values. */\nconst times = (a: Form, b: Form): Form => bound(a.flatMap((x) => b.flatMap((y) => multiply(x, y))));\n\n/** This function puts a bound in the place of each variable that `sigma` knows. */\nfunction subst(f: Form, sigma: (v: string) => Form | undefined): Form {\n const one = (s: Sum): Form => {\n let out = constant(s.base);\n for (const [v, c] of s.terms) {\n const u = sigma(v);\n out = plus(out, u === undefined ? term(v, c) : scale(u, c));\n }\n return out;\n };\n return bound(f.flatMap(one));\n}\n\n/** This function gives the sum without the variables that `drop` names, and the coefficients of these variables. */\nfunction split(s: Sum, drop: (v: string) => boolean): { readonly rest: Sum; readonly dropped: ReadonlyMap<string, Coef> } {\n const terms = new Map<string, Coef>();\n const dropped = new Map<string, Coef>();\n for (const [v, c] of s.terms) (drop(v) ? dropped : terms).set(v, c);\n return { rest: { base: s.base, terms }, dropped };\n}\n\nconst sameSum = (a: Sum, b: Sum): boolean => a.base === b.base && a.terms.size === b.terms.size && [...a.terms].every(([v, c]) => b.terms.get(v) === c);\nconst sameForm = (a: Form, b: Form): boolean => a.length === b.length && a.every((x) => b.some((y) => sameSum(x, y)));\n\n/** This function tells if a kind can be a list or an array. */\nconst listy = (k: Kind): boolean => k.tags === undefined || k.tags.has(\"list\") || k.tags.has(\"array\");\n\n/** This function gives the kind of the items of a value: no kind for a value that is not a list. */\nconst itemOf = (k: Kind): Kind => (listy(k) ? (k.item ?? ANY) : NO_KIND);\n\n/** This function gives the kind of a value of two kinds. */\nfunction joinKind(a: Kind, b: Kind): Kind {\n if (a.tags === undefined || b.tags === undefined) return ANY;\n const tags = new Set([...a.tags, ...b.tags]);\n return listy(a) || listy(b) ? { tags, item: joinKind(itemOf(a), itemOf(b)) } : { tags };\n}\n\n/** This function tells if each value of the kind `a` has the kind `b`. */\nfunction within(a: Kind, b: Kind): boolean {\n if (b.tags === undefined) return true;\n if (a.tags === undefined) return false;\n for (const t of a.tags) if (!b.tags.has(t)) return false;\n return !listy(a) || within(itemOf(a), itemOf(b));\n}\n\nconst isText = (k: Kind | undefined): boolean => k?.tags !== undefined && k.tags.size === 1 && k.tags.has(\"string\");\n\nconst joinShape = (a: Shape, b: Shape): Shape => ({\n size: join(a.size, b.size),\n count: join(a.count, b.count),\n inner: join(a.inner, b.inner),\n item: join(a.item, b.item),\n part: join(a.part, b.part),\n kind: joinKind(a.kind, b.kind),\n long: a.long || b.long,\n});\n\n/** This function puts a bound in the place of each variable that `sigma` knows, in each measure of a shape. */\nconst substShape = (s: Shape, sigma: (v: string) => Form | undefined): Shape => ({\n ...s,\n size: subst(s.size, sigma),\n count: subst(s.count, sigma),\n inner: subst(s.inner, sigma),\n item: subst(s.item, sigma),\n part: subst(s.part, sigma),\n});\n\n/** This function gives the coefficient of a use. */\nfunction coefOf(use: SizeUse): 0 | Coef {\n switch (use) {\n case 0:\n case \"number\":\n return 0;\n case 1:\n return 1;\n case \"scaled\":\n case \"copies\":\n case \"text\":\n return 2;\n case \"many\":\n case \"each\":\n case \"limit\":\n return 3;\n case \"unbounded\":\n return 4;\n }\n}\n\n/** The letters of the variables of the measures. */\nconst LETTERS: Readonly<Record<SizeMeasure, string>> = { size: \"s\", count: \"c\", inner: \"n\", item: \"t\", part: \"p\" };\n/** The name of the variable of a measure of a value with the number `id`, for example `s1` for its size. */\nconst variable = (m: SizeMeasure, id: number): string => `${LETTERS[m]}${String(id)}`;\n/** The shape of a value with a variable for each measure. A number, a boolean and null have no size. */\nconst shapeOfVar = (id: number, kind: Kind, long: boolean): Shape =>\n kind.tags !== undefined && [...kind.tags].every((t) => SCALARS.has(t))\n ? zero(kind)\n : {\n size: term(variable(\"size\", id), 1),\n count: term(variable(\"count\", id), 1),\n inner: term(variable(\"inner\", id), 1),\n item: term(variable(\"item\", id), 1),\n part: term(variable(\"part\", id), 1),\n kind,\n long,\n };\n\n/** The value of a name in the check: a shape, or the summary of a function (FN.BIND). */\ntype Entry =\n | { readonly t: \"value\"; readonly shape: Shape }\n | {\n readonly t: \"fn\";\n readonly params: readonly number[];\n readonly result: Shape;\n };\ntype Env = ReadonlyMap<string, Entry>;\n\n/** A refusal of the check. The check throws it, and `sizeError` gives its message. */\nclass Refusal {\n readonly message: string;\n constructor(message: string) {\n this.message = message;\n }\n}\n\n/** The literal number of an argument, if the argument is a literal number. */\nconst literalNumber = (e: Expr | undefined): number | undefined => (e?.tag === \"lit\" && typeof e.value === \"number\" ? e.value : undefined);\n\n/** The tag of the values of a domain: its primitive kind, or its name. */\nconst tagOf = (d: AnyDomain): string => d.primitive ?? `d:${d.name}`;\n\n/** This function tells if a domain accepts a value with a tag: surely, maybe or no. `undefined` is each tag. */\nfunction accepts(d: AnyDomain, tag: string | undefined): \"sure\" | \"maybe\" | \"no\" {\n if (tag === undefined) return \"maybe\";\n if (tag === tagOf(d)) return \"sure\";\n // KIND.PRIMITIVE: a domain with a primitive kind accepts each value of that type and no other value.\n if (d.primitive !== undefined) return tag.startsWith(\"d:\") ? \"maybe\" : \"no\";\n return \"maybe\";\n}\n\n/** The number of the nodes that the check reads with the kinds of the names of the loops, before it uses each kind. */\nconst BUDGET = 50_000;\n\n/** The check of one program. It keeps the shape of each node, to name the op of a refusal. */\nclass Checker {\n readonly #domains: readonly AnyDomain[];\n readonly #fns: Readonly<Record<string, unknown>> | undefined;\n readonly #shapes = new Map<Expr, Shape>();\n readonly #open = new Map<Expr, boolean>();\n /** With `true`, the check keeps the largest part as a measure and reads the rules `byParts` (LOOP.SIZE.READINGS). */\n readonly #parts: boolean;\n #next = 0;\n #visits = 0;\n\n constructor(opts: SizeOptions, parts: boolean) {\n this.#domains = opts.domains ?? [];\n this.#fns = opts.fns;\n this.#parts = parts;\n }\n\n shape(e: Expr, env: Env): Shape {\n this.#visits++;\n const found = this.#shape(e, env);\n // The first reading has no measure under the largest item, so the largest part of a value is its largest item.\n const s = this.#parts ? found : { ...found, part: found.item };\n this.#shapes.set(e, s);\n return s;\n }\n\n #fresh(): number {\n return this.#next++;\n }\n\n #shape(e: Expr, env: Env): Shape {\n switch (e.tag) {\n case \"lit\":\n return this.#literal(e.value);\n case \"ref\":\n for (const x of addrExprs(e.at)) this.shape(x, env);\n return fixed(ANY);\n case \"var\": {\n const entry = env.get(e.name);\n // A free name is a variable of the caller, so its value does not change in a loop. A function is not a value.\n return entry === undefined ? fixed(ANY) : entry.t === \"value\" ? entry.shape : zero(NO_KIND);\n }\n case \"ext\":\n return fixed(ANY);\n case \"rec\": {\n const fields = Object.values(e.fields).map((x) => this.shape(x, env));\n const size = fields.reduce((acc, x) => plus(acc, x.size), SOME);\n // LOOP.SIZE.PART: the items of a record are its fields, so one field gives the largest item.\n const item = fields.reduce((acc, x) => join(acc, x.size), NONE);\n const part = fields.reduce((acc, x) => join(acc, x.item), NONE);\n return { ...fixed(kindOf(\"object\")), size, item, part, long: fields.some((x) => x.long) };\n }\n case \"let\":\n return this.#let(e, env);\n case \"call\":\n return this.#call(e, env);\n case \"app\":\n return this.#app(e, env);\n case \"each\":\n return this.#each(e, env);\n case \"fold\":\n case \"iterate\":\n return this.#loop(e, env);\n case \"fix\":\n // A column gives a boolean or a number, so a list of the program cannot grow through it.\n this.shape(e.init, env);\n this.shape(e.step, env);\n return zero(kindOfJoin(e.join) === \"boolean\" ? BOOLEAN : NUMBER);\n case \"last\":\n return zero(SCALAR);\n case \"fn\":\n return zero(NO_KIND);\n }\n }\n\n /** This method gives the shape of a literal value: a constant, and its kind. */\n #literal(value: unknown): Shape {\n if (typeof value === \"number\") return zero(NUMBER);\n if (typeof value === \"boolean\") return zero(BOOLEAN);\n if (value === null || value === undefined) return zero(kindOf(\"null\"));\n if (typeof value === \"string\") {\n const length = constant(value.length);\n return { ...zero(STRING), size: length, item: length, part: length };\n }\n if (isVexList(value)) {\n const item = value.items.reduce((k, it) => (it.result.ok ? joinKind(k, this.#literal(it.result.value).kind) : k), NO_KIND);\n return { ...fixed(listKind(item)), count: constant(value.items.length) };\n }\n if (Array.isArray(value))\n return {\n ...fixed(\n listKind(\n value.reduce((k: Kind, x: unknown) => joinKind(k, this.#literal(x).kind), NO_KIND),\n \"array\",\n ),\n ),\n count: constant(value.length),\n };\n const d = this.#domains.find((x) => {\n try {\n return x.is(value);\n } catch {\n return false;\n }\n });\n return fixed(d === undefined ? kindOf(\"object\") : kindOf(tagOf(d)));\n }\n\n #let(e: ExprOf<\"let\">, env: Env): Shape {\n const inner = new Map(env);\n // FN.TOTAL: a binding does not see the other bindings of its let.\n for (const [name, b] of Object.entries(e.bind)) {\n if (b.tag === \"fn\") {\n // FN.CALL: the check reads the body one time, with a variable for each parameter. A call puts the shapes of\n // its arguments in the place of the variables.\n const params = b.params.map((p) => [p, this.#fresh()] as const);\n const fenv = new Map(env);\n for (const [p, id] of params) fenv.set(p, { t: \"value\", shape: shapeOfVar(id, ANY, true) });\n inner.set(name, { t: \"fn\", params: params.map(([, id]) => id), result: this.shape(b.body, fenv) });\n } else inner.set(name, { t: \"value\", shape: this.shape(b, env) });\n }\n return this.shape(e.body, inner);\n }\n\n #call(e: ExprOf<\"call\">, env: Env): Shape {\n const args = e.args.map((a) => this.shape(a, env));\n const entry = env.get(e.fn);\n // FN.ARGS: a call of a value, of a missing name or with another number of arguments gives an error.\n if (entry?.t !== \"fn\" || entry.params.length !== args.length) return zero(NO_KIND);\n const bindings = new Map<string, Form>();\n entry.params.forEach((id, i) => {\n for (const m of MEASURES) bindings.set(variable(m, id), (args[i] as Shape)[m]);\n });\n const sigma = (v: string): Form | undefined => bindings.get(v);\n return { ...substShape(entry.result, sigma), long: entry.result.long || args.some((a) => a.long) };\n }\n\n #app(e: ExprOf<\"app\">, env: Env): Shape {\n const args = e.args.map((a) => this.shape(a, env));\n switch (e.op) {\n case \"if\":\n case \"ifError\": {\n // FORM.IF: the test does not add to the size. A missing argument gives an error, which has no size.\n const outs = e.op === \"if\" ? args.slice(1, 3) : args.slice(0, 2);\n const [head = zero(NO_KIND), ...rest] = outs;\n return rest.reduce(joinShape, head);\n }\n case \"and\":\n case \"or\":\n return zero(BOOLEAN);\n }\n const { op } = e;\n const outs: Shape[] = [];\n let open = false;\n const listOp = isListOp(op) ? op : undefined;\n const fn = this.#fns !== undefined && Object.hasOwn(this.#fns, op) ? this.#fns[op] : undefined;\n const byFn = (): void => {\n const host = fn as { readonly size?: SizeRule; readonly returns?: ReturnKind };\n if (host.size === undefined) open = true;\n else outs.push(this.#apply(host.size, args, e.args, kindOfReturn(host.returns, undefined, this.#domains)));\n };\n const self = args[0]?.kind;\n // The order of the interpreter: a list op on a list, the domains in order, a function of the host, a list op on an\n // array (LIST.ARRAY), and fill.\n const tags = self === undefined ? [] : self.tags === undefined ? [undefined] : [...self.tags];\n for (const tag of tags) {\n if (listOp !== undefined && (tag === undefined || tag === \"list\")) {\n outs.push(this.#list(listOp, args, e.args));\n if (tag === \"list\") continue;\n }\n const d = this.#domain(op, tag, args, e.args, outs);\n open ||= d.open;\n if (d.done) continue;\n if (fn !== undefined) byFn();\n else if (listOp !== undefined && (tag === undefined || tag === \"array\")) outs.push(this.#list(listOp, args, e.args));\n else if (op === \"fill\") outs.push(this.#list(\"fill\", args, e.args));\n }\n if (self === undefined && fn !== undefined) byFn();\n // LOOP.SIZE.OPS: an op without a size rule has no bound (fail closed).\n if (open) outs.push(unbounded(args));\n this.#open.set(e, open);\n // An op that no domain and no function has gives an error, and an error has no size.\n return outs.slice(1).reduce(joinShape, outs[0] ?? zero(NO_KIND));\n }\n\n /**\n * This method adds the shapes of the ops of the domains that can take a receiver with the tag. It gives `true` for an\n * op without a size rule. A domain that surely takes the receiver and has a function for the op is the last domain,\n * and then `done` is `true`.\n */\n #domain(\n op: string,\n tag: string | undefined,\n args: readonly Shape[],\n exprs: readonly Expr[],\n outs: Shape[],\n ): { readonly open: boolean; readonly done: boolean } {\n if (!isOpName(op)) return { open: false, done: false };\n let open = false;\n for (const d of this.#domains) {\n const a = accepts(d, tag);\n if (a === \"no\") continue;\n const spec = Object.hasOwn(d.ops, op) ? (d.ops[op] as OpSpec<unknown>) : undefined;\n // A method needs an object: a number, a text, a boolean and null have no methods (findMethod).\n const method = (spec !== undefined || d.methods === \"all\") && (tag === undefined || !PRIMITIVES.has(tag));\n if (spec?.fn === undefined && !method) continue;\n const rule = spec === undefined ? undefined : ruleOf(d, spec, this.#domains);\n if (rule === undefined) open = true;\n else outs.push(this.#apply(rule, args, exprs, kindOfReturn(spec?.returns, d, this.#domains)));\n if (a === \"sure\" && spec?.fn !== undefined) return { open, done: true };\n }\n return { open, done: false };\n }\n\n /** This method gives the shape of a list op, and the kind of its result. */\n #list(op: ListOp | \"fill\", args: readonly Shape[], exprs: readonly Expr[]): Shape {\n // The receiver selects a list op, so the op has a first argument.\n const item = itemOf((args[0] as Shape).kind);\n const s = this.#apply(LIST_SIZES[op], args, exprs, listResult(op, item, args));\n return op === \"group\" ? { ...s, long: true } : s;\n }\n\n #apply(rule: SizeRule, args: readonly Shape[], exprs: readonly Expr[], kind: Kind): Shape {\n // The rule \"scalar\" tells that the result is a number or a boolean.\n if (rule === \"scalar\") return zero(kind.tags === undefined ? SCALAR : kind);\n if (rule === \"fixed\") return fixed(kind);\n if (rule === \"reduce\") return { ...this.#reduce(args, exprs), kind };\n const limit = rule.limit === undefined ? undefined : literalNumber(exprs[rule.limit]);\n // LOOP.SIZE.PART: a rule with a limit gives a bound for each item, so it needs a literal limit and short keys.\n const open = rule.limit !== undefined && (limit === undefined || args.some((a) => a.long));\n const r = this.#parts && !open ? (rule.byParts ?? rule) : rule;\n const sum = (terms: readonly SizeTerm[], own: SizeMeasure): Form =>\n args.reduce((acc, a, i) => {\n const t = terms[i] ?? r.rest ?? \"many\";\n const [use, of] = typeof t === \"object\" ? t : [t, own];\n const f = useForm(use, i, a[of], args, exprs, limit);\n // The largest item of the result is an item of one argument, so the arguments give the largest bound.\n if (own === \"item\" || own === \"part\") return join(acc, f);\n return r.union === true ? union(acc, f) : plus(acc, f);\n }, NONE);\n let size = sum(r.size, \"size\");\n let count = r.count === undefined ? size : sum(r.count, \"count\");\n const inner = r.inner === undefined ? size : sum(r.inner, \"inner\");\n if (limit !== undefined) count = constant(limit);\n if (r.constant === true) {\n size = plus(size, SOME);\n count = plus(count, SOME);\n }\n if (r.keys === \"position\") size = plus(size, times(count, SOME));\n const item = r.item === undefined ? size : sum(r.item, \"item\");\n const part = r.part === undefined ? item : sum(r.part, \"part\");\n return { size, count, inner, item, part, kind, long: args.some((a) => a.long) };\n }\n\n /** The rule of `reduce`: the op that the second argument names folds the values of the list (LIST.REDUCE). */\n #reduce(args: readonly Shape[], exprs: readonly Expr[]): Shape {\n const list = args[0] as Shape;\n const name = exprs[1]?.tag === \"lit\" ? exprs[1].value : undefined;\n if (typeof name !== \"string\" || !isOpName(name)) return unbounded([list]);\n // The empty list gives the identity of the op: a constant.\n let out: Shape = fixed(ANY);\n for (const d of this.#domains) {\n if (!Object.hasOwn(d.ops, name)) {\n if (d.methods === \"all\") return unbounded([list]);\n continue;\n }\n const rule = ruleOf(d, d.ops[name] as OpSpec<unknown>, this.#domains);\n if (rule === undefined || rule === \"reduce\") return unbounded([list]);\n if (rule === \"scalar\" || rule === \"fixed\") continue;\n const use = (i: number): 0 | Coef => {\n const t = rule.size[i] ?? rule.rest ?? \"many\";\n return coefOf(typeof t === \"object\" ? t[0] : t);\n };\n // The first argument is the result of the steps before. More than one use of it doubles at each value.\n const first = use(0);\n if (first > 1) return unbounded([list]);\n // A union holds each key one time, so the result is not larger than the list.\n const k = rule.union === true ? 1 : (Math.max(1, use(1)) as Coef);\n const size = rule.constant === true ? plus(scale(list.size, k), SOME) : scale(list.size, k);\n out = joinShape(out, {\n size,\n count: size,\n inner: size,\n item: size,\n part: size,\n kind: ANY,\n long: list.long,\n });\n }\n return out;\n }\n\n #each(e: ExprOf<\"each\">, env: Env): Shape {\n const list = this.#axis(e.axis, e.at, env);\n if (list === undefined) {\n const body = this.shape(e.body, bindItem(env, e.as, fixed(ANY)));\n // A fixed number of targets: the records of the space.\n return {\n size: plus(SOME, times(body.size, SOME)),\n count: SOME,\n inner: times(body.count, SOME),\n item: body.size,\n part: body.item,\n kind: listKind(body.kind),\n long: body.long,\n };\n }\n const id = this.#fresh();\n const body = this.shape(e.body, bindItem(env, e.as, shapeOfVar(id, itemOf(list.kind), list.long)));\n const vars = new Map(MEASURES.map((m) => [variable(m, id), m]));\n // The sum over the items of a bound of the body: a use of the item adds the measures of the list.\n const over = (f: Form, keys: boolean): Form => {\n // Each item can take another sum of the bound, so the sum over the items uses one sum that covers each sum.\n const { rest, dropped } = split(cover(f), (v) => vars.has(v));\n const c = (m: SizeMeasure): 0 | Coef => dropped.get(variable(m, id)) ?? 0;\n // The inner count, the largest item and the largest part of an item are not larger than its size.\n const uses = [c(\"size\"), c(\"inner\"), c(\"item\"), c(\"part\")].filter((x) => x > 0);\n const sizes = uses.length === 0 ? 0 : uses.length === 1 ? (uses[0] as Coef) : 3;\n // The items keep the keys of the list. A key with a fixed bound adds a constant for each item, and a long key is a\n // part of the size of the list.\n const whole = scale(list.size, keys && list.long ? (Math.max(1, sizes) as Coef) : sizes);\n // LOOP.SIZE.PART: more than one use of each item has the bound of the count of the items times the largest item.\n const values = this.#parts && sizes > 1 && !(keys && list.long) ? scale(times(c(\"size\") > 0 || c(\"inner\") > 0 ? list.item : list.part, list.count), sizes) : whole;\n const short = keys && !list.long ? times(list.count, SOME) : NONE;\n return plus(plus(plus(values, short), scale(list.inner, c(\"count\"))), times([rest], list.count));\n };\n // The largest item of the result is the value of the body for one item of the list.\n const one = itemMeasures(list);\n const sigma = (v: string): Form | undefined => {\n const m = vars.get(v);\n return m === undefined ? undefined : one[m];\n };\n return {\n size: over(body.size, true),\n count: list.count,\n inner: over(body.count, false),\n item: subst(body.size, sigma),\n part: subst(body.item, sigma),\n kind: listKind(body.kind),\n long: list.long || body.long,\n };\n }\n\n /** This method checks the parts of an axis and of an address. It gives the shape of the list of the axis `list`. */\n #axis(axis: Axis, at: ExprOf<\"each\">[\"at\"], env: Env): Shape | undefined {\n const list = listOf(axis);\n const shape = list === undefined ? undefined : this.shape(list, env);\n // The tests of `where` and the address do not add to the size.\n for (let x = axis; x.t === \"where\" || x.t === \"reverse\"; x = x.axis) if (x.t === \"where\") this.shape(x.test, env);\n for (const x of addrExprs(at)) this.shape(x, env);\n return shape;\n }\n\n #loop(e: ExprOf<\"fold\"> | ExprOf<\"iterate\">, env: Env): Shape {\n const list = e.tag === \"fold\" ? this.#axis(e.axis, e.at, env) : undefined;\n // ITERATE.LIMIT.DATA: a data limit has the bound of a fold over its axis, and the steps of iterate have no item.\n const axis = e.tag === \"iterate\" ? limitAxis(e) : undefined;\n const sized = axis === undefined ? undefined : this.#axis(axis, undefined, env);\n const names = Object.keys(e.init);\n const init = new Map(names.map((n) => [n, this.shape(e.init[n] as Expr, env)]));\n const ids = new Map(names.map((n) => [n, this.#fresh()]));\n const stepped = Object.keys(e.step);\n // AXIS.LIST.ITEM: the item of a fold over a list is the value of one item of the list.\n const item: Shape =\n list === undefined\n ? fixed(ANY)\n : { ...itemMeasures(list), kind: itemOf(list.kind), long: list.long };\n // The kinds of the names. The first step reads the values of init. The other steps read the values of the steps: the\n // kinds of the first step, then also the kinds of the next steps, then each kind. A large program uses each kind\n // at once, for each step.\n type Assumed = { readonly kind: Kind; readonly long: boolean };\n const each: Assumed = { kind: ANY, long: true };\n const start = (n: string): Shape => init.get(n) as Shape;\n const fromInit = (n: string): Assumed => ({ kind: start(n).kind, long: start(n).long });\n const always = (): Map<string, Assumed> => new Map(names.map((n) => [n, stepped.includes(n) ? each : fromInit(n)]));\n const run = (assumed: ReadonlyMap<string, Assumed>): { readonly senv: Env; readonly steps: Map<string, Shape> } => {\n const senv = new Map(env);\n for (const n of names) {\n const a = assumed.get(n) as Assumed;\n senv.set(n, { t: \"value\", shape: shapeOfVar(ids.get(n) as number, a.kind, a.long) });\n }\n const ienv = e.tag === \"fold\" ? bindItem(senv, e.as, item) : senv;\n return { senv, steps: new Map(stepped.map((n) => [n, this.shape(e.step[n] as Expr, ienv)])) };\n };\n let first: ReadonlyMap<string, Shape> | undefined;\n let assumed: Map<string, Assumed>;\n if (stepped.length > 0 && this.#visits < BUDGET) {\n first = run(new Map(names.map((n) => [n, fromInit(n)]))).steps;\n assumed = new Map(\n names.map((n): [string, Assumed] => {\n const s = first?.get(n);\n return [n, s === undefined ? fromInit(n) : { kind: s.kind, long: s.long }];\n }),\n );\n } else assumed = always();\n let senv: Env;\n let steps: Map<string, Shape>;\n for (let pass = 0; ; pass++) {\n ({ senv, steps } = run(assumed));\n const next = new Map(\n names.map((n): [string, Assumed] => {\n const a = assumed.get(n) as Assumed;\n const s = steps.get(n);\n return [n, s === undefined ? a : { kind: joinKind(a.kind, s.kind), long: a.long || s.long }];\n }),\n );\n const stable = names.every((n) => {\n const a = assumed.get(n) as Assumed;\n const b = next.get(n) as Assumed;\n return within(b.kind, a.kind) && (a.long || !b.long);\n });\n if (stable) break;\n // The second reading keeps the keys that the steps can give: `take` needs them (LOOP.SIZE.PART). Each pass after the\n // first pass only changes the keys from short to long, so the loop ends.\n assumed = pass === 0 && this.#visits < BUDGET ? next : this.#parts ? new Map(names.map((n): [string, Assumed] => {\n const b = next.get(n) as Assumed;\n return [n, stepped.includes(n) ? { kind: ANY, long: b.long } : b];\n })) : always();\n }\n if (e.tag === \"iterate\" && e.until !== undefined) this.shape(e.until, senv);\n const loop = new Loop(e, names, ids, steps);\n // LOOP.SIZE: the rule applies to the steps after the first step. One step can multiply the values one time.\n loop.check(this.#shapes, this.#open);\n // The values after the first step: the first step reads the values of init.\n const sigma = (v: string): Form | undefined => {\n for (const n of names) {\n const id = ids.get(n) as number;\n const m = MEASURES.find((x) => variable(x, id) === v);\n if (m !== undefined) return start(n)[m];\n }\n return undefined;\n };\n const starts = new Map(\n names.map((n): [string, Shape] => {\n const a = start(n);\n const s = first?.get(n);\n if (s === undefined) return [n, a];\n return [n, joinShape(a, substShape(s, sigma))];\n }),\n );\n const last = loop.last(starts, list?.count ?? sized?.count ?? (e.tag === \"iterate\" && typeof e.limit === \"number\" ? constant(e.limit) : SOME));\n const renv = new Map(env);\n for (const n of names) {\n const a = assumed.get(n) as Assumed;\n const s = last.get(n) as Shape;\n const i = start(n);\n // With no step, the result reads the values of init.\n renv.set(n, { t: \"value\", shape: stepped.includes(n) ? { ...s, kind: joinKind(i.kind, a.kind), long: i.long || a.long } : i });\n }\n return this.shape(e.result, renv);\n }\n}\n\n/** This function gives the kind of the result of an op of the domain `d`, or of a function of the host, from `returns` (KIND.RETURNS). */\nfunction kindOfReturn(r: ReturnKind | undefined, d: AnyDomain | undefined, domains: readonly AnyDomain[]): Kind {\n if (r === \"number\" || r === \"boolean\" || r === \"string\") return kindOf(r);\n if (r === \"domain\") return d === undefined ? ANY : kindOf(tagOf(d));\n if (r?.startsWith(\"domain:\") === true) {\n const target = domains.find((x) => x.name === r.slice(\"domain:\".length));\n return target === undefined ? ANY : kindOf(tagOf(target));\n }\n const item = listItemKind(r);\n return item === undefined ? ANY : listKind(kindOf(item));\n}\n\n/** This function gives the kind of the result of a list op. `item` is the kind of the items of the receiver. */\nfunction listResult(op: ListOp | \"fill\", item: Kind, args: readonly Shape[]): Kind {\n switch (op) {\n case \"count\":\n case \"sum\":\n case \"mean\":\n case \"min\":\n case \"max\":\n case \"indexOf\":\n return NUMBER;\n case \"any\":\n case \"all\":\n case \"none\":\n return BOOLEAN;\n case \"join\":\n return STRING;\n case \"values\":\n return listKind(item, \"array\");\n case \"keys\":\n return listKind(STRING, \"array\");\n case \"first\":\n case \"nth\":\n case \"get\":\n return item;\n case \"sortBy\":\n case \"take\":\n case \"drop\":\n case \"without\":\n case \"distinct\":\n return listKind(item);\n case \"append\":\n return listKind(joinKind(item, itemOf(args[1]?.kind ?? ANY)));\n case \"setNth\":\n return listKind(joinKind(item, args[2]?.kind ?? ANY));\n case \"flat\":\n return listKind(itemOf(item));\n case \"group\":\n return listKind(listKind(item));\n case \"fill\":\n return listKind(args[1]?.kind ?? ANY);\n case \"errors\":\n case \"reduce\":\n return ANY;\n }\n}\n\n/** This function binds the names `as` of a loop: the item gets `item`, and the index is a number. */\nfunction bindItem(env: Env, as: ItemNames | undefined, item: Shape): Env {\n if (as === undefined) return env;\n const out = new Map(env);\n out.set(as[0], { t: \"value\", shape: item });\n if (as[1] !== undefined) out.set(as[1], { t: \"value\", shape: zero(NUMBER) });\n return out;\n}\n\n/** The shape of the result of an op without a size rule: no bound in the sizes of its arguments. */\nfunction unbounded(args: readonly Shape[]): Shape {\n const f = scale(\n args.reduce((acc, a) => plus(acc, a.size), SOME),\n 4,\n );\n return { size: f, count: f, inner: f, item: f, part: f, kind: ANY, long: true };\n}\n\n/** The measures of one item of a list. The largest item of the list bounds its size, and the largest part bounds the rest. */\nconst itemMeasures = (list: Shape): Readonly<Record<SizeMeasure, Form>> => ({ size: list.item, count: list.item, inner: list.item, item: list.part, part: list.part });\n\n/** This function gives the bound of one use of an argument. */\nfunction useForm(use: SizeUse, i: number, form: Form, args: readonly Shape[], exprs: readonly Expr[], limit: number | undefined): Form {\n switch (use) {\n case \"text\":\n return isText(args[i]?.kind) ? form : scale(form, 2);\n case \"copies\": {\n const n = literalNumber(exprs[0]);\n return n === 0 ? NONE : n === 1 ? form : scale(form, 2);\n }\n case \"each\":\n return times(form, (args[0] as Shape).count);\n case \"number\":\n // LIST.FILL: a count has the bound 100000.\n return constant(Math.min(100_000, literalNumber(exprs[i]) ?? Infinity));\n case \"limit\":\n // LOOP.SIZE.PART: each item that the limit keeps has a key with a fixed bound and a value.\n return limit === undefined ? scale(form, 3) : times(plus(form, SOME), constant(limit));\n case 0:\n case 1:\n case \"scaled\":\n case \"many\":\n case \"unbounded\":\n return scale(form, coefOf(use));\n }\n}\n\n/** This function tells if a domain holds numbers or booleans. */\nfunction scalar(x: AnyDomain | undefined): boolean {\n return x?.primitive === \"number\" || x?.primitive === \"boolean\";\n}\n\n/**\n * This function gives the size rule of an op of a domain (LOOP.SIZE.OPS). The rule is the rule of the op, or a rule\n * from its result kind and from the domain. The function gives `undefined` for an op without a rule.\n */\nexport function ruleOf(d: AnyDomain, spec: OpSpec<unknown>, domains: readonly AnyDomain[]): SizeRule | undefined {\n if (spec.size !== undefined) return spec.size;\n const r = spec.returns;\n if (r === \"number\" || r === \"boolean\" || (r === \"domain\" && scalar(d))) return \"scalar\";\n if (d.size === \"fixed\") return \"fixed\";\n if (r?.startsWith(\"domain:\") === true) {\n const target = domains.find((x) => x.name === r.slice(\"domain:\".length));\n if (scalar(target)) return \"scalar\";\n if (target?.size === \"fixed\") return \"fixed\";\n }\n return undefined;\n}\n\n/** The terms of a sum that read a variable of a cycle. */\nconst inside = (s: Sum, cycle: ReadonlySet<string>): readonly (readonly [string, Coef])[] => [...s.terms].filter(([u]) => cycle.has(u));\n\n/** This function tells if a sum of a bound reads its cycle more than one time, or with a coefficient other than 1. */\nconst loose = (f: Form, cycle: ReadonlySet<string>): boolean =>\n f.some((s) => {\n const terms = inside(s, cycle);\n return terms.length > 1 || terms.some(([, c]) => c !== 1);\n });\n\n/** The variable of a measure of a name of a loop. */\ninterface Owner {\n readonly name: string;\n readonly measure: SizeMeasure;\n}\n\n/** The words of a measure in a message. */\nconst WORDS: Readonly<Record<SizeMeasure, string>> = {\n size: \"size\",\n count: \"number of items\",\n inner: \"number of inner items\",\n item: \"largest item\",\n part: \"largest part\",\n};\n\n/** This function gives the label of the node of a refusal: an op, a function, a name or a node. */\nfunction label(e: Expr): string {\n switch (e.tag) {\n case \"app\":\n return `the op \"${e.op}\"`;\n case \"call\":\n return `the function \"${e.fn}\"`;\n case \"var\":\n return `the name \"${e.name}\"`;\n case \"each\":\n case \"ext\":\n case \"fn\":\n case \"fix\":\n case \"fold\":\n case \"iterate\":\n case \"last\":\n case \"let\":\n case \"lit\":\n case \"rec\":\n case \"ref\":\n return `a node \"${e.tag}\"`;\n }\n}\n\n/** The names of one loop, their steps, and the rule of LOOP.SIZE. */\nclass Loop {\n readonly #owners = new Map<string, Owner>();\n /** The cycle of each variable: the variables that its new value reads, and that read it in turn. */\n readonly #cycles = new Map<string, ReadonlySet<string>>();\n\n readonly node: ExprOf<\"fold\"> | ExprOf<\"iterate\">;\n readonly names: readonly string[];\n readonly steps: ReadonlyMap<string, Shape>;\n\n // Node.js starts the speed gate from this source with the types removed, so the class has no parameter properties.\n constructor(node: ExprOf<\"fold\"> | ExprOf<\"iterate\">, names: readonly string[], ids: ReadonlyMap<string, number>, steps: ReadonlyMap<string, Shape>) {\n this.node = node;\n this.names = names;\n this.steps = steps;\n for (const name of names)\n for (const measure of MEASURES)\n this.#owners.set(variable(measure, ids.get(name) as number), {\n name,\n measure,\n });\n }\n\n /**\n * This method applies the rule of LOOP.SIZE to the steps, and it throws a refusal. Each sum of a measure of a new value\n * reads its cycle at most one time, with the coefficient 1. A name without a step keeps its value.\n */\n check(shapes: ReadonlyMap<Expr, Shape>, open: ReadonlyMap<Expr, boolean>): void {\n // The graph of the measures: an edge from each variable of a bound of a step to the measure of its name.\n const into = new Map<string, Form>();\n const out = new Map<string, string[]>();\n for (const [v, o] of this.#owners) {\n const form = this.steps.get(o.name)?.[o.measure] ?? term(v, 1);\n into.set(v, form);\n for (const u of new Set(form.flatMap((s) => [...s.terms.keys()]))) if (this.#owners.has(u)) out.set(u, [...(out.get(u) ?? []), v]);\n }\n const reach = (from: string): ReadonlySet<string> => {\n const seen = new Set<string>();\n const todo = [from];\n for (let x = todo.pop(); x !== undefined; x = todo.pop()) {\n for (const y of out.get(x) ?? []) {\n if (seen.has(y)) continue;\n seen.add(y);\n todo.push(y);\n }\n }\n return seen;\n };\n const reached = new Map([...this.#owners.keys()].map((v): [string, ReadonlySet<string>] => [v, reach(v)]));\n for (const [v, form] of into) {\n const cycle = new Set([...(reached.get(v) as ReadonlySet<string>)].filter((u) => (reached.get(u) as ReadonlySet<string>).has(v)));\n this.#cycles.set(v, cycle);\n if (!loose(form, cycle)) continue;\n const o = this.#owners.get(v) as Owner;\n const twice = form.some((s) => {\n const terms = inside(s, cycle);\n return terms.length > 1 || terms.some(([, c]) => c > 2);\n });\n const what = twice\n ? `a value that uses the lists of the loop more than one time in its ${WORDS[o.measure]}`\n : `a ${WORDS[o.measure]} that can grow by a factor at each step`;\n this.#refuse(o.name, (s) => loose(s[o.measure], cycle), what, shapes, open);\n }\n }\n\n #refuse(name: string, bad: (s: Shape) => boolean, what: string, shapes: ReadonlyMap<Expr, Shape>, open: ReadonlyMap<Expr, boolean>): never {\n // The node of the refusal: the deepest node on a path of bad nodes from the step.\n const worse = (at: Expr): Expr | undefined =>\n children(at).find((k) => {\n const s = shapes.get(k);\n return s !== undefined && bad(s);\n });\n let at = this.node.step[name] as Expr;\n for (let next = worse(at); next !== undefined; next = worse(at)) at = next;\n const source = findOpen(at, open);\n const head = `the expression has a node \"${this.node.tag}\" whose step gives the name \"${name}\" ${what}, at ${label(source ?? at)} (LOOP.SIZE)`;\n throw new Refusal(source === undefined ? head : `${head}. The op \"${source.op}\" has no size rule (LOOP.SIZE.OPS)`);\n }\n\n /**\n * This method gives a bound of the last value of each name, from the values of `init` and the steps. The number of the\n * steps is `steps`. Each sum of a measure in a cycle gets at most one measure of its cycle at each step. A sum with a\n * measure of the cycle adds its other parts one time for each step. A sum without such a measure sets the value again,\n * so it adds to the bound one time (LOOP.SIZE.BRANCH). The last value starts from the largest first value of the cycle\n * or of these sums. It adds the parts of the other sums one time for each step. A measure outside a cycle has its first\n * value or the value of its step.\n */\n last(init: ReadonlyMap<string, Shape>, steps: Form): ReadonlyMap<string, Shape> {\n const first = (v: string): Form => {\n const o = this.#owners.get(v) as Owner;\n return (init.get(o.name) as Shape)[o.measure];\n };\n const bounds = new Map([...this.#owners.keys()].map((v) => [v, first(v)]));\n const sigma = (v: string): Form | undefined => bounds.get(v);\n // Each pass makes the bounds larger, and the bounds have a finite number of values, so the loop ends. A constant\n // that is new in a bound becomes a constant without a known value.\n const widen = (old: Form, more: Form): Form => bound(join(old, more).map((s) => (s.base === 0 || old.some((o) => o.base === s.base) ? s : { base: Infinity, terms: s.terms })));\n const stepOf = (v: string): Form | undefined => {\n const o = this.#owners.get(v) as Owner;\n return this.steps.get(o.name)?.[o.measure];\n };\n for (let changed = true; changed;) {\n changed = false;\n for (const [v, old] of bounds) {\n const step = stepOf(v);\n if (step === undefined) continue;\n const cycle = this.#cycles.get(v) as ReadonlySet<string>;\n let next: Form;\n if (cycle.has(v)) {\n const members = [...cycle];\n const start = members.reduce((acc, u) => join(acc, first(u)), NONE);\n const sums = members.flatMap((u) => (stepOf(u) as Form).map((x) => split(x, (y) => cycle.has(y))));\n const sets = subst(bound(sums.filter((x) => x.dropped.size === 0).map((x) => x.rest)), sigma);\n const adds = subst(bound(sums.filter((x) => x.dropped.size > 0).map((x) => x.rest)), sigma);\n next = plus(join(start, sets), times(adds, steps));\n } else next = join(first(v), subst(step, sigma));\n const wide = widen(old, next);\n if (sameForm(old, wide)) continue;\n bounds.set(v, wide);\n changed = true;\n }\n }\n const values = new Map(this.names.map((n) => [n, init.get(n) as Shape]));\n for (const [v, o] of this.#owners) values.set(o.name, { ...(values.get(o.name) as Shape), [o.measure]: bounds.get(v) as Form });\n return values;\n }\n}\n\n/** This function finds an op without a size rule in a node or in its children. */\nfunction findOpen(at: Expr, open: ReadonlyMap<Expr, boolean>): ExprOf<\"app\"> | undefined {\n const todo = [at];\n for (let x = todo.pop(); x !== undefined; x = todo.pop()) {\n if (x.tag === \"app\" && open.get(x) === true) return x;\n todo.push(...children(x));\n }\n return undefined;\n}\n\n/** This function reads an expression one time, and it gives the reason of a refusal or `undefined`. */\nfunction refusalOf(e: Expr, opts: SizeOptions, parts: boolean): string | undefined {\n try {\n new Checker(opts, parts).shape(e, new Map());\n return undefined;\n } catch (thrown) {\n if (thrown instanceof Refusal) return thrown.message;\n throw thrown;\n }\n}\n\n/**\n * This function checks the sizes of the loops of an expression (LOOP.SIZE). It gives the reason of a refusal, or\n * `undefined`. The expression must pass `shapeError` and the limit of the nesting first. Each reading gives a sound\n * bound, so one reading that accepts the expression makes it valid. A refusal tells the reason of the first reading\n * (LOOP.SIZE.READINGS).\n */\nexport function sizeError(e: Expr, opts: SizeOptions = {}): string | undefined {\n const reason = refusalOf(e, opts, false);\n return reason === undefined || refusalOf(e, opts, true) === undefined ? undefined : reason;\n}\n","/**\n * The step of each construct of Vex (STEP.LADDER). The construct of a node is its tag. An `iterate` with a limit from\n * the data has its own construct `iterate.size` (ITERATE.LIMIT.DATA). The step of this construct, of `fix` and of `last` is\n * `B`. The step of each other construct is `A`. A function cannot call itself (FN.TOTAL). The table is its own module, so a test can declare a construct of a higher step.\n */\nimport type { ExprTag } from \"./ir.ts\";\n\n/** A step of Vex. Step A has loops with a fixed count. Step B adds limits from the data and fixed points. Step C adds functions that call themselves, with a budget. */\nexport type VexStep = \"A\" | \"B\" | \"C\";\n\n/** The construct of an `iterate` with a limit from the data. */\nexport const ITERATE_SIZE = \"iterate.size\";\n\n/** The step that each construct of Vex needs. The name of a construct is the tag of its node, or `ITERATE_SIZE`. */\nexport const CONSTRUCT_STEPS: Readonly<Record<ExprTag | typeof ITERATE_SIZE, VexStep>> = {\n lit: \"A\",\n ref: \"A\",\n app: \"A\",\n let: \"A\",\n var: \"A\",\n rec: \"A\",\n each: \"A\",\n fold: \"A\",\n iterate: \"A\",\n [ITERATE_SIZE]: \"B\",\n fix: \"B\",\n last: \"B\",\n fn: \"A\",\n call: \"A\",\n ext: \"A\",\n};\n","/**\n * The steps of Vex (STEP.LADDER, STEP.LOWEST, STEP.MAX). A step is a level of the power of the language. Step A is a\n * total formula language. Step B adds limits from the data and fixed points. Step C adds functions that call\n * themselves. The checker gives the lowest step that a program needs, with the reason. The host option `maxStep` sets\n * the highest step that the host accepts. The default is B. A program has no field for its step, so a document cannot\n * raise its own step. The ladder is the ladder of steps of coeval (D116 of coeval), with the table of `constructs.ts`.\n */\nimport { checkStep, isStep, stepLadder, stepOf, stepRank, type StepLadder, type StepReason, type StepWalk } from \"@mark1russell7/coeval\";\nimport { CONSTRUCT_STEPS, ITERATE_SIZE, type VexStep } from \"./constructs.ts\";\nimport { children, limitAxis, type Expr } from \"./ir.ts\";\n\nexport { CONSTRUCT_STEPS, type VexStep } from \"./constructs.ts\";\n\n/** The steps of Vex, from the lowest to the highest. */\nexport const VEX_STEP_NAMES: readonly VexStep[] = [\"A\", \"B\", \"C\"];\n\n/** The ladder of the steps of Vex: the steps and the step of each construct. */\nexport const VEX_STEPS: StepLadder<VexStep> = /* @__PURE__ */ stepLadder<VexStep>(VEX_STEP_NAMES, CONSTRUCT_STEPS);\n\n/** The highest step that a host accepts without the option `maxStep`. */\nexport const DEFAULT_MAX_STEP: VexStep = \"B\";\n\n/** The options of the check of steps: the highest step that the host accepts. */\nexport interface StepOptions {\n /** The highest step that the host accepts. The default is `DEFAULT_MAX_STEP`, step B. */\n readonly maxStep?: VexStep;\n}\n\n/** The step of a program, with the reason as text, and the construct and the path of the node that needs the step. */\nexport interface ProgramStep {\n readonly step: VexStep;\n /** The reason as text. */\n readonly reason: string;\n /** The construct that needs the step. A program of step A has none. */\n readonly construct?: string;\n /** The path of the node of the construct, as child indexes (EVAL.LOCATION). A program of step A has none. */\n readonly path?: readonly number[];\n}\n\n/**\n * The walk of an expression: the construct of a node is its tag, and the key of a child is its child index. An\n * `iterate` with a limit from the data is its own construct (ITERATE.LIMIT.DATA).\n */\nconst WALK: StepWalk<Expr> = {\n construct: (e) => (e.tag === \"iterate\" && limitAxis(e) !== undefined ? ITERATE_SIZE : e.tag),\n children: (e) => children(e).map((child, i) => [i, child] as const),\n};\n\n/** The position of the highest step of a construct of the table. A limit at that step or higher accepts each program without a walk. The table is frozen, so the module computes this value one time. */\nconst HIGHEST: number = Math.max(0, ...Object.values(VEX_STEPS.constructs).map((s) => stepRank(VEX_STEPS, s)));\n\nconst at = (path: readonly unknown[]): string => (path.length === 0 ? \"at the root\" : `at the path [${path.join(\", \")}]`);\n\n/**\n * This function gives the lowest step that a program needs, with the reason (STEP.LOWEST). The reason names the first\n * node in the order of `children` whose construct needs that step. The program must have a valid shape (EVAL.SHAPE).\n */\nexport function programStep(e: Expr): ProgramStep {\n const need = stepOf(VEX_STEPS, WALK, e);\n if (need.reason === undefined) return { step: need.step, reason: `each construct of the program is of step ${need.step}` };\n const { construct, path } = need.reason;\n return { step: need.step, reason: `the node \"${construct}\" ${at(path)} needs step ${need.step}`, construct, path: path as readonly number[] };\n}\n\n/**\n * This function gives the reason that a host refuses a program for its step, or `undefined` (STEP.MAX). A program of a\n * step above the option `maxStep` is not valid, and the reason names the step that it needs. A value of `maxStep` that\n * is not a step of Vex is not valid too. The program must have a valid shape (EVAL.SHAPE).\n */\nexport function stepError(e: Expr, opts: StepOptions = {}): string | undefined {\n const maxStep: unknown = opts.maxStep ?? DEFAULT_MAX_STEP;\n if (!isStep(VEX_STEPS, maxStep)) {\n const shown = typeof maxStep === \"string\" ? JSON.stringify(maxStep) : `of the type ${typeof maxStep}`;\n return `the option maxStep ${shown} is not a step of Vex. The steps are ${VEX_STEP_NAMES.join(\", \")} (STEP.MAX)`;\n }\n // Stryker disable next-line ConditionalExpression: without the shortcut, the walk gives the same answer\n if (stepRank(VEX_STEPS, maxStep) >= HIGHEST) return undefined;\n const refusal = checkStep(VEX_STEPS, stepOf(VEX_STEPS, WALK, e), maxStep);\n if (refusal === undefined) return undefined;\n // A refusal of `stepOf` has a reason, because its step is above the lowest step.\n const { construct, path } = refusal.reason as StepReason<Expr, VexStep>;\n return `the program needs step ${refusal.needed}, and the host accepts the steps up to ${maxStep}: the node \"${construct}\" ${at(path)} needs step ${refusal.needed} (STEP.MAX)`;\n}\n","import { CHECKED } from \"./checked.ts\";\nimport { fromDocument, isDocument, type Envelope } from \"./document.ts\";\nimport { fixRounds, fixValueError, joinValues, worstRow } from \"./fix.ts\";\nimport { findMethod, isOpName, liftsAt, resolveOp, type AnyDomain, type Monotone, type OpSpec, type ParamKind, type PrimitiveKind, type ResolvedOp, type ReturnKind, type SizeRule } from \"./domain.ts\";\nimport { describeType, errorAt, errorText, type ErrorExtra, type ErrorText } from \"./error-text.ts\";\nimport { formatError, isDepthError, isStackOverflow, vexError, type ErrorKind, type VexError } from \"./errors.ts\";\nimport { limitError, overLimitMessage, worstError } from \"./limit-error.ts\";\nimport { addrExprs, children, limitAxis, MAX_ITERATIONS, shapeError, type Addr, type Axis, type Expr, type ExprOf, type FixedMove, type ItemNames, type Move } from \"./ir.ts\";\nimport { asList, fillList, isFillCount, isIndexValue, listOfArray } from \"./array-list.ts\";\nimport { monotoneError } from \"./monotone.ts\";\nimport { sizeError } from \"./size.ts\";\nimport { stepError, type VexStep } from \"./steps.ts\";\nimport { isListOp, isVexList, vexList, type ListItem, type ListOp, type ListOptions, type VexList } from \"./list.ts\";\nimport { fail, ok, type Result } from \"./result.ts\";\nimport { axisTargets, fixAddr, resolveAddr, type Position, type Space } from \"./space.ts\";\nimport type { Read, Trace, TraceEvent, TraceSink } from \"./trace.ts\";\n\nexport { describeType };\n\n/**\n * A free function op. The interpreter gives it the values of all arguments. The property `size` is its size rule\n * (LOOP.SIZE.OPS). Without it, a step of a loop cannot use its result in the size of a list name. The property\n * `returns` is the kind of its result, as in `OpSpec`. The interpreter does not examine it.\n */\nexport type FreeFn = ((...args: readonly unknown[]) => unknown) & { readonly size?: SizeRule; readonly returns?: ReturnKind; readonly monotone?: readonly Monotone[] };\n\n/** The context of an extension handler. */\nexport interface ExtContext {\n readonly space: Space;\n readonly position: Position;\n readonly path: readonly number[];\n}\n\n/** The handler of an extension expression kind. */\nexport type ExtHandler = (data: unknown, ctx: ExtContext) => Result<unknown>;\n\n/** The options of an evaluation. */\nexport interface EvalOptions {\n /** The space that the program reads. */\n readonly space: Space;\n /** The key where the evaluation starts. Relative references read here. */\n readonly origin: string;\n /** The domains. The interpreter finds the op of a value in the first domain that accepts the value. */\n readonly domains?: readonly AnyDomain[];\n /** Free function ops, for ops that are not domain ops. */\n readonly fns?: Readonly<Record<string, FreeFn>>;\n /** The handlers of extension expression kinds. */\n readonly extensions?: Readonly<Record<string, ExtHandler>>;\n /** Variables that the program can read with `v(name)`. */\n readonly vars?: Readonly<Record<string, unknown>>;\n /** The other spaces of the evaluation, by name. The axis `table(name)` reads them. */\n readonly tables?: Readonly<Record<string, Space>>;\n /** A receiver of trace events. */\n readonly trace?: TraceSink;\n /**\n * The highest step of the language that the host accepts (STEP.MAX). The default is B. A program that needs a higher\n * step gives `#VALUE!` before the evaluation, and the reason names its step.\n */\n readonly maxStep?: VexStep;\n}\n\n/** The names of a frame: a map of the variables of the caller, or a scope inside it. */\ninterface Env {\n get(name: string | symbol): Result<unknown> | undefined;\n}\n\n/**\n * A scope: the names of one `let`, a function, an item or a loop. It is in front of the outer names, and it does not\n * copy them. A name of a scope hides an outer name of the same name. The names of one\n * scope are distinct (FN.BIND, LOOP.NAMES, AXIS.LIST.SCOPE).\n */\nclass Scope implements Env {\n readonly #outer: Env;\n readonly #names: readonly (string | symbol)[];\n readonly #values: readonly Result<unknown>[];\n\n constructor(outer: Env, names: readonly (string | symbol)[], values: readonly Result<unknown>[]) {\n this.#outer = outer;\n this.#names = names;\n this.#values = values;\n }\n\n get(name: string | symbol): Result<unknown> | undefined {\n const at = this.#names.indexOf(name);\n return at >= 0 ? this.#values[at] : this.#outer.get(name);\n }\n\n /** This method gives a copy of this scope with the values `values` at the positions `at` (LOOP.NAMES). */\n with(at: readonly number[], values: readonly Result<unknown>[]): Scope {\n const next = [...this.#values];\n at.forEach((position, i) => {\n next[position] = values[i] as Result<unknown>;\n });\n return new Scope(this.#outer, this.#names, next);\n }\n}\n\ninterface Frame {\n readonly pos: Position;\n readonly env: Env;\n}\n\n/** The name of a special form. */\nexport type SpecialForm = \"if\" | \"and\" | \"or\" | \"ifError\";\n\n/** The names of the special forms. Their arguments are not evaluated before the call. */\nexport const SPECIAL_FORMS: ReadonlySet<string> = new Set<SpecialForm>([\"if\", \"and\", \"or\", \"ifError\"]);\n\nconst isSpecialForm = (op: string): op is SpecialForm => SPECIAL_FORMS.has(op);\n\n/** The options that a compiled program keeps: the domains, the free functions and the extension handlers. */\nexport type CompileOptions = Pick<EvalOptions, \"domains\" | \"fns\" | \"extensions\" | \"maxStep\">;\n\n/** The options of one run of a compiled program. */\nexport type RunOptions = Pick<EvalOptions, \"space\" | \"origin\" | \"vars\" | \"trace\" | \"tables\">;\n\n/**\n * A compiled program: the expression as a tree of functions. A program evaluates many times at different origins,\n * and over different spaces, without a new walk of the expression.\n */\nexport interface Program {\n /**\n * The expression of the program. For a document, it is the expression of the document. A document that is not valid\n * stays as it is, as an expression that is not valid stays (DOC.ENTRY).\n */\n readonly expr: Expr;\n /** This method evaluates the program at an origin. It does not throw. */\n run(opts: RunOptions): Result<unknown>;\n /** This method evaluates the program at an origin, with a trace of each node. */\n explain(opts: Omit<RunOptions, \"trace\">): Trace;\n}\n\n/** A bound function (FN.BIND): its parameters, its compiled body and the names of the place of its binding. */\nclass Closure {\n readonly params: readonly string[];\n readonly body: Node;\n readonly env: Env;\n\n constructor(params: readonly string[], body: Node, env: Env) {\n this.params = params;\n this.body = body;\n this.env = env;\n }\n}\n\n/** This function gives the error of an origin that is not a key of the space (EVAL.ORIGIN). */\nexport const noKeyError = (origin: string): VexError => vexError(\"unknown-key\", `the space has no key \"${origin}\"`, { origin, focus: origin });\n\n/** The deepest nesting of an expression that `compile` accepts (EVAL.NESTING). */\nexport const MAX_NESTING = 500;\n\nconst DEPTH_MESSAGE = \"the evaluation is too deep for the call stack of the engine\";\n\n/** This function gives the number of nodes on the longest path from the root of `e`. It uses a stack, not recursion. */\nexport function nestingOf(e: Expr): number {\n let deepest = 0;\n const todo: [Expr, number][] = [[e, 1]];\n for (let item = todo.pop(); item !== undefined; item = todo.pop()) {\n const [x, d] = item;\n if (d > deepest) deepest = d;\n for (const child of children(x)) todo.push([child, d + 1]);\n }\n return deepest;\n}\n\n/** This function gives the reason of the refusal of an expression that is nested too deep (EVAL.NESTING), or undefined. */\nexport function nestingError(e: Expr): string | undefined {\n const nesting = nestingOf(e);\n return nesting > MAX_NESTING ? `the expression is nested ${String(nesting)} levels deep, and the limit is ${String(MAX_NESTING)}` : undefined;\n}\n\n/**\n * This function compiles an expression or a document (DOC.ENTRY). The result gives the same results and the same traces\n * as `evaluate`, because `evaluate` uses it too.\n */\n/**\n * The list ops of `compile` for the values of a host (LIST.OPS). A result has the rules of the interpreter. An error of\n * the op has the position and the path of the call, and an error of an item keeps its own.\n */\nexport interface ListOps {\n /** This function gives the result of a list op on a list. The list is the receiver, and `rest` has the other arguments. */\n readonly list: (op: ListOp, list: VexList, rest: readonly unknown[], position: Position, path: readonly number[]) => Result<unknown>;\n /** This function gives the result of a list op on an array (LIST.ARRAY). A missing item is an error item with the position and the path. */\n readonly array: (op: ListOp, array: readonly unknown[], rest: readonly unknown[], position: Position, path: readonly number[]) => Result<unknown>;\n /** This function gives the result of `fill` (LIST.FILL). */\n readonly fill: (values: readonly unknown[], position: Position, path: readonly number[]) => Result<VexList>;\n}\n\n/** This function gives the list ops of `compile` for the options. It keeps the index of each list that `get` read. */\nexport function listOps(opts: CompileOptions = {}): ListOps {\n const compiler = new Compiler(opts);\n const names = new Map<string, Result<unknown>>();\n return {\n list: (op, list, rest, pos, path) => compiler.listOp(op, list, rest, { pos, env: names }, path),\n array: (op, array, rest, pos, path) => compiler.arrayOp(op, array, rest, { pos, env: names }, path),\n fill: (values, pos, path) => compiler.fill(values, { pos, env: names }, path),\n };\n}\n\nexport function compile(source: Expr | Envelope, opts: CompileOptions = {}): Program {\n // DOC.ENTRY: a document gives its expression first. A document that is not valid gives the error of fromDocument.\n const read = isDocument(source) ? fromDocument(source, opts.domains) : ok(source);\n const expr = read.ok ? read.value : (source as unknown as Expr);\n // EVAL.SHAPE: an expression that is not valid, for example from a newer version of Vex, gives an error before a walk.\n // EVAL.NESTING: a program nested too deep gives an error before the compiler walks it with recursion.\n const shape = read.ok ? shapeError(expr) : read.error.message;\n const deep = shape ?? nestingError(expr);\n // LOOP.SIZE: a step of a loop that can double the size of a list at each step gives an error before a run.\n // STEP.MAX: a program above the highest step of the host gives an error before a run.\n // FIX.MONOTONE: a step of a fixed point without a proof that it moves one way gives an error before a run.\n const bad = deep ?? sizeError(expr, opts) ?? stepError(expr, opts) ?? monotoneError(expr, opts);\n const kind = read.ok ? \"bad-expression\" : read.error.kind;\n const root: Node = bad === undefined ? new Compiler(opts).node(expr, []) : (f) => fail(vexError(kind, bad, { path: [], origin: f.pos.origin, focus: f.pos.focus }));\n const run = (r: RunOptions): Result<unknown> => {\n const { space, origin } = r;\n if (!space.has(origin)) return fail(noKeyError(origin));\n const env = new Map<string, Result<unknown>>(Object.entries(r.vars ?? {}).map(([k, val]) => [k, ok(val)]));\n try {\n return root({ pos: { origin, focus: origin }, env }, { space, trace: r.trace, tables: r.tables });\n } catch (thrown) {\n // A defect in an extension handler or in a test of the interpreter itself. Totality still holds.\n if (isStackOverflow(thrown)) return fail(vexError(\"depth\", DEPTH_MESSAGE, { origin, focus: origin, thrown }));\n return fail(vexError(\"threw\", \"the evaluation threw an exception\", { origin, focus: origin, thrown }));\n }\n };\n return {\n expr,\n run,\n explain: (r) => {\n const sink: TraceSink = { events: [] };\n const result = run({ ...r, trace: sink });\n return { events: sink.events, result };\n },\n };\n}\n\n// The cache of compiled programs: one entry for each expression object or document, for the last options.\nconst CACHE = new WeakMap<Expr | Envelope, { readonly domains: unknown; readonly fns: unknown; readonly extensions: unknown; readonly maxStep: unknown; readonly program: Program }>();\n\nfunction compiled(expr: Expr | Envelope, opts: CompileOptions): Program {\n // V-056: a program that is not an object cannot be a key of the cache. Its compilation gives #VALUE! (EVAL.SHAPE).\n if (typeof expr !== \"object\" || expr === null) return compile(expr, opts);\n const hit = CACHE.get(expr);\n // Without the cache, each evaluation compiles again: the result is the same, so a mutant that removes a hit is\n // equivalent. A false hit changes results, and the tests find it.\n // Stryker disable next-line ConditionalExpression: a missed hit only compiles again\n if (hit !== undefined && hit.domains === opts.domains && hit.fns === opts.fns && hit.extensions === opts.extensions && hit.maxStep === opts.maxStep) return hit.program;\n const program = compile(expr, opts);\n CACHE.set(expr, { domains: opts.domains, fns: opts.fns, extensions: opts.extensions, maxStep: opts.maxStep, program });\n return program;\n}\n\n/** This function evaluates an expression or a document at the origin of a space. It does not throw. */\nexport function evaluate(expr: Expr | Envelope, opts: EvalOptions): Result<unknown> {\n return compiled(expr, opts).run(opts);\n}\n\n/** This function evaluates an expression or a document and records a trace of each node. */\nexport function explain(expr: Expr | Envelope, opts: Omit<EvalOptions, \"trace\">): Trace {\n return compiled(expr, opts).explain(opts);\n}\n\n/** The state of one run that the nodes read: the space, the trace sink and the other spaces. */\ninterface Ctx {\n readonly space: Space;\n readonly trace: TraceSink | undefined;\n readonly tables: Readonly<Record<string, Space>> | undefined;\n}\n\n/** This function gives the axis inside the `where` axes of an axis. */\nconst baseAxis = (a: Axis): Exclude<Axis, { readonly t: \"where\" }> => (a.t === \"where\" ? baseAxis(a.axis) : a);\n\n/** A compiled node: it evaluates in a frame of a run. */\ntype Node = (f: Frame, c: Ctx) => Result<unknown>;\n\n/** This function evaluates the nodes in order. The first error stops it and is the result. */\nfunction allValues(ns: readonly Node[], f: Frame, c: Ctx): Result<Result<unknown>[]> {\n const values: Result<unknown>[] = [];\n for (const n of ns) {\n const r = n(f, c);\n if (!r.ok) return r;\n values.push(r);\n }\n return ok(values);\n}\n\n/** The primitive types of KIND.PRIMITIVE. */\nconst PRIMITIVE_TYPES: readonly PrimitiveKind[] = [\"number\", \"string\", \"boolean\"];\n\n/** The spec of an op without an entry in the op table of a domain with `methods: \"all\"`. */\nconst NO_SPEC: OpSpec<unknown> = Object.freeze({});\n\n/** The function of an op: the receiver comes first, then the arguments. */\ntype OpFn = (self: unknown, ...args: readonly unknown[]) => unknown;\n\n/**\n * A target of an axis: its key, and the error of a test of `where` or of an error item. A target of the axis `list` also\n * has the value of its item and its position as `nth` counts it (AXIS.LIST.ITEM, AXIS.LIST.INDEX).\n */\ninterface Target {\n readonly key: string;\n readonly test?: Result<unknown>;\n readonly value?: unknown;\n readonly index?: number;\n}\n\n/** The targets of an axis from a frame, or the error of the axis. */\ntype Targets = (f: Frame, c: Ctx) => Result<readonly Target[]>;\n\n/**\n * This function adds the names `as` of a loop to the names of a body or of a step. The first name holds the value of\n * the item, and the second its index (AXIS.LIST.ITEM, AXIS.LIST.INDEX). A loop without `as` keeps its names.\n */\nfunction withItem(env: Env, as: ItemNames | undefined, t: Target): Env {\n // A scope with one name reads only the first value.\n return as === undefined ? env : new Scope(env, as, [ok(t.value), ok(t.index)]);\n}\n\n/** The static facts of a node for its trace events. */\ninterface Info {\n readonly path: readonly number[];\n readonly tag: Expr[\"tag\"];\n readonly label: string;\n}\n\nclass Compiler {\n readonly #domains: readonly AnyDomain[];\n readonly #fns: Readonly<Record<string, FreeFn>> | undefined;\n readonly #extensions: Readonly<Record<string, ExtHandler>> | undefined;\n /** The index of the keys of each list that `get` read (LIST.GET). A list does not change, so its index stays right. */\n readonly #keyIndex = new WeakMap<VexList, KeyIndex>();\n /**\n * The domains that can accept a value of each primitive type, in order (KIND.PRIMITIVE). These are the domains of\n * that type and the domains without a primitive type.\n */\n readonly #ofType = new Map<string, readonly AnyDomain[]>();\n /** The domains without a primitive type. Only they can accept a value of another type, for example an object. */\n readonly #open: readonly AnyDomain[];\n /** The slot of the column of each `fix` around the node that the compiler reads (FIX.LAST). A symbol is no name of the program. */\n #columns: ReadonlyMap<string, symbol> = new Map();\n\n constructor(opts: CompileOptions) {\n // Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain matches no value\n this.#domains = opts.domains ?? [];\n this.#fns = opts.fns;\n this.#extensions = opts.extensions;\n this.#open = this.#domains.filter((d) => d.primitive === undefined);\n for (const t of PRIMITIVE_TYPES) this.#ofType.set(t, this.#domains.filter((d) => d.primitive === undefined || d.primitive === t));\n }\n\n #err(kind: ErrorKind, message: string, f: Frame, path: readonly number[], extra: { op?: string; causes?: readonly VexError[]; thrown?: unknown } = {}): Result<never> {\n return fail(vexError(kind, message, { path, origin: f.pos.origin, focus: f.pos.focus, ...extra }));\n }\n\n /** This method gives the error of a text at a node (`errorAt`). */\n #at(text: ErrorText, f: Frame, path: readonly number[], extra?: ErrorExtra): Result<never> {\n return fail(errorAt(text, f.pos, path, extra));\n }\n\n /** This method gives the error of a position of an array without a value (LIST.ARRAY), at a node. */\n #missing(f: Frame, path: readonly number[]): (message: string) => VexError {\n return (message) => vexError(\"missing-field\", message, { path, origin: f.pos.origin, focus: f.pos.focus });\n }\n\n /** This method gives the list of `fill(n, value)` (LIST.FILL). A count that is not a whole number from 0 to 100000 gives `#VALUE!`. */\n fill(values: readonly unknown[], f: Frame, path: readonly number[]): Result<VexList> {\n const [n, value] = values;\n if (!isFillCount(n)) return this.#err(\"kind-mismatch\", `\"fill\" needs a whole number from 0 to 100000, not ${describeType(n)}`, f, path, { op: \"fill\" });\n if (value === undefined) return this.#err(\"bad-expression\", '\"fill\" needs argument 2', f, path, { op: \"fill\" });\n // Each item of the list has the value, so the list has the shape of LIST.SHAPE.\n const list = fillList(n, value);\n CHECKED.add(list);\n return ok(list);\n }\n\n #emit(c: Ctx, info: Info, f: Frame, result: Result<unknown>, reads?: readonly Read[]): Result<unknown> {\n if (c.trace !== undefined) {\n const event: TraceEvent = {\n path: info.path,\n tag: info.tag,\n label: info.label,\n origin: f.pos.origin,\n focus: f.pos.focus,\n ...(reads === undefined ? {} : { reads }),\n result,\n };\n c.trace.events.push(event);\n }\n return result;\n }\n\n /** This method compiles the expression `e` at the position `path` of the tree. */\n node(e: Expr, path: readonly number[]): Node {\n const info: Info = { path, tag: e.tag, label: labelOf(e) };\n switch (e.tag) {\n case \"lit\": {\n const r = ok(e.value);\n return (f, c) => this.#emit(c, info, f, r);\n }\n case \"ref\":\n return this.#ref(e, info);\n case \"var\": {\n const name = e.name;\n return (f, c) => {\n const bound = f.env.get(name);\n // A function is not a value (FN.VALUE).\n if (bound?.ok === true && bound.value instanceof Closure) return this.#emit(c, info, f, this.#at(errorText.functionValue(name), f, path));\n return this.#emit(c, info, f, bound ?? this.#at(errorText.unbound(name), f, path));\n };\n }\n case \"fn\":\n return this.#fn(e, path);\n case \"call\":\n return this.#callFn(e, info);\n case \"let\": {\n const names = Object.keys(e.bind);\n const binds = this.#nodes(Object.values(e.bind), path);\n const body = this.node(e.body, [...path, binds.length]);\n return (f, c) => {\n // Each binding evaluates with the outer names, so a binding does not see the other bindings.\n const values: Result<unknown>[] = [];\n for (const n of binds) values.push(n(f, c));\n return this.#emit(c, info, f, body({ pos: f.pos, env: new Scope(f.env, names, values) }, c));\n };\n }\n case \"rec\": {\n const names = Object.keys(e.fields);\n const fields = this.#nodes(Object.values(e.fields), path);\n return (f, c) => {\n const values = this.#all(fields, f, c, path, \"fields\");\n if (!values.ok) return this.#emit(c, info, f, values);\n // Object.fromEntries gives an own field for each name, also for \"__proto__\" (V-062).\n const out = Object.fromEntries(names.map((n, i) => [n, values.value[i]]));\n return this.#emit(c, info, f, ok(Object.freeze(out)));\n };\n }\n case \"app\":\n return isSpecialForm(e.op) ? this.#special(e.op, this.#nodes(e.args, path), info) : this.#app(e.op, this.#nodes(e.args, path), info);\n case \"each\":\n return this.#each(e, info);\n case \"fold\":\n return this.#fold(e, info);\n case \"iterate\":\n return this.#iterate(e, info);\n case \"fix\":\n return this.#fix(e, info);\n case \"last\":\n return this.#last(e, info);\n case \"ext\": {\n const extensions = this.#extensions ?? {};\n const handler = Object.hasOwn(extensions, e.kind) ? extensions[e.kind] : undefined;\n const { kind, data } = e;\n if (handler === undefined) return (f, c) => this.#emit(c, info, f, this.#at(errorText.noHandler(kind), f, path));\n return (f, c) =>\n this.#emit(c, info, f, this.#locate(this.#guard(() => handler(data, { space: c.space, position: f.pos, path }), f, path, kind), f, path));\n }\n }\n }\n\n #nodes(es: readonly Expr[], path: readonly number[]): readonly Node[] {\n return es.map((x, i) => this.node(x, [...path, i]));\n }\n\n /**\n * This method compiles a function (FN.BIND). Its value is a closure: the parameters, the body, and the names of the\n * place of its binding. A binding of `let` does not see the other bindings, so a function cannot call itself.\n */\n #fn(e: ExprOf<\"fn\">, path: readonly number[]): Node {\n const body = this.node(e.body, [...path, 0]);\n return (f) => ok(new Closure(e.params, body, f.env));\n }\n\n /**\n * This method compiles a call (FN.CALL, FN.ARGS). Each parameter gets the result of its argument at the call, so an\n * argument that fails has an effect only where the body reads it. The body evaluates at the position of the call.\n */\n #callFn(e: ExprOf<\"call\">, info: Info): Node {\n const { path } = info;\n const args = this.#nodes(e.args, path);\n return (f, c) => {\n const bound = f.env.get(e.fn);\n if (bound === undefined) return this.#emit(c, info, f, this.#at(errorText.noFunction(e.fn), f, path));\n if (!bound.ok) return this.#emit(c, info, f, bound);\n const callee = bound.value;\n if (!(callee instanceof Closure)) return this.#emit(c, info, f, this.#at(errorText.notFunction(e.fn), f, path));\n if (callee.params.length !== args.length) return this.#emit(c, info, f, this.#at(errorText.arity(e.fn, callee.params.length, args.length), f, path));\n const values: Result<unknown>[] = [];\n for (const n of args) values.push(n(f, c));\n return this.#emit(c, info, f, callee.body({ pos: f.pos, env: new Scope(callee.env, callee.params, values) }, c));\n };\n }\n\n /** This method gives an error of a handler the path, the origin and the focus of its node, if it has no origin. */\n #locate(r: Result<unknown>, f: Frame, path: readonly number[]): Result<unknown> {\n if (r.ok || r.error.origin !== undefined) return r;\n return fail({ ...r.error, path, origin: f.pos.origin, focus: f.pos.focus });\n }\n\n #guard(run: () => Result<unknown>, f: Frame, path: readonly number[], op: string): Result<unknown> {\n try {\n return run();\n } catch (thrown) {\n return this.#threw(thrown, errorText.threw(op), f, path);\n }\n }\n\n /** This method gives the error of an exception: `#DEPTH!` for a full call stack, and `#CALC!` for each other exception. */\n #threw(thrown: unknown, text: ErrorText, f: Frame, path: readonly number[]): Result<never> {\n return this.#at(isStackOverflow(thrown) ? { ...text, kind: \"depth\", message: DEPTH_MESSAGE } : text, f, path, { thrown });\n }\n\n /**\n * This method compiles an address. Its function gives the key where the address points. The expressions of the\n * computed moves evaluate first, at the position of the node, and their child indexes start at `first`. An error of\n * an expression keeps its path, and an error of a move gets the path of the node.\n */\n #address(at: Addr, path: readonly number[], first: number): (f: Frame, c: Ctx) => Result<string> {\n const nodes = addrExprs(at).map((x, i) => this.node(x, [...path, first + i]));\n const moved = (r: Result<string>): Result<string> => (r.ok ? r : fail({ ...r.error, path }));\n if (nodes.length === 0) return (f, c) => moved(resolveAddr(c.space, f.pos, at as readonly FixedMove[]));\n return (f, c) => {\n const values: unknown[] = [];\n for (const n of nodes) {\n const r = n(f, c);\n if (!r.ok) return r;\n values.push(r.value);\n }\n const fixed = fixAddr(at, values, f.pos);\n return fixed.ok ? moved(resolveAddr(c.space, f.pos, fixed.value)) : moved(fixed);\n };\n }\n\n #ref(e: ExprOf<\"ref\">, info: Info): Node {\n const { path } = info;\n const segs = e.path;\n const at = e.at ?? [];\n const address = this.#address(at, path, 0);\n const label = segs.join(\".\");\n const steps = segs.map((seg, i) => ({ seg, where: segs.slice(0, i + 1).join(\".\"), valid: isFieldName(seg) }));\n return (f, c) => {\n let key = f.pos.focus;\n // The empty address resolves to the focus, so this fast path changes no result.\n // Stryker disable next-line ConditionalExpression,EqualityOperator: resolveAddr of [] gives the focus too\n if (at.length > 0) {\n const where = address(f, c);\n if (!where.ok) return this.#emit(c, info, f, where);\n key = where.value;\n }\n const failed = (r: Result<unknown>): Result<unknown> => this.#emit(c, info, f, r, [{ key, path: segs, ok: false }]);\n const missing = (where: string): Result<unknown> => failed(this.#at(errorText.missing(key, where), f, path));\n let value: unknown = c.space.get(key);\n if (value === undefined || value === null) return missing(label === \"\" ? \"(record)\" : label);\n for (const { seg, where, valid } of steps) {\n if ((typeof value !== \"object\" && typeof value !== \"function\") || !valid) return missing(where);\n try {\n value = Reflect.get(value, seg);\n } catch (thrown) {\n return failed(this.#threw(thrown, errorText.readThrew(key, where), f, path));\n }\n if (value === undefined || value === null) return missing(where);\n }\n return this.#emit(c, info, f, ok(value), [{ key, path: segs, ok: true }]);\n };\n }\n\n /** This method evaluates nodes applicatively. One failure stays as it is. Two or more give `#ARGS`. */\n #all(nodes: readonly Node[], f: Frame, c: Ctx, path: readonly number[], what: string): Result<readonly unknown[]> {\n const values: unknown[] = [];\n let first: VexError | undefined;\n let errors: VexError[] | undefined;\n for (const n of nodes) {\n const r = n(f, c);\n if (r.ok) values.push(r.value);\n else if (first === undefined) first = r.error;\n else (errors ??= [first]).push(r.error);\n }\n if (first === undefined) return ok(values);\n // A #DEPTH! argument is the result, so #ARGS does not wrap it, and ifError cannot hide it.\n const depth = [first, ...(errors ?? [])].find(isDepthError);\n if (depth !== undefined) return fail(depth);\n return errors === undefined ? fail(first) : this.#at(errorText.args(errors.length, what), f, path, { causes: errors });\n }\n\n #each(e: ExprOf<\"each\">, info: Info): Node {\n const { path } = info;\n const at = e.at ?? [];\n const counter = { next: 1 };\n const targets = this.#targets(e.axis, path, counter);\n const body = this.node(e.body, [...path, 0]);\n const address = this.#address(at, path, counter.next);\n return (f, c) => {\n // An axis with an address finds its targets from the key of the address. The origin does not change.\n let from = f;\n // Stryker disable next-line ConditionalExpression,EqualityOperator: resolveAddr of [] gives the focus too\n if (at.length > 0) {\n const where = address(f, c);\n if (!where.ok) return this.#emit(c, info, f, where);\n from = { pos: { origin: f.pos.origin, focus: where.value }, env: f.env };\n }\n // The axis table moves the evaluation to the space of its table, where the origin of this space is not a key.\n // Thus there the origin is the target, and a value of this space goes in through a variable.\n const base = baseAxis(e.axis);\n const axisCtx = this.#axisCtx(base, f, c, path);\n if (!axisCtx.ok) return this.#emit(c, info, f, axisCtx);\n const inner = axisCtx.value;\n const ts = targets(from, inner);\n if (!ts.ok) return this.#emit(c, info, f, ts);\n const items: ListItem[] = ts.value.map((t) => {\n const { key, test } = t;\n if (test !== undefined && !test.ok) return { key, result: test };\n return { key, result: body({ pos: { origin: base.t === \"table\" ? key : f.pos.origin, focus: key }, env: withItem(f.env, e.as, t) }, inner) };\n });\n return this.#emit(c, info, f, ok(vexList(items)));\n };\n }\n\n /**\n * This method compiles the names of a loop: `init` at the indexes from 0, and `step` after them (LOOP.NAMES). Its\n * functions give the first values, and the values after one step. The first error stops each of them.\n */\n #names(e: ExprOf<\"fold\"> | ExprOf<\"iterate\">, path: readonly number[]): {\n readonly first: (f: Frame, c: Ctx) => Result<Scope>;\n readonly next: (f: Frame, c: Ctx, scope: Scope) => Result<Scope>;\n } {\n const names = Object.keys(e.init);\n const inits = this.#nodes(Object.values(e.init), path);\n const steps = Object.values(e.step).map((x, i) => this.node(x, [...path, inits.length + i]));\n // Each name of a step is a name of init (LOOP.NAMES), so a step changes the value at a position of the scope.\n const at = Object.keys(e.step).map((name) => names.indexOf(name));\n return {\n first: (f, c) => {\n const values = allValues(inits, f, c);\n return values.ok ? ok(new Scope(f.env, names, values.value)) : values;\n },\n // Each value of a step reads the values before the step, so the names change only after all the values. The new\n // names come from `scope`, the scope of the loop, because the frame can have more names, for example the names of\n // an item (AXIS.LIST.SCOPE).\n next: (f, c, scope) => {\n const values = allValues(steps, f, c);\n return values.ok ? ok(scope.with(at, values.value)) : values;\n },\n };\n }\n\n /**\n * This method compiles a fold (FOLD.ORDER, FOLD.ERROR). `init` evaluates at the node, then the address and the\n * targets. A step evaluates at each target in order. `result` evaluates at the node with the last values.\n */\n #fold(e: ExprOf<\"fold\">, info: Info): Node {\n const { path } = info;\n const at = e.at ?? [];\n const names = this.#names(e, path);\n const counter = { next: Object.keys(e.init).length + Object.keys(e.step).length };\n const targets = this.#targets(e.axis, path, counter);\n const address = this.#address(at, path, counter.next);\n const result = this.node(e.result, [...path, counter.next + addrExprs(at).length]);\n const base = baseAxis(e.axis);\n return (f, c) => {\n const first = names.first(f, c);\n if (!first.ok) return this.#emit(c, info, f, first);\n let env = first.value;\n let from = f;\n // Stryker disable next-line ConditionalExpression,EqualityOperator: resolveAddr of [] gives the focus too\n if (at.length > 0) {\n const where = address(f, c);\n if (!where.ok) return this.#emit(c, info, f, where);\n from = { pos: { origin: f.pos.origin, focus: where.value }, env: f.env };\n }\n const axisCtx = this.#axisCtx(base, f, c, path);\n if (!axisCtx.ok) return this.#emit(c, info, f, axisCtx);\n const inner = axisCtx.value;\n const ts = targets(from, inner);\n if (!ts.ok) return this.#emit(c, info, f, ts);\n for (const t of ts.value) {\n const { key, test } = t;\n if (test !== undefined && !test.ok) return this.#emit(c, info, f, test);\n const after = names.next({ pos: { origin: base.t === \"table\" ? key : f.pos.origin, focus: key }, env: withItem(env, e.as, t) }, inner, env);\n if (!after.ok) return this.#emit(c, info, f, after);\n env = after.value;\n }\n return this.#emit(c, info, f, result({ pos: f.pos, env }, c));\n };\n }\n\n /**\n * This method compiles an iteration (ITERATE.LIMIT, ITERATE.UNTIL, ITERATE.ERROR). The test `until` evaluates before\n * each step and after the last step. `result` evaluates with the last values.\n */\n /**\n * This method compiles a fixed-point column (FIX.ROUNDS). Each round evaluates each row from the column of the last\n * round, so the order of the rows has no effect. The first round without a change ends the rounds.\n */\n #fix(e: ExprOf<\"fix\">, info: Info): Node {\n const { path } = info;\n const { name, join } = e;\n const init = this.node(e.init, [...path, 0]);\n const slot = Symbol(name);\n const outer = this.#columns;\n this.#columns = new Map(outer).set(name, slot);\n const step = this.node(e.step, [...path, 1]);\n this.#columns = outer;\n return (f, c) => {\n const { keys } = c.space;\n const first = this.#rows(e, init, f, f.env, c, path);\n if (!first.ok) return this.#emit(c, info, f, first);\n let column = first.value;\n this.#round(c, info, f, 0, keys, column);\n const limit = fixRounds(keys.length);\n for (let round = 1; round <= limit; round++) {\n const stepped = this.#rows(e, step, f, new Scope(f.env, [slot], [ok(column)]), c, path);\n if (!stepped.ok) return this.#emit(c, info, f, stepped);\n const next = new Map<string, unknown>();\n const changed: string[] = [];\n for (const key of keys) {\n const old = column.get(key);\n const value = joinValues(join, old, stepped.value.get(key));\n if (value !== old) changed.push(key);\n next.set(key, value);\n }\n this.#round(c, info, f, round, changed, next);\n if (changed.length === 0) return this.#emit(c, info, f, this.#rowOf(name, column, f, path));\n column = next;\n }\n return this.#emit(c, info, f, this.#at(errorText.fixLimit(name, limit), f, path));\n };\n }\n\n /** This method evaluates a node at each row (FIX.ERROR). Each row runs, also after an error, so the rule of the errors has all of them. */\n #rows(e: ExprOf<\"fix\">, node: Node, f: Frame, env: Env, c: Ctx, path: readonly number[]): Result<ReadonlyMap<string, unknown>> {\n const out = new Map<string, unknown>();\n const errors: VexError[] = [];\n for (const key of c.space.keys) {\n const frame: Frame = { pos: { origin: f.pos.origin, focus: key }, env };\n const r = node(frame, c);\n const wrong = r.ok ? fixValueError(e.name, e.join, r.value) : undefined;\n if (!r.ok) errors.push(r.error);\n else if (wrong !== undefined) errors.push(errorAt(wrong, frame.pos, path));\n else out.set(key, r.value);\n }\n if (errors.length === 0) return ok(out);\n const worst = worstRow(errors);\n return worst === undefined ? this.#at(errorText.args(errors.length, \"rows\"), f, path, { causes: errors }) : fail(worst);\n }\n\n /** This method adds a round to the trace: the count of the round, the rows that it changed and the column (FIX.TRACE). */\n #round(c: Ctx, info: Info, f: Frame, round: number, changed: readonly string[], column: ReadonlyMap<string, unknown>): void {\n if (c.trace === undefined) return;\n const items = [...column].map(([key, value]): ListItem => ({ key, result: ok(value) }));\n c.trace.events.push({\n path: info.path,\n tag: info.tag,\n label: `${info.label}: round ${String(round)}, ${String(changed.length)} rows changed`,\n origin: f.pos.origin,\n focus: f.pos.focus,\n round: { index: round, changed },\n result: ok(vexList(items)),\n });\n }\n\n /** This method gives the value of the row of the focus. The focus of an item of the axis `list` can be no row (FIX.LAST). */\n #rowOf(name: string, column: ReadonlyMap<string, unknown>, f: Frame, path: readonly number[]): Result<unknown> {\n const value = column.get(f.pos.focus);\n return value === undefined ? this.#at(errorText.lastKey(name, f.pos.focus), f, path) : ok(value);\n }\n\n /** This method compiles a read of the last round at the focus (FIX.LAST). The check gives each read a `fix`. */\n #last(e: ExprOf<\"last\">, info: Info): Node {\n const { path } = info;\n const slot = this.#columns.get(e.name) as symbol;\n return (f, c) => {\n const column = f.env.get(slot) as { readonly value: ReadonlyMap<string, unknown> };\n return this.#emit(c, info, f, this.#rowOf(e.name, column.value, f, path));\n };\n }\n\n #iterate(e: ExprOf<\"iterate\">, info: Info): Node {\n const { path } = info;\n const names = this.#names(e, path);\n const counter = { next: Object.keys(e.init).length + Object.keys(e.step).length };\n const axis = limitAxis(e);\n const size = axis === undefined ? undefined : this.#size(axis, path, counter);\n const untilAt = counter.next;\n const untilPath = [...path, untilAt];\n const until = e.until === undefined ? undefined : this.node(e.until, untilPath);\n const result = this.node(e.result, [...path, untilAt + (until === undefined ? 0 : 1)]);\n const fixed = e.limit as number;\n return (f, c) => {\n const first = names.first(f, c);\n if (!first.ok) return this.#emit(c, info, f, first);\n let env = first.value;\n let limit = fixed;\n // The data limit evaluates at the node, after the first values and before the steps (ITERATE.LIMIT.DATA).\n if (size !== undefined) {\n const counted = size(f, c);\n if (!counted.ok) return this.#emit(c, info, f, counted);\n limit = counted.value;\n }\n for (let k = 0; ; k++) {\n const frame: Frame = { pos: f.pos, env };\n if (until !== undefined) {\n const t = until(frame, c);\n if (!t.ok) return this.#emit(c, info, f, t);\n if (t.value === true) break;\n if (t.value !== false) return this.#emit(c, info, f, this.#at(errorText.untilKind(t.value), f, untilPath));\n }\n if (k === limit) {\n if (until !== undefined) return this.#emit(c, info, f, this.#at(errorText.limit(limit), f, path));\n break;\n }\n const after = names.next(frame, c, env);\n if (!after.ok) return this.#emit(c, info, f, after);\n env = after.value;\n }\n return this.#emit(c, info, f, result({ pos: f.pos, env }, c));\n };\n }\n\n /**\n * This method compiles a data limit: the number of targets of an axis (ITERATE.LIMIT.DATA). Each failure of the axis, of\n * a test or of an item, and a count above the cap, is one error (ITERATE.LIMIT.ERROR).\n */\n #size(axis: Axis, path: readonly number[], counter: { next: number }): (f: Frame, c: Ctx) => Result<number> {\n const targets = this.#targets(axis, path, counter);\n const base = baseAxis(axis);\n const invalid = (f: Frame, cause: VexError): Result<never> => fail(limitError(cause, { path, origin: f.pos.origin, focus: f.pos.focus }));\n return (f, c) => {\n const inner = this.#axisCtx(base, f, c, path);\n if (!inner.ok) return invalid(f, inner.error);\n const ts = targets(f, inner.value);\n if (!ts.ok) return invalid(f, ts.error);\n const cause = worstError(ts.value.flatMap(({ test }) => (test === undefined || test.ok ? [] : test.error)));\n if (cause !== undefined) return invalid(f, cause);\n const count = ts.value.length;\n return count > MAX_ITERATIONS ? this.#err(\"limit\", overLimitMessage(count), f, path) : ok(count);\n };\n }\n\n /** This method gives the context of an axis: the space of its table for the axis `table`, or `c` (AXIS.TABLE). */\n #axisCtx(base: Axis, f: Frame, c: Ctx, path: readonly number[]): Result<Ctx> {\n if (base.t !== \"table\") return ok(c);\n const space = c.tables !== undefined && Object.hasOwn(c.tables, base.name) ? c.tables[base.name] : undefined;\n return space === undefined ? this.#at(errorText.noTable(base.name), f, path) : ok({ ...c, space });\n }\n\n /** This method compiles the targets of an axis. For `where`, a failed test keeps the target with its error. */\n #targets(a: Axis, path: readonly number[], counter: { next: number }): Targets {\n if (a.t === \"table\") return (_f, c) => ok(c.space.keys.map((key) => ({ key })));\n const base = a.t === \"reverse\" ? a.axis : a;\n if (base.t === \"list\") return this.#listTargets(base.list, a.t === \"reverse\", path, counter);\n if (a.t !== \"where\") {\n return (f, c) => {\n const keys = axisTargets(c.space, f.pos, a);\n return keys.ok ? ok(keys.value.map((key) => ({ key }))) : fail({ ...keys.error, path });\n };\n }\n const inner = this.#targets(a.axis, path, counter);\n const testPath = [...path, counter.next++];\n const test = this.node(a.test, testPath);\n // In the space of the axis table, the origin of the test is the target, as for the body.\n const sameOrigin = baseAxis(a).t === \"table\";\n return (f, c) => {\n const ts = inner(f, c);\n if (!ts.ok) return ts;\n const out: Target[] = [];\n for (const t of ts.value) {\n if (t.test !== undefined && !t.test.ok) {\n out.push(t);\n continue;\n }\n const at: Frame = { pos: { origin: sameOrigin ? t.key : f.pos.origin, focus: t.key }, env: f.env };\n const r = test(at, c);\n if (!r.ok) out.push({ key: t.key, test: r });\n // The target keeps the value and the index of its item (AXIS.LIST.ITEM).\n else if (r.value === true) out.push(t);\n else if (r.value !== false) {\n out.push({ key: t.key, test: this.#at(errorText.whereKind(r.value), at, testPath) });\n }\n }\n return ok(out);\n };\n }\n\n /**\n * This method compiles the targets of the axis list (AXIS.LIST): the keys of the items of a list, in its order. The\n * expression evaluates at the key of the address. An error item keeps its target with its error.\n */\n #listTargets(list: Expr, reverse: boolean, path: readonly number[], counter: { next: number }): Targets {\n const node = this.node(list, [...path, counter.next++]);\n return (f, c) => {\n const r = node(f, c);\n if (!r.ok) return r;\n // LIST.ARRAY: an array is a list with the positions as keys.\n const listed = asList(r.value, this.#missing(f, path));\n if (listed === undefined) return this.#at(errorText.axisList(r.value), f, path);\n // The index counts the items with a value, as nth does: nth skips the error items (LIST.LENIENT).\n let index = 0;\n const items = listed.items.map(({ key, result }): Target => (result.ok ? { key, value: result.value, index: index++ } : { key, test: result }));\n return ok(reverse ? items.toReversed() : items);\n };\n }\n\n #app(op: string, args: readonly Node[], info: Info): Node {\n const { path } = info;\n const listOp = isListOp(op) ? op : undefined;\n const fn = this.#fns !== undefined && Object.hasOwn(this.#fns, op) ? this.#fns[op] : undefined;\n // A name that cannot be an op name has no op, also with an own entry in an op table (resolveOp).\n const named = isOpName(op);\n return (f, c) => {\n const all = this.#all(args, f, c, path, \"arguments\");\n if (!all.ok) return this.#emit(c, info, f, all);\n const values = all.value;\n const self = values[0];\n if (listOp !== undefined && isVexList(self)) return this.#emit(c, info, f, this.listOp(listOp, self, values.slice(1), f, path));\n let accepted: AnyDomain | undefined;\n // Without arguments, the receiver is undefined, and no domain of a test accepts it.\n // Stryker disable next-line ConditionalExpression,EqualityOperator: the loop finds no domain for undefined\n if (values.length > 0) {\n for (const d of this.#domains) {\n if (!safeIs(d, self)) continue;\n accepted ??= d;\n // The rules of resolveOp, without a closure for each call: the function of the spec, or a method of the\n // receiver for a declared op without a function, or for each op of a domain with `methods: \"all\"`.\n const spec = named && Object.hasOwn(d.ops, op) ? (d.ops[op] as OpSpec<unknown>) : undefined;\n if (spec?.fn !== undefined) return this.#emit(c, info, f, this.#call(d, spec, spec.fn as OpFn, self, op, values.slice(1), f, path));\n const method = spec !== undefined || d.methods === \"all\" ? findMethod(self, op) : undefined;\n if (method !== undefined) return this.#emit(c, info, f, this.#call(d, spec ?? NO_SPEC, (receiver, ...given) => method.apply(receiver, [...given]), self, op, values.slice(1), f, path));\n }\n }\n if (fn !== undefined) return this.#emit(c, info, f, this.#checkResult(this.#invoke(() => fn(...values), op, f, path), f, path, op));\n // LIST.ARRAY and LIST.FILL come after the domains and the functions of the host, so each of their results stays.\n if (listOp !== undefined && Array.isArray(self)) return this.#emit(c, info, f, this.arrayOp(listOp, self, values.slice(1), f, path));\n if (op === \"fill\") return this.#emit(c, info, f, this.fill(values, f, path));\n if (accepted !== undefined) return this.#emit(c, info, f, this.#at(errorText.domainNoOp(accepted.name, op), f, path));\n if (values.length === 0) return this.#emit(c, info, f, this.#at(errorText.noOp(op), f, path));\n return this.#emit(c, info, f, this.#at(errorText.noDomain(op, self), f, path));\n };\n }\n\n #special(op: SpecialForm, args: readonly Node[], info: Info): Node {\n const { path } = info;\n const arg = (i: number, f: Frame, c: Ctx): Result<unknown> => {\n const n = args[i];\n return n === undefined ? this.#at(errorText.needsArgument(op, i), f, path) : n(f, c);\n };\n const bool = (i: number, f: Frame, c: Ctx): Result<boolean> => {\n const r = arg(i, f, c);\n if (!r.ok) return r;\n return typeof r.value === \"boolean\" ? ok(r.value) : this.#at(errorText.notBoolean(op, i, r.value), f, path);\n };\n switch (op) {\n case \"if\":\n return (f, c) => {\n const cond = bool(0, f, c);\n return this.#emit(c, info, f, cond.ok ? arg(cond.value ? 1 : 2, f, c) : cond);\n };\n case \"and\":\n case \"or\": {\n const stop = op === \"or\";\n return (f, c) => {\n if (args.length === 0) return this.#emit(c, info, f, this.#at(errorText.needsArguments(op), f, path));\n for (let i = 0; i < args.length; i++) {\n const b = bool(i, f, c);\n if (!b.ok) return this.#emit(c, info, f, b);\n if (b.value === stop) return this.#emit(c, info, f, ok(b.value));\n }\n return this.#emit(c, info, f, ok(!stop));\n };\n }\n case \"ifError\":\n return (f, c) => {\n const first = arg(0, f, c);\n // EVAL.DEPTH: ifError does not hide #DEPTH!, because the engine, not the data, failed.\n return this.#emit(c, info, f, first.ok || isDepthError(first.error) ? first : arg(1, f, c));\n };\n }\n }\n\n /** This method starts an op that resolveOp found, for example a method of the receiver. */\n #callResolved(op: ResolvedOp, self: unknown, name: string, rest: readonly unknown[], f: Frame, path: readonly number[]): Result<unknown> {\n return this.#call(op.domain, op.spec, (_self, ...args) => op.call(args), self, name, rest, f, path);\n }\n\n /**\n * This method starts the op `name` of the domain `domain` with the receiver `self` and the arguments `rest`. It lifts\n * the numbers, checks the arguments and checks the result.\n */\n #call(domain: AnyDomain, spec: OpSpec<unknown>, run: OpFn, self: unknown, name: string, rest: readonly unknown[], f: Frame, path: readonly number[]): Result<unknown> {\n const lift = spec.liftScalar;\n const from = domain.fromScalar;\n let callArgs: readonly unknown[] = rest;\n if (lift && from !== undefined) {\n const lifted = this.#invoke(() => rest.map((a, i): unknown => (typeof a === \"number\" && liftsAt(lift, i) ? from(a) : a)), `${domain.name}.fromScalar`, f, path);\n if (!lifted.ok) return lifted;\n callArgs = lifted.value as readonly unknown[];\n }\n if (spec.params !== undefined) {\n for (let i = 0; i < callArgs.length; i++) {\n const kind = spec.params[i] ?? \"any\";\n if (!matchesKind(kind, callArgs[i], domain)) return this.#at(errorText.badParam(name, i, callArgs[i], kind, domain.name), f, path);\n }\n }\n let value: unknown;\n try {\n value = run(self, ...callArgs);\n } catch (thrown) {\n return this.#threw(thrown, errorText.threw(name), f, path);\n }\n return this.#checkResult(ok(value), f, path, name);\n }\n\n #invoke(run: () => unknown, op: string, f: Frame, path: readonly number[]): Result<unknown> {\n try {\n return ok(run());\n } catch (thrown) {\n return this.#threw(thrown, errorText.threw(op), f, path);\n }\n }\n\n /**\n * This method gives the first domain that accepts a value. It starts only the tests of the domains without a primitive\n * type: a domain of the type of the value accepts it (KIND.PRIMITIVE).\n */\n #domainOf(value: unknown): AnyDomain | undefined {\n const candidates = this.#ofType.get(typeof value) ?? this.#open;\n for (const d of candidates) if (d.primitive !== undefined || testIs(d, value)) return d;\n return undefined;\n }\n\n /** This method checks the value that an op gave: no `undefined`, finite numbers, and valid domain values. */\n #checkResult(r: Result<unknown>, f: Frame, path: readonly number[], op: string): Result<unknown> {\n if (!r.ok) return r;\n const value = r.value;\n if (value === undefined || value === null) return this.#at(errorText.noValue(op), f, path);\n if (typeof value === \"number\" && !Number.isFinite(value)) return this.#at(errorText.notFinite(op, value), f, path);\n const d = this.#domainOf(value);\n if (d?.valid !== undefined) {\n let valid: boolean;\n try {\n valid = d.valid(value);\n } catch (thrown) {\n return this.#threw(thrown, errorText.validThrew(op, d.name), f, path);\n }\n if (!valid) return this.#at(errorText.invalid(op, d.name), f, path);\n }\n return r;\n }\n\n /** This method gives the result of a list op on an array (LIST.ARRAY): the list op on the list of its items. */\n arrayOp(op: ListOp, array: readonly unknown[], rest: readonly unknown[], f: Frame, path: readonly number[]): Result<unknown> {\n return this.listOp(op, listOfArray(array, this.#missing(f, path)), rest, f, path);\n }\n\n listOp(op: ListOp, list: VexList, rest: readonly unknown[], f: Frame, path: readonly number[]): Result<unknown> {\n // The options come after the second argument of an op with one, for example the count of take.\n const optsArg = op === \"setNth\" ? rest[2] : WITH_ARGUMENT.has(op) ? rest[1] : rest[0];\n const strict = (optsArg as ListOptions | null | undefined)?.strict === true;\n if (op === \"get\") return this.#get(list, rest[0], strict, f, path);\n if (op === \"group\") return this.#group(list, rest[0], strict, f, path);\n const good = goodItems(list, strict);\n if (!good.ok) return good;\n const okItems = good.value;\n const okValues: unknown[] = [];\n for (const it of okItems) okValues.push(valueOf(it));\n const numbers = (): Result<readonly number[]> => {\n const bad = okValues.find((x) => typeof x !== \"number\");\n return bad === undefined ? ok(okValues as readonly number[]) : this.#at(errorText.needsItems(op, \"numbers\", bad), f, path);\n };\n const booleans = (): Result<readonly boolean[]> => {\n const bad = okValues.find((x) => typeof x !== \"boolean\");\n return bad === undefined ? ok(okValues as readonly boolean[]) : this.#at(errorText.needsItems(op, \"booleans\", bad), f, path);\n };\n const empty = (): Result<never> => this.#at(errorText.empty(op), f, path);\n // A count or a position of take, drop and nth is a whole number from 0.\n const whole = (): Result<number> => {\n const n = rest[0] as number;\n return Number.isSafeInteger(n) && n >= 0 ? ok(n) : this.#err(\"kind-mismatch\", `\"${op}\" needs a whole number from 0, not ${describeType(n)}`, f, path, { op });\n };\n // The second list of append and without follows the rules of the first list (LIST.BUILD).\n const other = (): Result<readonly ListItem[]> => {\n const second = asList(rest[0], this.#missing(f, path));\n return second !== undefined ? goodItems(second, strict) : this.#err(\"kind-mismatch\", `\"${op}\" needs a list as its second argument, not a ${describeType(rest[0])}`, f, path, { op });\n };\n switch (op) {\n case \"sortBy\":\n return this.#sortBy(okItems, okValues, optsArg, f, path);\n case \"take\":\n case \"drop\": {\n const n = whole();\n if (!n.ok) return n;\n return ok(checkedList(op === \"take\" ? okItems.slice(0, n.value) : okItems.slice(n.value)));\n }\n case \"append\": {\n const more = other();\n return more.ok ? ok(checkedList([...okItems, ...more.value])) : more;\n }\n case \"without\": {\n const more = other();\n if (!more.ok) return more;\n const gone = new Set(more.value.map((it) => it.key));\n return ok(checkedList(okItems.filter((it) => !gone.has(it.key))));\n }\n case \"flat\":\n return this.#flat(okValues, strict, f, path);\n case \"distinct\": {\n // The first item of each value, in the order of the list (LIST.DISTINCT). === compares the values, as for\n // indexOf, so each NaN stays.\n const seen = new Set<unknown>();\n const out: ListItem[] = [];\n for (let i = 0; i < okValues.length; i++) {\n const x = okValues[i];\n if (!isIndexValue(x)) return this.#err(\"kind-mismatch\", `\"distinct\" needs numbers, texts or booleans, but an item is a ${describeType(x)}`, f, path, { op });\n if (Number.isNaN(x) || !seen.has(x)) out.push(okItems[i] as ListItem);\n seen.add(x);\n }\n return ok(checkedList(out));\n }\n case \"join\": {\n // The texts of the items with the text sep between them (LIST.JOIN).\n const sep = rest[0];\n if (typeof sep !== \"string\") return this.#err(\"kind-mismatch\", `\"join\" needs a text separator, not a ${describeType(sep)}`, f, path, { op });\n const bad = okValues.find((x) => typeof x !== \"string\");\n return bad === undefined ? ok(okValues.join(sep)) : this.#err(\"kind-mismatch\", `\"join\" needs texts, but an item is a ${describeType(bad)}`, f, path, { op });\n }\n case \"indexOf\": {\n const x = rest[0];\n if (!isIndexValue(x)) return this.#err(\"kind-mismatch\", `\"indexOf\" needs a number, a text or a boolean, not a ${describeType(x)}`, f, path, { op });\n const i = okValues.indexOf(x);\n return i >= 0 ? ok(i) : this.#err(\"missing-field\", `the list has no item with the value ${JSON.stringify(x)}`, f, path, { op });\n }\n case \"nth\": {\n const i = whole();\n if (!i.ok) return i;\n return i.value < okValues.length ? ok(okValues[i.value]) : this.#err(\"empty\", `\"nth\" has no item at the position ${String(i.value)}, and the list has ${String(okValues.length)} items`, f, path, { op });\n }\n case \"setNth\": {\n const i = whole();\n if (!i.ok) return i;\n const old = okItems[i.value];\n if (old === undefined) return this.#err(\"empty\", `\"setNth\" has no item at the position ${String(i.value)}, and the list has ${String(okItems.length)} items`, f, path, { op });\n if (rest[1] === undefined) return this.#err(\"bad-expression\", '\"setNth\" needs argument 3', f, path, { op });\n const items = [...okItems];\n items[i.value] = { key: old.key, result: ok(rest[1]) };\n return ok(checkedList(items));\n }\n case \"count\":\n return ok(okValues.length);\n case \"values\":\n return ok(Object.freeze([...okValues]));\n case \"keys\":\n return ok(Object.freeze(okItems.map((it) => it.key)));\n case \"errors\":\n return ok(Object.freeze(list.items.flatMap((it) => (it.result.ok ? [] : [it.result.error]))));\n case \"first\":\n return okValues.length > 0 ? ok(okValues[0]) : empty();\n case \"sum\": {\n const n = numbers();\n return n.ok ? this.#checkResult(ok(n.value.reduce((s, x) => s + x, 0)), f, path, op) : n;\n }\n case \"mean\": {\n const n = numbers();\n if (!n.ok) return n;\n return n.value.length === 0 ? empty() : this.#checkResult(ok(n.value.reduce((s, x) => s + x, 0) / n.value.length), f, path, op);\n }\n case \"min\":\n case \"max\": {\n const n = numbers();\n if (!n.ok) return n;\n if (n.value.length === 0) return empty();\n return ok(n.value.reduce((best, x) => (op === \"min\" ? Math.min(best, x) : Math.max(best, x))));\n }\n case \"any\":\n case \"all\":\n case \"none\": {\n const b = booleans();\n if (!b.ok) return b;\n if (op === \"any\") return ok(b.value.some((x) => x));\n if (op === \"all\") return ok(b.value.every((x) => x));\n return ok(!b.value.some((x) => x));\n }\n case \"reduce\":\n return this.#reduce(rest[0], okValues, f, path, optsArg);\n }\n }\n\n /**\n * This method gives the value of the first item with a key (LIST.GET). LIST.LENIENT applies, so an error item is not\n * an item of the key. The program keeps the index of each list, so a step that reads each key of a list reads it once.\n */\n #get(list: VexList, key: unknown, strict: boolean, f: Frame, path: readonly number[]): Result<unknown> {\n let index = this.#keyIndex.get(list);\n // Stryker disable next-line ConditionalExpression: a new index of the same list has the same values\n if (index === undefined) {\n index = keyIndexOf(list);\n this.#keyIndex.set(list, index);\n }\n // As goodItems: #DEPTH! comes first, and with strict, the first error item is the result.\n const stop = index.depth ?? (strict ? index.first : undefined);\n if (stop !== undefined) return fail(stop);\n if (typeof key !== \"string\") return this.#err(\"kind-mismatch\", `\"get\" needs a text key, not a ${describeType(key)}`, f, path, { op: \"get\" });\n return index.values.has(key) ? ok(index.values.get(key)) : this.#err(\"missing-field\", `the list has no item with the key ${JSON.stringify(key)}`, f, path, { op: \"get\" });\n }\n\n /**\n * This method gives the groups of a list (LIST.GROUP). The item at a position has the key at the same position of\n * `keys`, so the two lists must have the same number of items. A pair with an error item or an error key is not in a\n * group (LIST.LENIENT). Each key gives one item, in the order of its first pair, and its value is a list of its items.\n */\n #group(list: VexList, keys: unknown, strict: boolean, f: Frame, path: readonly number[]): Result<VexList> {\n const good = goodItems(list, strict);\n if (!good.ok) return good;\n const listed = asList(keys, this.#missing(f, path));\n if (listed === undefined) return this.#err(\"kind-mismatch\", `\"group\" needs a list of keys as its second argument, not a ${describeType(keys)}`, f, path, { op: \"group\" });\n const goodKeys = goodItems(listed, strict);\n if (!goodKeys.ok) return goodKeys;\n const { items } = list;\n const keyItems = listed.items;\n if (keyItems.length !== items.length) return this.#err(\"kind-mismatch\", `\"group\" needs one key for each item, but the list has ${String(items.length)} items and ${String(keyItems.length)} keys`, f, path, { op: \"group\" });\n const groups = new Map<string, ListItem[]>();\n for (let i = 0; i < items.length; i++) {\n const it = items[i] as ListItem;\n const k = (keyItems[i] as ListItem).result;\n if (!it.result.ok || !k.ok) continue;\n if (typeof k.value !== \"string\") return this.#err(\"kind-mismatch\", `\"group\" needs text keys, but a key is a ${describeType(k.value)}`, f, path, { op: \"group\" });\n const g = groups.get(k.value);\n if (g === undefined) groups.set(k.value, [it]);\n else g.push(it);\n }\n const out: ListItem[] = [];\n for (const [key, g] of groups) out.push({ key, result: ok(checkedList(g)) });\n return ok(checkedList(out));\n }\n\n /**\n * This method joins the lists that are the values of the items of a list, in order (LIST.FLAT). Each list follows the\n * rules of LIST.BUILD. A value that is not a list gives `#VALUE!`.\n */\n #flat(values: readonly unknown[], strict: boolean, f: Frame, path: readonly number[]): Result<VexList> {\n const out: ListItem[] = [];\n for (const value of values) {\n const inner = asList(value, this.#missing(f, path));\n if (inner === undefined) return this.#err(\"kind-mismatch\", `\"flat\" needs a list as the value of each item, but an item is a ${describeType(value)}`, f, path, { op: \"flat\" });\n const good = goodItems(inner, strict);\n if (!good.ok) return good;\n out.push(...good.value);\n }\n return ok(checkedList(out));\n }\n\n /**\n * This method sorts the items of a list by their sort values, from the smallest (LIST.SORT). The sort is stable. The\n * sort values are all numbers without NaN, or all texts. Texts compare by their UTF-16 code units. Without the option\n * `by`, the sort value of an item is its value (LIST.SORT.BY).\n */\n #sortBy(items: readonly ListItem[], values: readonly unknown[], opts: unknown, f: Frame, path: readonly number[]): Result<VexList> {\n const by = (opts as { readonly by?: unknown } | null | undefined)?.by;\n const sorted = by === undefined ? ok(values) : this.#sortValues(by, values, f, path);\n if (!sorted.ok) return sorted;\n const keys = sorted.value;\n const kind = typeof keys[0];\n const bad = keys.findIndex((x) => typeof x !== kind || (kind !== \"number\" && kind !== \"string\") || Number.isNaN(x));\n if (bad >= 0) {\n const what = typeof by === \"string\" ? `\"${by}\" of an item` : \"an item\";\n return this.#err(\"kind-mismatch\", `\"sortBy\" needs numbers without NaN or texts, all of one kind, but ${what} is ${Number.isNaN(keys[bad]) ? \"NaN\" : `a ${describeType(keys[bad])}`}`, f, path, { op: \"sortBy\" });\n }\n const order = keys.map((_x, i) => i).toSorted((i, j) => {\n const a = keys[i] as number | string;\n const b = keys[j] as number | string;\n // The sort of Node reads only a negative result, and the sort of another engine needs the whole comparison.\n // Stryker disable next-line ConditionalExpression,EqualityOperator: see the comment above\n return a < b ? -1 : a > b ? 1 : 0;\n });\n return ok(checkedList(order.map((i) => items[i] as ListItem)));\n }\n\n /**\n * This method gives the sort value of each item for the option `by` of `sortBy` (LIST.SORT.BY). The op of the name\n * `by` applies to the value of each item, in the order of the list. The first error is the result.\n */\n #sortValues(by: unknown, values: readonly unknown[], f: Frame, path: readonly number[]): Result<readonly unknown[]> {\n if (typeof by !== \"string\") return this.#err(\"kind-mismatch\", `the option \"by\" of \"sortBy\" needs an op name, but got a ${describeType(by)}`, f, path, { op: \"sortBy\" });\n const out: unknown[] = [];\n for (const x of values) {\n let op: ResolvedOp | undefined;\n for (const d of this.#domains) {\n op = safeIs(d, x) ? resolveOp(d, x, by) : undefined;\n if (op !== undefined) break;\n }\n if (op === undefined) return this.#at(errorText.noStep(by, x), f, path);\n const r = this.#callResolved(op, x, by, [], f, path);\n if (!r.ok) return r;\n out.push(r.value);\n }\n return ok(out);\n }\n\n /**\n * This method folds the values with a domain op, from the left. An empty list gives the identity of the op, if one\n * domain has an identity for the op (LIST.EMPTY). The option `domain` names that domain when more domains have one.\n */\n #reduce(opName: unknown, values: readonly unknown[], f: Frame, path: readonly number[], opts: unknown): Result<unknown> {\n if (typeof opName !== \"string\") return this.#at(errorText.reduceName(opName), f, path);\n if (values.length === 0) {\n const named = (opts as { domain?: unknown } | null | undefined)?.domain;\n const candidates = this.#domains.filter((d) => Object.hasOwn(d.ops, opName) && (d.ops[opName] as { identity?: () => unknown }).identity !== undefined && (named === undefined || d.name === named));\n if (named !== undefined && !this.#domains.some((d) => d.name === named)) {\n return this.#err(\"unknown-op\", `\"reduce\" names the domain ${JSON.stringify(named)}, but the program has no such domain`, f, path, { op: opName });\n }\n const [only, second] = candidates;\n if (only === undefined) return this.#err(\"empty\", `\"reduce\" with \"${opName}\" has no values and the op has no identity`, f, path, { op: opName });\n if (second !== undefined) {\n const names = candidates.map((d) => d.name).join(\", \");\n return this.#err(\"empty\", `\"reduce\" with \"${opName}\" has no values, and more domains have an identity for it (${names}). Name one with { domain }`, f, path, { op: opName });\n }\n return this.#invoke((only.ops[opName] as { identity: () => unknown }).identity, opName, f, path);\n }\n let acc: unknown = values[0];\n for (let i = 1; i < values.length; i++) {\n const d = this.#domains.find((dom) => safeIs(dom, acc) && resolveOp(dom, acc, opName) !== undefined);\n const op = d === undefined ? undefined : resolveOp(d, acc, opName);\n if (op === undefined) return this.#at(errorText.noStep(opName, acc), f, path);\n const r = this.#callResolved(op, acc, opName, [values[i]], f, path);\n if (!r.ok) return r;\n acc = r.value;\n }\n return ok(acc);\n }\n}\n\n/** The list ops with a second argument before their options: a count, a position, an op name or a list. */\nconst WITH_ARGUMENT: ReadonlySet<ListOp> = new Set<ListOp>([\"reduce\", \"take\", \"nth\", \"drop\", \"append\", \"without\", \"get\", \"indexOf\", \"group\", \"join\"]);\n\n/**\n * This function gives the items of a list that have a value (LIST.LENIENT). A list op does not skip `#DEPTH!`, so that\n * error comes first (EVAL.DEPTH). With `strict`, the first error item is the result.\n */\nfunction goodItems(list: VexList, strict: boolean): Result<readonly ListItem[]> {\n const { items } = list;\n let first: VexError | undefined;\n for (const it of items) {\n if (it.result.ok) continue;\n if (isDepthError(it.result.error)) return fail(it.result.error);\n first ??= it.result.error;\n }\n // A list without error items gives its own items: no copy. Nothing changes them: the items of `vexList` are frozen,\n // and each list op makes a new array.\n if (first === undefined) return ok(items);\n if (strict) return fail(first);\n const out: ListItem[] = [];\n for (const it of items) if (it.result.ok) out.push(it);\n return ok(out);\n}\n\n/**\n * This function makes a list from the items of lists that passed the check of LIST.SHAPE, or from items of the same\n * shape. Thus the list skips the check of `isVexList`.\n */\nfunction checkedList(items: readonly ListItem[]): VexList {\n const list = vexList(items);\n CHECKED.add(list);\n return list;\n}\n\n/** This function gives the value of an item with a value. */\nconst valueOf = (it: ListItem): unknown => (it.result as { readonly value: unknown }).value;\n\n/** The index of the keys of a list (LIST.GET): the value of the first item of each key, and the first errors. */\ninterface KeyIndex {\n readonly values: ReadonlyMap<string, unknown>;\n /** The first error item. With strict, it is the result. */\n readonly first: VexError | undefined;\n /** The first item of `#DEPTH!`. A list op does not skip it (EVAL.DEPTH). */\n readonly depth: VexError | undefined;\n}\n\n/** This function makes the index of the keys of a list. An error item is not an item of its key (LIST.LENIENT). */\nfunction keyIndexOf(list: VexList): KeyIndex {\n const values = new Map<string, unknown>();\n let first: VexError | undefined;\n let depth: VexError | undefined;\n for (const it of list.items) {\n if (it.result.ok) {\n // The first item of a key gives its value. A later item with the same key does not replace it.\n if (!values.has(it.key)) values.set(it.key, it.result.value);\n } else {\n first ??= it.result.error;\n if (isDepthError(it.result.error)) depth ??= it.result.error;\n }\n }\n return { values, first, depth };\n}\n\nconst FORBIDDEN_FIELDS = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\n/** This function tells if a segment of a path can name a field. A compiler uses the same rule as the interpreter. */\nexport const isFieldName = (seg: string): boolean => seg.length > 0 && !FORBIDDEN_FIELDS.has(seg);\n\n/**\n * This function tells if a domain accepts a value. A domain with a primitive type accepts each value of that type and\n * no other value (KIND.PRIMITIVE), so its test `is` does not start. For another domain, a test that throws counts as\n * `false`.\n */\nexport function safeIs(d: AnyDomain, value: unknown): boolean {\n return d.primitive !== undefined ? typeof value === d.primitive : testIs(d, value);\n}\n\n/** This function starts the `is` test of a domain. A test that throws counts as `false`. */\n// Stryker disable BlockStatement: an empty catch gives undefined, which also counts as false\nfunction testIs(d: AnyDomain, value: unknown): boolean {\n try {\n return d.is(value);\n } catch {\n return false;\n }\n}\n// Stryker restore BlockStatement\n\n\n/** This function tells if an argument has the kind of a parameter of an op of the domain `domain`. */\nexport function matchesKind(kind: ParamKind, value: unknown, domain: AnyDomain): boolean {\n switch (kind) {\n case \"domain\":\n return safeIs(domain, value);\n case \"number\":\n return typeof value === \"number\";\n case \"boolean\":\n return typeof value === \"boolean\";\n case \"string\":\n return typeof value === \"string\";\n case \"any\":\n return true;\n }\n}\n\n/** This function gives the label of a node, for traces. */\nexport function labelOf(e: Expr): string {\n switch (e.tag) {\n case \"lit\":\n return previewValue(e.value);\n case \"ref\":\n return e.path.length === 0 ? \"(record)\" : e.path.join(\".\");\n case \"app\":\n return e.op;\n case \"let\":\n return `let ${Object.keys(e.bind).join(\", \")}`;\n // A function makes no event of the trace, so its label only completes the switch.\n // Stryker disable next-line all: see the comment above\n case \"fn\": return `fn (${e.params.join(\", \")})`;\n case \"call\":\n return `call ${e.fn}`;\n case \"var\":\n return e.name;\n case \"rec\":\n return `{ ${Object.keys(e.fields).join(\", \")} }`;\n case \"each\":\n case \"fold\":\n return e.at === undefined ? `${e.tag} ${e.axis.t}` : `${e.tag} ${e.axis.t} from ${e.at.map(moveText).join(\".\")}`;\n case \"iterate\":\n return `iterate ${typeof e.limit === \"number\" ? String(e.limit) : `size of ${e.limit.axis.t}`}`;\n case \"fix\":\n return `fix ${e.name} ${e.join}`;\n case \"last\":\n return `last ${e.name}`;\n case \"ext\":\n return e.kind;\n }\n}\n\n/** This function gives a short text for a move, for the label of an axis with an address. */\nfunction moveText(m: Move): string {\n switch (m.t) {\n case \"key\":\n return `key(${typeof m.key === \"string\" ? m.key : labelOf(m.key)})`;\n case \"index\":\n return `index(${typeof m.i === \"number\" ? String(m.i) : labelOf(m.i)})`;\n case \"offset\":\n return `offset(${m.d.join(\", \")})`;\n case \"other\":\n case \"origin\":\n case \"parent\":\n return m.t;\n }\n}\n\n/** This function gives a short text for a value. */\nexport function previewValue(u: unknown): string {\n // JSON has no NaN and no Infinity, so a number gets its own text. JSON gives the text of the other primitives.\n if (typeof u === \"number\") return String(u);\n if (isVexList(u)) return `list(${u.items.length})`;\n try {\n const json = JSON.stringify(u);\n // A function, a symbol and undefined have no JSON form.\n // Stryker disable next-line ConditionalExpression: without the test, undefined.length throws, and the catch gives the same text\n if (json !== undefined) return json.length > 60 ? `${json.slice(0, 57)}...` : json;\n } catch {\n // A value with cycles has no JSON form.\n }\n return describeType(u);\n}\n\n// The reads of a reference show the key and the path, for example \"read B.position\" or \"no value at A.mass\".\nconst formatRead = (r: Read): string => `${r.ok ? \"read\" : \"no value at\"} ${r.key}.${r.path.length === 0 ? \"(record)\" : r.path.join(\".\")}`;\n\n/**\n * This function gives a text form of a trace. Each event has one line, in finish order. The indent of a line\n * shows the depth of the node. A domain with `show` gives the text of its values. The golden tests compare this text.\n */\n// Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain shows no value\nexport function formatTrace(trace: Trace, domains: readonly AnyDomain[] = []): string {\n const show = (u: unknown): string => {\n if (isVexList(u)) return `[${u.items.map((it) => `${it.key}: ${result(it.result)}`).join(\", \")}]`;\n const d = domains.find((dom) => dom.show !== undefined && safeIs(dom, u));\n try {\n // Stryker disable next-line ConditionalExpression,OptionalChaining: without a domain, d.show throws, and the catch gives the same text\n if (d?.show !== undefined) return d.show(u);\n } catch {\n // A show function that throws gives the default text.\n }\n return previewValue(u);\n };\n const result = (r: Result<unknown>): string => (r.ok ? show(r.value) : formatError(r.error));\n const line = (e: TraceEvent): string => {\n const reads = e.reads === undefined ? \"\" : ` [${e.reads.map(formatRead).join(\", \")}]`;\n return `${\" \".repeat(e.path.length)}${e.label} @${e.focus}${reads} = ${result(e.result)}`;\n };\n const lines = trace.events.map(line);\n return [...lines, `result = ${result(trace.result)}`, \"\"].join(\"\\n\");\n}\n\n/** This function gives the number of nodes of an expression. */\nexport const sizeOf = (e: Expr): number => 1 + children(e).reduce((s, c) => s + sizeOf(c), 0);\n","/**\n * The static reads of a program (DEPS.READS). The static kit of coeval finds the references of the document of the\n * program, by the contracts of Vex (`refsOf`). Vex adds only what is its own: the axes around a read, and the reads of\n * a function at each of its calls (FN.CALL).\n */\nimport { pathMatches, refsOf, type DocVisit, type Key, type RefUse } from \"@mark1russell7/coeval\";\nimport type { Addr, Axis, DataLimit, Expr, ExprOf } from \"./ir.ts\";\nimport { VEX_WORLD } from \"./kernel.ts\";\nimport { writeDocument } from \"./write.ts\";\n\n/** One static read of a program: a field path at an address, inside zero or more axes. */\nexport interface Dependency {\n /** The address of the read. The empty address is the focus. */\n readonly at: Addr;\n /** The field path of the read. */\n readonly path: readonly string[];\n /** The axes around the read, from the outside to the inside. Inside an axis, the focus is the target. */\n readonly axes: readonly Axis[\"t\"][];\n /** The address of each axis in `axes`, in the same order. The empty address is the focus. */\n readonly axisAt: readonly Addr[];\n}\n\n/** An axis around a read: the kind of the axis of a loop, and the address of the loop. */\ninterface Around {\n readonly t: Axis[\"t\"];\n readonly at: Addr;\n}\n\n/** A chain of items, the innermost first. The chains of two documents share the items of the documents around both. */\ninterface Chain<T> {\n readonly item: T;\n readonly up: Chain<T> | undefined;\n}\n\n/** The context of a document for its reads. */\ninterface Context {\n /** The axes around the document, the innermost first. */\n readonly axes: Chain<Around> | undefined;\n /** Inside the axis document of a loop: the axis of that loop. A test of `where` there is inside the axis. */\n readonly axis: Around | undefined;\n /** The nearest function around the document: a binding of a let. Its reads happen at its calls, not here. */\n readonly fn: DocVisit | undefined;\n /** The calls around the document whose function is a binding of a let, the innermost first. */\n readonly calls: Chain<DocVisit> | undefined;\n}\n\nconst ROOT: Context = { axes: undefined, axis: undefined, fn: undefined, calls: undefined };\n\n/** This function gives the items of a chain until the chain `end`, from the outside to the inside. */\nfunction itemsUntil<T>(chain: Chain<T> | undefined, end: Chain<T> | undefined): T[] {\n const out: T[] = [];\n for (let c = chain; c !== undefined && c !== end; c = c.up) out.push(c.item);\n return out.toReversed();\n}\n\n/** This function gives the kind of a visit, as its keys joined with dots, for example `each` or `axes.where`. */\n// Stryker disable next-line ArrayDeclaration: each document of the writer has a type of the world, so each visit has a type path\nconst kindOf = (v: DocVisit): string => (v.typePath ?? []).join(\".\");\n\n/**\n * This function gives the static reads of an expression. A host can use them to recompute a program only when a field\n * that it reads changes. A computed move reads a key that only a run knows. Its address keeps the expression, and the\n * reads of that expression are in the list too (DEPS.COMPUTED). The kernel walks the document with a stack, so an\n * expression of any depth works (EVAL.NESTING).\n */\nexport function deps(e: Expr): readonly Dependency[] {\n const nodes = new Map<object, Expr>();\n // The order \"reads\" puts the body or the steps of a loop before its axis, as the reads of an evaluation come.\n const doc = writeDocument(e, {\n // Stryker disable next-line ArrayDeclaration: the reads come from the references, not from the form of a literal\n domains: [],\n // Stryker disable next-line StringLiteral: the writer tests only the mode \"json\", and each other mode keeps the value\n literals: \"host\",\n order: \"reads\",\n nodes,\n });\n const uses = refsOf(VEX_WORLD, doc);\n const memo = new WeakMap<DocVisit, Context>();\n const functions = new WeakMap<DocVisit, DocVisit | null>();\n const fnVisits = new Map<unknown, DocVisit>();\n\n /** This function gives the function of a call: the visit of the binding of a let, or `undefined` (FN.CALL). */\n const functionOf = (call: DocVisit): DocVisit | undefined => {\n const known = functions.get(call);\n if (known !== undefined) return known ?? undefined;\n const name = (call.doc.value as { readonly fn: { readonly value: readonly [string, string] } }).fn.value[1];\n let found: DocVisit | undefined;\n // The innermost kind that binds the name decides. A parameter, a binding or a name of a loop hides a function.\n search: for (let child: DocVisit = call, around = call.parent; around !== undefined; child = around, around = around.parent) {\n // Stryker disable next-line OptionalChaining: each document around a call is a term or a function, so it has a kind\n for (const rule of around.kind?.scope ?? []) {\n if (!rule.in.some((pattern) => pathMatches(child.slot, pattern))) continue;\n const source = rule.names as { readonly keysAt?: readonly Key[]; readonly listAt?: readonly Key[] };\n // Stryker disable next-line ArrayDeclaration: each rule of the scopes of Vex gives its names with keysAt or listAt\n const at = (source.keysAt ?? source.listAt ?? []).reduce<unknown>((x, k) => (x as Readonly<Record<string, unknown>>)[String(k)], around.doc.value);\n // A loop without the names `as` of its items has no list there (AXIS.LIST.SCOPE).\n // Stryker disable next-line ArrayDeclaration: a name that no program binds does not hide a function\n const names = source.keysAt !== undefined ? Object.keys(at as object) : ((at as readonly string[] | undefined) ?? []);\n if (!names.includes(name)) continue;\n // Only a binding of a let is a function (FN.BIND), and the map has only the documents of the functions.\n found = fnVisits.get((at as Readonly<Record<string, unknown>>)[name]);\n break search;\n }\n }\n functions.set(call, found ?? null);\n return found;\n };\n\n /** This function gives the context of a child from the context of its parent. */\n const step = (outer: Context, parent: DocVisit, child: DocVisit): Context => {\n const kind = kindOf(parent);\n const head = child.slot[0];\n let { axes, fn, calls } = outer;\n let axis: Around | undefined;\n if (outer.axis !== undefined) {\n // In the axis document of a loop: a test of where is inside the axis, and the list of the axis list is outside.\n // Only the axis where has a test.\n if (head === \"test\") axes = { item: outer.axis, up: axes };\n else if (head === \"axis\") axis = outer.axis;\n } else if (kind === \"each\" || kind === \"fold\") {\n const node = nodes.get(parent.doc) as ExprOf<\"each\" | \"fold\">;\n const around: Around = { t: node.axis.t, at: node.at ?? [] };\n if (head === \"body\" || head === \"step\") axes = { item: around, up: axes };\n else if (head === \"axis\") axis = around;\n } else if (kind === \"fix\") {\n // The start and the step of a column read at each row (FIX.ROWS).\n axes = { item: { t: \"all\", at: [] }, up: axes };\n } else if (kind === \"size\") {\n // The size of the writer is the data limit of its node, so the axis has no address (ITERATE.LIMIT.DATA).\n axis = { t: ((nodes.get(parent.doc) as ExprOf<\"iterate\">).limit as DataLimit).axis.t, at: [] };\n }\n if (kind === \"fn\") {\n fn = parent;\n fnVisits.set(parent.doc, parent);\n }\n // Each call goes in the chain, also a call of a name that is not a function: inCall looks for one call of a function.\n if (kind === \"call\") calls = { item: parent, up: calls };\n return { axes, axis, fn, calls };\n };\n\n /**\n * This function gives the context of a visit. It walks up to a known context with a loop, not with recursion. The\n * context of no visit is the context of the root.\n */\n const contextOf = (v: DocVisit | undefined): Context => {\n const todo: DocVisit[] = [];\n let x: DocVisit | undefined = v;\n while (x !== undefined && !memo.has(x)) {\n todo.push(x);\n x = x.parent;\n }\n let ctx = x === undefined ? ROOT : (memo.get(x) as Context);\n for (let i = todo.length - 1; i >= 0; i--) {\n const child = todo[i] as DocVisit;\n ctx = child.parent === undefined ? ROOT : step(ctx, child.parent, child);\n memo.set(child, ctx);\n }\n return ctx;\n };\n\n // The references of each function, apart from the others: they read at each call of the function.\n const groups = new Map<DocVisit | undefined, RefUse[]>();\n for (const use of uses) {\n const fn = contextOf(use.visit).fn;\n const group = groups.get(fn) ?? [];\n group.push(use);\n groups.set(fn, group);\n }\n\n const out: Dependency[] = [];\n /** This function gives the reads of the references of a function at a call, inside the axes of the call. */\n const emit = (group: readonly RefUse[], base: DocVisit | undefined, outside: readonly Around[]): void => {\n const baseAxes = contextOf(base).axes;\n const inside = (v: DocVisit): readonly Around[] => [...outside, ...itemsUntil(contextOf(v).axes, baseAxes)];\n // The reads of a call come after the reads of its arguments, so a call waits until the walk leaves it.\n const pending: { readonly call: DocVisit; readonly fn: DocVisit; readonly axes: readonly Around[] }[] = [];\n const inCall = (v: DocVisit | undefined, call: DocVisit): boolean => {\n for (let c = contextOf(v).calls; c !== undefined && c.item.depth >= call.depth; c = c.up) if (c.item === call) return true;\n return false;\n };\n const flush = (until?: DocVisit): void => {\n for (;;) {\n const top = pending.at(-1);\n if (top === undefined || inCall(until, top.call)) return;\n pending.pop();\n emit(groups.get(top.fn) ?? [], top.fn, top.axes);\n }\n };\n for (const use of group) {\n flush(use.visit);\n if (use.root === \"self\" && !use.address) {\n const node = nodes.get(use.visit.doc) as ExprOf<\"ref\">;\n const axes = inside(use.visit);\n out.push({ at: node.at ?? [], path: node.path, axes: axes.map((a) => a.t), axisAt: axes.map((a) => a.at) });\n }\n const call = use.visit.parent;\n if (call !== undefined && kindOf(call) === \"call\" && use.visit.slot[0] === \"fn\") {\n const fn = functionOf(call);\n if (fn !== undefined) pending.push({ call, fn, axes: inside(call) });\n }\n }\n flush();\n };\n emit(groups.get(undefined) ?? [], undefined, []);\n return out;\n}\n","import { decodeValue, encodeValue, isRecord } from \"./codec.ts\";\nimport { fromDocument, isDocument } from \"./document.ts\";\nimport type { AnyDomain } from \"./domain.ts\";\nimport { isStackOverflow, vexError } from \"./errors.ts\";\nimport { isExpr, type Expr } from \"./ir.ts\";\nimport { fail, ok, type Result } from \"./result.ts\";\n\n/** This function applies `f` to each literal value of a JSON tree of an expression. */\nfunction mapValues(u: unknown, f: (value: unknown) => Result<unknown>): Result<unknown> {\n if (!isRecord(u)) return ok(u);\n const out: Record<string, unknown> = { ...u };\n const child = (key: string): Result<unknown> | undefined => {\n const r = mapValues(u[key], f);\n if (r.ok) out[key] = r.value;\n return r.ok ? undefined : r;\n };\n const each = (key: string): Result<unknown> | undefined => {\n const list = u[key];\n if (Array.isArray(list)) {\n const items: unknown[] = [];\n for (const x of list) {\n const r = mapValues(x, f);\n if (!r.ok) return r;\n items.push(r.value);\n }\n out[key] = items;\n } else if (isRecord(list)) {\n const entries: [string, unknown][] = [];\n for (const [k, x] of Object.entries(list)) {\n const r = mapValues(x, f);\n if (!r.ok) return r;\n entries.push([k, r.value]);\n }\n // A binding or a field with the name \"__proto__\" is an own field too (V-062).\n out[key] = Object.fromEntries(entries);\n }\n return undefined;\n };\n // The expression of a computed move is a tree of the expression too (NAV.COMPUTED).\n const address = (): Result<unknown> | undefined => {\n const at = u[\"at\"];\n if (!Array.isArray(at)) return undefined;\n const moves: unknown[] = [];\n for (const m of at) {\n const field = isRecord(m) ? (m[\"t\"] === \"key\" ? \"key\" : m[\"t\"] === \"index\" ? \"i\" : undefined) : undefined;\n if (field === undefined || !isRecord(m) || !isRecord(m[field])) {\n moves.push(m);\n continue;\n }\n const r = mapValues(m[field], f);\n if (!r.ok) return r;\n moves.push({ ...m, [field]: r.value });\n }\n out[\"at\"] = moves;\n return undefined;\n };\n // The test of where and the list of the axis list are expressions, also inside reverse.\n const axis = (a: unknown): Result<unknown> => {\n if (!isRecord(a)) return ok(a);\n if (a[\"t\"] === \"list\") {\n const list = mapValues(a[\"list\"], f);\n return list.ok ? ok({ ...a, list: list.value }) : list;\n }\n if (a[\"t\"] === \"reverse\") {\n const inner = axis(a[\"axis\"]);\n return inner.ok ? ok({ ...a, axis: inner.value }) : inner;\n }\n if (a[\"t\"] !== \"where\") return ok(a);\n const inner = axis(a[\"axis\"]);\n if (!inner.ok) return inner;\n const test = mapValues(a[\"test\"], f);\n return test.ok ? ok({ ...a, axis: inner.value, test: test.value }) : test;\n };\n switch (u[\"tag\"]) {\n case \"lit\": {\n if (!Object.hasOwn(u, \"value\")) return ok(out);\n const r = f(u[\"value\"]);\n if (!r.ok) return r;\n out[\"value\"] = r.value;\n return ok(out);\n }\n case \"app\":\n return each(\"args\") ?? ok(out);\n case \"let\":\n return each(\"bind\") ?? child(\"body\") ?? ok(out);\n case \"rec\":\n return each(\"fields\") ?? ok(out);\n case \"each\": {\n const a = axis(u[\"axis\"]);\n if (!a.ok) return a;\n out[\"axis\"] = a.value;\n return child(\"body\") ?? address() ?? ok(out);\n }\n case \"fold\": {\n const a = axis(u[\"axis\"]);\n if (!a.ok) return a;\n out[\"axis\"] = a.value;\n return each(\"init\") ?? each(\"step\") ?? child(\"result\") ?? address() ?? ok(out);\n }\n case \"iterate\": {\n const limit = u[\"limit\"];\n if (isRecord(limit)) {\n const a = axis(limit[\"axis\"]);\n if (!a.ok) return a;\n out[\"limit\"] = { ...limit, axis: a.value };\n }\n return each(\"init\") ?? each(\"step\") ?? (u[\"until\"] === undefined ? undefined : child(\"until\")) ?? child(\"result\") ?? ok(out);\n }\n case \"fix\":\n return child(\"init\") ?? child(\"step\") ?? ok(out);\n case \"fn\":\n return child(\"body\") ?? ok(out);\n case \"call\":\n return each(\"args\") ?? ok(out);\n case \"ref\":\n return address() ?? ok(out);\n default:\n return ok(out);\n }\n}\n\n/**\n * This function gives the JSON text of an expression. A literal value that is a domain value needs a domain with\n * `encode`. A literal value that is not JSON data and has no such domain gives the error `#VALUE!`.\n */\n// Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain encodes no value\nexport function serialize(e: Expr, domains: readonly AnyDomain[] = []): Result<string> {\n try {\n // A getter of a literal value can throw, so the encoding is inside the try too.\n const tree = mapValues(e, (v) => encodeValue(v, domains));\n return tree.ok ? ok(JSON.stringify(tree.value)) : fail(tree.error);\n } catch (thrown) {\n if (isStackOverflow(thrown)) return fail(vexError(\"depth\", \"the expression is too deep for the call stack of the engine\", { thrown }));\n return fail(vexError(\"threw\", \"the expression has no JSON form\", { thrown }));\n }\n}\n\n/**\n * This function reads an expression from JSON text. It checks the whole tree. The text can also be a document: then\n * `fromDocument` reads it (DOC.ENTRY).\n */\n// Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain decodes no value\nexport function parse(text: string, domains: readonly AnyDomain[] = []): Result<Expr> {\n let raw: unknown;\n try {\n raw = JSON.parse(text);\n } catch (thrown) {\n return fail(vexError(\"bad-expression\", \"the text is not JSON\", { thrown }));\n }\n if (isDocument(raw)) {\n const read = fromDocument(raw, domains);\n // The JSON form needs whole numbers in the moves and the windows, as isExpr does.\n return !read.ok || isExpr(read.value) ? read : fail(vexError(\"bad-expression\", \"the JSON is not a valid Vex expression\"));\n }\n try {\n const tree = mapValues(raw, (v) => decodeValue(v, domains));\n if (!tree.ok) return fail(tree.error);\n return isExpr(tree.value) ? ok(tree.value) : fail(vexError(\"bad-expression\", \"the JSON is not a valid Vex expression\"));\n } catch (thrown) {\n // A JSON text nested deeper than the call stack, or a decoder of a domain that throws.\n if (isStackOverflow(thrown)) return fail(vexError(\"depth\", \"the JSON is too deep for the call stack of the engine\", { thrown }));\n return fail(vexError(\"threw\", \"a decoder of a domain threw an exception\", { thrown }));\n }\n}\n","/**\n * The reference tier of Vex: a program as a plan of the kernel of coeval (decision D13 of coeval). The kernel evaluates\n * the document of the program with the machine of `kernel.ts`. The closure compiler and the loop compiler give its\n * results (EVAL.REFERENCE), and the test kit compares them on random programs.\n */\nimport { agree as kernelAgree, context, prepare, reference as kernelReference, type Agreement, type Context, type Failed, type Result as Outcome } from \"@mark1russell7/coeval\";\nimport { fromDocument, isDocument, type Envelope } from \"./document.ts\";\nimport { vexError, type VexError } from \"./errors.ts\";\nimport { nestingError, type CompileOptions, type RunOptions } from \"./evaluate.ts\";\nimport { shapeError, type Expr } from \"./ir.ts\";\nimport { toKernelError, toVexResult, vexDefinitions, vexMachine, vexSelf } from \"./kernel.ts\";\nimport type { Result } from \"./result.ts\";\nimport { sameVex } from \"./same.ts\";\nimport { monotoneError } from \"./monotone.ts\";\nimport { sizeError } from \"./size.ts\";\nimport { stepError } from \"./steps.ts\";\nimport { writeDocument } from \"./write.ts\";\n\n/** The options of a run of a plan of the kernel: the options of a run without a trace. */\nexport type KernelRunOptions = Omit<RunOptions, \"trace\">;\n\n/** A program in the kernel: its document, and a run at an origin of a space. */\nexport interface KernelPlan {\n /** The document that the kernel evaluates, or `undefined` for a program that is not valid. */\n readonly doc: Envelope | undefined;\n /** This method evaluates the program at an origin. It does not throw. */\n run(opts: KernelRunOptions): Result<unknown>;\n /** This method evaluates the program at an origin, and gives the result of the kernel with its own code. */\n evaluate(opts: KernelRunOptions): Outcome;\n /**\n * This method evaluates the program at an origin with the reference interpreter of the kernel. The reference reads\n * the document by the rules of the kernel, and it compiles nothing. Thus it shares no compiler with `evaluate`.\n */\n reference(opts: KernelRunOptions): Outcome;\n /**\n * This method compares the tiers of the kernel at an origin (`agree` of coeval). The tiers are `evaluate`, the\n * reference interpreter, the traced evaluation and a second evaluation. The tier `other` of the caller is the last\n * tier. The method gives the result, or the first tier that gives another result. Two errors agree when they have the\n * same code.\n */\n agree(opts: KernelRunOptions, other?: () => Result<unknown>): Agreement;\n}\n\n/** This function gives the context of the kernel at an origin: the position of the origin, and the names of the caller. */\nconst contextOf = ({ space, origin, vars, tables }: KernelRunOptions): Context => context({ self: vexSelf(space, origin, tables), names: vars ?? {} });\n\n/** This function gives the result of the kernel for a result of Vex. */\nconst toOutcome = (r: Result<unknown>): Outcome => (r.ok ? { ok: true, value: r.value } : { ok: false, error: toKernelError(r.error) });\n\n/**\n * This function gives the plan of a program in the kernel (EVAL.REFERENCE). A document stays as it is, after the check\n * of `fromDocument`. An expression gets its document: a literal has its JSON form, or the value of the host when it has\n * no JSON form. A program that is not valid gives the error of `compile` at each run (EVAL.SHAPE, EVAL.NESTING).\n */\nexport function kernelPlan(source: Expr | Envelope, opts: CompileOptions = {}): KernelPlan {\n // Stryker disable next-line ArrayDeclaration: a list with a value that is not a domain matches no value\n const domains = opts.domains ?? [];\n let doc: Envelope | undefined;\n let bad: VexError | undefined;\n if (isDocument(source)) {\n const read = fromDocument(source, domains);\n // EVAL.NESTING, LOOP.SIZE, STEP.MAX: the plan refuses the same programs as `compile`. The nesting comes first, because the\n // other checks recurse, and a document can be deeper than the limit of an expression.\n const size = read.ok ? (nestingError(read.value) ?? sizeError(read.value, opts) ?? stepError(read.value, opts) ?? monotoneError(read.value, opts)) : undefined;\n if (read.ok && size === undefined) doc = source;\n else bad = read.ok ? vexError(\"bad-expression\", size ?? \"\") : read.error;\n } else {\n const shape = shapeError(source);\n const deep = shape ?? nestingError(source);\n const reason = deep ?? sizeError(source, opts) ?? stepError(source, opts) ?? monotoneError(source, opts);\n // Stryker disable next-line StringLiteral: the writer tests only the mode \"json\" and the order \"reads\"\n if (reason === undefined) doc = writeDocument(source, { domains, literals: \"host\", order: \"document\" });\n else bad = vexError(\"bad-expression\", reason);\n }\n const machine = vexMachine(opts);\n // A program that is not valid has no document. Its plan does not run, because each run fails before the kernel.\n const plan = prepare(machine, doc);\n // An origin outside the space and a program that is not valid fail before the kernel (EVAL.ORIGIN, EVAL.SHAPE).\n const early = ({ space, origin }: KernelRunOptions): Failed | undefined => {\n if (!space.has(origin)) return { ok: false, error: toKernelError(vexError(\"unknown-key\", `the space has no key \"${origin}\"`, { origin, focus: origin })) };\n return bad === undefined ? undefined : { ok: false, error: toKernelError(bad) };\n };\n const evaluate = (r: KernelRunOptions): Outcome => early(r) ?? plan.evaluate(contextOf(r));\n const reference = (r: KernelRunOptions): Outcome => early(r) ?? kernelReference(machine, doc, contextOf(r), { definitions: vexDefinitions(opts) });\n const agree = (r: KernelRunOptions, other?: () => Result<unknown>): Agreement => {\n const tier = other === undefined ? {} : { other: (): Outcome => toOutcome(other()) };\n const first = early(r);\n if (first === undefined) return kernelAgree(machine, doc, contextOf(r), { definitions: vexDefinitions(opts), equal: sameVex, ...tier });\n // The kernel does not evaluate the program, so only the tier can give another result.\n const second = tier.other?.() ?? first;\n return !second.ok && second.error.code === first.error.code ? { ok: true, result: first, effects: [] } : { ok: false, tier: \"other\", plan: first, other: second, reason: \"The plan does not evaluate the program, and the tier gives another result.\" };\n };\n return { doc, evaluate, reference, agree, run: (r) => toVexResult(evaluate(r)) };\n}\n","import type { AnyDomain } from \"./domain.ts\";\nimport { vexError, type VexError } from \"./errors.ts\";\nimport { evaluate, type FreeFn } from \"./evaluate.ts\";\nimport { app, lit, v } from \"./ir.ts\";\nimport { vexList, type ListItem } from \"./list.ts\";\nimport { fail, none, ok, toOptional, type Optional, type Result } from \"./result.ts\";\nimport { space as spaces, type Space } from \"./space.ts\";\n\n/** A monoid: an associative `concat` with an identity element `empty`. */\nexport interface Monoid<M> {\n readonly empty: M;\n readonly concat: (a: M, b: M) => M;\n}\n\n/** Standard monoids. */\nexport const monoids: {\n readonly sum: Monoid<number>;\n readonly product: Monoid<number>;\n readonly all: Monoid<boolean>;\n readonly any: Monoid<boolean>;\n} = {\n sum: { empty: 0, concat: (a, b) => a + b },\n product: { empty: 1, concat: (a, b) => a * b },\n all: { empty: true, concat: (a, b) => a && b },\n any: { empty: false, concat: (a, b) => a || b },\n};\n\n/** One item of a traversal: the start key and the result there. */\nexport interface TraversalItem<K extends string, T> {\n readonly key: K;\n readonly result: Result<T>;\n}\n\n/**\n * A traversal: the results of one program at each start key. The reductions skip error items by default.\n * After `strict()`, an error item makes the reduction that error.\n */\nexport interface Traversal<K extends string, T> {\n readonly items: readonly TraversalItem<K, T>[];\n /** This method gives a traversal whose reductions fail on the first error item. */\n strict(): Traversal<K, T>;\n /** This method gives the result at one key. */\n get(k: K): Optional<T>;\n /** The values of the items without errors. */\n values(): readonly T[];\n /** The keys of the items without errors. */\n keys(): readonly K[];\n /** The errors of the items with errors. */\n errors(): readonly VexError[];\n count(): Optional<number>;\n sum(this: Traversal<K, number>): Optional<number>;\n mean(this: Traversal<K, number>): Optional<number>;\n min(this: Traversal<K, number>): Optional<number>;\n max(this: Traversal<K, number>): Optional<number>;\n any(this: Traversal<K, boolean>): Optional<boolean>;\n all(this: Traversal<K, boolean>): Optional<boolean>;\n none(this: Traversal<K, boolean>): Optional<boolean>;\n /** This method folds the values with a domain op, from the left. */\n reduce(op: string): Optional<T>;\n /** This method gives the result of a reduction, with its error. */\n reduceResult(op: \"count\" | \"sum\" | \"mean\" | \"min\" | \"max\" | \"any\" | \"all\" | \"none\" | \"reduce\", reduceOp?: string): Result<unknown>;\n /** This method maps each value with `f`. If `f` throws, the item has the error `#CALC!`. */\n map<U>(f: (value: T, key: K) => U): Traversal<K, U>;\n /** This method folds the values with a monoid. */\n fold<M>(monoid: Monoid<M>, f: (value: T) => M): M;\n}\n\ninterface TraversalEnv {\n readonly domains: readonly AnyDomain[];\n readonly options?: { readonly fns?: Readonly<Record<string, FreeFn>> };\n}\n\nconst EMPTY_SPACE: Space = spaces.record({ $: {} });\n\nconst opt = <U>(r: Result<unknown>): Optional<U> => toOptional(r as Result<U>);\n\n/** This function makes a traversal from items. */\nexport function traversal<K extends string, T>(items: readonly TraversalItem<K, T>[], env: TraversalEnv, isStrict = false): Traversal<K, T> {\n const reduce = (op: string, reduceOp?: string): Result<unknown> => {\n const list = vexList(items as readonly ListItem[]);\n const args = [v(\"$list\"), ...(reduceOp === undefined ? [] : [lit(reduceOp)]), ...(isStrict ? [lit({ strict: true })] : [])];\n return evaluate(app(op, ...args), {\n space: EMPTY_SPACE,\n origin: \"$\",\n domains: env.domains,\n vars: { $list: list },\n });\n };\n const t: Traversal<K, T> = {\n items,\n strict: () => traversal(items, env, true),\n get: (k) => {\n const item = items.find((it) => it.key === k);\n return item === undefined ? none() : toOptional(item.result);\n },\n values: () => items.flatMap((it) => (it.result.ok ? [it.result.value] : [])),\n keys: () => items.flatMap((it) => (it.result.ok ? [it.key] : [])),\n errors: () => items.flatMap((it) => (it.result.ok ? [] : [it.result.error])),\n count: () => opt(reduce(\"count\")),\n sum: () => opt(reduce(\"sum\")),\n mean: () => opt(reduce(\"mean\")),\n min: () => opt(reduce(\"min\")),\n max: () => opt(reduce(\"max\")),\n any: () => opt(reduce(\"any\")),\n all: () => opt(reduce(\"all\")),\n none: () => opt(reduce(\"none\")),\n reduce: (op) => opt(reduce(\"reduce\", op)),\n reduceResult: (op, reduceOp) => reduce(op, reduceOp),\n map: <U>(f: (value: T, key: K) => U): Traversal<K, U> =>\n traversal(\n items.map((it): TraversalItem<K, U> => {\n if (!it.result.ok) return { key: it.key, result: it.result };\n try {\n return { key: it.key, result: ok(f(it.result.value, it.key)) };\n } catch (thrown) {\n return { key: it.key, result: fail(vexError(\"threw\", \"the map function threw an exception\", { thrown, focus: it.key })) };\n }\n }),\n env,\n isStrict,\n ),\n fold: <M>(monoid: Monoid<M>, f: (value: T) => M): M => t.values().reduce((acc, x) => monoid.concat(acc, f(x)), monoid.empty),\n };\n return t;\n}\n","/**\n * Sheets: named columns of formulas over a space. A formula can read a column at an address, like a cell\n * reference of a spreadsheet. A cell is one column at one key. A run evaluates each cell once, and each cell on a\n * cycle of reads gives `#CYCLE!`.\n *\n * A cell reference is the extension node `ext(\"vex.cell\", { column, at })`. Thus the IR has no new kind, and the\n * JSON form, `deps` and the traces work without a change.\n *\n * A cell can have its own formula. That formula replaces the formula of the column at the key of the cell. A\n * spreadsheet has the same thing: a cell with a formula that is different from the other formulas of its column.\n */\nimport { vexError } from \"./errors.ts\";\nimport { evaluate, explain, nestingOf, type CompileOptions, type EvalOptions, type ExtHandler, type Program } from \"./evaluate.ts\";\nimport { addrExprs, app, axes, children, each, ext, isFixedAddr, isMove, listOf, lit, moveExpr, shapeError, splitLimit, type Addr, type Axis, type Expr, type FixedMove, type Move } from \"./ir.ts\";\nimport { fail, type Result } from \"./result.ts\";\nimport { resolveAddr, type Space } from \"./space.ts\";\nimport type { Trace } from \"./trace.ts\";\n\n/** The extension kind of a cell reference. */\nexport const CELL_KIND = \"vex.cell\";\n\n/**\n * The data of a cell reference: the column, and the address from the focus. The data of an extension is not an\n * expression, so the address has only fixed moves. `cell` takes computed moves in another form.\n */\nexport interface CellRef {\n readonly column: string;\n readonly at: readonly FixedMove[];\n}\n\n/** This function makes the extension node of a cell reference. */\nconst cellRef = (column: string, at: readonly FixedMove[]): Expr => ext(CELL_KIND, { column, at } satisfies CellRef);\n\n/**\n * This function makes a read of the column `column` at the address `at` from the focus. An address of fixed moves gives\n * a cell reference. A computed move is an expression, not data (SHEET.CELL.COMPUTED). Thus it goes in the address of the\n * axis `window(0, 0)`, and the read is the one item of that axis. Each tier and the JSON form have this form.\n */\nexport const cell = (column: string, at: Addr = []): Expr => (isFixedAddr(at) ? cellRef(column, at) : app(\"first\", each(axes.window(0, 0), cellRef(column, []), at), lit({ strict: true })));\n\n/** This function tells if the data of an extension is a cell reference: a column, and an address of fixed moves. */\nexport const isCellRef = (u: unknown): u is CellRef =>\n typeof u === \"object\" &&\n u !== null &&\n typeof (u as { column?: unknown }).column === \"string\" &&\n Array.isArray((u as { at?: unknown }).at) &&\n (u as { at: readonly unknown[] }).at.every((m) => isMove(m) && moveExpr(m) === undefined);\n\n/** The formulas of single cells: for each column, the formula of each key that has its own formula. */\nexport type CellFormulas = ReadonlyMap<string, ReadonlyMap<string, Expr>>;\n\n/** A table of a run: its space, the formulas of its columns, and the formulas of its cells. */\nexport interface SheetTable {\n readonly space: Space;\n readonly columns: ReadonlyMap<string, Expr>;\n readonly cells?: CellFormulas;\n}\n\n/** The options of a sheet run: the evaluation options without the origin and the trace, and the tables. */\nexport type SheetOptions = Omit<EvalOptions, \"origin\" | \"trace\" | \"tables\"> & {\n /** The cells with their own formula. The formula of a cell replaces the formula of its column at its key. */\n readonly cells?: CellFormulas;\n /** The name of this table, so the axis `table(name)` in a formula of another table can read it. */\n readonly name?: string;\n /** The other tables, by name (SHEET.TABLES). A cell reference reads the table of the space where it evaluates. */\n readonly tables?: ReadonlyMap<string, SheetTable>;\n /**\n * The compiler of the formulas of the columns (SHEET.COMPILE), for example `tiered` of `@mark1russell7/vex-compiler`.\n * Without a compiler, the interpreter evaluates each formula. The compiled program must give the results of the\n * interpreter.\n */\n readonly compile?: CompileFn;\n};\n\n/** A compiler of the formulas of the columns of a run. */\nexport type CompileFn = (expr: Expr, options: CompileOptions) => Program;\n\n/**\n * The compiled programs of the formulas of the columns: one entry for each formula, for the last compiler and options.\n * A compiled program reads the cells of the active run, so each run with the same compiler and options can use it.\n */\nconst PROGRAMS = new WeakMap<Expr, { readonly compile: CompileFn; readonly domains: unknown; readonly fns: unknown; readonly extensions: unknown; readonly program: Program }>();\n\n/** The key of the options without extensions, for the extensions of the compiled programs. */\nconst NO_EXTENSIONS = {};\n\n/** The state of one table in a run. */\ninterface Table {\n /** The words for the table in a message: \"the sheet\" for the main table, or the table and its name. */\n readonly where: string;\n /** A short text for the ids of the cells of the table. */\n readonly tag: string;\n readonly space: Space;\n readonly columns: ReadonlyMap<string, Expr>;\n readonly cells: CellFormulas;\n // For each column, the number of keys at the start of the key order that a warm-up evaluated.\n readonly warmed: Map<string, number>;\n // The position of each key in the key order, made at the first warm-up.\n index: ReadonlyMap<string, number> | undefined;\n /** The result of each finished cell: for each column, the result at each key. */\n readonly done: Map<string, Map<string, Result<unknown>>>;\n}\n\nconst cycleError = (column: string, key: string): Result<never> =>\n fail(vexError(\"cycle\", `the cell \"${column}\" at \"${key}\" is on a cycle of cell references`, { origin: key, focus: key }));\n\n/** The id of a cell. */\nconst idOf = (t: Table, column: string, key: string): string => `${t.tag}\\u0001${column}\\u0000${key}`;\n\n/** This function gives the state of a table at the start of a run. */\nconst tableState = (where: string, i: number, t: SheetTable): Table => ({ where, tag: String(i), space: t.space, columns: t.columns, cells: t.cells ?? new Map(), warmed: new Map(), index: undefined, done: new Map() });\n\n/** This function gives the result of a finished cell, or `undefined`. */\nconst doneOf = (t: Table, column: string, key: string): Result<unknown> | undefined => t.done.get(column)?.get(key);\n\n/** This function keeps the result of a finished cell. */\nfunction setDone(t: Table, column: string, key: string, result: Result<unknown>): void {\n let results = t.done.get(column);\n if (results === undefined) {\n results = new Map();\n t.done.set(column, results);\n }\n results.set(key, result);\n}\n\n/** A direction of the reads of a column from itself: to an earlier key, to a later key, or down a tree to the children. */\nexport type Direction = \"before\" | \"after\" | \"down\";\n\n/** This function adds the direction of one move or one axis of a read of a column from itself. */\nfunction addDirection(d: Set<Direction>, m: Move | Axis): void {\n // The reverse order reads the same keys as its axis.\n if (m.t === \"reverse\") {\n addDirection(d, m.axis);\n return;\n }\n if (m.t === \"offset\" || m.t === \"window\") {\n // An offset moves by its first step that is not 0. A window reads the keys from `from` to `to`.\n const steps = m.t === \"offset\" ? [m.d.find((x) => x !== 0) ?? 0] : [m.from, m.to];\n // A step of 0 reads the cell itself, which is a cycle in each order.\n // Stryker disable next-line EqualityOperator: see the comment above\n if (steps.some((x) => x < 0)) d.add(\"before\");\n // Stryker disable next-line EqualityOperator: see the comment above\n if (steps.some((x) => x > 0)) d.add(\"after\");\n } else if (m.t === \"children\" || m.t === \"descendants\") d.add(\"down\");\n // The items of a list can be at each key, so the axis list gives no direction, and the other reads decide the order.\n}\n\n/** This function gives the base axis of an axis, and the tests of its `where` axes. */\nfunction partsOf(axis: Axis): { readonly base: Axis; readonly tests: readonly Expr[] } {\n const tests: Expr[] = [];\n let base = axis;\n while (base.t === \"where\") {\n tests.push(base.test);\n base = base.axis;\n }\n return { base, tests };\n}\n\n/**\n * This function gives the columns that the formulas of the column `self` read with a cell reference: its formula and\n * the formulas of its cells. It also gives the directions of their reads of the column itself. A read in the body or\n * in a test of an axis also has the direction of that axis. It walks each expression with a stack, not with recursion.\n */\nexport function readsOf(columns: ReadonlyMap<string, Expr>, cells: CellFormulas, self: string): { readonly columns: ReadonlySet<string>; readonly directions: ReadonlySet<Direction> } {\n const read = new Set<string>();\n const directions = new Set<Direction>();\n const formula = columns.get(self);\n // An expression that is not valid reads no column. Its evaluation gives the error (EVAL.SHAPE).\n const todo: [Expr, Axis | undefined][] = [...(formula === undefined ? [] : [formula]), ...(cells.get(self)?.values() ?? [])].filter((e) => shapeError(e) === undefined).map((e) => [e, undefined]);\n for (let item = todo.pop(); item !== undefined; item = todo.pop()) {\n const [e, axis] = item;\n // A test of the axis of a data limit reads at each target, as the test of an `each` does.\n const split = e.tag === \"iterate\" ? splitLimit(e) : undefined;\n if (split !== undefined) for (const x of split) todo.push([x, axis]);\n else if (e.tag === \"each\" || e.tag === \"fold\") {\n const { base, tests } = partsOf(e.axis);\n for (const x of [...(e.tag === \"each\" ? [e.body] : Object.values(e.step)), ...tests]) todo.push([x, base]);\n // The values of init, the result of a fold, the list of the axis list and the expressions of the address evaluate\n // at the node, so they keep the outer direction.\n const list = listOf(e.axis);\n for (const x of [...(e.tag === \"fold\" ? [...Object.values(e.init), e.result] : []), ...addrExprs(e.at), ...(list === undefined ? [] : [list])]) todo.push([x, axis]);\n } else if (e.tag !== \"ext\") {\n for (const child of children(e)) todo.push([child, axis]);\n // The data of an extension of another kind can look like a cell reference. It only changes the order of a fill.\n // Stryker disable next-line ConditionalExpression,LogicalOperator: see the comment above\n } else if (e.kind === CELL_KIND && isCellRef(e.data)) {\n read.add(e.data.column);\n // The directions of the reads of another column only change the order of a fill, because that column comes first.\n // Stryker disable next-line ConditionalExpression: see the comment above\n if (e.data.column === self) for (const m of [...(axis === undefined ? [] : [axis]), ...e.data.at]) addDirection(directions, m);\n }\n }\n return { columns: read, directions };\n}\n\n/**\n * This function gives the columns of a sheet in an order where each column comes after the columns that it reads.\n * The columns of a cycle keep their order. The columns with formulas of cells only come last.\n */\nexport function columnOrder(columns: ReadonlyMap<string, Expr>, cells: CellFormulas): readonly string[] {\n const names = new Set([...columns.keys(), ...cells.keys()]);\n let left = [...names].map((c) => ({ c, needs: [...readsOf(columns, cells, c).columns].filter((x) => x !== c && names.has(x)) }));\n const order: string[] = [];\n const placed = new Set<string>();\n // Each pass places each column whose reads are placed. A pass that places no column leaves a cycle, so it places\n // the first column that is left.\n while (left.length > 0) {\n const ready = left.filter((x) => x.needs.every((n) => placed.has(n)));\n for (const x of ready.length > 0 ? ready : left.slice(0, 1)) {\n order.push(x.c);\n placed.add(x.c);\n }\n left = left.filter((x) => !placed.has(x.c));\n }\n return order;\n}\n\n/**\n * This function gives the keys of a space in the order of the reads of a column from itself. A read of a later key\n * reverses the order. In a tree, a read of the children puts the children before their parent.\n */\nfunction keyOrder(s: Space, d: ReadonlySet<Direction>): readonly string[] {\n const reverse = d.has(\"after\") && !d.has(\"before\");\n const childrenOf = s.childrenOf?.bind(s);\n if (childrenOf === undefined) return reverse ? s.keys.toReversed() : s.keys;\n const post = d.has(\"down\");\n // The order with each parent before its children, and the order after the children is that order from the end, with\n // the siblings in the other order. `push` puts the next key to visit at the end of the stack.\n const backwards = post !== reverse;\n const push = (stack: string[], keys: readonly string[]): void => {\n for (const k of backwards ? keys : keys.toReversed()) stack.push(k);\n };\n const isChild = new Set(s.keys.flatMap((k) => childrenOf(k)));\n const stack: string[] = [];\n push(stack, s.keys.filter((k) => !isChild.has(k)));\n const out: string[] = [];\n for (let k = stack.pop(); k !== undefined; k = stack.pop()) {\n out.push(k);\n push(stack, childrenOf(k));\n }\n return post ? out.toReversed() : out;\n}\n\n/** The state of one cell in the search. */\ninterface Visit {\n readonly id: string;\n readonly table: Table;\n readonly column: string;\n readonly key: string;\n readonly index: number;\n low: number;\n reread: boolean;\n result: Result<unknown>;\n /** True when the last evaluation paused, because a cell that it reads is not finished. */\n paused: boolean;\n /** The cell that the evaluation waits for: a cell that the run started, or a cell that paused too. */\n need: Visit | undefined;\n}\n\n/**\n * The budget of the stack for the recursion of a run, in estimated frames. Each engine has more stack than this, so\n * the recursion of a run cannot fill the stack (SHEET.DEEP).\n */\nconst STACK_BUDGET = 3000;\n\n/**\n * One run of a sheet. It keeps the result of each cell that it evaluated. The space does not change, so a cell has\n * one result in a run.\n *\n * The run is a depth-first search with the algorithm of Tarjan for strongly connected components. A cell finishes\n * when its component finishes. Each cell of a component with two or more cells, or with a reference to itself,\n * gives `#CYCLE!`. A read of a cell that is not finished gives `#CYCLE!` too. Thus the order of the evaluations\n * does not change a result, also when `ifError` catches the error of a cycle.\n *\n * The search does not depend on the call stack of the engine (SHEET.DEEP). A read of a cell evaluates that cell\n * with recursion while the stack of the run stays in a budget. When a read is over the budget, the run starts the\n * cell, and the cell that reads it pauses. A paused evaluation reads no other cell and changes no state of the\n * search. The run then evaluates the started cell from its own list, and it evaluates the paused cell again after\n * that cell. A formula is pure (EVAL.PURE), so the second evaluation gives the result of one evaluation.\n *\n * A run can have more tables (SHEET.TABLES). Each table has its own space, and one search covers the cells of all\n * the tables. Thus a cycle across tables gives `#CYCLE!` too.\n */\nexport class SheetRun {\n readonly #main: Table;\n // The tables by name and by space. A cell reference reads the table of the space where it evaluates.\n readonly #byName = new Map<string, Table>();\n readonly #bySpace = new Map<Space, Table>();\n readonly #opts: Omit<EvalOptions, \"origin\" | \"trace\" | \"space\">;\n // The cells on the stack of the search: started, but their component is not finished.\n readonly #visits = new Map<string, Visit>();\n // Stryker disable next-line ArrayDeclaration: the search never reads below the root of a component\n readonly #stack: Visit[] = [];\n // The cell whose formula is in evaluation. At the top level, it is a placeholder that is not a cell.\n #top: Visit;\n // The placeholder at the top in a fill, and true when the evaluation of a fill reads a cell that is not finished.\n readonly #filling: Visit;\n #missed = false;\n #next = 0;\n // The estimated frames of the stack that the evaluations in progress use, and the cost of each program.\n #used = 0;\n readonly #cost = new Map<Expr, number>();\n readonly #budget: number;\n readonly #compile: CompileFn | undefined;\n readonly #compileOptions: CompileOptions;\n // The run that evaluates a formula with a compiled program. Each run is synchronous, so a run inside the evaluation\n // of another run gives the active run back when it ends.\n static #active: SheetRun | undefined;\n // The extensions of the compiled programs, for each object of extensions of the options. Their cell handler reads\n // the cells of the active run, so a compiled program does not depend on one run.\n static readonly #shared = new WeakMap<object, Readonly<Record<string, ExtHandler>>>();\n\n /** `budget` is the budget of the stack in estimated frames. A test can make it small, so the run pauses often. */\n constructor(columns: ReadonlyMap<string, Expr>, opts: SheetOptions, budget: number = STACK_BUDGET) {\n const { cells, name, tables, space, compile, ...rest } = opts;\n this.#main = { where: \"the sheet\", tag: \"0\", space, columns, cells: cells ?? new Map(), warmed: new Map(), index: undefined, done: new Map() };\n this.#bySpace.set(space, this.#main);\n if (name !== undefined) this.#byName.set(name, this.#main);\n if (tables !== undefined) {\n let i = 0;\n for (const [n, t] of tables) {\n if (this.#byName.has(n)) continue;\n const other = tableState(`the table \"${n}\"`, ++i, t);\n this.#byName.set(n, other);\n // A table with the space of an earlier table does not take its cells: the first table keeps the space.\n if (!this.#bySpace.has(t.space)) this.#bySpace.set(t.space, other);\n }\n }\n // Stryker disable next-line all: the placeholder is not a cell, so the search reads none of its fields\n this.#top = { id: \"\", table: this.#main, column: \"\", key: \"\", index: -1, low: -1, reread: false, result: cycleError(\"\", \"\"), paused: false, need: undefined };\n // Stryker disable next-line all: the placeholder is not a cell, so the search reads none of its fields\n this.#filling = { id: \"\", table: this.#main, column: \"\", key: \"\", index: 0, low: 0, reread: false, result: cycleError(\"\", \"\"), paused: false, need: undefined };\n this.#budget = budget;\n this.#compile = compile;\n const spaces = Object.fromEntries([...this.#byName].map(([n, t]) => [n, t.space]));\n this.#opts = { ...rest, tables: spaces, extensions: { ...rest.extensions, [CELL_KIND]: this.#handler } };\n const outer = rest.extensions ?? NO_EXTENSIONS;\n let shared = SheetRun.#shared.get(outer);\n if (shared === undefined) {\n shared = { ...rest.extensions, [CELL_KIND]: SheetRun.#cellOfActive };\n SheetRun.#shared.set(outer, shared);\n }\n this.#compileOptions = { ...this.#opts, extensions: shared };\n }\n\n /** The cell handler of the compiled programs: it reads the cells of the active run. */\n static readonly #cellOfActive: ExtHandler = (data, ctx) => {\n const run = SheetRun.#active;\n return run === undefined ? fail(vexError(\"unbound\", \"a compiled formula reads cells only in the evaluation of a sheet run\")) : run.#handler(data, ctx);\n };\n\n /** This method gives the program of a cell: its own formula, or the formula of its column (SHEET.CELL.FORMULA). */\n #programOf(t: Table, column: string, key: string): Expr | undefined {\n // Stryker disable next-line ConditionalExpression: without formulas of cells, the lookup gives undefined anyway\n const own = t.cells.size === 0 ? undefined : t.cells.get(column)?.get(key);\n return own ?? t.columns.get(column);\n }\n\n /** This method gives the error of a cell without a program. */\n #unbound(t: Table, column: string, key: string): Result<never> {\n const message = t.cells.has(column) ? `the cell \"${column}\" at \"${key}\" has no formula` : `${t.where} has no column \"${column}\"`;\n return fail(vexError(\"unbound\", message, { origin: key, focus: key }));\n }\n\n /** This method gives the table of a name for a read from a host. Without a name, it is the main table. */\n #named(table: string | undefined, key: string): Table | Result<never> {\n if (table === undefined) return this.#main;\n return this.#byName.get(table) ?? fail(vexError(\"no-table\", `the run has no table \"${table}\"`, { origin: key, focus: key }));\n }\n\n readonly #handler: ExtHandler = (data, ctx) => {\n // The interpreter gives an error without an origin the path and the position of its node.\n if (!isCellRef(data)) return fail(vexError(\"bad-expression\", \"a cell reference needs a column name and an address of fixed moves\"));\n const where = resolveAddr(ctx.space, ctx.position, data.at);\n if (!where.ok) return fail({ ...where.error, path: ctx.path });\n // The evaluation of a cell has the space of its table, and the body of the axis table has the space of that table.\n /* v8 ignore next -- @preserve: each space of an evaluation of the run is the space of a table */\n return this.#read(this.#bySpace.get(ctx.space) ?? this.#main, data.column, where.value);\n };\n\n /**\n * This method gives the result of one cell: the column `column` at the key `key` of the main table, or of the table\n * `table`. A read from a host first evaluates the column at the keys before `key`, in key order. Thus a recurrence\n * over the keys reads finished cells.\n */\n cell(column: string, key: string, table?: string): Result<unknown> {\n const t = this.#named(table, key);\n if (!(\"space\" in t)) return t;\n // The placeholder at the top has the index -1. A read inside a formula has a cell at the top, so it does not warm.\n if (this.#top.index >= 0) return this.#read(t, column, key);\n // A finished cell needs no warm-up.\n const done = doneOf(t, column, key);\n if (done !== undefined) return done;\n this.#warmTo(t, column, key);\n return this.#drive(t, column, key);\n }\n\n /** This method evaluates the column `column` at each key before `key` that it did not evaluate before, in key order. */\n #warmTo(t: Table, column: string, key: string): void {\n if (!t.columns.has(column)) return;\n const keys = t.space.keys;\n t.index ??= new Map(keys.map((k, i) => [k, i]));\n const end = t.index.get(key) ?? 0;\n const start = t.warmed.get(column) ?? 0;\n for (let i = start; i < end; i++) this.#drive(t, column, keys[i] ?? key);\n if (end > start) t.warmed.set(column, end);\n }\n\n /** This method gives the estimated frames of the stack that one evaluation of the program `program` uses. */\n #costOf(program: Expr): number {\n let cost = this.#cost.get(program);\n if (cost === undefined) {\n cost = 3 * (shapeError(program) === undefined ? nestingOf(program) : 1) + 16;\n this.#cost.set(program, cost);\n }\n return cost;\n }\n\n /** This method puts a new cell on the stack of the search. */\n #start(t: Table, column: string, key: string): Visit {\n const n = this.#next++;\n const visit: Visit = { id: idOf(t, column, key), table: t, column, key, index: n, low: n, reread: false, result: cycleError(column, key), paused: false, need: undefined };\n this.#visits.set(visit.id, visit);\n this.#stack.push(visit);\n return visit;\n }\n\n /** This method evaluates the formula of a cell once. When the evaluation pauses, the result of the cell does not change. */\n #evaluate(visit: Visit, program: Expr): void {\n const caller = this.#top;\n const cost = this.#costOf(program);\n visit.paused = false;\n visit.need = undefined;\n this.#top = visit;\n this.#used += cost;\n const result = this.#run(visit.table, visit.column, visit.key, program);\n this.#used -= cost;\n this.#top = caller;\n if (!visit.paused) visit.result = result;\n }\n\n /** This method evaluates the formula `program` of a cell, with its compiled program or with the interpreter. */\n #run(t: Table, column: string, key: string, program: Expr): Result<unknown> {\n const options = { ...this.#opts, space: t.space, origin: key };\n const compiled = this.#compiled(t, column, program);\n if (compiled === undefined) return evaluate(program, options);\n const active = SheetRun.#active;\n SheetRun.#active = this;\n const result = compiled.run(options);\n SheetRun.#active = active;\n return result;\n }\n\n /**\n * This method gives the compiled program of the formula of a column, or `undefined` for the interpreter. A formula\n * compiles once for each compiler and options, also across runs.\n */\n #compiled(t: Table, column: string, program: Expr): Program | undefined {\n const compile = this.#compile;\n // The formula of a cell evaluates once in a run, so the run compiles only the formulas of the columns.\n // V-056: a formula that is not an object cannot be a key of the cache, so the interpreter gives its error.\n if (compile === undefined || t.columns.get(column) !== program || typeof program !== \"object\" || program === null) return undefined;\n const { domains, fns, extensions } = this.#compileOptions;\n const hit = PROGRAMS.get(program);\n if (hit !== undefined && hit.compile === compile && hit.domains === domains && hit.fns === fns && hit.extensions === extensions) return hit.program;\n const compiled = compile(program, this.#compileOptions);\n PROGRAMS.set(program, { compile, domains, fns, extensions, program: compiled });\n return compiled;\n }\n\n /** This method ends a cell whose evaluation did not pause: it finishes its component, or it gives its low to the caller. */\n #end(visit: Visit, caller: Visit | undefined): void {\n if (visit.low === visit.index) this.#finish(visit);\n else if (caller !== undefined) caller.low = Math.min(caller.low, visit.low);\n }\n\n /** This method reads a cell from the formula of the cell at the top. */\n #read(t: Table, column: string, key: string): Result<unknown> {\n const done = doneOf(t, column, key);\n if (done !== undefined) return done;\n const caller = this.#top;\n // A paused evaluation reads no other cell, so it does not follow a path that its final evaluation does not follow.\n // In a fill, the cell goes to the search after the evaluation (SHEET.FILL).\n if (caller.paused) return cycleError(column, key);\n if (caller === this.#filling) {\n this.#missed = true;\n return cycleError(column, key);\n }\n const id = idOf(t, column, key);\n const seen = this.#visits.get(id);\n if (seen !== undefined) {\n // A read of a cell that is not finished: the caller and this cell are on one cycle. The cell is on the\n // stack of the search, so it is in the component of the caller. Thus a component with one cell is cyclic\n // only if that cell reads itself.\n caller.low = Math.min(caller.low, seen.index);\n seen.reread = true;\n return cycleError(column, key);\n }\n const program = this.#programOf(t, column, key);\n if (program === undefined) return this.#unbound(t, column, key);\n const visit = this.#start(t, column, key);\n if (this.#used + this.#costOf(program) > this.#budget) {\n // Over the budget: the caller pauses, and the run evaluates the new cell from its own list.\n caller.paused = true;\n caller.need = visit;\n return cycleError(column, key);\n }\n this.#evaluate(visit, program);\n if (visit.paused) {\n caller.paused = true;\n caller.need = visit;\n return cycleError(column, key);\n }\n this.#end(visit, caller);\n return doneOf(t, column, key) ?? cycleError(column, key);\n }\n\n /** This method evaluates a cell from the top level. The cells that pause go on a list, not on the call stack. */\n #drive(t: Table, column: string, key: string): Result<unknown> {\n const done = doneOf(t, column, key);\n if (done !== undefined) return done;\n if (this.#programOf(t, column, key) === undefined) return this.#unbound(t, column, key);\n const work: Visit[] = [this.#start(t, column, key)];\n for (let visit = work.at(-1); visit !== undefined; visit = work.at(-1)) {\n const program = this.#programOf(visit.table, visit.column, visit.key);\n /* v8 ignore next -- @preserve: a visit exists only for a cell with a program */\n if (program === undefined) break;\n this.#evaluate(visit, program);\n if (visit.paused) {\n // The cells that the evaluation waits for go on the list, the last one on the top.\n for (let need = visit.need; need !== undefined; need = need.need) work.push(need);\n continue;\n }\n work.pop();\n this.#end(visit, work.at(-1));\n }\n return doneOf(t, column, key) ?? cycleError(column, key);\n }\n\n /** This method takes the component of `root` from the stack, and sets the final result of each of its cells. */\n #finish(root: Visit): void {\n // The root is near the top of the stack, so the search starts at the top: a deep chain needs no long scan.\n const members = this.#stack.splice(this.#stack.lastIndexOf(root));\n // A component of two or more cells reads its root again, so root.reread alone decides. The length test is a guard.\n // Stryker disable next-line ConditionalExpression,LogicalOperator: members.length > 1 implies root.reread\n const cyclic = members.length > 1 || root.reread;\n for (const m of members) {\n // Stryker disable next-line CallExpression: a finished cell has a result, and a read looks for the result first\n this.#visits.delete(m.id);\n setDone(m.table, m.column, m.key, cyclic ? cycleError(m.column, m.key) : m.result);\n }\n }\n\n /** This method evaluates one cell with a trace of the nodes of its program. The result is the result of the cell. */\n explain(column: string, key: string, table?: string): Trace {\n const result = this.cell(column, key, table);\n const t = this.#named(table, key);\n const program = \"space\" in t ? this.#programOf(t, column, key) : undefined;\n if (program === undefined || !(\"space\" in t)) return { events: [], result };\n return { events: explain(program, { ...this.#opts, space: t.space, origin: key }).events, result };\n }\n\n /**\n * This method evaluates each cell of the table `table`, or of the main table (SHEET.FILL). Each column comes after\n * the columns that it reads, and the keys of a column come in the order of its reads from itself. Thus most reads\n * find a finished cell. An evaluation that reads a cell that is not finished has no effect, and the search then\n * evaluates its cell. A read of a cell gives the same result after a fill.\n */\n fill(table?: string): void {\n const t = table === undefined ? this.#main : this.#byName.get(table);\n // A read inside a formula has a cell at the top. A fill there has no effect.\n if (t === undefined || this.#top.index >= 0) return;\n const host = this.#top;\n for (const column of columnOrder(t.columns, t.cells)) {\n for (const key of keyOrder(t.space, readsOf(t.columns, t.cells, column).directions)) {\n const program = this.#programOf(t, column, key);\n if (program === undefined || doneOf(t, column, key) !== undefined) continue;\n this.#top = this.#filling;\n this.#missed = false;\n const result = this.#run(t, column, key, program);\n this.#top = host;\n if (this.#missed) this.#drive(t, column, key);\n else setDone(t, column, key, result);\n }\n }\n }\n\n /**\n * This method evaluates the column `column` at each key before `key`, in key order. A recurrence over the keys,\n * for example a running total, then reads finished cells.\n */\n warm(column: string, key: string, table?: string): void {\n const t = this.#named(table, key);\n // Stryker disable next-line all: a warm-up changes no result, only the depth of the recursion (SHEET.ORDER)\n if (\"space\" in t) this.#warmTo(t, column, key);\n }\n}\n","/**\n * The typed builder. Method calls make an expression of the IR. The builder has no other job: it does not\n * evaluate anything until a caller asks for a value.\n */\nimport type { AnyDomain, Domain, OpSpec, PrimitiveKind } from \"./domain.ts\";\nimport type { VexError } from \"./errors.ts\";\nimport { evaluate, explain, type EvalOptions, type ExtHandler, type FreeFn } from \"./evaluate.ts\";\nimport { addrExprs, app, axisExprs, call as callExpr, children, dataLimit, each, ext, fix as fixExpr, fn as fnExpr, fold as foldExpr, index as indexMove, iterate as iterateExpr, key as keyMove, last as lastExpr, let_, lit, listOf, offset as offsetMove, other as otherMove, origin as originMove, parent as parentMove, rec, ref, toPath, v, type Addr, type Axis, type DataLimit, type Expr, type FixJoin, type ItemNames, type Move } from \"./ir.ts\";\nimport { cell as cellRef, SheetRun, type CellFormulas } from \"./sheet.ts\";\nimport { ok, toOptional, type Optional, type Result } from \"./result.ts\";\nimport type { Space } from \"./space.ts\";\nimport type { Trace } from \"./trace.ts\";\nimport { vexList, type VexList } from \"./list.ts\";\nimport { traversal, type Traversal } from \"./traversal.ts\";\n\n// ---------------------------------------------------------------- argument tokens\n\ndeclare const ARG_TYPE: unique symbol;\ndeclare const CHAIN_VALUE: unique symbol;\ndeclare const FN_RESULT: unique symbol;\n\n/** An argument token: an expression with the static type `T` of its value. */\nexport interface Arg<T> {\n readonly kind: \"vex.arg\";\n readonly expr: Expr;\n /** This phantom member carries the type. It is not present at run time. */\n readonly [ARG_TYPE]?: T;\n}\n\nconst argToken = <T>(expr: Expr): Arg<T> => ({ kind: \"vex.arg\", expr });\n\n\n// ---------------------------------------------------------------- type helpers\n\n/**\n * The value of a column with the join `J`: a boolean for `or` and `and`, and a number for `max` and `min` (FIX.KIND). A\n * union of joins has no one kind, so it gives `never`.\n */\nexport type FixValue<J extends FixJoin> = [J] extends [\"or\" | \"and\"] ? boolean : [J] extends [\"max\" | \"min\"] ? number : never;\n\n/** The keys of any member of a union of record types. */\ntype AllKeys<O> = O extends unknown ? keyof O : never;\n\n/** The type of field `P` in the members of `O` that have it. */\ntype FieldType<O, P extends PropertyKey> = O extends unknown ? (P extends keyof O ? O[P] : never) : never;\n\n/**\n * The merged view of a union of record types: each field of any member, with the union of its types. A record\n * without the field gives `#N/A` at run time.\n */\nexport type Merge<O> = { readonly [P in AllKeys<O>]: FieldType<O, P> };\n\n/** The keys of `O` whose values have the type `T`. */\nexport type KeysOfType<O, T> = { [P in keyof O]-?: [NonNullable<O[P]>] extends [never] ? never : NonNullable<O[P]> extends T ? P : never }[keyof O] & string;\n\n/** The method names of `D`. */\nexport type MethodKeys<D> = { [P in keyof D]-?: D[P] extends (...args: never[]) => unknown ? P : never }[keyof D] & string;\n\n/** The value type of a domain. */\nexport type DomainValue<Dm> = Dm extends Domain<string, infer D, infer _Ops> ? D : never;\n\ntype OpsOf<Dm> = Dm extends Domain<string, unknown, infer Ops> ? Ops : Dm extends { readonly ops: infer Ops } ? Ops : never;\n\n/** The op names that a chain over a value of domain `Dm` can use. */\nexport type OpNames<Dm> =\n | (keyof OpsOf<Dm> & string)\n | (Dm extends { readonly methods: \"all\" } ? MethodKeys<DomainValue<Dm>> : never);\n\ntype FnOf<Dm, M extends string> = M extends keyof OpsOf<Dm>\n ? OpsOf<Dm>[M] extends { readonly fn: (self: never, ...args: infer P) => infer R }\n ? (...args: P) => R\n : M extends keyof DomainValue<Dm>\n ? DomainValue<Dm>[M]\n : never\n : M extends keyof DomainValue<Dm>\n ? DomainValue<Dm>[M]\n : never;\n\n/** The parameters of op `M` after the receiver. */\nexport type OpParams<Dm, M extends string> = FnOf<Dm, M> extends (...args: infer P) => unknown ? P : never;\n\n/** The value type that op `M` gives. */\nexport type OpReturn<Dm, M extends string> = FnOf<Dm, M> extends (...args: never[]) => infer R ? R : never;\n\ntype Lifts<Dm, M extends string> = M extends keyof OpsOf<Dm> ? (OpsOf<Dm>[M] extends { readonly liftScalar: true } ? true : false) : false;\n\n/** The first domain of `Dms` whose values include `T`, or `never`. */\nexport type DomainFor<Dms extends readonly AnyDomain[], T> = Dms extends readonly [infer H, ...infer R extends readonly AnyDomain[]]\n ? [T] extends [never]\n ? never\n : [T] extends [DomainValue<H>]\n ? H\n : DomainFor<R, T>\n : never;\n\ntype UnionToIntersection<U> = (U extends unknown ? (x: U) => void : never) extends (x: infer I) => void ? I : never;\ntype LastOf<U> = UnionToIntersection<U extends unknown ? () => U : never> extends () => infer R ? R : never;\n\n/** `true` if `other()` is permitted for the key type: a pair of keys, or keys that the compiler does not know. */\nexport type AllowsOther<K extends string> = string extends K\n ? true\n : `${number}` extends K\n ? true\n : [Exclude<K, LastOf<K>>] extends [never]\n ? false\n : [Exclude<Exclude<K, LastOf<K>>, LastOf<Exclude<K, LastOf<K>>>>] extends [never]\n ? true\n : false;\n\n/**\n * The inputs for an argument with the parameter type `P`. The input can be a literal of type `P`, but not a bare\n * string. It can be a field of the record with type `P`, an argument token, or a chain that gives `P`. If the op\n * lifts scalars, it can also be a number.\n */\nexport type ArgInput<P, Ctx extends ChainContext, Lift extends boolean> =\n | (P extends string ? never : P)\n | KeysOfType<Ctx[\"record\"], P>\n | Arg<P>\n | ChainOf<Ctx, P>\n | (Lift extends true ? ([P] extends [DomainValue<DomainFor<Ctx[\"domains\"], P>>] ? LiftedNumber<Ctx> : never) : never);\n\n/**\n * A number argument for a domain parameter of an op with `liftScalar` (TYPE.LIFT): a number, a field with numbers, an\n * argument or a chain. The interpreter lifts each of them with `fromScalar` (CALL.LIFT).\n */\ntype LiftedNumber<Ctx extends ChainContext> = number | KeysOfType<Ctx[\"record\"], number> | Arg<number> | ChainOf<Ctx, number>;\n\ntype MapArgs<P extends readonly unknown[], Ctx extends ChainContext, Lift extends boolean> = { [I in keyof P]: ArgInput<P[I], Ctx, Lift> };\n\n/** A table of free functions. The first parameter of a function gets the current value of the chain. */\nexport type FnTable = Readonly<Record<string, (...args: never[]) => unknown>>;\n\n/** The free functions of a builder without `withOptions`: none, so `call` accepts no name. */\n// oxlint-disable-next-line typescript/no-generated-empty-object-type -- an empty table is the intent.\nexport type NoFns = Record<never, never>;\n\n/** The static context of a chain: its domains, its key type, its record type and its free functions. */\nexport interface ChainContext {\n readonly domains: readonly AnyDomain[];\n readonly keys: string;\n readonly record: unknown;\n readonly fns?: FnTable;\n}\n\ntype FnsOf<Ctx extends ChainContext> = NonNullable<Ctx[\"fns\"]>;\ntype FnParams<F> = F extends (...args: infer P) => unknown ? P : never;\ntype FirstParam<P> = P extends readonly [infer A, ...unknown[]] ? A : unknown;\ntype RestParams<P> = P extends readonly [unknown, ...infer R] ? R : [];\n\n/** The names of the free functions whose first parameter accepts a value of type `T`. */\nexport type CallableFns<Ctx extends ChainContext, T> = {\n [K in keyof FnsOf<Ctx>]: [T] extends [FirstParam<FnParams<FnsOf<Ctx>[K]>>] ? K : never;\n}[keyof FnsOf<Ctx>] &\n string;\n\n/** The inputs for the parameters of the free function `N` after its first parameter. */\nexport type CallArgs<Ctx extends ChainContext, N extends keyof FnsOf<Ctx>> = MapArgs<RestParams<FnParams<FnsOf<Ctx>[N]>>, Ctx, false>;\n\n/** The return type of the free function `N`. */\nexport type CallReturn<Ctx extends ChainContext, N extends keyof FnsOf<Ctx>> = FnsOf<Ctx>[N] extends (...args: never[]) => infer R ? R : unknown;\n\n/** The ops section `._` of a chain whose value has domain `Dm`. */\nexport type OpsProxy<Ctx extends ChainContext, Dm> = {\n readonly [M in OpNames<Dm>]: (...args: MapArgs<OpParams<Dm, M>, Ctx, Lifts<Dm, M>>) => ChainOf<Ctx, OpReturn<Dm, M>>;\n};\n\n// ---------------------------------------------------------------- chain types\n\n/** The members of every chain. */\nexport interface ChainBase<Ctx extends ChainContext, T> {\n readonly kind: \"vex.chain\";\n /** This phantom member carries the value type. It is not present at run time. */\n readonly [CHAIN_VALUE]?: T;\n /** The expression of the chain, as plain data. */\n readonly program: Expr;\n /** This method evaluates the chain at a key. An error gives `none`. */\n at(k: Ctx[\"keys\"]): Optional<T>;\n /** This method is the same as `at`. The v0.9 spec calls it `value`. */\n value(k: Ctx[\"keys\"]): Optional<T>;\n /** This method evaluates the chain at a key, and gives the error if there is one. */\n result(k: Ctx[\"keys\"]): Result<T>;\n /** This method evaluates the chain at a key, with a trace of each node. */\n explain(k: Ctx[\"keys\"]): Trace;\n /** This method evaluates the chain at each key of the space (the start axis). */\n all(): Traversal<Ctx[\"keys\"], T>;\n /** This method gives a chain whose value is a field of the record at the current address. */\n from<P extends keyof Ctx[\"record\"] & string>(field: P): ChainOf<Ctx, NonNullable<Ctx[\"record\"][P]>>;\n /**\n * Navigation: later field references read at the key `k`. A chain of a text gives the key, and it evaluates at the\n * focus before the moves (NAV.COMPUTED).\n */\n to(k: Ctx[\"keys\"] | ChainBase<Ctx, string>): ChainOf<Ctx, T>;\n /**\n * Navigation: later field references read at the key with this position in the key order. A chain of a number gives\n * the position, and it evaluates at the focus before the moves (NAV.COMPUTED).\n */\n index(i: number | ChainBase<Ctx, number>): ChainOf<Ctx, T>;\n /** Navigation: later field references read at a relative position in an array or a grid. */\n offset(...d: readonly number[]): ChainOf<Ctx, T>;\n /** Navigation: later field references read at the origin again. */\n origin(): ChainOf<Ctx, T>;\n /** Navigation: later field references read at the parent of the focus, in a tree space. A root gives `#REF!`. */\n parent(): ChainOf<Ctx, T>;\n /** This method uses `fallback` when the chain gives an error. */\n ifError<U>(fallback: ArgInput<U, Ctx, false> | T): ChainOf<Ctx, T | U>;\n /**\n * This method gives `then` when the boolean value is true, and `otherwise` when it is false (the form `if`). Only\n * the selected branch evaluates.\n */\n if<U, V>(this: ChainBase<Ctx, boolean>, then: ArgInput<U, Ctx, false>, otherwise: ArgInput<V, Ctx, false>): ChainOf<Ctx, U | V>;\n /**\n * This method applies the free function `name` of `withOptions`. The function gets the current value as its first\n * argument, then `args`. The types accept only the functions whose first parameter accepts the current value.\n */\n call<N extends CallableFns<Ctx, T>>(name: N, ...args: CallArgs<Ctx, N>): ChainOf<Ctx, CallReturn<Ctx, N>>;\n /** This method evaluates each branch with the current value, and gives a record of the results. */\n fork<const B extends Readonly<Record<string, (c: ChainOf<Ctx, T>) => ChainBase<Ctx, unknown>>>>(branches: B): ChainOf<Ctx, { readonly [N in keyof B]: ValueOf<ReturnType<B[N]>> }>;\n /**\n * This method makes up to `limit` steps (ITERATE.LIMIT). A list chain or a `DataLimit` gives a limit from the data\n * (ITERATE.LIMIT.DATA). `init` gives the names and their first values, and `step` gives the next values. A true\n * `until` stops the steps (ITERATE.UNTIL). `result` gives the value of the chain. A name with a list chain as its\n * first value is a list chain (BUILD.LIST.LOOP), and a list result gives a list chain.\n */\n iterate<const I extends Readonly<Record<string, unknown>>, U>(\n limit: number | DataLimit | ListChain<Ctx, unknown>,\n init: I,\n step: (vars: LoopVars<Ctx, I>) => NoInfer<LoopStep<Ctx, I>>,\n result: (vars: LoopVars<Ctx, I>) => ListChain<Ctx, U>,\n opts?: { readonly until?: (vars: LoopVars<Ctx, I>) => ArgInput<boolean, Ctx, false> },\n ): ListChain<Ctx, U>;\n iterate<const I extends Readonly<Record<string, unknown>>, R>(\n limit: number | DataLimit | ListChain<Ctx, unknown>,\n init: I,\n step: (vars: LoopVars<Ctx, I>) => NoInfer<LoopStep<Ctx, I>>,\n result: (vars: LoopVars<Ctx, I>) => ArgInput<R, Ctx, false>,\n opts?: { readonly until?: (vars: LoopVars<Ctx, I>) => ArgInput<boolean, Ctx, false> },\n ): ChainOf<Ctx, R>;\n /**\n * This method makes a fixed-point column (BUILD.FIX). `init` gives each row its value of round 0. `step` gets a chain\n * of the last round at the focus, and it gives the next value of the row. `join` keeps each row on one way (FIX.JOIN).\n * The value of the chain is the row of the focus, and the rounds end when no row changes (FIX.ROUNDS).\n */\n fix<J extends FixJoin>(\n name: string,\n join: J,\n init: ArgInput<FixValue<J>, Ctx, false>,\n step: (last: ChainOf<Ctx, FixValue<J>>) => NoInfer<ArgInput<FixValue<J>, Ctx, false>>,\n ): ChainOf<Ctx, FixValue<J>>;\n /** This method binds names for the body. The body gets a variable token for each name. */\n with<const B extends Readonly<Record<string, unknown>>, U>(\n binds: B,\n body: (c: ChainOf<Ctx, T>, vars: { readonly [N in keyof B]: Arg<ArgValue<Ctx, B[N]>> }) => ChainBase<Ctx, U>,\n ): ChainOf<Ctx, U>;\n /**\n * This method binds functions of `root.fn` (BUILD.FN) and gives the value of `body`. `call` gives a chain of a call of\n * each function. A function cannot call another function of the same `functions`, so it uses an outer one (FN.TOTAL).\n */\n functions<const F extends Readonly<Record<string, FnDef<readonly FnParamKind[], unknown>>>, U>(fns: F, body: (c: ChainOf<Ctx, T>, call: FnCalls<Ctx, F>) => ChainBase<Ctx, U>): ChainOf<Ctx, U>;\n /** The others axis: the body evaluates at each key except the focus. Its start value is the current value. */\n others<U>(body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The neighbors axis of a grid. */\n neighbors<U>(n: 4 | 8, body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The all axis inside the expression: the body evaluates at each key, with the current value as start value. */\n each<U>(body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The children axis of a tree space: the body evaluates at each child of the focus. */\n children<U>(body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The ancestors axis of a tree space: the parent first, the root last. */\n ancestors<U>(body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The descendants axis of a tree space: depth first, each parent before its children. */\n descendants<U>(body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The siblings axis of a tree space: the other children of the parent, or the other roots for a root. */\n siblings<U>(body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /**\n * The window axis of an array space or a tree space: the keys at the offsets from `from` to `to` of the focus, in\n * order. The offset 0 is the focus. An offset outside the space has no target.\n */\n window<U>(from: number, to: number, body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /**\n * The table axis: the body evaluates at each key of the table `name` of the evaluation, in the space of that table.\n * The body reads the fields of that table, but the types of the chain are the types of this space.\n */\n table<U>(name: string, body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The successors axis of a graph space: the ends of the edges from the focus. In a tree space, the children. */\n successors<U>(body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The predecessors axis of a graph space: the keys with an edge to the focus. In a tree space, the parent. */\n predecessors<U>(body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n /** The reachable axis of a graph space: each key that a path of edges reaches, in breadth-first order. */\n reachable<U>(body: (c: ChainOf<Ctx, T>) => AxisBody<Ctx, U>, opts?: AxisOpts<Ctx, T>): ListChain<Ctx, U>;\n}\n\n/** The options of an axis. */\nexport interface AxisOpts<Ctx extends ChainContext, T> {\n /** A test at each target. The body evaluates only at the targets where the test gives `true`. */\n readonly where?: (c: ChainOf<Ctx, T>) => ChainBase<Ctx, boolean>;\n /** With `true`, the targets come in the reverse order (AXIS.REVERSE). The axis table has no reverse order. */\n readonly reverse?: boolean;\n}\n\n/** A function of the builder in its implementation: the kinds of its parameters, and the function that gives its body. */\ninterface FnDefImpl {\n readonly kind: \"vex.fn\";\n readonly params: readonly string[];\n readonly build: (...params: ChainImpl[]) => { readonly program: Expr };\n}\n\n/** The options of an axis in the implementation of the builder. */\ntype AxisOptsImpl = { readonly where?: (c: ChainImpl) => { readonly program: Expr }; readonly reverse?: boolean };\n\n/** The members of a chain whose value has a domain. */\nexport interface DomainMembers<Ctx extends ChainContext, Dm> {\n /** The ops of the domain of the current value. */\n readonly _: OpsProxy<Ctx, Dm>;\n}\n\n/** The members of a chain over a space whose keys permit `other()`. */\nexport interface OtherMembers<Ctx extends ChainContext, T> {\n /** Navigation: later field references read at the other key of the pair. */\n other(): ChainOf<Ctx, T>;\n}\n\n/** A chain with the current value type `T`. */\nexport type ChainOf<Ctx extends ChainContext, T> = ChainBase<Ctx, T> &\n ([DomainFor<Ctx[\"domains\"], T>] extends [never] ? unknown : DomainMembers<Ctx, DomainFor<Ctx[\"domains\"], T>>) &\n (AllowsOther<Ctx[\"keys\"]> extends true ? OtherMembers<Ctx, T> : unknown);\n\n/** The value type of a chain. */\nexport type ValueOf<C> = C extends { readonly [CHAIN_VALUE]?: infer T } ? T : never;\n\n/** The value type of an argument input. */\nexport type ArgValue<Ctx extends ChainContext, A> = A extends Arg<infer T>\n ? T\n : A extends { readonly kind: \"vex.chain\" }\n ? ValueOf<A>\n : A extends keyof Ctx[\"record\"] & string\n ? NonNullable<Ctx[\"record\"][A]>\n : A;\n\n/** The type of a value of a name of a loop: a literal of `init` gives its primitive type. */\ntype LoopValue<Ctx extends ChainContext, A> = ArgValue<Ctx, A> extends infer T ? (T extends number ? number : T extends string ? string : T extends boolean ? boolean : T) : never;\n\n/** The type of the items of a list chain, or `never` for another value. */\ntype ItemsOf<A> = A extends { readonly kind: \"vex.list-chain\"; readonly [CHAIN_VALUE]?: VexList<infer U> } ? U : never;\n\n/** A value of `init` that is a list chain: then the name of the loop holds a list (LOOP.LIST). */\ntype IsList<A> = A extends { readonly kind: \"vex.list-chain\" } ? true : false;\n\n/**\n * The chain of a name of a loop: a list chain for a list chain of `init` (BUILD.LIST.LOOP), and else a chain of its\n * value.\n */\nexport type LoopVar<Ctx extends ChainContext, A> = IsList<A> extends true ? ListChain<Ctx, ItemsOf<A>> : ChainOf<Ctx, LoopValue<Ctx, A>>;\n\n/** The names of a loop of the builder: a chain of the value of each name of `init` (LOOP.NAMES). */\nexport type LoopVars<Ctx extends ChainContext, I> = { readonly [N in keyof I]: LoopVar<Ctx, I[N]> };\n\n/** The next value of a name of a loop. A name of a list takes a list chain with items of the same type. */\nexport type LoopNext<Ctx extends ChainContext, A> = IsList<A> extends true ? ListChain<Ctx, ItemsOf<A>> : ArgInput<LoopValue<Ctx, A>, Ctx, false>;\n\n/** The next values of a step of a loop: a value for some of the names of `init`. */\nexport type LoopStep<Ctx extends ChainContext, I> = { readonly [N in keyof I]?: LoopNext<Ctx, I[N]> };\n\n/** The kind of a parameter of a function of the builder (BUILD.FN): a primitive type, or `any`. */\nexport type FnParamKind = PrimitiveKind | \"any\";\n\n/** The type of a value of a kind of a parameter. */\nexport type KindValue<K> = K extends \"number\" ? number : K extends \"string\" ? string : K extends \"boolean\" ? boolean : unknown;\n\n/** A chain of each parameter of a function of the builder. */\nexport type ParamChains<Ctx extends ChainContext, P extends readonly FnParamKind[]> = { readonly [I in keyof P]: ChainOf<Ctx, KindValue<P[I]>> };\n\n/** A function of the builder (BUILD.FN): the kinds of its parameters and its body. `functions` binds it. */\nexport interface FnDef<P extends readonly FnParamKind[], R> {\n readonly kind: \"vex.fn\";\n readonly params: P;\n /** This phantom member carries the type of the result. It is not present at run time. */\n readonly [FN_RESULT]?: R;\n}\n\n/** The calls of the functions of `functions`: each gives a chain of a call (FN.CALL). */\nexport type FnCalls<Ctx extends ChainContext, F> = {\n readonly [N in keyof F]: F[N] extends FnDef<infer P, infer R> ? (...args: { readonly [I in keyof P]: ArgInput<KindValue<P[I]>, Ctx, false> }) => ChainOf<Ctx, R> : never;\n};\n\n/**\n * The value of the body of an axis: a chain, or a list chain (BUILD.LIST.BUILD). For a list chain, the value of each\n * item of the axis is a list, so `flat` joins the lists.\n */\nexport type AxisBody<Ctx extends ChainContext, U> = ChainBase<Ctx, U> | ListBody<U>;\n\n/** A list chain as the body of an axis. Its phantom member carries the list. */\nexport interface ListBody<U> {\n readonly kind: \"vex.list-chain\";\n readonly [CHAIN_VALUE]?: U;\n readonly program: Expr;\n}\n\n/** A chain whose value is a list: the result of an axis, of a list op or of a list literal. */\nexport interface ListChain<Ctx extends ChainContext, U> {\n readonly kind: \"vex.list-chain\";\n /** This phantom member carries the type of the list. It is not present at run time. */\n readonly [CHAIN_VALUE]?: VexList<U>;\n /** The expression of the chain, as plain data. */\n readonly program: Expr;\n /**\n * This method folds the items in the order of the axis (FOLD.ORDER). `init` gives the names and their first values.\n * `step` gives the next values from the names and the item, a chain at the target. `result` gives the value. In a\n * fold over the axis `list`, `step` also gets the index of the item (BUILD.LIST.ITEM).\n */\n fold<const I extends Readonly<Record<string, unknown>>, V>(\n init: I,\n step: (vars: LoopVars<Ctx, I>, item: ChainOf<Ctx, U>, index: ChainOf<Ctx, number>) => NoInfer<LoopStep<Ctx, I>>,\n result: (vars: LoopVars<Ctx, I>) => ListChain<Ctx, V>,\n ): ListChain<Ctx, V>;\n fold<const I extends Readonly<Record<string, unknown>>, R>(\n init: I,\n step: (vars: LoopVars<Ctx, I>, item: ChainOf<Ctx, U>, index: ChainOf<Ctx, number>) => NoInfer<LoopStep<Ctx, I>>,\n result: (vars: LoopVars<Ctx, I>) => ArgInput<R, Ctx, false>,\n ): ChainOf<Ctx, R>;\n count(opts?: ListOpts): ChainOf<Ctx, number>;\n sum(this: ListChain<Ctx, number>, opts?: ListOpts): ChainOf<Ctx, number>;\n mean(this: ListChain<Ctx, number>, opts?: ListOpts): ChainOf<Ctx, number>;\n min(this: ListChain<Ctx, number>, opts?: ListOpts): ChainOf<Ctx, number>;\n max(this: ListChain<Ctx, number>, opts?: ListOpts): ChainOf<Ctx, number>;\n any(this: ListChain<Ctx, boolean>, opts?: ListOpts): ChainOf<Ctx, boolean>;\n all(this: ListChain<Ctx, boolean>, opts?: ListOpts): ChainOf<Ctx, boolean>;\n none(this: ListChain<Ctx, boolean>, opts?: ListOpts): ChainOf<Ctx, boolean>;\n values(opts?: ListOpts): ChainOf<Ctx, readonly U[]>;\n /** The keys of the items with a value, in the order of the axis. */\n keys(opts?: ListOpts): ChainOf<Ctx, readonly Ctx[\"keys\"][]>;\n /** The error of each item that failed, in the order of the axis. */\n errors(): ChainOf<Ctx, readonly VexError[]>;\n first(opts?: ListOpts): ChainOf<Ctx, U>;\n reduce(op: OpNames<DomainFor<Ctx[\"domains\"], U>>, opts?: ReduceOpts<Ctx>): ChainOf<Ctx, U>;\n /** The items in the order of their values, from the smallest (LIST.SORT). The values are numbers or texts of one kind. */\n sortBy(opts?: ListOpts): ListChain<Ctx, U>;\n /** The first `n` items (LIST.TAKE). */\n take(n: number, opts?: ListOpts): ListChain<Ctx, U>;\n /** The value of the item at the position `i`, from 0 (LIST.NTH). */\n nth(i: number, opts?: ListOpts): ChainOf<Ctx, U>;\n /**\n * This list with `value` as the value of the item at the position `i`, from 0 (LIST.SETNTH). The item keeps its key.\n * A chain or `lit` gives the value, and a chain can give the position. Both evaluate at the focus.\n */\n setNth<V>(i: number | ChainBase<Ctx, number>, value: ChainBase<Ctx, V> | Arg<V>, opts?: ListOpts): ListChain<Ctx, U | V>;\n /**\n * The value of the first item with the key `k` (LIST.GET). A chain of a text gives the key, and it evaluates at the\n * focus. A key that no item has gives `#N/A`. Thus a step reads the old value of each key.\n */\n get(k: Ctx[\"keys\"] | ChainBase<Ctx, string>, opts?: ListOpts): ChainOf<Ctx, U>;\n /** The items after the first `n` items (LIST.DROP). Thus `drop(1)` removes the first item of a stack. */\n drop(n: number, opts?: ListOpts): ListChain<Ctx, U>;\n /** The items of this list, and then the items of `other` (LIST.APPEND). Two items can have the same key. */\n append<V>(other: ListChain<Ctx, V>, opts?: ListOpts): ListChain<Ctx, U | V>;\n /** The items of this list whose key is not the key of an item of `other` (LIST.WITHOUT). */\n without<V>(other: ListChain<Ctx, V>, opts?: ListOpts): ListChain<Ctx, U>;\n /** The items of the lists that are the values of the items, in order (LIST.FLAT). The values must be lists. */\n flat<V>(this: ListChain<Ctx, VexList<V>>, opts?: ListOpts): ListChain<Ctx, V>;\n /** The first item of each value, in the order of the list (LIST.DISTINCT). The values are numbers, texts or booleans. */\n distinct(opts?: ListOpts): ListChain<Ctx, U>;\n /**\n * The groups of the items by the text keys of `keys` (LIST.GROUP). The key at a position is the key of the item at\n * the same position. Each key gives one item, and its value is the list of its items (BUILD.LIST.GROUP).\n */\n group(keys: ListChain<Ctx, string>, opts?: ListOpts): ListChain<Ctx, VexList<U>>;\n /** The texts of the items with the text `sep` between them (LIST.JOIN). A chain of a text gives the separator. */\n join(this: ListChain<Ctx, string>, sep: string | ChainBase<Ctx, string>, opts?: ListOpts): ChainOf<Ctx, string>;\n /**\n * The axis list (AXIS.LIST): the body evaluates at the key of each item, in the order of the list. The body reads the\n * fields of the record of the item. The chain of the body has no value of its own. The body also gets a chain of the\n * value of the item and a chain of its index, from 0 (BUILD.LIST.ITEM).\n */\n each<V>(body: (c: ChainOf<Ctx, null>, item: ChainOf<Ctx, U>, index: ChainOf<Ctx, number>) => AxisBody<Ctx, V>, opts?: AxisOpts<Ctx, null>): ListChain<Ctx, V>;\n /** The list at the origin `k`: one item for each target of the axis, with its key and its result. */\n result(k: Ctx[\"keys\"]): Result<VexList<U>>;\n /** The list at the origin `k`, as an `Optional`. */\n at(k: Ctx[\"keys\"]): Optional<VexList<U>>;\n /** The trace of the evaluation of the list at the origin `k`. */\n explain(k: Ctx[\"keys\"]): Trace;\n}\n\n/** The options of a list reduction. */\nexport interface ListOpts {\n /** With `true`, an error item makes the result that error. The default skips error items. */\n readonly strict?: boolean;\n}\n\n/** The options of `reduce`. `domain` names the domain whose identity an empty list gives (LIST.EMPTY). */\nexport interface ReduceOpts<Ctx extends ChainContext> extends ListOpts {\n readonly domain?: Ctx[\"domains\"][number][\"name\"];\n}\n\n/** The root of the builder for one space. */\nexport interface Root<Ctx extends ChainContext> {\n /** This method starts a chain with a field of the record at the focus. */\n from<P extends keyof Ctx[\"record\"] & string>(field: P): ChainOf<Ctx, NonNullable<Ctx[\"record\"][P]>>;\n /** This method starts a chain with a value. A string is a field reference, as in an argument. */\n start<const T>(value: T): ChainOf<Ctx, ArgValue<Ctx, T>>;\n /** This method makes an absolute reference: the field of the record at key `k`. */\n of<P extends keyof Ctx[\"record\"] & string>(k: Ctx[\"keys\"], field: P): Arg<NonNullable<Ctx[\"record\"][P]>>;\n /** This method makes a reference to a dotted path at the focus, with the type that the caller gives. */\n field<T>(path: string): Arg<T>;\n /** This method makes a literal argument. Use it for a string or an array: a bare string is a field reference. */\n lit<const T>(value: T): Arg<T>;\n /** This method makes an absolute reference to a dotted path at key `k`, with the type that the caller gives. */\n ofPath<T>(k: Ctx[\"keys\"], path: string): Arg<T>;\n /** This method makes a record argument from field arguments. */\n rec<const F extends Readonly<Record<string, unknown>>>(fields: F): Arg<{ readonly [N in keyof F]: ArgValue<Ctx, F[N]> }>;\n /**\n * This method makes a list literal (LIST.LITERAL, BUILD.LIST.LOOP): an item for each pair of a key and a value, in\n * order. Without pairs, it gives the empty list. Thus a loop can start a stack or a seen set.\n */\n list<U = unknown>(items?: readonly (readonly [Ctx[\"keys\"], U])[]): ListChain<Ctx, U>;\n /**\n * This method makes an extension argument: the node `ext(kind, data)`. The handler of `kind` in the options of\n * `withOptions` gives its value. The caller gives the type `T` of that value.\n */\n ext<T>(kind: string, data?: unknown): Arg<T>;\n /** This method starts a sheet over the space: named columns of formulas. Refer to `Sheet`. */\n sheet(): Sheet<Ctx, object>;\n /**\n * This method makes a function (BUILD.FN) with the kinds of its parameters. The body gets a chain of each parameter,\n * and it evaluates at the focus of each call. The method `functions` of a chain binds the function.\n */\n fn<const P extends readonly FnParamKind[], R>(params: P, body: (...params: ParamChains<Ctx, P>) => ChainBase<Ctx, R>): FnDef<P, R>;\n /** The space of the root. */\n readonly space: Space<Ctx[\"keys\"], Ctx[\"record\"]>;\n}\n\n/** The root of a column formula: the root of the builder, and references to the cells of the sheet. */\nexport interface SheetRoot<Ctx extends ChainContext, Cols> extends Root<Ctx> {\n /**\n * This method reads a cell: the column `column` at the key `at`, or at the address `at` from the focus. The address\n * can have computed moves (SHEET.CELL.COMPUTED). Without `at`, it reads at the focus. The type is the type of a column\n * before this one.\n */\n cell<N extends keyof Cols & string>(column: N, at?: Ctx[\"keys\"] | Addr): Arg<Cols[N]>;\n /** This method makes a cell reference to any column, also this column or a later one. The caller gives the type. */\n cell<T>(column: string, at?: Ctx[\"keys\"] | Addr): Arg<T>;\n}\n\n/** One row of a sheet: the key and the result of each column. */\nexport interface SheetRow<K extends string, Cols> {\n readonly key: K;\n readonly cells: { readonly [N in keyof Cols]: Result<Cols[N]> };\n}\n\n/**\n * A sheet: named columns of formulas over a space, like the computed columns of a spreadsheet. A formula reads the\n * other columns with `cell`. Each evaluation evaluates a cell once, and each cell on a cycle of references gives\n * `#CYCLE!`. A sheet is immutable: `column` gives a new sheet.\n */\nexport interface Sheet<Ctx extends ChainContext, Cols, Decl = object> {\n /**\n * This method gives a new sheet with one more column. The formula gets a root with `cell`. If `declare` gave the\n * column a type, the formula must give a value of that type.\n */\n column<const N extends string, C extends ChainBase<Ctx, DeclaredType<Decl, N>>>(\n name: N,\n formula: (r: SheetRoot<Ctx, Cols & Decl>) => C,\n ): Sheet<Ctx, Cols & { readonly [P in N]: ValueOf<C> }, Decl>;\n /**\n * This method gives the types of columns before their formulas. A formula can then read a declared column with\n * `cell` and its type: the column itself (a recurrence) or a later column. It has no effect at run time.\n */\n declare<D extends Readonly<Record<string, unknown>>>(): Sheet<Ctx, Cols, Decl & D>;\n /**\n * This method gives a new sheet in which the cell of the column `column` at the key `k` has its own formula. That\n * formula replaces the formula of the column at the key `k`. It must give a value of the type of the column.\n */\n cellFormula<const N extends keyof (Cols & Decl) & string>(\n k: Ctx[\"keys\"],\n column: N,\n formula: (r: SheetRoot<Ctx, Cols & Decl>) => ChainBase<Ctx, (Cols & Decl)[N]>,\n ): Sheet<Ctx, Cols, Decl>;\n /** The program of each column. */\n readonly columns: Readonly<Record<string, Expr>>;\n /** The program of each cell with its own formula, by column and then by key. */\n readonly cellFormulas: Readonly<Record<string, Readonly<Record<string, Expr>>>>;\n /** This method evaluates one cell, and gives the error if there is one. */\n result<N extends keyof Cols & string>(k: Ctx[\"keys\"], column: N): Result<Cols[N]>;\n /** This method evaluates one cell. An error gives `none`. */\n at<N extends keyof Cols & string>(k: Ctx[\"keys\"], column: N): Optional<Cols[N]>;\n /** This method evaluates one cell, with a trace of the nodes of its column. */\n explain(k: Ctx[\"keys\"], column: keyof Cols & string): Trace;\n /** This method evaluates each cell, in key order, with one result for each cell. */\n table(): readonly SheetRow<Ctx[\"keys\"], Cols>[];\n}\n\n/** The declared type of the column `N`, or `unknown` for a column without a declaration. */\nexport type DeclaredType<Decl, N extends string> = N extends keyof Decl ? Decl[N] : unknown;\n\n/** The options of the builder. */\nexport interface VexOptions<F extends FnTable = FnTable> {\n /** Free function ops. A chain applies them with `call`. */\n readonly fns?: F;\n /** Handlers of extension expression kinds. */\n readonly extensions?: Readonly<Record<string, ExtHandler>>;\n}\n\n/** The entry point for a list of domains. */\nexport interface VexEntry<Dms extends readonly AnyDomain[], F extends FnTable = NoFns> {\n /** This method gives the root of the builder for a space. */\n over<K extends string, O>(s: Space<K, O>): Root<{ readonly domains: Dms; readonly keys: K; readonly record: Merge<O>; readonly fns: F }>;\n /** The domains. */\n readonly domains: Dms;\n}\n\n// ---------------------------------------------------------------- run time\n\n/** The options as the interpreter takes them: free functions get untyped arguments at run time. */\ninterface RuntimeOptions {\n readonly fns?: Readonly<Record<string, FreeFn>>;\n readonly extensions?: Readonly<Record<string, ExtHandler>>;\n}\n\n/** This function gives the run-time form of the options. A typed free function gets the values that the types promise. */\nconst runtimeOptions = (options: VexOptions): RuntimeOptions => ({\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(options.fns === undefined ? {} : { fns: options.fns as Readonly<Record<string, FreeFn>> }),\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(options.extensions === undefined ? {} : { extensions: options.extensions }),\n});\n\ninterface Env {\n readonly space: Space;\n readonly domains: readonly AnyDomain[];\n readonly options: RuntimeOptions;\n}\n\ninterface State {\n readonly env: Env;\n /** The current value. */\n readonly expr: Expr;\n /** The address where later field references read. */\n readonly addr: readonly Move[];\n /** The depth of nested axis and binding bodies, for unique variable names. */\n readonly depth: number;\n}\n\nconst kindOf = (u: unknown): unknown => (u as { kind?: unknown } | null | undefined)?.kind;\nconst isArg = (u: unknown): u is Arg<unknown> => kindOf(u) === \"vex.arg\";\nconst isChainLike = (u: unknown): u is { readonly program: Expr } => kindOf(u) === \"vex.chain\" || kindOf(u) === \"vex.list-chain\";\n\n/** This function gives the expression of the list of `append` and `without`. The list is a chain, not a literal. */\nfunction listProgram(op: string, other: unknown): Expr {\n if (!isChainLike(other)) throw new TypeError(`${op} needs a list chain`);\n return other.program;\n}\n\n/** This function turns a builder argument into an expression. A bare string is a field reference at `addr`. */\nfunction toExpr(a: unknown, addr: readonly Move[]): Expr {\n if (typeof a === \"string\") return ref(toPath(a), addr);\n if (isArg(a)) return a.expr;\n if (isChainLike(a)) return a.program;\n return lit(a);\n}\n\n/** This function gives the expressions of a step of a loop, with the unique names of the loop. */\nfunction stepExprs(step: Readonly<Record<string, unknown>>, unique: ReadonlyMap<string, string>, addr: readonly Move[]): Readonly<Record<string, Expr>> {\n const out: Record<string, Expr> = {};\n for (const [n, a] of Object.entries(step)) {\n const name = unique.get(n);\n if (name === undefined) throw new TypeError(`the name \"${n}\" of the step is not a name of init`);\n out[name] = toExpr(a, addr);\n }\n return out;\n}\n\n/**\n * The number of the open bodies of `each` and steps of `fold` of a list chain. The names `as` of a loop end with this\n * number, so a loop inside a body has other names than the loop around it (BUILD.LIST.ITEM).\n */\nlet itemDepth = 0;\n\n/** This function gives the value of `build`, with the next number for the names `as` inside it. */\nfunction inItemLoop<T>(build: () => T): T {\n itemDepth += 1;\n try {\n return build();\n } finally {\n itemDepth -= 1;\n }\n}\n\n/**\n * The number of the open steps of `fix`. The name of a column ends with this number. Thus an inner `fix` does not hide\n * the column around it, also when the chain of the inner `fix` starts at the root (BUILD.FIX).\n */\nlet fixDepth = 0;\n\n/** This function gives the value of `build`, with the next number for the columns inside it. */\nfunction inFixStep<T>(build: () => T): T {\n fixDepth += 1;\n try {\n return build();\n } finally {\n fixDepth -= 1;\n }\n}\n\n/**\n * This function tells if the expression reads the name, in one of its parts. It uses a stack, not recursion. An `each`\n * or a `fold` can have the name in its item names (`as`). Then it binds the name again for its body or its step, and\n * those parts do not count (V-065). A chain made at the same depth of the loops has the same names, so a fold can hold such a chain in its step.\n */\nfunction reads(e: Expr, name: string): boolean {\n const todo: Expr[] = [e];\n for (let x = todo.pop(); x !== undefined; x = todo.pop()) {\n if (x.tag === \"var\" && x.name === name) return true;\n if (x.tag === \"each\" && x.as?.includes(name) === true) todo.push(...axisExprs(x.axis), ...addrExprs(x.at));\n else if (x.tag === \"fold\" && x.as?.includes(name) === true) todo.push(...Object.values(x.init), ...axisExprs(x.axis), ...addrExprs(x.at), x.result);\n else todo.push(...children(x));\n }\n return false;\n}\n\n/**\n * This function gives the names `as` of a fold whose step reads the index. The axis must be `list`. The name of the item\n * of the loop of `each` stays, so the item of the step keeps its value (BUILD.LIST.ITEM).\n */\nfunction foldItemNames(loop: { readonly axis: Axis; readonly as?: ItemNames }, index: string): ItemNames {\n if (listOf(loop.axis) === undefined) throw new TypeError(\"the index of a fold needs the axis list: go over the items of a list with each first\");\n return [loop.as?.[0] ?? `$item${itemDepth}`, index];\n}\n\nconst PROXY_RESERVED = new Set([\"then\", \"catch\", \"finally\", \"toJSON\", \"valueOf\", \"toString\", \"constructor\", \"inspect\", \"asymmetricMatch\", \"$$typeof\", \"nodeType\"]);\n\nclass ChainImpl {\n readonly kind = \"vex.chain\" as const;\n readonly #s: State;\n\n constructor(s: State) {\n this.#s = s;\n }\n\n get program(): Expr {\n return this.#s.expr;\n }\n\n get _(): Readonly<Record<string, (...args: readonly unknown[]) => ChainImpl>> {\n const s = this.#s;\n return new Proxy(Object.create(null) as Record<string, never>, {\n get: (_t, prop): unknown => {\n if (typeof prop !== \"string\" || PROXY_RESERVED.has(prop)) return undefined;\n return (...args: readonly unknown[]): ChainImpl => new ChainImpl({ ...s, expr: app(prop, s.expr, ...args.map((a) => toExpr(a, s.addr))) });\n },\n });\n }\n\n #opts(k: string): EvalOptions {\n return evalOptions(this.#s, k);\n }\n\n result(k: string): Result<unknown> {\n return evaluate(this.#s.expr, this.#opts(k));\n }\n at(k: string): Optional<unknown> {\n return toOptional(this.result(k));\n }\n value(k: string): Optional<unknown> {\n return this.at(k);\n }\n explain(k: string): Trace {\n return explain(this.#s.expr, this.#opts(k));\n }\n all(): Traversal<string, unknown> {\n const { env } = this.#s;\n const items = env.space.keys.map((k) => ({ key: k, result: this.result(k) }));\n return traversal(items, env);\n }\n\n from(field: string): ChainImpl {\n return new ChainImpl({ ...this.#s, expr: ref(toPath(field), this.#s.addr) });\n }\n\n #move(m: Move): ChainImpl {\n return new ChainImpl({ ...this.#s, addr: [...this.#s.addr, m] });\n }\n to(k: string | { readonly program: Expr }): ChainImpl {\n return this.#move(keyMove(typeof k === \"string\" ? k : k.program));\n }\n index(i: number | { readonly program: Expr }): ChainImpl {\n return this.#move(indexMove(typeof i === \"number\" ? i : i.program));\n }\n offset(...d: readonly number[]): ChainImpl {\n return this.#move(offsetMove(...d));\n }\n other(): ChainImpl {\n return this.#move(otherMove);\n }\n origin(): ChainImpl {\n return this.#move(originMove);\n }\n parent(): ChainImpl {\n return this.#move(parentMove);\n }\n\n call(name: string, ...args: readonly unknown[]): ChainImpl {\n return new ChainImpl({ ...this.#s, expr: app(name, this.#s.expr, ...args.map((a) => toExpr(a, this.#s.addr))) });\n }\n if(then: unknown, otherwise: unknown): ChainImpl {\n return new ChainImpl({ ...this.#s, expr: app(\"if\", this.#s.expr, toExpr(then, this.#s.addr), toExpr(otherwise, this.#s.addr)) });\n }\n ifError(fallback: unknown): ChainImpl {\n return new ChainImpl({ ...this.#s, expr: app(\"ifError\", this.#s.expr, toExpr(fallback, this.#s.addr)) });\n }\n\n /** This method binds the current value to a fresh name, and gives a chain that starts from that name. */\n #bound(): { readonly name: string; readonly start: ChainImpl } {\n const name = `$${this.#s.depth}`;\n return { name, start: new ChainImpl({ ...this.#s, expr: v(name), depth: this.#s.depth + 1 }) };\n }\n\n fork(branches: Readonly<Record<string, (c: ChainImpl) => { readonly program: Expr }>>): ChainImpl {\n const { name, start } = this.#bound();\n // Object.fromEntries gives an own field for each name, also for \"__proto__\" (V-062).\n const fields = Object.fromEntries(Object.entries(branches).map(([n, f]) => [n, f(start).program]));\n return new ChainImpl({ ...this.#s, expr: let_({ [name]: this.#s.expr }, rec(fields)) });\n }\n\n with(binds: Readonly<Record<string, unknown>>, body: (c: ChainImpl, vars: Readonly<Record<string, Arg<unknown>>>) => { readonly program: Expr }): ChainImpl {\n const depth = this.#s.depth;\n const bindExprs: Record<string, Expr> = {};\n const vars: Record<string, Arg<unknown>> = {};\n for (const [n, a] of Object.entries(binds)) {\n const unique = `${n}$${depth}`;\n bindExprs[unique] = toExpr(a, this.#s.addr);\n vars[n] = argToken(v(unique));\n }\n const inner = body(new ChainImpl({ ...this.#s, depth: depth + 1 }), vars);\n return new ChainImpl({ ...this.#s, expr: let_(bindExprs, inner.program) });\n }\n\n functions(fns: Readonly<Record<string, FnDefImpl>>, body: (c: ChainImpl, call: Readonly<Record<string, (...args: readonly unknown[]) => ChainImpl>>) => { readonly program: Expr }): ChainImpl {\n const depth = this.#s.depth;\n const binds: Record<string, Expr> = {};\n const calls: Record<string, (...args: readonly unknown[]) => ChainImpl> = {};\n for (const [n, def] of Object.entries(fns)) {\n if ((def as { readonly kind?: unknown }).kind !== \"vex.fn\") throw new TypeError(`the function \"${n}\" is not a function of root.fn`);\n const unique = `${n}$${depth}`;\n const params = def.params.map((_k, i) => `${unique}$${i}`);\n // A parameter is a chain at the focus of the call, so a field of the body reads at the call.\n const chains = params.map((p) => new ChainImpl({ ...this.#s, expr: v(p), addr: [], depth: depth + 1 }));\n binds[unique] = fnExpr(params, def.build(...chains).program);\n calls[n] = (...args) => new ChainImpl({ ...this.#s, expr: callExpr(unique, ...args.map((a) => toExpr(a, []))), addr: [], depth: depth + 1 });\n }\n const inner = body(new ChainImpl({ ...this.#s, depth: depth + 1 }), calls);\n return new ChainImpl({ ...this.#s, expr: let_(binds, inner.program) });\n }\n\n /**\n * This method gives the names of a loop. Each name of `init` gets a name that is unique at the depth of the chain.\n * It also gets its first value at the address of the chain, and a chain of its value.\n */\n loopNames(init: Readonly<Record<string, unknown>>): { readonly unique: ReadonlyMap<string, string>; readonly first: Readonly<Record<string, Expr>>; readonly vars: Readonly<Record<string, ChainImpl | ListChainImpl>> } {\n const depth = this.#s.depth;\n const unique = new Map<string, string>();\n const first: Record<string, Expr> = {};\n const vars: Record<string, ChainImpl | ListChainImpl> = {};\n for (const [n, a] of Object.entries(init)) {\n const name = `${n}$${depth}`;\n unique.set(n, name);\n first[name] = toExpr(a, this.#s.addr);\n // A name of a list is a list chain, so a step can use the list ops on it (BUILD.LIST.LOOP).\n const s: State = { ...this.#s, expr: v(name), addr: [], depth: depth + 1 };\n vars[n] = kindOf(a) === \"vex.list-chain\" ? new ListChainImpl(s) : new ChainImpl(s);\n }\n return { unique, first, vars };\n }\n\n iterate(\n limit: number | DataLimit | ListChainImpl,\n init: Readonly<Record<string, unknown>>,\n step: (vars: Readonly<Record<string, ChainImpl | ListChainImpl>>) => Readonly<Record<string, unknown>>,\n result: (vars: Readonly<Record<string, ChainImpl | ListChainImpl>>) => unknown,\n opts?: { readonly until?: (vars: Readonly<Record<string, ChainImpl | ListChainImpl>>) => unknown },\n ): ChainImpl | ListChainImpl {\n const { unique, first, vars } = this.loopNames(init);\n const next = stepExprs(step(vars), unique, this.#s.addr);\n const until = opts?.until === undefined ? undefined : toExpr(opts.until(vars), this.#s.addr);\n const r = result(vars);\n // The list of a limit reads the names outside the iteration, so the chain of the limit comes first (ITERATE.LIMIT.DATA).\n const bound = isChainLike(limit) ? dataLimit({ t: \"list\", list: toExpr(limit, this.#s.addr) }) : limit;\n return chainOf({ ...this.#s, expr: iterateExpr(bound, first, next, toExpr(r, this.#s.addr), until) }, r);\n }\n\n fix(name: string, join: FixJoin, init: unknown, step: (last: ChainImpl) => unknown): ChainImpl {\n const { addr, depth } = this.#s;\n const column = `${name}$${String(fixDepth)}`;\n // The read has no address, and an axis moves the focus of the read (FIX.LAST).\n const read = new ChainImpl({ ...this.#s, expr: lastExpr(column), addr: [], depth: depth + 1 });\n const next = inFixStep(() => toExpr(step(read), addr));\n return new ChainImpl({ ...this.#s, expr: fixExpr(column, join, toExpr(init, addr), next) });\n }\n\n #axis(a: Axis, body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n const { name, start } = this.#bound();\n // Inside the axis, the focus is the target, so the address of the body starts empty.\n const inTarget = new ChainImpl({ ...start.#s, addr: [] });\n const inner = body(inTarget);\n const ordered: Axis = opts?.reverse === true ? { t: \"reverse\", axis: a } : a;\n const axis: Axis = opts?.where === undefined ? ordered : { t: \"where\", axis: ordered, test: opts.where(inTarget).program };\n // The moves before the axis are its address: parent().children(f) gives f at each child of the parent.\n return new ListChainImpl({ ...this.#s, expr: let_({ [name]: this.#s.expr }, each(axis, inner.program, this.#s.addr)) });\n }\n others(body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"others\" }, body, opts);\n }\n neighbors(n: 4 | 8, body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"neighbors\", n }, body, opts);\n }\n each(body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"all\" }, body, opts);\n }\n children(body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"children\" }, body, opts);\n }\n ancestors(body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"ancestors\" }, body, opts);\n }\n descendants(body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"descendants\" }, body, opts);\n }\n siblings(body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"siblings\" }, body, opts);\n }\n window(from: number, to: number, body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"window\", from, to }, body, opts);\n }\n table(name: string, body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"table\", name }, body, opts);\n }\n successors(body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"successors\" }, body, opts);\n }\n predecessors(body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"predecessors\" }, body, opts);\n }\n reachable(body: (c: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n return this.#axis({ t: \"reachable\" }, body, opts);\n }\n}\n\n/** This function gives the chain of a loop: a list chain when its result is a list chain (BUILD.LIST.LOOP). */\nconst chainOf = (s: State, result: unknown): ChainImpl | ListChainImpl => (kindOf(result) === \"vex.list-chain\" ? new ListChainImpl(s) : new ChainImpl(s));\n\n/** This function gives the options of an evaluation of a chain or a list chain at the origin `k`. */\nfunction evalOptions(s: State, k: string): EvalOptions {\n const { env } = s;\n return {\n space: env.space,\n origin: k,\n domains: env.domains,\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(env.options.fns === undefined ? {} : { fns: env.options.fns }),\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(env.options.extensions === undefined ? {} : { extensions: env.options.extensions }),\n };\n}\n\nclass ListChainImpl {\n readonly kind = \"vex.list-chain\" as const;\n readonly #s: State;\n constructor(s: State) {\n this.#s = s;\n }\n get program(): Expr {\n return this.#s.expr;\n }\n fold(\n init: Readonly<Record<string, unknown>>,\n step: (vars: Readonly<Record<string, ChainImpl | ListChainImpl>>, item: ChainImpl, index: ChainImpl) => Readonly<Record<string, unknown>>,\n result: (vars: Readonly<Record<string, ChainImpl | ListChainImpl>>) => unknown,\n ): ChainImpl | ListChainImpl {\n // The list of an axis is a let of the start value around the axis, and the list of `each` of a list is the axis\n // alone. The fold keeps the let, and the body of the axis is the item of each step.\n const e = this.#s.expr;\n const loop = e.tag === \"let\" ? e.body : e;\n if (loop.tag !== \"each\") throw new TypeError(\"fold needs the list of an axis: go over the items of the list with each first\");\n const names = new ChainImpl({ ...this.#s, expr: lit(null) }).loopNames(init);\n const item = new ChainImpl({ ...this.#s, expr: loop.body, addr: [] });\n // The names as of the loop of each stay. A step that reads the index adds a name for it (BUILD.LIST.ITEM).\n const index = loop.as?.[1] ?? `$index${itemDepth}`;\n const next = stepExprs(inItemLoop(() => step(names.vars, item, new ChainImpl({ ...this.#s, expr: v(index), addr: [] }))), names.unique, []);\n const as = Object.values(next).some((x) => reads(x, index)) ? foldItemNames(loop, index) : loop.as;\n const r = result(names.vars);\n const folded = foldExpr(loop.axis, names.first, next, toExpr(r, this.#s.addr), loop.at, as);\n return chainOf({ ...this.#s, expr: e.tag === \"let\" ? let_(e.bind, folded) : folded }, r);\n }\n\n #op(op: string, extra: readonly Expr[], opts?: ListOpts & { readonly domain?: string }): ChainImpl {\n const options = { ...(opts?.strict === true ? { strict: true } : {}), ...(opts?.domain === undefined ? {} : { domain: opts.domain }) };\n const args = Object.keys(options).length > 0 ? [...extra, lit(options)] : extra;\n return new ChainImpl({ ...this.#s, expr: app(op, this.#s.expr, ...args) });\n }\n count(opts?: ListOpts): ChainImpl {\n return this.#op(\"count\", [], opts);\n }\n sum(opts?: ListOpts): ChainImpl {\n return this.#op(\"sum\", [], opts);\n }\n mean(opts?: ListOpts): ChainImpl {\n return this.#op(\"mean\", [], opts);\n }\n min(opts?: ListOpts): ChainImpl {\n return this.#op(\"min\", [], opts);\n }\n max(opts?: ListOpts): ChainImpl {\n return this.#op(\"max\", [], opts);\n }\n any(opts?: ListOpts): ChainImpl {\n return this.#op(\"any\", [], opts);\n }\n all(opts?: ListOpts): ChainImpl {\n return this.#op(\"all\", [], opts);\n }\n none(opts?: ListOpts): ChainImpl {\n return this.#op(\"none\", [], opts);\n }\n values(opts?: ListOpts): ChainImpl {\n return this.#op(\"values\", [], opts);\n }\n keys(opts?: ListOpts): ChainImpl {\n return this.#op(\"keys\", [], opts);\n }\n errors(): ChainImpl {\n return this.#op(\"errors\", []);\n }\n first(opts?: ListOpts): ChainImpl {\n return this.#op(\"first\", [], opts);\n }\n reduce(op: string, opts?: ListOpts & { readonly domain?: string }): ChainImpl {\n return this.#op(\"reduce\", [lit(op)], opts);\n }\n #list(op: string, extra: readonly Expr[], opts?: ListOpts): ListChainImpl {\n return new ListChainImpl({ ...this.#s, expr: this.#op(op, extra, opts).program });\n }\n sortBy(opts?: ListOpts): ListChainImpl {\n return this.#list(\"sortBy\", [], opts);\n }\n take(n: number, opts?: ListOpts): ListChainImpl {\n return this.#list(\"take\", [lit(n)], opts);\n }\n nth(i: number, opts?: ListOpts): ChainImpl {\n return this.#op(\"nth\", [lit(i)], opts);\n }\n setNth(i: number | { readonly program: Expr }, value: unknown, opts?: ListOpts): ListChainImpl {\n return this.#list(\"setNth\", [typeof i === \"number\" ? lit(i) : i.program, toExpr(value, this.#s.addr)], opts);\n }\n get(k: string | { readonly program: Expr }, opts?: ListOpts): ChainImpl {\n // A text is a key, not a field reference, as for the move to(k).\n return this.#op(\"get\", [typeof k === \"string\" ? lit(k) : k.program], opts);\n }\n drop(n: number, opts?: ListOpts): ListChainImpl {\n return this.#list(\"drop\", [lit(n)], opts);\n }\n append(other: unknown, opts?: ListOpts): ListChainImpl {\n return this.#list(\"append\", [listProgram(\"append\", other)], opts);\n }\n without(other: unknown, opts?: ListOpts): ListChainImpl {\n return this.#list(\"without\", [listProgram(\"without\", other)], opts);\n }\n flat(opts?: ListOpts): ListChainImpl {\n return this.#list(\"flat\", [], opts);\n }\n distinct(opts?: ListOpts): ListChainImpl {\n return this.#list(\"distinct\", [], opts);\n }\n group(keys: unknown, opts?: ListOpts): ListChainImpl {\n return this.#list(\"group\", [listProgram(\"group\", keys)], opts);\n }\n join(sep: string | { readonly program: Expr }, opts?: ListOpts): ChainImpl {\n return this.#op(\"join\", [typeof sep === \"string\" ? lit(sep) : sep.program], opts);\n }\n each(body: (c: ChainImpl, item: ChainImpl, index: ChainImpl) => { readonly program: Expr }, opts?: AxisOptsImpl): ListChainImpl {\n // The chains of the body are at the key of the item. The chain of the body has no value of its own.\n const inner: State = { ...this.#s, addr: [], depth: this.#s.depth + 1 };\n const start = new ChainImpl({ ...inner, expr: lit(null) });\n const list: Axis = { t: \"list\", list: this.#s.expr };\n const ordered: Axis = opts?.reverse === true ? { t: \"reverse\", axis: list } : list;\n const axis: Axis = opts?.where === undefined ? ordered : { t: \"where\", axis: ordered, test: opts.where(start).program };\n const names = [`$item${itemDepth}`, `$index${itemDepth}`] as const;\n const program = inItemLoop(() => body(start, new ChainImpl({ ...inner, expr: v(names[0]) }), new ChainImpl({ ...inner, expr: v(names[1]) })).program);\n // BUILD.LIST.ITEM: the field as has only the names that the body reads.\n const as: ItemNames | undefined = reads(program, names[1]) ? names : reads(program, names[0]) ? [names[0]] : undefined;\n return new ListChainImpl({ ...this.#s, expr: each(axis, program, undefined, as) });\n }\n result(k: string): Result<unknown> {\n return evaluate(this.#s.expr, evalOptions(this.#s, k));\n }\n at(k: string): Optional<unknown> {\n return toOptional(this.result(k));\n }\n explain(k: string): Trace {\n return explain(this.#s.expr, evalOptions(this.#s, k));\n }\n}\n\nclass RootImpl {\n readonly #env: Env;\n constructor(env: Env) {\n this.#env = env;\n }\n get space(): Space {\n return this.#env.space;\n }\n #chain(expr: Expr): ChainImpl {\n return new ChainImpl({ env: this.#env, expr, addr: [], depth: 0 });\n }\n from(field: string): ChainImpl {\n return this.#chain(ref(toPath(field)));\n }\n start(value: unknown): ChainImpl {\n return this.#chain(toExpr(value, []));\n }\n of(k: string, field: string): Arg<unknown> {\n return argToken(ref(toPath(field), [keyMove(k)]));\n }\n field(path: string): Arg<unknown> {\n return argToken(ref(toPath(path)));\n }\n lit(value: unknown): Arg<unknown> {\n return argToken(lit(value));\n }\n ofPath(k: string, path: string): Arg<unknown> {\n return argToken(ref(toPath(path), [keyMove(k)]));\n }\n ext(kind: string, data: unknown = null): Arg<unknown> {\n return argToken(ext(kind, data));\n }\n sheet(): SheetImpl {\n return new SheetImpl(this.#env, new Map());\n }\n fn(params: readonly string[], build: (...params: ChainImpl[]) => { readonly program: Expr }): FnDefImpl {\n return { kind: \"vex.fn\", params, build };\n }\n rec(fields: Readonly<Record<string, unknown>>): Arg<unknown> {\n return argToken(rec(Object.fromEntries(Object.entries(fields).map(([n, a]) => [n, toExpr(a, [])]))));\n }\n list(items: readonly (readonly [string, unknown])[] = []): ListChainImpl {\n // LIST.LITERAL: a literal of the list, with a value for each item.\n return new ListChainImpl({ env: this.#env, expr: lit(vexList(items.map(([key, value]) => ({ key, result: ok(value) })))), addr: [], depth: 0 });\n }\n}\n\nclass SheetRootImpl extends RootImpl {\n cell(column: string, at?: string | Addr): Arg<unknown> {\n return argToken(cellRef(column, typeof at === \"string\" ? [keyMove(at)] : at));\n }\n}\n\nclass SheetImpl {\n readonly #env: Env;\n readonly #columns: ReadonlyMap<string, Expr>;\n readonly #cells: CellFormulas;\n constructor(env: Env, columns: ReadonlyMap<string, Expr>, cells: CellFormulas = new Map()) {\n this.#env = env;\n this.#columns = columns;\n this.#cells = cells;\n }\n get columns(): Readonly<Record<string, Expr>> {\n return Object.freeze(Object.fromEntries(this.#columns));\n }\n get cellFormulas(): Readonly<Record<string, Readonly<Record<string, Expr>>>> {\n return Object.freeze(Object.fromEntries([...this.#cells].map(([c, keys]) => [c, Object.freeze(Object.fromEntries(keys))])));\n }\n declare(): SheetImpl {\n return this;\n }\n column(name: string, formula: (r: SheetRootImpl) => { readonly program: Expr }): SheetImpl {\n const program = formula(new SheetRootImpl(this.#env)).program;\n return new SheetImpl(this.#env, new Map([...this.#columns, [name, program]]), this.#cells);\n }\n cellFormula(k: string, column: string, formula: (r: SheetRootImpl) => { readonly program: Expr }): SheetImpl {\n const program = formula(new SheetRootImpl(this.#env)).program;\n const keys = new Map([...(this.#cells.get(column) ?? []), [k, program]]);\n return new SheetImpl(this.#env, this.#columns, new Map([...this.#cells, [column, keys]]));\n }\n #run(): SheetRun {\n const { space: s, domains, options } = this.#env;\n return new SheetRun(this.#columns, {\n space: s,\n domains,\n cells: this.#cells,\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(options.fns === undefined ? {} : { fns: options.fns }),\n // Stryker disable next-line ConditionalExpression: an undefined option and an absent option are the same\n ...(options.extensions === undefined ? {} : { extensions: options.extensions }),\n });\n }\n result(k: string, column: string): Result<unknown> {\n const run = this.#run();\n run.warm(column, k);\n return run.cell(column, k);\n }\n at(k: string, column: string): Optional<unknown> {\n return toOptional(this.result(k, column));\n }\n explain(k: string, column: string): Trace {\n const run = this.#run();\n run.warm(column, k);\n return run.explain(column, k);\n }\n table(): readonly SheetRow<string, Record<string, unknown>>[] {\n const run = this.#run();\n // The table reads each cell, so a fill evaluates them in the order of their reads first (SHEET.FILL).\n run.fill();\n const names = [...this.#columns.keys()];\n return this.#env.space.keys.map((key) => ({ key, cells: Object.fromEntries(names.map((c) => [c, run.cell(c, key)])) }));\n }\n}\n\n/**\n * This function gives the entry point of the builder for a list of domains. The interpreter finds the op of a\n * value in the first domain that accepts the value.\n */\nexport function vex<const Dms extends readonly AnyDomain[]>(\n ...domains: Dms\n): VexEntry<Dms> & { withOptions<const F extends FnTable = NoFns>(options: VexOptions<F>): VexEntry<Dms, F> } {\n const make = <F extends FnTable>(options: VexOptions<F>): VexEntry<Dms, F> => ({\n domains,\n over: <K extends string, O>(s: Space<K, O>): Root<{ readonly domains: Dms; readonly keys: K; readonly record: Merge<O>; readonly fns: F }> =>\n new RootImpl({ space: s, domains, options: runtimeOptions(options) }) as unknown as Root<{\n readonly domains: Dms;\n readonly keys: K;\n readonly record: Merge<O>;\n readonly fns: F;\n }>,\n });\n return { ...make<NoFns>({}), withOptions: make };\n}\n\n/** The type of a domain value, from the domain object. */\nexport type ValueOfDomain<Dm> = DomainValue<Dm>;\n\n/** An op specification type, for domain authors. */\nexport type { OpSpec };\n"],"mappings":";;AAaA,MAAMA,SAAwB,OAAO,OAAO,EAAE,KAAK,OAAO,CAAC;;AAG3D,MAAa,QAAW,WAA2B;CAAE,KAAK;CAAQ;AAAM;;AAGxE,MAAa,aAAqCA;;AAGlD,MAAa,MAAS,WAAyB;CAAE,IAAI;CAAM;AAAM;;AAGjE,MAAa,QAAmB,WAAgC;CAAE,IAAI;CAAO;AAAM;;AAGnF,MAAa,UAAa,MAAqE,EAAE,QAAQ;;AAGzG,MAAa,UAAa,MAAkD,EAAE,QAAQ;;AAGtF,MAAa,cAAiB,MAA+B,EAAE,KAAK,KAAK,EAAE,KAAK,IAAI,KAAK;;AAGzF,MAAa,SAAe,GAAgB,aAAwB,EAAE,QAAQ,SAAS,EAAE,QAAQ;;AAGjG,MAAa,aAAmB,GAAc,MAAmC,EAAE,KAAK,GAAG,EAAE,EAAE,KAAK,CAAC,IAAI;;AAGzG,MAAa,eAAqB,GAAc,MAA2C,EAAE,KAAK,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