@mark1russell7/layout-contract 0.6.2 → 0.8.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.
- package/build/index.d.ts +6 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +52 -261
- package/build/index.js.map +1 -1
- package/package.json +4 -3
- package/src/hash.ts +7 -68
- package/src/random.ts +4 -7
- package/src/verdict.ts +26 -72
- package/src/utf8.ts +0 -51
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["byCode","isFields","homeMulberry32","partOf","isObject","sweepOf"],"sources":["../src/geometry.ts","../src/shapes.ts","../src/tolerance.ts","../src/input.ts","../src/turn.ts","../src/output.ts","../src/record.ts","../src/rules.ts","../src/measures.ts","../src/balance.ts","../src/utf8.ts","../src/random.ts","../src/edges.ts","../src/hash.ts","../src/portfolio.ts","../src/corpus.ts","../src/space-walk.ts","../src/strategy-space.ts","../src/strategy-options.ts","../src/strategy-catalog.ts","../src/verdict.ts","../src/families.ts"],"sourcesContent":["/** A side of a box. The y axis points down, so `top` has the smallest y. */\nexport type Side = \"top\" | \"right\" | \"bottom\" | \"left\";\n\n/** The sides in clockwise order, from the top. */\nexport const SIDES: readonly Side[] = [\"top\", \"right\", \"bottom\", \"left\"];\n\nexport interface Point {\n readonly x: number;\n readonly y: number;\n}\n\n/** A rectangle: its top-left corner and its size. */\nexport interface Rect {\n readonly x: number;\n readonly y: number;\n readonly w: number;\n readonly h: number;\n}\n\n/**\n * A rectangle with the size in long names: its top-left corner, its `width` and its `height`.\n * Some layout engines use this shape. `toRect` and `toSizedRect` convert between it and `Rect`.\n */\nexport interface SizedRect {\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n}\n\n/** This function gives the `Rect` of a `SizedRect`. It copies each number, and it does not round. */\nexport function toRect(rect: SizedRect): Rect {\n return { x: rect.x, y: rect.y, w: rect.width, h: rect.height };\n}\n\n/** This function gives the `SizedRect` of a `Rect`. It copies each number, and it does not round. */\nexport function toSizedRect(rect: Rect): SizedRect {\n return { x: rect.x, y: rect.y, width: rect.w, height: rect.h };\n}\n\n/** A value for each side of a box. */\nexport interface Sides {\n readonly top: number;\n readonly right: number;\n readonly bottom: number;\n readonly left: number;\n}\n\n/**\n * A region. The forms and the rules are those of `docs/FORMAT.md` of `packing`.\n * A ring of a polygon closes without a copy of its first point.\n */\nexport type Region =\n | { readonly kind: \"rect\"; readonly x: number; readonly y: number; readonly w: number; readonly h: number }\n | {\n readonly kind: \"polygon\";\n readonly points: readonly (readonly [number, number])[];\n readonly holes?: readonly (readonly (readonly [number, number])[])[];\n }\n | { readonly kind: \"circle\"; readonly cx: number; readonly cy: number; readonly r: number }\n | { readonly kind: \"ellipse\"; readonly cx: number; readonly cy: number; readonly rx: number; readonly ry: number };\n\n/** A margin: one value for the four sides, or one value for each side. */\nexport type Margin = number | Sides;\n\n/** This function gives the value of each side of a margin. No margin gives 0 on each side. */\nexport function marginSides(margin: Margin | undefined): Sides {\n if (margin === undefined) return { top: 0, right: 0, bottom: 0, left: 0 };\n if (typeof margin === \"number\") return { top: margin, right: margin, bottom: margin, left: margin };\n return margin;\n}\n\n/** This function gives the rectangle made larger by the margin on each side. */\nexport function grow(rect: Rect, margin: Margin | undefined): Rect {\n const m = marginSides(margin);\n return { x: rect.x - m.left, y: rect.y - m.top, w: rect.w + m.left + m.right, h: rect.h + m.top + m.bottom };\n}\n\n/** This function gives the bounding box of a region. */\nexport function boundsOf(region: Region): Rect {\n switch (region.kind) {\n case \"rect\":\n return { x: region.x, y: region.y, w: region.w, h: region.h };\n case \"circle\":\n return { x: region.cx - region.r, y: region.cy - region.r, w: 2 * region.r, h: 2 * region.r };\n case \"ellipse\":\n return { x: region.cx - region.rx, y: region.cy - region.ry, w: 2 * region.rx, h: 2 * region.ry };\n case \"polygon\": {\n let x0 = Infinity;\n let y0 = Infinity;\n let x1 = -Infinity;\n let y1 = -Infinity;\n for (const [x, y] of region.points) {\n x0 = Math.min(x0, x);\n y0 = Math.min(y0, y);\n x1 = Math.max(x1, x);\n y1 = Math.max(y1, y);\n }\n return { x: x0, y: y0, w: x1 - x0, h: y1 - y0 };\n }\n }\n}\n\n/**\n * This function gives the exact area of a region. A `rect` gives `w` by `h`, a circle gives `PI * r * r`, and an ellipse gives `PI * rx * ry`.\n * A polygon gives the absolute value of the shoelace formula, less the area of each hole. A ring with fewer than 3 points has the area 0.\n */\nexport function regionArea(region: Region): number {\n switch (region.kind) {\n case \"rect\":\n return region.w * region.h;\n case \"circle\":\n return Math.PI * region.r * region.r;\n case \"ellipse\":\n return Math.PI * region.rx * region.ry;\n case \"polygon\":\n return (region.holes ?? []).reduce((area, hole) => area - ringArea(hole), ringArea(region.points));\n }\n}\n\n/** This function gives the area of one ring of a polygon: the absolute value of the shoelace formula. */\nfunction ringArea(ring: readonly (readonly [number, number])[]): number {\n let twice = 0;\n for (let i = 0; i < ring.length; i++) {\n const [ax, ay] = ring[i]!;\n const [bx, by] = ring[(i + 1) % ring.length]!;\n twice += ax * by - bx * ay;\n }\n return Math.abs(twice) / 2;\n}\n\n/** This function gives the region moved by `dx` and `dy`. */\nexport function translate(region: Region, dx: number, dy: number): Region {\n switch (region.kind) {\n case \"rect\":\n return { ...region, x: region.x + dx, y: region.y + dy };\n case \"circle\":\n case \"ellipse\":\n return { ...region, cx: region.cx + dx, cy: region.cy + dy };\n case \"polygon\": {\n const move = (ring: readonly (readonly [number, number])[]): [number, number][] => ring.map(([x, y]) => [x + dx, y + dy]);\n return region.holes === undefined\n ? { kind: \"polygon\", points: move(region.points) }\n : { kind: \"polygon\", points: move(region.points), holes: region.holes.map(move) };\n }\n }\n}\n\n/**\n * This function gives the overlap of the insides of two rectangles on each axis.\n * A value of 0 or less on an axis is no overlap. Two rectangles with a common edge have an overlap of 0.\n */\nexport function overlapOf(a: Rect, b: Rect): { readonly x: number; readonly y: number } {\n return {\n x: Math.min(a.x + a.w, b.x + b.w) - Math.max(a.x, b.x),\n y: Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y),\n };\n}\n\n/** This function gives the cross product of `ab` and `ac`. The sign tells the side of `ab` that has `c`. */\nfunction orient(a: Point, b: Point, c: Point): number {\n return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);\n}\n\n/** This function tells if two numbers have opposite signs. Zero and NaN give false, so a touch at an end does not count. */\nfunction opposite(p: number, q: number): boolean {\n return (p < 0 && q > 0) || (p > 0 && q < 0);\n}\n\n/**\n * This function tells if the segments `ab` and `cd` cross at one point inside both of them.\n * Segments that only touch at an end, or that are collinear, do not cross. The test has no tolerance.\n */\nexport function segmentsCross(a: Point, b: Point, c: Point, d: Point): boolean {\n return opposite(orient(c, d, a), orient(c, d, b)) && opposite(orient(a, b, c), orient(a, b, d));\n}\n\n/**\n * This function gives the point where the segments `ab` and `cd` cross, or `undefined`.\n * It gives a point exactly when `segmentsCross` is true, so a touch at an end and collinear segments give `undefined`.\n */\nexport function crossingPoint(a: Point, b: Point, c: Point, d: Point): Point | undefined {\n if (!segmentsCross(a, b, c, d)) return undefined;\n const from = orient(c, d, a);\n const t = from / (from - orient(c, d, b));\n return { x: a.x + t * (b.x - a.x), y: a.y + t * (b.y - a.y) };\n}\n\n/** This function gives the shortest distance from `p` to the segment `ab`. A segment of length 0 is the point `a`. */\nexport function pointSegmentDistance(p: Point, a: Point, b: Point): number {\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n const l2 = dx * dx + dy * dy;\n const t = l2 === 0 ? 0 : Math.max(0, Math.min(1, ((p.x - a.x) * dx + (p.y - a.y) * dy) / l2));\n return Math.hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy));\n}\n\n/**\n * This function gives the index at which a point goes among the items of a list on the screen.\n * The reading order is the rows from top to bottom, and each row from left to right.\n * The index is that of the first item whose center comes after the point, from 0 to the number of items.\n * A center within `rowTolerance` of the point on the vertical axis is in the row of the point.\n * The tolerance has the units of the points: on a screen, the default 24 is 24 pixels.\n *\n * Give the centers in reading order and without the item that moves.\n *\n * @example\n * ```ts\n * const index = dropIndex(pointer, others.map(centerOf));\n * ```\n */\nexport function dropIndex(point: Point, centers: readonly Point[], rowTolerance = 24): number {\n for (let i = 0; i < centers.length; i++) {\n const c = centers[i] as Point;\n if (point.y < c.y - rowTolerance) return i;\n if (Math.abs(point.y - c.y) <= rowTolerance && point.x < c.x) return i;\n }\n return centers.length;\n}\n","// The shape kinds of the items (`docs/SHAPES.md`): the declared set, the kind of a box and the check of the measures and rules on a run.\nimport type { ClaimBreak } from \"./corpus.ts\";\nimport { regionArea, type Region } from \"./geometry.ts\";\nimport type { LayoutBox, LayoutInput } from \"./input.ts\";\n\n/**\n * The kind of the shape of an item. A box without `shape` and without `shapeKind` is a `rect`.\n * The set is open: a later version can add a kind. A reader treats an unknown kind as a kind that it does not support.\n */\nexport type ShapeKind = \"rect\" | \"polygon\" | \"circle\" | \"free\";\n\n/** The geometry of a shape kind that this package gives. A `false` value tells that the kind declares the operation, but this package does not supply it. */\nexport interface ShapeGeometry {\n /** The bounding box: `boundsOf` and `placedRect`. */\n readonly bounds: boolean;\n /** The area of the shape: `regionArea` and `boxArea`. */\n readonly area: boolean;\n /** The test that the shape is inside a region: `rectInRegion` for a `rect`. */\n readonly contains: boolean;\n /** The test that two shapes of this kind overlap: `overlapOf` for two `rect` shapes, `shapesOverlap` for two `circle` shapes. */\n readonly overlap: boolean;\n}\n\n/** The facts of one shape kind: its fields, the kinds of `Region` that give it, and its geometry. */\nexport interface ShapeKindSpec {\n readonly id: ShapeKind;\n /** The fields of the outline, relative to the top-left corner of the box. A name with `?` is optional. */\n readonly fields: readonly string[];\n /** The kinds of `LayoutBox.shape` that agree with this kind. */\n readonly regions: readonly Region[\"kind\"][];\n readonly geometry: ShapeGeometry;\n}\n\n/**\n * The declared shape kinds, in their order. Only `rect` has all of its geometry.\n * `polygon` and `circle` have their bounding box and their exact area. A `circle` also has the overlap test of two circles. `free` has its bounding box only.\n */\nexport const SHAPE_KINDS: readonly ShapeKindSpec[] = /* @__PURE__ */ Object.freeze([\n { id: \"rect\", fields: [\"w\", \"h\"], regions: [\"rect\"], geometry: { bounds: true, area: true, contains: true, overlap: true } },\n { id: \"polygon\", fields: [\"points\", \"holes?\"], regions: [\"polygon\"], geometry: { bounds: true, area: true, contains: false, overlap: false } },\n { id: \"circle\", fields: [\"cx\", \"cy\", \"r\"], regions: [\"circle\"], geometry: { bounds: true, area: true, contains: false, overlap: true } },\n { id: \"free\", fields: [\"w\", \"h\", \"shape?\"], regions: [\"rect\", \"polygon\", \"circle\", \"ellipse\"], geometry: { bounds: true, area: false, contains: false, overlap: false } },\n] as const);\n\n/** The ids of `SHAPE_KINDS`, in their order. */\nexport const SHAPE_KIND_IDS: readonly ShapeKind[] = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ SHAPE_KINDS.map((k) => k.id));\n\n/** The shape kinds of a measure or a rule without `shapes`. The contract measured only rectangles before L46. */\nexport const DEFAULT_SHAPES: readonly ShapeKind[] = /* @__PURE__ */ Object.freeze([\"rect\"] as const);\n\n/** A measure or a rule, with the shape kinds that it supports. Without `shapes`, it supports `DEFAULT_SHAPES`. */\nexport interface ShapeSupport<Id extends string = string> {\n readonly id: Id;\n /** The kinds with an exact count or value. */\n readonly shapes?: readonly ShapeKind[];\n /**\n * The kinds with a safe count: the rule can count a break that is not real, but it does not miss a real break.\n * Thus a safe count of 0 tells that the rule has no break. A kind is in `shapes` or in `safe`, not in the two lists.\n */\n readonly safe?: readonly ShapeKind[];\n /**\n * The kinds where the value of a measure is a bound of the true value, not the exact value. `ShapeBound` tells the side.\n * A kind is in one list only: `shapes`, `safe` or `bound.shapes`. `docs/SHAPES.md` tells what a bound value proves.\n */\n readonly bound?: ShapeBound;\n /** The inputs where the exact count of this rule is only safe, with the reason and the date of the fix. `inputShapeLevel` reads it. */\n readonly limit?: ShapeLimit;\n}\n\n/**\n * A stated limit of an exact rule on circles. An input that the limit names gets the level `safe` for each kind that is exact.\n *\n * - `neighbours`: the input has a circle beside another shape kind or an obstacle.\n * - `container`: the input has a circle in a container that is a polygon or an ellipse.\n */\nexport interface ShapeLimit {\n readonly reads: \"neighbours\" | \"container\";\n /** The reason, in words. */\n readonly because: string;\n /** The date of the fix, as `YYYY-MM-DD`. */\n readonly until: string;\n}\n\n/**\n * The kinds where a measure gives a bound of the true value, and the side of the bound.\n * With `upper`, the value is the true value or more. With `lower`, the value is the true value or less.\n *\n * @remarks\n * The side and the `direction` of the measure tell what a bound value `v` proves about a threshold `t`.\n * A bound is optimistic on the better side of the true value, and pessimistic on the worse side.\n *\n * | `direction` | `side` | The bound | The proof | No proof |\n * |---|---|---|---|---|\n * | `higher` | `upper` | optimistic | `v < t`: the true value is less than `t`. | `v >= t` |\n * | `higher` | `lower` | pessimistic | `v >= t`: the true value is `t` or more. | `v < t` |\n * | `lower` | `upper` | pessimistic | `v <= t`: the true value is `t` or less. | `v > t` |\n * | `lower` | `lower` | optimistic | `v > t`: the true value is more than `t`. | `v <= t` |\n *\n * For a floor or a guard, a pessimistic bound proves a pass, and an optimistic bound proves a fail.\n * `compareMeasure` on two bound values proves nothing. A tie with a bound value proves nothing.\n * Against an exact baseline, an optimistic candidate proves only `worse`, and a pessimistic candidate proves only `better`.\n */\nexport interface ShapeBound {\n readonly shapes: readonly ShapeKind[];\n readonly side: \"upper\" | \"lower\";\n}\n\n/** The level of a rule on a shape kind: an exact count, a safe count (an upper bound), or no support. */\nexport type RuleLevel = \"exact\" | \"safe\" | \"none\";\n\n/** This function gives the level of a rule on a shape kind. A kind of `shapesOf` is `exact`, a kind of `safe` is `safe`, and another kind is `none`. It does not read `bound`. */\nexport function ruleLevel(rule: Pick<ShapeSupport, \"shapes\" | \"safe\">, kind: ShapeKind): RuleLevel {\n if (shapesOf(rule).includes(kind)) return \"exact\";\n return rule.safe?.includes(kind) === true ? \"safe\" : \"none\";\n}\n\n/** The level of a measure or a rule on a shape kind. The level `bound` is a value on one side of the true value (`ShapeBound`). */\nexport type ShapeLevel = RuleLevel | \"bound\";\n\n/**\n * This function gives the level of a measure or a rule on a shape kind. It joins the lists `shapes`, `safe` and `bound.shapes`.\n * A kind of `shapesOf` is `exact`, a kind of `safe` is `safe`, a kind of `bound.shapes` is `bound`, and another kind is `none`.\n */\nexport function shapeLevel(use: Pick<ShapeSupport, \"shapes\" | \"safe\" | \"bound\">, kind: ShapeKind): ShapeLevel {\n const level = ruleLevel(use, kind);\n if (level !== \"none\") return level;\n return use.bound?.shapes.includes(kind) === true ? \"bound\" : \"none\";\n}\n\n/** The parts of an input that `inputShapeLevel` and `checkShapes` read. */\nexport type ShapeInput = Pick<LayoutInput, \"id\" | \"boxes\"> & Partial<Pick<LayoutInput, \"obstacles\" | \"container\">>;\n\n/** This function tells if a limit names an input. An input without a circle box is not in a limit. */\nfunction inLimit(limit: ShapeLimit, input: ShapeInput): boolean {\n const kinds = shapeKindsOf(input);\n if (!kinds.includes(\"circle\")) return false;\n if (limit.reads === \"neighbours\") return kinds.length > 1 || (input.obstacles?.length ?? 0) > 0;\n const shape = input.container?.shape?.kind;\n return shape === \"polygon\" || shape === \"ellipse\";\n}\n\n/**\n * This function gives the level of a measure or a rule on a shape kind for one input. It is `shapeLevel` with the `limit` of the rule.\n * When the limit names the input, the level `exact` becomes `safe`. Each other level does not change.\n */\nexport function inputShapeLevel(use: Pick<ShapeSupport, \"shapes\" | \"safe\" | \"bound\" | \"limit\">, kind: ShapeKind, input: ShapeInput): ShapeLevel {\n const level = shapeLevel(use, kind);\n return level === \"exact\" && use.limit !== undefined && inLimit(use.limit, input) ? \"safe\" : level;\n}\n\n/**\n * This function gives the problems of a list of measures and rules. An empty list tells that the list is good.\n * It refuses an unknown kind, a kind two times in one list, and a kind in more than one of `shapesOf`, `safe` and `bound.shapes`.\n * It also refuses a `bound` without a list of kinds, and a `side` that is not `upper` or `lower`.\n * It also refuses a `limit` with a bad `reads` or a bad `until`.\n */\nexport function shapeSupportProblems(uses: readonly ShapeSupport[]): string[] {\n const out: string[] = [];\n for (const use of uses) {\n if (use.limit !== undefined) {\n if (use.limit.reads !== \"neighbours\" && use.limit.reads !== \"container\") out.push(`${use.id}: the limit reads ${String(use.limit.reads)}, not neighbours or container`);\n if (!/^\\d{4}-\\d{2}-\\d{2}$/.test(String(use.limit.until))) out.push(`${use.id}: the limit date ${String(use.limit.until)} is not YYYY-MM-DD`);\n }\n const bound: unknown = use.bound;\n const isBound = typeof bound === \"object\" && bound !== null && !Array.isArray(bound);\n if (bound !== undefined && !isBound) out.push(`${use.id}: the bound value is not an object with shapes and a side`);\n const boundShapes = isBound ? (bound as { readonly shapes?: unknown }).shapes : undefined;\n for (const [name, list] of [[\"shapes\", use.shapes], [\"safe\", use.safe], [\"bound\", boundShapes]] as const) {\n if (list === undefined && (name !== \"bound\" || !isBound)) continue;\n if (!Array.isArray(list)) {\n out.push(`${use.id}: the ${name === \"bound\" ? \"bound shapes\" : name} value is not a list of shape kinds`);\n continue;\n }\n list.forEach((k: unknown, i) => {\n if (!isShapeKind(k)) out.push(`${use.id}: the ${name} kind ${String(k)} is not a declared kind`);\n else if (list.indexOf(k) !== i) out.push(`${use.id}: the ${name} list has the kind ${k} two times`);\n });\n }\n const exact: readonly unknown[] = use.shapes === undefined ? DEFAULT_SHAPES : Array.isArray(use.shapes) ? use.shapes : [];\n if (Array.isArray(use.safe)) for (const k of new Set<unknown>(use.safe)) if (exact.includes(k)) out.push(`${use.id}: the kind ${String(k)} is in shapes and in safe`);\n if (!isBound) continue;\n const side: unknown = (bound as { readonly side?: unknown }).side;\n if (side !== \"upper\" && side !== \"lower\") out.push(`${use.id}: the bound side ${String(side)} is not upper or lower`);\n if (!Array.isArray(boundShapes)) continue;\n const safe: readonly unknown[] = Array.isArray(use.safe) ? use.safe : [];\n for (const k of new Set<unknown>(boundShapes)) {\n if (exact.includes(k)) out.push(`${use.id}: the kind ${String(k)} is in shapes and in bound`);\n if (safe.includes(k)) out.push(`${use.id}: the kind ${String(k)} is in safe and in bound`);\n }\n }\n return out;\n}\n\nconst REGION_KIND: Readonly<Record<Region[\"kind\"], ShapeKind>> = { rect: \"rect\", polygon: \"polygon\", circle: \"circle\", ellipse: \"free\" };\n\n/** This function tells if a value is a declared shape kind. */\nexport function isShapeKind(value: unknown): value is ShapeKind {\n return typeof value === \"string\" && (SHAPE_KIND_IDS as readonly string[]).includes(value);\n}\n\n/**\n * This function gives the shape kind of a box. A box with `shapeKind` has that kind.\n * Without it, the kind comes from `shape`: no shape is a `rect`, and an ellipse is `free`.\n */\nexport function shapeKindOf(box: LayoutBox): ShapeKind {\n if (box.shapeKind !== undefined) return box.shapeKind;\n return box.shape === undefined ? \"rect\" : REGION_KIND[box.shape.kind];\n}\n\n/**\n * This function gives the exact area of a box, or `undefined` when the contract knows only its bounding box.\n * A box with `shape` gives `regionArea` of the shape. A `rect` box without `shape` gives `w` by `h`.\n * A box of the kind `free` gives `undefined`, also with a shape. Thus a box with an ellipse shape gives `undefined`, because `shapeKindOf` makes an ellipse `free`.\n * A box of another kind without `shape` is a bad input, and gives `undefined`.\n */\nexport function boxArea(box: LayoutBox): number | undefined {\n const kind = shapeKindOf(box);\n if (kind === \"free\") return undefined;\n if (box.shape !== undefined) return regionArea(box.shape);\n return kind === \"rect\" ? box.w * box.h : undefined;\n}\n\n/** This function gives the shape kinds of the boxes of an input, in the order of `SHAPE_KINDS`. An input without boxes gives an empty list. */\nexport function shapeKindsOf(input: Pick<LayoutInput, \"boxes\">): ShapeKind[] {\n const seen = new Set(input.boxes.map(shapeKindOf));\n return SHAPE_KIND_IDS.filter((k) => seen.has(k));\n}\n\n/** This function gives the value of the cell dimension `itemShape` of an input: its one kind, `mixed` for more kinds, or `rect` without boxes. */\nexport function itemShapeOf(input: Pick<LayoutInput, \"boxes\">): ShapeKind | \"mixed\" {\n const kinds = shapeKindsOf(input);\n return kinds.length === 0 ? \"rect\" : kinds.length === 1 ? kinds[0]! : \"mixed\";\n}\n\n/** This function gives the problem of the shape kind of a box, or `undefined` when `shapeKind` and `shape` agree. */\nexport function shapeKindProblem(box: LayoutBox): string | undefined {\n const k: unknown = box.shapeKind;\n if (k === undefined) return undefined;\n const spec = SHAPE_KINDS.find((s) => s.id === k);\n if (spec === undefined) return `box ${box.id}: the shape kind ${String(k)} is not a declared kind`;\n if (box.shape === undefined) return k === \"rect\" || k === \"free\" ? undefined : `box ${box.id}: the shape kind ${k} has no shape`;\n if (!spec.regions.includes(box.shape.kind)) return `box ${box.id}: the shape kind ${k} does not agree with a shape of the kind ${box.shape.kind}`;\n return undefined;\n}\n\n/** This function gives the shape kinds that a measure or a rule supports. */\nexport function shapesOf(use: Pick<ShapeSupport, \"shapes\">): readonly ShapeKind[] {\n return use.shapes ?? DEFAULT_SHAPES;\n}\n\n/** The options of `checkShapes`. */\nexport interface ShapeCheck {\n /**\n * The lowest level that `checkShapes` accepts. The default `exact` refuses a kind with only a safe count or a bound value.\n * The value `safe` also accepts a kind of `safe`, as in 0.2.16. Use it only when the run claims that a rule has no break.\n * The value `bound` also accepts a kind of `safe` and a kind of `bound.shapes`. Use it only when the run reads each bound value for the proofs of its side (`docs/SHAPES.md`).\n */\n readonly level?: \"exact\" | \"safe\" | \"bound\";\n}\n\n/**\n * This function checks that each measure and each rule of a run supports each shape kind of the input. An empty list tells that the run is good.\n * Each break has the claim `shape`, the id of the input, and the first 5 ids of the boxes of the kind.\n * By default, a kind of `safe` or of `bound.shapes` is a break, because the result is not exact.\n * With the level `safe`, a kind of `safe` is not a break. With the level `bound`, a kind of `safe` and a kind of `bound.shapes` are not a break.\n */\nexport function checkShapes(input: ShapeInput, uses: readonly ShapeSupport[], options: ShapeCheck = {}): ClaimBreak[] {\n const kinds = shapeKindsOf(input);\n const out: ClaimBreak[] = [];\n for (const use of uses) {\n const shapes = shapesOf(use);\n for (const kind of kinds) {\n const level = inputShapeLevel(use, kind, input);\n const accepts = level === \"exact\" || (level === \"safe\" && (options.level === \"safe\" || options.level === \"bound\")) || (level === \"bound\" && options.level === \"bound\");\n if (accepts) continue;\n const ids = input.boxes.filter((b) => shapeKindOf(b) === kind).map((b) => b.id);\n const shown = ids.slice(0, 5).join(\", \") + (ids.length > 5 ? `, and ${ids.length - 5} more` : \"\");\n const safe =\n level === \"safe\" ? `. The count of ${use.id} on ${kind} is only safe` : level === \"bound\" ? `. The value of ${use.id} is only ${use.bound!.side === \"upper\" ? \"an upper\" : \"a lower\"} bound for ${kind}` : \"\";\n out.push({\n claim: \"shape\",\n detail: `${use.id} supports only the shape kinds ${shapes.join(\", \") || \"(none)\"}, but the input ${input.id} has ${kind} boxes: ${shown}${safe}`,\n inputs: [input.id],\n });\n }\n }\n return out;\n}\n","/** The epsilon for the float compares in an engine. */\nexport const EPS = 1e-6;\n\n/** The count of `EPS` steps in one layout unit. It is the integer equal to `1 / EPS`. */\nexport const EPS_STEPS = 1_000_000;\n\n/**\n * The count of grid steps in one unit of a written file. A file rounds each number `v` to `Math.round(v * RECORD_SCALE) / RECORD_SCALE`.\n * Use a multiplication by this value, not a division by `RECORD_EPS`. The two differ at some half steps.\n */\nexport const RECORD_SCALE = 1000;\n\n/**\n * The epsilon for the float compares on a written file. A file rounds each number to 3 decimals,\n * so a difference of two values can move by up to 0.001. It is `1 / RECORD_SCALE`.\n */\nexport const RECORD_EPS = 1e-3;\n\n/**\n * The tolerance of each hard rule, in layout units. A record writes the tolerance that its run used,\n * in its field `tolerance`, next to `hard`.\n */\nexport interface Tolerance {\n /** Two boxes with their margins break `no-overlap` when their insides overlap by more than this on each axis. */\n readonly overlap: number;\n /** A route breaks `no-pass-through` when a part longer than this is inside a box made this much smaller. */\n readonly through: number;\n}\n\n/**\n * The default tolerance of each rule. The packer is exact, so `overlap` is one unit of the rounding.\n * Routes are sampled curves that follow the margin line, so `through` is larger.\n */\nexport const DEFAULT_TOLERANCE: Tolerance = /* @__PURE__ */ Object.freeze({ overlap: 0.001, through: 0.5 });\n","import type { Margin, Point, Region, Side } from \"./geometry.ts\";\nimport type { ShapeKind } from \"./shapes.ts\";\n\n/**\n * A port of a box: a place where edges go into the box.\n * With `x` and `y`, the port is fixed on the border of the box, relative to its top-left corner.\n * With `side` and `along`, the port is fixed at a fraction of its side.\n * With only a side, the router places the port on that side. Without a side, the router picks the side.\n */\nexport interface Port {\n readonly id: string;\n readonly side?: Side;\n readonly x?: number;\n readonly y?: number;\n /**\n * The place of the port on its `side`: a fraction from 0 to 1, from the start of the side.\n * The start of `left` and `right` is the top end. The start of `top` and `bottom` is the left end.\n * It needs a `side`. A port with `along` has no `x` and no `y`.\n */\n readonly along?: number;\n}\n\n/**\n * This function gives the point of a port on the border of its box, relative to the top-left corner of the box.\n * A port with `x` and `y` gives that point. A port with `side` and `along` gives the point at that fraction of the side.\n * Another port gives `undefined`, because the router picks its point.\n */\nexport function portPoint(box: Pick<LayoutBox, \"w\" | \"h\">, port: Port): Point | undefined {\n if (port.x !== undefined && port.y !== undefined) return { x: port.x, y: port.y };\n if (port.side === undefined || port.along === undefined) return undefined;\n switch (port.side) {\n case \"top\":\n return { x: port.along * box.w, y: 0 };\n case \"bottom\":\n return { x: port.along * box.w, y: box.h };\n case \"left\":\n return { x: 0, y: port.along * box.h };\n case \"right\":\n return { x: box.w, y: port.along * box.h };\n }\n}\n\n/** A box of an input. In the packer, its name is item. */\nexport interface LayoutBox {\n readonly id: string;\n readonly w: number;\n readonly h: number;\n /** The packer writes the position. The router reads it. */\n readonly x?: number;\n readonly y?: number;\n /** A locked box keeps `x` and `y`. The packer reads it as an obstacle. */\n readonly locked?: boolean;\n /** The reading order. Without it, the order of the array is the rank. */\n readonly rank?: number;\n readonly parent?: string;\n readonly group?: string;\n /** A region relative to the origin of the box. Without it, the box is the rectangle `w` by `h`. */\n readonly shape?: Region;\n /**\n * The shape kind of the box (`docs/SHAPES.md`). Without it, `shapeKindOf` gives the kind of `shape`, or `rect` without a shape.\n * The kind `free` tells that the contract knows only the bounding box `w` by `h`.\n */\n readonly shapeKind?: ShapeKind;\n readonly ports?: readonly Port[];\n /** A ring around the box. No other box enters it. Only a route from a port of the box enters it, at a right angle. */\n readonly margin?: Margin;\n /** The packer can turn the box by 90 degrees. The output has the turned box and ports. */\n readonly turnable?: boolean;\n /** The free data of the node. The grouping rule `keys` of `highways` reads `data.group`. */\n readonly data?: Readonly<Record<string, unknown>>;\n}\n\n/** The packer name of a box. It is the same type. */\nexport type Item = LayoutBox;\n\n/** An edge between two boxes, with optional ports. */\nexport interface LayoutEdge {\n readonly id: string;\n readonly source: string;\n readonly target: string;\n readonly sourcePort?: string;\n readonly targetPort?: string;\n readonly data?: Readonly<Record<string, unknown>>;\n}\n\n/** The container. `fixed` tells which sides of the size stay. */\nexport interface LayoutContainer {\n readonly w?: number;\n readonly h?: number;\n readonly fixed: \"size\" | \"width\" | \"height\" | \"none\";\n /** The target aspect: the width divided by the height. The default is 1. */\n readonly aspect?: number;\n /** The weight of the aspect error in the objective. 0 gives the least area. The default is 1. */\n readonly aspectWeight?: number;\n /** The shape. Without it, the container is the rectangle from 0, 0 to `w`, `h`. */\n readonly shape?: Region;\n /** The space between the border and the boxes with their margins. */\n readonly inset?: number;\n}\n\n/** An area that boxes and routes avoid. Without `move`, it stays. With `move`, the packer can move it for `cost` times the distance. */\nexport interface Obstacle {\n readonly id: string;\n readonly region: Region;\n readonly move?: { readonly cost: number };\n}\n\n/** The generator of an input. The same name, version, parameters and seed give the same file, byte for byte. */\nexport interface LayoutGenerator {\n readonly name: string;\n readonly version: number;\n readonly params: Readonly<Record<string, unknown>>;\n readonly seed: number;\n}\n\n/**\n * One minimum distance between two boxes (`a` and `b`). It replaces the two margins of the boxes for this pair, and the global `gap`.\n * The order of `a` and `b` has no meaning. A pair without an entry keeps the margins and the `gap`.\n */\nexport interface PairGap {\n readonly a: string;\n readonly b: string;\n /** The minimum distance between the two boxes, in units: a finite number of 0 or more. */\n readonly gap: number;\n /** The count of the channels that the gap has space for. It is information only: a whole number of 0 or more. */\n readonly lanes?: number;\n}\n\n/** The cell of an input in the taxonomy: one value for each dimension. The dimensions are in `docs/FORMAT.md` of `packing`. */\nexport interface LayoutCell {\n readonly containerSize?: \"fixed\" | \"freeHeight\" | \"freeWidth\" | \"freeAspect\" | \"freeArea\";\n readonly containerShape?: \"rect\" | \"convex\" | \"polygon\" | \"circle\" | \"ellipse\" | \"holes\";\n readonly obstacles?: \"none\" | \"center\" | \"scattered\" | \"wall\" | \"corridors\" | \"touching\" | \"edge\";\n readonly sizes?: \"identical\" | \"uniform\" | \"heavyTail\" | \"bimodal\" | \"extremeAspect\" | \"nearIdentical\";\n readonly count?: \"1\" | \"10\" | \"100\" | \"1k\" | \"10k\";\n readonly mode?: \"offline\" | \"online\" | \"incremental\";\n readonly edgeDensity?: \"sparse\" | \"medium\" | \"dense\";\n readonly edgeShape?: \"random\" | \"clustered\" | \"hubChain\" | \"longRange\" | \"tree\" | \"bundled\";\n readonly groups?: \"none\" | \"flat\" | \"nested\";\n readonly ports?: \"free\" | \"sides\" | \"fixed\";\n /** The shape kinds of the boxes: one kind, or `mixed` for more kinds. Without it, each box is a `rect`. `itemShapeOf` gives the value. */\n readonly itemShape?: ShapeKind | \"mixed\";\n}\n\n/** An input of the corpus: the format `layout-input/1`. */\nexport interface LayoutInput {\n readonly schema: \"layout-input/1\";\n readonly id: string;\n readonly set?: string;\n readonly family?: string;\n readonly seed?: number;\n /** The origin: `made-up`, `published:<set>` or `known-best:<construction>`. */\n readonly source?: string;\n /** The first 16 hex characters of the SHA-256 of the canonical file without this field. */\n readonly hash?: string;\n /** The generator of the input. `null` or no value tells that a person made the input. */\n readonly generator?: LayoutGenerator | null;\n /** The steps that changed the input after its generator, in their order. `edgeStep` adds one. */\n readonly steps?: readonly LayoutGenerator[];\n readonly cell?: LayoutCell;\n /** The place of the input in a sequence of changes. */\n readonly step?: number;\n /** A router input can have no container. */\n readonly container?: LayoutContainer;\n /** The free space between two boxes with their margins. Routes use it. */\n readonly gap?: number;\n /** The distances of some pairs of boxes. An entry replaces the margins and the `gap` for its pair. `canonicalInput` sorts the list. */\n readonly pairGaps?: readonly PairGap[];\n readonly boxes: readonly LayoutBox[];\n readonly edges?: readonly LayoutEdge[];\n readonly obstacles?: readonly Obstacle[];\n /**\n * A variant names its base input and its change.\n * With `packed`, the variant is the packed output of its base input: the router routes the positions of that pack.\n */\n readonly base?: string;\n readonly change?: \"add\" | \"remove\" | \"resize\" | \"reorder\" | \"packed\";\n /**\n * The fields that a corpus registry removed, because a dimension value made them wrong (`CorpusDimension.invalidates`).\n * The names are sorted. An input with no removed field has no `invalidated`.\n */\n readonly invalidated?: readonly string[];\n}\n\n/**\n * A link between two items of a packer input. A graph order of the packer reads the links.\n * `a` and `b` are indexes into `PackInput.items`. The weight is 1 when it has no value.\n */\nexport interface PackLink {\n readonly a: number;\n readonly b: number;\n readonly weight?: number;\n}\n\n/** The input of a packer: a `layout-input/1` file without the edges. */\nexport interface PackInput {\n readonly container: LayoutContainer;\n readonly items: readonly Item[];\n readonly obstacles?: readonly Obstacle[];\n readonly gap?: number;\n readonly pairGaps?: readonly PairGap[];\n /** The links between the items. An input without `links` has no graph, and the links have no effect on an order that does not read them. */\n readonly links?: readonly PackLink[];\n}\n\n/** The options of `toPackInput`. */\nexport interface PackInputOptions {\n /** With `true`, the packer input gets the links of `packLinks`. The default is `false`, so the input has no `links`. */\n readonly links?: boolean;\n}\n\n/**\n * This function gives the packer input of a file. An input without a container gets `{ fixed: \"none\" }`, so the packer picks the size.\n * The edges are not in the packer input. With the option `links`, their links are in it.\n */\nexport function toPackInput(input: LayoutInput, options: PackInputOptions = {}): PackInput {\n return {\n container: input.container ?? { fixed: \"none\" },\n items: input.boxes,\n ...(input.obstacles === undefined ? {} : { obstacles: input.obstacles }),\n ...(input.gap === undefined ? {} : { gap: input.gap }),\n ...(input.pairGaps === undefined ? {} : { pairGaps: input.pairGaps }),\n ...(options.links === true ? { links: packLinks(input) } : {}),\n };\n}\n\n/**\n * This function gives the links of the edges of a file, with indexes into `input.boxes`.\n * - Each link has `a` below `b`. The list is sorted by `a` and then by `b`.\n * - The edges of one pair of boxes make one link. Its weight is the count of the edges, and a link of one edge has no weight.\n * - The function does not use an edge to a box that is not in `input.boxes`, or an edge from a box to the same box.\n */\nexport function packLinks(input: LayoutInput): PackLink[] {\n const index = new Map<string, number>();\n input.boxes.forEach((box, i) => {\n if (!index.has(box.id)) index.set(box.id, i);\n });\n const count = new Map<string, { a: number; b: number; n: number }>();\n for (const edge of input.edges ?? []) {\n const s = index.get(edge.source);\n const t = index.get(edge.target);\n if (s === undefined || t === undefined || s === t) continue;\n const a = Math.min(s, t);\n const b = Math.max(s, t);\n const key = `${a} ${b}`;\n const c = count.get(key);\n if (c === undefined) count.set(key, { a, b, n: 1 });\n else c.n += 1;\n }\n return [...count.values()].sort((x, y) => x.a - y.a || x.b - y.b).map(({ a, b, n }) => (n === 1 ? { a, b } : { a, b, weight: n }));\n}\n\n/** This function compares two strings by their UTF-16 code units, as `Array.prototype.sort` does without a compare function. */\nconst byCode = (x: string, y: string): number => (x < y ? -1 : x > y ? 1 : 0);\n\n/**\n * This function gives the canonical form of an input. `documentHash` uses it for each `layout-input/1` document.\n * Each pair of `pairGaps` gets `a` before `b`, and the list is sorted by `a` and then by `b`.\n * An input without `pairGaps` is the same object, so its hash does not change.\n */\nexport function canonicalInput<T extends LayoutInput>(input: T): T {\n if (!Array.isArray(input.pairGaps)) return input;\n const pairGaps = input.pairGaps\n .map((p): PairGap => (byCode(p.a, p.b) > 0 ? { ...p, a: p.b, b: p.a } : p))\n .sort((x, y) => byCode(x.a, y.a) || byCode(x.b, y.b));\n return { ...input, pairGaps };\n}\n","import { SIDES, marginSides, type Margin, type Region, type Side } from \"./geometry.ts\";\nimport type { LayoutBox, Port } from \"./input.ts\";\n\n/*\n * The turn: 90 degrees clockwise, with the y axis down. The turned box has `w` and `h` swapped,\n * and its top-left corner stays at the position of the box. A point (px, py) of a box of height h\n * goes to (h - py, px). Thus the top-left corner goes to the top-right corner, and each side moves\n * one step clockwise: top to right, right to bottom, bottom to left, left to top.\n */\n\n/** This function gives the side after a turn of 90 degrees clockwise. */\nexport function turnSide(side: Side): Side {\n return SIDES[(SIDES.indexOf(side) + 1) % 4]!;\n}\n\n/** This function gives a point of a box of height `h` after the turn. */\nexport function turnPoint(x: number, y: number, h: number): [number, number] {\n return [h - y, x];\n}\n\n/**\n * This function gives a port of a box of height `h` after the turn. Each value of the port turns, also a port with only `x` or only `y`.\n * The start of a side is its top end or its left end. Thus `left` goes to `top` and `right` goes to `bottom` with `along` changed to `1 - along`.\n * `top` goes to `right` and `bottom` goes to `left` with the same `along`.\n */\nexport function turnPort(port: Port, h: number): Port {\n const { side, x, y, along, ...rest } = port;\n const flips = side === \"left\" || side === \"right\";\n return {\n ...rest,\n ...(side === undefined ? {} : { side: turnSide(side) }),\n ...(y === undefined ? {} : { x: h - y }),\n ...(x === undefined ? {} : { y: x }),\n ...(along === undefined ? {} : { along: flips ? 1 - along : along }),\n };\n}\n\n/** This function gives a margin after the turn: the value of each side moves one side clockwise. */\nexport function turnMargin(margin: Margin): Margin {\n if (typeof margin === \"number\") return margin;\n const m = marginSides(margin);\n return { top: m.left, right: m.top, bottom: m.right, left: m.bottom };\n}\n\n/** This function gives a region relative to the origin of a box of height `h` after the turn. */\nexport function turnRegion(region: Region, h: number): Region {\n switch (region.kind) {\n case \"rect\":\n return { kind: \"rect\", x: h - region.y - region.h, y: region.x, w: region.h, h: region.w };\n case \"circle\":\n return { ...region, cx: h - region.cy, cy: region.cx };\n case \"ellipse\":\n return { kind: \"ellipse\", cx: h - region.cy, cy: region.cx, rx: region.ry, ry: region.rx };\n case \"polygon\": {\n const turn = (ring: readonly (readonly [number, number])[]): [number, number][] => ring.map(([x, y]) => turnPoint(x, y, h));\n return region.holes === undefined\n ? { kind: \"polygon\", points: turn(region.points) }\n : { kind: \"polygon\", points: turn(region.points), holes: region.holes.map(turn) };\n }\n }\n}\n\n/** This function gives a box after the turn: the size, the ports, the margin and the shape turn. The position stays. */\nexport function turnBox(box: LayoutBox): LayoutBox {\n return {\n ...box,\n w: box.h,\n h: box.w,\n ...(box.ports === undefined ? {} : { ports: box.ports.map((p) => turnPort(p, box.h)) }),\n ...(box.margin === undefined ? {} : { margin: turnMargin(box.margin) }),\n ...(box.shape === undefined ? {} : { shape: turnRegion(box.shape, box.h) }),\n };\n}\n","import { boundsOf, translate } from \"./geometry.ts\";\nimport type { LayoutInput } from \"./input.ts\";\nimport { turnBox } from \"./turn.ts\";\n\n/** The position of one item. `turn` is 90 when the packer turned a turnable item. */\nexport interface Placement {\n readonly id: string;\n readonly x: number;\n readonly y: number;\n readonly turn?: 0 | 90;\n}\n\n/** The facts of one stage of a strategy, for the records and the site. */\nexport interface StageTrace {\n readonly id: string;\n readonly ms?: number;\n readonly measures?: Readonly<Record<string, number>>;\n}\n\n/** The output of a packer. It does not change the input. */\nexport interface PackOutput {\n readonly placements: readonly Placement[];\n /** The ids of the items that the packer did not place. */\n readonly overflow: readonly string[];\n /** The size of the container after the pack. For a free size, the size that the search found. */\n readonly size: { readonly w: number; readonly h: number };\n /** The new top-left corner of the bounding box of each obstacle that moved. */\n readonly moved: readonly { readonly id: string; readonly x: number; readonly y: number }[];\n readonly trace?: readonly StageTrace[];\n}\n\n/**\n * This function gives the input with the output of a packer applied. Each placed box gets its position.\n * A turned box gets its turned size, ports, margin and shape. Each moved obstacle moves.\n * The container gets the size of the output. The router reads this result. It does not read `turn`.\n */\nexport function applyPack(input: LayoutInput, output: PackOutput): LayoutInput {\n const at = new Map(output.placements.map((p) => [p.id, p]));\n const moved = new Map(output.moved.map((m) => [m.id, m]));\n const boxes = input.boxes.map((box) => {\n const p = at.get(box.id);\n if (p === undefined) return box;\n const turned = p.turn === 90 ? turnBox(box) : box;\n return { ...turned, x: p.x, y: p.y };\n });\n const obstacles = input.obstacles?.map((o) => {\n const m = moved.get(o.id);\n if (m === undefined) return o;\n const b = boundsOf(o.region);\n return { ...o, region: translate(o.region, m.x - b.x, m.y - b.y) };\n });\n return {\n ...input,\n container: { ...(input.container ?? { fixed: \"none\" }), w: output.size.w, h: output.size.h },\n boxes,\n ...(obstacles === undefined ? {} : { obstacles }),\n };\n}\n","import type { Tolerance } from \"./tolerance.ts\";\nimport type { LayoutInput } from \"./input.ts\";\nimport { isShapeKind, shapeKindsOf, type ShapeKind } from \"./shapes.ts\";\n\n/** The stage of a record: the packer, the router, or both together. */\nexport type Stage = \"pack\" | \"route\" | \"joint\";\n\n/** One run of one strategy on one input and seed: the format `layout-record/1`. A run writes one line of JSON Lines. */\nexport interface LayoutRecord {\n readonly schema: \"layout-record/1\";\n readonly stage: Stage;\n readonly step: string;\n readonly strategy: string;\n /** The options in full, with the defaults. */\n readonly options: Readonly<Record<string, unknown>>;\n readonly corpus: string;\n /** The id of the input. */\n readonly input: string;\n /** The `hash` of the input file. */\n readonly inputHash: string;\n readonly set: string;\n readonly seed: number;\n readonly nodes: number;\n readonly edges: number;\n /** The shape kinds of the boxes of the input, in the order of `SHAPE_KINDS`. Without it, each box is a `rect`. */\n readonly shapes?: readonly ShapeKind[];\n /** The value of each measure, by its name: `pack.*`, `route.*` or `joint.*`. */\n readonly measures: Readonly<Record<string, number>>;\n /** The count of the breaks of each hard rule. A good run has 0 for each rule. */\n readonly hard: Readonly<Record<string, number>>;\n /** The tolerance of each hard rule of the run. */\n readonly tolerance?: Readonly<Partial<Tolerance>>;\n /** The version of the rules that made the counts of `hard`: `HARD_RULE_VERSION` at the run. `hardRuleOf` reads it. */\n readonly hardRule?: number;\n /**\n * The value is `true` when two runs with the same seed give the same positions.\n * A skipped record has `null`, because no run made a claim.\n * A record with `oneRun: true` can also have `null`: the pair had no second run to compare.\n * Each other record has a boolean.\n */\n readonly deterministic: boolean | null;\n /** The id of the prediction that was written before the run. */\n readonly prediction?: string;\n /** The median of `msRuns`, or the time of the one run. */\n readonly ms: number;\n /** The time of each timed repeat, in milliseconds. */\n readonly msRuns?: readonly number[];\n /**\n * The value is `true` when a measure of the pair chose 1 timed repeat and no warm-up.\n * Then `ms` is one time, so a time gate does not read this record.\n * A bench that runs such a pair only once writes `deterministic: null`, and its record makes no claim on determinism.\n */\n readonly oneRun?: boolean;\n /** The wall budget of the pair of a strategy and an input, in milliseconds. */\n readonly budgetMs?: number;\n /** The lower limit of the time of a pair that a stop ended, in milliseconds. This time is censored, so a mean does not read it. */\n readonly msAtLeast?: number;\n /** The pairs that caused a skip, for example the pairs over budget that stopped the larger inputs of a strategy. */\n readonly because?: readonly string[];\n /**\n * The first 16 hex characters of the SHA-256 of the canonical output of the stage.\n * The packer hashes its placements by the order of the ids. The router hashes its routes by the order of the edge ids.\n */\n readonly outputHash?: string;\n /** The facts of the computer of the run. */\n readonly env?: RunEnv;\n /** The reason when the strategy did not run, for example an input over its `maxNodes`. Then the record has no measures. */\n readonly skipped?: string;\n readonly commit?: string;\n /**\n * The facts of a carry: a later run kept this record after an engine release, with no new measure (L147).\n * Without the field, the engines of the run of the record measured it.\n * The measures, the hashes and the times stay the values of the versions of `carried.from`.\n */\n readonly carried?: Carried;\n}\n\n/**\n * The facts of a record that a run kept from an older run after an engine release (L147).\n * The run kept it because each strategy of the record has the same fingerprint at the two versions.\n */\nexport interface Carried {\n /** The version of each engine at the measure, by the name of the engine. */\n readonly from: Readonly<Record<string, string>>;\n /** The version of each engine of the run that keeps the record. The names are the names of `from`. */\n readonly to: Readonly<Record<string, string>>;\n /** The fingerprint of each strategy of the record, by its name: `fingerprintOf` of its probes, the same at the two versions. */\n readonly fingerprints: Readonly<Record<string, string>>;\n /** The id of the run that measured the record. */\n readonly run?: string;\n}\n\n/**\n * The values that a strategy supports, for each dimension of a taxonomy.\n * The dimension names are in `docs/FORMAT.md` of `packing` and `docs/LAYOUT-RECORDS.md` of `highways`.\n */\nexport type Supports = Readonly<Record<string, readonly string[]>>;\n\n/** The facts of the computer of a run. */\nexport interface RunEnv {\n readonly node: string;\n readonly os: string;\n readonly arch: string;\n /** The name of the runner, for example `ubuntu-latest` or `local`. */\n readonly runner: string;\n /** The model of the processor. */\n readonly cpu: string;\n /** The count of the logical processors. */\n readonly cpus: number;\n /** The mode of the timing, for example `process` or `fresh` of `paired-time/1`. Each timing record names its mode. */\n readonly mode?: string;\n /** The context of the run, for example `ci` or `local`, with the Node flags. */\n readonly context?: string;\n}\n\n/** The facts of a run that the input does not give. */\nexport type RunFacts = Omit<LayoutRecord, \"schema\" | \"input\" | \"inputHash\" | \"set\" | \"nodes\" | \"edges\" | \"shapes\">;\n\n/**\n * This function gives the record of a run. The input gives its id, its hash, its set and the counts of the nodes and the edges.\n * The input also gives `shapes`. An input with only `rect` boxes gets no `shapes`, so its record does not change.\n */\nexport function toLayoutRecord(input: LayoutInput, run: RunFacts): LayoutRecord {\n const shapes = shapeKindsOf(input);\n const onlyRect = shapes.length === 0 || (shapes.length === 1 && shapes[0] === \"rect\");\n return {\n schema: \"layout-record/1\",\n ...run,\n input: input.id,\n inputHash: input.hash ?? \"\",\n set: input.set ?? \"\",\n nodes: input.boxes.length,\n edges: input.edges?.length ?? 0,\n ...(onlyRect ? {} : { shapes }),\n };\n}\n\ntype Fields = Readonly<Record<string, unknown>>;\n\nconst isFields = (v: unknown): v is Fields => typeof v === \"object\" && v !== null && !Array.isArray(v);\n\nconst STAGES: readonly string[] = [\"pack\", \"route\", \"joint\"];\nconst RECORD_STRINGS = [\"step\", \"strategy\", \"corpus\", \"input\", \"inputHash\", \"set\"] as const;\nconst RECORD_NUMBERS = [\"seed\", \"nodes\", \"edges\", \"ms\"] as const;\nconst RECORD_OPTIONAL_STRINGS = [\"prediction\", \"outputHash\", \"skipped\", \"commit\"] as const;\nconst RECORD_OPTIONAL_NUMBERS = [\"budgetMs\", \"msAtLeast\", \"hardRule\"] as const;\nconst ENV_STRINGS = [\"node\", \"os\", \"arch\", \"runner\", \"cpu\"] as const;\nconst ENV_OPTIONAL_STRINGS = [\"mode\", \"context\"] as const;\n\n/** This function adds a problem for each value of a map that is not a number. */\nfunction numberMap(out: string[], v: unknown, name: string): void {\n if (!isFields(v)) {\n out.push(`${name} is not an object`);\n return;\n }\n for (const [key, n] of Object.entries(v)) if (typeof n !== \"number\") out.push(`${name}.${key} is not a number`);\n}\n\n/** This function tells if a value is an object whose values are strings. */\nconst isStringMap = (v: unknown): v is Readonly<Record<string, string>> => isFields(v) && Object.values(v).every((s) => typeof s === \"string\");\n\n/** This function gives the problems of the field `carried` of a record. */\nfunction carriedProblems(carried: unknown): string[] {\n if (!isFields(carried)) return [\"carried is not an object\"];\n const out: string[] = [];\n for (const key of [\"from\", \"to\", \"fingerprints\"] as const) if (!isStringMap(carried[key])) out.push(`carried.${key} is not a map of strings`);\n if (carried[\"run\"] !== undefined && typeof carried[\"run\"] !== \"string\") out.push(\"carried.run is not a string\");\n if (out.length > 0) return out;\n const from = carried[\"from\"] as Readonly<Record<string, string>>;\n const to = carried[\"to\"] as Readonly<Record<string, string>>;\n const names = (m: Readonly<Record<string, string>>): string => Object.keys(m).sort().join(\",\");\n if (names(from) === \"\" || names(from) !== names(to)) out.push(\"carried.from and carried.to do not name the same engines\");\n else if (Object.keys(from).every((name) => from[name] === to[name])) out.push(\"carried.to has no other version than carried.from\");\n if (Object.keys(carried[\"fingerprints\"] as object).length === 0) out.push(\"carried.fingerprints is empty\");\n return out;\n}\n\n/** This function gives the problems of the field `env` of a record. */\nfunction envProblems(env: unknown): string[] {\n if (!isFields(env)) return [\"env is not an object\"];\n const out: string[] = [];\n for (const key of ENV_STRINGS) if (typeof env[key] !== \"string\") out.push(`env.${key} is not a string`);\n if (typeof env[\"cpus\"] !== \"number\") out.push(\"env.cpus is not a number\");\n for (const key of ENV_OPTIONAL_STRINGS) if (env[key] !== undefined && typeof env[key] !== \"string\") out.push(`env.${key} is not a string`);\n return out;\n}\n\n/**\n * This function gives the version of the rules that made the counts of `hard` of a record. A record without `hardRule` has version 1.\n * On version 1, a count on a circle is by its bounding box. So it is an upper bound, and a count over 0 proves nothing.\n */\nexport function hardRuleOf(record: Pick<LayoutRecord, \"hardRule\">): number {\n return record.hardRule ?? 1;\n}\n\n/**\n * This function gives the problems of one `layout-record/1` value. An empty list means a good record.\n * A record that has `skipped` has `deterministic: null`. An old skipped record with a boolean is also correct.\n * A record without `skipped` has a boolean, or `null` when it has `oneRun: true`. The check accepts fields that the format does not know.\n */\nexport function checkLayoutRecord(value: unknown): string[] {\n if (!isFields(value)) return [\"the record is not an object\"];\n const out: string[] = [];\n const v = value;\n if (v[\"schema\"] !== \"layout-record/1\") out.push(\"schema is not layout-record/1\");\n if (typeof v[\"stage\"] !== \"string\" || !STAGES.includes(v[\"stage\"])) out.push(\"stage is not pack, route or joint\");\n for (const key of RECORD_STRINGS) if (typeof v[key] !== \"string\") out.push(`${key} is not a string`);\n for (const key of RECORD_NUMBERS) if (typeof v[key] !== \"number\") out.push(`${key} is not a number`);\n for (const key of RECORD_OPTIONAL_STRINGS) if (v[key] !== undefined && typeof v[key] !== \"string\") out.push(`${key} is not a string`);\n if (!isFields(v[\"options\"])) out.push(\"options is not an object\");\n numberMap(out, v[\"measures\"], \"measures\");\n numberMap(out, v[\"hard\"], \"hard\");\n if (v[\"tolerance\"] !== undefined) numberMap(out, v[\"tolerance\"], \"tolerance\");\n const shapes = v[\"shapes\"];\n if (shapes !== undefined && (!Array.isArray(shapes) || !shapes.every(isShapeKind))) out.push(\"shapes is not a list of shape kinds\");\n const msRuns = v[\"msRuns\"];\n if (msRuns !== undefined && (!Array.isArray(msRuns) || !msRuns.every((n) => typeof n === \"number\"))) out.push(\"msRuns is not a list of numbers\");\n if (v[\"oneRun\"] !== undefined && typeof v[\"oneRun\"] !== \"boolean\") out.push(\"oneRun is not a boolean\");\n for (const key of RECORD_OPTIONAL_NUMBERS) if (v[key] !== undefined && typeof v[key] !== \"number\") out.push(`${key} is not a number`);\n const because = v[\"because\"];\n if (because !== undefined && (!Array.isArray(because) || !because.every((s) => typeof s === \"string\"))) out.push(\"because is not a list of strings\");\n if (v[\"env\"] !== undefined) out.push(...envProblems(v[\"env\"]));\n if (v[\"carried\"] !== undefined) {\n out.push(...carriedProblems(v[\"carried\"]));\n if (v[\"skipped\"] !== undefined) out.push(\"a skipped record has carried\");\n }\n const deterministic = v[\"deterministic\"];\n if (v[\"skipped\"] === undefined) {\n const noClaim = deterministic === null && v[\"oneRun\"] === true;\n if (typeof deterministic !== \"boolean\" && !noClaim) out.push(\"deterministic is not a boolean, and the record has no skipped\");\n } else if (deterministic !== null && typeof deterministic !== \"boolean\") out.push(\"deterministic of a skipped record is not null or a boolean\");\n return out;\n}\n\n/**\n * This function reads one `layout-record/1` value, for example one parsed line of a JSON Lines file.\n * It throws a `TypeError` with the problems of `checkLayoutRecord`.\n * An old skipped record has a boolean `deterministic`. The result has `null` in its place, because no run made that claim.\n */\nexport function parseLayoutRecord(value: unknown): LayoutRecord {\n const problems = checkLayoutRecord(value);\n if (problems.length > 0) throw new TypeError(`The record is not a layout-record/1: ${problems.join(\", \")}.`);\n const record = value as LayoutRecord;\n return record.skipped !== undefined && record.deterministic !== null ? { ...record, deterministic: null } : record;\n}\n\n/** The facts of one carry, for `carryRecord`. */\nexport interface CarryFacts {\n /** The version of each engine of the run that keeps the record. */\n readonly to: Readonly<Record<string, string>>;\n /** The fingerprint of each strategy of the record, the same at the two versions. */\n readonly fingerprints: Readonly<Record<string, string>>;\n /** The version of each engine at the measure. A record that a run carried before keeps its `carried.from`, and the function ignores this value. */\n readonly from?: Readonly<Record<string, string>>;\n /** The id of the run that measured the record. A record that a run carried before keeps its `carried.run`. */\n readonly run?: string;\n}\n\n/**\n * This function gives a record that a run keeps after an engine release, with the field `carried` (L147).\n * A record that a run carried before keeps the versions and the run of its measure, so `carried.from` always names the measure.\n * The function throws a `RangeError` for a skipped record: a skip makes no claim on an output, so the run measures the pair again.\n * It also throws a `RangeError` when `checkLayoutRecord` refuses the field `carried` of the result.\n */\nexport function carryRecord(record: LayoutRecord, facts: CarryFacts): LayoutRecord {\n if (record.skipped !== undefined) throw new RangeError(`The record of ${record.strategy} on ${record.input} is skipped, so a run measures it again.`);\n const from = record.carried?.from ?? facts.from;\n if (from === undefined) throw new RangeError(`The record of ${record.strategy} on ${record.input} has no carried.from, so the carry needs from.`);\n const run = record.carried?.run ?? facts.run;\n const carried: Carried = { from, to: facts.to, fingerprints: facts.fingerprints, ...(run === undefined ? {} : { run }) };\n const problems = carriedProblems(carried);\n if (problems.length > 0) throw new RangeError(`The carry of ${record.strategy} on ${record.input} is bad: ${problems.join(\", \")}.`);\n return { ...record, carried };\n}\n","import { boundsOf, grow, marginSides, overlapOf, type Margin, type Point, type Rect, type Region } from \"./geometry.ts\";\nimport type { LayoutBox, LayoutContainer, LayoutInput, Obstacle, PairGap, Port } from \"./input.ts\";\nimport { applyPack, type PackOutput } from \"./output.ts\";\nimport { SHAPE_KIND_IDS, shapeKindProblem, type ShapeSupport } from \"./shapes.ts\";\nimport { DEFAULT_TOLERANCE, EPS, RECORD_EPS } from \"./tolerance.ts\";\n\n/** This function gives the area of a placed box: its shape or its rectangle, at its position. A box without a position gives `undefined`. */\nexport function placedRect(box: LayoutBox): Rect | undefined {\n if (box.x === undefined || box.y === undefined) return undefined;\n if (box.shape === undefined) return { x: box.x, y: box.y, w: box.w, h: box.h };\n const b = boundsOf(box.shape);\n return { x: box.x + b.x, y: box.y + b.y, w: b.w, h: b.h };\n}\n\n/**\n * The version of the rules that count `no-overlap` and `in-container`. A record states it in `LayoutRecord.hardRule`.\n *\n * - Version 1 counts each shape by its bounding box. On a circle, that count is an upper bound. A count over 0 proves nothing.\n * - Version 2 counts two circles, and a circle in a circle container, by the distance of the centers. The other pairs stay on the bounding box.\n */\nexport const HARD_RULE_VERSION = 2;\n\n/** A circle at its place on the board: its center and its radius, without a margin. */\nexport interface PlacedCircle {\n readonly cx: number;\n readonly cy: number;\n readonly r: number;\n}\n\n/** This function gives the circle of a placed box. A box without a position, or with another shape, gives `undefined`. */\nexport function placedCircle(box: LayoutBox): PlacedCircle | undefined {\n if (box.shape?.kind !== \"circle\" || box.x === undefined || box.y === undefined) return undefined;\n return { cx: box.x + box.shape.cx, cy: box.y + box.shape.cy, r: box.shape.r };\n}\n\n/** This function gives the largest side of a margin. A circle has one distance to the things near it, so its margin is this side. */\nfunction marginReach(margin: Margin | undefined): number {\n const m = marginSides(margin);\n return Math.max(m.top, m.right, m.bottom, m.left);\n}\n\n/** This function tells if the centers of two circles are nearer than `need`. It compares the squares, so it does not take a root. */\nfunction nearerThan(a: PlacedCircle, b: PlacedCircle, need: number): boolean {\n if (need <= 0) return false;\n const dx = a.cx - b.cx;\n const dy = a.cy - b.cy;\n return dx * dx + dy * dy < need * need;\n}\n\n/**\n * This function tells if two placed boxes break `no-overlap`. It is the rule for one pair of `countOverlaps`.\n *\n * - Two circles break the rule when their centers are nearer than the two radii and the two margins, less `tolerance`. The margin of a circle is the largest side of its margin.\n * - Another pair breaks the rule when the bounding boxes with their margins overlap by more than `tolerance` on each axis. With a shape that is not a rectangle, this test is an upper bound.\n * - With `gap`, the gap replaces the two margins. Two circles are then apart by the two radii and the gap. For another pair, one box grows by the gap.\n * - A box without a position does not overlap.\n */\nexport function shapesOverlap(a: LayoutBox, b: LayoutBox, tolerance: number = DEFAULT_TOLERANCE.overlap, gap?: number): boolean {\n const ca = placedCircle(a);\n const cb = placedCircle(b);\n if (ca !== undefined && cb !== undefined) return nearerThan(ca, cb, ca.r + cb.r + (gap ?? marginReach(a.margin) + marginReach(b.margin)) - tolerance);\n const ra = placedRect(a);\n const rb = placedRect(b);\n if (ra === undefined || rb === undefined) return false;\n const o = gap === undefined ? overlapOf(grow(ra, a.margin), grow(rb, b.margin)) : overlapOf(grow(ra, gap), rb);\n return o.x > tolerance && o.y > tolerance;\n}\n\n/** This function gives the gap of each pair of `pairGaps` by `pairKey`. The first entry of a pair wins. A pair of one box has no gap. */\nfunction gapsOf(pairGaps: readonly PairGap[] | undefined): Map<string, number> {\n const gaps = new Map<string, number>();\n for (const p of pairGaps ?? []) {\n const key = pairKey(p.a, p.b);\n if (p.a !== p.b && !gaps.has(key)) gaps.set(key, p.gap);\n }\n return gaps;\n}\n\n/**\n * This function counts the pairs of placed boxes that break `no-overlap`. `shapesOverlap` is the rule for one pair.\n * Two circles count by the distance of their centers. Each other pair counts by the bounding boxes, so a circle beside another shape is an upper bound (roadmap item L107).\n *\n * A pair of `pairGaps`, in either order, uses its `gap` in place of the two margins. One box grows by the gap, and the other box does not grow.\n * Thus the pair breaks the rule only when the boxes are nearer than the gap on each axis. The other pairs do not change.\n */\nexport function countOverlaps(boxes: readonly LayoutBox[], tolerance: number = DEFAULT_TOLERANCE.overlap, pairGaps?: readonly PairGap[]): number {\n const circles = circleOverlaps(boxes, tolerance, pairGaps);\n if (pairGaps === undefined || pairGaps.length === 0) return circles + marginOverlaps(boxes, tolerance, undefined);\n const gaps = gapsOf(pairGaps);\n const raw = new Map<string, LayoutBox>();\n for (const box of boxes) {\n if (placedRect(box) !== undefined && !raw.has(box.id)) raw.set(box.id, box);\n }\n let count = circles + marginOverlaps(boxes, tolerance, gaps);\n for (const [key, gap] of gaps) {\n const [a, b] = JSON.parse(key) as [string, string];\n const ba = raw.get(a);\n const bb = raw.get(b);\n if (ba === undefined || bb === undefined) continue;\n if (placedCircle(ba) !== undefined && placedCircle(bb) !== undefined) continue;\n if (shapesOverlap(ba, bb, tolerance, gap)) count++;\n }\n return count;\n}\n\n/** This function gives the key of a pair of box ids, with the same key for each order. */\nconst pairKey = (a: string, b: string): string => JSON.stringify(a < b ? [a, b] : [b, a]);\n\n/**\n * This function counts the pairs of placed circles that break `no-overlap`, by the distance of their centers. Each other box does not count.\n *\n * - Two circles break the rule when their centers are nearer than the two radii, the two margins and `gap`, less `tolerance`.\n * - The margin of a circle is the largest side of its margin.\n * - A pair of `pairGaps` is apart by the two radii and its gap, in place of the margins and `gap`.\n * - `gap` has the default 0. The rule `no-overlap` does not read `LayoutInput.gap`, so `countOverlaps` gives no value. An engine that keeps the gap between circles gives it here.\n */\nexport function circleOverlaps(boxes: readonly LayoutBox[], tolerance: number = DEFAULT_TOLERANCE.overlap, pairGaps?: readonly PairGap[], gap = 0): number {\n const gaps = gapsOf(pairGaps);\n const discs: { readonly id: string; readonly c: PlacedCircle; readonly reach: number }[] = [];\n const first = new Map<string, PlacedCircle>();\n for (const box of boxes) {\n const c = placedCircle(box);\n if (c === undefined) continue;\n discs.push({ id: box.id, c, reach: c.r + marginReach(box.margin) + gap / 2 });\n if (!first.has(box.id)) first.set(box.id, c);\n }\n discs.sort((a, b) => a.c.cx - a.reach - (b.c.cx - b.reach));\n let count = 0;\n for (let i = 0; i < discs.length; i++) {\n const a = discs[i]!;\n for (let j = i + 1; j < discs.length; j++) {\n const b = discs[j]!;\n if (b.c.cx - b.reach >= a.c.cx + a.reach - tolerance) break;\n if (gaps.has(pairKey(a.id, b.id))) continue;\n if (nearerThan(a.c, b.c, a.reach + b.reach - tolerance)) count++;\n }\n }\n for (const [key, g] of gaps) {\n const [a, b] = JSON.parse(key) as [string, string];\n const ca = first.get(a);\n const cb = first.get(b);\n if (ca !== undefined && cb !== undefined && nearerThan(ca, cb, ca.r + cb.r + g - tolerance)) count++;\n }\n return count;\n}\n\n/** This function counts the overlaps by the bounding boxes with their margins. It skips the pairs of `skip` and the pairs of two circles. */\nfunction marginOverlaps(boxes: readonly LayoutBox[], tolerance: number, skip: ReadonlyMap<string, number> | undefined): number {\n const rects: { readonly id: string; readonly r: Rect; readonly circle: boolean }[] = [];\n for (const box of boxes) {\n const r = placedRect(box);\n if (r !== undefined) rects.push({ id: box.id, r: grow(r, box.margin), circle: box.shape?.kind === \"circle\" });\n }\n rects.sort((a, b) => a.r.x - b.r.x);\n let count = 0;\n for (let i = 0; i < rects.length; i++) {\n const a = rects[i]!.r;\n for (let j = i + 1; j < rects.length; j++) {\n const b = rects[j]!.r;\n if (b.x >= a.x + a.w - tolerance) break;\n if (rects[i]!.circle && rects[j]!.circle) continue;\n if (skip !== undefined && skip.has(pairKey(rects[i]!.id, rects[j]!.id))) continue;\n const o = overlapOf(a, b);\n if (o.x > tolerance && o.y > tolerance) count++;\n }\n }\n return count;\n}\n\n/** The options of the container test of `countOutside` and `packHard`. */\nexport interface ContainerTest {\n /**\n * With `true`, a box of a shaped container with the size `fixed` must stay inside the shape, not only inside its bounding box.\n * A circle in a circle container is tested by distance. The default is `true` since 0.4.0. With `false`, only the bounding box counts.\n */\n readonly exactContainer?: boolean;\n}\n\n/** This function gives the circle of a circle container. A free size reads its radius from `w`, and the corner of the shape stays. Another container, or a free size without `w`, gives `undefined`. */\nfunction containerCircle(c: LayoutContainer): PlacedCircle | undefined {\n const s = c.shape;\n if (s?.kind !== \"circle\") return undefined;\n if (c.fixed === \"size\") return s;\n if (c.w === undefined) return undefined;\n const r = c.w / 2;\n return { cx: s.cx - s.r + r, cy: s.cy - s.r + r, r };\n}\n\n/** This function tells if a circle goes out of a circle container. The reach is the center distance, the radius and `extra`. It compares the squares. */\nfunction circleOutside(disc: PlacedCircle, extra: number, ring: PlacedCircle, tolerance: number): boolean {\n const room = ring.r + tolerance - disc.r - extra;\n if (room < 0) return true;\n const dx = disc.cx - ring.cx;\n const dy = disc.cy - ring.cy;\n return dx * dx + dy * dy > room * room;\n}\n\n/**\n * This function counts the placed circles that go out of a circle container, by the distance of the centers.\n *\n * - The reach of a circle is the sum of the center distance, the radius, the largest side of the margin and the inset.\n * - A circle breaks the rule when its reach is more than the container radius plus `tolerance`.\n * - A container with a free size reads its radius from `w`, and its center is the corner of the shape plus that radius. `applyPack` writes that `w`.\n * - Each other box does not count. The function throws a `RangeError` for a container that is not a circle.\n */\nexport function circlesOutside(input: LayoutInput, tolerance: number = DEFAULT_TOLERANCE.overlap): number {\n const c = input.container;\n const ring = c === undefined ? undefined : containerCircle(c);\n if (c === undefined || ring === undefined) throw new RangeError(\"The function circlesOutside needs a circle container, with w when its size is free.\");\n let count = 0;\n for (const box of input.boxes) {\n const disc = placedCircle(box);\n if (disc !== undefined && circleOutside(disc, marginReach(box.margin) + (c.inset ?? 0), ring, tolerance)) count++;\n }\n return count;\n}\n\n/** This function gives the length of the part of the segment `ab` inside a circle. A radius of 0 or less gives 0. */\nfunction partInCircle(a: Point, b: Point, cx: number, cy: number, r: number): number {\n if (r <= 0) return 0;\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n const fx = a.x - cx;\n const fy = a.y - cy;\n const l2 = dx * dx + dy * dy;\n if (l2 === 0) return 0;\n const half = fx * dx + fy * dy;\n const inner = half * half - l2 * (fx * fx + fy * fy - r * r);\n if (inner <= 0) return 0;\n const root = Math.sqrt(inner);\n const t0 = Math.max(0, (-half - root) / l2);\n const t1 = Math.min(1, (-half + root) / l2);\n return t1 > t0 ? (t1 - t0) * Math.sqrt(l2) : 0;\n}\n\n/** This function gives the length of the part of the segment `ab` inside the open box from (`x0`, `y0`) to (`x1`, `y1`). A box with no inside gives 0. */\nfunction partInBox(a: Point, b: Point, x0: number, y0: number, x1: number, y1: number): number {\n if (x1 <= x0 || y1 <= y0) return 0;\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n let t0 = 0;\n let t1 = 1;\n for (const [from, d, lo, hi] of [[a.x, dx, x0, x1], [a.y, dy, y0, y1]] as const) {\n if (d === 0) {\n if (from <= lo || from >= hi) return 0;\n continue;\n }\n const ta = (lo - from) / d;\n const tb = (hi - from) / d;\n t0 = Math.max(t0, Math.min(ta, tb));\n t1 = Math.min(t1, Math.max(ta, tb));\n if (t0 > t1) return 0;\n }\n return (t1 - t0) * Math.sqrt(dx * dx + dy * dy);\n}\n\n/**\n * This function tells if the segment `ab` goes through a placed box, by the rule of `Tolerance.through`.\n * A part of the segment longer than `tolerance` is inside the shape made `tolerance` smaller.\n *\n * - A circle box reads its circle. Each other kind reads its bounding box, so on a polygon or a free shape the answer is an upper bound.\n * - The margin of the box does not count. A box without a position gives `false`.\n */\nexport function segmentThroughShape(a: Point, b: Point, box: LayoutBox, tolerance: number = DEFAULT_TOLERANCE.through): boolean {\n const disc = placedCircle(box);\n if (disc !== undefined) return partInCircle(a, b, disc.cx, disc.cy, disc.r - tolerance) > tolerance;\n const r = placedRect(box);\n if (r === undefined) return false;\n return partInBox(a, b, r.x + tolerance, r.y + tolerance, r.x + r.w - tolerance, r.y + r.h - tolerance) > tolerance;\n}\n\n/** A route between two boxes: the ids of its ends and its points. `countLinksThroughShapes` reads it. */\nexport interface ShapeLink {\n readonly source: string;\n readonly target: string;\n readonly points: readonly Point[];\n}\n\n/**\n * This function counts the routes that go through a placed box that is not one of their two ends, by `segmentThroughShape`.\n * A route counts once, also when it goes through more than one box.\n */\nexport function countLinksThroughShapes(boxes: readonly LayoutBox[], links: readonly ShapeLink[], tolerance: number = DEFAULT_TOLERANCE.through): number {\n const placed = boxes.flatMap((box) => {\n const r = placedRect(box);\n return r === undefined ? [] : [{ box, r }];\n });\n placed.sort((p, q) => p.r.x - q.r.x);\n const widest = placed.reduce((m, p) => Math.max(m, p.r.w), 0);\n const firstAt = (x: number): number => {\n let lo = 0;\n let hi = placed.length;\n while (lo < hi) {\n const mid = (lo + hi) >>> 1;\n if (placed[mid]!.r.x < x) lo = mid + 1;\n else hi = mid;\n }\n return lo;\n };\n let count = 0;\n for (const link of links) {\n let hit = false;\n for (let i = 1; i < link.points.length && !hit; i++) {\n const a = link.points[i - 1]!;\n const b = link.points[i]!;\n const left = Math.min(a.x, b.x);\n const right = Math.max(a.x, b.x);\n const top = Math.min(a.y, b.y);\n const bottom = Math.max(a.y, b.y);\n for (let k = firstAt(left - widest); k < placed.length && placed[k]!.r.x < right && !hit; k++) {\n const { box, r } = placed[k]!;\n if (r.x + r.w <= left || r.y >= bottom || r.y + r.h <= top) continue;\n if (box.id !== link.source && box.id !== link.target && segmentThroughShape(a, b, box, tolerance)) hit = true;\n }\n }\n if (hit) count++;\n }\n return count;\n}\n\n/**\n * This function counts the placed boxes that go out of the container.\n * Each box with its margin must stay inside the container made smaller by `inset`. Only the fixed sides of the size count. A shaped container counts as its bounding box.\n *\n * With `exactContainer`, the default, a box of a shaped container with the size `fixed` also counts when it is not inside the shape, by `rectInRegion`.\n * For that test, the box grows by `inset` and becomes smaller by `tolerance` on each side. A shaped container with a free side keeps the bounding test only.\n * A circle in a circle container does not use `rectInRegion`. It counts by distance, as in `circlesOutside`, also when the size is free.\n * An input without a container gives 0.\n */\nexport function countOutside(input: LayoutInput, tolerance: number = DEFAULT_TOLERANCE.overlap, options: ContainerTest = {}): number {\n const c = input.container;\n if (c === undefined) return 0;\n const exact = options.exactContainer !== false;\n const shape = exact && c.fixed === \"size\" ? c.shape : undefined;\n const ring = exact ? containerCircle(c) : undefined;\n const area = c.shape === undefined ? { x: 0, y: 0, w: c.w ?? Infinity, h: c.h ?? Infinity } : boundsOf(c.shape);\n const inset = c.inset ?? 0;\n const fixW = c.fixed === \"size\" || c.fixed === \"width\";\n const fixH = c.fixed === \"size\" || c.fixed === \"height\";\n let count = 0;\n for (const box of input.boxes) {\n const r0 = placedRect(box);\n if (r0 === undefined) continue;\n const r = grow(r0, box.margin);\n const outX = r.x < area.x + inset - tolerance || r.x + r.w > area.x + area.w - inset + tolerance;\n const outY = r.y < area.y + inset - tolerance || r.y + r.h > area.y + area.h - inset + tolerance;\n const disc = ring === undefined ? undefined : placedCircle(box);\n if ((fixW && outX) || (fixH && outY)) count++;\n else if (ring !== undefined && disc !== undefined) {\n if (circleOutside(disc, marginReach(box.margin) + inset, ring, tolerance)) count++;\n } else if (shape !== undefined && !rectInRegion(shape, shrink(grow(r, inset), tolerance))) count++;\n }\n return count;\n}\n\n/** This function counts the fixed ports that are not on the border of their box, with the epsilon of a written file. A port without a side does not count. */\nexport function countPortsOffBorder(boxes: readonly LayoutBox[], eps: number = RECORD_EPS): number {\n let count = 0;\n for (const box of boxes) {\n for (const p of box.ports ?? []) {\n if (p.x === undefined || p.y === undefined || p.side === undefined) continue;\n const along = p.side === \"top\" || p.side === \"bottom\" ? p.x : p.y;\n const length = p.side === \"top\" || p.side === \"bottom\" ? box.w : box.h;\n const across = { top: p.y, bottom: p.y - box.h, left: p.x, right: p.x - box.w }[p.side];\n if (Math.abs(across) > eps || along < -eps || along > length + eps) count++;\n }\n }\n return count;\n}\n\n/** The count of the breaks of each hard rule of a pack. */\nexport interface PackHard {\n readonly \"no-overlap\": number;\n readonly \"in-container\": number;\n readonly \"locked-kept\": number;\n readonly complete: number;\n}\n\n/**\n * The hard rules of a pack, with the shape kinds that each rule supports.\n * `no-overlap` and `in-container` are exact for a `rect` and a `circle`. `limit` tells the inputs where the count of a circle is only safe (roadmap item L107).\n * For the other kinds, these rules test the bounding box. The count is safe: a shape is inside its bounding box, so the count is an upper bound. A count of 0 tells that the rule has no break.\n * `locked-kept` and `complete` read only the positions and the ids, so they support each kind.\n */\nexport const PACK_HARD_RULES: readonly ShapeSupport<keyof PackHard>[] = /* @__PURE__ */ Object.freeze([\n {\n id: \"no-overlap\",\n shapes: [\"rect\", \"circle\"],\n safe: [\"polygon\", \"free\"],\n limit: { reads: \"neighbours\", because: \"A circle beside another shape kind or an obstacle counts by its bounding box.\", until: \"2026-11-28\" },\n },\n {\n id: \"in-container\",\n shapes: [\"rect\", \"circle\"],\n safe: [\"polygon\", \"free\"],\n limit: { reads: \"container\", because: \"A circle in a polygon or an ellipse container counts by its bounding box.\", until: \"2026-11-28\" },\n },\n { id: \"locked-kept\", shapes: SHAPE_KIND_IDS },\n { id: \"complete\", shapes: SHAPE_KIND_IDS },\n] as const);\n\n/** This function tells if the inside of `region` and the inside of `rect` have a common point. */\nexport function regionHitsRect(region: Region, rect: Rect): boolean {\n if (rect.w <= 0 || rect.h <= 0) return false;\n switch (region.kind) {\n case \"rect\": {\n const o = overlapOf(region, rect);\n return o.x > 0 && o.y > 0;\n }\n case \"circle\":\n return circleHitsRect(region.cx, region.cy, region.r, region.r, rect);\n case \"ellipse\":\n return circleHitsRect(region.cx, region.cy, region.rx, region.ry, rect);\n case \"polygon\": {\n const rings = [region.points, ...(region.holes ?? [])];\n const inside = (x: number, y: number): boolean => x > rect.x && x < rect.x + rect.w && y > rect.y && y < rect.y + rect.h;\n if (region.points.some(([x, y]) => inside(x, y))) return true;\n for (const ring of rings) {\n for (let i = 0; i < ring.length; i++) {\n const a = ring[i]!;\n const b = ring[(i + 1) % ring.length]!;\n const m = clipMid(a[0], a[1], b[0], b[1], rect);\n if (m !== undefined && inside(m[0], m[1])) return true;\n }\n }\n return pointInRings(rect.x + rect.w / 2, rect.y + rect.h / 2, rings);\n }\n }\n}\n\n/**\n * This function tells if all of `rect` is inside `region`. A point on the border counts as inside. No part of `rect` can overlap a hole.\n * The test of a circle, an ellipse or a polygon accepts an error of `EPS` on the border. A polygon can be concave.\n */\nexport function rectInRegion(region: Region, rect: Rect): boolean {\n const x1 = rect.x + rect.w;\n const y1 = rect.y + rect.h;\n const corners: readonly (readonly [number, number])[] = [\n [rect.x, rect.y],\n [x1, rect.y],\n [x1, y1],\n [rect.x, y1],\n ];\n switch (region.kind) {\n case \"rect\":\n return rect.x >= region.x && rect.y >= region.y && x1 <= region.x + region.w && y1 <= region.y + region.h;\n case \"circle\":\n return corners.every(([x, y]) => inEllipse(region.cx, region.cy, region.r, region.r, x, y));\n case \"ellipse\":\n return corners.every(([x, y]) => inEllipse(region.cx, region.cy, region.rx, region.ry, x, y));\n case \"polygon\": {\n const ring = region.points;\n if (ring.length < 3) return false;\n const points = [...corners, [rect.x + rect.w / 2, rect.y + rect.h / 2] as const];\n if (!points.every(([x, y]) => onRing(x, y, ring) || pointInRings(x, y, [ring]))) return false;\n const deep = (x: number, y: number): boolean => x > rect.x + EPS && x < x1 - EPS && y > rect.y + EPS && y < y1 - EPS;\n for (let i = 0; i < ring.length; i++) {\n const a = ring[i]!;\n const b = ring[(i + 1) % ring.length]!;\n const m = clipMid(a[0], a[1], b[0], b[1], rect);\n if (m !== undefined && deep(m[0], m[1])) return false;\n }\n return (region.holes ?? []).every((hole) => !regionHitsRect({ kind: \"polygon\", points: hole }, rect));\n }\n }\n}\n\n/** This function gives the rectangle made smaller by `d` on each side. A side does not become smaller than 0. */\nfunction shrink(r: Rect, d: number): Rect {\n const dx = Math.min(d, r.w / 2);\n const dy = Math.min(d, r.h / 2);\n return { x: r.x + dx, y: r.y + dy, w: r.w - 2 * dx, h: r.h - 2 * dy };\n}\n\n/** This function tells if a point is inside an ellipse or on its border, with an error of `EPS`. */\nfunction inEllipse(cx: number, cy: number, rx: number, ry: number, x: number, y: number): boolean {\n if (rx <= 0 || ry <= 0) return false;\n const u = (x - cx) / rx;\n const v = (y - cy) / ry;\n return u * u + v * v <= 1 + EPS;\n}\n\n/** This function tells if a point is on a ring of a polygon, with an error of `EPS`. */\nfunction onRing(x: number, y: number, ring: readonly (readonly [number, number])[]): boolean {\n for (let i = 0; i < ring.length; i++) {\n const [ax, ay] = ring[i]!;\n const [bx, by] = ring[(i + 1) % ring.length]!;\n const dx = bx - ax;\n const dy = by - ay;\n const len2 = dx * dx + dy * dy;\n const t = len2 === 0 ? 0 : Math.max(0, Math.min(1, ((x - ax) * dx + (y - ay) * dy) / len2));\n if (Math.hypot(x - (ax + t * dx), y - (ay + t * dy)) <= EPS) return true;\n }\n return false;\n}\n\n/** An ellipse with the radii `rx` and `ry` scales to a unit circle. The rectangle scales with it. */\nfunction circleHitsRect(cx: number, cy: number, rx: number, ry: number, rect: Rect): boolean {\n if (rx <= 0 || ry <= 0) return false;\n const x0 = (rect.x - cx) / rx;\n const x1 = (rect.x + rect.w - cx) / rx;\n const y0 = (rect.y - cy) / ry;\n const y1 = (rect.y + rect.h - cy) / ry;\n const dx = Math.max(x0, 0, -x1);\n const dy = Math.max(y0, 0, -y1);\n return dx * dx + dy * dy < 1;\n}\n\n/** This function gives the middle of the part of a segment inside a rectangle, or `undefined` when that part is a point or empty. */\nfunction clipMid(ax: number, ay: number, bx: number, by: number, r: Rect): readonly [number, number] | undefined {\n let t0 = 0;\n let t1 = 1;\n const dx = bx - ax;\n const dy = by - ay;\n const edges: readonly (readonly [number, number])[] = [\n [-dx, ax - r.x],\n [dx, r.x + r.w - ax],\n [-dy, ay - r.y],\n [dy, r.y + r.h - ay],\n ];\n for (const [p, q] of edges) {\n if (p === 0) {\n if (q < 0) return undefined;\n } else if (p < 0) {\n t0 = Math.max(t0, q / p);\n } else {\n t1 = Math.min(t1, q / p);\n }\n }\n if (t1 <= t0) return undefined;\n const t = (t0 + t1) / 2;\n return [ax + t * dx, ay + t * dy];\n}\n\n/** The even-odd rule over the outer ring and the holes. */\nfunction pointInRings(x: number, y: number, rings: readonly (readonly (readonly [number, number])[])[]): boolean {\n let inside = false;\n for (const ring of rings) {\n for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {\n const [xi, yi] = ring[i]!;\n const [xj, yj] = ring[j]!;\n if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) inside = !inside;\n }\n }\n return inside;\n}\n\n/**\n * This function counts the pairs of a placed box and an obstacle that overlap by more than `tolerance`.\n * The box counts with its margin. A box with a shape counts as its bounding box.\n */\nexport function countObstacleHits(\n boxes: readonly LayoutBox[],\n obstacles: readonly Obstacle[] | undefined,\n tolerance: number = DEFAULT_TOLERANCE.overlap,\n): number {\n if (obstacles === undefined || obstacles.length === 0) return 0;\n let count = 0;\n for (const box of boxes) {\n const r0 = placedRect(box);\n if (r0 === undefined) continue;\n const r = grow(r0, box.margin);\n const small = { x: r.x + tolerance, y: r.y + tolerance, w: r.w - 2 * tolerance, h: r.h - 2 * tolerance };\n for (const o of obstacles) if (regionHitsRect(o.region, small)) count++;\n }\n return count;\n}\n\n/**\n * This function gives the count of each hard rule of the output of a packer.\n * It applies the output with `applyPack`. Only the placed boxes and the locked boxes count for the overlaps and the container.\n * `no-overlap` counts the pairs of boxes and the pairs of a box and an obstacle. A pair of `pairGaps` uses its gap in place of the margins. `HARD_RULE_VERSION` tells the version of these counts.\n *\n * A locked box without a placement, or with a move of more than `RECORD_EPS`, breaks `locked-kept`.\n * A locked box without a position in the input is a bad input, not a break. `checkInput` finds it.\n * Another box without a placement that is not in `overflow` breaks `complete`.\n *\n * `options` goes to `countOutside` for `in-container`.\n */\nexport function packHard(input: LayoutInput, output: PackOutput, tolerance: number = DEFAULT_TOLERANCE.overlap, options: ContainerTest = {}): PackHard {\n const after = applyPack(input, output);\n const placed = new Set(output.placements.map((p) => p.id));\n const out = new Set(output.overflow);\n const was = new Map(input.boxes.map((b) => [b.id, b]));\n let lockedMoved = 0;\n let incomplete = 0;\n const kept: LayoutBox[] = [];\n for (const box of after.boxes) {\n const old = was.get(box.id);\n if (old?.locked === true) {\n if (old.x === undefined || old.y === undefined) continue;\n const moved = Math.abs(old.x - (box.x ?? old.x)) > RECORD_EPS || Math.abs(old.y - (box.y ?? old.y)) > RECORD_EPS;\n if (!placed.has(box.id) || moved) lockedMoved++;\n kept.push(box);\n } else if (placed.has(box.id)) {\n kept.push(box);\n } else if (!out.has(box.id)) {\n incomplete++;\n }\n }\n return {\n \"no-overlap\": countOverlaps(kept, tolerance, input.pairGaps) + countObstacleHits(kept, after.obstacles, tolerance),\n \"in-container\": countOutside({ ...after, boxes: kept }, tolerance, options),\n \"locked-kept\": lockedMoved,\n complete: incomplete,\n };\n}\n\n/**\n * This function gives the problems of an input file. An empty list tells that the file is good.\n * A problem is a bad input, not a break of a hard rule. Thus an engine refuses the input.\n * In `pairGaps`, an unknown box, a pair of one box, a repeated pair in either order, a bad `gap` and bad `lanes` are problems.\n * A port with `along` and no `side`, with `x` or `y`, or with a value outside [0, 1] is a problem.\n */\nexport function checkInput(input: LayoutInput): readonly string[] {\n const problems: string[] = [];\n const ids = new Set<string>();\n for (const box of input.boxes) {\n if (ids.has(box.id)) problems.push(`box ${box.id}: the id is not unique`);\n ids.add(box.id);\n if (!(box.w > 0 && box.h > 0 && Number.isFinite(box.w) && Number.isFinite(box.h))) problems.push(`box ${box.id}: the size is not positive and finite`);\n if (box.locked === true && (box.x === undefined || box.y === undefined)) problems.push(`box ${box.id}: a locked box has no position`);\n const shape = shapeKindProblem(box);\n if (shape !== undefined) problems.push(shape);\n for (const port of box.ports ?? []) problems.push(...alongProblems(box.id, port));\n }\n if (countPortsOffBorder(input.boxes) > 0) problems.push(\"a fixed port is not on the border of its box\");\n for (const edge of input.edges ?? []) {\n if (!ids.has(edge.source) || !ids.has(edge.target)) problems.push(`edge ${edge.id}: a box of the edge is not in the input`);\n }\n problems.push(...pairGapProblems(input.pairGaps, ids));\n return problems;\n}\n\n/** This function gives the problems of the `along` of a port: no side, a value outside [0, 1], or `x` or `y` with it. A port without `along` has no problem. */\nfunction alongProblems(boxId: string, port: Port): string[] {\n if (port.along === undefined) return [];\n const at = `box ${boxId} port ${port.id}`;\n const problems: string[] = [];\n if (port.side === undefined) problems.push(`${at}: a port with along has no side`);\n if (typeof port.along !== \"number\" || !Number.isFinite(port.along) || port.along < 0 || port.along > 1)\n problems.push(`${at}: the along value ${String(port.along)} is not a finite number from 0 to 1`);\n if (port.x !== undefined || port.y !== undefined) problems.push(`${at}: a port with along also has x or y`);\n return problems;\n}\n\n/** This function gives the problems of the `pairGaps` of an input. `ids` has the ids of the boxes. */\nfunction pairGapProblems(pairGaps: LayoutInput[\"pairGaps\"], ids: ReadonlySet<string>): string[] {\n if (pairGaps === undefined) return [];\n if (!Array.isArray(pairGaps)) return [\"pairGaps: the value is not a list\"];\n const problems: string[] = [];\n const seen = new Map<string, number>();\n pairGaps.forEach((p: PairGap, i) => {\n const at = `pair gap ${i} (${String(p?.a)}, ${String(p?.b)})`;\n if (typeof p !== \"object\" || p === null || typeof p.a !== \"string\" || typeof p.b !== \"string\") {\n problems.push(`pair gap ${i}: the entry has no string ids a and b`);\n return;\n }\n for (const id of [p.a, p.b]) if (!ids.has(id)) problems.push(`${at}: the box ${id} is not in the input`);\n if (p.a === p.b) problems.push(`${at}: the two ids are the same box`);\n if (typeof p.gap !== \"number\" || !Number.isFinite(p.gap) || p.gap < 0) problems.push(`${at}: the gap ${String(p.gap)} is not a finite number of 0 or more`);\n if (p.lanes !== undefined && (typeof p.lanes !== \"number\" || !Number.isInteger(p.lanes) || p.lanes < 0))\n problems.push(`${at}: the lanes value ${String(p.lanes)} is not a whole number of 0 or more`);\n const key = JSON.stringify(p.a < p.b ? [p.a, p.b] : [p.b, p.a]);\n const first = seen.get(key);\n if (first !== undefined) problems.push(`${at}: the pair is also pair gap ${first}`);\n else seen.set(key, i);\n });\n return problems;\n}\n","import { SHAPE_KIND_IDS, type ShapeBound, type ShapeKind } from \"./shapes.ts\";\nimport { RECORD_EPS, RECORD_SCALE } from \"./tolerance.ts\";\n\n/** The direction of a measure: the side of the better values. */\nexport type Direction = \"lower\" | \"higher\";\n\n/**\n * The facts of one measure: its unit, its direction and its range.\n * `floor` and `tol` are the parameters of the floor rule of the promotion rule (`docs/PROMOTION.md` of `highways`).\n * Each engine exports the specs of its own measures. This package exports the specs of the `joint.*` measures.\n */\nexport interface MeasureSpec<Id extends string = string> {\n readonly id: Id;\n readonly unit: string;\n readonly direction: Direction;\n /** The lowest value. */\n readonly min: number;\n /** The highest value. The value `Infinity` tells that the measure has no upper limit. */\n readonly max: number;\n /** The family of the measure in the measure note of its engine. */\n readonly family?: string;\n /** The best value. Without it, the measure has no floor. */\n readonly floor?: number;\n /** The absolute tolerance at the floor. */\n readonly tol?: number;\n /**\n * The smallest change that counts as better or worse. A number is an absolute change. `{ rel }` is a share of the larger of the two values.\n * `docs/JOINT-MEASURES.md` gives the reason of each joint value.\n */\n readonly minEffect?: number | { readonly rel: number };\n /** The role of the measure in the joint selector. */\n readonly role?: \"guard\" | \"change-guard\" | \"diagnostic\" | \"time\";\n /** The shape kinds of the boxes that the measure supports. Without it, the measure supports only `rect`. `checkShapes` refuses the other kinds. */\n readonly shapes?: readonly ShapeKind[];\n /**\n * The kinds where the value is a bound of the true value, and its side. A kind is in `shapes` or in `bound.shapes`, not in the two lists.\n * `checkShapes` refuses a bound kind by default and with `{ level: \"safe\" }`. With `{ level: \"bound\" }`, it accepts it. `docs/SHAPES.md` tells what a bound value proves for each `direction`.\n */\n readonly bound?: ShapeBound;\n}\n\n/** The id of a joint measure. `docs/JOINT-MEASURES.md` gives the definitions. */\nexport type JointMeasureId =\n | \"joint.fill\"\n | \"joint.aspectError\"\n | \"joint.spill\"\n | \"joint.straight.crossings\"\n | \"joint.straight.length\"\n | \"joint.stability.mean\"\n | \"joint.stability.moved\"\n | \"joint.proxy.rank\"\n | \"joint.route.length\"\n | \"joint.ms\";\n\n/** The shape kinds of a joint measure that reads only the bounding boxes, the centers and the positions of the boxes. */\nconst BOUNDS_ONLY = SHAPE_KIND_IDS;\n/** The shape kinds of a joint measure that reads the area `w` by `h` of each box. */\nconst AREA: readonly ShapeKind[] = [\"rect\"];\n\n/**\n * The specs of the joint measures, in the order of `docs/JOINT-MEASURES.md`.\n * `joint.fill` and `joint.straight.length` read the area of each box, so they support only `rect`. `docs/SHAPES.md` tells the reasons.\n */\nexport const JOINT_MEASURES: readonly MeasureSpec<JointMeasureId>[] = /* @__PURE__ */ Object.freeze([\n { id: \"joint.fill\", minEffect: 0.001, unit: \"0 to 1\", direction: \"higher\", min: 0, max: 1, floor: 1, role: \"guard\", shapes: AREA },\n { id: \"joint.aspectError\", minEffect: 0.01, unit: \"natural log\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0.01, role: \"guard\", shapes: BOUNDS_ONLY },\n { id: \"joint.spill\", minEffect: 0.001, unit: \"0 to 1\", direction: \"lower\", min: 0, max: 1, floor: 0, tol: 0.001, role: \"guard\", shapes: BOUNDS_ONLY },\n { id: \"joint.straight.crossings\", minEffect: 0, unit: \"count\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0, role: \"guard\", shapes: BOUNDS_ONLY },\n { id: \"joint.straight.length\", minEffect: 0.01, unit: \"S for each edge\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0.01, role: \"guard\", shapes: AREA },\n { id: \"joint.stability.mean\", minEffect: 0.005, unit: \"W\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0.005, role: \"change-guard\", shapes: BOUNDS_ONLY },\n { id: \"joint.stability.moved\", minEffect: 0.02, unit: \"0 to 1\", direction: \"lower\", min: 0, max: 1, floor: 0, tol: 0.02, role: \"change-guard\", shapes: BOUNDS_ONLY },\n { id: \"joint.proxy.rank\", unit: \"-1 to 1\", direction: \"higher\", min: -1, max: 1, role: \"diagnostic\", shapes: BOUNDS_ONLY },\n { id: \"joint.route.length\", unit: \"layout units for each route\", direction: \"lower\", min: 0, max: Infinity, role: \"diagnostic\", shapes: BOUNDS_ONLY },\n { id: \"joint.ms\", unit: \"milliseconds\", direction: \"lower\", min: 0, max: Infinity, role: \"time\", shapes: BOUNDS_ONLY },\n] as const);\n\n/** The threshold of `joint.stability.moved`, in widths `W` of the base. */\nexport const JOINT_MOVED_MIN = 0.01;\n\n/** The result of a compare of a candidate with a baseline on one measure. A tie is not better. */\nexport type Verdict = \"better\" | \"worse\" | \"tie\";\n\n/**\n * This function gives the smallest change of a measure that counts between the values `a` and `b`.\n * The value is `max(RECORD_EPS, minEffect)`, or `max(RECORD_EPS, rel * max(|a|, |b|))` for a relative `minEffect`.\n * The larger value makes the threshold the same after a swap of `a` and `b`.\n */\nexport function minEffectOf(spec: Pick<MeasureSpec, \"minEffect\">, a = 0, b = 0): number {\n const m = spec.minEffect ?? 0;\n const t = typeof m === \"number\" ? m : m.rel * Math.max(Math.abs(a), Math.abs(b));\n return Math.max(RECORD_EPS, Number.isFinite(t) ? t : 0);\n}\n\n/** The slack of the threshold in grid steps. It absorbs only the float noise of the threshold, because the change is a whole number. */\nconst STEP_NOISE = 1e-6;\n\n/**\n * This function compares the value `candidate` with the value `baseline` of one measure on one input.\n * The compare uses whole grid steps of `RECORD_EPS`. Thus a live value and its rounded record give the same verdict.\n * A change of at most the threshold of `minEffectOf` in grid steps is a tie. A swap of the two values swaps better and worse.\n * Two equal values are a tie, also two infinite values. A value `NaN` is an error.\n */\nexport function compareMeasure(candidate: number, baseline: number, spec: Pick<MeasureSpec, \"direction\" | \"minEffect\">): Verdict {\n if (Number.isNaN(candidate) || Number.isNaN(baseline)) throw new RangeError(\"compareMeasure: a value is NaN\");\n if (candidate === baseline) return \"tie\";\n const a = Math.round(candidate * RECORD_SCALE);\n const b = Math.round(baseline * RECORD_SCALE);\n let delta: number;\n if (Number.isSafeInteger(a) && Number.isSafeInteger(b)) {\n delta = a - b;\n const m = spec.minEffect ?? 0;\n const t = typeof m === \"number\" ? m * RECORD_SCALE : m.rel * Math.max(Math.abs(a), Math.abs(b));\n if (Math.abs(delta) <= Math.max(1, Number.isFinite(t) ? t : 0) + STEP_NOISE) return \"tie\";\n } else {\n delta = candidate - baseline;\n if (!(Math.abs(delta) > minEffectOf(spec, candidate, baseline))) return \"tie\";\n }\n const better = spec.direction === \"lower\" ? delta < 0 : delta > 0;\n return better ? \"better\" : \"worse\";\n}\n","import { SIDES, type Rect, type Side } from \"./geometry.ts\";\nimport type { MeasureSpec } from \"./measures.ts\";\nimport { SHAPE_KIND_IDS, type ShapeKind } from \"./shapes.ts\";\n\n/** A placed box: its id and its bounding box. */\nexport interface PlacedBox extends Rect {\n readonly id: string;\n}\n\n/** The balance of one layout. `docs/BALANCE.md` gives the definitions. */\nexport interface Balance {\n /** The standard deviation of the nearest-neighbour gaps divided by their mean. */\n readonly gapCv: number;\n /** The distance from the centroid of the free area to the center of the container, as a share of the half-diagonal. */\n readonly centroidOffset: number;\n /** The empty share of the strip at each side of the container. */\n readonly side: Readonly<Record<Side, number>>;\n /** The largest value of `side` minus the smallest value. */\n readonly sideRange: number;\n}\n\n/** The depth of the strip of each side, as a share of the container. For `top` and `bottom`, it is a share of the height. For `left` and `right`, it is a share of the width. */\nexport const BALANCE_SIDE_DEPTH = 0.25;\n\n/** A suffix of a balance or stability measure. A stage adds its prefix, for example `pack.balance.gapCv`. */\nexport type BalanceMeasureSuffix =\n | \"balance.gapCv\"\n | \"balance.centroidOffset\"\n | \"balance.side.top\"\n | \"balance.side.right\"\n | \"balance.side.bottom\"\n | \"balance.side.left\"\n | \"balance.sideRange\"\n | \"stability.procrustes\"\n | \"stability.seed\";\n\n/** The suffixes of the balance and stability measures, in the order of `docs/BALANCE.md`. */\nexport const BALANCE_MEASURE_SUFFIXES: readonly BalanceMeasureSuffix[] = /* @__PURE__ */ Object.freeze([\n \"balance.gapCv\",\n \"balance.centroidOffset\",\n \"balance.side.top\",\n \"balance.side.right\",\n \"balance.side.bottom\",\n \"balance.side.left\",\n \"balance.sideRange\",\n \"stability.procrustes\",\n \"stability.seed\",\n] as const);\n\n/** This function gives the area of the overlap of two rectangles. */\nfunction overlapArea(a: Rect, b: Rect): number {\n const w = Math.min(a.x + a.w, b.x + b.w) - Math.max(a.x, b.x);\n const h = Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y);\n return w > 0 && h > 0 ? w * h : 0;\n}\n\n/** This function gives the distance between two rectangles. Two rectangles that touch or overlap give 0. */\nfunction rectDistance(a: Rect, b: Rect): number {\n const dx = Math.max(0, b.x - (a.x + a.w), a.x - (b.x + b.w));\n const dy = Math.max(0, b.y - (a.y + a.h), a.y - (b.y + b.h));\n return Math.hypot(dx, dy);\n}\n\n/**\n * This function gives the gap of each box to its nearest other box, in the order of `boxes`.\n * Each box scans the boxes sorted by `x` in the two directions. A scan stops when the distance on `x` alone is above the best gap of the box.\n * To the left, the distance on `x` is at least `a.x - b.x - maxW`, with `maxW` the largest width. With fewer than 2 boxes, a gap is `Infinity`.\n */\nexport function nearestGaps(boxes: readonly Rect[]): number[] {\n const order = boxes.map((_, i) => i).sort((i, j) => boxes[i]!.x - boxes[j]!.x || i - j);\n const maxW = boxes.reduce((m, b) => Math.max(m, b.w), 0);\n const gaps = new Array<number>(boxes.length).fill(Infinity);\n for (let k = 0; k < order.length; k++) {\n const a = boxes[order[k]!]!;\n let best = Infinity;\n for (let m = k + 1; m < order.length; m++) {\n const b = boxes[order[m]!]!;\n if (b.x - (a.x + a.w) > best) break;\n best = Math.min(best, rectDistance(a, b));\n }\n for (let m = k - 1; m >= 0; m--) {\n const b = boxes[order[m]!]!;\n if (a.x - b.x - maxW > best) break;\n best = Math.min(best, rectDistance(a, b));\n }\n gaps[order[k]!] = best;\n }\n return gaps;\n}\n\n/**\n * This function gives the balance of the placed boxes in the container: the evenness of the gaps and the place of the free space.\n * The boxes do not overlap, as in the output of a packer. The area of a box outside the container does not count.\n * `docs/BALANCE.md` gives the definitions and the reasons.\n */\nexport function balanceOf(boxes: readonly Rect[], container: Rect): Balance {\n const gaps = boxes.length < 2 ? [] : nearestGaps(boxes);\n const mean = gaps.length === 0 ? 0 : gaps.reduce((s, g) => s + g, 0) / gaps.length;\n const sd = gaps.length === 0 ? 0 : Math.sqrt(gaps.reduce((s, g) => s + (g - mean) ** 2, 0) / gaps.length);\n const gapCv = mean > 0 ? sd / mean : 0;\n\n const area = container.w * container.h;\n const cx = container.x + container.w / 2;\n const cy = container.y + container.h / 2;\n let used = 0;\n let mx = 0;\n let my = 0;\n for (const b of boxes) {\n const x0 = Math.max(b.x, container.x);\n const y0 = Math.max(b.y, container.y);\n const x1 = Math.min(b.x + b.w, container.x + container.w);\n const y1 = Math.min(b.y + b.h, container.y + container.h);\n if (x1 <= x0 || y1 <= y0) continue;\n const a = (x1 - x0) * (y1 - y0);\n used += a;\n mx += a * (x0 + x1) / 2;\n my += a * (y0 + y1) / 2;\n }\n const free = area - used;\n const half = Math.hypot(container.w, container.h) / 2;\n let centroidOffset = 0;\n if (free > 0 && half > 0) {\n const fx = (area * cx - mx) / free;\n const fy = (area * cy - my) / free;\n centroidOffset = Math.min(1, Math.hypot(fx - cx, fy - cy) / half);\n }\n\n const dh = container.h * BALANCE_SIDE_DEPTH;\n const dw = container.w * BALANCE_SIDE_DEPTH;\n const strips: Record<Side, Rect> = {\n top: { x: container.x, y: container.y, w: container.w, h: dh },\n right: { x: container.x + container.w - dw, y: container.y, w: dw, h: container.h },\n bottom: { x: container.x, y: container.y + container.h - dh, w: container.w, h: dh },\n left: { x: container.x, y: container.y, w: dw, h: container.h },\n };\n const side = {} as Record<Side, number>;\n for (const s of SIDES) {\n const strip = strips[s];\n const stripArea = strip.w * strip.h;\n const filled = boxes.reduce((sum, b) => sum + overlapArea(b, strip), 0);\n side[s] = stripArea > 0 ? Math.min(1, Math.max(0, 1 - filled / stripArea)) : 0;\n }\n const values = SIDES.map((s) => side[s]);\n return { gapCv, centroidOffset, side, sideRange: Math.max(...values) - Math.min(...values) };\n}\n\n/** The options of `procrustesOf`. */\nexport interface ProcrustesOptions {\n /** The unit of the result: the width `W` of the base, as in `joint.stability.mean`. A finite number above 0. */\n readonly unit: number;\n /** With `true` (the default), the alignment also rotates. With `false`, it only moves. */\n readonly rotate?: boolean;\n}\n\n/**\n * This function gives the root mean square move of the box centers from `base` to `next`, after the best alignment, in units of `unit`.\n * The alignment is the orthogonal Procrustes fit: one move and, by default, one rotation. Only the ids in the two lists count.\n * Fewer than 2 shared ids give 0, because the alignment then removes each move.\n */\nexport function procrustesOf(base: readonly PlacedBox[], next: readonly PlacedBox[], options: ProcrustesOptions): number {\n if (!(Number.isFinite(options.unit) && options.unit > 0)) throw new RangeError(`procrustesOf: the unit is a finite number above 0, not ${options.unit}.`);\n const after = new Map(next.map((b) => [b.id, b]));\n const a: [number, number][] = [];\n const b: [number, number][] = [];\n for (const p of base) {\n const q = after.get(p.id);\n if (q === undefined) continue;\n a.push([p.x + p.w / 2, p.y + p.h / 2]);\n b.push([q.x + q.w / 2, q.y + q.h / 2]);\n }\n const n = a.length;\n if (n < 2) return 0;\n const mean = (list: [number, number][]): [number, number] => [list.reduce((s, p) => s + p[0], 0) / n, list.reduce((s, p) => s + p[1], 0) / n];\n const [ax, ay] = mean(a);\n const [bx, by] = mean(b);\n let dot = 0;\n let cross = 0;\n for (let i = 0; i < n; i++) {\n const [px, py] = [a[i]![0] - ax, a[i]![1] - ay];\n const [qx, qy] = [b[i]![0] - bx, b[i]![1] - by];\n dot += px * qx + py * qy;\n cross += px * qy - py * qx;\n }\n const theta = options.rotate === false || (dot === 0 && cross === 0) ? 0 : Math.atan2(cross, dot);\n const cos = Math.cos(theta);\n const sin = Math.sin(theta);\n let sum = 0;\n for (let i = 0; i < n; i++) {\n const [px, py] = [a[i]![0] - ax, a[i]![1] - ay];\n const [qx, qy] = [b[i]![0] - bx, b[i]![1] - by];\n sum += (cos * px - sin * py - qx) ** 2 + (sin * px + cos * py - qy) ** 2;\n }\n return Math.sqrt(sum / n) / options.unit;\n}\n\n/**\n * This function gives the value of `stability.procrustes`: the move of `procrustesOf` divided by the change share.\n * The change share is `changed / count`, and it is at least `1 / count`. Thus a change of one box divides by the smallest share.\n */\nexport function perChange(move: number, changed: number, count: number): number {\n if (!(Number.isInteger(count) && count >= 1)) throw new RangeError(`perChange: the count is an integer of 1 or more, not ${count}.`);\n const share = Math.max(1, Math.min(count, changed)) / count;\n return move / share;\n}\n\n/** This function gives the balance values as measures, with the prefix of the stage, for example `pack.balance.gapCv`. */\nexport function balanceMeasures<S extends string>(stage: S, balance: Balance): Record<`${S}.${BalanceMeasureSuffix}`, number> {\n const m: Record<string, number> = {\n [`${stage}.balance.gapCv`]: balance.gapCv,\n [`${stage}.balance.centroidOffset`]: balance.centroidOffset,\n [`${stage}.balance.sideRange`]: balance.sideRange,\n };\n for (const s of SIDES) m[`${stage}.balance.side.${s}`] = balance.side[s];\n return m as Record<`${S}.${BalanceMeasureSuffix}`, number>;\n}\n\n/**\n * This function gives the specs of the balance and stability measures, with the prefix of the stage.\n * The balance measures read the area of each box, so they support only `rect`. The stability measures read only the centers.\n */\nexport function balanceMeasureSpecs<S extends string>(stage: S): readonly MeasureSpec<`${S}.${BalanceMeasureSuffix}`>[] {\n const id = (suffix: BalanceMeasureSuffix): `${S}.${BalanceMeasureSuffix}` => `${stage}.${suffix}`;\n const rect: readonly ShapeKind[] = [\"rect\"];\n const centers = SHAPE_KIND_IDS;\n return Object.freeze([\n { id: id(\"balance.gapCv\"), unit: \"ratio\", direction: \"lower\", min: 0, max: Infinity, minEffect: 0.01, family: \"balance\", shapes: rect },\n { id: id(\"balance.centroidOffset\"), unit: \"0 to 1\", direction: \"lower\", min: 0, max: 1, minEffect: 0.01, family: \"balance\", shapes: rect },\n ...SIDES.map((s) => ({ id: id(`balance.side.${s}`), unit: \"0 to 1\", direction: \"lower\" as const, min: 0, max: 1, family: \"balance\", role: \"diagnostic\" as const, shapes: rect })),\n { id: id(\"balance.sideRange\"), unit: \"0 to 1\", direction: \"lower\", min: 0, max: 1, minEffect: 0.02, family: \"balance\", shapes: rect },\n { id: id(\"stability.procrustes\"), unit: \"W for each change share\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0.005, minEffect: 0.005, family: \"stability\", role: \"change-guard\", shapes: centers },\n { id: id(\"stability.seed\"), unit: \"W\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0.005, minEffect: 0.005, family: \"stability\", shapes: centers },\n ]);\n}\n","/**\n * This function writes the UTF-8 bytes of a string into `out`, from the index `at`, and gives the index after the last byte.\n * With no `out`, it writes nothing and gives the count of the bytes. A lone surrogate gives the 3 bytes of its code.\n * It reads the UTF-16 code units, so it makes no string for each character (L81: `sha256Hex` allocated 2 GB in one pair).\n */\nexport function utf8Write(text: string, out?: Uint8Array, at = 0): number {\n let n = at;\n for (let i = 0; i < text.length; i++) {\n let c = text.charCodeAt(i);\n if (c >= 0xd800 && c < 0xdc00 && i + 1 < text.length) {\n const low = text.charCodeAt(i + 1);\n if (low >= 0xdc00 && low < 0xe000) {\n c = 0x10000 + ((c - 0xd800) << 10) + (low - 0xdc00);\n i++;\n }\n }\n if (c < 0x80) {\n if (out !== undefined) out[n] = c;\n n += 1;\n } else if (c < 0x800) {\n if (out !== undefined) {\n out[n] = 0xc0 | (c >> 6);\n out[n + 1] = 0x80 | (c & 63);\n }\n n += 2;\n } else if (c < 0x10000) {\n if (out !== undefined) {\n out[n] = 0xe0 | (c >> 12);\n out[n + 1] = 0x80 | ((c >> 6) & 63);\n out[n + 2] = 0x80 | (c & 63);\n }\n n += 3;\n } else {\n if (out !== undefined) {\n out[n] = 0xf0 | (c >> 18);\n out[n + 1] = 0x80 | ((c >> 12) & 63);\n out[n + 2] = 0x80 | ((c >> 6) & 63);\n out[n + 3] = 0x80 | (c & 63);\n }\n n += 4;\n }\n }\n return n;\n}\n\n/** This function gives the UTF-8 bytes of a string. It does not use `TextEncoder`, because `TextEncoder` encodes a lone surrogate as U+FFFD. */\nexport function utf8(text: string): Uint8Array {\n const bytes = new Uint8Array(utf8Write(text));\n utf8Write(text, bytes);\n return bytes;\n}\n","import { mulberry32 as homeMulberry32 } from \"@mark1russell7/rigor-generators\";\nimport { utf8 } from \"./utf8.ts\";\n\n/**\n * This function gives a generator of random numbers in [0, 1). It is `mulberry32`, as in `docs/FORMAT.md` of `packing`.\n * Its home is `@mark1russell7/rigor-generators`. This function keeps the name and the signature of the API.\n */\nexport function mulberry32(seed: number): () => number {\n return homeMulberry32(seed);\n}\n\n/**\n * This function gives the FNV-1a hash of 32 bits of the UTF-8 bytes of a string.\n * It stays here because `fnv1a32` of `@mark1russell7/rigor-generators` encodes a lone surrogate as U+FFFD. This function encodes the 3 bytes of its code.\n */\nexport function fnv1a32(text: string): number {\n let h = 0x811c9dc5;\n for (const b of utf8(text)) h = Math.imul(h ^ b, 0x01000193) >>> 0;\n return h;\n}\n\n/** This function gives the generator of one step of a seeded generator: `mulberry32(fnv1a32(\"<seed>:<step>\"))`. */\nexport function stepRandom(seed: number, step: string): () => number {\n return mulberry32(fnv1a32(`${seed}:${step}`));\n}\n\n/** This function gives a whole number from `lo` to `hi`, both included. */\nexport function randomInt(r: () => number, lo: number, hi: number): number {\n return lo + Math.floor(r() * (hi - lo + 1));\n}\n","import { SIDES, type Side } from \"./geometry.ts\";\nimport type { LayoutBox, LayoutEdge, LayoutGenerator, LayoutInput, Port } from \"./input.ts\";\nimport { randomInt, stepRandom } from \"./random.ts\";\n\n/**\n * The shape of the edges of `edgeStep`. The values are the cells of `edgeShape`, and `hubs`.\n * `hubs` waits for the next breaking change to become a value of `LayoutCell.edgeShape`.\n */\nexport type EdgeShape = \"random\" | \"clustered\" | \"hubChain\" | \"hubs\" | \"longRange\" | \"tree\" | \"bundled\";\n\n/** The parameters of `edgeStep`. */\nexport interface EdgeStepParams {\n readonly edgeDensity: \"sparse\" | \"medium\" | \"dense\";\n readonly edgeShape: EdgeShape;\n /** The default is `none`. */\n readonly groups?: \"none\" | \"flat\" | \"nested\";\n /** The default is `free`. */\n readonly ports?: \"free\" | \"sides\" | \"fixed\";\n /** The order of the hubs of `hubs` and `tree`: the largest box first, or a random order. The default is `area`. */\n readonly hubBy?: \"area\" | \"random\";\n}\n\n/**\n * The key of the edges of an input, in `data.collection`.\n * - `none`: the field is absent, so a router with the rule `collection` has no ways.\n * - `random`: a random name for each target box, so the key has no meaning.\n * - `cluster`: a name for each cluster of boxes, so the key follows the structure.\n */\nexport type EdgeKey = \"none\" | \"random\" | \"cluster\";\n\n/** The parameters of `edgeKeyStep`. */\nexport interface EdgeKeyParams {\n readonly edgeKey: EdgeKey;\n}\n\n/** The mean count of the edges of each box for each value of `edgeDensity`. */\nexport const EDGE_DENSITY: Readonly<Record<EdgeStepParams[\"edgeDensity\"], number>> = /* @__PURE__ */ Object.freeze({ sparse: 0.5, medium: 1.5, dense: 4 });\n\n/** The version of `edgeStep`. A change of its output gives a new version. */\nexport const EDGE_STEP_VERSION = 1;\n\n/** The version of `edgeKeyStep`. A change of its output gives a new version. */\nexport const EDGE_KEY_STEP_VERSION = 1;\n\nconst CLUSTER = 8;\nconst CHAIN = 32;\nconst INSIDE = 0.85;\nconst FAN_SHARE = 0.6;\nconst FIXED_SHARE = 0.2;\nconst COLLECTIONS = [\"users\", \"orders\", \"items\", \"events\"] as const;\n\nconst round3 = (x: number): number => Math.round(x * 1000) / 1000;\n\n/** This function gives the shuffled order of `n` boxes, from the first numbers of the stream `edges`. */\nfunction shuffledBoxes(n: number, r: () => number): number[] {\n const perm = Array.from({ length: n }, (_, i) => i);\n for (let i = n - 1; i > 0; i--) {\n const j = randomInt(r, 0, i);\n [perm[i], perm[j]] = [perm[j]!, perm[i]!];\n }\n return perm;\n}\n\n/** This function gives the cluster of each box from the shuffled order: each cluster has `CLUSTER` boxes. */\nfunction clustersOf(perm: readonly number[]): number[] {\n const clusterOf: number[] = new Array<number>(perm.length);\n perm.forEach((box, p) => (clusterOf[box] = Math.floor(p / CLUSTER)));\n return clusterOf;\n}\n\n/** This function gives the key of the boxes of one cluster. */\nconst clusterKey = (c: number): string => `${COLLECTIONS[c % COLLECTIONS.length]!}-${c}`;\n\n/**\n * This function gives the input with edges, groups and ports from its topology alone: a joint input has no positions before the pack.\n * The random numbers come from the steps `edges` and `ports` of `seed`. The function appends its stamp to `steps`, and removes the old `hash`.\n * The rules of each shape are in `docs/JOINT-CORPUS.md`.\n */\nexport function edgeStep(input: LayoutInput, params: EdgeStepParams, seed: number = input.seed ?? 0): LayoutInput {\n if ((input.edges?.length ?? 0) > 0) throw new RangeError(\"edgeStep: the input has edges already\");\n const full: Required<EdgeStepParams> = { groups: \"none\", ports: \"free\", hubBy: \"area\", ...params };\n const n = input.boxes.length;\n const r = stepRandom(seed, \"edges\");\n\n const perm = shuffledBoxes(n, r);\n const clusterOf = clustersOf(perm);\n const clusters = Math.ceil(n / CLUSTER);\n const members = (c: number): readonly number[] => perm.slice(c * CLUSTER, (c + 1) * CLUSTER);\n const collectionOf =\n full.edgeShape === \"bundled\"\n ? clusterOf.map(clusterKey)\n : input.boxes.map(() => COLLECTIONS[randomInt(r, 0, COLLECTIONS.length - 1)]!);\n const area = (i: number): number => input.boxes[i]!.w * input.boxes[i]!.h;\n const rank = full.hubBy === \"area\" ? input.boxes.map((_, i) => i).sort((a, b) => area(b) - area(a) || a - b) : perm;\n\n const pairs: [number, number][] = [];\n const seen = new Set<string>();\n const add = (u: number, v: number): void => {\n const key = u < v ? `${u}-${v}` : `${v}-${u}`;\n if (u === v || seen.has(key)) return;\n seen.add(key);\n pairs.push([u, v]);\n };\n const anyBox = (): number => randomInt(r, 0, n - 1);\n const inCluster = (c: number): number => {\n const m = members(c);\n return m[randomInt(r, 0, m.length - 1)]!;\n };\n const otherCluster = (c: number): number => {\n const o = randomInt(r, 0, clusters - 2);\n return o >= c ? o + 1 : o;\n };\n const target = Math.min(Math.round(n * EDGE_DENSITY[full.edgeDensity]), (n * (n - 1)) / 2);\n const fill = (pick: () => [number, number]): void => {\n for (let tries = 0; pairs.length < target && tries < target * 30; tries++) add(...pick());\n };\n const clustered = (): [number, number] => {\n const u = anyBox();\n return [u, r() < INSIDE ? inCluster(clusterOf[u]!) : anyBox()];\n };\n\n if (n >= 2) {\n switch (full.edgeShape) {\n case \"random\":\n fill(() => [anyBox(), anyBox()]);\n break;\n case \"clustered\":\n fill(clustered);\n break;\n case \"longRange\":\n fill(() => {\n const u = anyBox();\n return [u, clusters > 1 ? inCluster(otherCluster(clusterOf[u]!)) : anyBox()];\n });\n break;\n case \"hubs\":\n fill(() => [anyBox(), rank[Math.floor(n * r() ** 3)]!]);\n break;\n case \"tree\":\n for (let i = 1; i < n; i++) add(rank[randomInt(r, 0, i - 1)]!, rank[i]!);\n break;\n case \"hubChain\": {\n const k = Math.ceil(n / CHAIN);\n const length = Math.ceil(n / k);\n const chains = Array.from({ length: k }, (_, c) => perm.slice(c * length, (c + 1) * length));\n for (const chain of chains) for (let i = 0; i + 1 < chain.length; i++) add(chain[i]!, chain[i + 1]!);\n const skips = Math.max(0, target - pairs.length);\n for (let s = 0; s < skips; s++) {\n const c = k > 1 ? randomInt(r, 0, k - 2) : 0;\n const from = chains[c]!;\n const to = chains[k > 1 ? c + 1 : 0]!;\n const i = randomInt(r, 0, from.length - 1);\n const j = i + Math.floor(from.length / 8) + randomInt(r, 0, Math.floor(from.length / 2));\n if (j < to.length) add(from[i]!, to[j]!);\n }\n break;\n }\n case \"bundled\":\n for (let rounds = 0; pairs.length < target * FAN_SHARE && clusters > 1 && rounds < target; rounds++) {\n const u = anyBox();\n const c = otherCluster(clusterOf[u]!);\n const fan = randomInt(r, 4, 15);\n for (let f = 0; f < fan && pairs.length < target; f++) add(u, inCluster(c));\n }\n fill(clustered);\n break;\n }\n }\n\n const rp = stepRandom(seed, \"ports\");\n const ports: Port[][] = input.boxes.map((b) => [...(b.ports ?? [])]);\n const portOn = (box: LayoutBox, id: string, side: Side, fixed: boolean): Port => {\n if (!fixed) return { id, side };\n const along = round3(rp() * (side === \"top\" || side === \"bottom\" ? box.w : box.h));\n const at = { top: [along, 0], bottom: [along, box.h], left: [0, along], right: [box.w, along] }[side];\n return { id, side, x: at[0]!, y: at[1]! };\n };\n const out = new Set<number>();\n if (full.ports === \"fixed\") {\n input.boxes.forEach((box, i) => {\n if (rp() >= FIXED_SHARE) return;\n const side = SIDES[randomInt(rp, 0, 3)]!;\n ports[i]!.push(portOn(box, \"out\", side, true));\n out.add(i);\n });\n }\n const edges: LayoutEdge[] = pairs.map(([u, v], k) => {\n const id = `e${k}`;\n const s = input.boxes[u]!;\n const t = input.boxes[v]!;\n let ends: { sourcePort?: string; targetPort?: string } = {};\n if (full.ports === \"sides\") {\n ports[u]!.push(portOn(s, `${id}.s`, SIDES[randomInt(rp, 0, 3)]!, false));\n ports[v]!.push(portOn(t, `${id}.t`, SIDES[randomInt(rp, 0, 3)]!, false));\n ends = { sourcePort: `${id}.s`, targetPort: `${id}.t` };\n } else if (out.has(u)) {\n ends = { sourcePort: \"out\" };\n }\n return { id, source: s.id, target: t.id, ...ends, data: { collection: collectionOf[v]! } };\n });\n\n const boxes = input.boxes.map((box, i): LayoutBox => {\n const c = clusterOf[i]!;\n const group = full.groups === \"none\" ? undefined : `g${c}`;\n const path = full.groups === \"nested\" ? `G${Math.floor(c / 4)}/g${c}` : group;\n return {\n ...box,\n ...(group === undefined ? {} : { group, data: { ...box.data, group: path } }),\n ...(ports[i]!.length === 0 ? {} : { ports: ports[i]! }),\n };\n });\n const stamp: LayoutGenerator = { name: \"edges\", version: EDGE_STEP_VERSION, params: { ...full }, seed };\n const { hash: _old, ...rest } = input;\n return { ...rest, boxes, edges, steps: [...(input.steps ?? []), stamp] };\n}\n\n/**\n * This function gives the input with a stated key on each edge. The edges stay the same in all but `data.collection`, so the 3 values of `edgeKey` read one factor.\n * The key of an edge depends on its target box, as in `edgeStep`.\n * The value `cluster` uses the clusters of `edgeStep` with the same seed and box order, so this step comes directly after `edgeStep`. On the shape `bundled` it gives the keys of `edgeStep`.\n * The value `random` uses the stream `edge-key`, so it does not change the numbers of `edgeStep`. The function appends its stamp to `steps`, and removes the old `hash`.\n * It throws a `RangeError` for an edge with an unknown target.\n */\nexport function edgeKeyStep(input: LayoutInput, params: EdgeKeyParams, seed: number = input.seed ?? 0): LayoutInput {\n const n = input.boxes.length;\n const keys = (): readonly string[] => {\n if (params.edgeKey === \"cluster\") return clustersOf(shuffledBoxes(n, stepRandom(seed, \"edges\"))).map(clusterKey);\n const r = stepRandom(seed, \"edge-key\");\n return input.boxes.map(() => COLLECTIONS[randomInt(r, 0, COLLECTIONS.length - 1)]!);\n };\n const keyOf = params.edgeKey === \"none\" ? [] : keys();\n const indexOf = new Map(input.boxes.map((box, i) => [box.id, i]));\n const edges = input.edges?.map((edge): LayoutEdge => {\n const { data: oldData, ...plain } = edge;\n const { collection: _old, ...data } = oldData ?? {};\n if (params.edgeKey === \"none\") return Object.keys(data).length === 0 ? plain : { ...plain, data };\n const target = indexOf.get(edge.target);\n if (target === undefined) throw new RangeError(`edgeKeyStep: the edge \"${edge.id}\" has the unknown target \"${edge.target}\".`);\n return { ...plain, data: { ...data, collection: keyOf[target]! } };\n });\n const stamp: LayoutGenerator = { name: \"edge-key\", version: EDGE_KEY_STEP_VERSION, params: { edgeKey: params.edgeKey }, seed };\n const { hash: _oldHash, edges: _oldEdges, ...rest } = input;\n return { ...rest, ...(edges === undefined ? {} : { edges }), steps: [...(input.steps ?? []), stamp] };\n}\n","import { canonicalInput, type LayoutInput } from \"./input.ts\";\nimport type { PackOutput } from \"./output.ts\";\nimport { RECORD_EPS } from \"./tolerance.ts\";\nimport { utf8Write } from \"./utf8.ts\";\n\n/** The round constants of SHA-256. */\nconst K: readonly number[] = [\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe,\n 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,\n 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,\n 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n];\n\n/**\n * This function gives the SHA-256 digest of the UTF-8 bytes of a string, as 64 lowercase hex characters.\n * It uses no API of Node or of the browser.\n */\nexport function sha256Hex(text: string): string {\n // The bytes go straight into the padded buffer, so the digest makes one array, not a list of the bytes and a copy.\n const length = utf8Write(text);\n const bits = length * 8;\n const total = Math.ceil((length + 9) / 64) * 64;\n const data = new Uint8Array(total);\n utf8Write(text, data);\n data[length] = 0x80;\n const view = new DataView(data.buffer);\n view.setUint32(total - 8, Math.floor(bits / 0x100000000));\n view.setUint32(total - 4, bits >>> 0);\n const h = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];\n const w = new Uint32Array(64);\n const rotr = (x: number, n: number): number => (x >>> n) | (x << (32 - n));\n for (let off = 0; off < total; off += 64) {\n for (let i = 0; i < 16; i++) w[i] = view.getUint32(off + 4 * i);\n for (let i = 16; i < 64; i++) {\n const a = w[i - 15]!;\n const b = w[i - 2]!;\n const s0 = rotr(a, 7) ^ rotr(a, 18) ^ (a >>> 3);\n const s1 = rotr(b, 17) ^ rotr(b, 19) ^ (b >>> 10);\n w[i] = (w[i - 16]! + s0 + w[i - 7]! + s1) >>> 0;\n }\n let [a, b, c, d, e, f, g, k] = h as [number, number, number, number, number, number, number, number];\n for (let i = 0; i < 64; i++) {\n const s1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);\n const ch = (e & f) ^ (~e & g);\n const t1 = (k + s1 + ch + K[i]! + w[i]!) >>> 0;\n const s0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);\n const maj = (a & b) ^ (a & c) ^ (b & c);\n const t2 = (s0 + maj) >>> 0;\n k = g;\n g = f;\n f = e;\n e = (d + t1) >>> 0;\n d = c;\n c = b;\n b = a;\n a = (t1 + t2) >>> 0;\n }\n h[0] = (h[0]! + a) >>> 0;\n h[1] = (h[1]! + b) >>> 0;\n h[2] = (h[2]! + c) >>> 0;\n h[3] = (h[3]! + d) >>> 0;\n h[4] = (h[4]! + e) >>> 0;\n h[5] = (h[5]! + f) >>> 0;\n h[6] = (h[6]! + g) >>> 0;\n h[7] = (h[7]! + k) >>> 0;\n }\n return h.map((x) => x.toString(16).padStart(8, \"0\")).join(\"\");\n}\n\n/**\n * This function gives the canonical form of a value: sorted keys and no whitespace, with the numbers of `JSON.stringify`.\n * A key with the value `undefined` is not in the form. An `undefined` in an array becomes `null`.\n */\nexport function canonicalJson(value: unknown): string {\n if (value === null || typeof value !== \"object\") return JSON.stringify(value) ?? \"null\";\n if (Array.isArray(value)) return `[${value.map((v: unknown) => (v === undefined ? \"null\" : canonicalJson(v))).join(\",\")}]`;\n const o = value as Record<string, unknown>;\n const keys = Object.keys(o)\n .filter((k) => o[k] !== undefined)\n .sort();\n return `{${keys.map((k) => `${JSON.stringify(k)}:${canonicalJson(o[k])}`).join(\",\")}}`;\n}\n\n/** The options of `outputHash` and `documentHash`. */\nexport interface HashOptions {\n /**\n * The step of the grid of the numbers. The default is `RECORD_EPS`, so a number keeps 3 decimals.\n * The value `0` keeps the exact numbers. A negative value or a value that is not finite causes a `RangeError`.\n */\n readonly grid?: number;\n /**\n * The names of the fields that the hash does not read, at each depth. Use it for report fields, for example a trace or a time.\n * A field with one of these names is out of the form in each object of the value, also in an object in a list.\n */\n readonly skip?: readonly string[];\n}\n\n/** This function gives the factor of a grid: `1 / grid`, or `undefined` for the exact numbers. */\nfunction gridFactor(options: HashOptions): number | undefined {\n const grid = options.grid ?? RECORD_EPS;\n if (!Number.isFinite(grid) || grid < 0) throw new RangeError(`The grid ${grid} is not a finite number of 0 or more.`);\n return grid === 0 ? undefined : 1 / grid;\n}\n\n/**\n * This function gives a copy of a value with each number on the grid. The value `-0` becomes `0`.\n * It throws a `RangeError` for a number that is not finite.\n */\nfunction onGrid(value: unknown, path: string, k: number | undefined, skip: ReadonlySet<string>): unknown {\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) throw new RangeError(`The value has the number ${value} at ${path}. JSON has no form for it.`);\n if (k === undefined) return value;\n const r = Math.round(value * k) / k;\n if (!Number.isFinite(r)) throw new RangeError(`The number at ${path} is too large for the grid.`);\n return r === 0 ? 0 : r;\n }\n if (value === null || typeof value !== \"object\") return value;\n if (Array.isArray(value)) return value.map((v: unknown, i) => onGrid(v, `${path}[${i}]`, k, skip));\n const o = value as Record<string, unknown>;\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(o)) if (!skip.has(key)) out[key] = onGrid(o[key], `${path}.${key}`, k, skip);\n return out;\n}\n\n/**\n * This function gives the hash of an output: the first 16 hex characters of the SHA-256 of its canonical form.\n * Before the canonical form, each number goes to the nearest point of the grid, and `-0` becomes `0`.\n * With the default grid, the rounding is `round3` of `packing`: `Math.round(x * 1000) / 1000`.\n * The function throws a `RangeError` for `NaN` and for an infinite number. The fields of `options.skip` are out of the form.\n *\n * The grid can split two outputs. Two numbers near a rounding boundary can go to two different points.\n * The grid can also merge two outputs whose numbers go to the same points. This merge is intentional: it removes the noise of floating-point numbers.\n */\nexport function outputHash(value: unknown, options: HashOptions = {}): string {\n return sha256Hex(canonicalJson(onGrid(value, \"$\", gridFactor(options), new Set(options.skip ?? [])))).slice(0, 16);\n}\n\n/** This function throws a `RangeError` when a list of the output has an id two times. A packer with this output has a bug. */\nfunction uniqueIds(list: string, ids: readonly string[]): void {\n const seen = new Set<string>();\n for (const id of ids) {\n if (seen.has(id)) throw new RangeError(`The list ${list} of the output has the id \"${id}\" two times.`);\n seen.add(id);\n }\n}\n\n/** The order of two ids by their UTF-16 code units. It does not change with the locale. */\nfunction byId(a: { readonly id: string }, b: { readonly id: string }): number {\n return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;\n}\n\n/**\n * This function gives the normal form of the output of a packer, for a fingerprint.\n * The form has the placements, the overflow, the size and the moved obstacles. It does not have the trace.\n * The placements, the moved obstacles and the overflow are in the order of their ids. A placement without `turn` gets `turn: 0`.\n * Thus two packers with the same result in a different order have the same form.\n * The function throws a `RangeError` when `placements`, `overflow` or `moved` has an id two times.\n */\nexport function packOutputForm(output: PackOutput): unknown {\n uniqueIds(\"placements\", output.placements.map((p) => p.id));\n uniqueIds(\"overflow\", output.overflow);\n uniqueIds(\"moved\", output.moved.map((m) => m.id));\n return {\n placements: output.placements.map((p) => ({ id: p.id, x: p.x, y: p.y, turn: p.turn ?? 0 })).sort(byId),\n overflow: [...output.overflow].sort(),\n size: { w: output.size.w, h: output.size.h },\n moved: output.moved.map((m) => ({ id: m.id, x: m.x, y: m.y })).sort(byId),\n };\n}\n\n/** The hash of a probe that the strategy refused or does not support. It has no reason text, so a new text of a refusal does not change a fingerprint. */\nexport const REFUSED_PROBE = \"refused\";\n\n/**\n * This function gives the hash of one probe of a strategy. It calls `run` and gives `outputHash` of its result, with exact numbers by default.\n * When `run` throws an error that `refused` accepts, the function gives `REFUSED_PROBE`. It throws each other error again.\n * The option `grid` of `options` puts the numbers on a grid. Its default here is `0`, so a change in a number changes the hash.\n */\nexport function probeHash(run: () => unknown, refused: (error: unknown) => boolean, options: HashOptions = {}): string {\n let value: unknown;\n try {\n value = run();\n } catch (error) {\n if (refused(error)) return REFUSED_PROBE;\n throw error;\n }\n return outputHash(value, { ...options, grid: options.grid ?? 0 });\n}\n\n/**\n * This function gives the fingerprint of the outputs of one strategy: one hash of the hashes of its probes.\n * The key of `hashes` is the id of a probe, and its value is the hash of the probe, from `probeHash`.\n * The order of the keys does not change the fingerprint. A new probe, a probe less or a changed hash changes it.\n * The function throws a `RangeError` when there is no probe.\n */\nexport function fingerprintOf(hashes: Readonly<Record<string, string>>): string {\n if (Object.keys(hashes).length === 0) throw new RangeError(\"A fingerprint needs one probe or more.\");\n return sha256Hex(canonicalJson(hashes)).slice(0, 16);\n}\n\n/**\n * This function gives the hash of a document. It uses the rule of `outputHash`, but the form does not include the field `hash` of the document.\n * With the default grid, it is the input hash of `docs/FORMAT.md` of `packing`.\n * A document with the schema `layout-input/1` goes through `canonicalInput` first. Thus the order of its `pairGaps` does not change the hash.\n */\nexport function documentHash(doc: object, options: HashOptions = {}): string {\n const { hash: _hash, ...rest } = doc as { readonly hash?: unknown; readonly schema?: unknown };\n return outputHash(rest.schema === \"layout-input/1\" ? canonicalInput(rest as unknown as LayoutInput) : rest, options);\n}\n\n/** One output group: the candidates with the same output hash on each decision input. */\nexport interface OutputGroup {\n /** The id of the group: its first member. */\n readonly id: string;\n /** The ids of the candidates of the group, in sorted order. */\n readonly members: readonly string[];\n}\n\n/**\n * This function gives the output groups of the candidates. The key of `hashes` is the id of a candidate.\n * Its value is the list of the output hashes of the candidate, in the order of the decision inputs.\n * Candidates with equal lists make one group. The groups are in the order of their ids.\n * The function throws a `RangeError` when two lists have different lengths.\n */\nexport function outputGroups(hashes: Readonly<Record<string, readonly string[]>>): OutputGroup[] {\n const byList = new Map<string, string[]>();\n let first: string | undefined;\n for (const id of Object.keys(hashes)) {\n const list = hashes[id]!;\n if (first === undefined) first = id;\n else if (list.length !== hashes[first]!.length)\n throw new RangeError(`The candidate \"${id}\" has ${list.length} hashes, but \"${first}\" has ${hashes[first]!.length}.`);\n const key = JSON.stringify(list);\n const members = byList.get(key);\n if (members) members.push(id);\n else byList.set(key, [id]);\n }\n const groups = [...byList.values()].map((members): OutputGroup => {\n const sorted = [...members].sort();\n return { id: sorted[0]!, members: sorted };\n });\n return groups.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));\n}\n\n/** The evidence that a candidate is exercised on its decision inputs. */\nexport interface ExerciseEvidence {\n /** The move counts of the candidate, by name. A record keeps each one as the trace measure `move.<name>`. */\n readonly moves?: Readonly<Record<string, number>>;\n /** The output hashes of the candidate, in the order of the decision inputs. */\n readonly hashes?: readonly string[];\n /** The output hashes of the base of the candidate, in the same order. */\n readonly baseHashes?: readonly string[];\n}\n\n/**\n * This function tells if a candidate is exercised. It gives `true` when a move count is more than 0.\n * It also gives `true` when `hashes` and `baseHashes` are different at one place or more.\n * Without evidence, it gives `false`.\n * The function throws a `RangeError` when only one of the two lists is given, or when their lengths are different.\n */\nexport function exercised(evidence: ExerciseEvidence): boolean {\n const { moves, hashes, baseHashes } = evidence;\n if ((hashes === undefined) !== (baseHashes === undefined)) throw new RangeError(\"The evidence must have both hashes and baseHashes, or neither of them.\");\n if (hashes && baseHashes && hashes.length !== baseHashes.length)\n throw new RangeError(`The candidate has ${hashes.length} hashes, but its base has ${baseHashes.length}.`);\n if (moves && Object.values(moves).some((n) => n > 0)) return true;\n if (hashes && baseHashes) return hashes.some((h, i) => h !== baseHashes[i]);\n return false;\n}\n","import { outputHash } from \"./hash.ts\";\nimport { compareMeasure, type MeasureSpec } from \"./measures.ts\";\n\n/** The part of a `MeasureSpec` that a pick uses: the direction and the `minEffect`. */\nexport type PickSpec = Pick<MeasureSpec, \"direction\" | \"minEffect\">;\n\n/** A member of a portfolio: a function with an id. A portfolio is also a member. */\nexport interface Member<I, O> {\n readonly id: string;\n /** This function gives the output of the member for an input. */\n run(input: I): O;\n}\n\n/** One level of the key of a portfolio: a measure of an output. */\nexport interface PortfolioLevel<I, O> {\n /** The id of the level. The id `hard` is reserved. */\n readonly id: string;\n readonly spec: PickSpec;\n /** This function gives the value of the measure for the output of a member. The value must be finite. */\n value(input: I, output: O): number;\n}\n\n/** The key of a portfolio: the hard level, then the other levels in order. */\nexport interface PortfolioKey<I, O> {\n /** This function gives the count of hard breaks. It is level 0, with the direction `lower` and the `minEffect` 0. */\n hard(input: I, output: O): number;\n /** The levels after the hard level, in the order of the pick. */\n readonly levels: readonly PortfolioLevel<I, O>[];\n /** This function gives the hash of an output. The default is `outputHash` with the default grid. */\n hash?(output: O): string;\n}\n\n/** The options of a portfolio. */\nexport interface PortfolioOptions {\n /** The time limit in milliseconds, 0 or more. The first member always starts. A member that starts always finishes. */\n readonly budgetMs?: number;\n /** The largest count of members that run, a whole number of 1 or more. The other members are cut. */\n readonly maxMembers?: number;\n /** The clock in milliseconds. The default is `performance.now`, or `Date.now` without `performance`. */\n readonly now?: () => number;\n /**\n * The members that get an output hash. The default `all` hashes each member with the status `ran`. A hash that throws then gives the status `error`.\n * With `pick`, only member 0 and the winner get a hash, and only when the winner is not member 0. Then a hash that throws makes `pick` throw.\n */\n readonly hashes?: \"all\" | \"pick\";\n}\n\n/** The status of a member in a pick. */\nexport type MemberStatus = \"ran\" | \"cut\" | \"error\";\n\n/** The trace of one member in a pick. */\nexport interface MemberTrace {\n readonly id: string;\n readonly status: MemberStatus;\n /** The value of each level, with the key `hard` for the hard level. Only a member with the status `ran` has values. */\n readonly values?: Readonly<Record<string, number>>;\n /** The time of the run of the member, in milliseconds. */\n readonly ms?: number;\n /**\n * The hash of the output of the member. Under the option `hashes` \"all\" (the default), each member with the status `ran` has it.\n * Under `hashes` \"pick\", it is absent, except for member 0 and the winner when the winner is not member 0.\n */\n readonly outputHash?: string;\n /** The message of the error of a member with the status `error`. */\n readonly error?: string;\n}\n\n/** The trace of one pick of a portfolio. */\nexport interface PortfolioTrace {\n /** One entry for each member, in the order of the members. A cut member is also in the list. */\n readonly members: readonly MemberTrace[];\n readonly winner: string;\n /** The index of the winner in the list of the members. */\n readonly winnerIndex: number;\n /** The value `true` tells that the winner is not member 0 and has a different output hash. */\n readonly picked: boolean;\n /** The time of the full pick, in milliseconds. */\n readonly totalMs: number;\n readonly budgetMs?: number;\n readonly maxMembers?: number;\n /** The count of the cut members. */\n readonly cut: number;\n /** The value `false` tells that the time limit cut one member or more. Then a run on a different computer can give a different pick. */\n readonly deterministic: boolean;\n /** The ids of the members that stay in after each level of `selectBest`. The first list is for the hard level. */\n readonly kept: readonly (readonly string[])[];\n}\n\n/** The result of one pick of a portfolio: the output of the winner, its id and the trace. */\nexport interface PortfolioPick<O> {\n readonly output: O;\n readonly winner: string;\n readonly trace: PortfolioTrace;\n}\n\n/** A portfolio: a member that runs its members and gives the output of the best member. */\nexport interface Portfolio<I, O> extends Member<I, O> {\n /** This function starts the members on an input and gives the output of the winner with the trace. */\n pick(input: I): PortfolioPick<O>;\n}\n\n/** A candidate of `selectBest`: an id and the value of each level. */\nexport interface SelectCandidate {\n readonly id: string;\n readonly values: Readonly<Record<string, number>>;\n}\n\n/** A level of `selectBest`: the id of a value and its spec. */\nexport interface SelectLevel {\n readonly id: string;\n readonly spec: PickSpec;\n}\n\n/** The result of `selectBest`. */\nexport interface Selection {\n readonly winner: string;\n /** The ids of the candidates that stay in after each level, in the given order. */\n readonly kept: readonly (readonly string[])[];\n}\n\n/**\n * This function picks the best candidate. For each level, it finds the best value of the candidates that stay in.\n * It keeps each candidate that is not worse than that best value by `compareMeasure`.\n * The winner is the first candidate, in the given order, that stays in after the last level.\n * Without levels, the winner is the first candidate and `kept` is empty.\n *\n * The reason for the rule: a scan that compares each candidate with the current winner is not transitive, because of the `minEffect` ties.\n * Such a scan can drift away from the best value. An example: \"a\" is lower with the `minEffect` 0.005, and \"b\" is higher.\n * The candidates A (0, 1), B (0.004, 2) and C (0.008, 3) give the winner B.\n * The scan picks C, but A is better than C on \"a\".\n *\n * The function throws a `RangeError` for an empty list of candidates, for a missing value, and for a value that is not finite.\n */\nexport function selectBest(candidates: readonly SelectCandidate[], levels: readonly SelectLevel[]): Selection {\n if (candidates.length === 0) throw new RangeError(\"selectBest: the list of candidates is empty.\");\n for (const level of levels) {\n for (const c of candidates) {\n const v = c.values[level.id];\n if (typeof v !== \"number\") throw new RangeError(`selectBest: the candidate \"${c.id}\" has no value for the level \"${level.id}\".`);\n if (!Number.isFinite(v)) throw new RangeError(`selectBest: the candidate \"${c.id}\" has the value ${v} for the level \"${level.id}\".`);\n }\n }\n let alive: readonly SelectCandidate[] = candidates;\n const kept: (readonly string[])[] = [];\n for (const level of levels) {\n const at = (c: SelectCandidate): number => c.values[level.id]!;\n let best = at(alive[0]!);\n for (const c of alive) best = level.spec.direction === \"lower\" ? Math.min(best, at(c)) : Math.max(best, at(c));\n alive = alive.filter((c) => compareMeasure(at(c), best, level.spec) !== \"worse\");\n kept.push(alive.map((c) => c.id));\n }\n return { winner: alive[0]!.id, kept };\n}\n\n/** This function gives the move `pick` of a pick: 1 when `picked` is true, else 0. A record keeps it as the trace measure `move.pick`. */\nexport function pickMoves(trace: Pick<PortfolioTrace, \"picked\">): { pick: number } {\n return { pick: trace.picked ? 1 : 0 };\n}\n\n/** This function gives the default clock: `performance.now`, or `Date.now` without `performance`. */\nfunction defaultClock(): () => number {\n const perf = (globalThis as { readonly performance?: { now(): number } }).performance;\n return perf ? () => perf.now() : () => Date.now();\n}\n\n/** This function gives the message of an error value. */\nfunction messageOf(e: unknown): string {\n return e instanceof Error ? e.message : String(e);\n}\n\n/** This function throws a `RangeError` for an empty list of members or for two members with the same id. */\nfunction checkMembers(id: string, members: readonly Member<unknown, unknown>[]): void {\n if (members.length === 0) throw new RangeError(`The portfolio \"${id}\" has no members.`);\n const seen = new Set<string>();\n for (const m of members) {\n if (seen.has(m.id)) throw new RangeError(`The portfolio \"${id}\" has two members with the id \"${m.id}\".`);\n seen.add(m.id);\n }\n}\n\n/** The result of the run of one member. */\ntype Ran<O> = { readonly ok: true; readonly output: O; readonly values: Record<string, number>; readonly hash?: string } | { readonly ok: false; readonly error: unknown };\n\n/**\n * This function makes a portfolio. Its `pick` starts the members in their order. `selectBest` picks the winner of the members with the status `ran`.\n * The first level is the hard level, then the levels of the key follow.\n * `members` is a list, or a function of the input that gives the list.\n *\n * A member that throws, or that gives a value that is not finite, gets the status `error`. It does not win.\n * When each member has an error, `pick` throws the error of the first member.\n * `docs/PORTFOLIO.md` tells the rules of the time limit, the trace and `picked`.\n *\n * The function throws a `RangeError` for a level with the id `hard`, for two levels with the same id and for a bad option.\n * It also throws a `RangeError` for an empty list of members, or for two members with the same id.\n */\nexport function portfolio<I, O>(\n id: string,\n members: readonly Member<I, O>[] | ((input: I) => readonly Member<I, O>[]),\n key: PortfolioKey<I, O>,\n options: PortfolioOptions = {},\n): Portfolio<I, O> {\n const levelIds = new Set<string>();\n for (const level of key.levels) {\n if (level.id === \"hard\") throw new RangeError(`The portfolio \"${id}\" has a level with the reserved id \"hard\".`);\n if (levelIds.has(level.id)) throw new RangeError(`The portfolio \"${id}\" has two levels with the id \"${level.id}\".`);\n levelIds.add(level.id);\n }\n const { budgetMs, maxMembers, hashes = \"all\" } = options;\n if (budgetMs !== undefined && !(budgetMs >= 0)) throw new RangeError(`The portfolio \"${id}\" has the budgetMs ${budgetMs}. It must be 0 or more.`);\n if (maxMembers !== undefined && !(Number.isInteger(maxMembers) && maxMembers >= 1))\n throw new RangeError(`The portfolio \"${id}\" has the maxMembers ${maxMembers}. It must be a whole number of 1 or more.`);\n if (hashes !== \"all\" && hashes !== \"pick\") throw new RangeError(`The portfolio \"${id}\" has the hashes ${String(hashes)}. It must be \"all\" or \"pick\".`);\n if (typeof members !== \"function\") checkMembers(id, members);\n const levels: readonly SelectLevel[] = [{ id: \"hard\", spec: { direction: \"lower\", minEffect: 0 } }, ...key.levels.map((l) => ({ id: l.id, spec: l.spec }))];\n const now = options.now ?? defaultClock();\n\n /** This function gives the hash of the output of a member. A hash that throws causes a `RangeError`. */\n const hashOf = (m: Member<I, O>, output: O): string => {\n try {\n return key.hash ? key.hash(output) : outputHash(output);\n } catch (e) {\n throw new RangeError(`The hash of the member \"${m.id}\" of the portfolio \"${id}\" throws: ${messageOf(e)}`, { cause: e });\n }\n };\n\n const evaluate = (m: Member<I, O>, input: I, output: O): Ran<O> => {\n const values: Record<string, number> = {};\n const measure = (level: string, f: () => number): void => {\n let v: number;\n try {\n v = f();\n } catch (e) {\n throw new RangeError(`The level \"${level}\" of the member \"${m.id}\" of the portfolio \"${id}\" throws: ${messageOf(e)}`, { cause: e });\n }\n if (typeof v !== \"number\" || !Number.isFinite(v))\n throw new RangeError(`The member \"${m.id}\" of the portfolio \"${id}\" has the value ${v} for the level \"${level}\".`);\n values[level] = v;\n };\n try {\n measure(\"hard\", () => key.hard(input, output));\n for (const level of key.levels) measure(level.id, () => level.value(input, output));\n if (hashes === \"pick\") return { ok: true, output, values };\n return { ok: true, output, values, hash: hashOf(m, output) };\n } catch (e) {\n return { ok: false, error: e };\n }\n };\n\n const pick = (input: I): PortfolioPick<O> => {\n const list = typeof members === \"function\" ? members(input) : members;\n if (typeof members === \"function\") checkMembers(id, list);\n const start = now();\n const traces: MemberTrace[] = [];\n const outputs = new Map<string, O>();\n const ran: SelectCandidate[] = [];\n let firstError: { readonly error: unknown } | undefined;\n let cut = 0;\n let outOfTime = false;\n for (let i = 0; i < list.length; i++) {\n const m = list[i]!;\n if (maxMembers !== undefined && i >= maxMembers) {\n traces.push({ id: m.id, status: \"cut\" });\n cut++;\n continue;\n }\n if (i > 0 && budgetMs !== undefined && (outOfTime || now() - start >= budgetMs)) {\n outOfTime = true;\n traces.push({ id: m.id, status: \"cut\" });\n cut++;\n continue;\n }\n const t0 = now();\n let result: Ran<O>;\n let ms: number;\n try {\n const output = m.run(input);\n ms = now() - t0;\n result = evaluate(m, input, output);\n } catch (e) {\n ms = now() - t0;\n result = { ok: false, error: e };\n }\n if (result.ok) {\n traces.push(\n result.hash === undefined\n ? { id: m.id, status: \"ran\", values: result.values, ms }\n : { id: m.id, status: \"ran\", values: result.values, ms, outputHash: result.hash },\n );\n outputs.set(m.id, result.output);\n ran.push({ id: m.id, values: result.values });\n } else {\n traces.push({ id: m.id, status: \"error\", ms, error: messageOf(result.error) });\n firstError ??= { error: result.error };\n }\n }\n if (ran.length === 0) throw firstError!.error;\n const { winner, kept } = selectBest(ran, levels);\n const winnerIndex = traces.findIndex((t) => t.id === winner);\n if (hashes === \"pick\" && winnerIndex > 0 && traces[0]!.status === \"ran\") {\n // Only member 0 and the winner get a hash. Their two trace entries are new objects with the hash.\n for (const i of [0, winnerIndex]) traces[i] = { ...traces[i]!, outputHash: hashOf(list[i]!, outputs.get(traces[i]!.id)!) };\n }\n const base = traces[0]!;\n const picked = winnerIndex > 0 && (base.status !== \"ran\" || traces[winnerIndex]!.outputHash !== base.outputHash);\n const trace: PortfolioTrace = {\n members: traces,\n winner,\n winnerIndex,\n picked,\n totalMs: now() - start,\n ...(budgetMs !== undefined ? { budgetMs } : {}),\n ...(maxMembers !== undefined ? { maxMembers } : {}),\n cut,\n deterministic: !outOfTime,\n kept,\n };\n return { output: outputs.get(winner)!, winner, trace };\n };\n\n return { id, pick, run: (input: I): O => pick(input).output };\n}\n","// The checks of the claims of a corpus (`docs/CORPUS-CHECKS.md`). The joint corpus, `packing` and `highways` use the same checks.\nimport { canonicalJson, sha256Hex } from \"./hash.ts\";\n\n/** One broken claim of a corpus, with the ids of the inputs that break it. */\nexport interface ClaimBreak {\n /** The name of the claim, for example `declared`, `split` or `index`. */\n readonly claim: string;\n /** The text of the break. */\n readonly detail: string;\n /** The ids of the inputs that break the claim. The list is empty when the break has no input. */\n readonly inputs: readonly string[];\n}\n\n/** The claim `claims.declared` of a manifest: the count of the inputs for each declared property. */\nexport interface DeclaredClaim {\n /** A property with fewer inputs than this count is thin. */\n readonly minCount: number;\n /** The ids of the properties with a count below `minCount`. */\n readonly thin: readonly string[];\n /** The count of the inputs for each property id. */\n readonly counts: Readonly<Record<string, number>>;\n /** The key of the family of an input. `familyOf` gives the key of one cell. The family is the unit of a verdict. */\n readonly familyBy?: FamilyBy;\n /** The minimum count of the inputs of each family. Without it, `checkDeclared` does not count the families. */\n readonly familyMin?: number;\n}\n\n/**\n * The key of the family of a cell (`docs/CORPUS-CHECKS.md`).\n *\n * - The flat form is a list of dimensions. The key is the values of these dimensions of the cell, in order, with `/` between them.\n * - The map form chooses an entry by the field `kind` of the cell, or the entry `\"*\"`. The key is the kind, then the values of the dimensions of the entry.\n */\nexport type FamilyBy = readonly string[] | { readonly [kind: string]: readonly string[] };\n\n/** A cell of an input: one value for each dimension. The map form of `FamilyBy` also reads the field `kind`. */\nexport type FamilyCell = Readonly<Record<string, unknown>>;\n\n/** The entry of the map form of `FamilyBy` for each kind without its own entry. */\nexport const FAMILY_ANY_KIND = \"*\";\n\n/** The separator of the parts of a family key. */\nconst FAMILY_SEP = \"/\";\n\n/** The parts of the key of one cell, or the text of the problem. */\ntype FamilyParts = { readonly parts: readonly string[] } | { readonly problem: string };\n\n/** This function gives the text of a dimension value. A missing value, or a value that is not a string, a number or a boolean, gives `undefined`. */\nfunction partOf(value: unknown): string | undefined {\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"boolean\") return String(value);\n return undefined;\n}\n\n/** This function gives the parts of the family key of a cell. A missing dimension, a missing kind or a kind without an entry gives a problem. */\nfunction familyParts(cell: FamilyCell, familyBy: FamilyBy): FamilyParts {\n let dims: readonly string[];\n let kind: string | undefined;\n const parts: string[] = [];\n if (Array.isArray(familyBy)) {\n dims = familyBy as readonly string[];\n } else {\n const map = familyBy as Readonly<Record<string, readonly string[]>>;\n kind = partOf(cell[\"kind\"]);\n if (kind === undefined) return { problem: \"a cell without kind, which the map form of familyBy needs\" };\n const entry = Object.hasOwn(map, kind) ? map[kind] : Object.hasOwn(map, FAMILY_ANY_KIND) ? map[FAMILY_ANY_KIND] : undefined;\n if (entry === undefined) return { problem: `the kind \"${kind}\", which has no entry in familyBy and no entry \"${FAMILY_ANY_KIND}\"` };\n dims = entry;\n parts.push(kind);\n }\n for (const dim of dims) {\n const part = partOf(cell[dim]);\n if (part === undefined) return { problem: `a cell${kind === undefined ? \"\" : ` of the kind \"${kind}\"`} without the dimension \"${dim}\" of familyBy` };\n parts.push(part);\n }\n return { parts };\n}\n\n/**\n * This function gives the family key of a cell. It throws a `RangeError` when the cell does not have a dimension of the key.\n * In the map form, it also throws for a cell without `kind`, and for a kind with no entry and no entry `\"*\"`.\n * For example, `{ \"rect-grid\": [\"obstacles\"], \"*\": [] }` gives `rect-grid/wall` for a `rect-grid` cell and `gallery` for a `gallery` cell.\n */\nexport function familyOf(cell: FamilyCell, familyBy: FamilyBy): string {\n const found = familyParts(cell, familyBy);\n if (\"problem\" in found) throw new RangeError(`familyOf: ${found.problem}.`);\n return found.parts.join(FAMILY_SEP);\n}\n\n/** This function tells if a value is a `FamilyBy`: a list of dimensions, or a map from a kind to a list of dimensions. */\nfunction isFamilyBy(value: unknown): value is FamilyBy {\n const isDims = (v: unknown): boolean => Array.isArray(v) && v.every((d) => typeof d === \"string\");\n return isDims(value) || (isObject(value) && Object.values(value).every(isDims));\n}\n\n/** The hook that gives the ids of the properties that one input declares. */\nexport type Declares<I> = (input: I) => readonly string[];\n\n/**\n * This function gives the count of the inputs for each property id. Each id of `ids` has a count, also when the count is 0.\n * An id from `declares` that is not in `ids` comes after the ids of `ids`, in the order of the first input that declares it.\n */\nexport function declaredCounts<I>(inputs: Iterable<I>, declares: Declares<I>, ids: readonly string[] = []): Record<string, number> {\n const out: Record<string, number> = Object.fromEntries(ids.map((id) => [id, 0]));\n for (const input of inputs) for (const id of declares(input)) out[id] = (out[id] ?? 0) + 1;\n return out;\n}\n\n/** This function tells if a value is a plain object. */\nconst isObject = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === \"object\" && !Array.isArray(value);\n\n/**\n * This function reads the field `claims.declared` of a manifest. A manifest without it gives `undefined`.\n * It throws an `Error` for a claim without a whole `minCount`, a list `thin` of ids and a whole count for each id.\n */\nexport function declaredClaimOf(manifest: object): DeclaredClaim | undefined {\n const claims = (manifest as Record<string, unknown>)[\"claims\"];\n if (claims === undefined) return undefined;\n if (!isObject(claims)) throw new Error(\"The field claims of a corpus file is an object.\");\n const declared = claims[\"declared\"];\n if (declared === undefined) return undefined;\n if (!isObject(declared)) throw new Error(\"The field claims.declared of a corpus file is an object.\");\n const { minCount, thin, counts } = declared;\n if (!Number.isInteger(minCount) || (minCount as number) < 0) throw new Error(\"The field claims.declared.minCount is a whole number of 0 or more.\");\n if (!Array.isArray(thin) || !thin.every((id) => typeof id === \"string\")) throw new Error(\"The field claims.declared.thin is a list of property ids.\");\n if (!isObject(counts) || !Object.values(counts).every((n) => Number.isInteger(n) && (n as number) >= 0)) {\n throw new Error(\"The field claims.declared.counts gives a whole count for each property id.\");\n }\n const { familyBy, familyMin } = declared;\n if (familyBy !== undefined && !isFamilyBy(familyBy)) throw new Error(\"The field claims.declared.familyBy is a list of dimensions, or a map from a kind to a list of dimensions.\");\n if (familyMin !== undefined && (!Number.isInteger(familyMin) || (familyMin as number) < 0)) throw new Error(\"The field claims.declared.familyMin is a whole number of 0 or more.\");\n return {\n minCount: minCount as number,\n thin: [...(thin as string[])],\n counts: { ...(counts as Record<string, number>) },\n ...(familyBy === undefined ? {} : { familyBy: Array.isArray(familyBy) ? [...familyBy] : { ...(familyBy as Record<string, readonly string[]>) } }),\n ...(familyMin === undefined ? {} : { familyMin: familyMin as number }),\n };\n}\n\n/**\n * This function checks the claim `claims.declared` against the inputs. It gives one break `declared` for each problem. An empty list tells that the claim is true.\n *\n * - `ids` are the property ids. The default is the ids of `claim.counts`.\n * - Each id of `ids` has a count in `claim.counts`, and `claim.counts` has no other id. Each count is the count of the inputs.\n * - An id with a count below `minCount` is in `thin`. Each id of `thin` is an id of `ids`.\n * - Each id that `declares` gives is an id of `ids`.\n *\n * With `claim.familyBy`, the hook `cellOf` gives the cell of each input. The default reads the field `cell` of the input.\n *\n * - Each cell has each dimension of its key. In the map form, each cell has a `kind`, and the kind has an entry or the entry `\"*\"` is there.\n * - Two cells with different dimension values do not give the same key.\n * - With `claim.familyMin`, each family has `familyMin` inputs or more.\n */\nexport function checkDeclared<I>(\n inputs: Iterable<I>,\n declares: Declares<I>,\n claim: DeclaredClaim,\n ids: readonly string[] = Object.keys(claim.counts),\n cellOf: (input: I) => FamilyCell | undefined = cellField,\n): ClaimBreak[] {\n const list = [...inputs];\n const computed = declaredCounts(list, declares, ids);\n const out: string[] = [];\n for (const id of ids) {\n if (!(id in claim.counts)) out.push(`the property \"${id}\" has no count`);\n else if (claim.counts[id] !== computed[id]) out.push(`the property \"${id}\" has the count ${claim.counts[id]}, but the inputs give ${computed[id]}`);\n }\n for (const id of Object.keys(claim.counts)) if (!ids.includes(id)) out.push(`\"${id}\" is not a declared property`);\n for (const id of ids) {\n const thin = (computed[id] ?? 0) < claim.minCount;\n if (thin && !claim.thin.includes(id)) out.push(`the property \"${id}\" has ${computed[id]} inputs, below minCount ${claim.minCount}, and it is not in thin`);\n }\n for (const id of claim.thin) if (!ids.includes(id)) out.push(`\"${id}\" of thin is not a declared property`);\n for (const id of Object.keys(computed)) if (!ids.includes(id)) out.push(`${computed[id]} inputs declare \"${id}\", which is not a declared property`);\n const breaks: ClaimBreak[] = out.map((detail) => ({ claim: \"declared\", detail, inputs: [] }));\n if (claim.familyBy !== undefined) breaks.push(...checkFamilies(list, claim.familyBy, claim.familyMin, cellOf));\n return breaks;\n}\n\n/** This function gives the field `cell` of an input, when it is an object. */\nfunction cellField(input: unknown): FamilyCell | undefined {\n const cell = isObject(input) ? input[\"cell\"] : undefined;\n return isObject(cell) ? cell : undefined;\n}\n\n/** This function gives the field `id` of an input, or its place in the list. */\nfunction inputId(input: unknown, at: number): string {\n const id = isObject(input) ? input[\"id\"] : undefined;\n return typeof id === \"string\" ? id : `#${at}`;\n}\n\n/** This function gives the breaks of the family keys of the inputs: the problems of each key, the collisions and the thin families. */\nfunction checkFamilies<I>(inputs: readonly I[], familyBy: FamilyBy, familyMin: number | undefined, cellOf: (input: I) => FamilyCell | undefined): ClaimBreak[] {\n const problems = new Map<string, string[]>();\n const members = new Map<string, { readonly tuples: Map<string, string[]>; readonly ids: string[] }>();\n inputs.forEach((input, at) => {\n const id = inputId(input, at);\n const cell = cellOf(input);\n const found: FamilyParts = cell === undefined ? { problem: \"no cell, which familyBy needs\" } : familyParts(cell, familyBy);\n if (\"problem\" in found) {\n problems.set(found.problem, [...(problems.get(found.problem) ?? []), id]);\n return;\n }\n const key = found.parts.join(FAMILY_SEP);\n const family = members.get(key) ?? { tuples: new Map<string, string[]>(), ids: [] };\n const tuple = JSON.stringify(found.parts);\n family.tuples.set(tuple, [...(family.tuples.get(tuple) ?? []), id]);\n family.ids.push(id);\n members.set(key, family);\n });\n const breaks: ClaimBreak[] = [];\n const add = (detail: string, ids: readonly string[]): void => void breaks.push({ claim: \"declared\", detail, inputs: [...ids] });\n for (const [problem, ids] of problems) add(`${ids.length} inputs have ${problem}`, ids);\n for (const [key, family] of members) {\n if (family.tuples.size > 1) {\n const forms = [...family.tuples.keys()].join(\" and \");\n add(`the family \"${key}\" comes from different dimension values: ${forms}`, family.ids);\n }\n if (familyMin !== undefined && family.ids.length < familyMin) add(`the family \"${key}\" has ${family.ids.length} inputs, below familyMin ${familyMin}`, family.ids);\n }\n return breaks;\n}\n\n/** The id and the hash of one input of a corpus. */\nexport interface CorpusEntry {\n readonly id: string;\n readonly hash: string;\n}\n\n/**\n * This function gives the hash of a corpus: the first 16 hex characters of a SHA-256. The text of the SHA-256 is `canonicalJson`\n * of the corpus id and the `[id, hash]` of each input, in the order of the manifest. A change of one input changes the hash.\n */\nexport function corpusHashOf(corpus: string, inputs: readonly CorpusEntry[]): string {\n return sha256Hex(canonicalJson({ corpus, inputs: inputs.map((i) => [i.id, i.hash]) })).slice(0, 16);\n}\n\n/** The schema of a split file. */\nexport const SPLIT_SCHEMA = \"corpus-split/1\";\n\n/** One fold of a split: the seeds that fit a selector and the seeds that score it. */\nexport interface SplitFold {\n readonly train: readonly number[];\n readonly heldOut: readonly number[];\n}\n\n/** A split file `corpus-split/1`. Its name is `<corpus id>.<corpus hash>.json`. It is beside the corpus, so the corpus does not change. */\nexport interface CorpusSplit {\n readonly schema: typeof SPLIT_SCHEMA;\n readonly corpus: string;\n /** The hash of the corpus: `corpusHashOf` of its manifest. */\n readonly corpusHash: string;\n /** The splits by name. Each split has one fold or more. */\n readonly splits: Readonly<Record<string, { readonly folds: readonly SplitFold[] }>>;\n}\n\n/** The fields of a manifest that the split check reads. */\nexport interface SplitCorpus {\n readonly corpus: string;\n readonly specs: readonly { readonly seeds: readonly number[] }[];\n readonly inputs: readonly CorpusEntry[];\n}\n\n/** This function gives the name of the split file of a corpus. */\nexport function splitFileName(corpus: string, hash: string): string {\n return `${corpus}.${hash}.json`;\n}\n\n/** This function tells if a value is a list of whole numbers. */\nconst isSeeds = (value: unknown): value is number[] => Array.isArray(value) && value.every((s) => Number.isInteger(s));\n\n/**\n * This function checks a split file against a manifest. It gives one break `split` for each problem. An empty list tells that the file is good.\n *\n * - The schema is `corpus-split/1`, the corpus is the id of the manifest and `corpusHash` is `corpusHashOf` of the manifest.\n * - Each split has one fold or more. In each fold, `train` and `heldOut` are lists of seeds, not empty and with no common seed.\n * - Each seed is a seed of a spec of the manifest.\n * - With `name`, the file has the split `name`.\n */\nexport function checkSplit(split: unknown, corpus: SplitCorpus, name?: string): ClaimBreak[] {\n const out: string[] = [];\n const done = (): ClaimBreak[] => out.map((detail) => ({ claim: \"split\", detail, inputs: [] }));\n const f = split as Partial<CorpusSplit> | null;\n if (f === null || typeof f !== \"object\") {\n out.push(\"the split file is not an object\");\n return done();\n }\n if (f.schema !== SPLIT_SCHEMA) out.push(`the schema is ${String(f.schema)}, not ${SPLIT_SCHEMA}`);\n if (f.corpus !== corpus.corpus) out.push(`the corpus is ${String(f.corpus)}, not ${corpus.corpus}`);\n const hash = corpusHashOf(corpus.corpus, corpus.inputs);\n if (f.corpusHash !== hash) out.push(`the corpusHash is ${String(f.corpusHash)}, but the corpus gives ${hash}`);\n const seeds = new Set(corpus.specs.flatMap((s) => s.seeds));\n if (f.splits === null || typeof f.splits !== \"object\") {\n out.push(\"the field splits is not an object\");\n return done();\n }\n for (const [key, value] of Object.entries(f.splits)) {\n const folds = (value as { folds?: unknown } | null)?.folds;\n if (!Array.isArray(folds) || folds.length === 0) {\n out.push(`the split ${key} has no folds`);\n continue;\n }\n folds.forEach((fold: Partial<SplitFold> | null, k) => {\n const at = `the fold ${k} of the split ${key}`;\n const { train, heldOut } = fold ?? {};\n if (!isSeeds(train) || train.length === 0) out.push(`${at} has no train seeds`);\n if (!isSeeds(heldOut) || heldOut.length === 0) out.push(`${at} has no heldOut seeds`);\n if (!isSeeds(train) || !isSeeds(heldOut)) return;\n const common = train.filter((s) => heldOut.includes(s));\n if (common.length > 0) out.push(`${at} has the seeds ${common.join(\", \")} in train and in heldOut`);\n const unknown = [...train, ...heldOut].filter((s) => !seeds.has(s));\n if (unknown.length > 0) out.push(`${at} has the seeds ${unknown.join(\", \")}, which are not in the corpus`);\n });\n }\n if (name !== undefined && !Object.hasOwn(f.splits, name)) out.push(`the split file has no split ${name}. Its splits are ${Object.keys(f.splits).join(\", \")}`);\n return done();\n}\n\n/**\n * This function gives a copy of the folds of the split `name` of a split file. `where` names the file in the text of an error.\n * It throws an `Error` for each problem of `checkSplit`, and then for an unknown split name.\n */\nexport function splitFolds(split: unknown, corpus: SplitCorpus, name: string, where: string = \"The split file\"): SplitFold[] {\n const breaks = checkSplit(split, corpus);\n if (breaks.length > 0) throw new Error(`${where} is not good: ${breaks.map((b) => b.detail).join(\"; \")}.`);\n const splits = (split as CorpusSplit).splits;\n const found = Object.hasOwn(splits, name) ? splits[name] : undefined;\n if (found === undefined) throw new Error(`${where} has no split ${name}. Its splits are ${Object.keys(splits).join(\", \")}.`);\n return found.folds.map((f) => ({ train: [...f.train], heldOut: [...f.heldOut] }));\n}\n\n/** This function gives the folds that hold out one seed each, in the order of the seeds. Each fold trains on the other seeds. */\nexport function leaveOneSeedOut(seeds: readonly number[]): SplitFold[] {\n const sorted = [...new Set(seeds)].sort((a, b) => a - b);\n return sorted.map((s) => ({ train: sorted.filter((t) => t !== s), heldOut: [s] }));\n}\n","// The walk draw of a sample of a strategy space (`docs/STRATEGY-SPACE.md`). The package root does not export this file.\nimport type { OptionRef, SpaceConstraint, SpaceStage, StageOption } from \"./strategy-space.ts\";\n\nconst refMatches = (ref: OptionRef, choices: ReadonlyMap<string, string | null>): boolean => (choices.get(ref.stage) ?? null) === ref.option;\n\n/** This function tells if the option choices keep a constraint. */\nexport function holds(c: SpaceConstraint, choices: ReadonlyMap<string, string | null>): boolean {\n if (!refMatches(c.if, choices)) return true;\n return \"not\" in c.then ? !refMatches(c.then.not, choices) : refMatches(c.then, choices);\n}\n\nconst otherStage = (c: SpaceConstraint): string => (\"not\" in c.then ? c.then.not.stage : c.then.stage);\n\n/** This function tells if an option of a stage keeps each constraint between that stage and the stages that a walk has fixed. */\nexport function fitsWalk(constraints: readonly SpaceConstraint[], fixed: Map<string, string | null>, stage: string, id: string | null): boolean {\n fixed.set(stage, id);\n const ok = constraints.every((c) => !fixed.has(c.if.stage === stage ? otherStage(c) : c.if.stage) || holds(c, fixed));\n fixed.delete(stage);\n return ok;\n}\n\n/** The order of the stages of a walk, and the constraints that name each stage. */\nexport interface WalkPlan {\n /** The stages of the space. */\n readonly stages: readonly SpaceStage[];\n /** The options of each stage for a draw. */\n readonly lists: readonly (readonly (StageOption | null)[])[];\n /** The indexes of the stages. The stages of `first` come first, in the order of the space. The others follow, from the largest stage to the smallest. */\n readonly order: readonly number[];\n /** The constraints that name each stage. */\n readonly naming: readonly (readonly SpaceConstraint[])[];\n /** The count of points of a round. */\n readonly n: number;\n}\n\n/**\n * This function gives the plan of a walk. Stages of equal size keep the order of the space.\n * The stages of `first` go first, for example the stages of the sample option `fixed`. Thus the other stages draw only from the options that keep the constraints with them.\n */\nexport function walkPlan(\n stages: readonly SpaceStage[],\n lists: readonly (readonly (StageOption | null)[])[],\n constraints: readonly SpaceConstraint[],\n n: number,\n first: ReadonlySet<string> = new Set(),\n): WalkPlan {\n return {\n stages,\n lists,\n n,\n order: stages.map((_, k) => k).sort((a, b) => Number(first.has(stages[b]!.name)) - Number(first.has(stages[a]!.name)) || lists[b]!.length - lists[a]!.length || a - b),\n naming: stages.map((s) => constraints.filter((c) => c.if.stage === s.name || otherStage(c) === s.name)),\n };\n}\n\n/**\n * This function gives the options of one point of a walk. It fixes the largest stage first. Thus that stage keeps its equal strata, and the constraints limit only the smaller stages.\n * The value `picks[k][i]` is the stratum of the stage `k` for the point `i`. A stage with no open option gets `null`, and the caller rejects that point.\n * The argument `fits` lets a test give a fault. The default is `fitsWalk`.\n */\nexport function walkPoint(plan: WalkPlan, picks: readonly (readonly number[])[], i: number, fits: typeof fitsWalk = fitsWalk): Map<string, StageOption | null> {\n const fixed = new Map<string, string | null>();\n const out = new Map<string, StageOption | null>();\n for (const k of plan.order) {\n const s = plan.stages[k]!;\n const open = plan.lists[k]!.filter((o) => fits(plan.naming[k]!, fixed, s.name, o?.id ?? null));\n const o = open[Math.floor((picks[k]![i]! * open.length) / plan.n)] ?? null;\n fixed.set(s.name, o?.id ?? null);\n out.set(s.name, o);\n }\n return out;\n}\n","// The strategy space of an engine (`docs/STRATEGY-SPACE.md`): its stages, their options and the ranges of their params, as data.\nimport type { ClaimBreak } from \"./corpus.ts\";\nimport { canonicalJson, sha256Hex } from \"./hash.ts\";\nimport { stepRandom } from \"./random.ts\";\nimport { holds, walkPlan, walkPoint } from \"./space-walk.ts\";\nimport { isShapeKind, SHAPE_KIND_IDS, type ShapeKind } from \"./shapes.ts\";\n\n/** The schema of a strategy space. */\nexport const STRATEGY_SPACE_SCHEMA = \"strategy-space/1\";\n\n/** The kind of a param: a whole number, a real number, one value of a list, or `true` and `false`. */\nexport type ParamKind = \"int\" | \"real\" | \"enum\" | \"bool\";\n\n/** The value of one param in a config. */\nexport type ParamValue = number | string | boolean;\n\n/** The condition of a conditional param: the param is active only when an earlier param of the same option has one of the values `in`. */\nexport interface ParamWhen {\n /** The name of an earlier param of the same option. */\n readonly param: string;\n /** The values of that param that make this param active. */\n readonly in: readonly ParamValue[];\n}\n\n/** One param of a stage option, with its range. */\nexport interface SpaceParam {\n readonly name: string;\n readonly kind: ParamKind;\n /** The smallest value of an `int` or `real` param. */\n readonly min?: number;\n /** The largest value of an `int` or `real` param. */\n readonly max?: number;\n /** The step of the values from `min`. An `int` param has the step 1 by default. */\n readonly step?: number;\n /** The scale of the grid and of the samples. The scale `log` needs a `min` above 0. The default is `linear`. */\n readonly scale?: \"linear\" | \"log\";\n /** The values of an `enum` param. */\n readonly values?: readonly (string | number)[];\n /** The value that a config gets when it does not set the param. */\n readonly default: ParamValue;\n /** Without `when`, the param is active each time its option is chosen. */\n readonly when?: ParamWhen;\n}\n\n/**\n * The rule of the members of a meta option: a count from `min` to `max`. Members with `ordered: false` are sorted by their `configId`.\n * With `min` and `max` 0, the option chooses its members from the input, so a config lists none. This form has no `pool` and no `view`.\n */\nexport interface MemberRule {\n readonly min: number;\n readonly max: number;\n readonly ordered: boolean;\n /**\n * The member lists that the option permits. Each entry is a list of whole configs of the space of the members.\n * Without `pool`, each list of base configs with a good count is a member list.\n * With `pool`, a config of the option has the members of one entry, and `spaceSize` counts each entry one time.\n */\n readonly pool?: readonly (readonly StrategyConfig[])[];\n /**\n * The view of the items that the members get. With `bounds`, the option gives its members the bounding box of each item.\n * Then a shape filter checks the members with the kind `rect`, and the option itself with the kinds of the input. Without `view`, the members get the kinds of the input.\n */\n readonly view?: \"bounds\";\n}\n\n/** The inputs that an option supports. A missing field supports each value. */\nexport interface OptionSupports {\n /** The shape kinds of the boxes (`docs/SHAPES.md`). Without it, the option supports each kind. */\n readonly shape?: readonly ShapeKind[];\n}\n\n/** One implementation of a stage. An option with `members` is a meta option: it chooses between whole configs, or wraps them. */\nexport interface StageOption {\n readonly id: string;\n readonly params: readonly SpaceParam[];\n readonly members?: MemberRule;\n /** The inputs that the option supports. It describes the option, so it is not part of a config or of its id. */\n readonly supports?: OptionSupports;\n}\n\n/** The shape kinds of the inputs of a check, a count or an enumeration. Without `shapes`, each option counts. */\nexport interface ShapeFilter {\n /** The shape kinds of the input. Only the options that support each of these kinds count. */\n readonly shapes?: readonly ShapeKind[];\n}\n\n/** One stage of the pipeline of an engine. A config of an `optional` stage can have no option. */\nexport interface SpaceStage {\n readonly name: string;\n readonly options: readonly StageOption[];\n readonly optional?: boolean;\n}\n\n/** A reference to one option of a stage. The option `null` refers to an optional stage that a config does not use. */\nexport interface OptionRef {\n readonly stage: string;\n readonly option: string | null;\n}\n\n/** A rule that keeps out invalid combinations. A config with the option `if` also has the option `then`, or does not have the option `then.not`. */\nexport interface SpaceConstraint {\n readonly if: OptionRef;\n readonly then: OptionRef | { readonly not: OptionRef };\n}\n\n/** The strategy space of an engine: the stages, the constraints and the named configs. `docs/STRATEGY-SPACE.md` tells the rules. */\nexport interface StrategySpace {\n readonly schema: typeof STRATEGY_SPACE_SCHEMA;\n /** The name of the space. A config names the space with this value. */\n readonly engine: string;\n /** The version of the space. It is not part of a config or of its id. A record writes it. */\n readonly version: string;\n readonly stages: readonly SpaceStage[];\n readonly constraints?: readonly SpaceConstraint[];\n /** The named strategies of the engine, as points of the space. Old records stay comparable through them. */\n readonly named?: Readonly<Record<string, StrategyConfig>>;\n /** The spaces of a product space, from `productSpace`. A meta option of a part takes members of that part. */\n readonly parts?: readonly StrategySpace[];\n}\n\n/** The choice of one stage in a config: an option, its params and, for a meta option, its members. */\nexport interface StageChoice {\n readonly option: string;\n /** The values of the active params. A param that is not set gets its default. */\n readonly params?: Readonly<Record<string, ParamValue>>;\n /** The members of a meta option: configs of the same space, with no meta option. */\n readonly members?: readonly StrategyConfig[];\n}\n\n/** One point of a strategy space. The value `null` of a stage tells that the config does not use the optional stage. */\nexport interface StrategyConfig {\n /** The `engine` of the space, without its version. */\n readonly space: string;\n readonly stages: Readonly<Record<string, StageChoice | null>>;\n}\n\n/** The count of the grid points of a space. */\nexport interface SpaceSize {\n /** The count of the configs without a meta option. */\n readonly base: bigint;\n /** The count of the configs with a meta option. The value is `null` when the count is more than `maxMeta`. */\n readonly meta: bigint | null;\n}\n\n/** The options of `spaceSize`. */\nexport interface SpaceSizeOptions extends ShapeFilter {\n /** The count of the levels of each numeric param, a whole number of 1 or more. */\n readonly levels: number;\n /** The largest meta count that `spaceSize` gives. The default is `10n ** 18n`. */\n readonly maxMeta?: bigint;\n}\n\n/** The options of a grid. The grid gives only the configs without a meta option. */\nexport interface GridOptions extends ShapeFilter {\n readonly mode: \"grid\";\n readonly levels: number;\n /** The largest count of configs. A larger grid causes a `RangeError`. The default is 100000. */\n readonly limit?: number;\n}\n\n/** The options of a sample. */\nexport interface SampleOptions extends ShapeFilter {\n readonly mode: \"sample\";\n /** The count of the configs, a whole number of 0 or more. */\n readonly n: number;\n readonly seed: number;\n /** With `skip` (the default), the sample has no meta option. With `sample`, a meta option draws its members from base samples, or one entry of its `pool`. */\n readonly meta?: \"skip\" | \"sample\";\n /** The largest count of option draws. The default is the larger value of 1000 and `100 * n`. */\n readonly maxTries?: number;\n /**\n * How a point keeps the constraints. With `reject` (the default), a point that breaks a constraint draws again.\n * With `walk`, a point draws its stages from the largest to the smallest. Each stage draws only from the options that keep the constraints with the stages before it.\n * The stages of `fixed` draw before the other stages.\n * A space whose constraints reject most draws gets its sample with `walk`. The two values give different configs for one seed.\n * A sample of `walk` is not uniform over the valid configs. Each option of the largest stage gets an equal share, whatever count of valid configs it has.\n * Thus a mean over this sample is not a mean of the space.\n */\n readonly draw?: \"reject\" | \"walk\";\n /**\n * The options that each config of the sample has. A key is the name of a stage, and its value is the id of one option of that stage. The other stages draw as before.\n * A stage of a product space has the name of its part before its own name, for example `pack.placement`.\n * A fixed meta option needs `meta: \"sample\"`. A meta option of another stage of the same part goes out, because such an option replaces the fixed stage.\n * A fixed option that the shape filter removes, or that the constraints forbid, gets a `RangeError` with the reason.\n */\n readonly fixed?: Readonly<Record<string, string>>;\n}\n\n/** The options of `enumerateSpace`. */\nexport type EnumerateOptions = GridOptions | SampleOptions;\n\ntype Problem = readonly [claim: string, detail: string];\ntype Choices = ReadonlyMap<string, StageOption | null>;\ntype Values = Record<string, ParamValue>;\n\nconst isObject = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === \"object\" && !Array.isArray(value);\nconst show = (value: unknown): string => (typeof value === \"string\" ? `\"${value}\"` : String(value));\nconst isNumeric = (p: SpaceParam): boolean => p.kind === \"int\" || p.kind === \"real\";\nconst zero = (v: number): number => (v === 0 ? 0 : v);\n\n/** This function gives the stable form of a real number: 12 significant digits, with `-0` as `0`. */\nconst realForm = (v: number, digits = 12): number => zero(Number(v.toPrecision(digits)));\n\n/** This function gives the stable form of a value of a param. */\nfunction normalize(p: SpaceParam, v: ParamValue): ParamValue {\n if (typeof v !== \"number\") return v;\n if (p.kind !== \"real\") return zero(v);\n return Math.min(p.max ?? Infinity, Math.max(p.min ?? -Infinity, realForm(v)));\n}\n\n/** This function tells if a value is on the step of a param. */\nfunction onStep(p: SpaceParam, v: number): boolean {\n if (p.step === undefined || p.min === undefined) return true;\n const q = (v - p.min) / p.step;\n return Math.abs(q - Math.round(q)) <= 1e-9 * Math.max(1, Math.abs(q));\n}\n\n/** This function gives the problem of a value of a param, or `undefined` for a value in the range. */\nfunction valueProblem(p: SpaceParam, v: unknown): string | undefined {\n if (p.kind === \"bool\") return typeof v === \"boolean\" ? undefined : `${show(v)} is not true or false`;\n if (p.kind === \"enum\") return (p.values ?? []).some((x) => x === v) ? undefined : `${show(v)} is not one of ${(p.values ?? []).map(show).join(\", \")}`;\n if (typeof v !== \"number\" || !Number.isFinite(v)) return `${show(v)} is not a finite number`;\n if (p.kind === \"int\" && !Number.isInteger(v)) return `${v} is not a whole number`;\n if (p.min !== undefined && v < p.min) return `${v} is less than the min ${p.min}`;\n if (p.max !== undefined && v > p.max) return `${v} is more than the max ${p.max}`;\n if (!onStep(p, v)) return `${v} is not on the step ${p.step} from ${p.min}`;\n return undefined;\n}\n\n/** This function tells if a param is active for the values of the earlier params. */\nfunction isActive(p: SpaceParam, values: Values): boolean {\n if (p.when === undefined) return true;\n if (!Object.hasOwn(values, p.when.param)) return false;\n const v = values[p.when.param];\n return p.when.in.some((x) => x === v);\n}\n\n/** This function gives the problem of a value of a param, or `undefined` for a value in its range. The corpus dimensions of `families.ts` use it. */\nexport function paramProblem(param: SpaceParam, value: unknown): string | undefined {\n return valueProblem(param, value);\n}\n\n/** This function tells if a param is active for the values of the earlier params. A param without `when` is always active. */\nexport function paramActive(param: SpaceParam, values: Readonly<Record<string, ParamValue>>): boolean {\n return isActive(param, values);\n}\n\n/** This function gives the stable form of a value of a param: a real number gets 12 significant digits, and `-0` becomes `0`. */\nexport function paramValue(param: SpaceParam, value: ParamValue): ParamValue {\n return normalize(param, value);\n}\n\n/** This function gives the part of a space that has a stage, and the prefix of the names of its stages. */\nfunction partOf(space: StrategySpace, stage: string): { readonly space: StrategySpace; readonly prefix: string } {\n for (const part of space.parts ?? []) {\n const head = `${part.engine}.`;\n if (stage.startsWith(head)) {\n const inner = partOf(part, stage.slice(head.length));\n return { space: inner.space, prefix: head + inner.prefix };\n }\n }\n return { space, prefix: \"\" };\n}\n\n/** This function gives the prefix of the innermost part of each stage. */\nconst prefixes = (space: StrategySpace): Map<string, string> => new Map(space.stages.map((s) => [s.name, partOf(space, s.name).prefix]));\n\nconst describe = (c: SpaceConstraint): string => {\n const ref = (r: OptionRef): string => `${r.stage}=${r.option ?? \"null\"}`;\n return \"not\" in c.then ? `if ${ref(c.if)} then not ${ref(c.then.not)}` : `if ${ref(c.if)} then ${ref(c.then)}`;\n};\n\n/** This function gives the problems of the range and the default of one param. */\nfunction paramProblems(p: SpaceParam, at: string): Problem[] {\n const out: Problem[] = [];\n if (isNumeric(p)) {\n const { min, max, step } = p;\n if (typeof min !== \"number\" || typeof max !== \"number\" || !Number.isFinite(min) || !Number.isFinite(max)) {\n out.push([\"range\", `${at} has no finite min and max`]);\n return out;\n }\n if (min > max) out.push([\"range\", `${at} has an empty range: the min ${min} is more than the max ${max}`]);\n if (p.kind === \"int\" && (!Number.isInteger(min) || !Number.isInteger(max))) out.push([\"range\", `${at} is an int with a min or a max that is not whole`]);\n if (step !== undefined && (!Number.isFinite(step) || step <= 0 || (p.kind === \"int\" && !Number.isInteger(step))))\n out.push([\"range\", `${at} has the step ${step}, which is not a ${p.kind === \"int\" ? \"whole \" : \"\"}number above 0`]);\n if (p.scale === \"log\" && min <= 0) out.push([\"scale\", `${at} has the scale log with the min ${min}, which is not above 0`]);\n } else {\n if (p.scale !== undefined) out.push([\"scale\", `${at} is a ${p.kind} param with a scale`]);\n if (p.kind === \"enum\") {\n if (!Array.isArray(p.values) || p.values.length === 0) out.push([\"values\", `${at} is an enum without values`]);\n else {\n const seen = new Set<unknown>();\n for (const v of p.values) {\n if (seen.has(v)) out.push([\"duplicate\", `${at} has the value ${show(v)} two times`]);\n seen.add(v);\n }\n }\n }\n }\n if (out.length === 0) {\n const problem = valueProblem(p, p.default);\n if (problem !== undefined) out.push([\"default\", `the default of ${at} is not in its range: ${problem}`]);\n }\n return out;\n}\n\n/** This function gives the problems of one stage option. */\nfunction optionProblems(stage: SpaceStage, o: StageOption): Problem[] {\n const out: Problem[] = [];\n const at = `the option ${stage.name}.${o.id}`;\n if (!Array.isArray(o.params)) return [[\"config\", `${at} has no list of params`]];\n const names = o.params.map((p) => p.name);\n o.params.forEach((p, i) => {\n const pat = `the param ${stage.name}.${o.id}.${p.name}`;\n if (names.indexOf(p.name) !== i) out.push([\"duplicate\", `${at} has the param ${p.name} two times`]);\n out.push(...paramProblems(p, pat));\n if (p.when === undefined) return;\n const j = names.indexOf(p.when.param);\n if (j < 0) out.push([\"unknown\", `${pat} has a when with the unknown param ${p.when.param}`]);\n else if (j >= i) out.push([\"when\", `${pat} has a when with the param ${p.when.param}, which does not come before it`]);\n else if (!Array.isArray(p.when.in) || p.when.in.length === 0) out.push([\"when\", `${pat} has a when with no values`]);\n else for (const v of p.when.in) {\n const problem = valueProblem(o.params[j]!, v);\n if (problem !== undefined) out.push([\"when\", `${pat} has a when value that is not a value of ${p.when.param}: ${problem}`]);\n }\n });\n if (o.supports !== undefined) out.push(...supportsProblems(o.supports, at));\n if (o.members !== undefined) {\n const { min, max, ordered } = o.members;\n const noList = min === 0 && max === 0;\n if (!Number.isInteger(min) || !Number.isInteger(max) || (!noList && (min < 1 || min > max)) || typeof ordered !== \"boolean\")\n out.push([\"members\", `${at} has a member rule without whole counts 1 <= min <= max or min = max = 0, and a boolean ordered`]);\n if (noList && (o.members.pool !== undefined || o.members.view !== undefined))\n out.push([\"members\", `${at} has no member list, so its member rule cannot have a pool or a view`]);\n const pool: unknown = o.members.pool;\n if (pool !== undefined && (!Array.isArray(pool) || pool.length === 0 || !pool.every((entry: unknown) => Array.isArray(entry))))\n out.push([\"pool\", `${at} has a pool that is not a list of one or more member lists`]);\n const view: unknown = o.members.view;\n if (view !== undefined && view !== \"bounds\") out.push([\"view\", `${at} has the member view ${show(view)}, not \"bounds\"`]);\n }\n return out;\n}\n\n/** This function gives the problems of the `supports` of an option. */\nfunction supportsProblems(supports: unknown, at: string): Problem[] {\n if (!isObject(supports)) return [[\"shape\", `the supports of ${at} are not an object`]];\n const shape = supports[\"shape\"];\n if (shape === undefined) return [];\n if (!Array.isArray(shape) || shape.length === 0) return [[\"shape\", `${at} supports no shape kind. Remove shape to support each kind`]];\n const out: Problem[] = [];\n shape.forEach((k: unknown, i) => {\n if (!isShapeKind(k)) out.push([\"shape\", `${at} supports the shape kind ${show(k)}, which is not one of ${SHAPE_KIND_IDS.join(\", \")}`]);\n else if (shape.indexOf(k) !== i) out.push([\"duplicate\", `${at} has the shape kind ${k} two times`]);\n });\n return out;\n}\n\n/** This function tells if an option supports each shape kind of the list. */\nconst supportsShapes = (o: StageOption, shapes: readonly ShapeKind[] | undefined): boolean =>\n shapes === undefined || o.supports?.shape === undefined || shapes.every((k) => o.supports!.shape!.includes(k));\n\n/** The shape kinds that the members of an option with `view: \"bounds\"` see: a bounding box is a `rect`. */\nconst BOUNDS_VIEW: readonly ShapeKind[] = /* @__PURE__ */ Object.freeze([\"rect\"] as const);\n\n/**\n * This function gives the shape kinds of the members of a meta option. With `view: \"bounds\"`, a list with a kind becomes `BOUNDS_VIEW`.\n * Without a list, or with an empty list, the value does not change.\n */\nconst memberShapes = (rule: MemberRule, shapes: readonly ShapeKind[] | undefined): readonly ShapeKind[] | undefined =>\n rule.view === \"bounds\" && shapes !== undefined && shapes.length > 0 ? BOUNDS_VIEW : shapes;\n\n/** This function tells if two lists have the same shape kinds. */\nconst sameKinds = (a: readonly ShapeKind[], b: readonly ShapeKind[]): boolean => a.every((k) => b.includes(k)) && b.every((k) => a.includes(k));\n\n/** This function gives the problems of the params of one stage choice. */\nfunction choiceParamProblems(o: StageOption, params: unknown, at: string): Problem[] {\n if (params !== undefined && !isObject(params)) return [[\"config\", `the params of ${at} are not an object`]];\n const given = (params ?? {}) as Values;\n const out: Problem[] = [];\n for (const key of Object.keys(given)) if (!o.params.some((p) => p.name === key)) out.push([\"unknown\", `${at} has the unknown param ${key}`]);\n const values: Values = {};\n for (const p of o.params) {\n const has = Object.hasOwn(given, p.name);\n if (!isActive(p, values)) {\n if (has) out.push([\"inactive\", `${at} sets the param ${p.name}, which is not active`]);\n continue;\n }\n const v = has ? given[p.name] : p.default;\n const problem = valueProblem(p, v);\n if (problem !== undefined) out.push([\"param\", `the param ${p.name} of ${at} is not in its range: ${problem}`]);\n else values[p.name] = normalize(p, v as ParamValue);\n }\n return out;\n}\n\n/** This function gives the problems of a config of a space. A member of a meta option has `member: true`. */\nfunction configProblems(space: StrategySpace, config: unknown, member: boolean, shapes?: readonly ShapeKind[]): Problem[] {\n if (!isObject(config) || !isObject(config[\"stages\"])) return [[\"config\", \"the config is not an object with stages\"]];\n const out: Problem[] = [];\n const stages = config[\"stages\"];\n if (config[\"space\"] !== space.engine) out.push([\"space\", `the space of the config is ${show(config[\"space\"])}, not ${show(space.engine)}`]);\n for (const key of Object.keys(stages)) if (!space.stages.some((s) => s.name === key)) out.push([\"unknown\", `the config has the unknown stage ${key}`]);\n const optionOf = (s: SpaceStage): StageOption | undefined => {\n const c = stages[s.name];\n return isObject(c) ? s.options.find((o) => o.id === c[\"option\"]) : undefined;\n };\n const prefix = prefixes(space);\n const metaStage = new Map<string, string>();\n for (const s of space.stages) {\n if (optionOf(s)?.members === undefined) continue;\n const p = prefix.get(s.name)!;\n if (metaStage.has(p)) out.push([\"meta\", `the stages ${metaStage.get(p)} and ${s.name} both have a meta option`]);\n else metaStage.set(p, s.name);\n }\n const chosen = new Map<string, string | null>();\n for (const s of space.stages) {\n const c = Object.hasOwn(stages, s.name) ? stages[s.name] : undefined;\n const meta = metaStage.get(prefix.get(s.name)!);\n chosen.set(s.name, null);\n if (c === undefined || c === null) {\n if (!s.optional && meta === undefined) out.push([\"missing\", `the config has no option for the stage ${s.name}`]);\n continue;\n }\n if (!isObject(c) || typeof c[\"option\"] !== \"string\") {\n out.push([\"config\", `the choice of the stage ${s.name} has no option`]);\n continue;\n }\n const o = s.options.find((x) => x.id === c[\"option\"]);\n if (o === undefined) {\n out.push([\"unknown\", `the stage ${s.name} has no option ${c[\"option\"]}`]);\n continue;\n }\n chosen.set(s.name, o.id);\n const at = `the option ${s.name}.${o.id}`;\n if (!supportsShapes(o, shapes)) {\n const missing = shapes!.filter((k) => !o.supports!.shape!.includes(k));\n out.push([\"shape\", `${at} supports the shape kinds ${o.supports!.shape!.join(\", \")}, not ${missing.join(\", \")}`]);\n }\n if (meta !== undefined && meta !== s.name) out.push([\"meta\", `the stage ${s.name} is set, but the meta option of ${meta} replaces the other stages of its part`]);\n out.push(...choiceParamProblems(o, c[\"params\"], at));\n if (o.members === undefined) {\n if (c[\"members\"] !== undefined) out.push([\"members\", `${at} is not a meta option, but the config gives members`]);\n continue;\n }\n if (member) {\n out.push([\"depth\", `a member has the meta option ${s.name}.${o.id}. The depth of a meta config is 1`]);\n continue;\n }\n out.push(...memberProblems(partOf(space, s.name).space, o.members, c[\"members\"], at, memberShapes(o.members, shapes)));\n }\n for (const c of space.constraints ?? []) if (!holds(c, chosen)) out.push([\"constraint\", `the config breaks the constraint ${describe(c)}`]);\n return out;\n}\n\n/** This function gives the problems of the members of a meta option. `part` is the space of the members. */\nfunction memberProblems(part: StrategySpace, rule: MemberRule, members: unknown, at: string, shapes?: readonly ShapeKind[]): Problem[] {\n if (!Array.isArray(members)) return [[\"members\", `${at} is a meta option without a list of members`]];\n const out: Problem[] = [];\n if (members.length < rule.min || members.length > rule.max) out.push([\"members\", `${at} has ${members.length} members, not ${rule.min} to ${rule.max}`]);\n const ids = new Map<string, number>();\n members.forEach((m: unknown, k) => {\n const inner = configProblems(part, m, true, shapes);\n for (const [claim, detail] of inner) out.push([claim, `the member ${k} of ${at}: ${detail}`]);\n if (inner.length > 0) return;\n const id = idOf(canonicalOf(part, m as StrategyConfig, true));\n if (ids.has(id)) out.push([\"duplicate\", `the members ${ids.get(id)} and ${k} of ${at} are the same config ${id}`]);\n else ids.set(id, k);\n });\n if (rule.pool !== undefined && out.length === 0) {\n const key = memberKey(part, rule, members as readonly StrategyConfig[]);\n if (!rule.pool.some((entry) => memberKey(part, rule, entry) === key))\n out.push([\"pool\", `${at} has a member list that is not in its pool of ${rule.pool.length} ${rule.pool.length === 1 ? \"list\" : \"lists\"}`]);\n }\n return out;\n}\n\n/** This function gives the key of a good member list: the `configId` of each member, sorted when the rule is not ordered. */\nfunction memberKey(part: StrategySpace, rule: MemberRule, members: readonly StrategyConfig[]): string {\n const ids = members.map((m) => idOf(canonicalOf(part, m, true)));\n if (!rule.ordered) ids.sort();\n return ids.join(\",\");\n}\n\n/** This function gives the problems of the pool of a meta option of a good space. `part` is the space of the members. */\nfunction poolProblems(part: StrategySpace, rule: MemberRule, at: string): Problem[] {\n const out: Problem[] = [];\n const keys = new Map<string, number>();\n const plain: MemberRule = { min: rule.min, max: rule.max, ordered: rule.ordered };\n (rule.pool ?? []).forEach((entry, j) => {\n const inner = memberProblems(part, plain, entry, `the pool entry ${j} of ${at}`);\n out.push(...inner);\n if (inner.length > 0) return;\n const key = memberKey(part, rule, entry);\n if (keys.has(key)) out.push([\"duplicate\", `the pool entries ${keys.get(key)} and ${j} of ${at} have the same members`]);\n else keys.set(key, j);\n });\n return out;\n}\n\n/** This function tells if a member list fits a space: each member is a good config of the space. A shape filter removes options from the space. */\nconst fits = (part: StrategySpace, entry: readonly StrategyConfig[]): boolean => entry.every((m) => configProblems(part, m, true).length === 0);\n\nconst toBreaks = (problems: readonly Problem[], inputs: readonly string[] = []): ClaimBreak[] => problems.map(([claim, detail]) => ({ claim, detail, inputs }));\n\n/**\n * This function checks one config of a space. It gives one break for each problem. An empty list tells that the config is good.\n * The `claim` of a break is the kind of the problem, for example `missing`, `unknown`, `inactive`, `param`, `constraint`, `members` or `depth`.\n *\n * A member list that is not an entry of the `pool` of its option gives the claim `pool`.\n * With `shapes`, an option that does not support a kind of the list gives the claim `shape`. A member of a meta option gets the same check.\n * A member of an option with `view: \"bounds\"` gets the check with the kind `rect`.\n */\nexport function checkConfig(space: StrategySpace, config: StrategyConfig, options: ShapeFilter = {}): ClaimBreak[] {\n return toBreaks(configProblems(space, config, false, options.shapes));\n}\n\n/**\n * This function checks a space. It gives one break for each problem. An empty list tells that the space is good.\n * It finds duplicate names, empty ranges, defaults out of range, enums without values, bad log scales, unknown names and bad named configs.\n * It also checks each entry of a `pool`: the count of its members, each member and a repeated entry.\n * The `inputs` of a break of a named config have the name of the config.\n */\nexport function checkSpace(space: StrategySpace): ClaimBreak[] {\n if (!isObject(space) || !Array.isArray(space.stages)) return toBreaks([[\"schema\", \"the space is not an object with stages\"]]);\n const out: Problem[] = [];\n if (space.schema !== STRATEGY_SPACE_SCHEMA) out.push([\"schema\", `the schema is ${show(space.schema)}, not ${STRATEGY_SPACE_SCHEMA}`]);\n if (typeof space.engine !== \"string\" || space.engine === \"\") out.push([\"schema\", \"the space has no engine name\"]);\n if (typeof space.version !== \"string\") out.push([\"schema\", \"the space has no version\"]);\n const names = space.stages.map((s) => s.name);\n space.stages.forEach((s, i) => {\n if (names.indexOf(s.name) !== i) out.push([\"duplicate\", `the space has the stage ${s.name} two times`]);\n const options: readonly StageOption[] = Array.isArray(s.options) ? s.options : [];\n if (options.length === 0) {\n out.push([\"options\", `the stage ${s.name} has no options`]);\n return;\n }\n const ids = options.map((o) => o.id);\n options.forEach((o, j) => {\n if (ids.indexOf(o.id) !== j) out.push([\"duplicate\", `the stage ${s.name} has the option ${o.id} two times`]);\n out.push(...optionProblems(s, o));\n });\n if (!s.optional && options.every((o) => o.members !== undefined)) out.push([\"meta\", `the stage ${s.name} is not optional and has only meta options, so no base config exists`]);\n });\n const known = (ref: OptionRef, at: string): void => {\n const s = space.stages.find((x) => x.name === ref?.stage);\n if (s === undefined) out.push([\"unknown\", `${at} has the unknown stage ${ref?.stage}`]);\n else if (ref.option === null ? !s.optional : !s.options.some((o) => o.id === ref.option))\n out.push([\"unknown\", `${at} has the unknown option ${s.name}=${ref.option ?? \"null\"}`]);\n };\n (space.constraints ?? []).forEach((c, k) => {\n known(c.if, `the constraint ${k}`);\n known(\"not\" in c.then ? c.then.not : c.then, `the constraint ${k}`);\n });\n for (const part of space.parts ?? []) for (const b of checkSpace(part)) out.push([b.claim, `the part ${part.engine}: ${b.detail}`]);\n if (space.parts !== undefined)\n for (const s of space.stages) if (partOf(space, s.name).prefix === \"\") out.push([\"parts\", `the stage ${s.name} is not a stage of a part`]);\n const breaks = toBreaks(out);\n if (breaks.length > 0) return breaks;\n for (const s of space.stages)\n for (const o of s.options) if (o.members?.pool !== undefined) breaks.push(...toBreaks(poolProblems(partOf(space, s.name).space, o.members, `the option ${s.name}.${o.id}`)));\n if (breaks.length > 0) return breaks;\n for (const [name, config] of Object.entries(space.named ?? {}))\n breaks.push(...toBreaks(configProblems(space, config, false).map(([c, d]) => [c, `the named config ${name}: ${d}`] as const), [name]));\n return breaks;\n}\n\n/** This function gives the canonical form of a config that is known to be good. */\nfunction canonicalOf(space: StrategySpace, config: StrategyConfig, member: boolean): StrategyConfig {\n const stages: Record<string, StageChoice | null> = {};\n for (const s of space.stages) {\n const c = Object.hasOwn(config.stages, s.name) ? config.stages[s.name] : undefined;\n if (c === undefined || c === null) {\n stages[s.name] = null;\n continue;\n }\n const o = s.options.find((x) => x.id === c.option)!;\n const given = c.params ?? {};\n const params: Values = {};\n for (const p of o.params) if (isActive(p, params)) params[p.name] = normalize(p, Object.hasOwn(given, p.name) ? given[p.name]! : p.default);\n if (o.members === undefined || member) {\n stages[s.name] = { option: o.id, params };\n continue;\n }\n const part = partOf(space, s.name).space;\n const members = (c.members ?? []).map((m) => canonicalOf(part, m, true));\n if (!o.members.ordered) members.sort((a, b) => (idOf(a) < idOf(b) ? -1 : idOf(a) > idOf(b) ? 1 : 0));\n stages[s.name] = { option: o.id, params, members };\n }\n return { space: space.engine, stages };\n}\n\nconst idOf = (canonical: StrategyConfig): string => sha256Hex(canonicalJson(canonical)).slice(0, 16);\n\n/**\n * This function gives the canonical form of a config: each stage of the space, the active params only, the defaults, and stable numbers.\n * An unused optional stage is `null`. The members of an unordered meta option are sorted by their `configId`.\n * It throws an `Error` for a config with a break of `checkConfig`.\n */\nexport function canonicalConfig(space: StrategySpace, config: StrategyConfig): StrategyConfig {\n const problems = configProblems(space, config, false);\n if (problems.length > 0) throw new Error(`The config of the space ${space.engine} is not good: ${problems.map((p) => p[1]).join(\"; \")}.`);\n return canonicalOf(space, config, false);\n}\n\n/**\n * This function gives the id of a config: the first 16 hex characters of the SHA-256 of `canonicalJson` of `canonicalConfig`.\n * Two spellings of one config get one id. The version of the space is not part of the id.\n */\nexport function configId(space: StrategySpace, config: StrategyConfig): string {\n return idOf(canonicalConfig(space, config));\n}\n\n/** This function throws an `Error` for a space with a break of `checkSpace`. */\nfunction assertSpace(space: StrategySpace): void {\n const breaks = checkSpace(space);\n if (breaks.length > 0) throw new Error(`The space ${String(space?.engine)} is not good: ${breaks.map((b) => b.detail).join(\"; \")}.`);\n}\n\n/** This function throws a `RangeError` when a value is not a whole number of `min` or more. */\nfunction assertWhole(value: number, name: string, min: number): void {\n if (!Number.isInteger(value) || value < min) throw new RangeError(`The option ${name} is ${value}, not a whole number of ${min} or more.`);\n}\n\n/** This function gives the last point of the step grid of a numeric param. */\nfunction lastPoint(p: SpaceParam): number {\n const min = p.min!;\n const step = p.step ?? (p.kind === \"int\" ? 1 : undefined);\n if (step === undefined) return p.max!;\n return min + Math.floor((p.max! - min) / step + 1e-9) * step;\n}\n\n/** This function moves a value of a numeric param onto its step and into its range. */\nfunction snap(p: SpaceParam, x: number, digits: number): number {\n const min = p.min!;\n const step = p.step ?? (p.kind === \"int\" ? 1 : undefined);\n let v = step === undefined ? x : min + Math.round((x - min) / step) * step;\n v = Math.min(lastPoint(p), Math.max(min, v));\n return p.kind === \"int\" ? zero(Math.round(v)) : Math.min(p.max!, Math.max(min, realForm(v, digits)));\n}\n\n/** This function gives the point at the fraction `t` of the range of a numeric param, on its scale. */\nfunction at01(p: SpaceParam, t: number): number {\n const min = p.min!;\n const max = p.max!;\n if (p.scale === \"log\") return Math.exp(Math.log(min) + t * (Math.log(max) - Math.log(min)));\n return min + t * (max - min);\n}\n\n/**\n * This function gives the grid values of one param, in increasing order. An `enum` gives its values, and a `bool` gives `false` and `true`.\n * With 1 level, a numeric param gives its default. With k levels, it gives k points from `min` to `max` on its scale and step, without repeats.\n */\nexport function paramLevels(param: SpaceParam, levels: number): ParamValue[] {\n assertWhole(levels, \"levels\", 1);\n if (param.kind === \"bool\") return [false, true];\n if (param.kind === \"enum\") return [...(param.values ?? [])];\n if (levels === 1 || param.min === param.max) return [normalize(param, param.default)];\n const out: number[] = [];\n const steps = param.kind === \"int\" || param.step !== undefined ? Math.round((lastPoint(param) - param.min!) / (param.step ?? 1)) + 1 : Infinity;\n if (steps <= levels && param.scale !== \"log\") {\n for (let j = 0; j < steps; j++) out.push(snap(param, param.min! + j * (param.step ?? 1), 12));\n } else {\n for (let j = 0; j < levels; j++) out.push(snap(param, at01(param, j / (levels - 1)), 12));\n }\n return [...new Set(out)];\n}\n\n/** This function tells if a later param of the list reads a param in its `when`. */\nconst readLater = (params: readonly SpaceParam[], i: number): boolean => params.slice(i + 1).some((q) => q.when?.param === params[i]!.name);\n\n/** This function gives the count of the grid assignments of the params of an option, with only the active params. */\nfunction countParams(params: readonly SpaceParam[], levels: number, i = 0, values: Values = {}): bigint {\n if (i === params.length) return 1n;\n const p = params[i]!;\n if (!isActive(p, values)) return countParams(params, levels, i + 1, values);\n const lv = paramLevels(p, levels);\n if (!readLater(params, i)) return BigInt(lv.length) * countParams(params, levels, i + 1, values);\n let sum = 0n;\n for (const v of lv) sum += countParams(params, levels, i + 1, { ...values, [p.name]: v });\n return sum;\n}\n\n/** This function gives the grid assignments of the params of an option, in a stable order. */\nfunction* gridParams(params: readonly SpaceParam[], levels: number, i = 0, values: Values = {}): Generator<Values> {\n if (i === params.length) {\n yield { ...values };\n return;\n }\n const p = params[i]!;\n if (!isActive(p, values)) {\n yield* gridParams(params, levels, i + 1, values);\n return;\n }\n for (const v of paramLevels(p, levels)) yield* gridParams(params, levels, i + 1, { ...values, [p.name]: v });\n}\n\n/** One combination of options of a space, with its count of grid points. */\ninterface Combo {\n readonly choices: Choices;\n readonly base: boolean;\n /** The count of the grid points, or `null` when the count is more than the limit. */\n readonly weight: bigint | null;\n}\n\nconst optionIds = (choices: Choices): Map<string, string | null> => new Map([...choices].map(([k, o]) => [k, o?.id ?? null]));\nconst keeps = (space: StrategySpace, choices: Choices): boolean => (space.constraints ?? []).every((c) => holds(c, optionIds(choices)));\n\n/**\n * This function gives the constraints of a space for each stage: a constraint goes to the last stage that it names.\n * The last list holds each constraint that names a stage outside the space, so a walk examines it at the end.\n */\nfunction constraintsByStage(space: StrategySpace): readonly (readonly SpaceConstraint[])[] {\n const place = new Map(space.stages.map((s, i) => [s.name, i]));\n const lists: SpaceConstraint[][] = Array.from({ length: space.stages.length + 1 }, () => []);\n for (const c of space.constraints ?? []) {\n const named = [c.if.stage, \"not\" in c.then ? c.then.not.stage : c.then.stage];\n lists[Math.max(...named.map((name) => place.get(name) ?? space.stages.length))]!.push(c);\n }\n return lists;\n}\n\n/** This function gives the count of the member lists of a meta option without a pool from `base` base configs, or `null` above `limit`. */\nfunction memberLists(base: bigint, rule: MemberRule, limit: bigint): bigint | null {\n let sum = 0n;\n for (let m = rule.min; m <= rule.max; m++) {\n let n = 1n;\n for (let k = 0; k < m; k++) {\n n = (n * (base - BigInt(k))) / (rule.ordered ? 1n : BigInt(k + 1));\n if (n <= 0n) break;\n }\n if (n <= 0n) break;\n sum += n;\n if (sum > limit) return null;\n }\n return sum;\n}\n\n/** This function multiplies two counts. A `null` count or a product above `limit` gives `null`. */\nconst times = (a: bigint | null, b: bigint | null, limit: bigint): bigint | null => (a === null || b === null ? null : a * b > limit ? null : a * b);\n\n/**\n * This function gives the combinations of options of a space and their grid counts.\n * A product space joins the combinations of its parts. Each combination keeps the constraints.\n */\nfunction combos(space: StrategySpace, levels: number, meta: boolean, limit: bigint): Combo[] {\n if (space.parts !== undefined && space.parts.length > 0) {\n let acc: Combo[] = [{ choices: new Map(), base: true, weight: 1n }];\n for (const part of space.parts) {\n const head = `${part.engine}.`;\n const own = combos(part, levels, meta, limit);\n const next: Combo[] = [];\n for (const a of acc)\n for (const b of own) {\n const choices = new Map(a.choices);\n for (const [k, o] of b.choices) choices.set(head + k, o);\n const base = a.base && b.base;\n next.push({ choices, base, weight: base ? a.weight! * b.weight! : times(a.weight, b.weight, limit) });\n }\n acc = next;\n }\n return acc.filter((c) => keeps(space, c.choices));\n }\n const counts = new Map<StageOption, bigint>();\n const countOf = (o: StageOption): bigint => {\n if (!counts.has(o)) counts.set(o, countParams(o.params, levels));\n return counts.get(o)!;\n };\n const out: Combo[] = [];\n const stages = space.stages;\n // A space can have hundreds of constraints. Each one is examined at its last stage, so the walk leaves a branch at the first break.\n const checks = constraintsByStage(space);\n const ids = new Map<string, string | null>();\n const walk = (i: number, choices: Map<string, StageOption | null>, weight: bigint): void => {\n if (i === stages.length) {\n if (checks[i]!.every((c) => holds(c, ids))) out.push({ choices: new Map(choices), base: true, weight });\n return;\n }\n const s = stages[i]!;\n const list: (StageOption | null)[] = s.options.filter((o) => o.members === undefined);\n if (s.optional) list.push(null);\n for (const o of list) {\n choices.set(s.name, o);\n ids.set(s.name, o?.id ?? null);\n if (checks[i]!.every((c) => holds(c, ids))) walk(i + 1, choices, o === null ? weight : weight * countOf(o));\n }\n choices.delete(s.name);\n ids.delete(s.name);\n };\n walk(0, new Map(), 1n);\n if (!meta) return out;\n const base = out.reduce((sum, c) => sum + c.weight!, 0n);\n for (const s of stages)\n for (const o of s.options) {\n if (o.members === undefined) continue;\n const choices = new Map<string, StageOption | null>(stages.map((x) => [x.name, x === s ? o : null]));\n const own = memberSpaces.get(o);\n const from = own === undefined ? base : baseCount(own, levels, limit);\n const lists = o.members.pool === undefined ? memberLists(from, o.members, limit) : BigInt(o.members.pool.length);\n if (keeps(space, choices)) out.push({ choices, base: false, weight: times(countOf(o), lists, limit) });\n }\n return out;\n}\n\n/**\n * This function gives the count of the grid points of a space, with `levels` levels for each numeric param.\n * It counts only the active params and the combinations that keep the constraints. It gives the meta configs apart.\n * A meta option with a `pool` counts each entry of the pool one time.\n * With `shapes`, it counts only the options that support each kind of the list.\n */\nexport function spaceSize(space: StrategySpace, options: SpaceSizeOptions): SpaceSize {\n assertSpace(space);\n assertWhole(options.levels, \"levels\", 1);\n assertShapes(options.shapes);\n return sizeOf(restrict(space, options.shapes), options.levels, options.maxMeta ?? 10n ** 18n);\n}\n\n/**\n * This function gives the space with only the options that support each shape kind of `shapes`. Without `shapes`, it gives the same space.\n * A stage can lose all of its options. Then the space has no config with that stage.\n * A pool keeps only the entries whose members fit the smaller space. A meta option without such an entry goes out.\n *\n * The members of an option with `view: \"bounds\"` come from the space for the kinds of `memberShapes`. `memberSpaces` keeps that space.\n */\nfunction restrict(space: StrategySpace, shapes: readonly ShapeKind[] | undefined): StrategySpace {\n if (shapes === undefined) return space;\n const kept: StrategySpace = {\n ...space,\n stages: space.stages.map((s) => ({ ...s, options: s.options.filter((o) => supportsShapes(o, shapes)) })),\n ...(space.parts === undefined ? {} : { parts: space.parts.map((p) => restrict(p, shapes)) }),\n };\n const withPool = (s: SpaceStage, o: StageOption): StageOption[] => {\n if (o.members === undefined) return [o];\n const inner = memberShapes(o.members, shapes)!;\n const own = sameKinds(inner, shapes) ? undefined : restrict(partOf(space, s.name).space, inner);\n const mark = (option: StageOption): StageOption[] => {\n if (own !== undefined) memberSpaces.set(option, own);\n return [option];\n };\n if (o.members.pool === undefined) return own === undefined ? [o] : mark({ ...o });\n const part = own ?? partOf(kept, s.name).space;\n const pool = o.members.pool.filter((entry) => fits(part, entry));\n return pool.length === 0 ? [] : mark({ ...o, members: { ...o.members, pool } });\n };\n return { ...kept, stages: kept.stages.map((s) => ({ ...s, options: s.options.flatMap((o) => withPool(s, o)) })) };\n}\n\n/** The space of the members of a meta option of a restricted space, when it is not the part of the option. Only `view: \"bounds\"` makes such a space. */\nconst memberSpaces = /* @__PURE__ */ new WeakMap<StageOption, StrategySpace>();\n\n/**\n * This function tells if an option of a restricted space has a member list. A base option and a meta option with a `pool` have one.\n * A different meta option has one when its members have a base config. `restrict` keeps only the pool entries that fit.\n */\nconst hasMembers = (space: StrategySpace, stage: string, o: StageOption): boolean =>\n o.members === undefined || o.members.max === 0 || o.members.pool !== undefined || combos(memberSpaces.get(o) ?? partOf(space, stage).space, 1, false, 0n).length > 0;\n\n/** This function tells if a restricted space has a config. A base config counts. With `meta`, a meta config counts when each of its meta options has a member list. */\nconst hasConfig = (space: StrategySpace, meta: boolean): boolean =>\n combos(space, 1, meta, 0n).some((c) => c.base || [...c.choices].every(([stage, o]) => o === null || hasMembers(space, stage, o)));\n\n/** This function gives the error of a sample of a space that has no config for the shape kinds `shapes`. `kept` is the restricted space. */\nfunction noSample(space: StrategySpace, kept: StrategySpace, shapes: readonly ShapeKind[], meta: boolean): RangeError {\n const list = (names: readonly string[], one: string, more: string): string => (names.length === 1 ? `${one} ${names[0]}` : `${more} ${names.join(\", \")}`);\n const empty = kept.stages.filter((s) => !s.optional && !s.options.some((o) => meta || o.members === undefined)).map((s) => s.name);\n const removed = !meta\n ? []\n : space.stages.flatMap((s) =>\n s.options\n .filter((o) => o.members !== undefined && o.members.view !== \"bounds\" && supportsShapes(o, shapes))\n .filter((o) => {\n const own = kept.stages.find((x) => x.name === s.name)?.options.find((x) => x.id === o.id);\n return own === undefined || !hasMembers(kept, s.name, own);\n })\n .map((o) => `${s.name}.${o.id}`),\n );\n let text = `The space ${space.engine} has no config for a sample with the shape kinds ${shapes.join(\", \")}.`;\n if (empty.length > 0) text += ` ${list(empty, \"The stage\", \"The stages\")} ${empty.length === 1 ? \"has\" : \"have\"} no option for these kinds.`;\n if (removed.length > 0)\n text += ` ${list(removed, \"The meta option\", \"The meta options\")} ${removed.length === 1 ? \"has\" : \"have\"} no member config for these kinds. Set members.view to \"bounds\" when the members see only the bounding boxes.`;\n if (empty.length === 0 && removed.length === 0) text += \" The constraints remove each config.\";\n return new RangeError(text);\n}\n\n/** This function gives a constraint in words, for the reason of an error. */\nfunction constraintText(c: SpaceConstraint): string {\n const ref = (r: OptionRef): string => `${r.stage} ${r.option === null ? \"has no option\" : `is ${r.option}`}`;\n return \"not\" in c.then ? `if ${ref(c.if)}, then not ${ref(c.then.not)}` : `if ${ref(c.if)}, then ${ref(c.then)}`;\n}\n\n/**\n * This function throws a `RangeError` for a bad `fixed` option of a sample. A stage or an option that the space does not have is bad.\n * A meta option without `meta: \"sample\"` is bad, and so are two fixed options that a constraint forbids.\n */\nfunction assertFixed(space: StrategySpace, fixed: Readonly<Record<string, string>>, meta: boolean): void {\n for (const [stage, id] of Object.entries(fixed)) {\n const s = space.stages.find((x) => x.name === stage);\n if (s === undefined) throw new RangeError(`The option fixed names the stage ${stage}, and the space ${space.engine} has no such stage.`);\n const o = s.options.find((x) => x.id === id);\n if (o === undefined) throw new RangeError(`The option fixed names the option ${String(id)} of the stage ${stage}, and the stage has no such option.`);\n if (o.members !== undefined && !meta) throw new RangeError(`The option fixed names the meta option ${stage}.${id}, and a sample with meta skip has no meta option. Set meta to \"sample\".`);\n }\n const ids = new Map<string, string | null>(Object.entries(fixed));\n const other = (c: SpaceConstraint): string => (\"not\" in c.then ? c.then.not.stage : c.then.stage);\n const broken = (space.constraints ?? []).filter((c) => ids.has(c.if.stage) && ids.has(other(c)) && !holds(c, ids));\n if (broken.length > 0) {\n const names = Object.entries(fixed).map(([stage, id]) => `${stage}.${id}`);\n throw new RangeError(`The constraints of the space ${space.engine} forbid the fixed options ${names.join(\", \")}. The broken constraints: ${broken.map(constraintText).join(\"; \")}.`);\n }\n}\n\n/**\n * This function gives the restricted space `kept` with only the fixed option at each fixed stage. A fixed stage that was optional stops being optional.\n * A meta option of another stage of the part of a fixed stage goes out. A sample gives no option to the other stages of the part of its meta option.\n */\nfunction fixStages(space: StrategySpace, kept: StrategySpace, fixed: Readonly<Record<string, string>>, shapes: readonly ShapeKind[] | undefined): StrategySpace {\n const prefix = prefixes(kept);\n const parts = new Set(Object.keys(fixed).map((stage) => prefix.get(stage)!));\n const stages = kept.stages.map((s) => {\n const id = fixed[s.name];\n if (id === undefined) return parts.has(prefix.get(s.name)!) ? { ...s, options: s.options.filter((o) => o.members === undefined) } : s;\n // A fixed meta option takes its members from the space before the fix, because the fix removes each base config of its own stage.\n const options = s.options.filter((o) => o.id === id).map((o) => (o.members === undefined ? o : withMemberSpace(o, memberSpaces.get(o) ?? partOf(kept, s.name).space)));\n if (options.length === 0) throw new RangeError(`The fixed option ${s.name}.${id} of the space ${space.engine} does not support the shape kinds ${(shapes ?? []).join(\", \")}.`);\n return { ...s, options, optional: false };\n });\n return { ...kept, stages };\n}\n\n/** This function gives a copy of a meta option whose members come from `members`. */\nfunction withMemberSpace(o: StageOption, members: StrategySpace): StageOption {\n const copy = { ...o };\n memberSpaces.set(copy, members);\n return copy;\n}\n\n/** This function gives the error of a sample whose fixed options keep each constraint between them. The constraints with the other stages remove each config. */\nfunction noFixedSample(space: StrategySpace, fixed: Readonly<Record<string, string>>): RangeError {\n const names = Object.entries(fixed).map(([stage, id]) => `${stage}.${id}`);\n return new RangeError(\n `The space ${space.engine} has no config with the fixed options ${names.join(\", \")}. No constraint between two fixed options breaks, so the constraints with the other stages remove each config.`,\n );\n}\n\n/** This function gives the count of the base configs of a space that is known to be good. */\nconst baseCount = (space: StrategySpace, levels: number, limit: bigint): bigint => combos(space, levels, false, limit).reduce((sum, c) => sum + c.weight!, 0n);\n\n/** This function throws a `RangeError` for a list of shape kinds with a kind that is not declared. */\nfunction assertShapes(shapes: readonly ShapeKind[] | undefined): void {\n if (shapes === undefined) return;\n if (!Array.isArray(shapes)) throw new RangeError(\"The option shapes is not a list of shape kinds.\");\n for (const k of shapes) if (!isShapeKind(k)) throw new RangeError(`The shape kind ${show(k)} is not one of ${SHAPE_KIND_IDS.join(\", \")}.`);\n}\n\n/** This function gives the count of the grid points of a space that is known to be good. */\nfunction sizeOf(space: StrategySpace, levels: number, limit: bigint): SpaceSize {\n let base = 0n;\n let meta: bigint | null = 0n;\n for (const c of combos(space, levels, true, limit)) {\n if (c.base) base += c.weight!;\n else meta = meta === null || c.weight === null || meta + c.weight > limit ? null : meta + c.weight;\n }\n return { base, meta };\n}\n\n/** This function gives the cartesian product of lists, with the last list as the fastest. */\nfunction* product<T>(lists: readonly (readonly T[])[], i = 0, acc: T[] = []): Generator<T[]> {\n if (i === lists.length) {\n yield [...acc];\n return;\n }\n for (const x of lists[i]!) {\n acc.push(x);\n yield* product(lists, i + 1, acc);\n acc.pop();\n }\n}\n\n/** This function gives the configs of the grid of a space, without meta options. */\nfunction gridConfigs(space: StrategySpace, levels: number, limit: number, shapes: readonly ShapeKind[] | undefined): StrategyConfig[] {\n const kept = restrict(space, shapes);\n const size = sizeOf(kept, levels, 0n).base;\n if (size > BigInt(limit)) throw new RangeError(`The grid of the space ${space.engine} has ${size} configs, more than the limit ${limit}.`);\n const out: StrategyConfig[] = [];\n for (const c of combos(kept, levels, false, 0n)) {\n const names = [...c.choices.keys()];\n const lists = names.map((k) => {\n const o = c.choices.get(k)!;\n return o === null ? [null] : [...gridParams(o.params, levels)].map((params): StageChoice => ({ option: o.id, params }));\n });\n for (const row of product<StageChoice | null>(lists)) out.push(canonicalOf(space, { space: space.engine, stages: Object.fromEntries(names.map((k, i) => [k, row[i]!])) }, false));\n }\n return out;\n}\n\n/** This function gives a random order of the numbers from 0 to `n - 1`. */\nfunction permutation(n: number, r: () => number): number[] {\n const out = Array.from({ length: n }, (_, i) => i);\n for (let i = n - 1; i > 0; i--) {\n const j = Math.floor(r() * (i + 1));\n [out[i], out[j]] = [out[j]!, out[i]!];\n }\n return out;\n}\n\n/** This function gives the value of a param at the fraction `u` of its range. A sampled real number has 6 significant digits. */\nfunction sampleValue(p: SpaceParam, u: number): ParamValue {\n if (p.kind === \"bool\") return u >= 0.5;\n if (p.kind === \"enum\") {\n const values = p.values!;\n return values[Math.min(values.length - 1, Math.floor(u * values.length))]!;\n }\n if (p.min === p.max) return normalize(p, p.min!);\n if (p.scale !== \"log\" && (p.kind === \"int\" || p.step !== undefined)) {\n const steps = Math.round((lastPoint(p) - p.min!) / (p.step ?? 1)) + 1;\n return snap(p, p.min! + Math.min(steps - 1, Math.floor(u * steps)) * (p.step ?? 1), 6);\n }\n return snap(p, at01(p, u), 6);\n}\n\n/** This function gives a seed of 32 bits from a seed and a step name. */\nconst subSeed = (seed: number, step: string): number => Math.floor(stepRandom(seed, step)() * 4294967296);\n\n/**\n * This function gives a sample of a space: Latin hypercube strata over the options, the params and the member counts.\n * `canon` is the space of `canonicalConfig`: the space before a shape filter. A member of an option with `view: \"bounds\"` can have an option that the filter removed.\n */\nfunction sampleConfigs(\n space: StrategySpace,\n n: number,\n seed: number,\n meta: boolean,\n maxTries: number,\n canon: StrategySpace = space,\n walk = false,\n first: ReadonlySet<string> = new Set(),\n): StrategyConfig[] {\n const stages = space.stages;\n const prefix = prefixes(space);\n // A stage without options can stay empty in a part with a meta option of `view: \"bounds\"` or with no member list, because that option replaces the stage.\n const bounded = new Set(stages.filter((s) => meta && s.options.some((o) => memberSpaces.has(o) || o.members?.max === 0)).map((s) => prefix.get(s.name)!));\n const lists = stages.map((s) => {\n const list: (StageOption | null)[] = s.options.filter((o) => meta || o.members === undefined);\n if (s.optional) list.push(null);\n if (list.length === 0 && bounded.has(prefix.get(s.name)!)) list.push(null);\n if (list.length === 0) throw new Error(`The stage ${s.name} of the space ${space.engine} has no option for a sample. A shape filter can remove all of its options.`);\n return list;\n });\n // A meta option without a member list stays in its list, so the strata of 0.2.16 do not change. A point that chooses it draws again.\n const usable = new Map<StageOption, boolean>();\n const withMembers = (s: SpaceStage, o: StageOption | null | undefined): boolean => {\n if (o === null || o === undefined || o.members === undefined) return true;\n if (!usable.has(o)) usable.set(o, hasMembers(space, s.name, o));\n return usable.get(o)!;\n };\n const plan = walk ? walkPlan(stages, lists, space.constraints ?? [], n, first) : null;\n const points: Map<string, StageOption | null>[] = [];\n let tries = 0;\n for (let round = 0; points.length < n; round++) {\n const r = stepRandom(seed, `options:${round}`);\n const picks = walk ? lists.map(() => permutation(n, r)) : [];\n const columns = walk ? [] : lists.map((list) => permutation(n, r).map((p) => list[Math.floor((p * list.length) / n)]!));\n for (let i = 0; i < n && points.length < n; i++) {\n if (tries >= maxTries) throw new Error(`The constraints of the space ${space.engine} remove too many points: ${points.length} of ${n} configs after ${tries} tries.${walk ? \"\" : ' The option draw: \"walk\" gets a sample of a space with many constraints.'}`);\n tries++;\n const choices = plan !== null ? walkPoint(plan, picks, i) : new Map<string, StageOption | null>(stages.map((s, k) => [s.name, columns[k]![i]!]));\n const metaPart = new Map<string, string>();\n for (const s of stages) {\n const o = choices.get(s.name);\n if (o?.members !== undefined && !metaPart.has(prefix.get(s.name)!)) metaPart.set(prefix.get(s.name)!, s.name);\n }\n for (const s of stages) {\n const m = metaPart.get(prefix.get(s.name)!);\n if (m !== undefined && m !== s.name) choices.set(s.name, null);\n }\n const filled = stages.every((s) => s.optional === true || choices.get(s.name) !== null || metaPart.has(prefix.get(s.name)!));\n if (filled && keeps(space, choices) && stages.every((s) => withMembers(s, choices.get(s.name)))) points.push(choices);\n }\n }\n const values: Values[][] = points.map(() => stages.map(() => ({})));\n const members: StrategyConfig[][][] = points.map(() => stages.map(() => []));\n stages.forEach((s, k) => {\n for (const o of s.options) {\n const users = points.flatMap((c, i) => (c.get(s.name) === o ? [i] : []));\n if (users.length === 0) continue;\n for (const p of o.params) {\n const active = users.filter((i) => isActive(p, values[i]![k]!));\n const r = stepRandom(seed, `param:${s.name}:${o.id}:${p.name}`);\n permutation(active.length, r).forEach((stratum, j) => {\n values[active[j]!]![k]![p.name] = sampleValue(p, (stratum + r()) / active.length);\n });\n }\n if (o.members === undefined || o.members.max === 0) continue;\n const fixed = o.members.pool;\n if (fixed !== undefined) {\n const r = stepRandom(seed, `pool-entry:${s.name}:${o.id}`);\n permutation(users.length, r).forEach((stratum, j) => {\n members[users[j]!]![k] = [...fixed[Math.min(fixed.length - 1, Math.floor(((stratum + r()) / users.length) * fixed.length))]!];\n });\n continue;\n }\n const part = memberSpaces.get(o) ?? partOf(space, s.name).space;\n const poolSize = Math.max(n, 4 * o.members.max, 8);\n const seen = new Set<string>();\n const pool = sampleConfigs(part, poolSize, subSeed(seed, `pool:${s.name}:${o.id}`), false, Math.max(1000, 100 * poolSize), part, walk).filter((c) => {\n const id = idOf(c);\n return seen.has(id) ? false : (seen.add(id), true);\n });\n const r = stepRandom(seed, `members:${s.name}:${o.id}`);\n const { min, max } = o.members;\n permutation(users.length, r).forEach((stratum, j) => {\n const count = min + Math.min(max - min, Math.floor(((stratum + r()) / users.length) * (max - min + 1)));\n if (pool.length < count) throw new Error(`The space ${part.engine} has only ${pool.length} distinct base samples, fewer than the ${count} members of ${s.name}.${o.id}.`);\n const picked = permutation(pool.length, r).slice(0, count);\n members[users[j]!]![k] = picked.map((x) => pool[x]!);\n });\n }\n });\n return points.map((choices, i) => {\n const out: Record<string, StageChoice | null> = {};\n stages.forEach((s, k) => {\n const o = choices.get(s.name)!;\n out[s.name] = o === null ? null : o.members === undefined ? { option: o.id, params: values[i]![k]! } : { option: o.id, params: values[i]![k]!, members: members[i]![k]! };\n });\n return canonicalConfig(canon, { space: space.engine, stages: out });\n });\n}\n\n/**\n * This function gives configs of a space, in their canonical form. Each config keeps the constraints. The result is deterministic.\n *\n * - The mode `grid` gives each grid point without a meta option, in a stable order. Stages, options and values go in the order of the space.\n * - The mode `sample` gives `n` configs of a seeded Latin hypercube. The options of a stage get equal strata, and each active param gets its own strata.\n * - A sample draws again when a point breaks a constraint. After `maxTries` draws, it throws an `Error`. Two sampled configs can be equal.\n * - With `draw: \"walk\"`, each stage draws only from the options that keep the constraints with the stages before it. The largest stage keeps its equal strata.\n * - With `shapes`, only the options that support each kind of the list count. Without `shapes`, the result does not change.\n * - A meta option with a `pool` gives only the entries of its pool. With `shapes`, only the entries whose members support each kind count.\n * - A sample draws again when a point chooses a meta option without a member list. `spaceSize` gives such an option 0.\n * - With `shapes`, a sample throws a `RangeError` when the space has no config for the kinds. The error names the stages without an option and the meta options without members.\n * - With `fixed`, each config has the fixed option at each named stage. A fixed option that the space, the shape filter or the constraints do not permit gets a `RangeError` with the reason.\n */\nexport function enumerateSpace(space: StrategySpace, options: EnumerateOptions): StrategyConfig[] {\n assertSpace(space);\n assertShapes(options.shapes);\n if (options.mode === \"grid\") {\n assertWhole(options.levels, \"levels\", 1);\n return gridConfigs(space, options.levels, options.limit ?? 100_000, options.shapes);\n }\n if (options.mode !== \"sample\") throw new RangeError(`The mode ${String((options as { mode?: unknown }).mode)} is not grid or sample.`);\n assertWhole(options.n, \"n\", 0);\n if (!Number.isInteger(options.seed)) throw new RangeError(`The seed ${options.seed} is not a whole number.`);\n const meta = options.meta ?? \"skip\";\n if (meta !== \"skip\" && meta !== \"sample\") throw new RangeError(`The option meta is ${String(meta)}, not skip or sample.`);\n const draw = options.draw ?? \"reject\";\n if (draw !== \"reject\" && draw !== \"walk\") throw new RangeError(`The option draw is ${String(draw)}, not reject or walk.`);\n const fixed = options.fixed;\n if (fixed !== undefined) assertFixed(space, fixed, meta === \"sample\");\n if (options.n === 0) return [];\n const kept = restrict(space, options.shapes);\n const drawn = fixed === undefined ? kept : fixStages(space, kept, fixed, options.shapes);\n try {\n return sampleConfigs(drawn, options.n, options.seed, meta === \"sample\", options.maxTries ?? Math.max(1000, 100 * options.n), space, draw === \"walk\", new Set(Object.keys(fixed ?? {})));\n } catch (error) {\n // Only a space without a config for the shape kinds, or for the fixed options, gives the RangeError. A different failure keeps its own error.\n if (options.shapes !== undefined && !hasConfig(kept, meta === \"sample\")) throw noSample(space, kept, options.shapes, meta === \"sample\");\n if (fixed !== undefined && !hasConfig(drawn, meta === \"sample\")) throw noFixedSample(space, fixed);\n throw error;\n }\n}\n\n/**\n * This function gives the shape kinds that a space accepts, in the order of `SHAPE_KINDS`. The value comes from the `supports` of the options.\n * A space accepts a kind when it has at least one config without a meta option on that kind.\n */\nexport function spaceShapeKinds(space: StrategySpace): ShapeKind[] {\n assertSpace(space);\n return SHAPE_KIND_IDS.filter((k) => sizeOf(restrict(space, [k]), 1, 0n).base > 0n);\n}\n\n/**\n * This function joins configs of the parts of a product space into one config of the space `space`.\n * The name of each stage gets the prefix `<space of the part>.`. The members of a meta option do not change.\n */\nexport function joinConfigs(space: string, parts: readonly StrategyConfig[]): StrategyConfig {\n const stages: Record<string, StageChoice | null> = {};\n for (const part of parts) for (const [k, c] of Object.entries(part.stages)) stages[`${part.space}.${k}`] = c;\n return { space, stages };\n}\n\n/** This function gives the config of the part `engine` of a joint config. It throws a `RangeError` when no stage has the prefix `<engine>.`. */\nexport function splitConfig(config: StrategyConfig, engine: string): StrategyConfig {\n const head = `${engine}.`;\n const entries = Object.entries(config.stages).filter(([k]) => k.startsWith(head));\n if (entries.length === 0) throw new RangeError(`The config of the space ${config.space} has no stage of the part ${engine}.`);\n return { space: engine, stages: Object.fromEntries(entries.map(([k, c]) => [k.slice(head.length), c])) };\n}\n\n/**\n * This function joins two spaces, for example a packer and a router, into the space `name`. The stages of `a` and `b` get the prefixes `<a.engine>.` and `<b.engine>.`.\n * The constraints get the same prefixes. The named configs are the pairs `<name of a>+<name of b>`. It throws a `RangeError` when the two engines have the same name.\n */\nexport function productSpace(a: StrategySpace, b: StrategySpace, name: string): StrategySpace {\n if (a.engine === b.engine) throw new RangeError(`The two spaces have the same engine ${a.engine}.`);\n if (name === \"\") throw new RangeError(\"The product space has no name.\");\n const stagesOf = (s: StrategySpace): SpaceStage[] => s.stages.map((x) => ({ ...x, name: `${s.engine}.${x.name}` }));\n const ref = (s: StrategySpace, r: OptionRef): OptionRef => ({ stage: `${s.engine}.${r.stage}`, option: r.option });\n const constraintsOf = (s: StrategySpace): SpaceConstraint[] =>\n (s.constraints ?? []).map((c) => ({ if: ref(s, c.if), then: \"not\" in c.then ? { not: ref(s, c.then.not) } : ref(s, c.then) }));\n const named: Record<string, StrategyConfig> = {};\n for (const [ka, ca] of Object.entries(a.named ?? {})) for (const [kb, cb] of Object.entries(b.named ?? {})) named[`${ka}+${kb}`] = joinConfigs(name, [ca, cb]);\n const constraints = [...constraintsOf(a), ...constraintsOf(b)];\n return {\n schema: STRATEGY_SPACE_SCHEMA,\n engine: name,\n version: `${a.engine}@${a.version}+${b.engine}@${b.version}`,\n stages: [...stagesOf(a), ...stagesOf(b)],\n ...(constraints.length > 0 ? { constraints } : {}),\n ...(Object.keys(named).length > 0 ? { named } : {}),\n parts: [a, b],\n };\n}\n","import type { ParamWhen } from \"./strategy-space.ts\";\n\n/** The scale of a number option. A sweep on the scale `log` gives values with equal ratios, not with equal differences. */\nexport type OptionScale = \"linear\" | \"log\";\n\n/** The reason why an option has no default value. The strategy reads the absence, the caller sets it, the strategy calculates it, or the default is code. */\nexport type NoDefaultReason = \"unset\" | \"required\" | \"derived\" | \"function\";\n\n/** The statement of an option without a default value that JSON can hold. */\nexport interface NoDefault {\n readonly reason: NoDefaultReason;\n /** One short sentence that tells what the strategy does without a value. */\n readonly describe: string;\n}\n\n/** The fields of each option declaration. */\ninterface OptionBase {\n /** One short sentence that tells what the option sets. The site and the documents show it. */\n readonly describe: string;\n /** This field tells why the option has no default. The catalog of an engine has this field or a `default` on each option. */\n readonly noDefault?: NoDefault;\n /** The option is active only when an earlier option of the same strategy has one of these values. */\n readonly when?: ParamWhen;\n}\n\n/**\n * The declaration of a number option. The range from `min` to `max` is the range of a control and of a sweep.\n * The strategy can take a value outside the range. `checkOptions` reports such a value, and `clampOptions` moves it into the range.\n */\nexport interface NumberOption extends OptionBase {\n /** The type `integer` takes only whole numbers. */\n readonly type: \"number\" | \"integer\";\n readonly min: number;\n readonly max: number;\n /** The grain of a control and of a sweep. A value off the step is valid. Without it, the grain is free (or 1 for an integer). */\n readonly step?: number;\n /** The scale of a control and of a sweep. The default is `linear`. The scale `log` needs a `min` above 0. */\n readonly scale?: OptionScale;\n /** These values are valid outside the range. For example, `Infinity` sets no limit. */\n readonly special?: readonly number[];\n /** These values are the notable values of the option: the default and the values of the sweeps of the benchmark. */\n readonly marks?: readonly number[];\n /**\n * These values are the only valid values of the option, in the order of a control. A control shows them as a list, and a sweep gives them.\n * Without them, each value on the range is valid.\n */\n readonly values?: readonly number[];\n /** The strategy uses this value when the caller and `defaults` give no value. */\n readonly default?: number;\n}\n\n/** The declaration of a boolean option. */\nexport interface BooleanOption extends OptionBase {\n readonly type: \"boolean\";\n /** The strategy uses this value when the caller and `defaults` give no value. */\n readonly default?: boolean;\n}\n\n/** The declaration of an option with a fixed list of string values. */\nexport interface EnumOption<V extends string = string> extends OptionBase {\n readonly type: \"enum\";\n /** The values of the option, in the order of a control. */\n readonly values: readonly V[];\n /**\n * With `function`, the option also takes a rule of the caller in place of a name. A control sets only the names.\n * Each name is a known rule of the strategy.\n */\n readonly custom?: \"function\";\n /** The strategy uses this value when the caller and `defaults` give no value. */\n readonly default?: V;\n}\n\n/**\n * The declaration of an option that a control or a sweep cannot set from a range.\n * The type `function` is a rule, `strategy` is a strategy of the step `step`, `list` is an array and `object` is any other object.\n */\nexport interface ValueOption<V = unknown, S extends string = string> extends OptionBase {\n readonly type: \"function\" | \"strategy\" | \"list\" | \"object\";\n /** The step of the strategy, for the type `strategy`. A control lists the strategies of this step of a registry. */\n readonly step?: S;\n /** The kinds of strategy that the option takes, for the type `strategy`. Without them, the option takes each kind. */\n readonly kinds?: readonly string[];\n /** The key of the option that holds the options of the chosen strategy, for the type `strategy`. */\n readonly optionsKey?: string;\n /** The value `true` lets a value hold its options: a key, or an object with the fields `strategy`, `options` and `id`. This field is for the type `strategy`, and also for an item of a list. */\n readonly inlineOptions?: boolean;\n /** The value `false` leaves out the opt-in strategies, because the option finds only the default set of the engine. This field is for the type `strategy`. */\n readonly optIn?: boolean;\n /** For each dimension of `supports`, the value that a chosen strategy must take. This field is for the type `strategy`, and also for an item of a list. */\n readonly needs?: Readonly<Record<string, string>>;\n /** The declaration of each item, for the type `list`. */\n readonly of?: ListItem<S>;\n /** The smallest number of items, for the type `list`. */\n readonly min?: number;\n /** The largest number of items, for the type `list`. */\n readonly max?: number;\n /** The strategy uses this value when the caller and `defaults` give no value. */\n readonly default?: V;\n}\n\n/** The declaration of one option of any type. */\nexport type AnyOption<S extends string = string> = NumberOption | BooleanOption | EnumOption | ValueOption<unknown, S>;\n\n/** This type removes the fields of a whole option from a declaration. */\ntype ItemOf<T> = T extends unknown ? Omit<T, \"describe\" | \"default\" | \"noDefault\" | \"when\"> : never;\n\n/** The declaration of one item of a list option: an option without its text, its default and its condition. */\nexport type ListItem<S extends string = string> = ItemOf<AnyOption<S>>;\n\n/**\n * The declaration that fits the type of an option value: numbers, booleans, string unions or other values.\n * A union of strings and other values takes an enum of the strings or a value declaration. An example is a rule or the name of a rule.\n * A plain `string` takes an enum or a value declaration, because the value can be the key of a strategy.\n */\nexport type OptionDeclaration<V, S extends string = string> = [V] extends [number]\n ? NumberOption\n : [V] extends [boolean]\n ? BooleanOption\n : [V] extends [string]\n ? string extends V\n ? EnumOption<V> | ValueOption<V, S>\n : EnumOption<V>\n : [Extract<V, string>] extends [never]\n ? ValueOption<V, S>\n : EnumOption<Extract<V, string>> | ValueOption<V, S>;\n\n/** The declarations of the options of a strategy. The schema has one declaration for each key of the options type, and no other key. */\nexport type OptionSchema<O, S extends string = string> = { readonly [K in keyof O]-?: OptionDeclaration<NonNullable<O[K]>, S> };\n\n/** The fields of a strategy that the functions of this module read. An engine can add other fields. */\nexport interface DeclaredStrategy<O extends object = object, S extends string = string> {\n /** The name of the strategy in a message. */\n readonly name: string;\n readonly defaults: O;\n readonly schema?: OptionSchema<O, S>;\n}\n\n/** One problem of an option value against its declaration. */\nexport interface OptionIssue {\n /** The key of the option. */\n readonly key: string;\n readonly value: unknown;\n /** The kind of the problem: no declaration, the wrong type, out of the range, not a whole number or not one of the values. */\n readonly problem: \"unknown\" | \"type\" | \"range\" | \"integer\" | \"value\";\n /** One sentence that tells the problem. */\n readonly message: string;\n}\n\n/** One setting of a sweep: a name for the rows of a table, and the options of the strategy. */\nexport interface OptionSetting<O extends object> {\n /** The key and the value of each option of the setting, for example `stretch 1.5`. */\n readonly name: string;\n readonly options: Partial<O>;\n}\n\n/** The options of `sweepValues`, `sweepOf` and `sweepGrid`. */\nexport interface SweepOptions {\n /**\n * The number of values on the range of a number option. Without it, the sweep gives the `marks` of the declaration.\n * A declaration without `marks` gets 5 values.\n */\n readonly count?: number;\n /** With `true`, a sweep of a number option on the range also gives the `special` values. The default is `false`. */\n readonly special?: boolean;\n}\n\n/** The number of values of a sweep on a range when the call and the declaration give no number. */\nconst SWEEP_COUNT = 5;\n\n/** This function gives the declarations of a strategy as a record. A strategy without a schema gives an empty record. */\nfunction schemaOf<S extends string>(strategy: DeclaredStrategy<object, S>): Readonly<Record<string, AnyOption<S>>> {\n return (strategy.schema ?? {}) as Readonly<Record<string, AnyOption<S>>>;\n}\n\n/** This function gives the declared options of a strategy, in the order of its schema, with the effective default of each one. */\nexport function listOptions<O extends object, S extends string = string>(\n strategy: DeclaredStrategy<O, S>,\n): { readonly key: keyof O & string; readonly declaration: AnyOption<S>; readonly value: unknown }[] {\n const defaults = optionDefaults(strategy) as Record<string, unknown>;\n return Object.entries(schemaOf(strategy)).map(([key, declaration]) => ({ key: key as keyof O & string, declaration, value: defaults[key] }));\n}\n\n/**\n * This function gives the effective default of each declared option: the value of `defaults`, else the `default` of the declaration.\n * An option without either value stays out. The strategy gives the same output with this object as with no options.\n */\nexport function optionDefaults<O extends object, S extends string = string>(strategy: DeclaredStrategy<O, S>): Partial<O> {\n const out: Record<string, unknown> = {};\n const defaults = strategy.defaults as Readonly<Record<string, unknown>>;\n for (const [key, declaration] of Object.entries(schemaOf(strategy))) {\n if (key in defaults) out[key] = defaults[key];\n else if (declaration.default !== undefined) out[key] = declaration.default;\n }\n for (const key of Object.keys(defaults)) if (!(key in out)) out[key] = defaults[key];\n return out as Partial<O>;\n}\n\n/** This function gives `true` if the number is one of the special values of the declaration. */\nconst isSpecial = (d: NumberOption, v: number): boolean => (d.special ?? []).some((s) => Object.is(s, v) || s === v);\n\n/** This function gives the problem of one value against its declaration, or `undefined` when the value fits. */\nexport function optionIssue(key: string, value: unknown, d: AnyOption): OptionIssue | undefined {\n const issue = (problem: OptionIssue[\"problem\"], message: string): OptionIssue => ({ key, value, problem, message });\n if (value === undefined) return undefined;\n switch (d.type) {\n case \"number\":\n case \"integer\": {\n if (typeof value !== \"number\" || Number.isNaN(value)) return issue(\"type\", `The option \"${key}\" takes a number.`);\n if (isSpecial(d, value)) return undefined;\n if (d.values !== undefined && !d.values.includes(value)) return issue(\"value\", `The option \"${key}\" takes ${d.values.join(\", \")}, not ${value}.`);\n if (value < d.min || value > d.max) return issue(\"range\", `The option \"${key}\" is ${value}, out of the range ${d.min} to ${d.max}.`);\n if (d.type === \"integer\" && !Number.isInteger(value)) return issue(\"integer\", `The option \"${key}\" takes a whole number, not ${value}.`);\n return undefined;\n }\n case \"boolean\":\n return typeof value === \"boolean\" ? undefined : issue(\"type\", `The option \"${key}\" takes true or false.`);\n case \"enum\":\n if (d.custom === \"function\" && typeof value === \"function\") return undefined;\n return d.values.includes(value as string) ? undefined : issue(\"value\", `The option \"${key}\" takes ${d.values.join(\", \")}, not ${String(value)}.`);\n case \"function\":\n return typeof value === \"function\" ? undefined : issue(\"type\", `The option \"${key}\" takes a function.`);\n case \"list\":\n return Array.isArray(value) ? undefined : issue(\"type\", `The option \"${key}\" takes a list.`);\n default:\n return typeof value === \"object\" && value !== null ? undefined : issue(\"type\", `The option \"${key}\" takes an object.`);\n }\n}\n\n/**\n * This function examines option values against the schema of a strategy. It gives one issue for each key without a declaration.\n * It also gives one issue for each value of the wrong type, out of the range, not whole or not one of the values.\n * It changes no value.\n * A strategy without a schema gives no issue.\n */\nexport function checkOptions<O extends object>(strategy: DeclaredStrategy<O>, options: Partial<O>): OptionIssue[] {\n if (strategy.schema === undefined) return [];\n const schema = schemaOf(strategy);\n const out: OptionIssue[] = [];\n for (const [key, value] of Object.entries(options)) {\n const d = schema[key];\n const issue = d ? optionIssue(key, value, d) : { key, value, problem: \"unknown\" as const, message: `The strategy \"${strategy.name}\" has no option \"${key}\".` };\n if (issue) out.push(issue);\n }\n return out;\n}\n\n/**\n * This function moves each number option into the range of its declaration, for a control. An integer option gets the nearest whole number.\n * An option with a list of `values` gets the nearest value of the list. A special value stays. The function keeps each other value as it is. `checkOptions` reports the values that this function cannot correct.\n */\nexport function clampOptions<O extends object>(strategy: DeclaredStrategy<O>, options: Partial<O>): Partial<O> {\n const schema = schemaOf(strategy);\n const out: Record<string, unknown> = { ...options };\n for (const [key, value] of Object.entries(options)) {\n const d = schema[key];\n if (!d || (d.type !== \"number\" && d.type !== \"integer\") || typeof value !== \"number\" || Number.isNaN(value) || isSpecial(d, value)) continue;\n if (d.values !== undefined && d.values.length > 0) {\n out[key] = d.values.reduce((best, v) => (Math.abs(v - value) < Math.abs(best - value) ? v : best));\n continue;\n }\n const v = Math.min(d.max, Math.max(d.min, value));\n out[key] = d.type === \"integer\" ? Math.min(d.max, Math.max(d.min, Math.round(v))) : v;\n }\n return out as Partial<O>;\n}\n\n/** This function gives `count` values from `min` to `max` on the scale, on the grain of the step, without repeats. */\nfunction rangeValues(d: NumberOption, count: number): number[] {\n const n = Math.max(1, Math.floor(count));\n const log = d.scale === \"log\" && d.min > 0;\n const at = (t: number): number => (log ? d.min * (d.max / d.min) ** t : d.min + (d.max - d.min) * t);\n const step = d.step ?? (d.type === \"integer\" ? 1 : undefined);\n const snap = (v: number): number => {\n const s = step === undefined ? v : d.min + Math.round((v - d.min) / step) * step;\n const r = Number(s.toPrecision(12));\n return Math.min(d.max, Math.max(d.min, d.type === \"integer\" ? Math.round(r) : r));\n };\n const out: number[] = [];\n for (let i = 0; i < n; i++) {\n const v = snap(at(n === 1 ? 0 : i / (n - 1)));\n if (!out.includes(v)) out.push(v);\n }\n return out;\n}\n\n/**\n * This function gives the values of a sweep of one option declaration.\n * A number option gives its `marks`, or its list of `values`, or `count` values on its range and its scale. A boolean gives `false` and `true`. An enum gives its values.\n * An option of another type has no sweep, so the function throws an error.\n */\nexport function sweepValues(declaration: AnyOption, options: SweepOptions = {}): unknown[] {\n switch (declaration.type) {\n case \"number\":\n case \"integer\": {\n if (options.count === undefined && declaration.marks !== undefined) return [...declaration.marks];\n if (declaration.values !== undefined) return [...declaration.values];\n const values = rangeValues(declaration, options.count ?? SWEEP_COUNT);\n return options.special ? [...values, ...(declaration.special ?? []).filter((s) => !values.includes(s))] : values;\n }\n case \"boolean\":\n return [false, true];\n case \"enum\":\n return [...declaration.values];\n default:\n throw new Error(`An option of the type \"${declaration.type}\" has no sweep. A sweep takes a number, an integer, a boolean or an enum.`);\n }\n}\n\n/** This function gives the declaration of one option of a strategy. When the strategy has no such declaration, the function throws an error. */\nfunction declarationOf(strategy: DeclaredStrategy, key: string): AnyOption {\n const d = schemaOf(strategy)[key];\n if (!d) throw new Error(`The strategy \"${strategy.name}\" has no declaration of the option \"${key}\".`);\n return d;\n}\n\n/**\n * This function gives the settings of a sweep of one option of a strategy, from its declaration only.\n * The name of each setting is the key and the value, for example `stretch 1.5`.\n */\nexport function sweepOf<O extends object>(strategy: DeclaredStrategy<O>, key: keyof O & string, options: SweepOptions = {}): OptionSetting<O>[] {\n return sweepValues(declarationOf(strategy, key), options).map((value) => ({ name: `${key} ${String(value)}`, options: { [key]: value } as Partial<O> }));\n}\n\n/**\n * This function gives the settings of a grid of options: each combination of the values of the sweeps of the keys.\n * The name of a setting joins the names of its values with commas, in the order of the keys.\n */\nexport function sweepGrid<O extends object>(strategy: DeclaredStrategy<O>, keys: readonly (keyof O & string)[], options: SweepOptions = {}): OptionSetting<O>[] {\n let out: OptionSetting<O>[] = [{ name: \"\", options: {} }];\n for (const key of keys) {\n const sweep = sweepOf(strategy, key, options);\n out = out.flatMap((s) => sweep.map((t) => ({ name: s.name === \"\" ? t.name : `${s.name}, ${t.name}`, options: { ...s.options, ...t.options } })));\n }\n return keys.length === 0 ? [] : out;\n}\n\n/** This function gives the problems of one declaration: a bad range, a bad step, or marks and a default that do not fit. */\nexport function declarationIssues(key: string, d: AnyOption): string[] {\n const out: string[] = [];\n if (d.describe.trim().length === 0) out.push(`The option \"${key}\" has no description.`);\n if (d.type === \"number\" || d.type === \"integer\") {\n if (!Number.isFinite(d.min) || !Number.isFinite(d.max) || d.min > d.max) out.push(`The option \"${key}\" has the bad range ${d.min} to ${d.max}.`);\n if (d.type === \"integer\" && (!Number.isInteger(d.min) || !Number.isInteger(d.max))) out.push(`The integer option \"${key}\" has a range that is not whole.`);\n if (d.step !== undefined && !(d.step > 0)) out.push(`The option \"${key}\" has the step ${d.step}. A step is more than 0.`);\n if (d.scale === \"log\" && !(d.min > 0)) out.push(`The option \"${key}\" has the scale log and the min ${d.min}. The scale log needs a min above 0.`);\n if (d.values !== undefined && d.values.length === 0) out.push(`The number option \"${key}\" has an empty list of values.`);\n for (const v of d.values ?? []) {\n if (v < d.min || v > d.max || (d.type === \"integer\" && !Number.isInteger(v))) out.push(`The value ${v} of the option \"${key}\" is not on its range ${d.min} to ${d.max}.`);\n }\n for (const v of [...(d.marks ?? []), ...(d.default === undefined ? [] : [d.default])]) {\n const issue = optionIssue(key, v, d);\n if (issue) out.push(issue.message);\n }\n } else if (d.type === \"enum\") {\n if (d.values.length === 0) out.push(`The enum option \"${key}\" has no values.`);\n if (d.default !== undefined && !d.values.includes(d.default)) out.push(`The default of the option \"${key}\" is not one of its values.`);\n } else if (d.type === \"boolean\") {\n if (d.default !== undefined && typeof d.default !== \"boolean\") out.push(`The default of the option \"${key}\" is not true or false.`);\n }\n return out;\n}\n\n/**\n * This function examines the schema of a strategy. It gives one message for each option of `defaults` without a declaration.\n * It also gives one message for each bad declaration, and for each value of `defaults` that does not fit its declaration.\n * A good schema gives an empty list.\n */\nexport function checkSchema(strategy: DeclaredStrategy): string[] {\n const schema = schemaOf(strategy);\n const out: string[] = [];\n for (const key of Object.keys(strategy.defaults)) if (!(key in schema)) out.push(`The strategy \"${strategy.name}\" has the option \"${key}\" in its defaults, without a declaration.`);\n for (const [key, d] of Object.entries(schema)) out.push(...declarationIssues(key, d).map((m) => `The strategy \"${strategy.name}\": ${m}`));\n out.push(...checkOptions(strategy, strategy.defaults).filter((i) => i.problem !== \"unknown\").map((i) => `The strategy \"${strategy.name}\": ${i.message}`));\n return out;\n}\n","// The strategy catalog: every strategy and every option of an engine, as JSON (`docs/STRATEGY-CATALOG.md`).\nimport { canonicalJson } from \"./hash.ts\";\nimport type { Supports } from \"./record.ts\";\nimport { type AnyOption, declarationIssues, type ListItem, type NoDefaultReason, optionIssue, type OptionScale, type ValueOption } from \"./strategy-options.ts\";\nimport type { ParamValue, StrategySpace } from \"./strategy-space.ts\";\n\n/** The newest schema of a strategy catalog. A new field is a new version of the schema. */\nexport const STRATEGY_CATALOG_SCHEMA = \"strategy-catalog/3\";\n\n/** The schemas that `parseStrategyCatalog` reads, oldest first. Schema 2 adds the field `output` of an entry, and schema 3 adds the field `fingerprint`. */\nexport const STRATEGY_CATALOG_SCHEMAS: readonly [\"strategy-catalog/1\", \"strategy-catalog/2\", \"strategy-catalog/3\"] = [\"strategy-catalog/1\", \"strategy-catalog/2\", STRATEGY_CATALOG_SCHEMA];\n\n/** The form of the field `fingerprint` of an entry: the 16 lowercase hex digits that `fingerprintOf` gives. */\nconst FINGERPRINT = /^[0-9a-f]{16}$/u;\n\n/** The name of one schema of a strategy catalog. */\nexport type StrategyCatalogSchema = (typeof STRATEGY_CATALOG_SCHEMAS)[number];\n\n/**\n * The dimension of `supports` that tells who owns the positions of the nodes. The value `host` means that the strategy keeps the positions that the host gives.\n * The value `engine` means that the strategy can set them. A strategy that moves nodes has only `engine`. A `SupportProbe` tests the claim with a run.\n */\nexport const NODE_POSITIONS_DIMENSION = \"nodePositions\";\n\n/** A limit on one measure of the input. The key of the record of limits names the measure, for example `nodes`. */\nexport interface CatalogLimit {\n /** The smallest value that the strategy takes. */\n readonly min?: number;\n /** The largest value that the strategy takes. */\n readonly max?: number;\n /** One short sentence that tells what the strategy does outside the limit. */\n readonly describe: string;\n}\n\n/** The kind of a strategy: it places on its own, it wraps other strategies, or it is for one shape of item. */\nexport type StrategyKind = \"single\" | \"composite\" | \"shape\";\n\n/** The output properties that tell if the numbers of a result are whole: the positions and the sizes. The parser examines the class of these properties. */\nexport const OUTPUT_GRID_PROPERTIES: readonly string[] = [\"position-grid\", \"size-grid\"];\n\n/** The class of a grid property of an output. */\nexport type OutputGridClass = \"whole\" | \"near-whole\" | \"fractional\" | \"untested\";\n\n/** The largest distance from a whole number for a near-whole value. A value at a larger distance is fractional. */\nexport const OUTPUT_NEAR_WHOLE = 1e-9;\n\n/** The fewest packed inputs for the class `whole` or `near-whole`. A fraction needs no such count, because one counterexample is a proof. */\nexport const OUTPUT_CLASS_MIN_INPUTS = 30;\n\n/** What one read of an output covers. The row states no promise beyond this evidence. */\nexport interface OutputEvidence {\n /** The count of inputs that the strategy packed in this read. */\n readonly inputs: number;\n /** The count of inputs with a fractional value of the property. A grid property must have this field. */\n readonly fractionalInputs?: number;\n /** The count of inputs with a near-whole value and no fractional value of the property. A grid property must have this field. */\n readonly nearWholeInputs?: number;\n /** The input family or the study of the read. */\n readonly source: string;\n /** The name of the options of the read, for example `default`. */\n readonly optionSet: string;\n /** The version of the catalog that the read used. */\n readonly catalogVersion: string;\n}\n\n/** One property of the output of a strategy, as a read found it. An entry has one row for each pair of `property` and `optionSet`. */\nexport interface OutputRow {\n /** The property, for example `position-grid`. */\n readonly property: string;\n /** The class of the property. For a grid property, `outputGridClass` gives the only class that the evidence permits. */\n readonly class: string;\n readonly evidence: OutputEvidence;\n}\n\n/** The counts that decide the class of a grid property. */\nexport interface OutputGridCounts {\n readonly inputs: number;\n readonly fractionalInputs: number;\n readonly nearWholeInputs: number;\n}\n\n/**\n * This function gives the class of a grid property from its counts. One fractional input gives `fractional` at any count.\n * With no fraction, fewer than `OUTPUT_CLASS_MIN_INPUTS` inputs give `untested`. Each other read gives `near-whole` or `whole`.\n */\nexport function outputGridClass(counts: OutputGridCounts): OutputGridClass {\n if (counts.fractionalInputs > 0) return \"fractional\";\n if (counts.inputs < OUTPUT_CLASS_MIN_INPUTS) return \"untested\";\n return counts.nearWholeInputs > 0 ? \"near-whole\" : \"whole\";\n}\n\n/** One strategy of a catalog. */\nexport interface CatalogEntry {\n /** The key is unique in the catalog: `<step>/<id>` with a step, else `id`. */\n readonly key: string;\n /** The name that the engine reads. */\n readonly id: string;\n /** The step of the pipeline of the engine. An engine without steps leaves it out. */\n readonly step?: string;\n /** The group of the strategy in a chooser. */\n readonly family: string;\n readonly kind: StrategyKind;\n /** One line that tells what the strategy does. */\n readonly describe: string;\n /** For each dimension, the values that the strategy takes. A dimension that is not here has no declared limit. */\n readonly supports: Supports;\n /** The limits of the strategy on the measures of the input. An empty record means that the engine declares no limit. */\n readonly limits: Readonly<Record<string, CatalogLimit>>;\n /** The value is `true` when, with the default options, the result depends only on the input, the options and the seed. */\n readonly deterministic: boolean;\n /** One sentence that tells what can change this claim, for example a clock. */\n readonly determinismNote?: string;\n /** The value is `true` when the strategy is outside the default set of the engine, and a caller asks for it by name. */\n readonly optIn: boolean;\n /** The value `true` tells that the strategy is a baseline of a bench. It has `optIn` true, and a chooser does not offer it. */\n readonly baseline?: true;\n /** The reads of the output of the strategy. A file with this field has the schema 2. */\n readonly output?: readonly OutputRow[];\n /** The fingerprint of the outputs of the strategy on the probes of its engine, from `fingerprintOf`. A file with this field has the schema 3. */\n readonly fingerprint?: string;\n /** The declarations of the options, in the order of a form. */\n readonly options: Readonly<Record<string, AnyOption>>;\n}\n\n/** The form of a catalog that an engine exports as data. It holds no version: the build gives the version from `package.json`. */\nexport interface StrategyCatalogSource {\n /** The npm name of the engine, without its scope. */\n readonly engine: string;\n readonly strategies: readonly CatalogEntry[];\n}\n\n/** A catalog document: the form that `writeStrategyCatalog` writes and `parseStrategyCatalog` reads. */\nexport interface StrategyCatalog extends StrategyCatalogSource {\n readonly schema: StrategyCatalogSchema;\n /** The npm version of the engine. */\n readonly version: string;\n}\n\n/** The result of `parseStrategyCatalog`. */\nexport type StrategyCatalogParse = { readonly ok: true; readonly catalog: StrategyCatalog } | { readonly ok: false; readonly faults: readonly string[] };\n\n/** The live facts of one strategy, for `checkCatalog`. */\nexport interface RegistryEntry {\n readonly key: string;\n /** The live defaults of the strategy. */\n readonly defaults: Readonly<Record<string, unknown>>;\n readonly optIn: boolean;\n /** The value `true` tells that the strategy is a baseline of a bench. */\n readonly baseline?: boolean;\n /** The limits in the code of the engine. Without them, the engine has no limits. */\n readonly limits?: Readonly<Record<string, { readonly min?: number; readonly max?: number }>>;\n /** This function runs the strategy on a small fixture and gives its output as text. The text does not hold times. */\n readonly run?: () => string;\n}\n\n/** A test of one value of `supports`: each strategy runs on an input with this value. */\nexport interface SupportProbe {\n /** The dimension of `supports`. */\n readonly field: string;\n readonly value: string;\n /** This function gives `true` if the strategy refuses the input, and `undefined` if the input cannot go to this strategy. */\n readonly refuses: (key: string) => boolean | undefined;\n}\n\n/**\n * The statement of how one place of a space reaches the options of an engine. The file of a catalog does not hold it, because a value can hold code.\n *\n * - `spaceOnly` tells that the place sets no option, with one sentence that tells why. A stage option without an entry can also have this statement.\n * - `option` names the option of the param, when the option has another name. `value` gives the option value of one param value, and `undefined` when the param value sets no option.\n */\nexport type ParamRoute =\n | { readonly spaceOnly: string }\n | { readonly option?: string; readonly value?: (value: ParamValue) => unknown };\n\n/** The options of `checkCatalog`. */\nexport interface CatalogCheckOptions {\n /** Each param of these spaces is examined against the declaration of its option. */\n readonly spaces?: readonly StrategySpace[];\n /** The routes of the params of `spaces`. The key is `<stage>/<option>.<param>`, or `<stage>/<option>` for a stage option. A route that matches nothing is a fault. */\n readonly paramRoutes?: Readonly<Record<string, ParamRoute>>;\n readonly probes?: readonly SupportProbe[];\n /** This function runs `owner` with `choice` in its option `option`. It gives `true` for a refusal, or `undefined` if the input cannot go to `owner`. */\n readonly refusesChoice?: (owner: string, option: string, choice: string) => boolean | undefined;\n}\n\n/** The result of `checkCatalog`. */\nexport interface CatalogCheck {\n /** Each break of a rule, as one sentence. A good catalog has none. */\n readonly faults: readonly string[];\n /** The claims that no run examined, by key and with the reason. */\n readonly notRun: readonly string[];\n /** The stage options and the params of a space that have no entry, no declaration and no route. */\n readonly notMatched: readonly string[];\n /** The places of a space with a `spaceOnly` route, each with its reason. */\n readonly spaceOnly: readonly string[];\n}\n\n/** The value of a strategy option that holds the options of the chosen strategy. A declaration with `inlineOptions` takes it. */\nexport interface StrategyMember {\n /** The key of the chosen strategy. */\n readonly strategy: string;\n /** The options of the chosen strategy, in the JSON form of its declarations. */\n readonly options?: Readonly<Record<string, unknown>>;\n /** The name of the member in the output. */\n readonly id?: string;\n}\n\n/** The options of `catalogOptions`. */\nexport interface CatalogOptionsOptions {\n /** This function gives the key of a strategy from a default value of the type `strategy`. */\n readonly strategyKey?: (value: unknown) => string | undefined;\n}\n\nconst STRATEGY_KINDS: readonly string[] = [\"single\", \"composite\", \"shape\"];\nconst NO_DEFAULT_REASONS: readonly NoDefaultReason[] = [\"unset\", \"required\", \"derived\", \"function\"];\nconst SCALES: readonly OptionScale[] = [\"linear\", \"log\"];\nconst TOP_FIELDS: readonly string[] = [\"schema\", \"engine\", \"version\", \"strategies\"];\nconst ENTRY_FIELDS: readonly string[] = [\"key\", \"id\", \"step\", \"family\", \"kind\", \"describe\", \"supports\", \"limits\", \"deterministic\", \"determinismNote\", \"optIn\", \"baseline\", \"output\", \"fingerprint\", \"options\"];\nconst COMMON_FIELDS: readonly string[] = [\"type\", \"describe\", \"default\", \"noDefault\", \"when\"];\nconst NUMBER_FIELDS: readonly string[] = [...COMMON_FIELDS, \"min\", \"max\", \"step\", \"scale\", \"special\", \"marks\", \"values\"];\nconst ENUM_FIELDS: readonly string[] = [...COMMON_FIELDS, \"values\", \"custom\"];\nconst STRATEGY_FIELDS: readonly string[] = [...COMMON_FIELDS, \"step\", \"kinds\", \"optionsKey\", \"inlineOptions\", \"optIn\", \"needs\"];\nconst MEMBER_FIELDS: readonly string[] = [\"strategy\", \"options\", \"id\"];\nconst LIST_FIELDS: readonly string[] = [...COMMON_FIELDS, \"of\", \"min\", \"max\"];\nconst ROW_FIELDS: readonly string[] = [\"property\", \"class\", \"evidence\"];\nconst EVIDENCE_FIELDS: readonly string[] = [\"inputs\", \"fractionalInputs\", \"nearWholeInputs\", \"source\", \"optionSet\", \"catalogVersion\"];\n/** The fields of a declaration, in the order of the file. */\nconst OPTION_ORDER: readonly string[] = [\"type\", \"describe\", \"min\", \"max\", \"step\", \"scale\", \"special\", \"marks\", \"values\", \"custom\", \"kinds\", \"optionsKey\", \"inlineOptions\", \"optIn\", \"needs\", \"of\", \"default\", \"noDefault\", \"when\"];\n\ntype Fields = Readonly<Record<string, unknown>>;\n\nconst isFields = (v: unknown): v is Fields => typeof v === \"object\" && v !== null && !Array.isArray(v);\nconst isText = (v: unknown): v is string => typeof v === \"string\" && v.trim() !== \"\";\nconst isTextList = (v: unknown): v is readonly string[] => Array.isArray(v) && v.every(isText);\nconst isFiniteNumber = (v: unknown): v is number => typeof v === \"number\" && Number.isFinite(v);\nconst isMember = (v: unknown): v is StrategyMember =>\n isFields(v) &&\n isText(v[\"strategy\"]) &&\n (v[\"options\"] === undefined || isFields(v[\"options\"])) &&\n (v[\"id\"] === undefined || isText(v[\"id\"])) &&\n Object.keys(v).every((k) => MEMBER_FIELDS.includes(k));\n\n/** This function gives the key of a strategy from its step and its id. */\nexport function catalogKey(id: string, step?: string): string {\n return step === undefined ? id : `${step}/${id}`;\n}\n\n/** This function adds one fault for each field of `o` that is not in `allowed`. */\nfunction refuseUnknown(at: string, o: Fields, allowed: readonly string[], faults: string[]): void {\n for (const key of Object.keys(o)) if (!allowed.includes(key)) faults.push(`${at}: the field \"${key}\" is unknown.`);\n}\n\n/** This function restores a number field of a file. It gives `undefined` for each value that is not a finite number, `\"Infinity\"` or `\"-Infinity\"`. */\nfunction readNumber(v: unknown): number | undefined {\n if (v === \"Infinity\") return Infinity;\n if (v === \"-Infinity\") return -Infinity;\n return isFiniteNumber(v) ? v : undefined;\n}\n\n/** This function restores a list of number fields, with one fault for each bad value. */\nfunction readNumbers(at: string, v: unknown, faults: string[]): number[] | undefined {\n if (!Array.isArray(v)) {\n faults.push(`${at} is not a list.`);\n return undefined;\n }\n const out: number[] = [];\n for (const x of v) {\n const n = readNumber(x);\n if (n === undefined) faults.push(`${at} holds a value that is not a number.`);\n else out.push(n);\n }\n return out;\n}\n\n/** This function gives the fields of a number declaration, restored from a file. */\nfunction readNumberFields(at: string, raw: Fields, faults: string[]): Fields {\n const out: Record<string, unknown> = {};\n for (const f of [\"min\", \"max\"]) {\n if (isFiniteNumber(raw[f])) out[f] = raw[f];\n else faults.push(`${at}: \"${f}\" is not a finite number.`);\n }\n if (raw[\"step\"] !== undefined) {\n if (isFiniteNumber(raw[\"step\"])) out[\"step\"] = raw[\"step\"];\n else faults.push(`${at}: \"step\" is not a finite number.`);\n }\n if (raw[\"scale\"] !== undefined) {\n if (SCALES.includes(raw[\"scale\"] as OptionScale)) out[\"scale\"] = raw[\"scale\"];\n else faults.push(`${at}: \"scale\" is not linear or log.`);\n }\n for (const f of [\"special\", \"marks\"]) {\n if (raw[f] === undefined) continue;\n const list = readNumbers(`${at}: \"${f}\"`, raw[f], faults);\n if (list !== undefined) out[f] = list;\n }\n if (raw[\"values\"] !== undefined) {\n if (Array.isArray(raw[\"values\"]) && raw[\"values\"].every(isFiniteNumber)) out[\"values\"] = raw[\"values\"];\n else faults.push(`${at}: \"values\" is not a list of finite numbers.`);\n }\n if (raw[\"default\"] !== undefined) {\n const n = readNumber(raw[\"default\"]);\n if (n === undefined) faults.push(`${at}: the default is not a number.`);\n else out[\"default\"] = n;\n }\n return out;\n}\n\n/** This function gives the fields of a list declaration, restored from a file. */\nfunction readListFields(at: string, raw: Fields, faults: string[]): Fields {\n const out: Record<string, unknown> = {};\n if (raw[\"of\"] !== undefined) {\n const item = readOption(`${at}: \"of\"`, raw[\"of\"], true, faults);\n if (item !== undefined) out[\"of\"] = item;\n if (isFields(raw[\"of\"]) && raw[\"of\"][\"optionsKey\"] !== undefined) faults.push(`${at}: an item of a list has no sibling for \"optionsKey\". Use \"inlineOptions\".`);\n }\n for (const f of [\"min\", \"max\"]) {\n if (raw[f] === undefined) continue;\n if (Number.isInteger(raw[f]) && (raw[f] as number) >= 0) out[f] = raw[f];\n else faults.push(`${at}: \"${f}\" is not a whole number.`);\n }\n if (raw[\"default\"] !== undefined) {\n if (Array.isArray(raw[\"default\"])) out[\"default\"] = raw[\"default\"];\n else faults.push(`${at}: the default is not a list.`);\n }\n if (typeof out[\"min\"] === \"number\" && typeof out[\"max\"] === \"number\" && out[\"min\"] > out[\"max\"]) faults.push(`${at}: \"min\" is more than \"max\".`);\n return out;\n}\n\n/** This function gives the fields of a `strategy` declaration, restored from a file. */\nfunction readStrategyFields(at: string, raw: Fields, faults: string[]): Fields {\n const out: Record<string, unknown> = {};\n if (raw[\"step\"] !== undefined) {\n if (isText(raw[\"step\"])) out[\"step\"] = raw[\"step\"];\n else faults.push(`${at}: \"step\" is not a text.`);\n }\n if (raw[\"kinds\"] !== undefined) {\n if (isTextList(raw[\"kinds\"]) && raw[\"kinds\"].every((k) => STRATEGY_KINDS.includes(k))) out[\"kinds\"] = raw[\"kinds\"];\n else faults.push(`${at}: \"kinds\" is not a list of strategy kinds.`);\n }\n if (raw[\"optionsKey\"] !== undefined) {\n if (isText(raw[\"optionsKey\"])) out[\"optionsKey\"] = raw[\"optionsKey\"];\n else faults.push(`${at}: \"optionsKey\" is not a text.`);\n }\n for (const f of [\"inlineOptions\", \"optIn\"]) {\n if (raw[f] === undefined) continue;\n if (typeof raw[f] === \"boolean\") out[f] = raw[f];\n else faults.push(`${at}: \"${f}\" is not true or false.`);\n }\n if (raw[\"needs\"] !== undefined) {\n if (isFields(raw[\"needs\"]) && Object.values(raw[\"needs\"]).every(isText)) out[\"needs\"] = raw[\"needs\"];\n else faults.push(`${at}: \"needs\" is not a record of texts.`);\n }\n if (raw[\"inlineOptions\"] === true && raw[\"optionsKey\"] !== undefined) faults.push(`${at}: \"inlineOptions\" and \"optionsKey\" give two places for the options.`);\n if (raw[\"default\"] !== undefined) {\n if (isText(raw[\"default\"]) || (raw[\"inlineOptions\"] === true && isMember(raw[\"default\"]))) out[\"default\"] = raw[\"default\"];\n else faults.push(`${at}: the default is not the key of a strategy.`);\n }\n return out;\n}\n\n/** This function gives the fields that belong only to the type of a declaration, restored from a file. */\nfunction readTypeFields(at: string, type: string, raw: Fields, faults: string[]): Fields {\n switch (type) {\n case \"number\":\n case \"integer\":\n refuseUnknown(at, raw, NUMBER_FIELDS, faults);\n return readNumberFields(at, raw, faults);\n case \"boolean\":\n refuseUnknown(at, raw, COMMON_FIELDS, faults);\n if (raw[\"default\"] !== undefined && typeof raw[\"default\"] !== \"boolean\") faults.push(`${at}: the default is not true or false.`);\n return raw[\"default\"] === undefined ? {} : { default: raw[\"default\"] };\n case \"enum\": {\n refuseUnknown(at, raw, ENUM_FIELDS, faults);\n if (!isTextList(raw[\"values\"])) faults.push(`${at}: \"values\" is not a list of texts.`);\n if (raw[\"custom\"] !== undefined && raw[\"custom\"] !== \"function\") faults.push(`${at}: \"custom\" is not \"function\".`);\n return { values: raw[\"values\"], ...(raw[\"custom\"] === undefined ? {} : { custom: raw[\"custom\"] }), ...(raw[\"default\"] === undefined ? {} : { default: raw[\"default\"] }) };\n }\n case \"strategy\":\n refuseUnknown(at, raw, STRATEGY_FIELDS, faults);\n return readStrategyFields(at, raw, faults);\n case \"list\":\n refuseUnknown(at, raw, LIST_FIELDS, faults);\n return readListFields(at, raw, faults);\n case \"object\":\n refuseUnknown(at, raw, COMMON_FIELDS, faults);\n return raw[\"default\"] === undefined ? {} : { default: raw[\"default\"] };\n case \"function\":\n refuseUnknown(at, raw, COMMON_FIELDS, faults);\n if (raw[\"default\"] !== undefined) faults.push(`${at}: a function option has no default in JSON.`);\n return {};\n default:\n faults.push(`${at}: the type \"${type}\" is unknown.`);\n return {};\n }\n}\n\n/** This function adds the faults of the statement of an absent default, and gives the statement. */\nfunction readNoDefault(at: string, raw: unknown, faults: string[]): Fields | undefined {\n if (!isFields(raw)) {\n faults.push(`${at}: \"noDefault\" is not an object.`);\n return undefined;\n }\n refuseUnknown(`${at}: \"noDefault\"`, raw, [\"reason\", \"describe\"], faults);\n if (!NO_DEFAULT_REASONS.includes(raw[\"reason\"] as NoDefaultReason)) faults.push(`${at}: the reason of \"noDefault\" is unknown.`);\n if (!isText(raw[\"describe\"])) faults.push(`${at}: \"noDefault\" has no description.`);\n return { reason: raw[\"reason\"], describe: raw[\"describe\"] };\n}\n\n/** This function restores one declaration of a file. An item of a list has only the fields of its type. */\nfunction readOption(at: string, raw: unknown, item: boolean, faults: string[]): AnyOption | ListItem | undefined {\n if (!isFields(raw)) {\n faults.push(`${at} is not an object.`);\n return undefined;\n }\n const type = raw[\"type\"];\n if (typeof type !== \"string\") {\n faults.push(`${at} has no type.`);\n return undefined;\n }\n const before = faults.length;\n const fields = readTypeFields(at, type, raw, faults);\n const out: Record<string, unknown> = { type, ...fields };\n if (item) {\n for (const f of [\"describe\", \"default\", \"noDefault\", \"when\"]) if (raw[f] !== undefined) faults.push(`${at}: an item of a list has no \"${f}\".`);\n } else {\n if (isText(raw[\"describe\"])) out[\"describe\"] = raw[\"describe\"];\n else faults.push(`${at} has no description.`);\n const hasDefault = raw[\"default\"] !== undefined;\n const hasNoDefault = raw[\"noDefault\"] !== undefined;\n if (hasDefault === hasNoDefault) faults.push(`${at} has ${hasDefault ? \"both\" : \"neither\"} of \"default\" and \"noDefault\".`);\n if (hasNoDefault) out[\"noDefault\"] = readNoDefault(at, raw[\"noDefault\"], faults);\n if (raw[\"when\"] !== undefined) out[\"when\"] = raw[\"when\"];\n }\n return faults.length === before ? (out as unknown as AnyOption) : undefined;\n}\n\n/** This function adds the faults of the condition of an option, against the options before it. */\nfunction checkWhen(at: string, when: unknown, earlier: readonly string[], faults: string[]): void {\n if (!isFields(when) || !isText(when[\"param\"]) || !Array.isArray(when[\"in\"])) {\n faults.push(`${at}: \"when\" has no \"param\" and \"in\".`);\n return;\n }\n refuseUnknown(`${at}: \"when\"`, when, [\"param\", \"in\"], faults);\n if (!earlier.includes(when[\"param\"])) faults.push(`${at}: \"when\" names \"${when[\"param\"]}\", which is not an earlier option.`);\n}\n\n/** This function adds the faults of the limits of an entry. */\nfunction checkLimits(at: string, limits: unknown, faults: string[]): void {\n if (!isFields(limits)) {\n faults.push(`${at}: \"limits\" is not an object.`);\n return;\n }\n for (const [name, raw] of Object.entries(limits)) {\n const place = `${at}: the limit \"${name}\"`;\n if (!isFields(raw)) {\n faults.push(`${place} is not an object.`);\n continue;\n }\n refuseUnknown(place, raw, [\"min\", \"max\", \"describe\"], faults);\n if (!isText(raw[\"describe\"])) faults.push(`${place} has no description.`);\n if (raw[\"min\"] === undefined && raw[\"max\"] === undefined) faults.push(`${place} has no \"min\" and no \"max\".`);\n for (const f of [\"min\", \"max\"]) if (raw[f] !== undefined && !isFiniteNumber(raw[f])) faults.push(`${place}: \"${f}\" is not a finite number.`);\n if (isFiniteNumber(raw[\"min\"]) && isFiniteNumber(raw[\"max\"]) && raw[\"min\"] > raw[\"max\"]) faults.push(`${place}: \"min\" is more than \"max\".`);\n }\n}\n\n/** This function adds the faults of the evidence of one output row. */\nfunction checkEvidence(at: string, property: unknown, rowClass: unknown, raw: unknown, faults: string[]): void {\n if (!isFields(raw)) {\n faults.push(`${at}: \"evidence\" is not an object.`);\n return;\n }\n refuseUnknown(`${at}: the evidence`, raw, EVIDENCE_FIELDS, faults);\n for (const f of [\"source\", \"optionSet\", \"catalogVersion\"]) if (!isText(raw[f])) faults.push(`${at}: the evidence field \"${f}\" is not a text.`);\n const count = (v: unknown): v is number => Number.isInteger(v) && (v as number) >= 0;\n if (!count(raw[\"inputs\"])) faults.push(`${at}: the evidence field \"inputs\" is not a count.`);\n const grid = OUTPUT_GRID_PROPERTIES.includes(property as string);\n for (const f of [\"fractionalInputs\", \"nearWholeInputs\"]) if (grid ? !count(raw[f]) : raw[f] !== undefined && !count(raw[f])) faults.push(`${at}: the evidence field \"${f}\" is not a count.`);\n const [inputs, fractionalInputs, nearWholeInputs] = [raw[\"inputs\"], raw[\"fractionalInputs\"], raw[\"nearWholeInputs\"]];\n if (!grid || !count(inputs) || !count(fractionalInputs) || !count(nearWholeInputs)) return;\n if (fractionalInputs + nearWholeInputs > inputs) faults.push(`${at}: the fractional and near-whole counts are more than the inputs.`);\n const expected = outputGridClass({ inputs, fractionalInputs, nearWholeInputs });\n if (rowClass !== expected) faults.push(`${at}: the evidence gives the class \"${expected}\".`);\n}\n\n/** This function adds the faults of the field `output` of one entry. */\nfunction checkOutput(at: string, raw: unknown, schema: unknown, faults: string[]): void {\n if (schema === STRATEGY_CATALOG_SCHEMAS[0]) faults.push(`${at}: the field \"output\" needs the schema ${STRATEGY_CATALOG_SCHEMAS[1]} or a newer schema.`);\n if (!Array.isArray(raw) || raw.length === 0) {\n faults.push(`${at}: \"output\" is not a list with rows.`);\n return;\n }\n const seen = new Set<string>();\n (raw as readonly unknown[]).forEach((row, i) => {\n const place = `${at}: the output row ${i}`;\n if (!isFields(row)) {\n faults.push(`${place} is not an object.`);\n return;\n }\n refuseUnknown(place, row, ROW_FIELDS, faults);\n for (const f of [\"property\", \"class\"]) if (!isText(row[f])) faults.push(`${place}: \"${f}\" is not a text.`);\n checkEvidence(place, row[\"property\"], row[\"class\"], row[\"evidence\"], faults);\n const optionSet = isFields(row[\"evidence\"]) ? row[\"evidence\"][\"optionSet\"] : undefined;\n const name = JSON.stringify([row[\"property\"], optionSet]);\n if (seen.has(name)) faults.push(`${place}: the property and the option set are not unique.`);\n seen.add(name);\n });\n}\n\n/** This function restores one entry of a file. */\nfunction readEntry(at: string, raw: unknown, schema: unknown, faults: string[]): CatalogEntry | undefined {\n if (!isFields(raw)) {\n faults.push(`${at} is not an object.`);\n return undefined;\n }\n const before = faults.length;\n refuseUnknown(at, raw, ENTRY_FIELDS, faults);\n for (const f of [\"key\", \"id\", \"family\", \"describe\"]) if (!isText(raw[f])) faults.push(`${at}: \"${f}\" is not a text.`);\n if (raw[\"step\"] !== undefined && !isText(raw[\"step\"])) faults.push(`${at}: \"step\" is not a text.`);\n if (raw[\"determinismNote\"] !== undefined && !isText(raw[\"determinismNote\"])) faults.push(`${at}: \"determinismNote\" is not a text.`);\n if (!STRATEGY_KINDS.includes(raw[\"kind\"] as string)) faults.push(`${at}: \"kind\" is unknown.`);\n for (const f of [\"deterministic\", \"optIn\"]) if (typeof raw[f] !== \"boolean\") faults.push(`${at}: \"${f}\" is not true or false.`);\n if (raw[\"baseline\"] !== undefined && raw[\"baseline\"] !== true) faults.push(`${at}: \"baseline\" is not true.`);\n if (raw[\"baseline\"] === true && raw[\"optIn\"] !== true) faults.push(`${at}: a baseline has \"optIn\" true.`);\n if (!isFields(raw[\"supports\"]) || !Object.values(raw[\"supports\"]).every(isTextList)) faults.push(`${at}: \"supports\" is not a record of text lists.`);\n checkLimits(at, raw[\"limits\"], faults);\n if (raw[\"output\"] !== undefined) checkOutput(at, raw[\"output\"], schema, faults);\n if (raw[\"fingerprint\"] !== undefined) {\n if (schema !== STRATEGY_CATALOG_SCHEMAS[2]) faults.push(`${at}: the field \"fingerprint\" needs the schema ${STRATEGY_CATALOG_SCHEMAS[2]}.`);\n if (!isText(raw[\"fingerprint\"]) || !FINGERPRINT.test(raw[\"fingerprint\"])) faults.push(`${at}: \"fingerprint\" is not 16 lowercase hex digits.`);\n }\n if (isText(raw[\"id\"]) && raw[\"key\"] !== catalogKey(raw[\"id\"], raw[\"step\"] as string | undefined)) faults.push(`${at}: the key does not follow from \"step\" and \"id\".`);\n if (!isFields(raw[\"options\"])) {\n faults.push(`${at}: \"options\" is not an object.`);\n return undefined;\n }\n const options: Record<string, AnyOption> = {};\n const earlier: string[] = [];\n for (const [key, value] of Object.entries(raw[\"options\"])) {\n const place = `${at}: the option \"${key}\"`;\n const option = readOption(place, value, false, faults) as AnyOption | undefined;\n if (option !== undefined) {\n options[key] = option;\n for (const message of declarationIssues(key, option)) faults.push(`${at}: ${message}`);\n if (option.when !== undefined) checkWhen(place, option.when, earlier, faults);\n }\n earlier.push(key);\n }\n if (faults.length !== before) return undefined;\n const { step, determinismNote } = raw as { readonly step?: string; readonly determinismNote?: string };\n return {\n key: raw[\"key\"] as string,\n id: raw[\"id\"] as string,\n ...(step === undefined ? {} : { step }),\n family: raw[\"family\"] as string,\n kind: raw[\"kind\"] as StrategyKind,\n describe: raw[\"describe\"] as string,\n supports: raw[\"supports\"] as Supports,\n limits: raw[\"limits\"] as Readonly<Record<string, CatalogLimit>>,\n deterministic: raw[\"deterministic\"] as boolean,\n ...(determinismNote === undefined ? {} : { determinismNote }),\n optIn: raw[\"optIn\"] as boolean,\n ...(raw[\"baseline\"] === true ? { baseline: true as const } : {}),\n ...(raw[\"output\"] === undefined ? {} : { output: raw[\"output\"] as readonly OutputRow[] }),\n ...(raw[\"fingerprint\"] === undefined ? {} : { fingerprint: raw[\"fingerprint\"] as string }),\n options,\n };\n}\n\n/**\n * This function gives the strategies that a chooser offers, by the `step`, `kinds`, `optIn` and `needs` of an option. Thus no chooser keeps a copy of this rule.\n * A baseline is not in the result. A list gives the strategies of its items. An option of each other type gives nothing.\n * A strategy that does not list a dimension of `needs` has no declared limit there, so the option offers it.\n * Without a declaration, the function gives each strategy that is not a baseline.\n */\nexport function catalogChoices(strategies: readonly CatalogEntry[], declaration?: AnyOption | ListItem): readonly CatalogEntry[] {\n const offered = strategies.filter((e) => e.baseline !== true);\n if (declaration === undefined) return offered;\n const d = (declaration.type === \"list\" ? declaration.of : declaration) as ValueOption | undefined;\n if (d?.type !== \"strategy\") return [];\n const needs = Object.entries(d.needs ?? {});\n return offered.filter(\n (e) =>\n (d.step === undefined || e.step === d.step) &&\n (d.kinds === undefined || d.kinds.includes(e.kind)) &&\n (d.optIn === undefined || d.optIn === e.optIn) &&\n needs.every(([dimension, value]) => e.supports[dimension]?.includes(value) !== false),\n );\n}\n\n/** This function adds one fault for each option of a member that its chosen strategy does not take. */\nfunction checkMember(at: string, member: StrategyMember, chosen: CatalogEntry, faults: string[]): void {\n for (const [key, value] of Object.entries(member.options ?? {})) {\n const declaration = chosen.options[key];\n if (declaration === undefined) {\n faults.push(`${at}: the default gives \"${key}\", and ${chosen.key} has no such option.`);\n continue;\n }\n const issue = declaration.type === \"strategy\" ? undefined : optionIssue(key, decodeOptionValue(value, declaration), declaration);\n if (issue !== undefined) faults.push(`${at}: ${issue.message}`);\n }\n}\n\n/** This function adds one fault for each reference that names no strategy of the catalog, or a strategy that the option does not take. */\nfunction checkReferences(entries: readonly CatalogEntry[], faults: string[]): void {\n const check = (at: string, o: AnyOption | ListItem, values: readonly unknown[]): void => {\n const choices = catalogChoices(entries, o);\n if (choices.length === 0) faults.push(`${at} takes no strategy of the catalog.`);\n for (const value of values) {\n const inline = ((o.type === \"list\" ? o.of : o) as ValueOption).inlineOptions === true && isMember(value);\n const key = inline ? value.strategy : value;\n const chosen = choices.find((e) => e.key === key);\n if (chosen === undefined) faults.push(`${at}: the default ${JSON.stringify(key)} is not a strategy that the option takes.`);\n else if (inline) checkMember(at, value, chosen, faults);\n }\n };\n for (const entry of entries) {\n for (const [key, o] of Object.entries(entry.options)) {\n const at = `${entry.key}: the option \"${key}\"`;\n if (o.type === \"strategy\") {\n check(at, o, o.default === undefined ? [] : [o.default]);\n if (o.optionsKey !== undefined && (o.optionsKey === key || entry.options[o.optionsKey]?.type !== \"object\")) faults.push(`${at}: \"optionsKey\" does not name an object option.`);\n } else if (o.type === \"list\" && o.of?.type === \"strategy\") {\n check(at, o, Array.isArray(o.default) ? o.default : []);\n }\n if (o.type === \"list\" && Array.isArray(o.default)) {\n if (o.min !== undefined && o.default.length < o.min) faults.push(`${at}: the default has fewer than ${o.min} items.`);\n if (o.max !== undefined && o.default.length > o.max) faults.push(`${at}: the default has more than ${o.max} items.`);\n }\n }\n }\n}\n\n/**\n * This function reads a catalog from parsed JSON, in each schema of `STRATEGY_CATALOG_SCHEMAS`. It refuses each unknown field and each other schema.\n * It gives the catalog with its `Infinity` values restored, or the list of all faults.\n */\nexport function parseStrategyCatalog(value: unknown): StrategyCatalogParse {\n const faults: string[] = [];\n if (!isFields(value)) return { ok: false, faults: [\"The catalog is not an object.\"] };\n refuseUnknown(\"The catalog\", value, TOP_FIELDS, faults);\n const schema = value[\"schema\"];\n if (!(STRATEGY_CATALOG_SCHEMAS as readonly unknown[]).includes(schema)) faults.push(`The schema is not one of ${STRATEGY_CATALOG_SCHEMAS.join(\", \")}.`);\n if (!isText(value[\"engine\"])) faults.push(`\"engine\" is not a text.`);\n if (!isText(value[\"version\"])) faults.push(`\"version\" is not a text.`);\n if (!Array.isArray(value[\"strategies\"])) return { ok: false, faults: [...faults, `\"strategies\" is not a list.`] };\n const entries: CatalogEntry[] = [];\n (value[\"strategies\"] as readonly unknown[]).forEach((raw, i) => {\n const entry = readEntry(`The strategy ${isFields(raw) && isText(raw[\"key\"]) ? raw[\"key\"] : i}`, raw, schema, faults);\n if (entry !== undefined) entries.push(entry);\n });\n for (let i = 1; i < entries.length; i++) {\n const [a, b] = [entries[i - 1]!.key, entries[i]!.key];\n if (a === b) faults.push(`The key ${a} is not unique.`);\n else if (a > b) faults.push(`The key ${b} is out of order.`);\n }\n // A bad entry is not in the list, so each reference to it would give a false fault.\n if (faults.length === 0) checkReferences(entries, faults);\n if (faults.length > 0) return { ok: false, faults };\n return { ok: true, catalog: { schema: schema as StrategyCatalogSchema, engine: value[\"engine\"] as string, version: value[\"version\"] as string, strategies: entries } };\n}\n\n/** This function gives the file form of a number. A value that is not finite becomes its name, and `NaN` stays for the writer to refuse. */\nconst writeNumber = (v: unknown): unknown => (v === Infinity ? \"Infinity\" : v === -Infinity ? \"-Infinity\" : v);\n\n/**\n * This function gives the value of an option for a call of the engine, from its JSON form.\n * The strings `\"Infinity\"` and `\"-Infinity\"` become numbers in a number option, and in a list of numbers. Each other value stays as it is.\n */\nexport function decodeOptionValue(value: unknown, declaration: AnyOption | ListItem): unknown {\n if (declaration.type === \"number\" || declaration.type === \"integer\") return readNumber(value) ?? value;\n if (declaration.type === \"list\" && declaration.of !== undefined && Array.isArray(value)) {\n const item = declaration.of;\n return value.map((v: unknown) => decodeOptionValue(v, item));\n }\n return value;\n}\n\n/** This function gives the JSON form of the value of an option. It is the inverse of `decodeOptionValue`. */\nexport function encodeOptionValue(value: unknown, declaration: AnyOption | ListItem): unknown {\n if (declaration.type === \"number\" || declaration.type === \"integer\") return writeNumber(value);\n if (declaration.type === \"list\" && declaration.of !== undefined && Array.isArray(value)) {\n const item = declaration.of;\n return value.map((v: unknown) => encodeOptionValue(v, item));\n }\n return value;\n}\n\n/** This function gives the file form of a declaration, with its fields in the order of the file. */\nfunction writeOption(option: AnyOption | ListItem): Fields {\n const o = option as unknown as Fields;\n for (const key of Object.keys(o)) if (!OPTION_ORDER.includes(key) && o[key] !== undefined) throw new Error(`The field \"${key}\" is not a field of a declaration.`);\n const numeric = o[\"type\"] === \"number\" || o[\"type\"] === \"integer\";\n const out: Record<string, unknown> = {};\n for (const f of OPTION_ORDER) {\n const v = o[f];\n if (v === undefined) continue;\n if (f === \"of\") out[f] = writeOption(v as ListItem);\n else if (numeric && f === \"default\") out[f] = writeNumber(v);\n else if (numeric && (f === \"special\" || f === \"marks\")) out[f] = (v as readonly number[]).map(writeNumber);\n else out[f] = v;\n }\n return out;\n}\n\n/** This function gives the file form of one output row, with the fields in the order of the file. */\nfunction writeRow(row: OutputRow): unknown {\n const e = row.evidence;\n return {\n property: row.property,\n class: row.class,\n evidence: {\n inputs: e.inputs,\n ...(e.fractionalInputs === undefined ? {} : { fractionalInputs: e.fractionalInputs }),\n ...(e.nearWholeInputs === undefined ? {} : { nearWholeInputs: e.nearWholeInputs }),\n source: e.source,\n optionSet: e.optionSet,\n catalogVersion: e.catalogVersion,\n },\n };\n}\n\n/** This function gives the file form of an entry, with its fields in the order of the file. */\nfunction writeEntry(e: CatalogEntry): Fields {\n const options = Object.fromEntries(Object.entries(e.options).map(([key, o]) => [key, writeOption(o)]));\n return {\n key: e.key,\n id: e.id,\n ...(e.step === undefined ? {} : { step: e.step }),\n family: e.family,\n kind: e.kind,\n describe: e.describe,\n supports: e.supports,\n limits: e.limits,\n deterministic: e.deterministic,\n ...(e.determinismNote === undefined ? {} : { determinismNote: e.determinismNote }),\n optIn: e.optIn,\n ...(e.baseline === true ? { baseline: true } : {}),\n ...(e.output === undefined ? {} : { output: e.output.map(writeRow) }),\n ...(e.fingerprint === undefined ? {} : { fingerprint: e.fingerprint }),\n options,\n };\n}\n\n/** This function gives the place of each value that JSON cannot hold: a function, `undefined` in a list, or a number that is not finite. */\nfunction unsafeValues(v: unknown, at: string): string[] {\n if (typeof v === \"function\") return [`${at} is a function.`];\n if (typeof v === \"number\") return Number.isFinite(v) ? [] : [`${at} is ${v}.`];\n if (Array.isArray(v)) return v.flatMap((x: unknown, i) => (x === undefined ? [`${at}[${i}] is undefined.`] : unsafeValues(x, `${at}[${i}]`)));\n if (isFields(v)) return Object.entries(v).flatMap(([k, x]) => unsafeValues(x, `${at}.${k}`));\n return [];\n}\n\n/**\n * This function gives the text of the catalog file, sorted by key. The same source and version give the same bytes.\n * The file has the oldest schema that holds it. A catalog with no `output` and no `fingerprint` stays valid for a reader of the schema 1.\n * A catalog with no `fingerprint` stays valid for a reader of the schema 2.\n * The caller gives the version from `package.json`. The function throws an error if the file breaks a rule of the format.\n */\nexport function writeStrategyCatalog(source: StrategyCatalogSource, version: string): string {\n const strategies = [...source.strategies].sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0)).map(writeEntry);\n const has = (field: \"output\" | \"fingerprint\"): boolean => source.strategies.some((e) => e[field] !== undefined);\n const schema = has(\"fingerprint\") ? STRATEGY_CATALOG_SCHEMAS[2] : has(\"output\") ? STRATEGY_CATALOG_SCHEMAS[1] : STRATEGY_CATALOG_SCHEMAS[0];\n const doc = { schema, engine: source.engine, version, strategies };\n const unsafe = unsafeValues(doc, \"catalog\");\n if (unsafe.length > 0) throw new Error(`The catalog of ${source.engine} has values that JSON cannot hold: ${unsafe.join(\" \")}`);\n const text = `${JSON.stringify(doc, null, 2)}\\n`;\n const parsed = parseStrategyCatalog(JSON.parse(text));\n if (!parsed.ok) throw new Error(`The catalog of ${source.engine} breaks the format: ${parsed.faults.join(\" \")}`);\n return text;\n}\n\n/** This function gives the default of each option of an entry that has a default. */\nexport function catalogDefaults(entry: CatalogEntry): Record<string, unknown> {\n return Object.fromEntries(Object.entries(entry.options).flatMap(([key, o]) => (o.default === undefined ? [] : [[key, o.default]])));\n}\n\n/**\n * This function gives the catalog declarations of a strategy from its live `defaults` and its schema. Thus each engine has no copy of this rule.\n * A live default goes on its declaration. A function stays out, so the declaration needs its own `noDefault`.\n */\nexport function catalogOptions(defaults: Readonly<Record<string, unknown>>, schema: Readonly<Record<string, AnyOption>>, options: CatalogOptionsOptions = {}): Record<string, AnyOption> {\n const out: Record<string, AnyOption> = {};\n for (const [key, declaration] of Object.entries(schema)) {\n const live = key in defaults ? defaults[key] : declaration.default;\n const object = declaration.type === \"strategy\" && typeof live === \"object\" && live !== null;\n const value = object && !(declaration.inlineOptions === true && isMember(live)) ? options.strategyKey?.(live) : live;\n const { default: _unused, ...rest } = declaration;\n out[key] = (value === undefined || typeof value === \"function\" ? rest : { ...rest, default: value }) as AnyOption;\n }\n return out;\n}\n\n/** This function adds the faults of one entry against its live facts. */\nfunction checkLive(entry: CatalogEntry, live: RegistryEntry, faults: string[]): void {\n const defaults = catalogDefaults(entry);\n if (entry.optIn !== live.optIn) faults.push(`${entry.key}: \"optIn\" is ${entry.optIn}, and the engine gives ${live.optIn}.`);\n if ((entry.baseline === true) !== (live.baseline === true)) faults.push(`${entry.key}: \"baseline\" differs from the engine.`);\n const limits = Object.fromEntries(Object.entries(entry.limits).map(([name, { min, max }]) => [name, { min, max }]));\n if (canonicalJson(limits) !== canonicalJson(live.limits ?? {})) faults.push(`${entry.key}: \"limits\" differ from the limits of the engine.`);\n for (const [key, value] of Object.entries(live.defaults)) {\n const option = entry.options[key];\n if (option === undefined) {\n faults.push(`${entry.key}: the default \"${key}\" has no declaration.`);\n } else if (typeof value === \"function\") {\n if (option.noDefault?.reason !== \"function\") faults.push(`${entry.key}: the default \"${key}\" is code, and its \"noDefault\" does not say it.`);\n } else if (option.type !== \"strategy\" || typeof value === \"string\" || (option.inlineOptions === true && isMember(value))) {\n const same = Object.is(value, defaults[key]) || canonicalJson(value) === canonicalJson(defaults[key]);\n if (!same) faults.push(`${entry.key}: the default \"${key}\" differs from the live default.`);\n }\n }\n}\n\n/** This function runs each entry that claims determinism two times, and compares the bytes. */\nfunction checkDeterminism(entry: CatalogEntry, live: RegistryEntry, faults: string[], notRun: string[]): void {\n if (!entry.deterministic) return;\n if (live.run === undefined) {\n notRun.push(`${entry.key}: the engine gives no fixture.`);\n return;\n }\n try {\n if (live.run() !== live.run()) faults.push(`${entry.key}: \"deterministic\" is true, and two runs differ.`);\n } catch (error) {\n notRun.push(`${entry.key}: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/** This function runs each probe on an entry, and compares the refusal with `supports`. */\nfunction checkProbes(entry: CatalogEntry, probes: readonly SupportProbe[], faults: string[], notRun: string[]): void {\n for (const probe of probes) {\n const name = `${entry.key} on ${probe.field} ${probe.value}`;\n const declared = entry.supports[probe.field];\n const takes = declared === undefined || declared.includes(probe.value);\n let refused: boolean | undefined;\n try {\n refused = probe.refuses(entry.key);\n } catch (error) {\n notRun.push(`${name}: ${error instanceof Error ? error.message : String(error)}`);\n continue;\n }\n if (refused === undefined) notRun.push(`${name}: the input cannot go to this strategy.`);\n else if (refused === takes) faults.push(`${name}: \"supports\" ${takes ? \"takes\" : \"refuses\"} the value, and the engine ${refused ? \"refuses\" : \"takes\"} it.`);\n }\n}\n\n/** This function runs each strategy that an option of an entry offers, because a chooser must not offer a strategy that fails. */\nfunction checkChoices(entry: CatalogEntry, strategies: readonly CatalogEntry[], refuses: NonNullable<CatalogCheckOptions[\"refusesChoice\"]>, faults: string[], notRun: string[]): void {\n for (const [key, declaration] of Object.entries(entry.options)) {\n for (const choice of catalogChoices(strategies, declaration)) {\n const name = `${entry.key}: the option \"${key}\" with ${choice.key}`;\n let refused: boolean | undefined;\n try {\n refused = refuses(entry.key, key, choice.key);\n } catch (error) {\n notRun.push(`${name}: ${error instanceof Error ? error.message : String(error)}`);\n continue;\n }\n if (refused === undefined) notRun.push(`${name}: the input cannot go to this strategy.`);\n else if (refused) faults.push(`${name}: the option offers this strategy, and the engine refuses it.`);\n }\n }\n}\n\n/** The lists that the check of the spaces writes, and the routes that it reads. */\ninterface SpaceCheck {\n readonly routes: Readonly<Record<string, ParamRoute>>;\n /** The keys of the routes that matched a place. */\n readonly used: Set<string>;\n readonly faults: string[];\n readonly notMatched: string[];\n readonly spaceOnly: string[];\n}\n\n/** This function examines each value of one param against the declaration of its option, through the route of the param. */\nfunction checkParamValues(entry: CatalogEntry, engine: string, place: string, option: string, values: readonly ParamValue[], route: ParamRoute | undefined, check: SpaceCheck): void {\n const declaration = entry.options[option]!;\n const toOption = route !== undefined && \"value\" in route ? route.value : undefined;\n for (const value of values) {\n let mapped: unknown = value;\n try {\n if (toOption !== undefined) mapped = toOption(value);\n } catch (error) {\n check.faults.push(`${entry.key}: the route \"${place}\" fails on ${String(value)}: ${error instanceof Error ? error.message : String(error)}`);\n continue;\n }\n if (mapped === undefined) continue;\n const issue = optionIssue(option, mapped, declaration);\n if (issue !== undefined) check.faults.push(`${entry.key}: the space ${engine} is outside the declaration. ${issue.message}`);\n }\n}\n\n/** This function examines each param of a space against the declaration of its option, with the routes of the engine. */\nfunction checkSpaceParams(space: StrategySpace, entries: ReadonlyMap<string, CatalogEntry>, check: SpaceCheck): void {\n const { routes, used, faults, notMatched, spaceOnly } = check;\n const routeOf = (place: string): ParamRoute | undefined => {\n const route = routes[place];\n if (route !== undefined) used.add(place);\n return route;\n };\n for (const stage of space.stages) {\n for (const option of stage.options) {\n const name = `${stage.name}/${option.id}`;\n const entry = entries.get(name) ?? entries.get(option.id);\n if (entry === undefined) {\n const reason = routes[name];\n if (reason !== undefined && \"spaceOnly\" in reason) {\n used.add(name);\n spaceOnly.push(`${name}: ${reason.spaceOnly}`);\n } else {\n notMatched.push(name);\n }\n continue;\n }\n for (const param of option.params) {\n const place = `${name}.${param.name}`;\n const route = routeOf(place);\n if (route !== undefined && \"spaceOnly\" in route) {\n if (entry.options[param.name] === undefined) spaceOnly.push(`${place}: ${route.spaceOnly}`);\n else faults.push(`${entry.key}: the route \"${place}\" says that the param is only in the space, and the strategy has this option.`);\n continue;\n }\n const target = route?.option ?? param.name;\n if (entry.options[target] === undefined) {\n if (route === undefined) notMatched.push(place);\n else faults.push(`${entry.key}: the route \"${place}\" names \"${target}\", and the strategy has no such option.`);\n continue;\n }\n const values = [param.min, param.max, ...(param.values ?? []), param.default].filter((v): v is ParamValue => v !== undefined);\n checkParamValues(entry, space.engine, place, target, values, route, check);\n }\n }\n }\n}\n\n/** This function adds one fault for each route that matched nothing, and for each `spaceOnly` route with no reason. */\nfunction checkRoutes({ routes, used, faults }: SpaceCheck): void {\n for (const [place, route] of Object.entries(routes)) {\n if (!used.has(place)) faults.push(`The route \"${place}\" matches nothing in the spaces.`);\n if (\"spaceOnly\" in route && !isText(route.spaceOnly)) faults.push(`The route \"${place}\" has no reason.`);\n }\n}\n\n/**\n * This function examines a catalog against its engine: the live defaults, the set of strategies and a round trip through JSON.\n * It also examines the claims of determinism, `supports`, `limits`, the choices of each strategy option and the spaces.\n * A claim that no run can examine goes to `notRun`, by key, so a test can state their count.\n */\nexport function checkCatalog(source: StrategyCatalogSource, registry: readonly RegistryEntry[], options: CatalogCheckOptions = {}): CatalogCheck {\n const faults: string[] = [];\n const notRun: string[] = [];\n const notMatched: string[] = [];\n const spaceOnly: string[] = [];\n let text: string | undefined;\n try {\n text = writeStrategyCatalog(source, \"0.0.0\");\n } catch (error) {\n faults.push(error instanceof Error ? error.message : String(error));\n }\n if (text !== undefined) {\n const parsed = parseStrategyCatalog(JSON.parse(text));\n if (!parsed.ok || writeStrategyCatalog(parsed.catalog, \"0.0.0\") !== text) faults.push(\"A round trip through JSON changes the catalog.\");\n }\n const entries = new Map(source.strategies.map((e) => [e.key, e]));\n const live = new Map(registry.map((e) => [e.key, e]));\n for (const key of live.keys()) if (!entries.has(key)) faults.push(`${key} is in the engine, and not in the catalog.`);\n for (const key of entries.keys()) if (!live.has(key)) faults.push(`${key} is in the catalog, and not in the engine.`);\n for (const [key, entry] of entries) {\n const facts = live.get(key);\n if (facts === undefined) continue;\n checkLive(entry, facts, faults);\n checkDeterminism(entry, facts, faults, notRun);\n checkProbes(entry, options.probes ?? [], faults, notRun);\n if (options.refusesChoice !== undefined) checkChoices(entry, source.strategies, options.refusesChoice, faults, notRun);\n }\n const spaceCheck: SpaceCheck = { routes: options.paramRoutes ?? {}, used: new Set(), faults, notMatched, spaceOnly };\n for (const space of options.spaces ?? []) checkSpaceParams(space, entries, spaceCheck);\n checkRoutes(spaceCheck);\n return { faults, notRun, notMatched, spaceOnly };\n}\n","// The verdict over families (`docs/VERDICT.md`). highways, packing and the joint bench use the same rule, so they give the same verdict.\nimport { compareMeasure, type MeasureSpec } from \"./measures.ts\";\nimport { stepRandom } from \"./random.ts\";\nimport type { LayoutRecord } from \"./record.ts\";\n\n/**\n * The largest count of inputs for the exact permutation test. Up to this count, the test enumerates all `2^n` sign sets.\n * At 16 inputs, that is 65 536 sign sets, approximately 3 times the default draws. Above it, the cost doubles with each input, so the test uses seeded draws.\n */\nexport const VERDICT_EXACT_MAX = 16;\n\n/** The largest value of the option `exactMax`. At 20 inputs, the exact test has approximately 1 million sign sets. */\nexport const VERDICT_EXACT_CAP = 20;\n\n/** The default count of the samples of each bootstrap. It is the parameter `bootstrapRuns` of `docs/PROMOTION.md`. */\nexport const VERDICT_RUNS = 10000;\n\n/** The default count of the random sign sets of the permutation test above `VERDICT_EXACT_MAX` inputs. */\nexport const VERDICT_DRAWS = 20000;\n\n/** The default seed of the bootstraps and of the random sign sets. */\nexport const VERDICT_SEED = 1;\n\n/** The fields of a record that the verdict reads. */\nexport type VerdictRecord = Pick<LayoutRecord, \"strategy\" | \"input\" | \"seed\" | \"measures\"> & { readonly skipped?: string };\n\n/** One side of a verdict: a strategy id, or a test that selects the records of the side. */\nexport type VerdictSide<R extends VerdictRecord = VerdictRecord> = string | ((record: R) => boolean);\n\n/** The arguments of `verdict`. `tie` and `level` have no default. */\nexport interface VerdictOptions<R extends VerdictRecord = VerdictRecord> {\n /** The unit of the verdict. The family is the only unit. */\n readonly by: \"family\";\n /** The hook that gives the family of a record, for example `familyOf` of the cell of its input. */\n readonly family: (record: R) => string;\n /** The measure. Its direction tells which side is better. */\n readonly measure: Pick<MeasureSpec, \"id\" | \"direction\">;\n /** The baseline side. */\n readonly a: VerdictSide<R>;\n /** The candidate side. A positive difference tells that `b` is better than `a`. */\n readonly b: VerdictSide<R>;\n /**\n * The minimum effect of the sign of a family, as `minEffect` of `MeasureSpec`. A smaller change of the family mean is a tie.\n * `compareMeasure` compares the two family means, so the smallest tie is one grid step of `RECORD_EPS`.\n */\n readonly tie: number | { readonly rel: number };\n /** The significance level, from 0 to 1. The permutation p must be below it. The intervals have the level `1 - level`. */\n readonly level: number;\n /** The count of the samples of each bootstrap. The default is `VERDICT_RUNS`. */\n readonly runs?: number;\n /** The count of the random sign sets above the exact limit. The default is `VERDICT_DRAWS`. */\n readonly draws?: number;\n /** The seed of the bootstraps and of the random sign sets. The default is `VERDICT_SEED`. */\n readonly seed?: number;\n /** The largest count of inputs for the exact test. The default is `VERDICT_EXACT_MAX`. The value 0 always uses draws. */\n readonly exactMax?: number;\n}\n\n/** A mean with its bootstrap interval. The interval is clear of 0 when `lo > 0` or `hi < 0`. */\nexport interface VerdictInterval {\n readonly mean: number;\n readonly lo: number;\n readonly hi: number;\n}\n\n/** The difference of one family: the count of its inputs, the mean of their differences and its sign. */\nexport interface FamilyVerdict {\n readonly family: string;\n readonly n: number;\n readonly mean: number;\n /** The value 1 tells that `b` is better, -1 that `b` is worse, and 0 a tie by `tie`. */\n readonly sign: -1 | 0 | 1;\n}\n\n/** The stratified paired permutation test. With `exact`, `draws` is the count of all the sign sets. */\nexport interface VerdictPermutation {\n readonly p: number;\n readonly exact: boolean;\n readonly draws: number;\n readonly seed: number;\n}\n\n/** The two-sided exact sign test of the family signs. It is a report only. Ties do not count. */\nexport interface VerdictSignTest {\n readonly wins: number;\n readonly losses: number;\n readonly ties: number;\n readonly p: number;\n}\n\n/** The label of a verdict. `better` and `worse` tell the side of `b`. */\nexport type VerdictLabel = \"better\" | \"worse\" | \"depends on the mix\" | \"no verdict\";\n\n/**\n * The scope of a verdict. The test keeps the families of the corpus as fixed, so its claim is about these families only.\n * It is not a claim about a new kind of input.\n */\nexport type VerdictScope = \"these families\";\n\n/**\n * The breadth of a verdict: the count of the families against its side.\n * The side is the side of the label. For `depends on the mix` and `no verdict`, it is the sign of the stratified mean.\n */\nexport interface VerdictBreadth {\n /** The count of the families with a sign against the side. A stratified mean of exactly 0 has no side, so this count is 0. */\n readonly against: number;\n /** The count of the families. */\n readonly of: number;\n /** The count of the families with the sign 0. */\n readonly ties: number;\n}\n\n/** The result of `verdict`. */\nexport interface VerdictResult {\n readonly measure: string;\n /** The count of the paired inputs. */\n readonly n: number;\n /** The mean of the family means, with a bootstrap of the seeds inside each family. */\n readonly stratified: VerdictInterval;\n /** The mean of the inputs, with a bootstrap of the inputs. */\n readonly pooled: VerdictInterval;\n readonly permutation: VerdictPermutation;\n /** The families, in sort order. */\n readonly families: readonly FamilyVerdict[];\n readonly signTest: VerdictSignTest;\n /** `true` only when the two means have the same sign, the two intervals are clear of 0 and the permutation p is below `level`. */\n readonly agree: boolean;\n readonly label: VerdictLabel;\n /** The scope of the claim: the families of the corpus, not a new kind of input. */\n readonly scope: VerdictScope;\n /** The count of the families against the side of the verdict, of all the families and of the ties. */\n readonly breadth: VerdictBreadth;\n /** The label, the scope and the breadth in one line, for example `better on these families, worse on 2 of 6 (1 tie)`. */\n readonly summary: string;\n /** The inputs without a pair: one side has no record, a skipped record or no value of the measure. */\n readonly dropped: readonly string[];\n}\n\n/** One paired input: its key, its family, the two values and the difference in the direction of the measure. */\ninterface Pair {\n readonly key: string;\n readonly family: string;\n readonly a: number;\n readonly b: number;\n readonly d: number;\n}\n\n/** This function gives the mean of a list that is not empty. */\nconst meanOf = (values: readonly number[]): number => values.reduce((s, v) => s + v, 0) / values.length;\n\n/** This function gives the `q` quantile of sorted values, with linear interpolation. */\nfunction quantileOf(sorted: readonly number[], q: number): number {\n const at = (sorted.length - 1) * q;\n const lo = Math.floor(at);\n const hi = Math.ceil(at);\n return sorted[lo]! + (sorted[hi]! - sorted[lo]!) * (at - lo);\n}\n\n/** This function gives the interval of the samples of a bootstrap at the level `1 - level`. */\nfunction intervalOf(mean: number, samples: number[], level: number): VerdictInterval {\n samples.sort((x, y) => x - y);\n return { mean, lo: quantileOf(samples, level / 2), hi: quantileOf(samples, 1 - level / 2) };\n}\n\n/** This function tells if an interval is clear of 0 on the side of the sign `sign`. */\nconst clearOn = (i: VerdictInterval, sign: number): boolean => (sign > 0 ? i.lo > 0 : sign < 0 ? i.hi < 0 : false);\n\n/** This function gives the two-sided p of the exact binomial sign test, with `p = 0.5`. No count gives 1. */\nfunction signP(wins: number, losses: number): number {\n const n = wins + losses;\n if (n === 0) return 1;\n const k = Math.min(wins, losses);\n let tail = 0;\n let c = 1;\n for (let i = 0; i <= k; i++) {\n tail += c;\n c = (c * (n - i)) / (i + 1);\n }\n return Math.min(1, (2 * tail) / 2 ** n);\n}\n\n/** This function gives the breadth of a verdict with the side `side`: 1, -1, or 0 for no side. */\nfunction breadthOf(families: readonly FamilyVerdict[], side: number): VerdictBreadth {\n const ties = families.filter((f) => f.sign === 0).length;\n const against = side === 0 ? 0 : families.filter((f) => f.sign === -side).length;\n return { against, of: families.length, ties };\n}\n\n/** This function gives the line of a verdict: its label, its scope and its breadth (`docs/VERDICT.md`). */\nfunction summaryOf(label: VerdictLabel, side: number, breadth: VerdictBreadth): string {\n const ties = breadth.ties === 0 ? \"\" : ` (${breadth.ties} ${breadth.ties === 1 ? \"tie\" : \"ties\"})`;\n const word = side > 0 ? \"better\" : \"worse\";\n const other = side > 0 ? \"worse\" : \"better\";\n const count = breadth.against === 0 ? \"none\" : String(breadth.against);\n if (label === \"better\" || label === \"worse\") return `${label} on these families, ${other} on ${count} of ${breadth.of}${ties}`;\n if (side === 0) return `${label}: the family mean is 0, on ${breadth.of} families${ties}`;\n return `${label}: ${word} on the family mean, ${other} on ${count} of ${breadth.of}${ties}`;\n}\n\n/** This function tells if a value is a positive whole number. */\nconst isCount = (v: number): boolean => Number.isInteger(v) && v > 0;\n\n/** This function gives the test of one side. */\nfunction sideTest<R extends VerdictRecord>(side: VerdictSide<R>): (record: R) => boolean {\n return typeof side === \"string\" ? (r) => r.strategy === side : side;\n}\n\n/** This function pairs the records of `a` and `b` by input and seed, and gives the pairs in the order of family and key. */\nfunction pairsOf<R extends VerdictRecord>(records: Iterable<R>, options: VerdictOptions<R>): { pairs: Pair[]; dropped: string[] } {\n const isA = sideTest(options.a);\n const isB = sideTest(options.b);\n const sides = new Map<string, { a?: R; b?: R }>();\n for (const r of records) {\n const inA = isA(r);\n const inB = isB(r);\n if (inA && inB) throw new RangeError(`verdict: the record of the input \"${r.input}\" is in the two sides`);\n if (!inA && !inB) continue;\n const key = `${r.input}#${r.seed}`;\n const entry = sides.get(key) ?? {};\n const side = inA ? \"a\" : \"b\";\n if (entry[side] !== undefined) throw new RangeError(`verdict: the side ${side} has two records of the input \"${r.input}\" and the seed ${r.seed}`);\n entry[side] = r;\n sides.set(key, entry);\n }\n const pairs: Pair[] = [];\n const dropped: string[] = [];\n const id = options.measure.id;\n for (const [key, { a, b }] of sides) {\n const va = a?.skipped === undefined ? a?.measures[id] : undefined;\n const vb = b?.skipped === undefined ? b?.measures[id] : undefined;\n if (a === undefined || b === undefined || va === undefined || vb === undefined) {\n dropped.push(key);\n continue;\n }\n if (!Number.isFinite(va) || !Number.isFinite(vb)) throw new RangeError(`verdict: the measure ${id} of the input \"${a.input}\" is not finite`);\n const family = options.family(a);\n if (options.family(b) !== family) throw new RangeError(`verdict: the two records of the input \"${a.input}\" have different families`);\n pairs.push({ key, family, a: va, b: vb, d: options.measure.direction === \"higher\" ? vb - va : va - vb });\n }\n pairs.sort((x, y) => (x.family < y.family ? -1 : x.family > y.family ? 1 : x.key < y.key ? -1 : x.key > y.key ? 1 : 0));\n dropped.sort();\n return { pairs, dropped };\n}\n\n/**\n * This function gives the verdict of the candidate `b` against the baseline `a` on one measure, with the family as the unit (`docs/VERDICT.md`).\n *\n * - It pairs the records by input and seed. The difference of a pair is `b - a` for a measure where more is better, else `a - b`.\n * - `stratified` is the mean of the family means. Its bootstrap draws the seeds inside each family. `pooled` is the mean of the inputs.\n * - The permutation test changes the sign of each difference inside its family. Its statistic is the mean of the family means.\n * - The label is `better` or `worse` only when `agree` is `true`. Opposite signs of the two means give `depends on the mix`.\n * - `scope`, `breadth` and `summary` tell that the claim is about these families, and how many families are against it.\n *\n * It throws a `RangeError` for a missing `tie` or `level`, and for no pair. Two records of one side and input, or a value that is not finite, also cause a `RangeError`.\n */\nexport function verdict<R extends VerdictRecord>(records: Iterable<R>, options: VerdictOptions<R>): VerdictResult {\n const { tie, level, measure } = options;\n if (options.by !== \"family\") throw new RangeError(`verdict: the unit is \"family\", not \"${String(options.by)}\"`);\n if (tie === undefined || (typeof tie === \"number\" ? !(tie >= 0) : !(tie.rel >= 0))) throw new RangeError(\"verdict: tie is a required number of 0 or more, or { rel } of 0 or more\");\n if (level === undefined || !(level > 0 && level < 1)) throw new RangeError(\"verdict: level is a required number between 0 and 1\");\n const runs = options.runs ?? VERDICT_RUNS;\n const draws = options.draws ?? VERDICT_DRAWS;\n const seed = options.seed ?? VERDICT_SEED;\n const exactMax = options.exactMax ?? VERDICT_EXACT_MAX;\n if (!isCount(runs) || !isCount(draws)) throw new RangeError(\"verdict: runs and draws are whole numbers above 0\");\n if (!Number.isInteger(exactMax) || exactMax < 0 || exactMax > VERDICT_EXACT_CAP) throw new RangeError(`verdict: exactMax is a whole number from 0 to ${VERDICT_EXACT_CAP}`);\n\n const { pairs, dropped } = pairsOf(records, options);\n const n = pairs.length;\n if (n === 0) throw new RangeError(`verdict: the records give no pair of the measure ${measure.id}`);\n\n const groups = new Map<string, Pair[]>();\n for (const p of pairs) groups.set(p.family, [...(groups.get(p.family) ?? []), p]);\n const lists = [...groups.values()];\n const spec = { direction: measure.direction, minEffect: tie };\n const families: FamilyVerdict[] = lists.map((list) => {\n const verdictOf = compareMeasure(meanOf(list.map((p) => p.b)), meanOf(list.map((p) => p.a)), spec);\n return { family: list[0]!.family, n: list.length, mean: meanOf(list.map((p) => p.d)), sign: verdictOf === \"better\" ? 1 : verdictOf === \"worse\" ? -1 : 0 };\n });\n\n // The stratified bootstrap draws the seeds of each family with replacement. The pooled bootstrap draws all the inputs.\n const stratMean = meanOf(families.map((f) => f.mean));\n const rs = stepRandom(seed, \"verdict.stratified\");\n const stratSamples: number[] = [];\n for (let run = 0; run < runs; run++) {\n let sum = 0;\n for (const list of lists) {\n let s = 0;\n for (let j = 0; j < list.length; j++) s += list[Math.floor(rs() * list.length)]!.d;\n sum += s / list.length;\n }\n stratSamples.push(sum / lists.length);\n }\n const stratified = intervalOf(stratMean, stratSamples, level);\n\n const pooledMean = meanOf(pairs.map((p) => p.d));\n const rp = stepRandom(seed, \"verdict.pooled\");\n const pooledSamples: number[] = [];\n for (let run = 0; run < runs; run++) {\n let s = 0;\n for (let j = 0; j < n; j++) s += pairs[Math.floor(rp() * n)]!.d;\n pooledSamples.push(s / n);\n }\n const pooled = intervalOf(pooledMean, pooledSamples, level);\n\n // The statistic is a weighted sum: the weight of an input is 1 / (the count of families × the count of its family).\n const terms = lists.flatMap((list) => list.map((p) => p.d / (lists.length * list.length)));\n const observed = Math.abs(terms.reduce((s, t) => s + t, 0));\n const slack = 1e-12 * terms.reduce((s, t) => s + Math.abs(t), 0);\n const exact = n <= exactMax;\n let hits = 0;\n let total: number;\n if (exact) {\n total = 2 ** n;\n for (let mask = 0; mask < total; mask++) {\n let t = 0;\n for (let i = 0; i < n; i++) t += mask & (1 << i) ? -terms[i]! : terms[i]!;\n if (Math.abs(t) >= observed - slack) hits++;\n }\n } else {\n total = draws;\n const rf = stepRandom(seed, \"verdict.permutation\");\n for (let k = 0; k < draws; k++) {\n let t = 0;\n for (let i = 0; i < n; i++) t += rf() < 0.5 ? -terms[i]! : terms[i]!;\n if (Math.abs(t) >= observed - slack) hits++;\n }\n }\n // A drawn p counts the observed sign set as one draw, so it is always above 0.\n const permutation: VerdictPermutation = { p: exact ? hits / total : (hits + 1) / (total + 1), exact, draws: total, seed };\n\n const wins = families.filter((f) => f.sign === 1).length;\n const losses = families.filter((f) => f.sign === -1).length;\n const signTest: VerdictSignTest = { wins, losses, ties: families.length - wins - losses, p: signP(wins, losses) };\n\n const sign = Math.sign(stratified.mean);\n const agree = sign !== 0 && sign === Math.sign(pooled.mean) && clearOn(stratified, sign) && clearOn(pooled, sign) && permutation.p < level;\n const label: VerdictLabel = agree ? (sign > 0 ? \"better\" : \"worse\") : sign * Math.sign(pooled.mean) < 0 ? \"depends on the mix\" : \"no verdict\";\n const breadth = breadthOf(families, sign);\n const summary = summaryOf(label, sign, breadth);\n return { measure: measure.id, n, stratified, pooled, permutation, families, signTest, agree, label, scope: \"these families\", breadth, summary, dropped };\n}\n","// The shared corpus generator (`docs/CORPUS.md`): the dimension schema, the family registry and the seeded random numbers.\n// An engine owns its families and gives them to a registry. This file imports no engine and no API of Node, so a browser can run it.\nimport type { FamilyBy } from \"./corpus.ts\";\nimport { EDGE_KEY_STEP_VERSION, edgeKeyStep, edgeStep, type EdgeKey, type EdgeStepParams } from \"./edges.ts\";\nimport { documentHash } from \"./hash.ts\";\nimport type { LayoutInput, Obstacle } from \"./input.ts\";\nimport { mulberry32, randomInt, stepRandom } from \"./random.ts\";\nimport { SHAPE_KIND_IDS } from \"./shapes.ts\";\nimport { paramActive, paramLevels, paramProblem, paramValue, type ParamValue, type SpaceParam } from \"./strategy-space.ts\";\n\n/**\n * One dimension of a corpus: a param of `strategy-space.ts` with its meaning and the engines that use it.\n * The field `when` has the form of `SpaceParam.when`: the dimension is active only for some values of an earlier dimension.\n */\nexport interface CorpusDimension extends SpaceParam {\n /** The meaning of the dimension, in one sentence. */\n readonly meaning: string;\n /** The engines that read the dimension, for example `packing`, `highways` and `joint`. */\n readonly engines: readonly string[];\n /** The values of a sweep. Without them, a sweep uses the values of an `enum`, `false` and `true` of a `bool`, or the default. */\n readonly levels?: readonly ParamValue[];\n /**\n * The values that the family accepts. Without it, the family accepts each value of the dimension.\n * A list is for an `enum` or a `bool`. A sub-range is for an `int` or a `real`.\n * The default and each level are supported values. `resolve` and `generate` refuse a value that is not supported.\n */\n readonly supported?: SupportedValues;\n /**\n * The output fields that a value other than the default makes wrong, for example `known`.\n * Then `generate` of a registry removes these fields from the output, and lists them in `invalidated`.\n */\n readonly invalidates?: readonly string[];\n /**\n * The count of decimal places that the family uses for a value of a numeric dimension: a whole number of 0 or more.\n * Only the `invalidates` compare reads it. The registry rounds the value and the default to it before the compare.\n * The cells, the cell keys, `rngOf` and the value that `generate` gets do not change.\n */\n readonly precision?: number;\n}\n\n/**\n * The supported values of a dimension (`CorpusDimension.supported`).\n * The list form gives the values of an `enum` or a `bool`. The range form gives a sub-range of an `int` or a `real`.\n * A range without `min` or `max` keeps that end of the dimension.\n */\nexport type SupportedValues = readonly ParamValue[] | SupportedRange;\n\n/** The range form of `SupportedValues`: the least and the largest supported value of a numeric dimension. */\nexport interface SupportedRange {\n readonly min?: number;\n readonly max?: number;\n}\n\n/** The name of the output field that lists the fields that `generate` of a registry removed. */\nexport const INVALIDATED_FIELD = \"invalidated\";\n\n/** The values of the dimensions of one input: one value for each name. */\nexport type DimensionValues = Readonly<Record<string, ParamValue>>;\n\n/** A factory of seeded random numbers: it gives a source of numbers in [0, 1) for a seed. */\nexport type RngFactory = (seed: number) => () => number;\n\n/**\n * The cross-engine note of a family. `exact` tells that each JavaScript engine gives the same output.\n * `libm-dependent` tells that the family uses a function that is not correctly rounded in each engine, for example `Math.log`, `Math.cos` or `**`.\n */\nexport type CrossEngine = \"exact\" | \"libm-dependent\";\n\n/** The random numbers of the default factory: `mulberry32` of `random.ts`. Its stream is pinned in `families.test.ts`. */\nexport const DEFAULT_RNG: RngFactory = mulberry32;\n\n/** The context that a registry gives to `generate`. */\nexport interface GenerateContext {\n /** The random factory of the family: its own `rng`, or `DEFAULT_RNG`. */\n readonly rng: RngFactory;\n /** The source of random numbers of the input: `rng(rngSeed(seed, dims))`. A family that does not use it takes no numbers from it. */\n readonly random: () => number;\n /** The name of the corpus of the input, when the caller gives one. */\n readonly set?: string;\n}\n\n/**\n * A family of a corpus: a seeded generator with declared dimensions. The engine that owns it gives it to a registry.\n * The registry gives `generate` the raw seed and the full dimension values.\n * The registry changes the output only for a dimension with `invalidates` at a value other than its default.\n */\nexport interface CorpusFamily<O = LayoutInput> {\n /** The name of the family, for example `rect-grid`. */\n readonly name: string;\n /** The version. A change of the output of the family needs a new version. A dimension of only some versions is in the list of those versions only. */\n readonly version: number;\n /** The engine that owns the definition of the family, for example `packing`. */\n readonly owner: string;\n /** The meaning of the family, in one sentence. */\n readonly meaning: string;\n /** The dimensions of the family, in their order. A dimension with `when` comes after the dimension that its `when` names. The name `kind` is reserved. */\n readonly dimensions: readonly CorpusDimension[];\n /** The text of the rule that gives the random numbers of an input from its seed and its dimensions. */\n readonly seeding: string;\n /** The cross-engine note of the family. */\n readonly crossEngine: CrossEngine;\n /** The random factory of the family. The default is `DEFAULT_RNG`. */\n readonly rng?: RngFactory;\n /** This function gives the seed of `context.random` from the input seed and the full dimension values. The default gives the input seed. */\n readonly rngSeed?: (seed: number, dims: DimensionValues) => number;\n /** The dimensions of the family key of `familyBy`, after the kind of the cell. A dimension with `when` is not permitted. The default is no dimension. */\n readonly familyBy?: readonly string[];\n /**\n * This function gives the hash of an output after the registry removes the fields of `invalidates`. The default is `documentHash` of `hash.ts`.\n * The registry uses it only for an output with a `hash` field of text. The registry gives it an output of the family.\n * Its parameter has the type `never`, so a family of each output type can be a `CorpusFamily<unknown>`.\n */\n readonly hash?: (output: never) => string;\n /** This function gives the input of a seed. `dims` has a value for each dimension, also for an inactive dimension. */\n generate(seed: number, dims: DimensionValues, context: GenerateContext): O;\n}\n\n/** The options of `generate` of a registry. */\nexport interface GenerateOptions {\n /** The version of the family. The default is the first version that the registry got. */\n readonly version?: number;\n /** The name of the corpus. The registry gives it to the family in `context.set`. */\n readonly set?: string;\n}\n\n/** The options of `cells` and `cellCount` of a registry. */\nexport interface CellsOptions {\n readonly version?: number;\n /** The dimensions of the sweep. The other dimensions keep their defaults. The default is each dimension of the family. */\n readonly sweep?: readonly string[];\n /** The values of a sweep for some dimensions, in place of the levels of the dimensions. */\n readonly levels?: Readonly<Record<string, readonly ParamValue[]>>;\n}\n\n/** The cell of an input of a registry: `<name>@<version>` of its family in `kind` (`familyKind`), and the value of each active dimension. */\nexport type RegistryCell = Readonly<Record<string, ParamValue>> & { readonly kind: string };\n\n/** This function gives the `kind` of the cells of a version of a family: `<name>@<version>`, for example `rect-grid@2`. Thus two versions do not share a family key. */\nexport function familyKind(name: string, version: number): string {\n return `${name}@${version}`;\n}\n\n/** A registry of families. An import registers nothing: a host makes a registry from the lists of families of the engines. */\nexport interface FamilyRegistry<O = LayoutInput> {\n /** This method adds a family. It throws a `RangeError` for a second family with the same name and version, or for a bad dimension. */\n register(family: CorpusFamily<O>): FamilyRegistry<O>;\n /** This method gives a family. Without a version, it gives the first version that the registry got. It throws a `RangeError` for an unknown family. */\n family(name: string, version?: number): CorpusFamily<O>;\n /** This method gives each family, in the order of registration. */\n families(): readonly CorpusFamily<O>[];\n /**\n * This method gives the full dimension values of an input. It throws a `RangeError` for an unknown dimension, a bad value or a value that is not supported.\n * The methods with `dims` accept a cell of `cellOf`: they ignore a `kind` that is the `familyKind` of the family, and refuse another `kind`.\n */\n resolve(name: string, dims?: Readonly<Record<string, ParamValue>>, version?: number): DimensionValues;\n /**\n * This method gives the input of a seed: the output of the family. A dimension with `invalidates` at a value other than its default changes it.\n * Then the method removes those fields, adds their names to `invalidated` and calculates the `hash` again. Another output has no change.\n */\n generate(name: string, seed: number, dims?: Readonly<Record<string, ParamValue>>, options?: GenerateOptions): O;\n /** This method gives the cell of an input: the `familyKind` of the family version and the value of each active dimension. */\n cellOf(name: string, dims?: Readonly<Record<string, ParamValue>>, version?: number): RegistryCell;\n /** This method gives the full dimension values of each cell of a sweep, without the dead combinations of `when`. */\n cells(name: string, options?: CellsOptions): Generator<DimensionValues>;\n /** This method gives the count of the cells of `cells`. It makes no input. */\n cellCount(name: string, options?: CellsOptions): number;\n /** This method gives the defaults, and each end of each numeric range. The dimensions that a `when` needs get its first value. The other dimensions keep their defaults. */\n boundaryCells(name: string, version?: number): DimensionValues[];\n /** This method gives the random source of an input: the stream that `generate` gets in `context.random`. */\n rngOf(name: string, version?: number): (seed: number, dims?: Readonly<Record<string, ParamValue>>) => () => number;\n /** This method gives the map form of `FamilyBy` for the cells of `cellOf`: the `familyKind` of each family version, with its own `familyBy`. */\n familyBy(): FamilyBy;\n}\n\n/** The default key of a family in a manifest: the kind of the cell alone. It is the map form of `FamilyBy` with the entry `\"*\"`. */\nexport const DEFAULT_FAMILY_BY: FamilyBy = /* @__PURE__ */ Object.freeze({ \"*\": /* @__PURE__ */ Object.freeze([]) as readonly string[] });\n\n/** This function gives an `enum` dimension. */\nconst choice = (name: string, values: readonly string[], value: string, meaning: string, engines: readonly string[]): CorpusDimension =>\n Object.freeze({ name, kind: \"enum\", values: Object.freeze([...values]), default: value, meaning, engines: Object.freeze([...engines]) });\n\n/** This function gives an `int` or a `real` dimension. */\nconst range = (\n name: string,\n kind: \"int\" | \"real\",\n limits: { readonly min: number; readonly max: number; readonly value: number; readonly scale?: \"linear\" | \"log\"; readonly levels?: readonly number[] },\n meaning: string,\n engines: readonly string[],\n): CorpusDimension =>\n Object.freeze({\n name,\n kind,\n min: limits.min,\n max: limits.max,\n default: limits.value,\n scale: limits.scale ?? \"linear\",\n ...(limits.levels === undefined ? {} : { levels: Object.freeze([...limits.levels]) }),\n meaning,\n engines: Object.freeze([...engines]),\n });\n\n/**\n * This function gives a dimension with the condition `when`, as a frozen object.\n * A spread in the literal of `CORPUS_DIMENSIONS` is a side effect for a bundler, so the copy is in this function.\n */\nconst withWhen = (dimension: CorpusDimension, when: NonNullable<CorpusDimension[\"when\"]>): CorpusDimension => Object.freeze({ ...dimension, when });\n\nconst P = \"packing\";\nconst H = \"highways\";\nconst J = \"joint\";\n\n/**\n * The shared dimension table. A family takes a dimension of it with `sharedDimension`, or declares its own dimension.\n * The coverage table of each dimension and each engine is in `docs/CORPUS.md`.\n */\nexport const CORPUS_DIMENSIONS: Readonly<Record<string, CorpusDimension>> = /* @__PURE__ */ Object.freeze({\n count: /* @__PURE__ */ range(\"count\", \"int\", { min: 0, max: 100_000, value: 100, scale: \"log\", levels: [1, 10, 100, 1000, 10_000] }, \"The count of the items (n) of an input.\", [P, H, J]),\n sizes: /* @__PURE__ */ choice(\"sizes\", [\"identical\", \"nearIdentical\", \"uniform\", \"heavyTail\", \"bimodal\", \"extremeAspect\"], \"uniform\", \"The distribution of the sizes of the items.\", [P, J]),\n aspect: /* @__PURE__ */ range(\"aspect\", \"real\", { min: 0.25, max: 4, value: 1, scale: \"log\" }, \"The width over the height of a container with no fixed size.\", [P]),\n density: /* @__PURE__ */ range(\"density\", \"real\", { min: 0.05, max: 1, value: 0.4, scale: \"linear\" }, \"The area of the items over the area of the frame of the container.\", [P]),\n obstacles: /* @__PURE__ */ choice(\"obstacles\", [\"none\", \"center\", \"scattered\", \"wall\", \"corridors\", \"touching\", \"edge\"], \"none\", \"The layout of the fixed obstacles.\", [P, J]),\n containerSize: /* @__PURE__ */ choice(\"containerSize\", [\"fixed\", \"freeHeight\", \"freeWidth\", \"freeAspect\", \"freeArea\"], \"fixed\", \"The sides of the container that the engine can change.\", [P, J]),\n containerShape: /* @__PURE__ */ choice(\"containerShape\", [\"rect\", \"convex\", \"polygon\", \"circle\", \"ellipse\", \"holes\"], \"rect\", \"The kind of the shape of the container.\", [P, J]),\n shape: /* @__PURE__ */ choice(\"shape\", SHAPE_KIND_IDS, \"rect\", \"The shape kind of each item: a `ShapeKind` of `shapes.ts`.\", [P]),\n order: /* @__PURE__ */ choice(\"order\", [\"free\", \"soft\"], \"free\", \"The reading order of the items: no order, or a rank on each item.\", [P]),\n groups: /* @__PURE__ */ choice(\"groups\", [\"none\", \"flat\", \"nested\"], \"none\", \"The groups of the items: no groups, one level, or groups in groups.\", [H, J]),\n edgeDensity: /* @__PURE__ */ choice(\"edgeDensity\", [\"sparse\", \"medium\", \"dense\"], \"medium\", \"The mean count of the edges of each item: 0.5, 1.5 or 4.\", [H, J]),\n edgeShape: /* @__PURE__ */ choice(\"edgeShape\", [\"random\", \"clustered\", \"hubChain\", \"hubs\", \"longRange\", \"tree\", \"bundled\"], \"random\", \"The topology of the edges.\", [H, J]),\n ports: /* @__PURE__ */ choice(\"ports\", [\"free\", \"sides\", \"fixed\"], \"free\", \"The ports of the edges: free, a side for each end, or fixed ports.\", [H, J]),\n edgeKey: /* @__PURE__ */ choice(\"edgeKey\", [\"none\", \"random\", \"cluster\"], \"none\", \"The key of each edge in `data.collection`: absent, a random name for each target box, or a name for each cluster of boxes.\", [H, J]),\n hubBy: /* @__PURE__ */ withWhen(\n /* @__PURE__ */ choice(\"hubBy\", [\"area\", \"random\"], \"area\", \"The order of the hubs of the shapes hubs and tree: the largest item first, or random.\", [J]),\n /* @__PURE__ */ Object.freeze({ param: \"edgeShape\", in: /* @__PURE__ */ Object.freeze([\"hubs\", \"tree\"]) }),\n ),\n spacing: /* @__PURE__ */ choice(\"spacing\", [\"stress\", \"gap\", \"margin\", \"both\"], \"both\", \"The split of the route clearance between the margins and the gap. `stress` has neither.\", [J]),\n margin: /* @__PURE__ */ range(\"margin\", \"real\", { min: 0, max: 32, value: 0 }, \"The margin of each item, in units.\", [P, J]),\n gap: /* @__PURE__ */ range(\"gap\", \"real\", { min: 0, max: 32, value: 0 }, \"The free space between two items, in units.\", [P, J]),\n});\n\n/**\n * This function gives a dimension of `CORPUS_DIMENSIONS`, with the fields of `patch` over it. It throws a `RangeError` for an unknown name.\n * With `supported`, `invalidates` or `precision` in the patch, it also throws a `RangeError` for a bad dimension, as `ownerDimension` does.\n */\nexport function sharedDimension(name: string, patch: Partial<CorpusDimension> = {}): CorpusDimension {\n const base = Object.hasOwn(CORPUS_DIMENSIONS, name) ? CORPUS_DIMENSIONS[name] : undefined;\n if (base === undefined) throw new RangeError(`The shared dimension table has no dimension \"${name}\".`);\n const dim: CorpusDimension = Object.freeze({ ...base, ...patch, name });\n if (patch.supported !== undefined || patch.invalidates !== undefined || patch.precision !== undefined)\n throwProblems(`sharedDimension: the dimension \"${name}\"`, ownProblems(dim));\n return dim;\n}\n\n/** The fields of a dimension that the owner declares: each field of `CorpusDimension` but the name. */\nexport type OwnerDimensionSpec = Omit<CorpusDimension, \"name\">;\n\n/**\n * This function gives a dimension that only its owner declares, for example `cut` of a family of `packing`.\n * It throws a `RangeError` for a name of `CORPUS_DIMENSIONS`, the reserved name `kind`, or a bad default, level, `supported`, `invalidates` or `precision`.\n * The registry examines the `when` of the dimension, because it needs the earlier dimensions.\n */\nexport function ownerDimension(name: string, spec: OwnerDimensionSpec): CorpusDimension {\n const where = `ownerDimension: the dimension \"${name}\"`;\n if (typeof name !== \"string\" || name === \"\") throw new RangeError(\"ownerDimension: the name of a dimension is a text that is not empty.\");\n if (name === \"kind\") throw new RangeError(`${where} has a reserved name: the cell of \\`cellOf\\` has the \\`familyKind\\` of the family in \\`kind\\`.`);\n if (Object.hasOwn(CORPUS_DIMENSIONS, name)) throw new RangeError(`${where} is in the shared dimension table. Use sharedDimension(\"${name}\") for it.`);\n const dim: CorpusDimension = Object.freeze({ ...spec, name });\n throwProblems(where, ownProblems(dim));\n return dim;\n}\n\n/** This function throws a `RangeError` with each problem of a list. An empty list throws nothing. */\nfunction throwProblems(where: string, problems: readonly string[]): void {\n if (problems.length > 0) throw new RangeError(`${where} is not good: ${problems.join(\"; \")}.`);\n}\n\n/** This function tells if a value of the stable form of a dimension is in its `supported` values. Without `supported`, each value is in them. */\nfunction inSupported(dim: CorpusDimension, value: ParamValue): boolean {\n const s = dim.supported;\n if (s === undefined) return true;\n if (isSupportedList(s)) return s.some((v) => paramValue(dim, v) === value);\n if (typeof value !== \"number\") return false;\n return (s.min === undefined || value >= s.min) && (s.max === undefined || value <= s.max);\n}\n\n/** This function tells if `SupportedValues` has the list form. */\nconst isSupportedList = (s: SupportedValues): s is readonly ParamValue[] => Array.isArray(s);\n\n/**\n * This function tells if a family accepts a value of a dimension. A site uses it to show the values that a family does not support.\n * It gives `false` for a bad value, and for a value outside `supported`. Without `supported`, it gives `true` for each good value.\n */\nexport function dimensionSupports(dim: CorpusDimension, value: unknown): boolean {\n if (paramProblem(dim, value) !== undefined) return false;\n return inSupported(dim, paramValue(dim, value as ParamValue));\n}\n\n/** This function gives the text of the supported values of a dimension, for a message. */\nfunction supportedText(dim: CorpusDimension): string {\n const s = dim.supported;\n if (s === undefined) return \"each value\";\n if (isSupportedList(s)) return s.map((v) => JSON.stringify(v)).join(\", \");\n return `the values from ${s.min ?? dim.min} to ${s.max ?? dim.max}`;\n}\n\n/** This function gives the problems of one dimension that need no other dimension: the default, the levels, `supported`, `invalidates` and `precision`. */\nfunction ownProblems(d: CorpusDimension): string[] {\n const out: string[] = [];\n const bad = paramProblem(d, d.default);\n if (bad !== undefined) out.push(`the default of \"${d.name}\" is bad: ${bad}`);\n for (const v of d.levels ?? []) {\n const p = paramProblem(d, v);\n if (p !== undefined) out.push(`a level of \"${d.name}\" is bad: ${p}`);\n }\n out.push(...supportProblems(d, bad === undefined));\n out.push(...invalidatesProblems(d));\n out.push(...precisionProblems(d));\n return out;\n}\n\n/** This function gives the problems of the `supported` values of a dimension. `goodDefault` tells that the default is a good value. */\nfunction supportProblems(d: CorpusDimension, goodDefault: boolean): string[] {\n const s = d.supported;\n if (s === undefined) return [];\n const out: string[] = [];\n const numeric = d.kind === \"int\" || d.kind === \"real\";\n if (isSupportedList(s)) {\n if (numeric) return [`the supported values of \"${d.name}\" are a range with min and max, because the dimension is numeric`];\n if (s.length === 0) return [`the supported values of \"${d.name}\" are an empty list`];\n for (const v of s) {\n const p = paramProblem(d, v);\n if (p !== undefined) out.push(`a supported value of \"${d.name}\" is bad: ${p}`);\n }\n if (new Set(s).size !== s.length) out.push(`the supported values of \"${d.name}\" have a value two times`);\n } else {\n if (s === null || typeof s !== \"object\") return [`the supported values of \"${d.name}\" are a list or a range`];\n if (!numeric) return [`the supported values of \"${d.name}\" are a list, because the dimension is not numeric`];\n for (const end of [s.min, s.max]) {\n if (end === undefined) continue;\n const p = paramProblem(d, end);\n if (p !== undefined) out.push(`an end of the supported range of \"${d.name}\" is bad: ${p}`);\n }\n if (s.min !== undefined && s.max !== undefined && s.min > s.max) out.push(`the supported range of \"${d.name}\" has a min above its max`);\n }\n if (out.length > 0) return out;\n if (goodDefault && !inSupported(d, paramValue(d, d.default))) out.push(`the default of \"${d.name}\" is not a supported value`);\n for (const v of d.levels ?? []) if (paramProblem(d, v) === undefined && !inSupported(d, paramValue(d, v))) out.push(`the level ${JSON.stringify(v)} of \"${d.name}\" is not a supported value`);\n return out;\n}\n\n/** This function gives the problems of the `invalidates` fields of a dimension. */\nfunction invalidatesProblems(d: CorpusDimension): string[] {\n const list = d.invalidates;\n if (list === undefined) return [];\n if (!Array.isArray(list) || !list.every((f) => typeof f === \"string\" && f !== \"\")) return [`the invalidates of \"${d.name}\" is not a list of field names`];\n const out: string[] = [];\n if (new Set(list).size !== list.length) out.push(`the invalidates of \"${d.name}\" has a field two times`);\n for (const f of [\"hash\", INVALIDATED_FIELD]) if (list.includes(f)) out.push(`the invalidates of \"${d.name}\" has the field \"${f}\", which the registry writes`);\n return out;\n}\n\n/** This function gives the problems of the `precision` of a dimension. A bad value and a dimension that is not numeric are problems. */\nfunction precisionProblems(d: CorpusDimension): string[] {\n const p: unknown = d.precision;\n if (p === undefined) return [];\n if (typeof p !== \"number\" || !Number.isInteger(p) || p < 0) return [`the precision of \"${d.name}\" is ${JSON.stringify(p)}, not a whole number of 0 or more`];\n if (d.kind !== \"int\" && d.kind !== \"real\") return [`the precision of \"${d.name}\" is for a numeric dimension, but the dimension is a ${d.kind}`];\n return [];\n}\n\n/** This function rounds a number to `places` decimal places: `Math.round(v * 10 ** places) / 10 ** places`. */\nconst roundTo = (v: number, places: number): number => Math.round(v * 10 ** places) / 10 ** places;\n\n/** This function tells if a value is the default of a dimension. With `precision`, it compares the two numbers after it rounds them. */\nfunction isDefault(d: CorpusDimension, value: ParamValue | undefined): boolean {\n const def = paramValue(d, d.default);\n if (d.precision === undefined || typeof value !== \"number\" || typeof def !== \"number\") return value === def;\n return roundTo(value, d.precision) === roundTo(def, d.precision);\n}\n\n/** This function tells if a log scale of a range starts at 0. Then the scale is the log of `1 + x - min`. */\nconst fromZero = (d: SpaceParam): boolean => d.scale === \"log\" && (d.min ?? 0) <= 0;\n\n/**\n * This function gives the value at the fraction `t` of the range of a numeric dimension, on its scale. A slider of a site uses it.\n * A log scale with a `min` of 0 or less is the log of `1 + x - min`. An `int` dimension gives a whole number.\n */\nexport function dimensionAt(dim: SpaceParam, t: number): number {\n const min = dim.min ?? 0;\n const max = dim.max ?? min;\n const u = Math.min(1, Math.max(0, t));\n let v: number;\n if (dim.scale !== \"log\") v = min + u * (max - min);\n else if (fromZero(dim)) v = min + Math.expm1(u * Math.log1p(max - min));\n else v = Math.exp(Math.log(min) + u * (Math.log(max) - Math.log(min)));\n v = Math.min(max, Math.max(min, v));\n return dim.kind === \"int\" ? Math.round(v) : (paramValue(dim, v) as number);\n}\n\n/** This function gives the fraction of the range of a numeric dimension at a value, on its scale. It is the inverse of `dimensionAt`. */\nexport function dimensionUnit(dim: SpaceParam, value: number): number {\n const min = dim.min ?? 0;\n const max = dim.max ?? min;\n if (max === min) return 0;\n const v = Math.min(max, Math.max(min, value));\n if (dim.scale !== \"log\") return (v - min) / (max - min);\n if (fromZero(dim)) return Math.log1p(v - min) / Math.log1p(max - min);\n return (Math.log(v) - Math.log(min)) / (Math.log(max) - Math.log(min));\n}\n\n/** This function gives the range of the supported values of a numeric dimension: its own `min` and `max` in place of the ends of `supported`. */\nfunction supportedSpan(dim: CorpusDimension): { readonly min: number | undefined; readonly max: number | undefined } {\n const s = dim.supported;\n const range = s === undefined || isSupportedList(s) ? {} : s;\n return { min: range.min ?? dim.min, max: range.max ?? dim.max };\n}\n\n/**\n * This function gives the values of a sweep of a dimension. `levels` of the dimension come first. Then an `enum` gives its values, and a `bool` gives `false` and `true`.\n * With `steps`, a numeric dimension gives `steps` points from `min` to `max` on its scale. Else it gives its default.\n * With `supported`, an `enum` and a `bool` give only the supported values, and the points of a numeric dimension stay in the supported range.\n */\nexport function levelsOf(dim: CorpusDimension, steps?: number): ParamValue[] {\n if (dim.levels !== undefined) return [...dim.levels];\n if (dim.kind === \"enum\" || dim.kind === \"bool\") return paramLevels(dim, 1).filter((v) => inSupported(dim, paramValue(dim, v)));\n if (steps === undefined) return paramLevels(dim, 1);\n if (dim.supported !== undefined) {\n const { supported: _supported, ...rest } = dim;\n const span = supportedSpan(dim);\n return levelsOf({ ...rest, ...(span.min === undefined ? {} : { min: span.min }), ...(span.max === undefined ? {} : { max: span.max }) }, steps);\n }\n if (!fromZero(dim)) return paramLevels(dim, steps);\n if (!Number.isInteger(steps) || steps < 1) throw new RangeError(`The steps of a sweep are a whole number of 1 or more, not ${steps}.`);\n if (steps === 1) return [paramValue(dim, dim.default)];\n return [...new Set(Array.from({ length: steps }, (_, j) => dimensionAt(dim, j / (steps - 1))))];\n}\n\n/** This function gives the problems of the dimensions of a family: a repeated name, a bad default, level, `supported`, `invalidates` or `when`. */\nfunction dimensionProblems(dims: readonly CorpusDimension[]): string[] {\n const out: string[] = [];\n const names = dims.map((d) => d.name);\n dims.forEach((d, i) => {\n if (names.indexOf(d.name) !== i) out.push(`the dimension \"${d.name}\" is in the list two times`);\n out.push(...ownProblems(d));\n if (d.when === undefined) return;\n const j = names.indexOf(d.when.param);\n if (j < 0 || j >= i) out.push(`the when of \"${d.name}\" names \"${d.when.param}\", which is not an earlier dimension`);\n else if (d.when.in.length === 0) out.push(`the when of \"${d.name}\" has no values`);\n else for (const v of d.when.in) if (paramProblem(dims[j]!, v) !== undefined) out.push(`the when of \"${d.name}\" has a value that \"${d.when.param}\" does not have`);\n });\n return out;\n}\n\n/**\n * This function gives the full dimension values of an input. A missing dimension gets its default. An inactive dimension of `when` also gets its default.\n * Thus a default that the caller gives, a missing value and an inactive value give the same values. A real number gets its stable form.\n *\n * The function throws a `RangeError` for an unknown dimension or a bad value, also for a bad value of an inactive dimension.\n * It also throws a `RangeError` for a value outside `supported`, with the text \"not supported by\" and `by`.\n */\nexport function resolveDimensions(\n dimensions: readonly CorpusDimension[],\n dims: Readonly<Record<string, ParamValue>> = {},\n where: string = \"The family\",\n by: string = \"the family\",\n): DimensionValues {\n const known = new Set(dimensions.map((d) => d.name));\n for (const key of Object.keys(dims)) if (!known.has(key)) throw new RangeError(`${where} has no dimension \"${key}\".`);\n const active: Record<string, ParamValue> = {};\n const out: Record<string, ParamValue> = {};\n for (const d of dimensions) {\n const given = Object.hasOwn(dims, d.name) ? dims[d.name] : undefined;\n if (given !== undefined) {\n const bad = paramProblem(d, given);\n if (bad !== undefined) throw new RangeError(`${where}: the dimension \"${d.name}\" is bad: ${bad}.`);\n if (!inSupported(d, paramValue(d, given))) {\n throw new RangeError(`${where}: the value ${JSON.stringify(given)} of the dimension \"${d.name}\" is not supported by ${by}. The supported values are ${supportedText(d)}.`);\n }\n }\n const on = paramActive(d, active);\n const value = paramValue(d, on && given !== undefined ? given : d.default);\n if (on) active[d.name] = value;\n out[d.name] = value;\n }\n return out;\n}\n\n/** This function gives the values of the active dimensions only. */\nfunction activeValues(dimensions: readonly CorpusDimension[], full: DimensionValues): Record<string, ParamValue> {\n const active: Record<string, ParamValue> = {};\n for (const d of dimensions) if (paramActive(d, active)) active[d.name] = full[d.name]!;\n return active;\n}\n\n/** This function gives the active values of each cell of a sweep, in the order of the dimensions. The last dimension changes first. */\nfunction* sweepOf(dimensions: readonly CorpusDimension[], levels: readonly (readonly ParamValue[] | undefined)[], i = 0, values: Record<string, ParamValue> = {}): Generator<Record<string, ParamValue>> {\n if (i === dimensions.length) {\n yield { ...values };\n return;\n }\n const d = dimensions[i]!;\n const lv = levels[i];\n if (lv === undefined || !paramActive(d, values)) {\n yield* sweepOf(dimensions, levels, i + 1, paramActive(d, values) ? { ...values, [d.name]: paramValue(d, d.default) } : values);\n return;\n }\n for (const v of lv) yield* sweepOf(dimensions, levels, i + 1, { ...values, [d.name]: paramValue(d, v) });\n}\n\n/** This function counts the cells of a sweep with no list of the cells. A dimension that a later `when` reads splits the count. */\nfunction countOf(dimensions: readonly CorpusDimension[], levels: readonly (readonly ParamValue[] | undefined)[], i = 0, values: Record<string, ParamValue> = {}): number {\n if (i === dimensions.length) return 1;\n const d = dimensions[i]!;\n if (!paramActive(d, values)) return countOf(dimensions, levels, i + 1, values);\n const lv = levels[i] ?? [d.default];\n const readLater = dimensions.slice(i + 1).some((q) => q.when?.param === d.name);\n if (!readLater) return lv.length * countOf(dimensions, levels, i + 1, values);\n let sum = 0;\n for (const v of lv) sum += countOf(dimensions, levels, i + 1, { ...values, [d.name]: paramValue(d, v) });\n return sum;\n}\n\n/** This function gives the levels of each dimension of a sweep. A dimension outside the sweep has `undefined`, so it keeps its default. */\nfunction sweepLevels(dimensions: readonly CorpusDimension[], options: CellsOptions, where: string, by: string): (readonly ParamValue[] | undefined)[] {\n const names = new Set(dimensions.map((d) => d.name));\n for (const name of [...(options.sweep ?? []), ...Object.keys(options.levels ?? {})]) if (!names.has(name)) throw new RangeError(`${where} has no dimension \"${name}\".`);\n return dimensions.map((d) => {\n if (options.sweep !== undefined && !options.sweep.includes(d.name)) return undefined;\n const lv = options.levels !== undefined && Object.hasOwn(options.levels, d.name) ? options.levels[d.name]! : levelsOf(d);\n for (const v of lv) {\n const bad = paramProblem(d, v);\n if (bad !== undefined) throw new RangeError(`${where}: a level of \"${d.name}\" is bad: ${bad}.`);\n if (!inSupported(d, paramValue(d, v))) throw new RangeError(`${where}: the level ${JSON.stringify(v)} of \"${d.name}\" is not supported by ${by}.`);\n }\n return lv;\n });\n}\n\n/**\n * This function gives the output fields that the values make wrong: the `invalidates` of each dimension with a value other than its default, sorted.\n * A dimension with `precision` compares the rounded value with the rounded default.\n */\nfunction invalidFields(dimensions: readonly CorpusDimension[], full: DimensionValues): string[] {\n const out = new Set<string>();\n for (const d of dimensions) {\n if (d.invalidates === undefined || d.invalidates.length === 0) continue;\n if (!isDefault(d, full[d.name])) for (const f of d.invalidates) out.add(f);\n }\n return [...out].sort(byCode);\n}\n\n/** This function compares two strings by their UTF-16 code units. */\nconst byCode = (x: string, y: string): number => (x < y ? -1 : x > y ? 1 : 0);\n\n/**\n * This function removes the fields of `fields` from an output, and adds their names to its field `invalidated`, sorted.\n * Only a field of the output counts. The `hash` of text gets the value of `hash` again. An output with none of the fields is the same object.\n */\nfunction dropFields<O>(output: O, fields: readonly string[], hash: (output: O) => string, where: string): O {\n if (fields.length === 0) return output;\n if (output === null || typeof output !== \"object\" || Array.isArray(output)) throw new RangeError(`${where} invalidates the fields ${fields.join(\", \")}, but its output is not an object.`);\n const o = output as Record<string, unknown>;\n const dropped = fields.filter((f) => Object.hasOwn(o, f));\n if (dropped.length === 0) return output;\n const before = o[INVALIDATED_FIELD];\n const prior = Array.isArray(before) ? before.filter((f): f is string => typeof f === \"string\") : [];\n const body: Record<string, unknown> = {};\n for (const key of Object.keys(o)) if (key !== \"hash\" && key !== INVALIDATED_FIELD && !dropped.includes(key)) body[key] = o[key];\n body[INVALIDATED_FIELD] = [...new Set([...prior, ...dropped])].sort(byCode);\n if (typeof o[\"hash\"] !== \"string\") return (Object.hasOwn(o, \"hash\") ? { ...body, hash: o[\"hash\"] } : body) as O;\n return { ...body, hash: hash(body as O) } as O;\n}\n\n/** This function gives the values that make a dimension active: the first value of its `when`, and the values that make that dimension active. */\nfunction activation(dimensions: readonly CorpusDimension[], dim: CorpusDimension): Record<string, ParamValue> {\n const out: Record<string, ParamValue> = {};\n let d: CorpusDimension | undefined = dim;\n while (d?.when !== undefined) {\n const param: string = d.when.param;\n out[param] = d.when.in[0]!;\n d = dimensions.find((q) => q.name === param);\n }\n return out;\n}\n\n/** This function throws a `RangeError` when a seed is not a whole number of 0 or more. */\nfunction checkSeed(seed: number): void {\n if (!Number.isSafeInteger(seed) || seed < 0) throw new RangeError(`The seed is a whole number of 0 or more, not ${seed}.`);\n}\n\n/** This function gives a new registry with the families of the list. Each engine gives the list of its families. An import registers nothing. */\nexport function createFamilyRegistry<O = LayoutInput>(families: Iterable<CorpusFamily<O>> = []): FamilyRegistry<O> {\n const list: CorpusFamily<O>[] = [];\n const label = (f: CorpusFamily<O>): string => `The family \"${f.name}\" version ${f.version}`;\n const find = (name: string, version?: number): CorpusFamily<O> => {\n const named = list.filter((f) => f.name === name);\n if (named.length === 0) throw new RangeError(`The registry has no family \"${name}\".`);\n if (version === undefined) return named[0]!;\n const found = named.find((f) => f.version === version);\n if (found === undefined) throw new RangeError(`The family \"${name}\" has the versions ${named.map((f) => f.version).join(\", \")}, not ${version}.`);\n return found;\n };\n /** This function removes the `kind` of a cell of `cellOf` when it is the `familyKind` of `f`. It throws a `RangeError` for another kind. */\n const ownDims = (f: CorpusFamily<O>, dims: Readonly<Record<string, ParamValue>> | undefined): Readonly<Record<string, ParamValue>> | undefined => {\n if (dims === undefined || !Object.hasOwn(dims, \"kind\")) return dims;\n const kind = familyKind(f.name, f.version);\n if (dims[\"kind\"] !== kind) throw new RangeError(`${label(f)} has the kind \"${kind}\", not the kind ${JSON.stringify(dims[\"kind\"])} of the cell.`);\n const { kind: _kind, ...rest } = dims;\n return rest;\n };\n /** This function gives the full dimension values of an input of `f`. A message names the family as `familyKind` gives it. */\n const resolveIn = (f: CorpusFamily<O>, dims: Readonly<Record<string, ParamValue>> | undefined): DimensionValues =>\n resolveDimensions(f.dimensions, dims, label(f), familyKind(f.name, f.version));\n const streamOf = (f: CorpusFamily<O>, seed: number, full: DimensionValues): { readonly rng: RngFactory; readonly random: () => number } => {\n const rng = f.rng ?? DEFAULT_RNG;\n return { rng, random: rng(f.rngSeed === undefined ? seed : f.rngSeed(seed, full)) };\n };\n const registry: FamilyRegistry<O> = {\n register(family) {\n if (!Number.isInteger(family.version) || family.version < 1) throw new RangeError(`${label(family)} has a version that is not a whole number of 1 or more.`);\n if (list.some((f) => f.name === family.name && f.version === family.version)) throw new RangeError(`${label(family)} is in the registry already.`);\n const problems = dimensionProblems(family.dimensions);\n const names = family.dimensions.map((d) => d.name);\n if (names.includes(\"kind\")) problems.push('the dimension name \"kind\" is reserved: the cell of `cellOf` has the `familyKind` of the family in `kind`');\n for (const key of family.familyBy ?? []) {\n const d = family.dimensions.find((q) => q.name === key);\n if (d === undefined) problems.push(`the familyBy dimension \"${key}\" is not a dimension of the family`);\n else if (d.when !== undefined) problems.push(`the familyBy dimension \"${key}\" has a when, so a cell without it has no family key`);\n }\n if (problems.length > 0) throw new RangeError(`${label(family)} is not good: ${problems.join(\"; \")}.`);\n list.push(family);\n return registry;\n },\n family: find,\n families: () => [...list],\n resolve(name, dims, version) {\n const f = find(name, version);\n return resolveIn(f, ownDims(f, dims));\n },\n generate(name, seed, dims, options = {}) {\n checkSeed(seed);\n const f = find(name, options.version);\n const full = resolveIn(f, ownDims(f, dims));\n const context: GenerateContext = { ...streamOf(f, seed, full), ...(options.set === undefined ? {} : { set: options.set }) };\n const output = f.generate(seed, full, context);\n const hash = (f.hash ?? documentHash) as (o: O) => string;\n return dropFields(output, invalidFields(f.dimensions, full), hash, label(f));\n },\n cellOf(name, dims, version) {\n const f = find(name, version);\n return { kind: familyKind(f.name, f.version), ...activeValues(f.dimensions, resolveIn(f, ownDims(f, dims))) };\n },\n *cells(name, options = {}) {\n const f = find(name, options.version);\n for (const values of sweepOf(f.dimensions, sweepLevels(f.dimensions, options, label(f), familyKind(f.name, f.version)))) yield resolveIn(f, values);\n },\n cellCount(name, options = {}) {\n const f = find(name, options.version);\n return countOf(f.dimensions, sweepLevels(f.dimensions, options, label(f), familyKind(f.name, f.version)));\n },\n boundaryCells(name, version) {\n const f = find(name, version);\n const base = resolveIn(f, {});\n const out: DimensionValues[] = [base];\n const seen = new Set([JSON.stringify(base)]);\n for (const d of f.dimensions) {\n if (d.kind !== \"int\" && d.kind !== \"real\") continue;\n const span = supportedSpan(d);\n for (const end of [span.min, span.max]) {\n if (end === undefined) continue;\n const cell = resolveIn(f, { ...activation(f.dimensions, d), [d.name]: end });\n const key = JSON.stringify(cell);\n if (!seen.has(key)) {\n seen.add(key);\n out.push(cell);\n }\n }\n }\n return out;\n },\n rngOf(name, version) {\n const f = find(name, version);\n return (seed, dims) => {\n checkSeed(seed);\n return streamOf(f, seed, resolveIn(f, ownDims(f, dims))).random;\n };\n },\n familyBy() {\n const out: Record<string, readonly string[]> = {};\n for (const f of list) out[familyKind(f.name, f.version)] = [...(f.familyBy ?? [])];\n return out;\n },\n };\n for (const f of families) registry.register(f);\n return registry;\n}\n\n/** A step of a composed family: a pure function that changes an input after its base family, as `edgeStep` does. */\nexport interface CorpusStep {\n readonly name: string;\n readonly version: number;\n /** The engine that owns the definition of the step. */\n readonly owner: string;\n readonly meaning: string;\n /** The dimensions of the step. Their names are not names of the dimensions of the base family. */\n readonly dimensions: readonly CorpusDimension[];\n /** The text of the rule that gives the random numbers of the step from the seed. */\n readonly seeding: string;\n readonly crossEngine: CrossEngine;\n /** This function gives the part of the family of the input that tells the values of the step. Without it, the family does not change. */\n readonly familyPart?: (dims: DimensionValues) => string;\n /** This function gives the changed input. It removes the old `hash` of the input. */\n apply(input: LayoutInput, seed: number, dims: DimensionValues): LayoutInput;\n}\n\n/** The options of `composeFamily`. */\nexport interface ComposeOptions {\n /** The default is the name of the base family and the names of the steps, with `+` between them. */\n readonly name?: string;\n /** The default is the owner of the base family. */\n readonly owner?: string;\n readonly meaning?: string;\n /** The hash of the composed input. The default is `documentHash` of `hash.ts`. The composed family also gives it to the registry in `hash`. */\n readonly hash?: (input: LayoutInput) => string;\n}\n\n/** This function gives the values of a list of dimensions from the full values. */\nconst pick = (dims: readonly CorpusDimension[], full: DimensionValues): DimensionValues => Object.fromEntries(dims.map((d) => [d.name, full[d.name]!]));\n\n/**\n * This function gives a family that runs the base family and then each step, with the same seed.\n * The family of the input gets the part of each step after a dot. The id becomes `<set>/<family>/s<seed>`, and the input gets the hash of `options.hash`.\n * The function throws a `RangeError` when a step has a dimension with the name of an earlier dimension.\n */\nexport function composeFamily(base: CorpusFamily<LayoutInput>, steps: readonly CorpusStep[], options: ComposeOptions = {}): CorpusFamily<LayoutInput> {\n const dimensions = [...base.dimensions, ...steps.flatMap((s) => s.dimensions)];\n const seen = new Set<string>();\n for (const d of dimensions) {\n if (seen.has(d.name)) throw new RangeError(`composeFamily: the dimension \"${d.name}\" is in the base family or in an earlier step already.`);\n seen.add(d.name);\n }\n const hash = options.hash ?? documentHash;\n const libm = base.crossEngine === \"libm-dependent\" || steps.some((s) => s.crossEngine === \"libm-dependent\");\n return Object.freeze({\n name: options.name ?? [base.name, ...steps.map((s) => s.name)].join(\"+\"),\n version: base.version,\n owner: options.owner ?? base.owner,\n meaning: options.meaning ?? `${base.meaning} Then the steps ${steps.map((s) => s.name).join(\", \")}.`,\n dimensions,\n seeding: [base.seeding, ...steps.map((s) => `${s.name}: ${s.seeding}`)].join(\" \"),\n crossEngine: libm ? \"libm-dependent\" : \"exact\",\n ...(base.rng === undefined ? {} : { rng: base.rng }),\n ...(base.rngSeed === undefined ? {} : { rngSeed: (seed: number, full: DimensionValues) => base.rngSeed!(seed, pick(base.dimensions, full)) }),\n ...(base.familyBy === undefined ? {} : { familyBy: base.familyBy }),\n ...(options.hash === undefined ? {} : { hash: options.hash }),\n generate(seed: number, full: DimensionValues, context: GenerateContext): LayoutInput {\n let input = base.generate(seed, pick(base.dimensions, full), context);\n const parts: string[] = [];\n for (const step of steps) {\n const values = pick(step.dimensions, full);\n input = step.apply(input, seed, values);\n if (step.familyPart !== undefined) parts.push(step.familyPart(values));\n }\n const family = [input.family ?? base.name, ...parts].join(\".\");\n const set = input.set ?? context.set;\n const id = `${set === undefined ? \"\" : `${set}/`}${family}/s${seed}`;\n const stepped: LayoutInput = { ...input, id, family };\n return { ...stepped, hash: hash(stepped) };\n },\n });\n}\n\n/** The dimensions of `EDGES_STEP`: the parameters of `edgeStep`, from the shared table. */\nconst EDGE_DIMENSIONS: readonly CorpusDimension[] = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ [\"edgeDensity\", \"edgeShape\", \"groups\", \"ports\", \"hubBy\"].map((n) => CORPUS_DIMENSIONS[n]!));\n\n/** This function gives the parameters of `edgeStep` from the values of the dimensions. It throws a `RangeError` for a missing or a bad value. */\nfunction edgeParams(d: DimensionValues): EdgeStepParams {\n const text = (name: string): string => {\n const dim = EDGE_DIMENSIONS.find((q) => q.name === name)!;\n const value = Object.hasOwn(d, name) ? d[name] : undefined;\n const bad = value === undefined ? \"the value is missing\" : paramProblem(dim, value);\n if (bad !== undefined || typeof value !== \"string\") throw new RangeError(`EDGES_STEP: the dimension \"${name}\" is bad: ${bad ?? \"it is not text\"}.`);\n return value;\n };\n return {\n edgeDensity: text(\"edgeDensity\") as EdgeStepParams[\"edgeDensity\"],\n edgeShape: text(\"edgeShape\") as EdgeStepParams[\"edgeShape\"],\n groups: text(\"groups\") as NonNullable<EdgeStepParams[\"groups\"]>,\n ports: text(\"ports\") as NonNullable<EdgeStepParams[\"ports\"]>,\n hubBy: text(\"hubBy\") as NonNullable<EdgeStepParams[\"hubBy\"]>,\n };\n}\n\n/**\n * The step `edges` of `edgeStep` (version 1), as a corpus step. Its family part is `e-<edgeDensity>.<edgeShape>.<groups>.<ports>`.\n * The value `random` of `hubBy` adds the part `.hub-random`.\n */\nexport const EDGES_STEP: CorpusStep = /* @__PURE__ */ Object.freeze({\n name: \"edges\",\n version: 1,\n owner: \"layout-contract\",\n meaning: \"The edges, the groups and the ports of an input, from its topology alone.\",\n dimensions: EDGE_DIMENSIONS,\n seeding: \"stepRandom(seed, step) for the steps edges and ports.\",\n crossEngine: \"libm-dependent\",\n familyPart: (d: DimensionValues) => `e-${d[\"edgeDensity\"]}.${d[\"edgeShape\"]}.${d[\"groups\"]}.${d[\"ports\"]}${d[\"hubBy\"] === \"random\" ? \".hub-random\" : \"\"}`,\n apply: (input: LayoutInput, seed: number, d: DimensionValues) => edgeStep(input, edgeParams(d), seed),\n});\n\n/** The dimension of `EDGE_KEY_STEP`, from the shared table. */\nconst EDGE_KEY_DIMENSIONS: readonly CorpusDimension[] = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ [\"edgeKey\"].map((n) => CORPUS_DIMENSIONS[n]!));\n\n/** This function gives the value of `edgeKey`. It throws a `RangeError` for a missing or a bad value. */\nfunction edgeKeyOf(d: DimensionValues): EdgeKey {\n const value = Object.hasOwn(d, \"edgeKey\") ? d[\"edgeKey\"] : undefined;\n const bad = value === undefined ? \"the value is missing\" : paramProblem(EDGE_KEY_DIMENSIONS[0]!, value);\n if (bad !== undefined) throw new RangeError(`EDGE_KEY_STEP: the dimension \"edgeKey\" is bad: ${bad}.`);\n return value as EdgeKey;\n}\n\n/**\n * The step `edge-key` of `edgeKeyStep` (version 1), as a corpus step. It comes directly after `EDGES_STEP`. Its family part is `key-<edgeKey>`.\n */\nexport const EDGE_KEY_STEP: CorpusStep = /* @__PURE__ */ Object.freeze({\n name: \"edge-key\",\n version: EDGE_KEY_STEP_VERSION,\n owner: \"layout-contract\",\n meaning: \"The key of each edge: absent, with no meaning, or with the meaning of a cluster of boxes.\",\n dimensions: EDGE_KEY_DIMENSIONS,\n seeding: \"stepRandom(seed, step) for the value random. The value cluster reads the stream edges again, as edgeStep does.\",\n crossEngine: \"exact\",\n familyPart: (d: DimensionValues) => `key-${d[\"edgeKey\"]}`,\n apply: (input: LayoutInput, seed: number, d: DimensionValues) => edgeKeyStep(input, { edgeKey: edgeKeyOf(d) }, seed),\n});\n\n/** The set of `CIRCLE_SCATTERED` when the caller gives no set. */\nconst CIRCLE_SET = \"circle-v1\";\n\n/**\n * The shared family `circle-scattered`, version 1: circle items of random whole radii in a fixed container, with no obstacles and no edges.\n *\n * - The dimension `containerShape` takes `rect` or `circle`. One seed gives the same radii in the 2 containers, so a pair joins on the seed.\n * - The circles fill approximately half of the container, and the container is at least as large as the largest circle.\n * - The stream `items` gives each radius, from 8 to 40. The stream `container` gives the width of a rectangle over its side, from 0.80 to 1.25.\n * - The family has no margin and no gap. Each value comes from whole numbers and `Math.sqrt`, which each engine rounds correctly, so the family is `exact`.\n */\nexport const CIRCLE_SCATTERED: CorpusFamily<LayoutInput> = /* @__PURE__ */ Object.freeze({\n name: \"circle-scattered\",\n version: 1,\n owner: \"layout-contract\",\n meaning: \"Circle items of random radii in a fixed rectangle or circle container, which they fill approximately half.\",\n dimensions: /* @__PURE__ */ Object.freeze([/* @__PURE__ */ sharedDimension(\"count\", { default: 40 }), /* @__PURE__ */ sharedDimension(\"containerShape\", { supported: [\"rect\", \"circle\"] })]),\n seeding: \"stepRandom(seed, items) gives the radius of each item. stepRandom(seed, container) gives the width over the side of a rectangle, in hundredths.\",\n crossEngine: \"exact\",\n generate(seed: number, dims: DimensionValues, context: GenerateContext): LayoutInput {\n const count = dims[\"count\"];\n if (typeof count !== \"number\" || !Number.isInteger(count) || count < 0) throw new RangeError(`circle-scattered: the count is a whole number of 0 or more, not ${String(count)}.`);\n const containerShape = dims[\"containerShape\"];\n if (containerShape !== \"rect\" && containerShape !== \"circle\") throw new RangeError(`circle-scattered: the container shape is rect or circle, not ${String(containerShape)}.`);\n const set = context.set ?? CIRCLE_SET;\n let r = stepRandom(seed, \"items\");\n const radii = Array.from({ length: count }, () => randomInt(r, 8, 40));\n const largest = radii.reduce((m, v) => Math.max(m, v), 1);\n const squares = radii.reduce((sum, v) => sum + v * v, 0);\n let container: LayoutInput[\"container\"];\n if (containerShape === \"circle\") {\n const big = Math.max(largest, Math.ceil(Math.sqrt(2 * squares)));\n container = { w: 2 * big, h: 2 * big, fixed: \"size\", shape: { kind: \"circle\", cx: big, cy: big, r: big } };\n } else {\n // The circles have the area PI * squares. A rectangle of 6.3 * squares holds them at approximately half, and 6.3 keeps PI out of the input.\n const area = Math.ceil((63 * squares) / 10);\n r = stepRandom(seed, \"container\");\n const w = Math.max(2 * largest, Math.ceil((Math.sqrt(area) * randomInt(r, 80, 125)) / 100));\n container = { w, h: Math.max(2 * largest, Math.ceil(area / w)), fixed: \"size\" };\n }\n const body: LayoutInput = {\n schema: \"layout-input/1\",\n id: `${set}/circle-scattered/${containerShape}/s${seed}`,\n set,\n family: \"circle-scattered\",\n seed,\n source: \"made-up\",\n generator: { name: \"circle-scattered\", version: 1, params: { count, containerShape }, seed },\n container,\n boxes: radii.map((v, i) => ({ id: `c${i}`, w: 2 * v, h: 2 * v, shape: { kind: \"circle\", cx: v, cy: v, r: v } })),\n edges: [],\n };\n return { ...body, hash: documentHash(body) };\n },\n});\n\n/** The set of `RECT_SCATTERED` when the caller gives no set. */\nconst XCHECK_SET = \"xcheck-v1\";\n\n/**\n * The shared family `rect-scattered`, version 1: a fixed rectangle container, rectangle obstacles at random places and boxes without positions.\n * It is the one copy of the generator of `docs/FORMAT.md` of `packing`. Its input is the input of `packing`, byte for byte.\n * The steps `container`, `obstacles` and `boxes` each have a stream of `stepRandom`. Each value is a whole number, so the family is `exact`.\n */\nexport const RECT_SCATTERED: CorpusFamily<LayoutInput> = /* @__PURE__ */ Object.freeze({\n name: \"rect-scattered\",\n version: 1,\n owner: \"layout-contract\",\n meaning: \"Rectangle obstacles at random places in a fixed rectangle container, and boxes of random sizes.\",\n dimensions: /* @__PURE__ */ Object.freeze([/* @__PURE__ */ sharedDimension(\"count\", { default: 40 })]),\n seeding: \"stepRandom(seed, container) gives w and h. stepRandom(seed, obstacles) gives n, then ow, oh, x and y of each obstacle. stepRandom(seed, boxes) gives bw and bh of each box.\",\n crossEngine: \"exact\",\n generate(seed: number, dims: DimensionValues, context: GenerateContext): LayoutInput {\n const count = dims[\"count\"];\n if (typeof count !== \"number\" || !Number.isInteger(count) || count < 0) throw new RangeError(`rect-scattered: the count is a whole number of 0 or more, not ${String(count)}.`);\n const set = context.set ?? XCHECK_SET;\n let r = stepRandom(seed, \"container\");\n const w = randomInt(r, 600, 1000);\n const h = randomInt(r, 400, 800);\n r = stepRandom(seed, \"obstacles\");\n const n = randomInt(r, 3, 8);\n const obstacles: Obstacle[] = [];\n for (let i = 0; i < n; i++) {\n const ow = randomInt(r, 40, 160);\n const oh = randomInt(r, 40, 160);\n const x = randomInt(r, 0, w - ow);\n const y = randomInt(r, 0, h - oh);\n obstacles.push({ id: `o${i}`, region: { kind: \"rect\", x, y, w: ow, h: oh } });\n }\n r = stepRandom(seed, \"boxes\");\n const boxes = Array.from({ length: count }, (_, i) => {\n const bw = randomInt(r, 20, 120);\n const bh = randomInt(r, 20, 80);\n return { id: `b${i}`, w: bw, h: bh };\n });\n const body: LayoutInput = {\n schema: \"layout-input/1\",\n id: `${set}/rect-scattered/s${seed}`,\n set,\n family: \"rect-scattered\",\n seed,\n source: \"made-up\",\n generator: { name: \"rect-scattered\", version: 1, params: { count }, seed },\n container: { w, h, fixed: \"size\" },\n obstacles,\n boxes,\n edges: [],\n };\n return { ...body, hash: documentHash(body) };\n },\n});\n"],"mappings":";;;AAIA,MAAa,QAAyB;CAAC;CAAO;CAAS;CAAU;AAAM;;AA2BvE,SAAgB,OAAO,MAAuB;CAC5C,OAAO;EAAE,GAAG,KAAK;EAAG,GAAG,KAAK;EAAG,GAAG,KAAK;EAAO,GAAG,KAAK;CAAO;AAC/D;;AAGA,SAAgB,YAAY,MAAuB;CACjD,OAAO;EAAE,GAAG,KAAK;EAAG,GAAG,KAAK;EAAG,OAAO,KAAK;EAAG,QAAQ,KAAK;CAAE;AAC/D;;AA4BA,SAAgB,YAAY,QAAmC;CAC7D,IAAI,WAAW,KAAA,GAAW,OAAO;EAAE,KAAK;EAAG,OAAO;EAAG,QAAQ;EAAG,MAAM;CAAE;CACxE,IAAI,OAAO,WAAW,UAAU,OAAO;EAAE,KAAK;EAAQ,OAAO;EAAQ,QAAQ;EAAQ,MAAM;CAAO;CAClG,OAAO;AACT;;AAGA,SAAgB,KAAK,MAAY,QAAkC;CACjE,MAAM,IAAI,YAAY,MAAM;CAC5B,OAAO;EAAE,GAAG,KAAK,IAAI,EAAE;EAAM,GAAG,KAAK,IAAI,EAAE;EAAK,GAAG,KAAK,IAAI,EAAE,OAAO,EAAE;EAAO,GAAG,KAAK,IAAI,EAAE,MA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|
|
1
|
+
{"version":3,"file":"index.js","names":["byCode","isFields","homeMulberry32","homeFnv1a32","homeSha256Hex","homeCanonicalJson","partOf","isObject","sweepOf"],"sources":["../src/geometry.ts","../src/shapes.ts","../src/tolerance.ts","../src/input.ts","../src/turn.ts","../src/output.ts","../src/record.ts","../src/rules.ts","../src/measures.ts","../src/balance.ts","../src/random.ts","../src/edges.ts","../src/hash.ts","../src/portfolio.ts","../src/corpus.ts","../src/space-walk.ts","../src/strategy-space.ts","../src/strategy-options.ts","../src/strategy-catalog.ts","../src/verdict.ts","../src/families.ts"],"sourcesContent":["/** A side of a box. The y axis points down, so `top` has the smallest y. */\nexport type Side = \"top\" | \"right\" | \"bottom\" | \"left\";\n\n/** The sides in clockwise order, from the top. */\nexport const SIDES: readonly Side[] = [\"top\", \"right\", \"bottom\", \"left\"];\n\nexport interface Point {\n readonly x: number;\n readonly y: number;\n}\n\n/** A rectangle: its top-left corner and its size. */\nexport interface Rect {\n readonly x: number;\n readonly y: number;\n readonly w: number;\n readonly h: number;\n}\n\n/**\n * A rectangle with the size in long names: its top-left corner, its `width` and its `height`.\n * Some layout engines use this shape. `toRect` and `toSizedRect` convert between it and `Rect`.\n */\nexport interface SizedRect {\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n}\n\n/** This function gives the `Rect` of a `SizedRect`. It copies each number, and it does not round. */\nexport function toRect(rect: SizedRect): Rect {\n return { x: rect.x, y: rect.y, w: rect.width, h: rect.height };\n}\n\n/** This function gives the `SizedRect` of a `Rect`. It copies each number, and it does not round. */\nexport function toSizedRect(rect: Rect): SizedRect {\n return { x: rect.x, y: rect.y, width: rect.w, height: rect.h };\n}\n\n/** A value for each side of a box. */\nexport interface Sides {\n readonly top: number;\n readonly right: number;\n readonly bottom: number;\n readonly left: number;\n}\n\n/**\n * A region. The forms and the rules are those of `docs/FORMAT.md` of `packing`.\n * A ring of a polygon closes without a copy of its first point.\n */\nexport type Region =\n | { readonly kind: \"rect\"; readonly x: number; readonly y: number; readonly w: number; readonly h: number }\n | {\n readonly kind: \"polygon\";\n readonly points: readonly (readonly [number, number])[];\n readonly holes?: readonly (readonly (readonly [number, number])[])[];\n }\n | { readonly kind: \"circle\"; readonly cx: number; readonly cy: number; readonly r: number }\n | { readonly kind: \"ellipse\"; readonly cx: number; readonly cy: number; readonly rx: number; readonly ry: number };\n\n/** A margin: one value for the four sides, or one value for each side. */\nexport type Margin = number | Sides;\n\n/** This function gives the value of each side of a margin. No margin gives 0 on each side. */\nexport function marginSides(margin: Margin | undefined): Sides {\n if (margin === undefined) return { top: 0, right: 0, bottom: 0, left: 0 };\n if (typeof margin === \"number\") return { top: margin, right: margin, bottom: margin, left: margin };\n return margin;\n}\n\n/** This function gives the rectangle made larger by the margin on each side. */\nexport function grow(rect: Rect, margin: Margin | undefined): Rect {\n const m = marginSides(margin);\n return { x: rect.x - m.left, y: rect.y - m.top, w: rect.w + m.left + m.right, h: rect.h + m.top + m.bottom };\n}\n\n/** This function gives the bounding box of a region. */\nexport function boundsOf(region: Region): Rect {\n switch (region.kind) {\n case \"rect\":\n return { x: region.x, y: region.y, w: region.w, h: region.h };\n case \"circle\":\n return { x: region.cx - region.r, y: region.cy - region.r, w: 2 * region.r, h: 2 * region.r };\n case \"ellipse\":\n return { x: region.cx - region.rx, y: region.cy - region.ry, w: 2 * region.rx, h: 2 * region.ry };\n case \"polygon\": {\n let x0 = Infinity;\n let y0 = Infinity;\n let x1 = -Infinity;\n let y1 = -Infinity;\n for (const [x, y] of region.points) {\n x0 = Math.min(x0, x);\n y0 = Math.min(y0, y);\n x1 = Math.max(x1, x);\n y1 = Math.max(y1, y);\n }\n return { x: x0, y: y0, w: x1 - x0, h: y1 - y0 };\n }\n }\n}\n\n/**\n * This function gives the exact area of a region. A `rect` gives `w` by `h`, a circle gives `PI * r * r`, and an ellipse gives `PI * rx * ry`.\n * A polygon gives the absolute value of the shoelace formula, less the area of each hole. A ring with fewer than 3 points has the area 0.\n */\nexport function regionArea(region: Region): number {\n switch (region.kind) {\n case \"rect\":\n return region.w * region.h;\n case \"circle\":\n return Math.PI * region.r * region.r;\n case \"ellipse\":\n return Math.PI * region.rx * region.ry;\n case \"polygon\":\n return (region.holes ?? []).reduce((area, hole) => area - ringArea(hole), ringArea(region.points));\n }\n}\n\n/** This function gives the area of one ring of a polygon: the absolute value of the shoelace formula. */\nfunction ringArea(ring: readonly (readonly [number, number])[]): number {\n let twice = 0;\n for (let i = 0; i < ring.length; i++) {\n const [ax, ay] = ring[i]!;\n const [bx, by] = ring[(i + 1) % ring.length]!;\n twice += ax * by - bx * ay;\n }\n return Math.abs(twice) / 2;\n}\n\n/** This function gives the region moved by `dx` and `dy`. */\nexport function translate(region: Region, dx: number, dy: number): Region {\n switch (region.kind) {\n case \"rect\":\n return { ...region, x: region.x + dx, y: region.y + dy };\n case \"circle\":\n case \"ellipse\":\n return { ...region, cx: region.cx + dx, cy: region.cy + dy };\n case \"polygon\": {\n const move = (ring: readonly (readonly [number, number])[]): [number, number][] => ring.map(([x, y]) => [x + dx, y + dy]);\n return region.holes === undefined\n ? { kind: \"polygon\", points: move(region.points) }\n : { kind: \"polygon\", points: move(region.points), holes: region.holes.map(move) };\n }\n }\n}\n\n/**\n * This function gives the overlap of the insides of two rectangles on each axis.\n * A value of 0 or less on an axis is no overlap. Two rectangles with a common edge have an overlap of 0.\n */\nexport function overlapOf(a: Rect, b: Rect): { readonly x: number; readonly y: number } {\n return {\n x: Math.min(a.x + a.w, b.x + b.w) - Math.max(a.x, b.x),\n y: Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y),\n };\n}\n\n/** This function gives the cross product of `ab` and `ac`. The sign tells the side of `ab` that has `c`. */\nfunction orient(a: Point, b: Point, c: Point): number {\n return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);\n}\n\n/** This function tells if two numbers have opposite signs. Zero and NaN give false, so a touch at an end does not count. */\nfunction opposite(p: number, q: number): boolean {\n return (p < 0 && q > 0) || (p > 0 && q < 0);\n}\n\n/**\n * This function tells if the segments `ab` and `cd` cross at one point inside both of them.\n * Segments that only touch at an end, or that are collinear, do not cross. The test has no tolerance.\n */\nexport function segmentsCross(a: Point, b: Point, c: Point, d: Point): boolean {\n return opposite(orient(c, d, a), orient(c, d, b)) && opposite(orient(a, b, c), orient(a, b, d));\n}\n\n/**\n * This function gives the point where the segments `ab` and `cd` cross, or `undefined`.\n * It gives a point exactly when `segmentsCross` is true, so a touch at an end and collinear segments give `undefined`.\n */\nexport function crossingPoint(a: Point, b: Point, c: Point, d: Point): Point | undefined {\n if (!segmentsCross(a, b, c, d)) return undefined;\n const from = orient(c, d, a);\n const t = from / (from - orient(c, d, b));\n return { x: a.x + t * (b.x - a.x), y: a.y + t * (b.y - a.y) };\n}\n\n/** This function gives the shortest distance from `p` to the segment `ab`. A segment of length 0 is the point `a`. */\nexport function pointSegmentDistance(p: Point, a: Point, b: Point): number {\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n const l2 = dx * dx + dy * dy;\n const t = l2 === 0 ? 0 : Math.max(0, Math.min(1, ((p.x - a.x) * dx + (p.y - a.y) * dy) / l2));\n return Math.hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy));\n}\n\n/**\n * This function gives the index at which a point goes among the items of a list on the screen.\n * The reading order is the rows from top to bottom, and each row from left to right.\n * The index is that of the first item whose center comes after the point, from 0 to the number of items.\n * A center within `rowTolerance` of the point on the vertical axis is in the row of the point.\n * The tolerance has the units of the points: on a screen, the default 24 is 24 pixels.\n *\n * Give the centers in reading order and without the item that moves.\n *\n * @example\n * ```ts\n * const index = dropIndex(pointer, others.map(centerOf));\n * ```\n */\nexport function dropIndex(point: Point, centers: readonly Point[], rowTolerance = 24): number {\n for (let i = 0; i < centers.length; i++) {\n const c = centers[i] as Point;\n if (point.y < c.y - rowTolerance) return i;\n if (Math.abs(point.y - c.y) <= rowTolerance && point.x < c.x) return i;\n }\n return centers.length;\n}\n","// The shape kinds of the items (`docs/SHAPES.md`): the declared set, the kind of a box and the check of the measures and rules on a run.\nimport type { ClaimBreak } from \"./corpus.ts\";\nimport { regionArea, type Region } from \"./geometry.ts\";\nimport type { LayoutBox, LayoutInput } from \"./input.ts\";\n\n/**\n * The kind of the shape of an item. A box without `shape` and without `shapeKind` is a `rect`.\n * The set is open: a later version can add a kind. A reader treats an unknown kind as a kind that it does not support.\n */\nexport type ShapeKind = \"rect\" | \"polygon\" | \"circle\" | \"free\";\n\n/** The geometry of a shape kind that this package gives. A `false` value tells that the kind declares the operation, but this package does not supply it. */\nexport interface ShapeGeometry {\n /** The bounding box: `boundsOf` and `placedRect`. */\n readonly bounds: boolean;\n /** The area of the shape: `regionArea` and `boxArea`. */\n readonly area: boolean;\n /** The test that the shape is inside a region: `rectInRegion` for a `rect`. */\n readonly contains: boolean;\n /** The test that two shapes of this kind overlap: `overlapOf` for two `rect` shapes, `shapesOverlap` for two `circle` shapes. */\n readonly overlap: boolean;\n}\n\n/** The facts of one shape kind: its fields, the kinds of `Region` that give it, and its geometry. */\nexport interface ShapeKindSpec {\n readonly id: ShapeKind;\n /** The fields of the outline, relative to the top-left corner of the box. A name with `?` is optional. */\n readonly fields: readonly string[];\n /** The kinds of `LayoutBox.shape` that agree with this kind. */\n readonly regions: readonly Region[\"kind\"][];\n readonly geometry: ShapeGeometry;\n}\n\n/**\n * The declared shape kinds, in their order. Only `rect` has all of its geometry.\n * `polygon` and `circle` have their bounding box and their exact area. A `circle` also has the overlap test of two circles. `free` has its bounding box only.\n */\nexport const SHAPE_KINDS: readonly ShapeKindSpec[] = /* @__PURE__ */ Object.freeze([\n { id: \"rect\", fields: [\"w\", \"h\"], regions: [\"rect\"], geometry: { bounds: true, area: true, contains: true, overlap: true } },\n { id: \"polygon\", fields: [\"points\", \"holes?\"], regions: [\"polygon\"], geometry: { bounds: true, area: true, contains: false, overlap: false } },\n { id: \"circle\", fields: [\"cx\", \"cy\", \"r\"], regions: [\"circle\"], geometry: { bounds: true, area: true, contains: false, overlap: true } },\n { id: \"free\", fields: [\"w\", \"h\", \"shape?\"], regions: [\"rect\", \"polygon\", \"circle\", \"ellipse\"], geometry: { bounds: true, area: false, contains: false, overlap: false } },\n] as const);\n\n/** The ids of `SHAPE_KINDS`, in their order. */\nexport const SHAPE_KIND_IDS: readonly ShapeKind[] = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ SHAPE_KINDS.map((k) => k.id));\n\n/** The shape kinds of a measure or a rule without `shapes`. The contract measured only rectangles before L46. */\nexport const DEFAULT_SHAPES: readonly ShapeKind[] = /* @__PURE__ */ Object.freeze([\"rect\"] as const);\n\n/** A measure or a rule, with the shape kinds that it supports. Without `shapes`, it supports `DEFAULT_SHAPES`. */\nexport interface ShapeSupport<Id extends string = string> {\n readonly id: Id;\n /** The kinds with an exact count or value. */\n readonly shapes?: readonly ShapeKind[];\n /**\n * The kinds with a safe count: the rule can count a break that is not real, but it does not miss a real break.\n * Thus a safe count of 0 tells that the rule has no break. A kind is in `shapes` or in `safe`, not in the two lists.\n */\n readonly safe?: readonly ShapeKind[];\n /**\n * The kinds where the value of a measure is a bound of the true value, not the exact value. `ShapeBound` tells the side.\n * A kind is in one list only: `shapes`, `safe` or `bound.shapes`. `docs/SHAPES.md` tells what a bound value proves.\n */\n readonly bound?: ShapeBound;\n /** The inputs where the exact count of this rule is only safe, with the reason and the date of the fix. `inputShapeLevel` reads it. */\n readonly limit?: ShapeLimit;\n}\n\n/**\n * A stated limit of an exact rule on circles. An input that the limit names gets the level `safe` for each kind that is exact.\n *\n * - `neighbours`: the input has a circle beside another shape kind or an obstacle.\n * - `container`: the input has a circle in a container that is a polygon or an ellipse.\n */\nexport interface ShapeLimit {\n readonly reads: \"neighbours\" | \"container\";\n /** The reason, in words. */\n readonly because: string;\n /** The date of the fix, as `YYYY-MM-DD`. */\n readonly until: string;\n}\n\n/**\n * The kinds where a measure gives a bound of the true value, and the side of the bound.\n * With `upper`, the value is the true value or more. With `lower`, the value is the true value or less.\n *\n * @remarks\n * The side and the `direction` of the measure tell what a bound value `v` proves about a threshold `t`.\n * A bound is optimistic on the better side of the true value, and pessimistic on the worse side.\n *\n * | `direction` | `side` | The bound | The proof | No proof |\n * |---|---|---|---|---|\n * | `higher` | `upper` | optimistic | `v < t`: the true value is less than `t`. | `v >= t` |\n * | `higher` | `lower` | pessimistic | `v >= t`: the true value is `t` or more. | `v < t` |\n * | `lower` | `upper` | pessimistic | `v <= t`: the true value is `t` or less. | `v > t` |\n * | `lower` | `lower` | optimistic | `v > t`: the true value is more than `t`. | `v <= t` |\n *\n * For a floor or a guard, a pessimistic bound proves a pass, and an optimistic bound proves a fail.\n * `compareMeasure` on two bound values proves nothing. A tie with a bound value proves nothing.\n * Against an exact baseline, an optimistic candidate proves only `worse`, and a pessimistic candidate proves only `better`.\n */\nexport interface ShapeBound {\n readonly shapes: readonly ShapeKind[];\n readonly side: \"upper\" | \"lower\";\n}\n\n/** The level of a rule on a shape kind: an exact count, a safe count (an upper bound), or no support. */\nexport type RuleLevel = \"exact\" | \"safe\" | \"none\";\n\n/** This function gives the level of a rule on a shape kind. A kind of `shapesOf` is `exact`, a kind of `safe` is `safe`, and another kind is `none`. It does not read `bound`. */\nexport function ruleLevel(rule: Pick<ShapeSupport, \"shapes\" | \"safe\">, kind: ShapeKind): RuleLevel {\n if (shapesOf(rule).includes(kind)) return \"exact\";\n return rule.safe?.includes(kind) === true ? \"safe\" : \"none\";\n}\n\n/** The level of a measure or a rule on a shape kind. The level `bound` is a value on one side of the true value (`ShapeBound`). */\nexport type ShapeLevel = RuleLevel | \"bound\";\n\n/**\n * This function gives the level of a measure or a rule on a shape kind. It joins the lists `shapes`, `safe` and `bound.shapes`.\n * A kind of `shapesOf` is `exact`, a kind of `safe` is `safe`, a kind of `bound.shapes` is `bound`, and another kind is `none`.\n */\nexport function shapeLevel(use: Pick<ShapeSupport, \"shapes\" | \"safe\" | \"bound\">, kind: ShapeKind): ShapeLevel {\n const level = ruleLevel(use, kind);\n if (level !== \"none\") return level;\n return use.bound?.shapes.includes(kind) === true ? \"bound\" : \"none\";\n}\n\n/** The parts of an input that `inputShapeLevel` and `checkShapes` read. */\nexport type ShapeInput = Pick<LayoutInput, \"id\" | \"boxes\"> & Partial<Pick<LayoutInput, \"obstacles\" | \"container\">>;\n\n/** This function tells if a limit names an input. An input without a circle box is not in a limit. */\nfunction inLimit(limit: ShapeLimit, input: ShapeInput): boolean {\n const kinds = shapeKindsOf(input);\n if (!kinds.includes(\"circle\")) return false;\n if (limit.reads === \"neighbours\") return kinds.length > 1 || (input.obstacles?.length ?? 0) > 0;\n const shape = input.container?.shape?.kind;\n return shape === \"polygon\" || shape === \"ellipse\";\n}\n\n/**\n * This function gives the level of a measure or a rule on a shape kind for one input. It is `shapeLevel` with the `limit` of the rule.\n * When the limit names the input, the level `exact` becomes `safe`. Each other level does not change.\n */\nexport function inputShapeLevel(use: Pick<ShapeSupport, \"shapes\" | \"safe\" | \"bound\" | \"limit\">, kind: ShapeKind, input: ShapeInput): ShapeLevel {\n const level = shapeLevel(use, kind);\n return level === \"exact\" && use.limit !== undefined && inLimit(use.limit, input) ? \"safe\" : level;\n}\n\n/**\n * This function gives the problems of a list of measures and rules. An empty list tells that the list is good.\n * It refuses an unknown kind, a kind two times in one list, and a kind in more than one of `shapesOf`, `safe` and `bound.shapes`.\n * It also refuses a `bound` without a list of kinds, and a `side` that is not `upper` or `lower`.\n * It also refuses a `limit` with a bad `reads` or a bad `until`.\n */\nexport function shapeSupportProblems(uses: readonly ShapeSupport[]): string[] {\n const out: string[] = [];\n for (const use of uses) {\n if (use.limit !== undefined) {\n if (use.limit.reads !== \"neighbours\" && use.limit.reads !== \"container\") out.push(`${use.id}: the limit reads ${String(use.limit.reads)}, not neighbours or container`);\n if (!/^\\d{4}-\\d{2}-\\d{2}$/.test(String(use.limit.until))) out.push(`${use.id}: the limit date ${String(use.limit.until)} is not YYYY-MM-DD`);\n }\n const bound: unknown = use.bound;\n const isBound = typeof bound === \"object\" && bound !== null && !Array.isArray(bound);\n if (bound !== undefined && !isBound) out.push(`${use.id}: the bound value is not an object with shapes and a side`);\n const boundShapes = isBound ? (bound as { readonly shapes?: unknown }).shapes : undefined;\n for (const [name, list] of [[\"shapes\", use.shapes], [\"safe\", use.safe], [\"bound\", boundShapes]] as const) {\n if (list === undefined && (name !== \"bound\" || !isBound)) continue;\n if (!Array.isArray(list)) {\n out.push(`${use.id}: the ${name === \"bound\" ? \"bound shapes\" : name} value is not a list of shape kinds`);\n continue;\n }\n list.forEach((k: unknown, i) => {\n if (!isShapeKind(k)) out.push(`${use.id}: the ${name} kind ${String(k)} is not a declared kind`);\n else if (list.indexOf(k) !== i) out.push(`${use.id}: the ${name} list has the kind ${k} two times`);\n });\n }\n const exact: readonly unknown[] = use.shapes === undefined ? DEFAULT_SHAPES : Array.isArray(use.shapes) ? use.shapes : [];\n if (Array.isArray(use.safe)) for (const k of new Set<unknown>(use.safe)) if (exact.includes(k)) out.push(`${use.id}: the kind ${String(k)} is in shapes and in safe`);\n if (!isBound) continue;\n const side: unknown = (bound as { readonly side?: unknown }).side;\n if (side !== \"upper\" && side !== \"lower\") out.push(`${use.id}: the bound side ${String(side)} is not upper or lower`);\n if (!Array.isArray(boundShapes)) continue;\n const safe: readonly unknown[] = Array.isArray(use.safe) ? use.safe : [];\n for (const k of new Set<unknown>(boundShapes)) {\n if (exact.includes(k)) out.push(`${use.id}: the kind ${String(k)} is in shapes and in bound`);\n if (safe.includes(k)) out.push(`${use.id}: the kind ${String(k)} is in safe and in bound`);\n }\n }\n return out;\n}\n\nconst REGION_KIND: Readonly<Record<Region[\"kind\"], ShapeKind>> = { rect: \"rect\", polygon: \"polygon\", circle: \"circle\", ellipse: \"free\" };\n\n/** This function tells if a value is a declared shape kind. */\nexport function isShapeKind(value: unknown): value is ShapeKind {\n return typeof value === \"string\" && (SHAPE_KIND_IDS as readonly string[]).includes(value);\n}\n\n/**\n * This function gives the shape kind of a box. A box with `shapeKind` has that kind.\n * Without it, the kind comes from `shape`: no shape is a `rect`, and an ellipse is `free`.\n */\nexport function shapeKindOf(box: LayoutBox): ShapeKind {\n if (box.shapeKind !== undefined) return box.shapeKind;\n return box.shape === undefined ? \"rect\" : REGION_KIND[box.shape.kind];\n}\n\n/**\n * This function gives the exact area of a box, or `undefined` when the contract knows only its bounding box.\n * A box with `shape` gives `regionArea` of the shape. A `rect` box without `shape` gives `w` by `h`.\n * A box of the kind `free` gives `undefined`, also with a shape. Thus a box with an ellipse shape gives `undefined`, because `shapeKindOf` makes an ellipse `free`.\n * A box of another kind without `shape` is a bad input, and gives `undefined`.\n */\nexport function boxArea(box: LayoutBox): number | undefined {\n const kind = shapeKindOf(box);\n if (kind === \"free\") return undefined;\n if (box.shape !== undefined) return regionArea(box.shape);\n return kind === \"rect\" ? box.w * box.h : undefined;\n}\n\n/** This function gives the shape kinds of the boxes of an input, in the order of `SHAPE_KINDS`. An input without boxes gives an empty list. */\nexport function shapeKindsOf(input: Pick<LayoutInput, \"boxes\">): ShapeKind[] {\n const seen = new Set(input.boxes.map(shapeKindOf));\n return SHAPE_KIND_IDS.filter((k) => seen.has(k));\n}\n\n/** This function gives the value of the cell dimension `itemShape` of an input: its one kind, `mixed` for more kinds, or `rect` without boxes. */\nexport function itemShapeOf(input: Pick<LayoutInput, \"boxes\">): ShapeKind | \"mixed\" {\n const kinds = shapeKindsOf(input);\n return kinds.length === 0 ? \"rect\" : kinds.length === 1 ? kinds[0]! : \"mixed\";\n}\n\n/** This function gives the problem of the shape kind of a box, or `undefined` when `shapeKind` and `shape` agree. */\nexport function shapeKindProblem(box: LayoutBox): string | undefined {\n const k: unknown = box.shapeKind;\n if (k === undefined) return undefined;\n const spec = SHAPE_KINDS.find((s) => s.id === k);\n if (spec === undefined) return `box ${box.id}: the shape kind ${String(k)} is not a declared kind`;\n if (box.shape === undefined) return k === \"rect\" || k === \"free\" ? undefined : `box ${box.id}: the shape kind ${k} has no shape`;\n if (!spec.regions.includes(box.shape.kind)) return `box ${box.id}: the shape kind ${k} does not agree with a shape of the kind ${box.shape.kind}`;\n return undefined;\n}\n\n/** This function gives the shape kinds that a measure or a rule supports. */\nexport function shapesOf(use: Pick<ShapeSupport, \"shapes\">): readonly ShapeKind[] {\n return use.shapes ?? DEFAULT_SHAPES;\n}\n\n/** The options of `checkShapes`. */\nexport interface ShapeCheck {\n /**\n * The lowest level that `checkShapes` accepts. The default `exact` refuses a kind with only a safe count or a bound value.\n * The value `safe` also accepts a kind of `safe`, as in 0.2.16. Use it only when the run claims that a rule has no break.\n * The value `bound` also accepts a kind of `safe` and a kind of `bound.shapes`. Use it only when the run reads each bound value for the proofs of its side (`docs/SHAPES.md`).\n */\n readonly level?: \"exact\" | \"safe\" | \"bound\";\n}\n\n/**\n * This function checks that each measure and each rule of a run supports each shape kind of the input. An empty list tells that the run is good.\n * Each break has the claim `shape`, the id of the input, and the first 5 ids of the boxes of the kind.\n * By default, a kind of `safe` or of `bound.shapes` is a break, because the result is not exact.\n * With the level `safe`, a kind of `safe` is not a break. With the level `bound`, a kind of `safe` and a kind of `bound.shapes` are not a break.\n */\nexport function checkShapes(input: ShapeInput, uses: readonly ShapeSupport[], options: ShapeCheck = {}): ClaimBreak[] {\n const kinds = shapeKindsOf(input);\n const out: ClaimBreak[] = [];\n for (const use of uses) {\n const shapes = shapesOf(use);\n for (const kind of kinds) {\n const level = inputShapeLevel(use, kind, input);\n const accepts = level === \"exact\" || (level === \"safe\" && (options.level === \"safe\" || options.level === \"bound\")) || (level === \"bound\" && options.level === \"bound\");\n if (accepts) continue;\n const ids = input.boxes.filter((b) => shapeKindOf(b) === kind).map((b) => b.id);\n const shown = ids.slice(0, 5).join(\", \") + (ids.length > 5 ? `, and ${ids.length - 5} more` : \"\");\n const safe =\n level === \"safe\" ? `. The count of ${use.id} on ${kind} is only safe` : level === \"bound\" ? `. The value of ${use.id} is only ${use.bound!.side === \"upper\" ? \"an upper\" : \"a lower\"} bound for ${kind}` : \"\";\n out.push({\n claim: \"shape\",\n detail: `${use.id} supports only the shape kinds ${shapes.join(\", \") || \"(none)\"}, but the input ${input.id} has ${kind} boxes: ${shown}${safe}`,\n inputs: [input.id],\n });\n }\n }\n return out;\n}\n","/** The epsilon for the float compares in an engine. */\nexport const EPS = 1e-6;\n\n/** The count of `EPS` steps in one layout unit. It is the integer equal to `1 / EPS`. */\nexport const EPS_STEPS = 1_000_000;\n\n/**\n * The count of grid steps in one unit of a written file. A file rounds each number `v` to `Math.round(v * RECORD_SCALE) / RECORD_SCALE`.\n * Use a multiplication by this value, not a division by `RECORD_EPS`. The two differ at some half steps.\n */\nexport const RECORD_SCALE = 1000;\n\n/**\n * The epsilon for the float compares on a written file. A file rounds each number to 3 decimals,\n * so a difference of two values can move by up to 0.001. It is `1 / RECORD_SCALE`.\n */\nexport const RECORD_EPS = 1e-3;\n\n/**\n * The tolerance of each hard rule, in layout units. A record writes the tolerance that its run used,\n * in its field `tolerance`, next to `hard`.\n */\nexport interface Tolerance {\n /** Two boxes with their margins break `no-overlap` when their insides overlap by more than this on each axis. */\n readonly overlap: number;\n /** A route breaks `no-pass-through` when a part longer than this is inside a box made this much smaller. */\n readonly through: number;\n}\n\n/**\n * The default tolerance of each rule. The packer is exact, so `overlap` is one unit of the rounding.\n * Routes are sampled curves that follow the margin line, so `through` is larger.\n */\nexport const DEFAULT_TOLERANCE: Tolerance = /* @__PURE__ */ Object.freeze({ overlap: 0.001, through: 0.5 });\n","import type { Margin, Point, Region, Side } from \"./geometry.ts\";\nimport type { ShapeKind } from \"./shapes.ts\";\n\n/**\n * A port of a box: a place where edges go into the box.\n * With `x` and `y`, the port is fixed on the border of the box, relative to its top-left corner.\n * With `side` and `along`, the port is fixed at a fraction of its side.\n * With only a side, the router places the port on that side. Without a side, the router picks the side.\n */\nexport interface Port {\n readonly id: string;\n readonly side?: Side;\n readonly x?: number;\n readonly y?: number;\n /**\n * The place of the port on its `side`: a fraction from 0 to 1, from the start of the side.\n * The start of `left` and `right` is the top end. The start of `top` and `bottom` is the left end.\n * It needs a `side`. A port with `along` has no `x` and no `y`.\n */\n readonly along?: number;\n}\n\n/**\n * This function gives the point of a port on the border of its box, relative to the top-left corner of the box.\n * A port with `x` and `y` gives that point. A port with `side` and `along` gives the point at that fraction of the side.\n * Another port gives `undefined`, because the router picks its point.\n */\nexport function portPoint(box: Pick<LayoutBox, \"w\" | \"h\">, port: Port): Point | undefined {\n if (port.x !== undefined && port.y !== undefined) return { x: port.x, y: port.y };\n if (port.side === undefined || port.along === undefined) return undefined;\n switch (port.side) {\n case \"top\":\n return { x: port.along * box.w, y: 0 };\n case \"bottom\":\n return { x: port.along * box.w, y: box.h };\n case \"left\":\n return { x: 0, y: port.along * box.h };\n case \"right\":\n return { x: box.w, y: port.along * box.h };\n }\n}\n\n/** A box of an input. In the packer, its name is item. */\nexport interface LayoutBox {\n readonly id: string;\n readonly w: number;\n readonly h: number;\n /** The packer writes the position. The router reads it. */\n readonly x?: number;\n readonly y?: number;\n /** A locked box keeps `x` and `y`. The packer reads it as an obstacle. */\n readonly locked?: boolean;\n /** The reading order. Without it, the order of the array is the rank. */\n readonly rank?: number;\n readonly parent?: string;\n readonly group?: string;\n /** A region relative to the origin of the box. Without it, the box is the rectangle `w` by `h`. */\n readonly shape?: Region;\n /**\n * The shape kind of the box (`docs/SHAPES.md`). Without it, `shapeKindOf` gives the kind of `shape`, or `rect` without a shape.\n * The kind `free` tells that the contract knows only the bounding box `w` by `h`.\n */\n readonly shapeKind?: ShapeKind;\n readonly ports?: readonly Port[];\n /** A ring around the box. No other box enters it. Only a route from a port of the box enters it, at a right angle. */\n readonly margin?: Margin;\n /** The packer can turn the box by 90 degrees. The output has the turned box and ports. */\n readonly turnable?: boolean;\n /** The free data of the node. The grouping rule `keys` of `highways` reads `data.group`. */\n readonly data?: Readonly<Record<string, unknown>>;\n}\n\n/** The packer name of a box. It is the same type. */\nexport type Item = LayoutBox;\n\n/** An edge between two boxes, with optional ports. */\nexport interface LayoutEdge {\n readonly id: string;\n readonly source: string;\n readonly target: string;\n readonly sourcePort?: string;\n readonly targetPort?: string;\n readonly data?: Readonly<Record<string, unknown>>;\n}\n\n/** The container. `fixed` tells which sides of the size stay. */\nexport interface LayoutContainer {\n readonly w?: number;\n readonly h?: number;\n readonly fixed: \"size\" | \"width\" | \"height\" | \"none\";\n /** The target aspect: the width divided by the height. The default is 1. */\n readonly aspect?: number;\n /** The weight of the aspect error in the objective. 0 gives the least area. The default is 1. */\n readonly aspectWeight?: number;\n /** The shape. Without it, the container is the rectangle from 0, 0 to `w`, `h`. */\n readonly shape?: Region;\n /** The space between the border and the boxes with their margins. */\n readonly inset?: number;\n}\n\n/** An area that boxes and routes avoid. Without `move`, it stays. With `move`, the packer can move it for `cost` times the distance. */\nexport interface Obstacle {\n readonly id: string;\n readonly region: Region;\n readonly move?: { readonly cost: number };\n}\n\n/** The generator of an input. The same name, version, parameters and seed give the same file, byte for byte. */\nexport interface LayoutGenerator {\n readonly name: string;\n readonly version: number;\n readonly params: Readonly<Record<string, unknown>>;\n readonly seed: number;\n}\n\n/**\n * One minimum distance between two boxes (`a` and `b`). It replaces the two margins of the boxes for this pair, and the global `gap`.\n * The order of `a` and `b` has no meaning. A pair without an entry keeps the margins and the `gap`.\n */\nexport interface PairGap {\n readonly a: string;\n readonly b: string;\n /** The minimum distance between the two boxes, in units: a finite number of 0 or more. */\n readonly gap: number;\n /** The count of the channels that the gap has space for. It is information only: a whole number of 0 or more. */\n readonly lanes?: number;\n}\n\n/** The cell of an input in the taxonomy: one value for each dimension. The dimensions are in `docs/FORMAT.md` of `packing`. */\nexport interface LayoutCell {\n readonly containerSize?: \"fixed\" | \"freeHeight\" | \"freeWidth\" | \"freeAspect\" | \"freeArea\";\n readonly containerShape?: \"rect\" | \"convex\" | \"polygon\" | \"circle\" | \"ellipse\" | \"holes\";\n readonly obstacles?: \"none\" | \"center\" | \"scattered\" | \"wall\" | \"corridors\" | \"touching\" | \"edge\";\n readonly sizes?: \"identical\" | \"uniform\" | \"heavyTail\" | \"bimodal\" | \"extremeAspect\" | \"nearIdentical\";\n readonly count?: \"1\" | \"10\" | \"100\" | \"1k\" | \"10k\";\n readonly mode?: \"offline\" | \"online\" | \"incremental\";\n readonly edgeDensity?: \"sparse\" | \"medium\" | \"dense\";\n readonly edgeShape?: \"random\" | \"clustered\" | \"hubChain\" | \"longRange\" | \"tree\" | \"bundled\";\n readonly groups?: \"none\" | \"flat\" | \"nested\";\n readonly ports?: \"free\" | \"sides\" | \"fixed\";\n /** The shape kinds of the boxes: one kind, or `mixed` for more kinds. Without it, each box is a `rect`. `itemShapeOf` gives the value. */\n readonly itemShape?: ShapeKind | \"mixed\";\n}\n\n/** An input of the corpus: the format `layout-input/1`. */\nexport interface LayoutInput {\n readonly schema: \"layout-input/1\";\n readonly id: string;\n readonly set?: string;\n readonly family?: string;\n readonly seed?: number;\n /** The origin: `made-up`, `published:<set>` or `known-best:<construction>`. */\n readonly source?: string;\n /** The first 16 hex characters of the SHA-256 of the canonical file without this field. */\n readonly hash?: string;\n /** The generator of the input. `null` or no value tells that a person made the input. */\n readonly generator?: LayoutGenerator | null;\n /** The steps that changed the input after its generator, in their order. `edgeStep` adds one. */\n readonly steps?: readonly LayoutGenerator[];\n readonly cell?: LayoutCell;\n /** The place of the input in a sequence of changes. */\n readonly step?: number;\n /** A router input can have no container. */\n readonly container?: LayoutContainer;\n /** The free space between two boxes with their margins. Routes use it. */\n readonly gap?: number;\n /** The distances of some pairs of boxes. An entry replaces the margins and the `gap` for its pair. `canonicalInput` sorts the list. */\n readonly pairGaps?: readonly PairGap[];\n readonly boxes: readonly LayoutBox[];\n readonly edges?: readonly LayoutEdge[];\n readonly obstacles?: readonly Obstacle[];\n /**\n * A variant names its base input and its change.\n * With `packed`, the variant is the packed output of its base input: the router routes the positions of that pack.\n */\n readonly base?: string;\n readonly change?: \"add\" | \"remove\" | \"resize\" | \"reorder\" | \"packed\";\n /**\n * The fields that a corpus registry removed, because a dimension value made them wrong (`CorpusDimension.invalidates`).\n * The names are sorted. An input with no removed field has no `invalidated`.\n */\n readonly invalidated?: readonly string[];\n}\n\n/**\n * A link between two items of a packer input. A graph order of the packer reads the links.\n * `a` and `b` are indexes into `PackInput.items`. The weight is 1 when it has no value.\n */\nexport interface PackLink {\n readonly a: number;\n readonly b: number;\n readonly weight?: number;\n}\n\n/** The input of a packer: a `layout-input/1` file without the edges. */\nexport interface PackInput {\n readonly container: LayoutContainer;\n readonly items: readonly Item[];\n readonly obstacles?: readonly Obstacle[];\n readonly gap?: number;\n readonly pairGaps?: readonly PairGap[];\n /** The links between the items. An input without `links` has no graph, and the links have no effect on an order that does not read them. */\n readonly links?: readonly PackLink[];\n}\n\n/** The options of `toPackInput`. */\nexport interface PackInputOptions {\n /** With `true`, the packer input gets the links of `packLinks`. The default is `false`, so the input has no `links`. */\n readonly links?: boolean;\n}\n\n/**\n * This function gives the packer input of a file. An input without a container gets `{ fixed: \"none\" }`, so the packer picks the size.\n * The edges are not in the packer input. With the option `links`, their links are in it.\n */\nexport function toPackInput(input: LayoutInput, options: PackInputOptions = {}): PackInput {\n return {\n container: input.container ?? { fixed: \"none\" },\n items: input.boxes,\n ...(input.obstacles === undefined ? {} : { obstacles: input.obstacles }),\n ...(input.gap === undefined ? {} : { gap: input.gap }),\n ...(input.pairGaps === undefined ? {} : { pairGaps: input.pairGaps }),\n ...(options.links === true ? { links: packLinks(input) } : {}),\n };\n}\n\n/**\n * This function gives the links of the edges of a file, with indexes into `input.boxes`.\n * - Each link has `a` below `b`. The list is sorted by `a` and then by `b`.\n * - The edges of one pair of boxes make one link. Its weight is the count of the edges, and a link of one edge has no weight.\n * - The function does not use an edge to a box that is not in `input.boxes`, or an edge from a box to the same box.\n */\nexport function packLinks(input: LayoutInput): PackLink[] {\n const index = new Map<string, number>();\n input.boxes.forEach((box, i) => {\n if (!index.has(box.id)) index.set(box.id, i);\n });\n const count = new Map<string, { a: number; b: number; n: number }>();\n for (const edge of input.edges ?? []) {\n const s = index.get(edge.source);\n const t = index.get(edge.target);\n if (s === undefined || t === undefined || s === t) continue;\n const a = Math.min(s, t);\n const b = Math.max(s, t);\n const key = `${a} ${b}`;\n const c = count.get(key);\n if (c === undefined) count.set(key, { a, b, n: 1 });\n else c.n += 1;\n }\n return [...count.values()].sort((x, y) => x.a - y.a || x.b - y.b).map(({ a, b, n }) => (n === 1 ? { a, b } : { a, b, weight: n }));\n}\n\n/** This function compares two strings by their UTF-16 code units, as `Array.prototype.sort` does without a compare function. */\nconst byCode = (x: string, y: string): number => (x < y ? -1 : x > y ? 1 : 0);\n\n/**\n * This function gives the canonical form of an input. `documentHash` uses it for each `layout-input/1` document.\n * Each pair of `pairGaps` gets `a` before `b`, and the list is sorted by `a` and then by `b`.\n * An input without `pairGaps` is the same object, so its hash does not change.\n */\nexport function canonicalInput<T extends LayoutInput>(input: T): T {\n if (!Array.isArray(input.pairGaps)) return input;\n const pairGaps = input.pairGaps\n .map((p): PairGap => (byCode(p.a, p.b) > 0 ? { ...p, a: p.b, b: p.a } : p))\n .sort((x, y) => byCode(x.a, y.a) || byCode(x.b, y.b));\n return { ...input, pairGaps };\n}\n","import { SIDES, marginSides, type Margin, type Region, type Side } from \"./geometry.ts\";\nimport type { LayoutBox, Port } from \"./input.ts\";\n\n/*\n * The turn: 90 degrees clockwise, with the y axis down. The turned box has `w` and `h` swapped,\n * and its top-left corner stays at the position of the box. A point (px, py) of a box of height h\n * goes to (h - py, px). Thus the top-left corner goes to the top-right corner, and each side moves\n * one step clockwise: top to right, right to bottom, bottom to left, left to top.\n */\n\n/** This function gives the side after a turn of 90 degrees clockwise. */\nexport function turnSide(side: Side): Side {\n return SIDES[(SIDES.indexOf(side) + 1) % 4]!;\n}\n\n/** This function gives a point of a box of height `h` after the turn. */\nexport function turnPoint(x: number, y: number, h: number): [number, number] {\n return [h - y, x];\n}\n\n/**\n * This function gives a port of a box of height `h` after the turn. Each value of the port turns, also a port with only `x` or only `y`.\n * The start of a side is its top end or its left end. Thus `left` goes to `top` and `right` goes to `bottom` with `along` changed to `1 - along`.\n * `top` goes to `right` and `bottom` goes to `left` with the same `along`.\n */\nexport function turnPort(port: Port, h: number): Port {\n const { side, x, y, along, ...rest } = port;\n const flips = side === \"left\" || side === \"right\";\n return {\n ...rest,\n ...(side === undefined ? {} : { side: turnSide(side) }),\n ...(y === undefined ? {} : { x: h - y }),\n ...(x === undefined ? {} : { y: x }),\n ...(along === undefined ? {} : { along: flips ? 1 - along : along }),\n };\n}\n\n/** This function gives a margin after the turn: the value of each side moves one side clockwise. */\nexport function turnMargin(margin: Margin): Margin {\n if (typeof margin === \"number\") return margin;\n const m = marginSides(margin);\n return { top: m.left, right: m.top, bottom: m.right, left: m.bottom };\n}\n\n/** This function gives a region relative to the origin of a box of height `h` after the turn. */\nexport function turnRegion(region: Region, h: number): Region {\n switch (region.kind) {\n case \"rect\":\n return { kind: \"rect\", x: h - region.y - region.h, y: region.x, w: region.h, h: region.w };\n case \"circle\":\n return { ...region, cx: h - region.cy, cy: region.cx };\n case \"ellipse\":\n return { kind: \"ellipse\", cx: h - region.cy, cy: region.cx, rx: region.ry, ry: region.rx };\n case \"polygon\": {\n const turn = (ring: readonly (readonly [number, number])[]): [number, number][] => ring.map(([x, y]) => turnPoint(x, y, h));\n return region.holes === undefined\n ? { kind: \"polygon\", points: turn(region.points) }\n : { kind: \"polygon\", points: turn(region.points), holes: region.holes.map(turn) };\n }\n }\n}\n\n/** This function gives a box after the turn: the size, the ports, the margin and the shape turn. The position stays. */\nexport function turnBox(box: LayoutBox): LayoutBox {\n return {\n ...box,\n w: box.h,\n h: box.w,\n ...(box.ports === undefined ? {} : { ports: box.ports.map((p) => turnPort(p, box.h)) }),\n ...(box.margin === undefined ? {} : { margin: turnMargin(box.margin) }),\n ...(box.shape === undefined ? {} : { shape: turnRegion(box.shape, box.h) }),\n };\n}\n","import { boundsOf, translate } from \"./geometry.ts\";\nimport type { LayoutInput } from \"./input.ts\";\nimport { turnBox } from \"./turn.ts\";\n\n/** The position of one item. `turn` is 90 when the packer turned a turnable item. */\nexport interface Placement {\n readonly id: string;\n readonly x: number;\n readonly y: number;\n readonly turn?: 0 | 90;\n}\n\n/** The facts of one stage of a strategy, for the records and the site. */\nexport interface StageTrace {\n readonly id: string;\n readonly ms?: number;\n readonly measures?: Readonly<Record<string, number>>;\n}\n\n/** The output of a packer. It does not change the input. */\nexport interface PackOutput {\n readonly placements: readonly Placement[];\n /** The ids of the items that the packer did not place. */\n readonly overflow: readonly string[];\n /** The size of the container after the pack. For a free size, the size that the search found. */\n readonly size: { readonly w: number; readonly h: number };\n /** The new top-left corner of the bounding box of each obstacle that moved. */\n readonly moved: readonly { readonly id: string; readonly x: number; readonly y: number }[];\n readonly trace?: readonly StageTrace[];\n}\n\n/**\n * This function gives the input with the output of a packer applied. Each placed box gets its position.\n * A turned box gets its turned size, ports, margin and shape. Each moved obstacle moves.\n * The container gets the size of the output. The router reads this result. It does not read `turn`.\n */\nexport function applyPack(input: LayoutInput, output: PackOutput): LayoutInput {\n const at = new Map(output.placements.map((p) => [p.id, p]));\n const moved = new Map(output.moved.map((m) => [m.id, m]));\n const boxes = input.boxes.map((box) => {\n const p = at.get(box.id);\n if (p === undefined) return box;\n const turned = p.turn === 90 ? turnBox(box) : box;\n return { ...turned, x: p.x, y: p.y };\n });\n const obstacles = input.obstacles?.map((o) => {\n const m = moved.get(o.id);\n if (m === undefined) return o;\n const b = boundsOf(o.region);\n return { ...o, region: translate(o.region, m.x - b.x, m.y - b.y) };\n });\n return {\n ...input,\n container: { ...(input.container ?? { fixed: \"none\" }), w: output.size.w, h: output.size.h },\n boxes,\n ...(obstacles === undefined ? {} : { obstacles }),\n };\n}\n","import type { Tolerance } from \"./tolerance.ts\";\nimport type { LayoutInput } from \"./input.ts\";\nimport { isShapeKind, shapeKindsOf, type ShapeKind } from \"./shapes.ts\";\n\n/** The stage of a record: the packer, the router, or both together. */\nexport type Stage = \"pack\" | \"route\" | \"joint\";\n\n/** One run of one strategy on one input and seed: the format `layout-record/1`. A run writes one line of JSON Lines. */\nexport interface LayoutRecord {\n readonly schema: \"layout-record/1\";\n readonly stage: Stage;\n readonly step: string;\n readonly strategy: string;\n /** The options in full, with the defaults. */\n readonly options: Readonly<Record<string, unknown>>;\n readonly corpus: string;\n /** The id of the input. */\n readonly input: string;\n /** The `hash` of the input file. */\n readonly inputHash: string;\n readonly set: string;\n readonly seed: number;\n readonly nodes: number;\n readonly edges: number;\n /** The shape kinds of the boxes of the input, in the order of `SHAPE_KINDS`. Without it, each box is a `rect`. */\n readonly shapes?: readonly ShapeKind[];\n /** The value of each measure, by its name: `pack.*`, `route.*` or `joint.*`. */\n readonly measures: Readonly<Record<string, number>>;\n /** The count of the breaks of each hard rule. A good run has 0 for each rule. */\n readonly hard: Readonly<Record<string, number>>;\n /** The tolerance of each hard rule of the run. */\n readonly tolerance?: Readonly<Partial<Tolerance>>;\n /** The version of the rules that made the counts of `hard`: `HARD_RULE_VERSION` at the run. `hardRuleOf` reads it. */\n readonly hardRule?: number;\n /**\n * The value is `true` when two runs with the same seed give the same positions.\n * A skipped record has `null`, because no run made a claim.\n * A record with `oneRun: true` can also have `null`: the pair had no second run to compare.\n * Each other record has a boolean.\n */\n readonly deterministic: boolean | null;\n /** The id of the prediction that was written before the run. */\n readonly prediction?: string;\n /** The median of `msRuns`, or the time of the one run. */\n readonly ms: number;\n /** The time of each timed repeat, in milliseconds. */\n readonly msRuns?: readonly number[];\n /**\n * The value is `true` when a measure of the pair chose 1 timed repeat and no warm-up.\n * Then `ms` is one time, so a time gate does not read this record.\n * A bench that runs such a pair only once writes `deterministic: null`, and its record makes no claim on determinism.\n */\n readonly oneRun?: boolean;\n /** The wall budget of the pair of a strategy and an input, in milliseconds. */\n readonly budgetMs?: number;\n /** The lower limit of the time of a pair that a stop ended, in milliseconds. This time is censored, so a mean does not read it. */\n readonly msAtLeast?: number;\n /** The pairs that caused a skip, for example the pairs over budget that stopped the larger inputs of a strategy. */\n readonly because?: readonly string[];\n /**\n * The first 16 hex characters of the SHA-256 of the canonical output of the stage.\n * The packer hashes its placements by the order of the ids. The router hashes its routes by the order of the edge ids.\n */\n readonly outputHash?: string;\n /** The facts of the computer of the run. */\n readonly env?: RunEnv;\n /** The reason when the strategy did not run, for example an input over its `maxNodes`. Then the record has no measures. */\n readonly skipped?: string;\n readonly commit?: string;\n /**\n * The facts of a carry: a later run kept this record after an engine release, with no new measure (L147).\n * Without the field, the engines of the run of the record measured it.\n * The measures, the hashes and the times stay the values of the versions of `carried.from`.\n */\n readonly carried?: Carried;\n}\n\n/**\n * The facts of a record that a run kept from an older run after an engine release (L147).\n * The run kept it because each strategy of the record has the same fingerprint at the two versions.\n */\nexport interface Carried {\n /** The version of each engine at the measure, by the name of the engine. */\n readonly from: Readonly<Record<string, string>>;\n /** The version of each engine of the run that keeps the record. The names are the names of `from`. */\n readonly to: Readonly<Record<string, string>>;\n /** The fingerprint of each strategy of the record, by its name: `fingerprintOf` of its probes, the same at the two versions. */\n readonly fingerprints: Readonly<Record<string, string>>;\n /** The id of the run that measured the record. */\n readonly run?: string;\n}\n\n/**\n * The values that a strategy supports, for each dimension of a taxonomy.\n * The dimension names are in `docs/FORMAT.md` of `packing` and `docs/LAYOUT-RECORDS.md` of `highways`.\n */\nexport type Supports = Readonly<Record<string, readonly string[]>>;\n\n/** The facts of the computer of a run. */\nexport interface RunEnv {\n readonly node: string;\n readonly os: string;\n readonly arch: string;\n /** The name of the runner, for example `ubuntu-latest` or `local`. */\n readonly runner: string;\n /** The model of the processor. */\n readonly cpu: string;\n /** The count of the logical processors. */\n readonly cpus: number;\n /** The mode of the timing, for example `process` or `fresh` of `paired-time/1`. Each timing record names its mode. */\n readonly mode?: string;\n /** The context of the run, for example `ci` or `local`, with the Node flags. */\n readonly context?: string;\n}\n\n/** The facts of a run that the input does not give. */\nexport type RunFacts = Omit<LayoutRecord, \"schema\" | \"input\" | \"inputHash\" | \"set\" | \"nodes\" | \"edges\" | \"shapes\">;\n\n/**\n * This function gives the record of a run. The input gives its id, its hash, its set and the counts of the nodes and the edges.\n * The input also gives `shapes`. An input with only `rect` boxes gets no `shapes`, so its record does not change.\n */\nexport function toLayoutRecord(input: LayoutInput, run: RunFacts): LayoutRecord {\n const shapes = shapeKindsOf(input);\n const onlyRect = shapes.length === 0 || (shapes.length === 1 && shapes[0] === \"rect\");\n return {\n schema: \"layout-record/1\",\n ...run,\n input: input.id,\n inputHash: input.hash ?? \"\",\n set: input.set ?? \"\",\n nodes: input.boxes.length,\n edges: input.edges?.length ?? 0,\n ...(onlyRect ? {} : { shapes }),\n };\n}\n\ntype Fields = Readonly<Record<string, unknown>>;\n\nconst isFields = (v: unknown): v is Fields => typeof v === \"object\" && v !== null && !Array.isArray(v);\n\nconst STAGES: readonly string[] = [\"pack\", \"route\", \"joint\"];\nconst RECORD_STRINGS = [\"step\", \"strategy\", \"corpus\", \"input\", \"inputHash\", \"set\"] as const;\nconst RECORD_NUMBERS = [\"seed\", \"nodes\", \"edges\", \"ms\"] as const;\nconst RECORD_OPTIONAL_STRINGS = [\"prediction\", \"outputHash\", \"skipped\", \"commit\"] as const;\nconst RECORD_OPTIONAL_NUMBERS = [\"budgetMs\", \"msAtLeast\", \"hardRule\"] as const;\nconst ENV_STRINGS = [\"node\", \"os\", \"arch\", \"runner\", \"cpu\"] as const;\nconst ENV_OPTIONAL_STRINGS = [\"mode\", \"context\"] as const;\n\n/** This function adds a problem for each value of a map that is not a number. */\nfunction numberMap(out: string[], v: unknown, name: string): void {\n if (!isFields(v)) {\n out.push(`${name} is not an object`);\n return;\n }\n for (const [key, n] of Object.entries(v)) if (typeof n !== \"number\") out.push(`${name}.${key} is not a number`);\n}\n\n/** This function tells if a value is an object whose values are strings. */\nconst isStringMap = (v: unknown): v is Readonly<Record<string, string>> => isFields(v) && Object.values(v).every((s) => typeof s === \"string\");\n\n/** This function gives the problems of the field `carried` of a record. */\nfunction carriedProblems(carried: unknown): string[] {\n if (!isFields(carried)) return [\"carried is not an object\"];\n const out: string[] = [];\n for (const key of [\"from\", \"to\", \"fingerprints\"] as const) if (!isStringMap(carried[key])) out.push(`carried.${key} is not a map of strings`);\n if (carried[\"run\"] !== undefined && typeof carried[\"run\"] !== \"string\") out.push(\"carried.run is not a string\");\n if (out.length > 0) return out;\n const from = carried[\"from\"] as Readonly<Record<string, string>>;\n const to = carried[\"to\"] as Readonly<Record<string, string>>;\n const names = (m: Readonly<Record<string, string>>): string => Object.keys(m).sort().join(\",\");\n if (names(from) === \"\" || names(from) !== names(to)) out.push(\"carried.from and carried.to do not name the same engines\");\n else if (Object.keys(from).every((name) => from[name] === to[name])) out.push(\"carried.to has no other version than carried.from\");\n if (Object.keys(carried[\"fingerprints\"] as object).length === 0) out.push(\"carried.fingerprints is empty\");\n return out;\n}\n\n/** This function gives the problems of the field `env` of a record. */\nfunction envProblems(env: unknown): string[] {\n if (!isFields(env)) return [\"env is not an object\"];\n const out: string[] = [];\n for (const key of ENV_STRINGS) if (typeof env[key] !== \"string\") out.push(`env.${key} is not a string`);\n if (typeof env[\"cpus\"] !== \"number\") out.push(\"env.cpus is not a number\");\n for (const key of ENV_OPTIONAL_STRINGS) if (env[key] !== undefined && typeof env[key] !== \"string\") out.push(`env.${key} is not a string`);\n return out;\n}\n\n/**\n * This function gives the version of the rules that made the counts of `hard` of a record. A record without `hardRule` has version 1.\n * On version 1, a count on a circle is by its bounding box. So it is an upper bound, and a count over 0 proves nothing.\n */\nexport function hardRuleOf(record: Pick<LayoutRecord, \"hardRule\">): number {\n return record.hardRule ?? 1;\n}\n\n/**\n * This function gives the problems of one `layout-record/1` value. An empty list means a good record.\n * A record that has `skipped` has `deterministic: null`. An old skipped record with a boolean is also correct.\n * A record without `skipped` has a boolean, or `null` when it has `oneRun: true`. The check accepts fields that the format does not know.\n */\nexport function checkLayoutRecord(value: unknown): string[] {\n if (!isFields(value)) return [\"the record is not an object\"];\n const out: string[] = [];\n const v = value;\n if (v[\"schema\"] !== \"layout-record/1\") out.push(\"schema is not layout-record/1\");\n if (typeof v[\"stage\"] !== \"string\" || !STAGES.includes(v[\"stage\"])) out.push(\"stage is not pack, route or joint\");\n for (const key of RECORD_STRINGS) if (typeof v[key] !== \"string\") out.push(`${key} is not a string`);\n for (const key of RECORD_NUMBERS) if (typeof v[key] !== \"number\") out.push(`${key} is not a number`);\n for (const key of RECORD_OPTIONAL_STRINGS) if (v[key] !== undefined && typeof v[key] !== \"string\") out.push(`${key} is not a string`);\n if (!isFields(v[\"options\"])) out.push(\"options is not an object\");\n numberMap(out, v[\"measures\"], \"measures\");\n numberMap(out, v[\"hard\"], \"hard\");\n if (v[\"tolerance\"] !== undefined) numberMap(out, v[\"tolerance\"], \"tolerance\");\n const shapes = v[\"shapes\"];\n if (shapes !== undefined && (!Array.isArray(shapes) || !shapes.every(isShapeKind))) out.push(\"shapes is not a list of shape kinds\");\n const msRuns = v[\"msRuns\"];\n if (msRuns !== undefined && (!Array.isArray(msRuns) || !msRuns.every((n) => typeof n === \"number\"))) out.push(\"msRuns is not a list of numbers\");\n if (v[\"oneRun\"] !== undefined && typeof v[\"oneRun\"] !== \"boolean\") out.push(\"oneRun is not a boolean\");\n for (const key of RECORD_OPTIONAL_NUMBERS) if (v[key] !== undefined && typeof v[key] !== \"number\") out.push(`${key} is not a number`);\n const because = v[\"because\"];\n if (because !== undefined && (!Array.isArray(because) || !because.every((s) => typeof s === \"string\"))) out.push(\"because is not a list of strings\");\n if (v[\"env\"] !== undefined) out.push(...envProblems(v[\"env\"]));\n if (v[\"carried\"] !== undefined) {\n out.push(...carriedProblems(v[\"carried\"]));\n if (v[\"skipped\"] !== undefined) out.push(\"a skipped record has carried\");\n }\n const deterministic = v[\"deterministic\"];\n if (v[\"skipped\"] === undefined) {\n const noClaim = deterministic === null && v[\"oneRun\"] === true;\n if (typeof deterministic !== \"boolean\" && !noClaim) out.push(\"deterministic is not a boolean, and the record has no skipped\");\n } else if (deterministic !== null && typeof deterministic !== \"boolean\") out.push(\"deterministic of a skipped record is not null or a boolean\");\n return out;\n}\n\n/**\n * This function reads one `layout-record/1` value, for example one parsed line of a JSON Lines file.\n * It throws a `TypeError` with the problems of `checkLayoutRecord`.\n * An old skipped record has a boolean `deterministic`. The result has `null` in its place, because no run made that claim.\n */\nexport function parseLayoutRecord(value: unknown): LayoutRecord {\n const problems = checkLayoutRecord(value);\n if (problems.length > 0) throw new TypeError(`The record is not a layout-record/1: ${problems.join(\", \")}.`);\n const record = value as LayoutRecord;\n return record.skipped !== undefined && record.deterministic !== null ? { ...record, deterministic: null } : record;\n}\n\n/** The facts of one carry, for `carryRecord`. */\nexport interface CarryFacts {\n /** The version of each engine of the run that keeps the record. */\n readonly to: Readonly<Record<string, string>>;\n /** The fingerprint of each strategy of the record, the same at the two versions. */\n readonly fingerprints: Readonly<Record<string, string>>;\n /** The version of each engine at the measure. A record that a run carried before keeps its `carried.from`, and the function ignores this value. */\n readonly from?: Readonly<Record<string, string>>;\n /** The id of the run that measured the record. A record that a run carried before keeps its `carried.run`. */\n readonly run?: string;\n}\n\n/**\n * This function gives a record that a run keeps after an engine release, with the field `carried` (L147).\n * A record that a run carried before keeps the versions and the run of its measure, so `carried.from` always names the measure.\n * The function throws a `RangeError` for a skipped record: a skip makes no claim on an output, so the run measures the pair again.\n * It also throws a `RangeError` when `checkLayoutRecord` refuses the field `carried` of the result.\n */\nexport function carryRecord(record: LayoutRecord, facts: CarryFacts): LayoutRecord {\n if (record.skipped !== undefined) throw new RangeError(`The record of ${record.strategy} on ${record.input} is skipped, so a run measures it again.`);\n const from = record.carried?.from ?? facts.from;\n if (from === undefined) throw new RangeError(`The record of ${record.strategy} on ${record.input} has no carried.from, so the carry needs from.`);\n const run = record.carried?.run ?? facts.run;\n const carried: Carried = { from, to: facts.to, fingerprints: facts.fingerprints, ...(run === undefined ? {} : { run }) };\n const problems = carriedProblems(carried);\n if (problems.length > 0) throw new RangeError(`The carry of ${record.strategy} on ${record.input} is bad: ${problems.join(\", \")}.`);\n return { ...record, carried };\n}\n","import { boundsOf, grow, marginSides, overlapOf, type Margin, type Point, type Rect, type Region } from \"./geometry.ts\";\nimport type { LayoutBox, LayoutContainer, LayoutInput, Obstacle, PairGap, Port } from \"./input.ts\";\nimport { applyPack, type PackOutput } from \"./output.ts\";\nimport { SHAPE_KIND_IDS, shapeKindProblem, type ShapeSupport } from \"./shapes.ts\";\nimport { DEFAULT_TOLERANCE, EPS, RECORD_EPS } from \"./tolerance.ts\";\n\n/** This function gives the area of a placed box: its shape or its rectangle, at its position. A box without a position gives `undefined`. */\nexport function placedRect(box: LayoutBox): Rect | undefined {\n if (box.x === undefined || box.y === undefined) return undefined;\n if (box.shape === undefined) return { x: box.x, y: box.y, w: box.w, h: box.h };\n const b = boundsOf(box.shape);\n return { x: box.x + b.x, y: box.y + b.y, w: b.w, h: b.h };\n}\n\n/**\n * The version of the rules that count `no-overlap` and `in-container`. A record states it in `LayoutRecord.hardRule`.\n *\n * - Version 1 counts each shape by its bounding box. On a circle, that count is an upper bound. A count over 0 proves nothing.\n * - Version 2 counts two circles, and a circle in a circle container, by the distance of the centers. The other pairs stay on the bounding box.\n */\nexport const HARD_RULE_VERSION = 2;\n\n/** A circle at its place on the board: its center and its radius, without a margin. */\nexport interface PlacedCircle {\n readonly cx: number;\n readonly cy: number;\n readonly r: number;\n}\n\n/** This function gives the circle of a placed box. A box without a position, or with another shape, gives `undefined`. */\nexport function placedCircle(box: LayoutBox): PlacedCircle | undefined {\n if (box.shape?.kind !== \"circle\" || box.x === undefined || box.y === undefined) return undefined;\n return { cx: box.x + box.shape.cx, cy: box.y + box.shape.cy, r: box.shape.r };\n}\n\n/** This function gives the largest side of a margin. A circle has one distance to the things near it, so its margin is this side. */\nfunction marginReach(margin: Margin | undefined): number {\n const m = marginSides(margin);\n return Math.max(m.top, m.right, m.bottom, m.left);\n}\n\n/** This function tells if the centers of two circles are nearer than `need`. It compares the squares, so it does not take a root. */\nfunction nearerThan(a: PlacedCircle, b: PlacedCircle, need: number): boolean {\n if (need <= 0) return false;\n const dx = a.cx - b.cx;\n const dy = a.cy - b.cy;\n return dx * dx + dy * dy < need * need;\n}\n\n/**\n * This function tells if two placed boxes break `no-overlap`. It is the rule for one pair of `countOverlaps`.\n *\n * - Two circles break the rule when their centers are nearer than the two radii and the two margins, less `tolerance`. The margin of a circle is the largest side of its margin.\n * - Another pair breaks the rule when the bounding boxes with their margins overlap by more than `tolerance` on each axis. With a shape that is not a rectangle, this test is an upper bound.\n * - With `gap`, the gap replaces the two margins. Two circles are then apart by the two radii and the gap. For another pair, one box grows by the gap.\n * - A box without a position does not overlap.\n */\nexport function shapesOverlap(a: LayoutBox, b: LayoutBox, tolerance: number = DEFAULT_TOLERANCE.overlap, gap?: number): boolean {\n const ca = placedCircle(a);\n const cb = placedCircle(b);\n if (ca !== undefined && cb !== undefined) return nearerThan(ca, cb, ca.r + cb.r + (gap ?? marginReach(a.margin) + marginReach(b.margin)) - tolerance);\n const ra = placedRect(a);\n const rb = placedRect(b);\n if (ra === undefined || rb === undefined) return false;\n const o = gap === undefined ? overlapOf(grow(ra, a.margin), grow(rb, b.margin)) : overlapOf(grow(ra, gap), rb);\n return o.x > tolerance && o.y > tolerance;\n}\n\n/** This function gives the gap of each pair of `pairGaps` by `pairKey`. The first entry of a pair wins. A pair of one box has no gap. */\nfunction gapsOf(pairGaps: readonly PairGap[] | undefined): Map<string, number> {\n const gaps = new Map<string, number>();\n for (const p of pairGaps ?? []) {\n const key = pairKey(p.a, p.b);\n if (p.a !== p.b && !gaps.has(key)) gaps.set(key, p.gap);\n }\n return gaps;\n}\n\n/**\n * This function counts the pairs of placed boxes that break `no-overlap`. `shapesOverlap` is the rule for one pair.\n * Two circles count by the distance of their centers. Each other pair counts by the bounding boxes, so a circle beside another shape is an upper bound (roadmap item L107).\n *\n * A pair of `pairGaps`, in either order, uses its `gap` in place of the two margins. One box grows by the gap, and the other box does not grow.\n * Thus the pair breaks the rule only when the boxes are nearer than the gap on each axis. The other pairs do not change.\n */\nexport function countOverlaps(boxes: readonly LayoutBox[], tolerance: number = DEFAULT_TOLERANCE.overlap, pairGaps?: readonly PairGap[]): number {\n const circles = circleOverlaps(boxes, tolerance, pairGaps);\n if (pairGaps === undefined || pairGaps.length === 0) return circles + marginOverlaps(boxes, tolerance, undefined);\n const gaps = gapsOf(pairGaps);\n const raw = new Map<string, LayoutBox>();\n for (const box of boxes) {\n if (placedRect(box) !== undefined && !raw.has(box.id)) raw.set(box.id, box);\n }\n let count = circles + marginOverlaps(boxes, tolerance, gaps);\n for (const [key, gap] of gaps) {\n const [a, b] = JSON.parse(key) as [string, string];\n const ba = raw.get(a);\n const bb = raw.get(b);\n if (ba === undefined || bb === undefined) continue;\n if (placedCircle(ba) !== undefined && placedCircle(bb) !== undefined) continue;\n if (shapesOverlap(ba, bb, tolerance, gap)) count++;\n }\n return count;\n}\n\n/** This function gives the key of a pair of box ids, with the same key for each order. */\nconst pairKey = (a: string, b: string): string => JSON.stringify(a < b ? [a, b] : [b, a]);\n\n/**\n * This function counts the pairs of placed circles that break `no-overlap`, by the distance of their centers. Each other box does not count.\n *\n * - Two circles break the rule when their centers are nearer than the two radii, the two margins and `gap`, less `tolerance`.\n * - The margin of a circle is the largest side of its margin.\n * - A pair of `pairGaps` is apart by the two radii and its gap, in place of the margins and `gap`.\n * - `gap` has the default 0. The rule `no-overlap` does not read `LayoutInput.gap`, so `countOverlaps` gives no value. An engine that keeps the gap between circles gives it here.\n */\nexport function circleOverlaps(boxes: readonly LayoutBox[], tolerance: number = DEFAULT_TOLERANCE.overlap, pairGaps?: readonly PairGap[], gap = 0): number {\n const gaps = gapsOf(pairGaps);\n const discs: { readonly id: string; readonly c: PlacedCircle; readonly reach: number }[] = [];\n const first = new Map<string, PlacedCircle>();\n for (const box of boxes) {\n const c = placedCircle(box);\n if (c === undefined) continue;\n discs.push({ id: box.id, c, reach: c.r + marginReach(box.margin) + gap / 2 });\n if (!first.has(box.id)) first.set(box.id, c);\n }\n discs.sort((a, b) => a.c.cx - a.reach - (b.c.cx - b.reach));\n let count = 0;\n for (let i = 0; i < discs.length; i++) {\n const a = discs[i]!;\n for (let j = i + 1; j < discs.length; j++) {\n const b = discs[j]!;\n if (b.c.cx - b.reach >= a.c.cx + a.reach - tolerance) break;\n if (gaps.has(pairKey(a.id, b.id))) continue;\n if (nearerThan(a.c, b.c, a.reach + b.reach - tolerance)) count++;\n }\n }\n for (const [key, g] of gaps) {\n const [a, b] = JSON.parse(key) as [string, string];\n const ca = first.get(a);\n const cb = first.get(b);\n if (ca !== undefined && cb !== undefined && nearerThan(ca, cb, ca.r + cb.r + g - tolerance)) count++;\n }\n return count;\n}\n\n/** This function counts the overlaps by the bounding boxes with their margins. It skips the pairs of `skip` and the pairs of two circles. */\nfunction marginOverlaps(boxes: readonly LayoutBox[], tolerance: number, skip: ReadonlyMap<string, number> | undefined): number {\n const rects: { readonly id: string; readonly r: Rect; readonly circle: boolean }[] = [];\n for (const box of boxes) {\n const r = placedRect(box);\n if (r !== undefined) rects.push({ id: box.id, r: grow(r, box.margin), circle: box.shape?.kind === \"circle\" });\n }\n rects.sort((a, b) => a.r.x - b.r.x);\n let count = 0;\n for (let i = 0; i < rects.length; i++) {\n const a = rects[i]!.r;\n for (let j = i + 1; j < rects.length; j++) {\n const b = rects[j]!.r;\n if (b.x >= a.x + a.w - tolerance) break;\n if (rects[i]!.circle && rects[j]!.circle) continue;\n if (skip !== undefined && skip.has(pairKey(rects[i]!.id, rects[j]!.id))) continue;\n const o = overlapOf(a, b);\n if (o.x > tolerance && o.y > tolerance) count++;\n }\n }\n return count;\n}\n\n/** The options of the container test of `countOutside` and `packHard`. */\nexport interface ContainerTest {\n /**\n * With `true`, a box of a shaped container with the size `fixed` must stay inside the shape, not only inside its bounding box.\n * A circle in a circle container is tested by distance. The default is `true` since 0.4.0. With `false`, only the bounding box counts.\n */\n readonly exactContainer?: boolean;\n}\n\n/** This function gives the circle of a circle container. A free size reads its radius from `w`, and the corner of the shape stays. Another container, or a free size without `w`, gives `undefined`. */\nfunction containerCircle(c: LayoutContainer): PlacedCircle | undefined {\n const s = c.shape;\n if (s?.kind !== \"circle\") return undefined;\n if (c.fixed === \"size\") return s;\n if (c.w === undefined) return undefined;\n const r = c.w / 2;\n return { cx: s.cx - s.r + r, cy: s.cy - s.r + r, r };\n}\n\n/** This function tells if a circle goes out of a circle container. The reach is the center distance, the radius and `extra`. It compares the squares. */\nfunction circleOutside(disc: PlacedCircle, extra: number, ring: PlacedCircle, tolerance: number): boolean {\n const room = ring.r + tolerance - disc.r - extra;\n if (room < 0) return true;\n const dx = disc.cx - ring.cx;\n const dy = disc.cy - ring.cy;\n return dx * dx + dy * dy > room * room;\n}\n\n/**\n * This function counts the placed circles that go out of a circle container, by the distance of the centers.\n *\n * - The reach of a circle is the sum of the center distance, the radius, the largest side of the margin and the inset.\n * - A circle breaks the rule when its reach is more than the container radius plus `tolerance`.\n * - A container with a free size reads its radius from `w`, and its center is the corner of the shape plus that radius. `applyPack` writes that `w`.\n * - Each other box does not count. The function throws a `RangeError` for a container that is not a circle.\n */\nexport function circlesOutside(input: LayoutInput, tolerance: number = DEFAULT_TOLERANCE.overlap): number {\n const c = input.container;\n const ring = c === undefined ? undefined : containerCircle(c);\n if (c === undefined || ring === undefined) throw new RangeError(\"The function circlesOutside needs a circle container, with w when its size is free.\");\n let count = 0;\n for (const box of input.boxes) {\n const disc = placedCircle(box);\n if (disc !== undefined && circleOutside(disc, marginReach(box.margin) + (c.inset ?? 0), ring, tolerance)) count++;\n }\n return count;\n}\n\n/** This function gives the length of the part of the segment `ab` inside a circle. A radius of 0 or less gives 0. */\nfunction partInCircle(a: Point, b: Point, cx: number, cy: number, r: number): number {\n if (r <= 0) return 0;\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n const fx = a.x - cx;\n const fy = a.y - cy;\n const l2 = dx * dx + dy * dy;\n if (l2 === 0) return 0;\n const half = fx * dx + fy * dy;\n const inner = half * half - l2 * (fx * fx + fy * fy - r * r);\n if (inner <= 0) return 0;\n const root = Math.sqrt(inner);\n const t0 = Math.max(0, (-half - root) / l2);\n const t1 = Math.min(1, (-half + root) / l2);\n return t1 > t0 ? (t1 - t0) * Math.sqrt(l2) : 0;\n}\n\n/** This function gives the length of the part of the segment `ab` inside the open box from (`x0`, `y0`) to (`x1`, `y1`). A box with no inside gives 0. */\nfunction partInBox(a: Point, b: Point, x0: number, y0: number, x1: number, y1: number): number {\n if (x1 <= x0 || y1 <= y0) return 0;\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n let t0 = 0;\n let t1 = 1;\n for (const [from, d, lo, hi] of [[a.x, dx, x0, x1], [a.y, dy, y0, y1]] as const) {\n if (d === 0) {\n if (from <= lo || from >= hi) return 0;\n continue;\n }\n const ta = (lo - from) / d;\n const tb = (hi - from) / d;\n t0 = Math.max(t0, Math.min(ta, tb));\n t1 = Math.min(t1, Math.max(ta, tb));\n if (t0 > t1) return 0;\n }\n return (t1 - t0) * Math.sqrt(dx * dx + dy * dy);\n}\n\n/**\n * This function tells if the segment `ab` goes through a placed box, by the rule of `Tolerance.through`.\n * A part of the segment longer than `tolerance` is inside the shape made `tolerance` smaller.\n *\n * - A circle box reads its circle. Each other kind reads its bounding box, so on a polygon or a free shape the answer is an upper bound.\n * - The margin of the box does not count. A box without a position gives `false`.\n */\nexport function segmentThroughShape(a: Point, b: Point, box: LayoutBox, tolerance: number = DEFAULT_TOLERANCE.through): boolean {\n const disc = placedCircle(box);\n if (disc !== undefined) return partInCircle(a, b, disc.cx, disc.cy, disc.r - tolerance) > tolerance;\n const r = placedRect(box);\n if (r === undefined) return false;\n return partInBox(a, b, r.x + tolerance, r.y + tolerance, r.x + r.w - tolerance, r.y + r.h - tolerance) > tolerance;\n}\n\n/** A route between two boxes: the ids of its ends and its points. `countLinksThroughShapes` reads it. */\nexport interface ShapeLink {\n readonly source: string;\n readonly target: string;\n readonly points: readonly Point[];\n}\n\n/**\n * This function counts the routes that go through a placed box that is not one of their two ends, by `segmentThroughShape`.\n * A route counts once, also when it goes through more than one box.\n */\nexport function countLinksThroughShapes(boxes: readonly LayoutBox[], links: readonly ShapeLink[], tolerance: number = DEFAULT_TOLERANCE.through): number {\n const placed = boxes.flatMap((box) => {\n const r = placedRect(box);\n return r === undefined ? [] : [{ box, r }];\n });\n placed.sort((p, q) => p.r.x - q.r.x);\n const widest = placed.reduce((m, p) => Math.max(m, p.r.w), 0);\n const firstAt = (x: number): number => {\n let lo = 0;\n let hi = placed.length;\n while (lo < hi) {\n const mid = (lo + hi) >>> 1;\n if (placed[mid]!.r.x < x) lo = mid + 1;\n else hi = mid;\n }\n return lo;\n };\n let count = 0;\n for (const link of links) {\n let hit = false;\n for (let i = 1; i < link.points.length && !hit; i++) {\n const a = link.points[i - 1]!;\n const b = link.points[i]!;\n const left = Math.min(a.x, b.x);\n const right = Math.max(a.x, b.x);\n const top = Math.min(a.y, b.y);\n const bottom = Math.max(a.y, b.y);\n for (let k = firstAt(left - widest); k < placed.length && placed[k]!.r.x < right && !hit; k++) {\n const { box, r } = placed[k]!;\n if (r.x + r.w <= left || r.y >= bottom || r.y + r.h <= top) continue;\n if (box.id !== link.source && box.id !== link.target && segmentThroughShape(a, b, box, tolerance)) hit = true;\n }\n }\n if (hit) count++;\n }\n return count;\n}\n\n/**\n * This function counts the placed boxes that go out of the container.\n * Each box with its margin must stay inside the container made smaller by `inset`. Only the fixed sides of the size count. A shaped container counts as its bounding box.\n *\n * With `exactContainer`, the default, a box of a shaped container with the size `fixed` also counts when it is not inside the shape, by `rectInRegion`.\n * For that test, the box grows by `inset` and becomes smaller by `tolerance` on each side. A shaped container with a free side keeps the bounding test only.\n * A circle in a circle container does not use `rectInRegion`. It counts by distance, as in `circlesOutside`, also when the size is free.\n * An input without a container gives 0.\n */\nexport function countOutside(input: LayoutInput, tolerance: number = DEFAULT_TOLERANCE.overlap, options: ContainerTest = {}): number {\n const c = input.container;\n if (c === undefined) return 0;\n const exact = options.exactContainer !== false;\n const shape = exact && c.fixed === \"size\" ? c.shape : undefined;\n const ring = exact ? containerCircle(c) : undefined;\n const area = c.shape === undefined ? { x: 0, y: 0, w: c.w ?? Infinity, h: c.h ?? Infinity } : boundsOf(c.shape);\n const inset = c.inset ?? 0;\n const fixW = c.fixed === \"size\" || c.fixed === \"width\";\n const fixH = c.fixed === \"size\" || c.fixed === \"height\";\n let count = 0;\n for (const box of input.boxes) {\n const r0 = placedRect(box);\n if (r0 === undefined) continue;\n const r = grow(r0, box.margin);\n const outX = r.x < area.x + inset - tolerance || r.x + r.w > area.x + area.w - inset + tolerance;\n const outY = r.y < area.y + inset - tolerance || r.y + r.h > area.y + area.h - inset + tolerance;\n const disc = ring === undefined ? undefined : placedCircle(box);\n if ((fixW && outX) || (fixH && outY)) count++;\n else if (ring !== undefined && disc !== undefined) {\n if (circleOutside(disc, marginReach(box.margin) + inset, ring, tolerance)) count++;\n } else if (shape !== undefined && !rectInRegion(shape, shrink(grow(r, inset), tolerance))) count++;\n }\n return count;\n}\n\n/** This function counts the fixed ports that are not on the border of their box, with the epsilon of a written file. A port without a side does not count. */\nexport function countPortsOffBorder(boxes: readonly LayoutBox[], eps: number = RECORD_EPS): number {\n let count = 0;\n for (const box of boxes) {\n for (const p of box.ports ?? []) {\n if (p.x === undefined || p.y === undefined || p.side === undefined) continue;\n const along = p.side === \"top\" || p.side === \"bottom\" ? p.x : p.y;\n const length = p.side === \"top\" || p.side === \"bottom\" ? box.w : box.h;\n const across = { top: p.y, bottom: p.y - box.h, left: p.x, right: p.x - box.w }[p.side];\n if (Math.abs(across) > eps || along < -eps || along > length + eps) count++;\n }\n }\n return count;\n}\n\n/** The count of the breaks of each hard rule of a pack. */\nexport interface PackHard {\n readonly \"no-overlap\": number;\n readonly \"in-container\": number;\n readonly \"locked-kept\": number;\n readonly complete: number;\n}\n\n/**\n * The hard rules of a pack, with the shape kinds that each rule supports.\n * `no-overlap` and `in-container` are exact for a `rect` and a `circle`. `limit` tells the inputs where the count of a circle is only safe (roadmap item L107).\n * For the other kinds, these rules test the bounding box. The count is safe: a shape is inside its bounding box, so the count is an upper bound. A count of 0 tells that the rule has no break.\n * `locked-kept` and `complete` read only the positions and the ids, so they support each kind.\n */\nexport const PACK_HARD_RULES: readonly ShapeSupport<keyof PackHard>[] = /* @__PURE__ */ Object.freeze([\n {\n id: \"no-overlap\",\n shapes: [\"rect\", \"circle\"],\n safe: [\"polygon\", \"free\"],\n limit: { reads: \"neighbours\", because: \"A circle beside another shape kind or an obstacle counts by its bounding box.\", until: \"2026-11-28\" },\n },\n {\n id: \"in-container\",\n shapes: [\"rect\", \"circle\"],\n safe: [\"polygon\", \"free\"],\n limit: { reads: \"container\", because: \"A circle in a polygon or an ellipse container counts by its bounding box.\", until: \"2026-11-28\" },\n },\n { id: \"locked-kept\", shapes: SHAPE_KIND_IDS },\n { id: \"complete\", shapes: SHAPE_KIND_IDS },\n] as const);\n\n/** This function tells if the inside of `region` and the inside of `rect` have a common point. */\nexport function regionHitsRect(region: Region, rect: Rect): boolean {\n if (rect.w <= 0 || rect.h <= 0) return false;\n switch (region.kind) {\n case \"rect\": {\n const o = overlapOf(region, rect);\n return o.x > 0 && o.y > 0;\n }\n case \"circle\":\n return circleHitsRect(region.cx, region.cy, region.r, region.r, rect);\n case \"ellipse\":\n return circleHitsRect(region.cx, region.cy, region.rx, region.ry, rect);\n case \"polygon\": {\n const rings = [region.points, ...(region.holes ?? [])];\n const inside = (x: number, y: number): boolean => x > rect.x && x < rect.x + rect.w && y > rect.y && y < rect.y + rect.h;\n if (region.points.some(([x, y]) => inside(x, y))) return true;\n for (const ring of rings) {\n for (let i = 0; i < ring.length; i++) {\n const a = ring[i]!;\n const b = ring[(i + 1) % ring.length]!;\n const m = clipMid(a[0], a[1], b[0], b[1], rect);\n if (m !== undefined && inside(m[0], m[1])) return true;\n }\n }\n return pointInRings(rect.x + rect.w / 2, rect.y + rect.h / 2, rings);\n }\n }\n}\n\n/**\n * This function tells if all of `rect` is inside `region`. A point on the border counts as inside. No part of `rect` can overlap a hole.\n * The test of a circle, an ellipse or a polygon accepts an error of `EPS` on the border. A polygon can be concave.\n */\nexport function rectInRegion(region: Region, rect: Rect): boolean {\n const x1 = rect.x + rect.w;\n const y1 = rect.y + rect.h;\n const corners: readonly (readonly [number, number])[] = [\n [rect.x, rect.y],\n [x1, rect.y],\n [x1, y1],\n [rect.x, y1],\n ];\n switch (region.kind) {\n case \"rect\":\n return rect.x >= region.x && rect.y >= region.y && x1 <= region.x + region.w && y1 <= region.y + region.h;\n case \"circle\":\n return corners.every(([x, y]) => inEllipse(region.cx, region.cy, region.r, region.r, x, y));\n case \"ellipse\":\n return corners.every(([x, y]) => inEllipse(region.cx, region.cy, region.rx, region.ry, x, y));\n case \"polygon\": {\n const ring = region.points;\n if (ring.length < 3) return false;\n const points = [...corners, [rect.x + rect.w / 2, rect.y + rect.h / 2] as const];\n if (!points.every(([x, y]) => onRing(x, y, ring) || pointInRings(x, y, [ring]))) return false;\n const deep = (x: number, y: number): boolean => x > rect.x + EPS && x < x1 - EPS && y > rect.y + EPS && y < y1 - EPS;\n for (let i = 0; i < ring.length; i++) {\n const a = ring[i]!;\n const b = ring[(i + 1) % ring.length]!;\n const m = clipMid(a[0], a[1], b[0], b[1], rect);\n if (m !== undefined && deep(m[0], m[1])) return false;\n }\n return (region.holes ?? []).every((hole) => !regionHitsRect({ kind: \"polygon\", points: hole }, rect));\n }\n }\n}\n\n/** This function gives the rectangle made smaller by `d` on each side. A side does not become smaller than 0. */\nfunction shrink(r: Rect, d: number): Rect {\n const dx = Math.min(d, r.w / 2);\n const dy = Math.min(d, r.h / 2);\n return { x: r.x + dx, y: r.y + dy, w: r.w - 2 * dx, h: r.h - 2 * dy };\n}\n\n/** This function tells if a point is inside an ellipse or on its border, with an error of `EPS`. */\nfunction inEllipse(cx: number, cy: number, rx: number, ry: number, x: number, y: number): boolean {\n if (rx <= 0 || ry <= 0) return false;\n const u = (x - cx) / rx;\n const v = (y - cy) / ry;\n return u * u + v * v <= 1 + EPS;\n}\n\n/** This function tells if a point is on a ring of a polygon, with an error of `EPS`. */\nfunction onRing(x: number, y: number, ring: readonly (readonly [number, number])[]): boolean {\n for (let i = 0; i < ring.length; i++) {\n const [ax, ay] = ring[i]!;\n const [bx, by] = ring[(i + 1) % ring.length]!;\n const dx = bx - ax;\n const dy = by - ay;\n const len2 = dx * dx + dy * dy;\n const t = len2 === 0 ? 0 : Math.max(0, Math.min(1, ((x - ax) * dx + (y - ay) * dy) / len2));\n if (Math.hypot(x - (ax + t * dx), y - (ay + t * dy)) <= EPS) return true;\n }\n return false;\n}\n\n/** An ellipse with the radii `rx` and `ry` scales to a unit circle. The rectangle scales with it. */\nfunction circleHitsRect(cx: number, cy: number, rx: number, ry: number, rect: Rect): boolean {\n if (rx <= 0 || ry <= 0) return false;\n const x0 = (rect.x - cx) / rx;\n const x1 = (rect.x + rect.w - cx) / rx;\n const y0 = (rect.y - cy) / ry;\n const y1 = (rect.y + rect.h - cy) / ry;\n const dx = Math.max(x0, 0, -x1);\n const dy = Math.max(y0, 0, -y1);\n return dx * dx + dy * dy < 1;\n}\n\n/** This function gives the middle of the part of a segment inside a rectangle, or `undefined` when that part is a point or empty. */\nfunction clipMid(ax: number, ay: number, bx: number, by: number, r: Rect): readonly [number, number] | undefined {\n let t0 = 0;\n let t1 = 1;\n const dx = bx - ax;\n const dy = by - ay;\n const edges: readonly (readonly [number, number])[] = [\n [-dx, ax - r.x],\n [dx, r.x + r.w - ax],\n [-dy, ay - r.y],\n [dy, r.y + r.h - ay],\n ];\n for (const [p, q] of edges) {\n if (p === 0) {\n if (q < 0) return undefined;\n } else if (p < 0) {\n t0 = Math.max(t0, q / p);\n } else {\n t1 = Math.min(t1, q / p);\n }\n }\n if (t1 <= t0) return undefined;\n const t = (t0 + t1) / 2;\n return [ax + t * dx, ay + t * dy];\n}\n\n/** The even-odd rule over the outer ring and the holes. */\nfunction pointInRings(x: number, y: number, rings: readonly (readonly (readonly [number, number])[])[]): boolean {\n let inside = false;\n for (const ring of rings) {\n for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {\n const [xi, yi] = ring[i]!;\n const [xj, yj] = ring[j]!;\n if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) inside = !inside;\n }\n }\n return inside;\n}\n\n/**\n * This function counts the pairs of a placed box and an obstacle that overlap by more than `tolerance`.\n * The box counts with its margin. A box with a shape counts as its bounding box.\n */\nexport function countObstacleHits(\n boxes: readonly LayoutBox[],\n obstacles: readonly Obstacle[] | undefined,\n tolerance: number = DEFAULT_TOLERANCE.overlap,\n): number {\n if (obstacles === undefined || obstacles.length === 0) return 0;\n let count = 0;\n for (const box of boxes) {\n const r0 = placedRect(box);\n if (r0 === undefined) continue;\n const r = grow(r0, box.margin);\n const small = { x: r.x + tolerance, y: r.y + tolerance, w: r.w - 2 * tolerance, h: r.h - 2 * tolerance };\n for (const o of obstacles) if (regionHitsRect(o.region, small)) count++;\n }\n return count;\n}\n\n/**\n * This function gives the count of each hard rule of the output of a packer.\n * It applies the output with `applyPack`. Only the placed boxes and the locked boxes count for the overlaps and the container.\n * `no-overlap` counts the pairs of boxes and the pairs of a box and an obstacle. A pair of `pairGaps` uses its gap in place of the margins. `HARD_RULE_VERSION` tells the version of these counts.\n *\n * A locked box without a placement, or with a move of more than `RECORD_EPS`, breaks `locked-kept`.\n * A locked box without a position in the input is a bad input, not a break. `checkInput` finds it.\n * Another box without a placement that is not in `overflow` breaks `complete`.\n *\n * `options` goes to `countOutside` for `in-container`.\n */\nexport function packHard(input: LayoutInput, output: PackOutput, tolerance: number = DEFAULT_TOLERANCE.overlap, options: ContainerTest = {}): PackHard {\n const after = applyPack(input, output);\n const placed = new Set(output.placements.map((p) => p.id));\n const out = new Set(output.overflow);\n const was = new Map(input.boxes.map((b) => [b.id, b]));\n let lockedMoved = 0;\n let incomplete = 0;\n const kept: LayoutBox[] = [];\n for (const box of after.boxes) {\n const old = was.get(box.id);\n if (old?.locked === true) {\n if (old.x === undefined || old.y === undefined) continue;\n const moved = Math.abs(old.x - (box.x ?? old.x)) > RECORD_EPS || Math.abs(old.y - (box.y ?? old.y)) > RECORD_EPS;\n if (!placed.has(box.id) || moved) lockedMoved++;\n kept.push(box);\n } else if (placed.has(box.id)) {\n kept.push(box);\n } else if (!out.has(box.id)) {\n incomplete++;\n }\n }\n return {\n \"no-overlap\": countOverlaps(kept, tolerance, input.pairGaps) + countObstacleHits(kept, after.obstacles, tolerance),\n \"in-container\": countOutside({ ...after, boxes: kept }, tolerance, options),\n \"locked-kept\": lockedMoved,\n complete: incomplete,\n };\n}\n\n/**\n * This function gives the problems of an input file. An empty list tells that the file is good.\n * A problem is a bad input, not a break of a hard rule. Thus an engine refuses the input.\n * In `pairGaps`, an unknown box, a pair of one box, a repeated pair in either order, a bad `gap` and bad `lanes` are problems.\n * A port with `along` and no `side`, with `x` or `y`, or with a value outside [0, 1] is a problem.\n */\nexport function checkInput(input: LayoutInput): readonly string[] {\n const problems: string[] = [];\n const ids = new Set<string>();\n for (const box of input.boxes) {\n if (ids.has(box.id)) problems.push(`box ${box.id}: the id is not unique`);\n ids.add(box.id);\n if (!(box.w > 0 && box.h > 0 && Number.isFinite(box.w) && Number.isFinite(box.h))) problems.push(`box ${box.id}: the size is not positive and finite`);\n if (box.locked === true && (box.x === undefined || box.y === undefined)) problems.push(`box ${box.id}: a locked box has no position`);\n const shape = shapeKindProblem(box);\n if (shape !== undefined) problems.push(shape);\n for (const port of box.ports ?? []) problems.push(...alongProblems(box.id, port));\n }\n if (countPortsOffBorder(input.boxes) > 0) problems.push(\"a fixed port is not on the border of its box\");\n for (const edge of input.edges ?? []) {\n if (!ids.has(edge.source) || !ids.has(edge.target)) problems.push(`edge ${edge.id}: a box of the edge is not in the input`);\n }\n problems.push(...pairGapProblems(input.pairGaps, ids));\n return problems;\n}\n\n/** This function gives the problems of the `along` of a port: no side, a value outside [0, 1], or `x` or `y` with it. A port without `along` has no problem. */\nfunction alongProblems(boxId: string, port: Port): string[] {\n if (port.along === undefined) return [];\n const at = `box ${boxId} port ${port.id}`;\n const problems: string[] = [];\n if (port.side === undefined) problems.push(`${at}: a port with along has no side`);\n if (typeof port.along !== \"number\" || !Number.isFinite(port.along) || port.along < 0 || port.along > 1)\n problems.push(`${at}: the along value ${String(port.along)} is not a finite number from 0 to 1`);\n if (port.x !== undefined || port.y !== undefined) problems.push(`${at}: a port with along also has x or y`);\n return problems;\n}\n\n/** This function gives the problems of the `pairGaps` of an input. `ids` has the ids of the boxes. */\nfunction pairGapProblems(pairGaps: LayoutInput[\"pairGaps\"], ids: ReadonlySet<string>): string[] {\n if (pairGaps === undefined) return [];\n if (!Array.isArray(pairGaps)) return [\"pairGaps: the value is not a list\"];\n const problems: string[] = [];\n const seen = new Map<string, number>();\n pairGaps.forEach((p: PairGap, i) => {\n const at = `pair gap ${i} (${String(p?.a)}, ${String(p?.b)})`;\n if (typeof p !== \"object\" || p === null || typeof p.a !== \"string\" || typeof p.b !== \"string\") {\n problems.push(`pair gap ${i}: the entry has no string ids a and b`);\n return;\n }\n for (const id of [p.a, p.b]) if (!ids.has(id)) problems.push(`${at}: the box ${id} is not in the input`);\n if (p.a === p.b) problems.push(`${at}: the two ids are the same box`);\n if (typeof p.gap !== \"number\" || !Number.isFinite(p.gap) || p.gap < 0) problems.push(`${at}: the gap ${String(p.gap)} is not a finite number of 0 or more`);\n if (p.lanes !== undefined && (typeof p.lanes !== \"number\" || !Number.isInteger(p.lanes) || p.lanes < 0))\n problems.push(`${at}: the lanes value ${String(p.lanes)} is not a whole number of 0 or more`);\n const key = JSON.stringify(p.a < p.b ? [p.a, p.b] : [p.b, p.a]);\n const first = seen.get(key);\n if (first !== undefined) problems.push(`${at}: the pair is also pair gap ${first}`);\n else seen.set(key, i);\n });\n return problems;\n}\n","import { SHAPE_KIND_IDS, type ShapeBound, type ShapeKind } from \"./shapes.ts\";\nimport { RECORD_EPS, RECORD_SCALE } from \"./tolerance.ts\";\n\n/** The direction of a measure: the side of the better values. */\nexport type Direction = \"lower\" | \"higher\";\n\n/**\n * The facts of one measure: its unit, its direction and its range.\n * `floor` and `tol` are the parameters of the floor rule of the promotion rule (`docs/PROMOTION.md` of `highways`).\n * Each engine exports the specs of its own measures. This package exports the specs of the `joint.*` measures.\n */\nexport interface MeasureSpec<Id extends string = string> {\n readonly id: Id;\n readonly unit: string;\n readonly direction: Direction;\n /** The lowest value. */\n readonly min: number;\n /** The highest value. The value `Infinity` tells that the measure has no upper limit. */\n readonly max: number;\n /** The family of the measure in the measure note of its engine. */\n readonly family?: string;\n /** The best value. Without it, the measure has no floor. */\n readonly floor?: number;\n /** The absolute tolerance at the floor. */\n readonly tol?: number;\n /**\n * The smallest change that counts as better or worse. A number is an absolute change. `{ rel }` is a share of the larger of the two values.\n * `docs/JOINT-MEASURES.md` gives the reason of each joint value.\n */\n readonly minEffect?: number | { readonly rel: number };\n /** The role of the measure in the joint selector. */\n readonly role?: \"guard\" | \"change-guard\" | \"diagnostic\" | \"time\";\n /** The shape kinds of the boxes that the measure supports. Without it, the measure supports only `rect`. `checkShapes` refuses the other kinds. */\n readonly shapes?: readonly ShapeKind[];\n /**\n * The kinds where the value is a bound of the true value, and its side. A kind is in `shapes` or in `bound.shapes`, not in the two lists.\n * `checkShapes` refuses a bound kind by default and with `{ level: \"safe\" }`. With `{ level: \"bound\" }`, it accepts it. `docs/SHAPES.md` tells what a bound value proves for each `direction`.\n */\n readonly bound?: ShapeBound;\n}\n\n/** The id of a joint measure. `docs/JOINT-MEASURES.md` gives the definitions. */\nexport type JointMeasureId =\n | \"joint.fill\"\n | \"joint.aspectError\"\n | \"joint.spill\"\n | \"joint.straight.crossings\"\n | \"joint.straight.length\"\n | \"joint.stability.mean\"\n | \"joint.stability.moved\"\n | \"joint.proxy.rank\"\n | \"joint.route.length\"\n | \"joint.ms\";\n\n/** The shape kinds of a joint measure that reads only the bounding boxes, the centers and the positions of the boxes. */\nconst BOUNDS_ONLY = SHAPE_KIND_IDS;\n/** The shape kinds of a joint measure that reads the area `w` by `h` of each box. */\nconst AREA: readonly ShapeKind[] = [\"rect\"];\n\n/**\n * The specs of the joint measures, in the order of `docs/JOINT-MEASURES.md`.\n * `joint.fill` and `joint.straight.length` read the area of each box, so they support only `rect`. `docs/SHAPES.md` tells the reasons.\n */\nexport const JOINT_MEASURES: readonly MeasureSpec<JointMeasureId>[] = /* @__PURE__ */ Object.freeze([\n { id: \"joint.fill\", minEffect: 0.001, unit: \"0 to 1\", direction: \"higher\", min: 0, max: 1, floor: 1, role: \"guard\", shapes: AREA },\n { id: \"joint.aspectError\", minEffect: 0.01, unit: \"natural log\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0.01, role: \"guard\", shapes: BOUNDS_ONLY },\n { id: \"joint.spill\", minEffect: 0.001, unit: \"0 to 1\", direction: \"lower\", min: 0, max: 1, floor: 0, tol: 0.001, role: \"guard\", shapes: BOUNDS_ONLY },\n { id: \"joint.straight.crossings\", minEffect: 0, unit: \"count\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0, role: \"guard\", shapes: BOUNDS_ONLY },\n { id: \"joint.straight.length\", minEffect: 0.01, unit: \"S for each edge\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0.01, role: \"guard\", shapes: AREA },\n { id: \"joint.stability.mean\", minEffect: 0.005, unit: \"W\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0.005, role: \"change-guard\", shapes: BOUNDS_ONLY },\n { id: \"joint.stability.moved\", minEffect: 0.02, unit: \"0 to 1\", direction: \"lower\", min: 0, max: 1, floor: 0, tol: 0.02, role: \"change-guard\", shapes: BOUNDS_ONLY },\n { id: \"joint.proxy.rank\", unit: \"-1 to 1\", direction: \"higher\", min: -1, max: 1, role: \"diagnostic\", shapes: BOUNDS_ONLY },\n { id: \"joint.route.length\", unit: \"layout units for each route\", direction: \"lower\", min: 0, max: Infinity, role: \"diagnostic\", shapes: BOUNDS_ONLY },\n { id: \"joint.ms\", unit: \"milliseconds\", direction: \"lower\", min: 0, max: Infinity, role: \"time\", shapes: BOUNDS_ONLY },\n] as const);\n\n/** The threshold of `joint.stability.moved`, in widths `W` of the base. */\nexport const JOINT_MOVED_MIN = 0.01;\n\n/** The result of a compare of a candidate with a baseline on one measure. A tie is not better. */\nexport type Verdict = \"better\" | \"worse\" | \"tie\";\n\n/**\n * This function gives the smallest change of a measure that counts between the values `a` and `b`.\n * The value is `max(RECORD_EPS, minEffect)`, or `max(RECORD_EPS, rel * max(|a|, |b|))` for a relative `minEffect`.\n * The larger value makes the threshold the same after a swap of `a` and `b`.\n */\nexport function minEffectOf(spec: Pick<MeasureSpec, \"minEffect\">, a = 0, b = 0): number {\n const m = spec.minEffect ?? 0;\n const t = typeof m === \"number\" ? m : m.rel * Math.max(Math.abs(a), Math.abs(b));\n return Math.max(RECORD_EPS, Number.isFinite(t) ? t : 0);\n}\n\n/** The slack of the threshold in grid steps. It absorbs only the float noise of the threshold, because the change is a whole number. */\nconst STEP_NOISE = 1e-6;\n\n/**\n * This function compares the value `candidate` with the value `baseline` of one measure on one input.\n * The compare uses whole grid steps of `RECORD_EPS`. Thus a live value and its rounded record give the same verdict.\n * A change of at most the threshold of `minEffectOf` in grid steps is a tie. A swap of the two values swaps better and worse.\n * Two equal values are a tie, also two infinite values. A value `NaN` is an error.\n */\nexport function compareMeasure(candidate: number, baseline: number, spec: Pick<MeasureSpec, \"direction\" | \"minEffect\">): Verdict {\n if (Number.isNaN(candidate) || Number.isNaN(baseline)) throw new RangeError(\"compareMeasure: a value is NaN\");\n if (candidate === baseline) return \"tie\";\n const a = Math.round(candidate * RECORD_SCALE);\n const b = Math.round(baseline * RECORD_SCALE);\n let delta: number;\n if (Number.isSafeInteger(a) && Number.isSafeInteger(b)) {\n delta = a - b;\n const m = spec.minEffect ?? 0;\n const t = typeof m === \"number\" ? m * RECORD_SCALE : m.rel * Math.max(Math.abs(a), Math.abs(b));\n if (Math.abs(delta) <= Math.max(1, Number.isFinite(t) ? t : 0) + STEP_NOISE) return \"tie\";\n } else {\n delta = candidate - baseline;\n if (!(Math.abs(delta) > minEffectOf(spec, candidate, baseline))) return \"tie\";\n }\n const better = spec.direction === \"lower\" ? delta < 0 : delta > 0;\n return better ? \"better\" : \"worse\";\n}\n","import { SIDES, type Rect, type Side } from \"./geometry.ts\";\nimport type { MeasureSpec } from \"./measures.ts\";\nimport { SHAPE_KIND_IDS, type ShapeKind } from \"./shapes.ts\";\n\n/** A placed box: its id and its bounding box. */\nexport interface PlacedBox extends Rect {\n readonly id: string;\n}\n\n/** The balance of one layout. `docs/BALANCE.md` gives the definitions. */\nexport interface Balance {\n /** The standard deviation of the nearest-neighbour gaps divided by their mean. */\n readonly gapCv: number;\n /** The distance from the centroid of the free area to the center of the container, as a share of the half-diagonal. */\n readonly centroidOffset: number;\n /** The empty share of the strip at each side of the container. */\n readonly side: Readonly<Record<Side, number>>;\n /** The largest value of `side` minus the smallest value. */\n readonly sideRange: number;\n}\n\n/** The depth of the strip of each side, as a share of the container. For `top` and `bottom`, it is a share of the height. For `left` and `right`, it is a share of the width. */\nexport const BALANCE_SIDE_DEPTH = 0.25;\n\n/** A suffix of a balance or stability measure. A stage adds its prefix, for example `pack.balance.gapCv`. */\nexport type BalanceMeasureSuffix =\n | \"balance.gapCv\"\n | \"balance.centroidOffset\"\n | \"balance.side.top\"\n | \"balance.side.right\"\n | \"balance.side.bottom\"\n | \"balance.side.left\"\n | \"balance.sideRange\"\n | \"stability.procrustes\"\n | \"stability.seed\";\n\n/** The suffixes of the balance and stability measures, in the order of `docs/BALANCE.md`. */\nexport const BALANCE_MEASURE_SUFFIXES: readonly BalanceMeasureSuffix[] = /* @__PURE__ */ Object.freeze([\n \"balance.gapCv\",\n \"balance.centroidOffset\",\n \"balance.side.top\",\n \"balance.side.right\",\n \"balance.side.bottom\",\n \"balance.side.left\",\n \"balance.sideRange\",\n \"stability.procrustes\",\n \"stability.seed\",\n] as const);\n\n/** This function gives the area of the overlap of two rectangles. */\nfunction overlapArea(a: Rect, b: Rect): number {\n const w = Math.min(a.x + a.w, b.x + b.w) - Math.max(a.x, b.x);\n const h = Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y);\n return w > 0 && h > 0 ? w * h : 0;\n}\n\n/** This function gives the distance between two rectangles. Two rectangles that touch or overlap give 0. */\nfunction rectDistance(a: Rect, b: Rect): number {\n const dx = Math.max(0, b.x - (a.x + a.w), a.x - (b.x + b.w));\n const dy = Math.max(0, b.y - (a.y + a.h), a.y - (b.y + b.h));\n return Math.hypot(dx, dy);\n}\n\n/**\n * This function gives the gap of each box to its nearest other box, in the order of `boxes`.\n * Each box scans the boxes sorted by `x` in the two directions. A scan stops when the distance on `x` alone is above the best gap of the box.\n * To the left, the distance on `x` is at least `a.x - b.x - maxW`, with `maxW` the largest width. With fewer than 2 boxes, a gap is `Infinity`.\n */\nexport function nearestGaps(boxes: readonly Rect[]): number[] {\n const order = boxes.map((_, i) => i).sort((i, j) => boxes[i]!.x - boxes[j]!.x || i - j);\n const maxW = boxes.reduce((m, b) => Math.max(m, b.w), 0);\n const gaps = new Array<number>(boxes.length).fill(Infinity);\n for (let k = 0; k < order.length; k++) {\n const a = boxes[order[k]!]!;\n let best = Infinity;\n for (let m = k + 1; m < order.length; m++) {\n const b = boxes[order[m]!]!;\n if (b.x - (a.x + a.w) > best) break;\n best = Math.min(best, rectDistance(a, b));\n }\n for (let m = k - 1; m >= 0; m--) {\n const b = boxes[order[m]!]!;\n if (a.x - b.x - maxW > best) break;\n best = Math.min(best, rectDistance(a, b));\n }\n gaps[order[k]!] = best;\n }\n return gaps;\n}\n\n/**\n * This function gives the balance of the placed boxes in the container: the evenness of the gaps and the place of the free space.\n * The boxes do not overlap, as in the output of a packer. The area of a box outside the container does not count.\n * `docs/BALANCE.md` gives the definitions and the reasons.\n */\nexport function balanceOf(boxes: readonly Rect[], container: Rect): Balance {\n const gaps = boxes.length < 2 ? [] : nearestGaps(boxes);\n const mean = gaps.length === 0 ? 0 : gaps.reduce((s, g) => s + g, 0) / gaps.length;\n const sd = gaps.length === 0 ? 0 : Math.sqrt(gaps.reduce((s, g) => s + (g - mean) ** 2, 0) / gaps.length);\n const gapCv = mean > 0 ? sd / mean : 0;\n\n const area = container.w * container.h;\n const cx = container.x + container.w / 2;\n const cy = container.y + container.h / 2;\n let used = 0;\n let mx = 0;\n let my = 0;\n for (const b of boxes) {\n const x0 = Math.max(b.x, container.x);\n const y0 = Math.max(b.y, container.y);\n const x1 = Math.min(b.x + b.w, container.x + container.w);\n const y1 = Math.min(b.y + b.h, container.y + container.h);\n if (x1 <= x0 || y1 <= y0) continue;\n const a = (x1 - x0) * (y1 - y0);\n used += a;\n mx += a * (x0 + x1) / 2;\n my += a * (y0 + y1) / 2;\n }\n const free = area - used;\n const half = Math.hypot(container.w, container.h) / 2;\n let centroidOffset = 0;\n if (free > 0 && half > 0) {\n const fx = (area * cx - mx) / free;\n const fy = (area * cy - my) / free;\n centroidOffset = Math.min(1, Math.hypot(fx - cx, fy - cy) / half);\n }\n\n const dh = container.h * BALANCE_SIDE_DEPTH;\n const dw = container.w * BALANCE_SIDE_DEPTH;\n const strips: Record<Side, Rect> = {\n top: { x: container.x, y: container.y, w: container.w, h: dh },\n right: { x: container.x + container.w - dw, y: container.y, w: dw, h: container.h },\n bottom: { x: container.x, y: container.y + container.h - dh, w: container.w, h: dh },\n left: { x: container.x, y: container.y, w: dw, h: container.h },\n };\n const side = {} as Record<Side, number>;\n for (const s of SIDES) {\n const strip = strips[s];\n const stripArea = strip.w * strip.h;\n const filled = boxes.reduce((sum, b) => sum + overlapArea(b, strip), 0);\n side[s] = stripArea > 0 ? Math.min(1, Math.max(0, 1 - filled / stripArea)) : 0;\n }\n const values = SIDES.map((s) => side[s]);\n return { gapCv, centroidOffset, side, sideRange: Math.max(...values) - Math.min(...values) };\n}\n\n/** The options of `procrustesOf`. */\nexport interface ProcrustesOptions {\n /** The unit of the result: the width `W` of the base, as in `joint.stability.mean`. A finite number above 0. */\n readonly unit: number;\n /** With `true` (the default), the alignment also rotates. With `false`, it only moves. */\n readonly rotate?: boolean;\n}\n\n/**\n * This function gives the root mean square move of the box centers from `base` to `next`, after the best alignment, in units of `unit`.\n * The alignment is the orthogonal Procrustes fit: one move and, by default, one rotation. Only the ids in the two lists count.\n * Fewer than 2 shared ids give 0, because the alignment then removes each move.\n */\nexport function procrustesOf(base: readonly PlacedBox[], next: readonly PlacedBox[], options: ProcrustesOptions): number {\n if (!(Number.isFinite(options.unit) && options.unit > 0)) throw new RangeError(`procrustesOf: the unit is a finite number above 0, not ${options.unit}.`);\n const after = new Map(next.map((b) => [b.id, b]));\n const a: [number, number][] = [];\n const b: [number, number][] = [];\n for (const p of base) {\n const q = after.get(p.id);\n if (q === undefined) continue;\n a.push([p.x + p.w / 2, p.y + p.h / 2]);\n b.push([q.x + q.w / 2, q.y + q.h / 2]);\n }\n const n = a.length;\n if (n < 2) return 0;\n const mean = (list: [number, number][]): [number, number] => [list.reduce((s, p) => s + p[0], 0) / n, list.reduce((s, p) => s + p[1], 0) / n];\n const [ax, ay] = mean(a);\n const [bx, by] = mean(b);\n let dot = 0;\n let cross = 0;\n for (let i = 0; i < n; i++) {\n const [px, py] = [a[i]![0] - ax, a[i]![1] - ay];\n const [qx, qy] = [b[i]![0] - bx, b[i]![1] - by];\n dot += px * qx + py * qy;\n cross += px * qy - py * qx;\n }\n const theta = options.rotate === false || (dot === 0 && cross === 0) ? 0 : Math.atan2(cross, dot);\n const cos = Math.cos(theta);\n const sin = Math.sin(theta);\n let sum = 0;\n for (let i = 0; i < n; i++) {\n const [px, py] = [a[i]![0] - ax, a[i]![1] - ay];\n const [qx, qy] = [b[i]![0] - bx, b[i]![1] - by];\n sum += (cos * px - sin * py - qx) ** 2 + (sin * px + cos * py - qy) ** 2;\n }\n return Math.sqrt(sum / n) / options.unit;\n}\n\n/**\n * This function gives the value of `stability.procrustes`: the move of `procrustesOf` divided by the change share.\n * The change share is `changed / count`, and it is at least `1 / count`. Thus a change of one box divides by the smallest share.\n */\nexport function perChange(move: number, changed: number, count: number): number {\n if (!(Number.isInteger(count) && count >= 1)) throw new RangeError(`perChange: the count is an integer of 1 or more, not ${count}.`);\n const share = Math.max(1, Math.min(count, changed)) / count;\n return move / share;\n}\n\n/** This function gives the balance values as measures, with the prefix of the stage, for example `pack.balance.gapCv`. */\nexport function balanceMeasures<S extends string>(stage: S, balance: Balance): Record<`${S}.${BalanceMeasureSuffix}`, number> {\n const m: Record<string, number> = {\n [`${stage}.balance.gapCv`]: balance.gapCv,\n [`${stage}.balance.centroidOffset`]: balance.centroidOffset,\n [`${stage}.balance.sideRange`]: balance.sideRange,\n };\n for (const s of SIDES) m[`${stage}.balance.side.${s}`] = balance.side[s];\n return m as Record<`${S}.${BalanceMeasureSuffix}`, number>;\n}\n\n/**\n * This function gives the specs of the balance and stability measures, with the prefix of the stage.\n * The balance measures read the area of each box, so they support only `rect`. The stability measures read only the centers.\n */\nexport function balanceMeasureSpecs<S extends string>(stage: S): readonly MeasureSpec<`${S}.${BalanceMeasureSuffix}`>[] {\n const id = (suffix: BalanceMeasureSuffix): `${S}.${BalanceMeasureSuffix}` => `${stage}.${suffix}`;\n const rect: readonly ShapeKind[] = [\"rect\"];\n const centers = SHAPE_KIND_IDS;\n return Object.freeze([\n { id: id(\"balance.gapCv\"), unit: \"ratio\", direction: \"lower\", min: 0, max: Infinity, minEffect: 0.01, family: \"balance\", shapes: rect },\n { id: id(\"balance.centroidOffset\"), unit: \"0 to 1\", direction: \"lower\", min: 0, max: 1, minEffect: 0.01, family: \"balance\", shapes: rect },\n ...SIDES.map((s) => ({ id: id(`balance.side.${s}`), unit: \"0 to 1\", direction: \"lower\" as const, min: 0, max: 1, family: \"balance\", role: \"diagnostic\" as const, shapes: rect })),\n { id: id(\"balance.sideRange\"), unit: \"0 to 1\", direction: \"lower\", min: 0, max: 1, minEffect: 0.02, family: \"balance\", shapes: rect },\n { id: id(\"stability.procrustes\"), unit: \"W for each change share\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0.005, minEffect: 0.005, family: \"stability\", role: \"change-guard\", shapes: centers },\n { id: id(\"stability.seed\"), unit: \"W\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0.005, minEffect: 0.005, family: \"stability\", shapes: centers },\n ]);\n}\n","import { fnv1a32 as homeFnv1a32, mulberry32 as homeMulberry32 } from \"@mark1russell7/rigor-generators\";\n\n/**\n * This function gives a generator of random numbers in [0, 1). It is `mulberry32`, as in `docs/FORMAT.md` of `packing`.\n * Its home is `@mark1russell7/rigor-generators`. This function keeps the name and the signature of the API.\n */\nexport function mulberry32(seed: number): () => number {\n return homeMulberry32(seed);\n}\n\n/**\n * This function gives the FNV-1a hash of 32 bits of the UTF-8 bytes of a string. A lone surrogate gives the 3 bytes of its code.\n * Its home is `fnv1a32` of `@mark1russell7/rigor-generators`, with the option `input: \"wtf8\"`. This function keeps the name and the signature of the API.\n */\nexport function fnv1a32(text: string): number {\n return homeFnv1a32(text, { input: \"wtf8\" });\n}\n\n/** This function gives the generator of one step of a seeded generator: `mulberry32(fnv1a32(\"<seed>:<step>\"))`. */\nexport function stepRandom(seed: number, step: string): () => number {\n return mulberry32(fnv1a32(`${seed}:${step}`));\n}\n\n/** This function gives a whole number from `lo` to `hi`, both included. */\nexport function randomInt(r: () => number, lo: number, hi: number): number {\n return lo + Math.floor(r() * (hi - lo + 1));\n}\n","import { SIDES, type Side } from \"./geometry.ts\";\nimport type { LayoutBox, LayoutEdge, LayoutGenerator, LayoutInput, Port } from \"./input.ts\";\nimport { randomInt, stepRandom } from \"./random.ts\";\n\n/**\n * The shape of the edges of `edgeStep`. The values are the cells of `edgeShape`, and `hubs`.\n * `hubs` waits for the next breaking change to become a value of `LayoutCell.edgeShape`.\n */\nexport type EdgeShape = \"random\" | \"clustered\" | \"hubChain\" | \"hubs\" | \"longRange\" | \"tree\" | \"bundled\";\n\n/** The parameters of `edgeStep`. */\nexport interface EdgeStepParams {\n readonly edgeDensity: \"sparse\" | \"medium\" | \"dense\";\n readonly edgeShape: EdgeShape;\n /** The default is `none`. */\n readonly groups?: \"none\" | \"flat\" | \"nested\";\n /** The default is `free`. */\n readonly ports?: \"free\" | \"sides\" | \"fixed\";\n /** The order of the hubs of `hubs` and `tree`: the largest box first, or a random order. The default is `area`. */\n readonly hubBy?: \"area\" | \"random\";\n}\n\n/**\n * The key of the edges of an input, in `data.collection`.\n * - `none`: the field is absent, so a router with the rule `collection` has no ways.\n * - `random`: a random name for each target box, so the key has no meaning.\n * - `cluster`: a name for each cluster of boxes, so the key follows the structure.\n */\nexport type EdgeKey = \"none\" | \"random\" | \"cluster\";\n\n/** The parameters of `edgeKeyStep`. */\nexport interface EdgeKeyParams {\n readonly edgeKey: EdgeKey;\n}\n\n/** The mean count of the edges of each box for each value of `edgeDensity`. */\nexport const EDGE_DENSITY: Readonly<Record<EdgeStepParams[\"edgeDensity\"], number>> = /* @__PURE__ */ Object.freeze({ sparse: 0.5, medium: 1.5, dense: 4 });\n\n/** The version of `edgeStep`. A change of its output gives a new version. */\nexport const EDGE_STEP_VERSION = 1;\n\n/** The version of `edgeKeyStep`. A change of its output gives a new version. */\nexport const EDGE_KEY_STEP_VERSION = 1;\n\nconst CLUSTER = 8;\nconst CHAIN = 32;\nconst INSIDE = 0.85;\nconst FAN_SHARE = 0.6;\nconst FIXED_SHARE = 0.2;\nconst COLLECTIONS = [\"users\", \"orders\", \"items\", \"events\"] as const;\n\nconst round3 = (x: number): number => Math.round(x * 1000) / 1000;\n\n/** This function gives the shuffled order of `n` boxes, from the first numbers of the stream `edges`. */\nfunction shuffledBoxes(n: number, r: () => number): number[] {\n const perm = Array.from({ length: n }, (_, i) => i);\n for (let i = n - 1; i > 0; i--) {\n const j = randomInt(r, 0, i);\n [perm[i], perm[j]] = [perm[j]!, perm[i]!];\n }\n return perm;\n}\n\n/** This function gives the cluster of each box from the shuffled order: each cluster has `CLUSTER` boxes. */\nfunction clustersOf(perm: readonly number[]): number[] {\n const clusterOf: number[] = new Array<number>(perm.length);\n perm.forEach((box, p) => (clusterOf[box] = Math.floor(p / CLUSTER)));\n return clusterOf;\n}\n\n/** This function gives the key of the boxes of one cluster. */\nconst clusterKey = (c: number): string => `${COLLECTIONS[c % COLLECTIONS.length]!}-${c}`;\n\n/**\n * This function gives the input with edges, groups and ports from its topology alone: a joint input has no positions before the pack.\n * The random numbers come from the steps `edges` and `ports` of `seed`. The function appends its stamp to `steps`, and removes the old `hash`.\n * The rules of each shape are in `docs/JOINT-CORPUS.md`.\n */\nexport function edgeStep(input: LayoutInput, params: EdgeStepParams, seed: number = input.seed ?? 0): LayoutInput {\n if ((input.edges?.length ?? 0) > 0) throw new RangeError(\"edgeStep: the input has edges already\");\n const full: Required<EdgeStepParams> = { groups: \"none\", ports: \"free\", hubBy: \"area\", ...params };\n const n = input.boxes.length;\n const r = stepRandom(seed, \"edges\");\n\n const perm = shuffledBoxes(n, r);\n const clusterOf = clustersOf(perm);\n const clusters = Math.ceil(n / CLUSTER);\n const members = (c: number): readonly number[] => perm.slice(c * CLUSTER, (c + 1) * CLUSTER);\n const collectionOf =\n full.edgeShape === \"bundled\"\n ? clusterOf.map(clusterKey)\n : input.boxes.map(() => COLLECTIONS[randomInt(r, 0, COLLECTIONS.length - 1)]!);\n const area = (i: number): number => input.boxes[i]!.w * input.boxes[i]!.h;\n const rank = full.hubBy === \"area\" ? input.boxes.map((_, i) => i).sort((a, b) => area(b) - area(a) || a - b) : perm;\n\n const pairs: [number, number][] = [];\n const seen = new Set<string>();\n const add = (u: number, v: number): void => {\n const key = u < v ? `${u}-${v}` : `${v}-${u}`;\n if (u === v || seen.has(key)) return;\n seen.add(key);\n pairs.push([u, v]);\n };\n const anyBox = (): number => randomInt(r, 0, n - 1);\n const inCluster = (c: number): number => {\n const m = members(c);\n return m[randomInt(r, 0, m.length - 1)]!;\n };\n const otherCluster = (c: number): number => {\n const o = randomInt(r, 0, clusters - 2);\n return o >= c ? o + 1 : o;\n };\n const target = Math.min(Math.round(n * EDGE_DENSITY[full.edgeDensity]), (n * (n - 1)) / 2);\n const fill = (pick: () => [number, number]): void => {\n for (let tries = 0; pairs.length < target && tries < target * 30; tries++) add(...pick());\n };\n const clustered = (): [number, number] => {\n const u = anyBox();\n return [u, r() < INSIDE ? inCluster(clusterOf[u]!) : anyBox()];\n };\n\n if (n >= 2) {\n switch (full.edgeShape) {\n case \"random\":\n fill(() => [anyBox(), anyBox()]);\n break;\n case \"clustered\":\n fill(clustered);\n break;\n case \"longRange\":\n fill(() => {\n const u = anyBox();\n return [u, clusters > 1 ? inCluster(otherCluster(clusterOf[u]!)) : anyBox()];\n });\n break;\n case \"hubs\":\n fill(() => [anyBox(), rank[Math.floor(n * r() ** 3)]!]);\n break;\n case \"tree\":\n for (let i = 1; i < n; i++) add(rank[randomInt(r, 0, i - 1)]!, rank[i]!);\n break;\n case \"hubChain\": {\n const k = Math.ceil(n / CHAIN);\n const length = Math.ceil(n / k);\n const chains = Array.from({ length: k }, (_, c) => perm.slice(c * length, (c + 1) * length));\n for (const chain of chains) for (let i = 0; i + 1 < chain.length; i++) add(chain[i]!, chain[i + 1]!);\n const skips = Math.max(0, target - pairs.length);\n for (let s = 0; s < skips; s++) {\n const c = k > 1 ? randomInt(r, 0, k - 2) : 0;\n const from = chains[c]!;\n const to = chains[k > 1 ? c + 1 : 0]!;\n const i = randomInt(r, 0, from.length - 1);\n const j = i + Math.floor(from.length / 8) + randomInt(r, 0, Math.floor(from.length / 2));\n if (j < to.length) add(from[i]!, to[j]!);\n }\n break;\n }\n case \"bundled\":\n for (let rounds = 0; pairs.length < target * FAN_SHARE && clusters > 1 && rounds < target; rounds++) {\n const u = anyBox();\n const c = otherCluster(clusterOf[u]!);\n const fan = randomInt(r, 4, 15);\n for (let f = 0; f < fan && pairs.length < target; f++) add(u, inCluster(c));\n }\n fill(clustered);\n break;\n }\n }\n\n const rp = stepRandom(seed, \"ports\");\n const ports: Port[][] = input.boxes.map((b) => [...(b.ports ?? [])]);\n const portOn = (box: LayoutBox, id: string, side: Side, fixed: boolean): Port => {\n if (!fixed) return { id, side };\n const along = round3(rp() * (side === \"top\" || side === \"bottom\" ? box.w : box.h));\n const at = { top: [along, 0], bottom: [along, box.h], left: [0, along], right: [box.w, along] }[side];\n return { id, side, x: at[0]!, y: at[1]! };\n };\n const out = new Set<number>();\n if (full.ports === \"fixed\") {\n input.boxes.forEach((box, i) => {\n if (rp() >= FIXED_SHARE) return;\n const side = SIDES[randomInt(rp, 0, 3)]!;\n ports[i]!.push(portOn(box, \"out\", side, true));\n out.add(i);\n });\n }\n const edges: LayoutEdge[] = pairs.map(([u, v], k) => {\n const id = `e${k}`;\n const s = input.boxes[u]!;\n const t = input.boxes[v]!;\n let ends: { sourcePort?: string; targetPort?: string } = {};\n if (full.ports === \"sides\") {\n ports[u]!.push(portOn(s, `${id}.s`, SIDES[randomInt(rp, 0, 3)]!, false));\n ports[v]!.push(portOn(t, `${id}.t`, SIDES[randomInt(rp, 0, 3)]!, false));\n ends = { sourcePort: `${id}.s`, targetPort: `${id}.t` };\n } else if (out.has(u)) {\n ends = { sourcePort: \"out\" };\n }\n return { id, source: s.id, target: t.id, ...ends, data: { collection: collectionOf[v]! } };\n });\n\n const boxes = input.boxes.map((box, i): LayoutBox => {\n const c = clusterOf[i]!;\n const group = full.groups === \"none\" ? undefined : `g${c}`;\n const path = full.groups === \"nested\" ? `G${Math.floor(c / 4)}/g${c}` : group;\n return {\n ...box,\n ...(group === undefined ? {} : { group, data: { ...box.data, group: path } }),\n ...(ports[i]!.length === 0 ? {} : { ports: ports[i]! }),\n };\n });\n const stamp: LayoutGenerator = { name: \"edges\", version: EDGE_STEP_VERSION, params: { ...full }, seed };\n const { hash: _old, ...rest } = input;\n return { ...rest, boxes, edges, steps: [...(input.steps ?? []), stamp] };\n}\n\n/**\n * This function gives the input with a stated key on each edge. The edges stay the same in all but `data.collection`, so the 3 values of `edgeKey` read one factor.\n * The key of an edge depends on its target box, as in `edgeStep`.\n * The value `cluster` uses the clusters of `edgeStep` with the same seed and box order, so this step comes directly after `edgeStep`. On the shape `bundled` it gives the keys of `edgeStep`.\n * The value `random` uses the stream `edge-key`, so it does not change the numbers of `edgeStep`. The function appends its stamp to `steps`, and removes the old `hash`.\n * It throws a `RangeError` for an edge with an unknown target.\n */\nexport function edgeKeyStep(input: LayoutInput, params: EdgeKeyParams, seed: number = input.seed ?? 0): LayoutInput {\n const n = input.boxes.length;\n const keys = (): readonly string[] => {\n if (params.edgeKey === \"cluster\") return clustersOf(shuffledBoxes(n, stepRandom(seed, \"edges\"))).map(clusterKey);\n const r = stepRandom(seed, \"edge-key\");\n return input.boxes.map(() => COLLECTIONS[randomInt(r, 0, COLLECTIONS.length - 1)]!);\n };\n const keyOf = params.edgeKey === \"none\" ? [] : keys();\n const indexOf = new Map(input.boxes.map((box, i) => [box.id, i]));\n const edges = input.edges?.map((edge): LayoutEdge => {\n const { data: oldData, ...plain } = edge;\n const { collection: _old, ...data } = oldData ?? {};\n if (params.edgeKey === \"none\") return Object.keys(data).length === 0 ? plain : { ...plain, data };\n const target = indexOf.get(edge.target);\n if (target === undefined) throw new RangeError(`edgeKeyStep: the edge \"${edge.id}\" has the unknown target \"${edge.target}\".`);\n return { ...plain, data: { ...data, collection: keyOf[target]! } };\n });\n const stamp: LayoutGenerator = { name: \"edge-key\", version: EDGE_KEY_STEP_VERSION, params: { edgeKey: params.edgeKey }, seed };\n const { hash: _oldHash, edges: _oldEdges, ...rest } = input;\n return { ...rest, ...(edges === undefined ? {} : { edges }), steps: [...(input.steps ?? []), stamp] };\n}\n","import { canonicalJson as homeCanonicalJson, sha256Hex as homeSha256Hex } from \"@mark1russell7/rigor-generators\";\nimport { canonicalInput, type LayoutInput } from \"./input.ts\";\nimport type { PackOutput } from \"./output.ts\";\nimport { RECORD_EPS } from \"./tolerance.ts\";\n\n/**\n * This function gives the SHA-256 digest of the bytes of a string, as 64 lowercase hex characters. A lone surrogate gives the 3 bytes of its code.\n * Its home is `sha256Hex` of `@mark1russell7/rigor-generators`, with the option `input: \"wtf8\"`. This function keeps the name and the signature of the API.\n */\nexport function sha256Hex(text: string): string {\n return homeSha256Hex(text, { input: \"wtf8\" });\n}\n\n/**\n * This function gives the canonical form of a value: sorted keys and no whitespace, with the numbers of `JSON.stringify`.\n * A key with the value `undefined` is not in the form. An `undefined` in an array becomes `null`.\n * Its home is `canonicalJson` of `@mark1russell7/rigor-generators`, with the option `form: \"json\"`.\n * So a value with a method `toJSON`, for example a `Date`, gives the form of the result of that method. A function, a symbol and a cycle cause a `TypeError`.\n */\nexport function canonicalJson(value: unknown): string {\n return homeCanonicalJson(value, { form: \"json\" });\n}\n\n/** The options of `outputHash` and `documentHash`. */\nexport interface HashOptions {\n /**\n * The step of the grid of the numbers. The default is `RECORD_EPS`, so a number keeps 3 decimals.\n * The value `0` keeps the exact numbers. A negative value or a value that is not finite causes a `RangeError`.\n */\n readonly grid?: number;\n /**\n * The names of the fields that the hash does not read, at each depth. Use it for report fields, for example a trace or a time.\n * A field with one of these names is out of the form in each object of the value, also in an object in a list.\n */\n readonly skip?: readonly string[];\n}\n\n/** This function gives the factor of a grid: `1 / grid`, or `undefined` for the exact numbers. */\nfunction gridFactor(options: HashOptions): number | undefined {\n const grid = options.grid ?? RECORD_EPS;\n if (!Number.isFinite(grid) || grid < 0) throw new RangeError(`The grid ${grid} is not a finite number of 0 or more.`);\n return grid === 0 ? undefined : 1 / grid;\n}\n\n/**\n * This function gives a copy of a value with each number on the grid. The value `-0` becomes `0`.\n * It throws a `RangeError` for a number that is not finite.\n */\nfunction onGrid(value: unknown, path: string, k: number | undefined, skip: ReadonlySet<string>): unknown {\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) throw new RangeError(`The value has the number ${value} at ${path}. JSON has no form for it.`);\n if (k === undefined) return value;\n const r = Math.round(value * k) / k;\n if (!Number.isFinite(r)) throw new RangeError(`The number at ${path} is too large for the grid.`);\n return r === 0 ? 0 : r;\n }\n if (value === null || typeof value !== \"object\") return value;\n if (Array.isArray(value)) return value.map((v: unknown, i) => onGrid(v, `${path}[${i}]`, k, skip));\n const o = value as Record<string, unknown>;\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(o)) if (!skip.has(key)) out[key] = onGrid(o[key], `${path}.${key}`, k, skip);\n return out;\n}\n\n/**\n * This function gives the hash of an output: the first 16 hex characters of the SHA-256 of its canonical form.\n * Before the canonical form, each number goes to the nearest point of the grid, and `-0` becomes `0`.\n * With the default grid, the rounding is `round3` of `packing`: `Math.round(x * 1000) / 1000`.\n * The function throws a `RangeError` for `NaN` and for an infinite number. The fields of `options.skip` are out of the form.\n *\n * The grid can split two outputs. Two numbers near a rounding boundary can go to two different points.\n * The grid can also merge two outputs whose numbers go to the same points. This merge is intentional: it removes the noise of floating-point numbers.\n */\nexport function outputHash(value: unknown, options: HashOptions = {}): string {\n return sha256Hex(canonicalJson(onGrid(value, \"$\", gridFactor(options), new Set(options.skip ?? [])))).slice(0, 16);\n}\n\n/** This function throws a `RangeError` when a list of the output has an id two times. A packer with this output has a bug. */\nfunction uniqueIds(list: string, ids: readonly string[]): void {\n const seen = new Set<string>();\n for (const id of ids) {\n if (seen.has(id)) throw new RangeError(`The list ${list} of the output has the id \"${id}\" two times.`);\n seen.add(id);\n }\n}\n\n/** The order of two ids by their UTF-16 code units. It does not change with the locale. */\nfunction byId(a: { readonly id: string }, b: { readonly id: string }): number {\n return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;\n}\n\n/**\n * This function gives the normal form of the output of a packer, for a fingerprint.\n * The form has the placements, the overflow, the size and the moved obstacles. It does not have the trace.\n * The placements, the moved obstacles and the overflow are in the order of their ids. A placement without `turn` gets `turn: 0`.\n * Thus two packers with the same result in a different order have the same form.\n * The function throws a `RangeError` when `placements`, `overflow` or `moved` has an id two times.\n */\nexport function packOutputForm(output: PackOutput): unknown {\n uniqueIds(\"placements\", output.placements.map((p) => p.id));\n uniqueIds(\"overflow\", output.overflow);\n uniqueIds(\"moved\", output.moved.map((m) => m.id));\n return {\n placements: output.placements.map((p) => ({ id: p.id, x: p.x, y: p.y, turn: p.turn ?? 0 })).sort(byId),\n overflow: [...output.overflow].sort(),\n size: { w: output.size.w, h: output.size.h },\n moved: output.moved.map((m) => ({ id: m.id, x: m.x, y: m.y })).sort(byId),\n };\n}\n\n/** The hash of a probe that the strategy refused or does not support. It has no reason text, so a new text of a refusal does not change a fingerprint. */\nexport const REFUSED_PROBE = \"refused\";\n\n/**\n * This function gives the hash of one probe of a strategy. It calls `run` and gives `outputHash` of its result, with exact numbers by default.\n * When `run` throws an error that `refused` accepts, the function gives `REFUSED_PROBE`. It throws each other error again.\n * The option `grid` of `options` puts the numbers on a grid. Its default here is `0`, so a change in a number changes the hash.\n */\nexport function probeHash(run: () => unknown, refused: (error: unknown) => boolean, options: HashOptions = {}): string {\n let value: unknown;\n try {\n value = run();\n } catch (error) {\n if (refused(error)) return REFUSED_PROBE;\n throw error;\n }\n return outputHash(value, { ...options, grid: options.grid ?? 0 });\n}\n\n/**\n * This function gives the fingerprint of the outputs of one strategy: one hash of the hashes of its probes.\n * The key of `hashes` is the id of a probe, and its value is the hash of the probe, from `probeHash`.\n * The order of the keys does not change the fingerprint. A new probe, a probe less or a changed hash changes it.\n * The function throws a `RangeError` when there is no probe.\n */\nexport function fingerprintOf(hashes: Readonly<Record<string, string>>): string {\n if (Object.keys(hashes).length === 0) throw new RangeError(\"A fingerprint needs one probe or more.\");\n return sha256Hex(canonicalJson(hashes)).slice(0, 16);\n}\n\n/**\n * This function gives the hash of a document. It uses the rule of `outputHash`, but the form does not include the field `hash` of the document.\n * With the default grid, it is the input hash of `docs/FORMAT.md` of `packing`.\n * A document with the schema `layout-input/1` goes through `canonicalInput` first. Thus the order of its `pairGaps` does not change the hash.\n */\nexport function documentHash(doc: object, options: HashOptions = {}): string {\n const { hash: _hash, ...rest } = doc as { readonly hash?: unknown; readonly schema?: unknown };\n return outputHash(rest.schema === \"layout-input/1\" ? canonicalInput(rest as unknown as LayoutInput) : rest, options);\n}\n\n/** One output group: the candidates with the same output hash on each decision input. */\nexport interface OutputGroup {\n /** The id of the group: its first member. */\n readonly id: string;\n /** The ids of the candidates of the group, in sorted order. */\n readonly members: readonly string[];\n}\n\n/**\n * This function gives the output groups of the candidates. The key of `hashes` is the id of a candidate.\n * Its value is the list of the output hashes of the candidate, in the order of the decision inputs.\n * Candidates with equal lists make one group. The groups are in the order of their ids.\n * The function throws a `RangeError` when two lists have different lengths.\n */\nexport function outputGroups(hashes: Readonly<Record<string, readonly string[]>>): OutputGroup[] {\n const byList = new Map<string, string[]>();\n let first: string | undefined;\n for (const id of Object.keys(hashes)) {\n const list = hashes[id]!;\n if (first === undefined) first = id;\n else if (list.length !== hashes[first]!.length)\n throw new RangeError(`The candidate \"${id}\" has ${list.length} hashes, but \"${first}\" has ${hashes[first]!.length}.`);\n const key = JSON.stringify(list);\n const members = byList.get(key);\n if (members) members.push(id);\n else byList.set(key, [id]);\n }\n const groups = [...byList.values()].map((members): OutputGroup => {\n const sorted = [...members].sort();\n return { id: sorted[0]!, members: sorted };\n });\n return groups.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));\n}\n\n/** The evidence that a candidate is exercised on its decision inputs. */\nexport interface ExerciseEvidence {\n /** The move counts of the candidate, by name. A record keeps each one as the trace measure `move.<name>`. */\n readonly moves?: Readonly<Record<string, number>>;\n /** The output hashes of the candidate, in the order of the decision inputs. */\n readonly hashes?: readonly string[];\n /** The output hashes of the base of the candidate, in the same order. */\n readonly baseHashes?: readonly string[];\n}\n\n/**\n * This function tells if a candidate is exercised. It gives `true` when a move count is more than 0.\n * It also gives `true` when `hashes` and `baseHashes` are different at one place or more.\n * Without evidence, it gives `false`.\n * The function throws a `RangeError` when only one of the two lists is given, or when their lengths are different.\n */\nexport function exercised(evidence: ExerciseEvidence): boolean {\n const { moves, hashes, baseHashes } = evidence;\n if ((hashes === undefined) !== (baseHashes === undefined)) throw new RangeError(\"The evidence must have both hashes and baseHashes, or neither of them.\");\n if (hashes && baseHashes && hashes.length !== baseHashes.length)\n throw new RangeError(`The candidate has ${hashes.length} hashes, but its base has ${baseHashes.length}.`);\n if (moves && Object.values(moves).some((n) => n > 0)) return true;\n if (hashes && baseHashes) return hashes.some((h, i) => h !== baseHashes[i]);\n return false;\n}\n","import { outputHash } from \"./hash.ts\";\nimport { compareMeasure, type MeasureSpec } from \"./measures.ts\";\n\n/** The part of a `MeasureSpec` that a pick uses: the direction and the `minEffect`. */\nexport type PickSpec = Pick<MeasureSpec, \"direction\" | \"minEffect\">;\n\n/** A member of a portfolio: a function with an id. A portfolio is also a member. */\nexport interface Member<I, O> {\n readonly id: string;\n /** This function gives the output of the member for an input. */\n run(input: I): O;\n}\n\n/** One level of the key of a portfolio: a measure of an output. */\nexport interface PortfolioLevel<I, O> {\n /** The id of the level. The id `hard` is reserved. */\n readonly id: string;\n readonly spec: PickSpec;\n /** This function gives the value of the measure for the output of a member. The value must be finite. */\n value(input: I, output: O): number;\n}\n\n/** The key of a portfolio: the hard level, then the other levels in order. */\nexport interface PortfolioKey<I, O> {\n /** This function gives the count of hard breaks. It is level 0, with the direction `lower` and the `minEffect` 0. */\n hard(input: I, output: O): number;\n /** The levels after the hard level, in the order of the pick. */\n readonly levels: readonly PortfolioLevel<I, O>[];\n /** This function gives the hash of an output. The default is `outputHash` with the default grid. */\n hash?(output: O): string;\n}\n\n/** The options of a portfolio. */\nexport interface PortfolioOptions {\n /** The time limit in milliseconds, 0 or more. The first member always starts. A member that starts always finishes. */\n readonly budgetMs?: number;\n /** The largest count of members that run, a whole number of 1 or more. The other members are cut. */\n readonly maxMembers?: number;\n /** The clock in milliseconds. The default is `performance.now`, or `Date.now` without `performance`. */\n readonly now?: () => number;\n /**\n * The members that get an output hash. The default `all` hashes each member with the status `ran`. A hash that throws then gives the status `error`.\n * With `pick`, only member 0 and the winner get a hash, and only when the winner is not member 0. Then a hash that throws makes `pick` throw.\n */\n readonly hashes?: \"all\" | \"pick\";\n}\n\n/** The status of a member in a pick. */\nexport type MemberStatus = \"ran\" | \"cut\" | \"error\";\n\n/** The trace of one member in a pick. */\nexport interface MemberTrace {\n readonly id: string;\n readonly status: MemberStatus;\n /** The value of each level, with the key `hard` for the hard level. Only a member with the status `ran` has values. */\n readonly values?: Readonly<Record<string, number>>;\n /** The time of the run of the member, in milliseconds. */\n readonly ms?: number;\n /**\n * The hash of the output of the member. Under the option `hashes` \"all\" (the default), each member with the status `ran` has it.\n * Under `hashes` \"pick\", it is absent, except for member 0 and the winner when the winner is not member 0.\n */\n readonly outputHash?: string;\n /** The message of the error of a member with the status `error`. */\n readonly error?: string;\n}\n\n/** The trace of one pick of a portfolio. */\nexport interface PortfolioTrace {\n /** One entry for each member, in the order of the members. A cut member is also in the list. */\n readonly members: readonly MemberTrace[];\n readonly winner: string;\n /** The index of the winner in the list of the members. */\n readonly winnerIndex: number;\n /** The value `true` tells that the winner is not member 0 and has a different output hash. */\n readonly picked: boolean;\n /** The time of the full pick, in milliseconds. */\n readonly totalMs: number;\n readonly budgetMs?: number;\n readonly maxMembers?: number;\n /** The count of the cut members. */\n readonly cut: number;\n /** The value `false` tells that the time limit cut one member or more. Then a run on a different computer can give a different pick. */\n readonly deterministic: boolean;\n /** The ids of the members that stay in after each level of `selectBest`. The first list is for the hard level. */\n readonly kept: readonly (readonly string[])[];\n}\n\n/** The result of one pick of a portfolio: the output of the winner, its id and the trace. */\nexport interface PortfolioPick<O> {\n readonly output: O;\n readonly winner: string;\n readonly trace: PortfolioTrace;\n}\n\n/** A portfolio: a member that runs its members and gives the output of the best member. */\nexport interface Portfolio<I, O> extends Member<I, O> {\n /** This function starts the members on an input and gives the output of the winner with the trace. */\n pick(input: I): PortfolioPick<O>;\n}\n\n/** A candidate of `selectBest`: an id and the value of each level. */\nexport interface SelectCandidate {\n readonly id: string;\n readonly values: Readonly<Record<string, number>>;\n}\n\n/** A level of `selectBest`: the id of a value and its spec. */\nexport interface SelectLevel {\n readonly id: string;\n readonly spec: PickSpec;\n}\n\n/** The result of `selectBest`. */\nexport interface Selection {\n readonly winner: string;\n /** The ids of the candidates that stay in after each level, in the given order. */\n readonly kept: readonly (readonly string[])[];\n}\n\n/**\n * This function picks the best candidate. For each level, it finds the best value of the candidates that stay in.\n * It keeps each candidate that is not worse than that best value by `compareMeasure`.\n * The winner is the first candidate, in the given order, that stays in after the last level.\n * Without levels, the winner is the first candidate and `kept` is empty.\n *\n * The reason for the rule: a scan that compares each candidate with the current winner is not transitive, because of the `minEffect` ties.\n * Such a scan can drift away from the best value. An example: \"a\" is lower with the `minEffect` 0.005, and \"b\" is higher.\n * The candidates A (0, 1), B (0.004, 2) and C (0.008, 3) give the winner B.\n * The scan picks C, but A is better than C on \"a\".\n *\n * The function throws a `RangeError` for an empty list of candidates, for a missing value, and for a value that is not finite.\n */\nexport function selectBest(candidates: readonly SelectCandidate[], levels: readonly SelectLevel[]): Selection {\n if (candidates.length === 0) throw new RangeError(\"selectBest: the list of candidates is empty.\");\n for (const level of levels) {\n for (const c of candidates) {\n const v = c.values[level.id];\n if (typeof v !== \"number\") throw new RangeError(`selectBest: the candidate \"${c.id}\" has no value for the level \"${level.id}\".`);\n if (!Number.isFinite(v)) throw new RangeError(`selectBest: the candidate \"${c.id}\" has the value ${v} for the level \"${level.id}\".`);\n }\n }\n let alive: readonly SelectCandidate[] = candidates;\n const kept: (readonly string[])[] = [];\n for (const level of levels) {\n const at = (c: SelectCandidate): number => c.values[level.id]!;\n let best = at(alive[0]!);\n for (const c of alive) best = level.spec.direction === \"lower\" ? Math.min(best, at(c)) : Math.max(best, at(c));\n alive = alive.filter((c) => compareMeasure(at(c), best, level.spec) !== \"worse\");\n kept.push(alive.map((c) => c.id));\n }\n return { winner: alive[0]!.id, kept };\n}\n\n/** This function gives the move `pick` of a pick: 1 when `picked` is true, else 0. A record keeps it as the trace measure `move.pick`. */\nexport function pickMoves(trace: Pick<PortfolioTrace, \"picked\">): { pick: number } {\n return { pick: trace.picked ? 1 : 0 };\n}\n\n/** This function gives the default clock: `performance.now`, or `Date.now` without `performance`. */\nfunction defaultClock(): () => number {\n const perf = (globalThis as { readonly performance?: { now(): number } }).performance;\n return perf ? () => perf.now() : () => Date.now();\n}\n\n/** This function gives the message of an error value. */\nfunction messageOf(e: unknown): string {\n return e instanceof Error ? e.message : String(e);\n}\n\n/** This function throws a `RangeError` for an empty list of members or for two members with the same id. */\nfunction checkMembers(id: string, members: readonly Member<unknown, unknown>[]): void {\n if (members.length === 0) throw new RangeError(`The portfolio \"${id}\" has no members.`);\n const seen = new Set<string>();\n for (const m of members) {\n if (seen.has(m.id)) throw new RangeError(`The portfolio \"${id}\" has two members with the id \"${m.id}\".`);\n seen.add(m.id);\n }\n}\n\n/** The result of the run of one member. */\ntype Ran<O> = { readonly ok: true; readonly output: O; readonly values: Record<string, number>; readonly hash?: string } | { readonly ok: false; readonly error: unknown };\n\n/**\n * This function makes a portfolio. Its `pick` starts the members in their order. `selectBest` picks the winner of the members with the status `ran`.\n * The first level is the hard level, then the levels of the key follow.\n * `members` is a list, or a function of the input that gives the list.\n *\n * A member that throws, or that gives a value that is not finite, gets the status `error`. It does not win.\n * When each member has an error, `pick` throws the error of the first member.\n * `docs/PORTFOLIO.md` tells the rules of the time limit, the trace and `picked`.\n *\n * The function throws a `RangeError` for a level with the id `hard`, for two levels with the same id and for a bad option.\n * It also throws a `RangeError` for an empty list of members, or for two members with the same id.\n */\nexport function portfolio<I, O>(\n id: string,\n members: readonly Member<I, O>[] | ((input: I) => readonly Member<I, O>[]),\n key: PortfolioKey<I, O>,\n options: PortfolioOptions = {},\n): Portfolio<I, O> {\n const levelIds = new Set<string>();\n for (const level of key.levels) {\n if (level.id === \"hard\") throw new RangeError(`The portfolio \"${id}\" has a level with the reserved id \"hard\".`);\n if (levelIds.has(level.id)) throw new RangeError(`The portfolio \"${id}\" has two levels with the id \"${level.id}\".`);\n levelIds.add(level.id);\n }\n const { budgetMs, maxMembers, hashes = \"all\" } = options;\n if (budgetMs !== undefined && !(budgetMs >= 0)) throw new RangeError(`The portfolio \"${id}\" has the budgetMs ${budgetMs}. It must be 0 or more.`);\n if (maxMembers !== undefined && !(Number.isInteger(maxMembers) && maxMembers >= 1))\n throw new RangeError(`The portfolio \"${id}\" has the maxMembers ${maxMembers}. It must be a whole number of 1 or more.`);\n if (hashes !== \"all\" && hashes !== \"pick\") throw new RangeError(`The portfolio \"${id}\" has the hashes ${String(hashes)}. It must be \"all\" or \"pick\".`);\n if (typeof members !== \"function\") checkMembers(id, members);\n const levels: readonly SelectLevel[] = [{ id: \"hard\", spec: { direction: \"lower\", minEffect: 0 } }, ...key.levels.map((l) => ({ id: l.id, spec: l.spec }))];\n const now = options.now ?? defaultClock();\n\n /** This function gives the hash of the output of a member. A hash that throws causes a `RangeError`. */\n const hashOf = (m: Member<I, O>, output: O): string => {\n try {\n return key.hash ? key.hash(output) : outputHash(output);\n } catch (e) {\n throw new RangeError(`The hash of the member \"${m.id}\" of the portfolio \"${id}\" throws: ${messageOf(e)}`, { cause: e });\n }\n };\n\n const evaluate = (m: Member<I, O>, input: I, output: O): Ran<O> => {\n const values: Record<string, number> = {};\n const measure = (level: string, f: () => number): void => {\n let v: number;\n try {\n v = f();\n } catch (e) {\n throw new RangeError(`The level \"${level}\" of the member \"${m.id}\" of the portfolio \"${id}\" throws: ${messageOf(e)}`, { cause: e });\n }\n if (typeof v !== \"number\" || !Number.isFinite(v))\n throw new RangeError(`The member \"${m.id}\" of the portfolio \"${id}\" has the value ${v} for the level \"${level}\".`);\n values[level] = v;\n };\n try {\n measure(\"hard\", () => key.hard(input, output));\n for (const level of key.levels) measure(level.id, () => level.value(input, output));\n if (hashes === \"pick\") return { ok: true, output, values };\n return { ok: true, output, values, hash: hashOf(m, output) };\n } catch (e) {\n return { ok: false, error: e };\n }\n };\n\n const pick = (input: I): PortfolioPick<O> => {\n const list = typeof members === \"function\" ? members(input) : members;\n if (typeof members === \"function\") checkMembers(id, list);\n const start = now();\n const traces: MemberTrace[] = [];\n const outputs = new Map<string, O>();\n const ran: SelectCandidate[] = [];\n let firstError: { readonly error: unknown } | undefined;\n let cut = 0;\n let outOfTime = false;\n for (let i = 0; i < list.length; i++) {\n const m = list[i]!;\n if (maxMembers !== undefined && i >= maxMembers) {\n traces.push({ id: m.id, status: \"cut\" });\n cut++;\n continue;\n }\n if (i > 0 && budgetMs !== undefined && (outOfTime || now() - start >= budgetMs)) {\n outOfTime = true;\n traces.push({ id: m.id, status: \"cut\" });\n cut++;\n continue;\n }\n const t0 = now();\n let result: Ran<O>;\n let ms: number;\n try {\n const output = m.run(input);\n ms = now() - t0;\n result = evaluate(m, input, output);\n } catch (e) {\n ms = now() - t0;\n result = { ok: false, error: e };\n }\n if (result.ok) {\n traces.push(\n result.hash === undefined\n ? { id: m.id, status: \"ran\", values: result.values, ms }\n : { id: m.id, status: \"ran\", values: result.values, ms, outputHash: result.hash },\n );\n outputs.set(m.id, result.output);\n ran.push({ id: m.id, values: result.values });\n } else {\n traces.push({ id: m.id, status: \"error\", ms, error: messageOf(result.error) });\n firstError ??= { error: result.error };\n }\n }\n if (ran.length === 0) throw firstError!.error;\n const { winner, kept } = selectBest(ran, levels);\n const winnerIndex = traces.findIndex((t) => t.id === winner);\n if (hashes === \"pick\" && winnerIndex > 0 && traces[0]!.status === \"ran\") {\n // Only member 0 and the winner get a hash. Their two trace entries are new objects with the hash.\n for (const i of [0, winnerIndex]) traces[i] = { ...traces[i]!, outputHash: hashOf(list[i]!, outputs.get(traces[i]!.id)!) };\n }\n const base = traces[0]!;\n const picked = winnerIndex > 0 && (base.status !== \"ran\" || traces[winnerIndex]!.outputHash !== base.outputHash);\n const trace: PortfolioTrace = {\n members: traces,\n winner,\n winnerIndex,\n picked,\n totalMs: now() - start,\n ...(budgetMs !== undefined ? { budgetMs } : {}),\n ...(maxMembers !== undefined ? { maxMembers } : {}),\n cut,\n deterministic: !outOfTime,\n kept,\n };\n return { output: outputs.get(winner)!, winner, trace };\n };\n\n return { id, pick, run: (input: I): O => pick(input).output };\n}\n","// The checks of the claims of a corpus (`docs/CORPUS-CHECKS.md`). The joint corpus, `packing` and `highways` use the same checks.\nimport { canonicalJson, sha256Hex } from \"./hash.ts\";\n\n/** One broken claim of a corpus, with the ids of the inputs that break it. */\nexport interface ClaimBreak {\n /** The name of the claim, for example `declared`, `split` or `index`. */\n readonly claim: string;\n /** The text of the break. */\n readonly detail: string;\n /** The ids of the inputs that break the claim. The list is empty when the break has no input. */\n readonly inputs: readonly string[];\n}\n\n/** The claim `claims.declared` of a manifest: the count of the inputs for each declared property. */\nexport interface DeclaredClaim {\n /** A property with fewer inputs than this count is thin. */\n readonly minCount: number;\n /** The ids of the properties with a count below `minCount`. */\n readonly thin: readonly string[];\n /** The count of the inputs for each property id. */\n readonly counts: Readonly<Record<string, number>>;\n /** The key of the family of an input. `familyOf` gives the key of one cell. The family is the unit of a verdict. */\n readonly familyBy?: FamilyBy;\n /** The minimum count of the inputs of each family. Without it, `checkDeclared` does not count the families. */\n readonly familyMin?: number;\n}\n\n/**\n * The key of the family of a cell (`docs/CORPUS-CHECKS.md`).\n *\n * - The flat form is a list of dimensions. The key is the values of these dimensions of the cell, in order, with `/` between them.\n * - The map form chooses an entry by the field `kind` of the cell, or the entry `\"*\"`. The key is the kind, then the values of the dimensions of the entry.\n */\nexport type FamilyBy = readonly string[] | { readonly [kind: string]: readonly string[] };\n\n/** A cell of an input: one value for each dimension. The map form of `FamilyBy` also reads the field `kind`. */\nexport type FamilyCell = Readonly<Record<string, unknown>>;\n\n/** The entry of the map form of `FamilyBy` for each kind without its own entry. */\nexport const FAMILY_ANY_KIND = \"*\";\n\n/** The separator of the parts of a family key. */\nconst FAMILY_SEP = \"/\";\n\n/** The parts of the key of one cell, or the text of the problem. */\ntype FamilyParts = { readonly parts: readonly string[] } | { readonly problem: string };\n\n/** This function gives the text of a dimension value. A missing value, or a value that is not a string, a number or a boolean, gives `undefined`. */\nfunction partOf(value: unknown): string | undefined {\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"boolean\") return String(value);\n return undefined;\n}\n\n/** This function gives the parts of the family key of a cell. A missing dimension, a missing kind or a kind without an entry gives a problem. */\nfunction familyParts(cell: FamilyCell, familyBy: FamilyBy): FamilyParts {\n let dims: readonly string[];\n let kind: string | undefined;\n const parts: string[] = [];\n if (Array.isArray(familyBy)) {\n dims = familyBy as readonly string[];\n } else {\n const map = familyBy as Readonly<Record<string, readonly string[]>>;\n kind = partOf(cell[\"kind\"]);\n if (kind === undefined) return { problem: \"a cell without kind, which the map form of familyBy needs\" };\n const entry = Object.hasOwn(map, kind) ? map[kind] : Object.hasOwn(map, FAMILY_ANY_KIND) ? map[FAMILY_ANY_KIND] : undefined;\n if (entry === undefined) return { problem: `the kind \"${kind}\", which has no entry in familyBy and no entry \"${FAMILY_ANY_KIND}\"` };\n dims = entry;\n parts.push(kind);\n }\n for (const dim of dims) {\n const part = partOf(cell[dim]);\n if (part === undefined) return { problem: `a cell${kind === undefined ? \"\" : ` of the kind \"${kind}\"`} without the dimension \"${dim}\" of familyBy` };\n parts.push(part);\n }\n return { parts };\n}\n\n/**\n * This function gives the family key of a cell. It throws a `RangeError` when the cell does not have a dimension of the key.\n * In the map form, it also throws for a cell without `kind`, and for a kind with no entry and no entry `\"*\"`.\n * For example, `{ \"rect-grid\": [\"obstacles\"], \"*\": [] }` gives `rect-grid/wall` for a `rect-grid` cell and `gallery` for a `gallery` cell.\n */\nexport function familyOf(cell: FamilyCell, familyBy: FamilyBy): string {\n const found = familyParts(cell, familyBy);\n if (\"problem\" in found) throw new RangeError(`familyOf: ${found.problem}.`);\n return found.parts.join(FAMILY_SEP);\n}\n\n/** This function tells if a value is a `FamilyBy`: a list of dimensions, or a map from a kind to a list of dimensions. */\nfunction isFamilyBy(value: unknown): value is FamilyBy {\n const isDims = (v: unknown): boolean => Array.isArray(v) && v.every((d) => typeof d === \"string\");\n return isDims(value) || (isObject(value) && Object.values(value).every(isDims));\n}\n\n/** The hook that gives the ids of the properties that one input declares. */\nexport type Declares<I> = (input: I) => readonly string[];\n\n/**\n * This function gives the count of the inputs for each property id. Each id of `ids` has a count, also when the count is 0.\n * An id from `declares` that is not in `ids` comes after the ids of `ids`, in the order of the first input that declares it.\n */\nexport function declaredCounts<I>(inputs: Iterable<I>, declares: Declares<I>, ids: readonly string[] = []): Record<string, number> {\n const out: Record<string, number> = Object.fromEntries(ids.map((id) => [id, 0]));\n for (const input of inputs) for (const id of declares(input)) out[id] = (out[id] ?? 0) + 1;\n return out;\n}\n\n/** This function tells if a value is a plain object. */\nconst isObject = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === \"object\" && !Array.isArray(value);\n\n/**\n * This function reads the field `claims.declared` of a manifest. A manifest without it gives `undefined`.\n * It throws an `Error` for a claim without a whole `minCount`, a list `thin` of ids and a whole count for each id.\n */\nexport function declaredClaimOf(manifest: object): DeclaredClaim | undefined {\n const claims = (manifest as Record<string, unknown>)[\"claims\"];\n if (claims === undefined) return undefined;\n if (!isObject(claims)) throw new Error(\"The field claims of a corpus file is an object.\");\n const declared = claims[\"declared\"];\n if (declared === undefined) return undefined;\n if (!isObject(declared)) throw new Error(\"The field claims.declared of a corpus file is an object.\");\n const { minCount, thin, counts } = declared;\n if (!Number.isInteger(minCount) || (minCount as number) < 0) throw new Error(\"The field claims.declared.minCount is a whole number of 0 or more.\");\n if (!Array.isArray(thin) || !thin.every((id) => typeof id === \"string\")) throw new Error(\"The field claims.declared.thin is a list of property ids.\");\n if (!isObject(counts) || !Object.values(counts).every((n) => Number.isInteger(n) && (n as number) >= 0)) {\n throw new Error(\"The field claims.declared.counts gives a whole count for each property id.\");\n }\n const { familyBy, familyMin } = declared;\n if (familyBy !== undefined && !isFamilyBy(familyBy)) throw new Error(\"The field claims.declared.familyBy is a list of dimensions, or a map from a kind to a list of dimensions.\");\n if (familyMin !== undefined && (!Number.isInteger(familyMin) || (familyMin as number) < 0)) throw new Error(\"The field claims.declared.familyMin is a whole number of 0 or more.\");\n return {\n minCount: minCount as number,\n thin: [...(thin as string[])],\n counts: { ...(counts as Record<string, number>) },\n ...(familyBy === undefined ? {} : { familyBy: Array.isArray(familyBy) ? [...familyBy] : { ...(familyBy as Record<string, readonly string[]>) } }),\n ...(familyMin === undefined ? {} : { familyMin: familyMin as number }),\n };\n}\n\n/**\n * This function checks the claim `claims.declared` against the inputs. It gives one break `declared` for each problem. An empty list tells that the claim is true.\n *\n * - `ids` are the property ids. The default is the ids of `claim.counts`.\n * - Each id of `ids` has a count in `claim.counts`, and `claim.counts` has no other id. Each count is the count of the inputs.\n * - An id with a count below `minCount` is in `thin`. Each id of `thin` is an id of `ids`.\n * - Each id that `declares` gives is an id of `ids`.\n *\n * With `claim.familyBy`, the hook `cellOf` gives the cell of each input. The default reads the field `cell` of the input.\n *\n * - Each cell has each dimension of its key. In the map form, each cell has a `kind`, and the kind has an entry or the entry `\"*\"` is there.\n * - Two cells with different dimension values do not give the same key.\n * - With `claim.familyMin`, each family has `familyMin` inputs or more.\n */\nexport function checkDeclared<I>(\n inputs: Iterable<I>,\n declares: Declares<I>,\n claim: DeclaredClaim,\n ids: readonly string[] = Object.keys(claim.counts),\n cellOf: (input: I) => FamilyCell | undefined = cellField,\n): ClaimBreak[] {\n const list = [...inputs];\n const computed = declaredCounts(list, declares, ids);\n const out: string[] = [];\n for (const id of ids) {\n if (!(id in claim.counts)) out.push(`the property \"${id}\" has no count`);\n else if (claim.counts[id] !== computed[id]) out.push(`the property \"${id}\" has the count ${claim.counts[id]}, but the inputs give ${computed[id]}`);\n }\n for (const id of Object.keys(claim.counts)) if (!ids.includes(id)) out.push(`\"${id}\" is not a declared property`);\n for (const id of ids) {\n const thin = (computed[id] ?? 0) < claim.minCount;\n if (thin && !claim.thin.includes(id)) out.push(`the property \"${id}\" has ${computed[id]} inputs, below minCount ${claim.minCount}, and it is not in thin`);\n }\n for (const id of claim.thin) if (!ids.includes(id)) out.push(`\"${id}\" of thin is not a declared property`);\n for (const id of Object.keys(computed)) if (!ids.includes(id)) out.push(`${computed[id]} inputs declare \"${id}\", which is not a declared property`);\n const breaks: ClaimBreak[] = out.map((detail) => ({ claim: \"declared\", detail, inputs: [] }));\n if (claim.familyBy !== undefined) breaks.push(...checkFamilies(list, claim.familyBy, claim.familyMin, cellOf));\n return breaks;\n}\n\n/** This function gives the field `cell` of an input, when it is an object. */\nfunction cellField(input: unknown): FamilyCell | undefined {\n const cell = isObject(input) ? input[\"cell\"] : undefined;\n return isObject(cell) ? cell : undefined;\n}\n\n/** This function gives the field `id` of an input, or its place in the list. */\nfunction inputId(input: unknown, at: number): string {\n const id = isObject(input) ? input[\"id\"] : undefined;\n return typeof id === \"string\" ? id : `#${at}`;\n}\n\n/** This function gives the breaks of the family keys of the inputs: the problems of each key, the collisions and the thin families. */\nfunction checkFamilies<I>(inputs: readonly I[], familyBy: FamilyBy, familyMin: number | undefined, cellOf: (input: I) => FamilyCell | undefined): ClaimBreak[] {\n const problems = new Map<string, string[]>();\n const members = new Map<string, { readonly tuples: Map<string, string[]>; readonly ids: string[] }>();\n inputs.forEach((input, at) => {\n const id = inputId(input, at);\n const cell = cellOf(input);\n const found: FamilyParts = cell === undefined ? { problem: \"no cell, which familyBy needs\" } : familyParts(cell, familyBy);\n if (\"problem\" in found) {\n problems.set(found.problem, [...(problems.get(found.problem) ?? []), id]);\n return;\n }\n const key = found.parts.join(FAMILY_SEP);\n const family = members.get(key) ?? { tuples: new Map<string, string[]>(), ids: [] };\n const tuple = JSON.stringify(found.parts);\n family.tuples.set(tuple, [...(family.tuples.get(tuple) ?? []), id]);\n family.ids.push(id);\n members.set(key, family);\n });\n const breaks: ClaimBreak[] = [];\n const add = (detail: string, ids: readonly string[]): void => void breaks.push({ claim: \"declared\", detail, inputs: [...ids] });\n for (const [problem, ids] of problems) add(`${ids.length} inputs have ${problem}`, ids);\n for (const [key, family] of members) {\n if (family.tuples.size > 1) {\n const forms = [...family.tuples.keys()].join(\" and \");\n add(`the family \"${key}\" comes from different dimension values: ${forms}`, family.ids);\n }\n if (familyMin !== undefined && family.ids.length < familyMin) add(`the family \"${key}\" has ${family.ids.length} inputs, below familyMin ${familyMin}`, family.ids);\n }\n return breaks;\n}\n\n/** The id and the hash of one input of a corpus. */\nexport interface CorpusEntry {\n readonly id: string;\n readonly hash: string;\n}\n\n/**\n * This function gives the hash of a corpus: the first 16 hex characters of a SHA-256. The text of the SHA-256 is `canonicalJson`\n * of the corpus id and the `[id, hash]` of each input, in the order of the manifest. A change of one input changes the hash.\n */\nexport function corpusHashOf(corpus: string, inputs: readonly CorpusEntry[]): string {\n return sha256Hex(canonicalJson({ corpus, inputs: inputs.map((i) => [i.id, i.hash]) })).slice(0, 16);\n}\n\n/** The schema of a split file. */\nexport const SPLIT_SCHEMA = \"corpus-split/1\";\n\n/** One fold of a split: the seeds that fit a selector and the seeds that score it. */\nexport interface SplitFold {\n readonly train: readonly number[];\n readonly heldOut: readonly number[];\n}\n\n/** A split file `corpus-split/1`. Its name is `<corpus id>.<corpus hash>.json`. It is beside the corpus, so the corpus does not change. */\nexport interface CorpusSplit {\n readonly schema: typeof SPLIT_SCHEMA;\n readonly corpus: string;\n /** The hash of the corpus: `corpusHashOf` of its manifest. */\n readonly corpusHash: string;\n /** The splits by name. Each split has one fold or more. */\n readonly splits: Readonly<Record<string, { readonly folds: readonly SplitFold[] }>>;\n}\n\n/** The fields of a manifest that the split check reads. */\nexport interface SplitCorpus {\n readonly corpus: string;\n readonly specs: readonly { readonly seeds: readonly number[] }[];\n readonly inputs: readonly CorpusEntry[];\n}\n\n/** This function gives the name of the split file of a corpus. */\nexport function splitFileName(corpus: string, hash: string): string {\n return `${corpus}.${hash}.json`;\n}\n\n/** This function tells if a value is a list of whole numbers. */\nconst isSeeds = (value: unknown): value is number[] => Array.isArray(value) && value.every((s) => Number.isInteger(s));\n\n/**\n * This function checks a split file against a manifest. It gives one break `split` for each problem. An empty list tells that the file is good.\n *\n * - The schema is `corpus-split/1`, the corpus is the id of the manifest and `corpusHash` is `corpusHashOf` of the manifest.\n * - Each split has one fold or more. In each fold, `train` and `heldOut` are lists of seeds, not empty and with no common seed.\n * - Each seed is a seed of a spec of the manifest.\n * - With `name`, the file has the split `name`.\n */\nexport function checkSplit(split: unknown, corpus: SplitCorpus, name?: string): ClaimBreak[] {\n const out: string[] = [];\n const done = (): ClaimBreak[] => out.map((detail) => ({ claim: \"split\", detail, inputs: [] }));\n const f = split as Partial<CorpusSplit> | null;\n if (f === null || typeof f !== \"object\") {\n out.push(\"the split file is not an object\");\n return done();\n }\n if (f.schema !== SPLIT_SCHEMA) out.push(`the schema is ${String(f.schema)}, not ${SPLIT_SCHEMA}`);\n if (f.corpus !== corpus.corpus) out.push(`the corpus is ${String(f.corpus)}, not ${corpus.corpus}`);\n const hash = corpusHashOf(corpus.corpus, corpus.inputs);\n if (f.corpusHash !== hash) out.push(`the corpusHash is ${String(f.corpusHash)}, but the corpus gives ${hash}`);\n const seeds = new Set(corpus.specs.flatMap((s) => s.seeds));\n if (f.splits === null || typeof f.splits !== \"object\") {\n out.push(\"the field splits is not an object\");\n return done();\n }\n for (const [key, value] of Object.entries(f.splits)) {\n const folds = (value as { folds?: unknown } | null)?.folds;\n if (!Array.isArray(folds) || folds.length === 0) {\n out.push(`the split ${key} has no folds`);\n continue;\n }\n folds.forEach((fold: Partial<SplitFold> | null, k) => {\n const at = `the fold ${k} of the split ${key}`;\n const { train, heldOut } = fold ?? {};\n if (!isSeeds(train) || train.length === 0) out.push(`${at} has no train seeds`);\n if (!isSeeds(heldOut) || heldOut.length === 0) out.push(`${at} has no heldOut seeds`);\n if (!isSeeds(train) || !isSeeds(heldOut)) return;\n const common = train.filter((s) => heldOut.includes(s));\n if (common.length > 0) out.push(`${at} has the seeds ${common.join(\", \")} in train and in heldOut`);\n const unknown = [...train, ...heldOut].filter((s) => !seeds.has(s));\n if (unknown.length > 0) out.push(`${at} has the seeds ${unknown.join(\", \")}, which are not in the corpus`);\n });\n }\n if (name !== undefined && !Object.hasOwn(f.splits, name)) out.push(`the split file has no split ${name}. Its splits are ${Object.keys(f.splits).join(\", \")}`);\n return done();\n}\n\n/**\n * This function gives a copy of the folds of the split `name` of a split file. `where` names the file in the text of an error.\n * It throws an `Error` for each problem of `checkSplit`, and then for an unknown split name.\n */\nexport function splitFolds(split: unknown, corpus: SplitCorpus, name: string, where: string = \"The split file\"): SplitFold[] {\n const breaks = checkSplit(split, corpus);\n if (breaks.length > 0) throw new Error(`${where} is not good: ${breaks.map((b) => b.detail).join(\"; \")}.`);\n const splits = (split as CorpusSplit).splits;\n const found = Object.hasOwn(splits, name) ? splits[name] : undefined;\n if (found === undefined) throw new Error(`${where} has no split ${name}. Its splits are ${Object.keys(splits).join(\", \")}.`);\n return found.folds.map((f) => ({ train: [...f.train], heldOut: [...f.heldOut] }));\n}\n\n/** This function gives the folds that hold out one seed each, in the order of the seeds. Each fold trains on the other seeds. */\nexport function leaveOneSeedOut(seeds: readonly number[]): SplitFold[] {\n const sorted = [...new Set(seeds)].sort((a, b) => a - b);\n return sorted.map((s) => ({ train: sorted.filter((t) => t !== s), heldOut: [s] }));\n}\n","// The walk draw of a sample of a strategy space (`docs/STRATEGY-SPACE.md`). The package root does not export this file.\nimport type { OptionRef, SpaceConstraint, SpaceStage, StageOption } from \"./strategy-space.ts\";\n\nconst refMatches = (ref: OptionRef, choices: ReadonlyMap<string, string | null>): boolean => (choices.get(ref.stage) ?? null) === ref.option;\n\n/** This function tells if the option choices keep a constraint. */\nexport function holds(c: SpaceConstraint, choices: ReadonlyMap<string, string | null>): boolean {\n if (!refMatches(c.if, choices)) return true;\n return \"not\" in c.then ? !refMatches(c.then.not, choices) : refMatches(c.then, choices);\n}\n\nconst otherStage = (c: SpaceConstraint): string => (\"not\" in c.then ? c.then.not.stage : c.then.stage);\n\n/** This function tells if an option of a stage keeps each constraint between that stage and the stages that a walk has fixed. */\nexport function fitsWalk(constraints: readonly SpaceConstraint[], fixed: Map<string, string | null>, stage: string, id: string | null): boolean {\n fixed.set(stage, id);\n const ok = constraints.every((c) => !fixed.has(c.if.stage === stage ? otherStage(c) : c.if.stage) || holds(c, fixed));\n fixed.delete(stage);\n return ok;\n}\n\n/** The order of the stages of a walk, and the constraints that name each stage. */\nexport interface WalkPlan {\n /** The stages of the space. */\n readonly stages: readonly SpaceStage[];\n /** The options of each stage for a draw. */\n readonly lists: readonly (readonly (StageOption | null)[])[];\n /** The indexes of the stages. The stages of `first` come first, in the order of the space. The others follow, from the largest stage to the smallest. */\n readonly order: readonly number[];\n /** The constraints that name each stage. */\n readonly naming: readonly (readonly SpaceConstraint[])[];\n /** The count of points of a round. */\n readonly n: number;\n}\n\n/**\n * This function gives the plan of a walk. Stages of equal size keep the order of the space.\n * The stages of `first` go first, for example the stages of the sample option `fixed`. Thus the other stages draw only from the options that keep the constraints with them.\n */\nexport function walkPlan(\n stages: readonly SpaceStage[],\n lists: readonly (readonly (StageOption | null)[])[],\n constraints: readonly SpaceConstraint[],\n n: number,\n first: ReadonlySet<string> = new Set(),\n): WalkPlan {\n return {\n stages,\n lists,\n n,\n order: stages.map((_, k) => k).sort((a, b) => Number(first.has(stages[b]!.name)) - Number(first.has(stages[a]!.name)) || lists[b]!.length - lists[a]!.length || a - b),\n naming: stages.map((s) => constraints.filter((c) => c.if.stage === s.name || otherStage(c) === s.name)),\n };\n}\n\n/**\n * This function gives the options of one point of a walk. It fixes the largest stage first. Thus that stage keeps its equal strata, and the constraints limit only the smaller stages.\n * The value `picks[k][i]` is the stratum of the stage `k` for the point `i`. A stage with no open option gets `null`, and the caller rejects that point.\n * The argument `fits` lets a test give a fault. The default is `fitsWalk`.\n */\nexport function walkPoint(plan: WalkPlan, picks: readonly (readonly number[])[], i: number, fits: typeof fitsWalk = fitsWalk): Map<string, StageOption | null> {\n const fixed = new Map<string, string | null>();\n const out = new Map<string, StageOption | null>();\n for (const k of plan.order) {\n const s = plan.stages[k]!;\n const open = plan.lists[k]!.filter((o) => fits(plan.naming[k]!, fixed, s.name, o?.id ?? null));\n const o = open[Math.floor((picks[k]![i]! * open.length) / plan.n)] ?? null;\n fixed.set(s.name, o?.id ?? null);\n out.set(s.name, o);\n }\n return out;\n}\n","// The strategy space of an engine (`docs/STRATEGY-SPACE.md`): its stages, their options and the ranges of their params, as data.\nimport type { ClaimBreak } from \"./corpus.ts\";\nimport { canonicalJson, sha256Hex } from \"./hash.ts\";\nimport { stepRandom } from \"./random.ts\";\nimport { holds, walkPlan, walkPoint } from \"./space-walk.ts\";\nimport { isShapeKind, SHAPE_KIND_IDS, type ShapeKind } from \"./shapes.ts\";\n\n/** The schema of a strategy space. */\nexport const STRATEGY_SPACE_SCHEMA = \"strategy-space/1\";\n\n/** The kind of a param: a whole number, a real number, one value of a list, or `true` and `false`. */\nexport type ParamKind = \"int\" | \"real\" | \"enum\" | \"bool\";\n\n/** The value of one param in a config. */\nexport type ParamValue = number | string | boolean;\n\n/** The condition of a conditional param: the param is active only when an earlier param of the same option has one of the values `in`. */\nexport interface ParamWhen {\n /** The name of an earlier param of the same option. */\n readonly param: string;\n /** The values of that param that make this param active. */\n readonly in: readonly ParamValue[];\n}\n\n/** One param of a stage option, with its range. */\nexport interface SpaceParam {\n readonly name: string;\n readonly kind: ParamKind;\n /** The smallest value of an `int` or `real` param. */\n readonly min?: number;\n /** The largest value of an `int` or `real` param. */\n readonly max?: number;\n /** The step of the values from `min`. An `int` param has the step 1 by default. */\n readonly step?: number;\n /** The scale of the grid and of the samples. The scale `log` needs a `min` above 0. The default is `linear`. */\n readonly scale?: \"linear\" | \"log\";\n /** The values of an `enum` param. */\n readonly values?: readonly (string | number)[];\n /** The value that a config gets when it does not set the param. */\n readonly default: ParamValue;\n /** Without `when`, the param is active each time its option is chosen. */\n readonly when?: ParamWhen;\n}\n\n/**\n * The rule of the members of a meta option: a count from `min` to `max`. Members with `ordered: false` are sorted by their `configId`.\n * With `min` and `max` 0, the option chooses its members from the input, so a config lists none. This form has no `pool` and no `view`.\n */\nexport interface MemberRule {\n readonly min: number;\n readonly max: number;\n readonly ordered: boolean;\n /**\n * The member lists that the option permits. Each entry is a list of whole configs of the space of the members.\n * Without `pool`, each list of base configs with a good count is a member list.\n * With `pool`, a config of the option has the members of one entry, and `spaceSize` counts each entry one time.\n */\n readonly pool?: readonly (readonly StrategyConfig[])[];\n /**\n * The view of the items that the members get. With `bounds`, the option gives its members the bounding box of each item.\n * Then a shape filter checks the members with the kind `rect`, and the option itself with the kinds of the input. Without `view`, the members get the kinds of the input.\n */\n readonly view?: \"bounds\";\n}\n\n/** The inputs that an option supports. A missing field supports each value. */\nexport interface OptionSupports {\n /** The shape kinds of the boxes (`docs/SHAPES.md`). Without it, the option supports each kind. */\n readonly shape?: readonly ShapeKind[];\n}\n\n/** One implementation of a stage. An option with `members` is a meta option: it chooses between whole configs, or wraps them. */\nexport interface StageOption {\n readonly id: string;\n readonly params: readonly SpaceParam[];\n readonly members?: MemberRule;\n /** The inputs that the option supports. It describes the option, so it is not part of a config or of its id. */\n readonly supports?: OptionSupports;\n}\n\n/** The shape kinds of the inputs of a check, a count or an enumeration. Without `shapes`, each option counts. */\nexport interface ShapeFilter {\n /** The shape kinds of the input. Only the options that support each of these kinds count. */\n readonly shapes?: readonly ShapeKind[];\n}\n\n/** One stage of the pipeline of an engine. A config of an `optional` stage can have no option. */\nexport interface SpaceStage {\n readonly name: string;\n readonly options: readonly StageOption[];\n readonly optional?: boolean;\n}\n\n/** A reference to one option of a stage. The option `null` refers to an optional stage that a config does not use. */\nexport interface OptionRef {\n readonly stage: string;\n readonly option: string | null;\n}\n\n/** A rule that keeps out invalid combinations. A config with the option `if` also has the option `then`, or does not have the option `then.not`. */\nexport interface SpaceConstraint {\n readonly if: OptionRef;\n readonly then: OptionRef | { readonly not: OptionRef };\n}\n\n/** The strategy space of an engine: the stages, the constraints and the named configs. `docs/STRATEGY-SPACE.md` tells the rules. */\nexport interface StrategySpace {\n readonly schema: typeof STRATEGY_SPACE_SCHEMA;\n /** The name of the space. A config names the space with this value. */\n readonly engine: string;\n /** The version of the space. It is not part of a config or of its id. A record writes it. */\n readonly version: string;\n readonly stages: readonly SpaceStage[];\n readonly constraints?: readonly SpaceConstraint[];\n /** The named strategies of the engine, as points of the space. Old records stay comparable through them. */\n readonly named?: Readonly<Record<string, StrategyConfig>>;\n /** The spaces of a product space, from `productSpace`. A meta option of a part takes members of that part. */\n readonly parts?: readonly StrategySpace[];\n}\n\n/** The choice of one stage in a config: an option, its params and, for a meta option, its members. */\nexport interface StageChoice {\n readonly option: string;\n /** The values of the active params. A param that is not set gets its default. */\n readonly params?: Readonly<Record<string, ParamValue>>;\n /** The members of a meta option: configs of the same space, with no meta option. */\n readonly members?: readonly StrategyConfig[];\n}\n\n/** One point of a strategy space. The value `null` of a stage tells that the config does not use the optional stage. */\nexport interface StrategyConfig {\n /** The `engine` of the space, without its version. */\n readonly space: string;\n readonly stages: Readonly<Record<string, StageChoice | null>>;\n}\n\n/** The count of the grid points of a space. */\nexport interface SpaceSize {\n /** The count of the configs without a meta option. */\n readonly base: bigint;\n /** The count of the configs with a meta option. The value is `null` when the count is more than `maxMeta`. */\n readonly meta: bigint | null;\n}\n\n/** The options of `spaceSize`. */\nexport interface SpaceSizeOptions extends ShapeFilter {\n /** The count of the levels of each numeric param, a whole number of 1 or more. */\n readonly levels: number;\n /** The largest meta count that `spaceSize` gives. The default is `10n ** 18n`. */\n readonly maxMeta?: bigint;\n}\n\n/** The options of a grid. The grid gives only the configs without a meta option. */\nexport interface GridOptions extends ShapeFilter {\n readonly mode: \"grid\";\n readonly levels: number;\n /** The largest count of configs. A larger grid causes a `RangeError`. The default is 100000. */\n readonly limit?: number;\n}\n\n/** The options of a sample. */\nexport interface SampleOptions extends ShapeFilter {\n readonly mode: \"sample\";\n /** The count of the configs, a whole number of 0 or more. */\n readonly n: number;\n readonly seed: number;\n /** With `skip` (the default), the sample has no meta option. With `sample`, a meta option draws its members from base samples, or one entry of its `pool`. */\n readonly meta?: \"skip\" | \"sample\";\n /** The largest count of option draws. The default is the larger value of 1000 and `100 * n`. */\n readonly maxTries?: number;\n /**\n * How a point keeps the constraints. With `reject` (the default), a point that breaks a constraint draws again.\n * With `walk`, a point draws its stages from the largest to the smallest. Each stage draws only from the options that keep the constraints with the stages before it.\n * The stages of `fixed` draw before the other stages.\n * A space whose constraints reject most draws gets its sample with `walk`. The two values give different configs for one seed.\n * A sample of `walk` is not uniform over the valid configs. Each option of the largest stage gets an equal share, whatever count of valid configs it has.\n * Thus a mean over this sample is not a mean of the space.\n */\n readonly draw?: \"reject\" | \"walk\";\n /**\n * The options that each config of the sample has. A key is the name of a stage, and its value is the id of one option of that stage. The other stages draw as before.\n * A stage of a product space has the name of its part before its own name, for example `pack.placement`.\n * A fixed meta option needs `meta: \"sample\"`. A meta option of another stage of the same part goes out, because such an option replaces the fixed stage.\n * A fixed option that the shape filter removes, or that the constraints forbid, gets a `RangeError` with the reason.\n */\n readonly fixed?: Readonly<Record<string, string>>;\n}\n\n/** The options of `enumerateSpace`. */\nexport type EnumerateOptions = GridOptions | SampleOptions;\n\ntype Problem = readonly [claim: string, detail: string];\ntype Choices = ReadonlyMap<string, StageOption | null>;\ntype Values = Record<string, ParamValue>;\n\nconst isObject = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === \"object\" && !Array.isArray(value);\nconst show = (value: unknown): string => (typeof value === \"string\" ? `\"${value}\"` : String(value));\nconst isNumeric = (p: SpaceParam): boolean => p.kind === \"int\" || p.kind === \"real\";\nconst zero = (v: number): number => (v === 0 ? 0 : v);\n\n/** This function gives the stable form of a real number: 12 significant digits, with `-0` as `0`. */\nconst realForm = (v: number, digits = 12): number => zero(Number(v.toPrecision(digits)));\n\n/** This function gives the stable form of a value of a param. */\nfunction normalize(p: SpaceParam, v: ParamValue): ParamValue {\n if (typeof v !== \"number\") return v;\n if (p.kind !== \"real\") return zero(v);\n return Math.min(p.max ?? Infinity, Math.max(p.min ?? -Infinity, realForm(v)));\n}\n\n/** This function tells if a value is on the step of a param. */\nfunction onStep(p: SpaceParam, v: number): boolean {\n if (p.step === undefined || p.min === undefined) return true;\n const q = (v - p.min) / p.step;\n return Math.abs(q - Math.round(q)) <= 1e-9 * Math.max(1, Math.abs(q));\n}\n\n/** This function gives the problem of a value of a param, or `undefined` for a value in the range. */\nfunction valueProblem(p: SpaceParam, v: unknown): string | undefined {\n if (p.kind === \"bool\") return typeof v === \"boolean\" ? undefined : `${show(v)} is not true or false`;\n if (p.kind === \"enum\") return (p.values ?? []).some((x) => x === v) ? undefined : `${show(v)} is not one of ${(p.values ?? []).map(show).join(\", \")}`;\n if (typeof v !== \"number\" || !Number.isFinite(v)) return `${show(v)} is not a finite number`;\n if (p.kind === \"int\" && !Number.isInteger(v)) return `${v} is not a whole number`;\n if (p.min !== undefined && v < p.min) return `${v} is less than the min ${p.min}`;\n if (p.max !== undefined && v > p.max) return `${v} is more than the max ${p.max}`;\n if (!onStep(p, v)) return `${v} is not on the step ${p.step} from ${p.min}`;\n return undefined;\n}\n\n/** This function tells if a param is active for the values of the earlier params. */\nfunction isActive(p: SpaceParam, values: Values): boolean {\n if (p.when === undefined) return true;\n if (!Object.hasOwn(values, p.when.param)) return false;\n const v = values[p.when.param];\n return p.when.in.some((x) => x === v);\n}\n\n/** This function gives the problem of a value of a param, or `undefined` for a value in its range. The corpus dimensions of `families.ts` use it. */\nexport function paramProblem(param: SpaceParam, value: unknown): string | undefined {\n return valueProblem(param, value);\n}\n\n/** This function tells if a param is active for the values of the earlier params. A param without `when` is always active. */\nexport function paramActive(param: SpaceParam, values: Readonly<Record<string, ParamValue>>): boolean {\n return isActive(param, values);\n}\n\n/** This function gives the stable form of a value of a param: a real number gets 12 significant digits, and `-0` becomes `0`. */\nexport function paramValue(param: SpaceParam, value: ParamValue): ParamValue {\n return normalize(param, value);\n}\n\n/** This function gives the part of a space that has a stage, and the prefix of the names of its stages. */\nfunction partOf(space: StrategySpace, stage: string): { readonly space: StrategySpace; readonly prefix: string } {\n for (const part of space.parts ?? []) {\n const head = `${part.engine}.`;\n if (stage.startsWith(head)) {\n const inner = partOf(part, stage.slice(head.length));\n return { space: inner.space, prefix: head + inner.prefix };\n }\n }\n return { space, prefix: \"\" };\n}\n\n/** This function gives the prefix of the innermost part of each stage. */\nconst prefixes = (space: StrategySpace): Map<string, string> => new Map(space.stages.map((s) => [s.name, partOf(space, s.name).prefix]));\n\nconst describe = (c: SpaceConstraint): string => {\n const ref = (r: OptionRef): string => `${r.stage}=${r.option ?? \"null\"}`;\n return \"not\" in c.then ? `if ${ref(c.if)} then not ${ref(c.then.not)}` : `if ${ref(c.if)} then ${ref(c.then)}`;\n};\n\n/** This function gives the problems of the range and the default of one param. */\nfunction paramProblems(p: SpaceParam, at: string): Problem[] {\n const out: Problem[] = [];\n if (isNumeric(p)) {\n const { min, max, step } = p;\n if (typeof min !== \"number\" || typeof max !== \"number\" || !Number.isFinite(min) || !Number.isFinite(max)) {\n out.push([\"range\", `${at} has no finite min and max`]);\n return out;\n }\n if (min > max) out.push([\"range\", `${at} has an empty range: the min ${min} is more than the max ${max}`]);\n if (p.kind === \"int\" && (!Number.isInteger(min) || !Number.isInteger(max))) out.push([\"range\", `${at} is an int with a min or a max that is not whole`]);\n if (step !== undefined && (!Number.isFinite(step) || step <= 0 || (p.kind === \"int\" && !Number.isInteger(step))))\n out.push([\"range\", `${at} has the step ${step}, which is not a ${p.kind === \"int\" ? \"whole \" : \"\"}number above 0`]);\n if (p.scale === \"log\" && min <= 0) out.push([\"scale\", `${at} has the scale log with the min ${min}, which is not above 0`]);\n } else {\n if (p.scale !== undefined) out.push([\"scale\", `${at} is a ${p.kind} param with a scale`]);\n if (p.kind === \"enum\") {\n if (!Array.isArray(p.values) || p.values.length === 0) out.push([\"values\", `${at} is an enum without values`]);\n else {\n const seen = new Set<unknown>();\n for (const v of p.values) {\n if (seen.has(v)) out.push([\"duplicate\", `${at} has the value ${show(v)} two times`]);\n seen.add(v);\n }\n }\n }\n }\n if (out.length === 0) {\n const problem = valueProblem(p, p.default);\n if (problem !== undefined) out.push([\"default\", `the default of ${at} is not in its range: ${problem}`]);\n }\n return out;\n}\n\n/** This function gives the problems of one stage option. */\nfunction optionProblems(stage: SpaceStage, o: StageOption): Problem[] {\n const out: Problem[] = [];\n const at = `the option ${stage.name}.${o.id}`;\n if (!Array.isArray(o.params)) return [[\"config\", `${at} has no list of params`]];\n const names = o.params.map((p) => p.name);\n o.params.forEach((p, i) => {\n const pat = `the param ${stage.name}.${o.id}.${p.name}`;\n if (names.indexOf(p.name) !== i) out.push([\"duplicate\", `${at} has the param ${p.name} two times`]);\n out.push(...paramProblems(p, pat));\n if (p.when === undefined) return;\n const j = names.indexOf(p.when.param);\n if (j < 0) out.push([\"unknown\", `${pat} has a when with the unknown param ${p.when.param}`]);\n else if (j >= i) out.push([\"when\", `${pat} has a when with the param ${p.when.param}, which does not come before it`]);\n else if (!Array.isArray(p.when.in) || p.when.in.length === 0) out.push([\"when\", `${pat} has a when with no values`]);\n else for (const v of p.when.in) {\n const problem = valueProblem(o.params[j]!, v);\n if (problem !== undefined) out.push([\"when\", `${pat} has a when value that is not a value of ${p.when.param}: ${problem}`]);\n }\n });\n if (o.supports !== undefined) out.push(...supportsProblems(o.supports, at));\n if (o.members !== undefined) {\n const { min, max, ordered } = o.members;\n const noList = min === 0 && max === 0;\n if (!Number.isInteger(min) || !Number.isInteger(max) || (!noList && (min < 1 || min > max)) || typeof ordered !== \"boolean\")\n out.push([\"members\", `${at} has a member rule without whole counts 1 <= min <= max or min = max = 0, and a boolean ordered`]);\n if (noList && (o.members.pool !== undefined || o.members.view !== undefined))\n out.push([\"members\", `${at} has no member list, so its member rule cannot have a pool or a view`]);\n const pool: unknown = o.members.pool;\n if (pool !== undefined && (!Array.isArray(pool) || pool.length === 0 || !pool.every((entry: unknown) => Array.isArray(entry))))\n out.push([\"pool\", `${at} has a pool that is not a list of one or more member lists`]);\n const view: unknown = o.members.view;\n if (view !== undefined && view !== \"bounds\") out.push([\"view\", `${at} has the member view ${show(view)}, not \"bounds\"`]);\n }\n return out;\n}\n\n/** This function gives the problems of the `supports` of an option. */\nfunction supportsProblems(supports: unknown, at: string): Problem[] {\n if (!isObject(supports)) return [[\"shape\", `the supports of ${at} are not an object`]];\n const shape = supports[\"shape\"];\n if (shape === undefined) return [];\n if (!Array.isArray(shape) || shape.length === 0) return [[\"shape\", `${at} supports no shape kind. Remove shape to support each kind`]];\n const out: Problem[] = [];\n shape.forEach((k: unknown, i) => {\n if (!isShapeKind(k)) out.push([\"shape\", `${at} supports the shape kind ${show(k)}, which is not one of ${SHAPE_KIND_IDS.join(\", \")}`]);\n else if (shape.indexOf(k) !== i) out.push([\"duplicate\", `${at} has the shape kind ${k} two times`]);\n });\n return out;\n}\n\n/** This function tells if an option supports each shape kind of the list. */\nconst supportsShapes = (o: StageOption, shapes: readonly ShapeKind[] | undefined): boolean =>\n shapes === undefined || o.supports?.shape === undefined || shapes.every((k) => o.supports!.shape!.includes(k));\n\n/** The shape kinds that the members of an option with `view: \"bounds\"` see: a bounding box is a `rect`. */\nconst BOUNDS_VIEW: readonly ShapeKind[] = /* @__PURE__ */ Object.freeze([\"rect\"] as const);\n\n/**\n * This function gives the shape kinds of the members of a meta option. With `view: \"bounds\"`, a list with a kind becomes `BOUNDS_VIEW`.\n * Without a list, or with an empty list, the value does not change.\n */\nconst memberShapes = (rule: MemberRule, shapes: readonly ShapeKind[] | undefined): readonly ShapeKind[] | undefined =>\n rule.view === \"bounds\" && shapes !== undefined && shapes.length > 0 ? BOUNDS_VIEW : shapes;\n\n/** This function tells if two lists have the same shape kinds. */\nconst sameKinds = (a: readonly ShapeKind[], b: readonly ShapeKind[]): boolean => a.every((k) => b.includes(k)) && b.every((k) => a.includes(k));\n\n/** This function gives the problems of the params of one stage choice. */\nfunction choiceParamProblems(o: StageOption, params: unknown, at: string): Problem[] {\n if (params !== undefined && !isObject(params)) return [[\"config\", `the params of ${at} are not an object`]];\n const given = (params ?? {}) as Values;\n const out: Problem[] = [];\n for (const key of Object.keys(given)) if (!o.params.some((p) => p.name === key)) out.push([\"unknown\", `${at} has the unknown param ${key}`]);\n const values: Values = {};\n for (const p of o.params) {\n const has = Object.hasOwn(given, p.name);\n if (!isActive(p, values)) {\n if (has) out.push([\"inactive\", `${at} sets the param ${p.name}, which is not active`]);\n continue;\n }\n const v = has ? given[p.name] : p.default;\n const problem = valueProblem(p, v);\n if (problem !== undefined) out.push([\"param\", `the param ${p.name} of ${at} is not in its range: ${problem}`]);\n else values[p.name] = normalize(p, v as ParamValue);\n }\n return out;\n}\n\n/** This function gives the problems of a config of a space. A member of a meta option has `member: true`. */\nfunction configProblems(space: StrategySpace, config: unknown, member: boolean, shapes?: readonly ShapeKind[]): Problem[] {\n if (!isObject(config) || !isObject(config[\"stages\"])) return [[\"config\", \"the config is not an object with stages\"]];\n const out: Problem[] = [];\n const stages = config[\"stages\"];\n if (config[\"space\"] !== space.engine) out.push([\"space\", `the space of the config is ${show(config[\"space\"])}, not ${show(space.engine)}`]);\n for (const key of Object.keys(stages)) if (!space.stages.some((s) => s.name === key)) out.push([\"unknown\", `the config has the unknown stage ${key}`]);\n const optionOf = (s: SpaceStage): StageOption | undefined => {\n const c = stages[s.name];\n return isObject(c) ? s.options.find((o) => o.id === c[\"option\"]) : undefined;\n };\n const prefix = prefixes(space);\n const metaStage = new Map<string, string>();\n for (const s of space.stages) {\n if (optionOf(s)?.members === undefined) continue;\n const p = prefix.get(s.name)!;\n if (metaStage.has(p)) out.push([\"meta\", `the stages ${metaStage.get(p)} and ${s.name} both have a meta option`]);\n else metaStage.set(p, s.name);\n }\n const chosen = new Map<string, string | null>();\n for (const s of space.stages) {\n const c = Object.hasOwn(stages, s.name) ? stages[s.name] : undefined;\n const meta = metaStage.get(prefix.get(s.name)!);\n chosen.set(s.name, null);\n if (c === undefined || c === null) {\n if (!s.optional && meta === undefined) out.push([\"missing\", `the config has no option for the stage ${s.name}`]);\n continue;\n }\n if (!isObject(c) || typeof c[\"option\"] !== \"string\") {\n out.push([\"config\", `the choice of the stage ${s.name} has no option`]);\n continue;\n }\n const o = s.options.find((x) => x.id === c[\"option\"]);\n if (o === undefined) {\n out.push([\"unknown\", `the stage ${s.name} has no option ${c[\"option\"]}`]);\n continue;\n }\n chosen.set(s.name, o.id);\n const at = `the option ${s.name}.${o.id}`;\n if (!supportsShapes(o, shapes)) {\n const missing = shapes!.filter((k) => !o.supports!.shape!.includes(k));\n out.push([\"shape\", `${at} supports the shape kinds ${o.supports!.shape!.join(\", \")}, not ${missing.join(\", \")}`]);\n }\n if (meta !== undefined && meta !== s.name) out.push([\"meta\", `the stage ${s.name} is set, but the meta option of ${meta} replaces the other stages of its part`]);\n out.push(...choiceParamProblems(o, c[\"params\"], at));\n if (o.members === undefined) {\n if (c[\"members\"] !== undefined) out.push([\"members\", `${at} is not a meta option, but the config gives members`]);\n continue;\n }\n if (member) {\n out.push([\"depth\", `a member has the meta option ${s.name}.${o.id}. The depth of a meta config is 1`]);\n continue;\n }\n out.push(...memberProblems(partOf(space, s.name).space, o.members, c[\"members\"], at, memberShapes(o.members, shapes)));\n }\n for (const c of space.constraints ?? []) if (!holds(c, chosen)) out.push([\"constraint\", `the config breaks the constraint ${describe(c)}`]);\n return out;\n}\n\n/** This function gives the problems of the members of a meta option. `part` is the space of the members. */\nfunction memberProblems(part: StrategySpace, rule: MemberRule, members: unknown, at: string, shapes?: readonly ShapeKind[]): Problem[] {\n if (!Array.isArray(members)) return [[\"members\", `${at} is a meta option without a list of members`]];\n const out: Problem[] = [];\n if (members.length < rule.min || members.length > rule.max) out.push([\"members\", `${at} has ${members.length} members, not ${rule.min} to ${rule.max}`]);\n const ids = new Map<string, number>();\n members.forEach((m: unknown, k) => {\n const inner = configProblems(part, m, true, shapes);\n for (const [claim, detail] of inner) out.push([claim, `the member ${k} of ${at}: ${detail}`]);\n if (inner.length > 0) return;\n const id = idOf(canonicalOf(part, m as StrategyConfig, true));\n if (ids.has(id)) out.push([\"duplicate\", `the members ${ids.get(id)} and ${k} of ${at} are the same config ${id}`]);\n else ids.set(id, k);\n });\n if (rule.pool !== undefined && out.length === 0) {\n const key = memberKey(part, rule, members as readonly StrategyConfig[]);\n if (!rule.pool.some((entry) => memberKey(part, rule, entry) === key))\n out.push([\"pool\", `${at} has a member list that is not in its pool of ${rule.pool.length} ${rule.pool.length === 1 ? \"list\" : \"lists\"}`]);\n }\n return out;\n}\n\n/** This function gives the key of a good member list: the `configId` of each member, sorted when the rule is not ordered. */\nfunction memberKey(part: StrategySpace, rule: MemberRule, members: readonly StrategyConfig[]): string {\n const ids = members.map((m) => idOf(canonicalOf(part, m, true)));\n if (!rule.ordered) ids.sort();\n return ids.join(\",\");\n}\n\n/** This function gives the problems of the pool of a meta option of a good space. `part` is the space of the members. */\nfunction poolProblems(part: StrategySpace, rule: MemberRule, at: string): Problem[] {\n const out: Problem[] = [];\n const keys = new Map<string, number>();\n const plain: MemberRule = { min: rule.min, max: rule.max, ordered: rule.ordered };\n (rule.pool ?? []).forEach((entry, j) => {\n const inner = memberProblems(part, plain, entry, `the pool entry ${j} of ${at}`);\n out.push(...inner);\n if (inner.length > 0) return;\n const key = memberKey(part, rule, entry);\n if (keys.has(key)) out.push([\"duplicate\", `the pool entries ${keys.get(key)} and ${j} of ${at} have the same members`]);\n else keys.set(key, j);\n });\n return out;\n}\n\n/** This function tells if a member list fits a space: each member is a good config of the space. A shape filter removes options from the space. */\nconst fits = (part: StrategySpace, entry: readonly StrategyConfig[]): boolean => entry.every((m) => configProblems(part, m, true).length === 0);\n\nconst toBreaks = (problems: readonly Problem[], inputs: readonly string[] = []): ClaimBreak[] => problems.map(([claim, detail]) => ({ claim, detail, inputs }));\n\n/**\n * This function checks one config of a space. It gives one break for each problem. An empty list tells that the config is good.\n * The `claim` of a break is the kind of the problem, for example `missing`, `unknown`, `inactive`, `param`, `constraint`, `members` or `depth`.\n *\n * A member list that is not an entry of the `pool` of its option gives the claim `pool`.\n * With `shapes`, an option that does not support a kind of the list gives the claim `shape`. A member of a meta option gets the same check.\n * A member of an option with `view: \"bounds\"` gets the check with the kind `rect`.\n */\nexport function checkConfig(space: StrategySpace, config: StrategyConfig, options: ShapeFilter = {}): ClaimBreak[] {\n return toBreaks(configProblems(space, config, false, options.shapes));\n}\n\n/**\n * This function checks a space. It gives one break for each problem. An empty list tells that the space is good.\n * It finds duplicate names, empty ranges, defaults out of range, enums without values, bad log scales, unknown names and bad named configs.\n * It also checks each entry of a `pool`: the count of its members, each member and a repeated entry.\n * The `inputs` of a break of a named config have the name of the config.\n */\nexport function checkSpace(space: StrategySpace): ClaimBreak[] {\n if (!isObject(space) || !Array.isArray(space.stages)) return toBreaks([[\"schema\", \"the space is not an object with stages\"]]);\n const out: Problem[] = [];\n if (space.schema !== STRATEGY_SPACE_SCHEMA) out.push([\"schema\", `the schema is ${show(space.schema)}, not ${STRATEGY_SPACE_SCHEMA}`]);\n if (typeof space.engine !== \"string\" || space.engine === \"\") out.push([\"schema\", \"the space has no engine name\"]);\n if (typeof space.version !== \"string\") out.push([\"schema\", \"the space has no version\"]);\n const names = space.stages.map((s) => s.name);\n space.stages.forEach((s, i) => {\n if (names.indexOf(s.name) !== i) out.push([\"duplicate\", `the space has the stage ${s.name} two times`]);\n const options: readonly StageOption[] = Array.isArray(s.options) ? s.options : [];\n if (options.length === 0) {\n out.push([\"options\", `the stage ${s.name} has no options`]);\n return;\n }\n const ids = options.map((o) => o.id);\n options.forEach((o, j) => {\n if (ids.indexOf(o.id) !== j) out.push([\"duplicate\", `the stage ${s.name} has the option ${o.id} two times`]);\n out.push(...optionProblems(s, o));\n });\n if (!s.optional && options.every((o) => o.members !== undefined)) out.push([\"meta\", `the stage ${s.name} is not optional and has only meta options, so no base config exists`]);\n });\n const known = (ref: OptionRef, at: string): void => {\n const s = space.stages.find((x) => x.name === ref?.stage);\n if (s === undefined) out.push([\"unknown\", `${at} has the unknown stage ${ref?.stage}`]);\n else if (ref.option === null ? !s.optional : !s.options.some((o) => o.id === ref.option))\n out.push([\"unknown\", `${at} has the unknown option ${s.name}=${ref.option ?? \"null\"}`]);\n };\n (space.constraints ?? []).forEach((c, k) => {\n known(c.if, `the constraint ${k}`);\n known(\"not\" in c.then ? c.then.not : c.then, `the constraint ${k}`);\n });\n for (const part of space.parts ?? []) for (const b of checkSpace(part)) out.push([b.claim, `the part ${part.engine}: ${b.detail}`]);\n if (space.parts !== undefined)\n for (const s of space.stages) if (partOf(space, s.name).prefix === \"\") out.push([\"parts\", `the stage ${s.name} is not a stage of a part`]);\n const breaks = toBreaks(out);\n if (breaks.length > 0) return breaks;\n for (const s of space.stages)\n for (const o of s.options) if (o.members?.pool !== undefined) breaks.push(...toBreaks(poolProblems(partOf(space, s.name).space, o.members, `the option ${s.name}.${o.id}`)));\n if (breaks.length > 0) return breaks;\n for (const [name, config] of Object.entries(space.named ?? {}))\n breaks.push(...toBreaks(configProblems(space, config, false).map(([c, d]) => [c, `the named config ${name}: ${d}`] as const), [name]));\n return breaks;\n}\n\n/** This function gives the canonical form of a config that is known to be good. */\nfunction canonicalOf(space: StrategySpace, config: StrategyConfig, member: boolean): StrategyConfig {\n const stages: Record<string, StageChoice | null> = {};\n for (const s of space.stages) {\n const c = Object.hasOwn(config.stages, s.name) ? config.stages[s.name] : undefined;\n if (c === undefined || c === null) {\n stages[s.name] = null;\n continue;\n }\n const o = s.options.find((x) => x.id === c.option)!;\n const given = c.params ?? {};\n const params: Values = {};\n for (const p of o.params) if (isActive(p, params)) params[p.name] = normalize(p, Object.hasOwn(given, p.name) ? given[p.name]! : p.default);\n if (o.members === undefined || member) {\n stages[s.name] = { option: o.id, params };\n continue;\n }\n const part = partOf(space, s.name).space;\n const members = (c.members ?? []).map((m) => canonicalOf(part, m, true));\n if (!o.members.ordered) members.sort((a, b) => (idOf(a) < idOf(b) ? -1 : idOf(a) > idOf(b) ? 1 : 0));\n stages[s.name] = { option: o.id, params, members };\n }\n return { space: space.engine, stages };\n}\n\nconst idOf = (canonical: StrategyConfig): string => sha256Hex(canonicalJson(canonical)).slice(0, 16);\n\n/**\n * This function gives the canonical form of a config: each stage of the space, the active params only, the defaults, and stable numbers.\n * An unused optional stage is `null`. The members of an unordered meta option are sorted by their `configId`.\n * It throws an `Error` for a config with a break of `checkConfig`.\n */\nexport function canonicalConfig(space: StrategySpace, config: StrategyConfig): StrategyConfig {\n const problems = configProblems(space, config, false);\n if (problems.length > 0) throw new Error(`The config of the space ${space.engine} is not good: ${problems.map((p) => p[1]).join(\"; \")}.`);\n return canonicalOf(space, config, false);\n}\n\n/**\n * This function gives the id of a config: the first 16 hex characters of the SHA-256 of `canonicalJson` of `canonicalConfig`.\n * Two spellings of one config get one id. The version of the space is not part of the id.\n */\nexport function configId(space: StrategySpace, config: StrategyConfig): string {\n return idOf(canonicalConfig(space, config));\n}\n\n/** This function throws an `Error` for a space with a break of `checkSpace`. */\nfunction assertSpace(space: StrategySpace): void {\n const breaks = checkSpace(space);\n if (breaks.length > 0) throw new Error(`The space ${String(space?.engine)} is not good: ${breaks.map((b) => b.detail).join(\"; \")}.`);\n}\n\n/** This function throws a `RangeError` when a value is not a whole number of `min` or more. */\nfunction assertWhole(value: number, name: string, min: number): void {\n if (!Number.isInteger(value) || value < min) throw new RangeError(`The option ${name} is ${value}, not a whole number of ${min} or more.`);\n}\n\n/** This function gives the last point of the step grid of a numeric param. */\nfunction lastPoint(p: SpaceParam): number {\n const min = p.min!;\n const step = p.step ?? (p.kind === \"int\" ? 1 : undefined);\n if (step === undefined) return p.max!;\n return min + Math.floor((p.max! - min) / step + 1e-9) * step;\n}\n\n/** This function moves a value of a numeric param onto its step and into its range. */\nfunction snap(p: SpaceParam, x: number, digits: number): number {\n const min = p.min!;\n const step = p.step ?? (p.kind === \"int\" ? 1 : undefined);\n let v = step === undefined ? x : min + Math.round((x - min) / step) * step;\n v = Math.min(lastPoint(p), Math.max(min, v));\n return p.kind === \"int\" ? zero(Math.round(v)) : Math.min(p.max!, Math.max(min, realForm(v, digits)));\n}\n\n/** This function gives the point at the fraction `t` of the range of a numeric param, on its scale. */\nfunction at01(p: SpaceParam, t: number): number {\n const min = p.min!;\n const max = p.max!;\n if (p.scale === \"log\") return Math.exp(Math.log(min) + t * (Math.log(max) - Math.log(min)));\n return min + t * (max - min);\n}\n\n/**\n * This function gives the grid values of one param, in increasing order. An `enum` gives its values, and a `bool` gives `false` and `true`.\n * With 1 level, a numeric param gives its default. With k levels, it gives k points from `min` to `max` on its scale and step, without repeats.\n */\nexport function paramLevels(param: SpaceParam, levels: number): ParamValue[] {\n assertWhole(levels, \"levels\", 1);\n if (param.kind === \"bool\") return [false, true];\n if (param.kind === \"enum\") return [...(param.values ?? [])];\n if (levels === 1 || param.min === param.max) return [normalize(param, param.default)];\n const out: number[] = [];\n const steps = param.kind === \"int\" || param.step !== undefined ? Math.round((lastPoint(param) - param.min!) / (param.step ?? 1)) + 1 : Infinity;\n if (steps <= levels && param.scale !== \"log\") {\n for (let j = 0; j < steps; j++) out.push(snap(param, param.min! + j * (param.step ?? 1), 12));\n } else {\n for (let j = 0; j < levels; j++) out.push(snap(param, at01(param, j / (levels - 1)), 12));\n }\n return [...new Set(out)];\n}\n\n/** This function tells if a later param of the list reads a param in its `when`. */\nconst readLater = (params: readonly SpaceParam[], i: number): boolean => params.slice(i + 1).some((q) => q.when?.param === params[i]!.name);\n\n/** This function gives the count of the grid assignments of the params of an option, with only the active params. */\nfunction countParams(params: readonly SpaceParam[], levels: number, i = 0, values: Values = {}): bigint {\n if (i === params.length) return 1n;\n const p = params[i]!;\n if (!isActive(p, values)) return countParams(params, levels, i + 1, values);\n const lv = paramLevels(p, levels);\n if (!readLater(params, i)) return BigInt(lv.length) * countParams(params, levels, i + 1, values);\n let sum = 0n;\n for (const v of lv) sum += countParams(params, levels, i + 1, { ...values, [p.name]: v });\n return sum;\n}\n\n/** This function gives the grid assignments of the params of an option, in a stable order. */\nfunction* gridParams(params: readonly SpaceParam[], levels: number, i = 0, values: Values = {}): Generator<Values> {\n if (i === params.length) {\n yield { ...values };\n return;\n }\n const p = params[i]!;\n if (!isActive(p, values)) {\n yield* gridParams(params, levels, i + 1, values);\n return;\n }\n for (const v of paramLevels(p, levels)) yield* gridParams(params, levels, i + 1, { ...values, [p.name]: v });\n}\n\n/** One combination of options of a space, with its count of grid points. */\ninterface Combo {\n readonly choices: Choices;\n readonly base: boolean;\n /** The count of the grid points, or `null` when the count is more than the limit. */\n readonly weight: bigint | null;\n}\n\nconst optionIds = (choices: Choices): Map<string, string | null> => new Map([...choices].map(([k, o]) => [k, o?.id ?? null]));\nconst keeps = (space: StrategySpace, choices: Choices): boolean => (space.constraints ?? []).every((c) => holds(c, optionIds(choices)));\n\n/**\n * This function gives the constraints of a space for each stage: a constraint goes to the last stage that it names.\n * The last list holds each constraint that names a stage outside the space, so a walk examines it at the end.\n */\nfunction constraintsByStage(space: StrategySpace): readonly (readonly SpaceConstraint[])[] {\n const place = new Map(space.stages.map((s, i) => [s.name, i]));\n const lists: SpaceConstraint[][] = Array.from({ length: space.stages.length + 1 }, () => []);\n for (const c of space.constraints ?? []) {\n const named = [c.if.stage, \"not\" in c.then ? c.then.not.stage : c.then.stage];\n lists[Math.max(...named.map((name) => place.get(name) ?? space.stages.length))]!.push(c);\n }\n return lists;\n}\n\n/** This function gives the count of the member lists of a meta option without a pool from `base` base configs, or `null` above `limit`. */\nfunction memberLists(base: bigint, rule: MemberRule, limit: bigint): bigint | null {\n let sum = 0n;\n for (let m = rule.min; m <= rule.max; m++) {\n let n = 1n;\n for (let k = 0; k < m; k++) {\n n = (n * (base - BigInt(k))) / (rule.ordered ? 1n : BigInt(k + 1));\n if (n <= 0n) break;\n }\n if (n <= 0n) break;\n sum += n;\n if (sum > limit) return null;\n }\n return sum;\n}\n\n/** This function multiplies two counts. A `null` count or a product above `limit` gives `null`. */\nconst times = (a: bigint | null, b: bigint | null, limit: bigint): bigint | null => (a === null || b === null ? null : a * b > limit ? null : a * b);\n\n/**\n * This function gives the combinations of options of a space and their grid counts.\n * A product space joins the combinations of its parts. Each combination keeps the constraints.\n */\nfunction combos(space: StrategySpace, levels: number, meta: boolean, limit: bigint): Combo[] {\n if (space.parts !== undefined && space.parts.length > 0) {\n let acc: Combo[] = [{ choices: new Map(), base: true, weight: 1n }];\n for (const part of space.parts) {\n const head = `${part.engine}.`;\n const own = combos(part, levels, meta, limit);\n const next: Combo[] = [];\n for (const a of acc)\n for (const b of own) {\n const choices = new Map(a.choices);\n for (const [k, o] of b.choices) choices.set(head + k, o);\n const base = a.base && b.base;\n next.push({ choices, base, weight: base ? a.weight! * b.weight! : times(a.weight, b.weight, limit) });\n }\n acc = next;\n }\n return acc.filter((c) => keeps(space, c.choices));\n }\n const counts = new Map<StageOption, bigint>();\n const countOf = (o: StageOption): bigint => {\n if (!counts.has(o)) counts.set(o, countParams(o.params, levels));\n return counts.get(o)!;\n };\n const out: Combo[] = [];\n const stages = space.stages;\n // A space can have hundreds of constraints. Each one is examined at its last stage, so the walk leaves a branch at the first break.\n const checks = constraintsByStage(space);\n const ids = new Map<string, string | null>();\n const walk = (i: number, choices: Map<string, StageOption | null>, weight: bigint): void => {\n if (i === stages.length) {\n if (checks[i]!.every((c) => holds(c, ids))) out.push({ choices: new Map(choices), base: true, weight });\n return;\n }\n const s = stages[i]!;\n const list: (StageOption | null)[] = s.options.filter((o) => o.members === undefined);\n if (s.optional) list.push(null);\n for (const o of list) {\n choices.set(s.name, o);\n ids.set(s.name, o?.id ?? null);\n if (checks[i]!.every((c) => holds(c, ids))) walk(i + 1, choices, o === null ? weight : weight * countOf(o));\n }\n choices.delete(s.name);\n ids.delete(s.name);\n };\n walk(0, new Map(), 1n);\n if (!meta) return out;\n const base = out.reduce((sum, c) => sum + c.weight!, 0n);\n for (const s of stages)\n for (const o of s.options) {\n if (o.members === undefined) continue;\n const choices = new Map<string, StageOption | null>(stages.map((x) => [x.name, x === s ? o : null]));\n const own = memberSpaces.get(o);\n const from = own === undefined ? base : baseCount(own, levels, limit);\n const lists = o.members.pool === undefined ? memberLists(from, o.members, limit) : BigInt(o.members.pool.length);\n if (keeps(space, choices)) out.push({ choices, base: false, weight: times(countOf(o), lists, limit) });\n }\n return out;\n}\n\n/**\n * This function gives the count of the grid points of a space, with `levels` levels for each numeric param.\n * It counts only the active params and the combinations that keep the constraints. It gives the meta configs apart.\n * A meta option with a `pool` counts each entry of the pool one time.\n * With `shapes`, it counts only the options that support each kind of the list.\n */\nexport function spaceSize(space: StrategySpace, options: SpaceSizeOptions): SpaceSize {\n assertSpace(space);\n assertWhole(options.levels, \"levels\", 1);\n assertShapes(options.shapes);\n return sizeOf(restrict(space, options.shapes), options.levels, options.maxMeta ?? 10n ** 18n);\n}\n\n/**\n * This function gives the space with only the options that support each shape kind of `shapes`. Without `shapes`, it gives the same space.\n * A stage can lose all of its options. Then the space has no config with that stage.\n * A pool keeps only the entries whose members fit the smaller space. A meta option without such an entry goes out.\n *\n * The members of an option with `view: \"bounds\"` come from the space for the kinds of `memberShapes`. `memberSpaces` keeps that space.\n */\nfunction restrict(space: StrategySpace, shapes: readonly ShapeKind[] | undefined): StrategySpace {\n if (shapes === undefined) return space;\n const kept: StrategySpace = {\n ...space,\n stages: space.stages.map((s) => ({ ...s, options: s.options.filter((o) => supportsShapes(o, shapes)) })),\n ...(space.parts === undefined ? {} : { parts: space.parts.map((p) => restrict(p, shapes)) }),\n };\n const withPool = (s: SpaceStage, o: StageOption): StageOption[] => {\n if (o.members === undefined) return [o];\n const inner = memberShapes(o.members, shapes)!;\n const own = sameKinds(inner, shapes) ? undefined : restrict(partOf(space, s.name).space, inner);\n const mark = (option: StageOption): StageOption[] => {\n if (own !== undefined) memberSpaces.set(option, own);\n return [option];\n };\n if (o.members.pool === undefined) return own === undefined ? [o] : mark({ ...o });\n const part = own ?? partOf(kept, s.name).space;\n const pool = o.members.pool.filter((entry) => fits(part, entry));\n return pool.length === 0 ? [] : mark({ ...o, members: { ...o.members, pool } });\n };\n return { ...kept, stages: kept.stages.map((s) => ({ ...s, options: s.options.flatMap((o) => withPool(s, o)) })) };\n}\n\n/** The space of the members of a meta option of a restricted space, when it is not the part of the option. Only `view: \"bounds\"` makes such a space. */\nconst memberSpaces = /* @__PURE__ */ new WeakMap<StageOption, StrategySpace>();\n\n/**\n * This function tells if an option of a restricted space has a member list. A base option and a meta option with a `pool` have one.\n * A different meta option has one when its members have a base config. `restrict` keeps only the pool entries that fit.\n */\nconst hasMembers = (space: StrategySpace, stage: string, o: StageOption): boolean =>\n o.members === undefined || o.members.max === 0 || o.members.pool !== undefined || combos(memberSpaces.get(o) ?? partOf(space, stage).space, 1, false, 0n).length > 0;\n\n/** This function tells if a restricted space has a config. A base config counts. With `meta`, a meta config counts when each of its meta options has a member list. */\nconst hasConfig = (space: StrategySpace, meta: boolean): boolean =>\n combos(space, 1, meta, 0n).some((c) => c.base || [...c.choices].every(([stage, o]) => o === null || hasMembers(space, stage, o)));\n\n/** This function gives the error of a sample of a space that has no config for the shape kinds `shapes`. `kept` is the restricted space. */\nfunction noSample(space: StrategySpace, kept: StrategySpace, shapes: readonly ShapeKind[], meta: boolean): RangeError {\n const list = (names: readonly string[], one: string, more: string): string => (names.length === 1 ? `${one} ${names[0]}` : `${more} ${names.join(\", \")}`);\n const empty = kept.stages.filter((s) => !s.optional && !s.options.some((o) => meta || o.members === undefined)).map((s) => s.name);\n const removed = !meta\n ? []\n : space.stages.flatMap((s) =>\n s.options\n .filter((o) => o.members !== undefined && o.members.view !== \"bounds\" && supportsShapes(o, shapes))\n .filter((o) => {\n const own = kept.stages.find((x) => x.name === s.name)?.options.find((x) => x.id === o.id);\n return own === undefined || !hasMembers(kept, s.name, own);\n })\n .map((o) => `${s.name}.${o.id}`),\n );\n let text = `The space ${space.engine} has no config for a sample with the shape kinds ${shapes.join(\", \")}.`;\n if (empty.length > 0) text += ` ${list(empty, \"The stage\", \"The stages\")} ${empty.length === 1 ? \"has\" : \"have\"} no option for these kinds.`;\n if (removed.length > 0)\n text += ` ${list(removed, \"The meta option\", \"The meta options\")} ${removed.length === 1 ? \"has\" : \"have\"} no member config for these kinds. Set members.view to \"bounds\" when the members see only the bounding boxes.`;\n if (empty.length === 0 && removed.length === 0) text += \" The constraints remove each config.\";\n return new RangeError(text);\n}\n\n/** This function gives a constraint in words, for the reason of an error. */\nfunction constraintText(c: SpaceConstraint): string {\n const ref = (r: OptionRef): string => `${r.stage} ${r.option === null ? \"has no option\" : `is ${r.option}`}`;\n return \"not\" in c.then ? `if ${ref(c.if)}, then not ${ref(c.then.not)}` : `if ${ref(c.if)}, then ${ref(c.then)}`;\n}\n\n/**\n * This function throws a `RangeError` for a bad `fixed` option of a sample. A stage or an option that the space does not have is bad.\n * A meta option without `meta: \"sample\"` is bad, and so are two fixed options that a constraint forbids.\n */\nfunction assertFixed(space: StrategySpace, fixed: Readonly<Record<string, string>>, meta: boolean): void {\n for (const [stage, id] of Object.entries(fixed)) {\n const s = space.stages.find((x) => x.name === stage);\n if (s === undefined) throw new RangeError(`The option fixed names the stage ${stage}, and the space ${space.engine} has no such stage.`);\n const o = s.options.find((x) => x.id === id);\n if (o === undefined) throw new RangeError(`The option fixed names the option ${String(id)} of the stage ${stage}, and the stage has no such option.`);\n if (o.members !== undefined && !meta) throw new RangeError(`The option fixed names the meta option ${stage}.${id}, and a sample with meta skip has no meta option. Set meta to \"sample\".`);\n }\n const ids = new Map<string, string | null>(Object.entries(fixed));\n const other = (c: SpaceConstraint): string => (\"not\" in c.then ? c.then.not.stage : c.then.stage);\n const broken = (space.constraints ?? []).filter((c) => ids.has(c.if.stage) && ids.has(other(c)) && !holds(c, ids));\n if (broken.length > 0) {\n const names = Object.entries(fixed).map(([stage, id]) => `${stage}.${id}`);\n throw new RangeError(`The constraints of the space ${space.engine} forbid the fixed options ${names.join(\", \")}. The broken constraints: ${broken.map(constraintText).join(\"; \")}.`);\n }\n}\n\n/**\n * This function gives the restricted space `kept` with only the fixed option at each fixed stage. A fixed stage that was optional stops being optional.\n * A meta option of another stage of the part of a fixed stage goes out. A sample gives no option to the other stages of the part of its meta option.\n */\nfunction fixStages(space: StrategySpace, kept: StrategySpace, fixed: Readonly<Record<string, string>>, shapes: readonly ShapeKind[] | undefined): StrategySpace {\n const prefix = prefixes(kept);\n const parts = new Set(Object.keys(fixed).map((stage) => prefix.get(stage)!));\n const stages = kept.stages.map((s) => {\n const id = fixed[s.name];\n if (id === undefined) return parts.has(prefix.get(s.name)!) ? { ...s, options: s.options.filter((o) => o.members === undefined) } : s;\n // A fixed meta option takes its members from the space before the fix, because the fix removes each base config of its own stage.\n const options = s.options.filter((o) => o.id === id).map((o) => (o.members === undefined ? o : withMemberSpace(o, memberSpaces.get(o) ?? partOf(kept, s.name).space)));\n if (options.length === 0) throw new RangeError(`The fixed option ${s.name}.${id} of the space ${space.engine} does not support the shape kinds ${(shapes ?? []).join(\", \")}.`);\n return { ...s, options, optional: false };\n });\n return { ...kept, stages };\n}\n\n/** This function gives a copy of a meta option whose members come from `members`. */\nfunction withMemberSpace(o: StageOption, members: StrategySpace): StageOption {\n const copy = { ...o };\n memberSpaces.set(copy, members);\n return copy;\n}\n\n/** This function gives the error of a sample whose fixed options keep each constraint between them. The constraints with the other stages remove each config. */\nfunction noFixedSample(space: StrategySpace, fixed: Readonly<Record<string, string>>): RangeError {\n const names = Object.entries(fixed).map(([stage, id]) => `${stage}.${id}`);\n return new RangeError(\n `The space ${space.engine} has no config with the fixed options ${names.join(\", \")}. No constraint between two fixed options breaks, so the constraints with the other stages remove each config.`,\n );\n}\n\n/** This function gives the count of the base configs of a space that is known to be good. */\nconst baseCount = (space: StrategySpace, levels: number, limit: bigint): bigint => combos(space, levels, false, limit).reduce((sum, c) => sum + c.weight!, 0n);\n\n/** This function throws a `RangeError` for a list of shape kinds with a kind that is not declared. */\nfunction assertShapes(shapes: readonly ShapeKind[] | undefined): void {\n if (shapes === undefined) return;\n if (!Array.isArray(shapes)) throw new RangeError(\"The option shapes is not a list of shape kinds.\");\n for (const k of shapes) if (!isShapeKind(k)) throw new RangeError(`The shape kind ${show(k)} is not one of ${SHAPE_KIND_IDS.join(\", \")}.`);\n}\n\n/** This function gives the count of the grid points of a space that is known to be good. */\nfunction sizeOf(space: StrategySpace, levels: number, limit: bigint): SpaceSize {\n let base = 0n;\n let meta: bigint | null = 0n;\n for (const c of combos(space, levels, true, limit)) {\n if (c.base) base += c.weight!;\n else meta = meta === null || c.weight === null || meta + c.weight > limit ? null : meta + c.weight;\n }\n return { base, meta };\n}\n\n/** This function gives the cartesian product of lists, with the last list as the fastest. */\nfunction* product<T>(lists: readonly (readonly T[])[], i = 0, acc: T[] = []): Generator<T[]> {\n if (i === lists.length) {\n yield [...acc];\n return;\n }\n for (const x of lists[i]!) {\n acc.push(x);\n yield* product(lists, i + 1, acc);\n acc.pop();\n }\n}\n\n/** This function gives the configs of the grid of a space, without meta options. */\nfunction gridConfigs(space: StrategySpace, levels: number, limit: number, shapes: readonly ShapeKind[] | undefined): StrategyConfig[] {\n const kept = restrict(space, shapes);\n const size = sizeOf(kept, levels, 0n).base;\n if (size > BigInt(limit)) throw new RangeError(`The grid of the space ${space.engine} has ${size} configs, more than the limit ${limit}.`);\n const out: StrategyConfig[] = [];\n for (const c of combos(kept, levels, false, 0n)) {\n const names = [...c.choices.keys()];\n const lists = names.map((k) => {\n const o = c.choices.get(k)!;\n return o === null ? [null] : [...gridParams(o.params, levels)].map((params): StageChoice => ({ option: o.id, params }));\n });\n for (const row of product<StageChoice | null>(lists)) out.push(canonicalOf(space, { space: space.engine, stages: Object.fromEntries(names.map((k, i) => [k, row[i]!])) }, false));\n }\n return out;\n}\n\n/** This function gives a random order of the numbers from 0 to `n - 1`. */\nfunction permutation(n: number, r: () => number): number[] {\n const out = Array.from({ length: n }, (_, i) => i);\n for (let i = n - 1; i > 0; i--) {\n const j = Math.floor(r() * (i + 1));\n [out[i], out[j]] = [out[j]!, out[i]!];\n }\n return out;\n}\n\n/** This function gives the value of a param at the fraction `u` of its range. A sampled real number has 6 significant digits. */\nfunction sampleValue(p: SpaceParam, u: number): ParamValue {\n if (p.kind === \"bool\") return u >= 0.5;\n if (p.kind === \"enum\") {\n const values = p.values!;\n return values[Math.min(values.length - 1, Math.floor(u * values.length))]!;\n }\n if (p.min === p.max) return normalize(p, p.min!);\n if (p.scale !== \"log\" && (p.kind === \"int\" || p.step !== undefined)) {\n const steps = Math.round((lastPoint(p) - p.min!) / (p.step ?? 1)) + 1;\n return snap(p, p.min! + Math.min(steps - 1, Math.floor(u * steps)) * (p.step ?? 1), 6);\n }\n return snap(p, at01(p, u), 6);\n}\n\n/** This function gives a seed of 32 bits from a seed and a step name. */\nconst subSeed = (seed: number, step: string): number => Math.floor(stepRandom(seed, step)() * 4294967296);\n\n/**\n * This function gives a sample of a space: Latin hypercube strata over the options, the params and the member counts.\n * `canon` is the space of `canonicalConfig`: the space before a shape filter. A member of an option with `view: \"bounds\"` can have an option that the filter removed.\n */\nfunction sampleConfigs(\n space: StrategySpace,\n n: number,\n seed: number,\n meta: boolean,\n maxTries: number,\n canon: StrategySpace = space,\n walk = false,\n first: ReadonlySet<string> = new Set(),\n): StrategyConfig[] {\n const stages = space.stages;\n const prefix = prefixes(space);\n // A stage without options can stay empty in a part with a meta option of `view: \"bounds\"` or with no member list, because that option replaces the stage.\n const bounded = new Set(stages.filter((s) => meta && s.options.some((o) => memberSpaces.has(o) || o.members?.max === 0)).map((s) => prefix.get(s.name)!));\n const lists = stages.map((s) => {\n const list: (StageOption | null)[] = s.options.filter((o) => meta || o.members === undefined);\n if (s.optional) list.push(null);\n if (list.length === 0 && bounded.has(prefix.get(s.name)!)) list.push(null);\n if (list.length === 0) throw new Error(`The stage ${s.name} of the space ${space.engine} has no option for a sample. A shape filter can remove all of its options.`);\n return list;\n });\n // A meta option without a member list stays in its list, so the strata of 0.2.16 do not change. A point that chooses it draws again.\n const usable = new Map<StageOption, boolean>();\n const withMembers = (s: SpaceStage, o: StageOption | null | undefined): boolean => {\n if (o === null || o === undefined || o.members === undefined) return true;\n if (!usable.has(o)) usable.set(o, hasMembers(space, s.name, o));\n return usable.get(o)!;\n };\n const plan = walk ? walkPlan(stages, lists, space.constraints ?? [], n, first) : null;\n const points: Map<string, StageOption | null>[] = [];\n let tries = 0;\n for (let round = 0; points.length < n; round++) {\n const r = stepRandom(seed, `options:${round}`);\n const picks = walk ? lists.map(() => permutation(n, r)) : [];\n const columns = walk ? [] : lists.map((list) => permutation(n, r).map((p) => list[Math.floor((p * list.length) / n)]!));\n for (let i = 0; i < n && points.length < n; i++) {\n if (tries >= maxTries) throw new Error(`The constraints of the space ${space.engine} remove too many points: ${points.length} of ${n} configs after ${tries} tries.${walk ? \"\" : ' The option draw: \"walk\" gets a sample of a space with many constraints.'}`);\n tries++;\n const choices = plan !== null ? walkPoint(plan, picks, i) : new Map<string, StageOption | null>(stages.map((s, k) => [s.name, columns[k]![i]!]));\n const metaPart = new Map<string, string>();\n for (const s of stages) {\n const o = choices.get(s.name);\n if (o?.members !== undefined && !metaPart.has(prefix.get(s.name)!)) metaPart.set(prefix.get(s.name)!, s.name);\n }\n for (const s of stages) {\n const m = metaPart.get(prefix.get(s.name)!);\n if (m !== undefined && m !== s.name) choices.set(s.name, null);\n }\n const filled = stages.every((s) => s.optional === true || choices.get(s.name) !== null || metaPart.has(prefix.get(s.name)!));\n if (filled && keeps(space, choices) && stages.every((s) => withMembers(s, choices.get(s.name)))) points.push(choices);\n }\n }\n const values: Values[][] = points.map(() => stages.map(() => ({})));\n const members: StrategyConfig[][][] = points.map(() => stages.map(() => []));\n stages.forEach((s, k) => {\n for (const o of s.options) {\n const users = points.flatMap((c, i) => (c.get(s.name) === o ? [i] : []));\n if (users.length === 0) continue;\n for (const p of o.params) {\n const active = users.filter((i) => isActive(p, values[i]![k]!));\n const r = stepRandom(seed, `param:${s.name}:${o.id}:${p.name}`);\n permutation(active.length, r).forEach((stratum, j) => {\n values[active[j]!]![k]![p.name] = sampleValue(p, (stratum + r()) / active.length);\n });\n }\n if (o.members === undefined || o.members.max === 0) continue;\n const fixed = o.members.pool;\n if (fixed !== undefined) {\n const r = stepRandom(seed, `pool-entry:${s.name}:${o.id}`);\n permutation(users.length, r).forEach((stratum, j) => {\n members[users[j]!]![k] = [...fixed[Math.min(fixed.length - 1, Math.floor(((stratum + r()) / users.length) * fixed.length))]!];\n });\n continue;\n }\n const part = memberSpaces.get(o) ?? partOf(space, s.name).space;\n const poolSize = Math.max(n, 4 * o.members.max, 8);\n const seen = new Set<string>();\n const pool = sampleConfigs(part, poolSize, subSeed(seed, `pool:${s.name}:${o.id}`), false, Math.max(1000, 100 * poolSize), part, walk).filter((c) => {\n const id = idOf(c);\n return seen.has(id) ? false : (seen.add(id), true);\n });\n const r = stepRandom(seed, `members:${s.name}:${o.id}`);\n const { min, max } = o.members;\n permutation(users.length, r).forEach((stratum, j) => {\n const count = min + Math.min(max - min, Math.floor(((stratum + r()) / users.length) * (max - min + 1)));\n if (pool.length < count) throw new Error(`The space ${part.engine} has only ${pool.length} distinct base samples, fewer than the ${count} members of ${s.name}.${o.id}.`);\n const picked = permutation(pool.length, r).slice(0, count);\n members[users[j]!]![k] = picked.map((x) => pool[x]!);\n });\n }\n });\n return points.map((choices, i) => {\n const out: Record<string, StageChoice | null> = {};\n stages.forEach((s, k) => {\n const o = choices.get(s.name)!;\n out[s.name] = o === null ? null : o.members === undefined ? { option: o.id, params: values[i]![k]! } : { option: o.id, params: values[i]![k]!, members: members[i]![k]! };\n });\n return canonicalConfig(canon, { space: space.engine, stages: out });\n });\n}\n\n/**\n * This function gives configs of a space, in their canonical form. Each config keeps the constraints. The result is deterministic.\n *\n * - The mode `grid` gives each grid point without a meta option, in a stable order. Stages, options and values go in the order of the space.\n * - The mode `sample` gives `n` configs of a seeded Latin hypercube. The options of a stage get equal strata, and each active param gets its own strata.\n * - A sample draws again when a point breaks a constraint. After `maxTries` draws, it throws an `Error`. Two sampled configs can be equal.\n * - With `draw: \"walk\"`, each stage draws only from the options that keep the constraints with the stages before it. The largest stage keeps its equal strata.\n * - With `shapes`, only the options that support each kind of the list count. Without `shapes`, the result does not change.\n * - A meta option with a `pool` gives only the entries of its pool. With `shapes`, only the entries whose members support each kind count.\n * - A sample draws again when a point chooses a meta option without a member list. `spaceSize` gives such an option 0.\n * - With `shapes`, a sample throws a `RangeError` when the space has no config for the kinds. The error names the stages without an option and the meta options without members.\n * - With `fixed`, each config has the fixed option at each named stage. A fixed option that the space, the shape filter or the constraints do not permit gets a `RangeError` with the reason.\n */\nexport function enumerateSpace(space: StrategySpace, options: EnumerateOptions): StrategyConfig[] {\n assertSpace(space);\n assertShapes(options.shapes);\n if (options.mode === \"grid\") {\n assertWhole(options.levels, \"levels\", 1);\n return gridConfigs(space, options.levels, options.limit ?? 100_000, options.shapes);\n }\n if (options.mode !== \"sample\") throw new RangeError(`The mode ${String((options as { mode?: unknown }).mode)} is not grid or sample.`);\n assertWhole(options.n, \"n\", 0);\n if (!Number.isInteger(options.seed)) throw new RangeError(`The seed ${options.seed} is not a whole number.`);\n const meta = options.meta ?? \"skip\";\n if (meta !== \"skip\" && meta !== \"sample\") throw new RangeError(`The option meta is ${String(meta)}, not skip or sample.`);\n const draw = options.draw ?? \"reject\";\n if (draw !== \"reject\" && draw !== \"walk\") throw new RangeError(`The option draw is ${String(draw)}, not reject or walk.`);\n const fixed = options.fixed;\n if (fixed !== undefined) assertFixed(space, fixed, meta === \"sample\");\n if (options.n === 0) return [];\n const kept = restrict(space, options.shapes);\n const drawn = fixed === undefined ? kept : fixStages(space, kept, fixed, options.shapes);\n try {\n return sampleConfigs(drawn, options.n, options.seed, meta === \"sample\", options.maxTries ?? Math.max(1000, 100 * options.n), space, draw === \"walk\", new Set(Object.keys(fixed ?? {})));\n } catch (error) {\n // Only a space without a config for the shape kinds, or for the fixed options, gives the RangeError. A different failure keeps its own error.\n if (options.shapes !== undefined && !hasConfig(kept, meta === \"sample\")) throw noSample(space, kept, options.shapes, meta === \"sample\");\n if (fixed !== undefined && !hasConfig(drawn, meta === \"sample\")) throw noFixedSample(space, fixed);\n throw error;\n }\n}\n\n/**\n * This function gives the shape kinds that a space accepts, in the order of `SHAPE_KINDS`. The value comes from the `supports` of the options.\n * A space accepts a kind when it has at least one config without a meta option on that kind.\n */\nexport function spaceShapeKinds(space: StrategySpace): ShapeKind[] {\n assertSpace(space);\n return SHAPE_KIND_IDS.filter((k) => sizeOf(restrict(space, [k]), 1, 0n).base > 0n);\n}\n\n/**\n * This function joins configs of the parts of a product space into one config of the space `space`.\n * The name of each stage gets the prefix `<space of the part>.`. The members of a meta option do not change.\n */\nexport function joinConfigs(space: string, parts: readonly StrategyConfig[]): StrategyConfig {\n const stages: Record<string, StageChoice | null> = {};\n for (const part of parts) for (const [k, c] of Object.entries(part.stages)) stages[`${part.space}.${k}`] = c;\n return { space, stages };\n}\n\n/** This function gives the config of the part `engine` of a joint config. It throws a `RangeError` when no stage has the prefix `<engine>.`. */\nexport function splitConfig(config: StrategyConfig, engine: string): StrategyConfig {\n const head = `${engine}.`;\n const entries = Object.entries(config.stages).filter(([k]) => k.startsWith(head));\n if (entries.length === 0) throw new RangeError(`The config of the space ${config.space} has no stage of the part ${engine}.`);\n return { space: engine, stages: Object.fromEntries(entries.map(([k, c]) => [k.slice(head.length), c])) };\n}\n\n/**\n * This function joins two spaces, for example a packer and a router, into the space `name`. The stages of `a` and `b` get the prefixes `<a.engine>.` and `<b.engine>.`.\n * The constraints get the same prefixes. The named configs are the pairs `<name of a>+<name of b>`. It throws a `RangeError` when the two engines have the same name.\n */\nexport function productSpace(a: StrategySpace, b: StrategySpace, name: string): StrategySpace {\n if (a.engine === b.engine) throw new RangeError(`The two spaces have the same engine ${a.engine}.`);\n if (name === \"\") throw new RangeError(\"The product space has no name.\");\n const stagesOf = (s: StrategySpace): SpaceStage[] => s.stages.map((x) => ({ ...x, name: `${s.engine}.${x.name}` }));\n const ref = (s: StrategySpace, r: OptionRef): OptionRef => ({ stage: `${s.engine}.${r.stage}`, option: r.option });\n const constraintsOf = (s: StrategySpace): SpaceConstraint[] =>\n (s.constraints ?? []).map((c) => ({ if: ref(s, c.if), then: \"not\" in c.then ? { not: ref(s, c.then.not) } : ref(s, c.then) }));\n const named: Record<string, StrategyConfig> = {};\n for (const [ka, ca] of Object.entries(a.named ?? {})) for (const [kb, cb] of Object.entries(b.named ?? {})) named[`${ka}+${kb}`] = joinConfigs(name, [ca, cb]);\n const constraints = [...constraintsOf(a), ...constraintsOf(b)];\n return {\n schema: STRATEGY_SPACE_SCHEMA,\n engine: name,\n version: `${a.engine}@${a.version}+${b.engine}@${b.version}`,\n stages: [...stagesOf(a), ...stagesOf(b)],\n ...(constraints.length > 0 ? { constraints } : {}),\n ...(Object.keys(named).length > 0 ? { named } : {}),\n parts: [a, b],\n };\n}\n","import type { ParamWhen } from \"./strategy-space.ts\";\n\n/** The scale of a number option. A sweep on the scale `log` gives values with equal ratios, not with equal differences. */\nexport type OptionScale = \"linear\" | \"log\";\n\n/** The reason why an option has no default value. The strategy reads the absence, the caller sets it, the strategy calculates it, or the default is code. */\nexport type NoDefaultReason = \"unset\" | \"required\" | \"derived\" | \"function\";\n\n/** The statement of an option without a default value that JSON can hold. */\nexport interface NoDefault {\n readonly reason: NoDefaultReason;\n /** One short sentence that tells what the strategy does without a value. */\n readonly describe: string;\n}\n\n/** The fields of each option declaration. */\ninterface OptionBase {\n /** One short sentence that tells what the option sets. The site and the documents show it. */\n readonly describe: string;\n /** This field tells why the option has no default. The catalog of an engine has this field or a `default` on each option. */\n readonly noDefault?: NoDefault;\n /** The option is active only when an earlier option of the same strategy has one of these values. */\n readonly when?: ParamWhen;\n}\n\n/**\n * The declaration of a number option. The range from `min` to `max` is the range of a control and of a sweep.\n * The strategy can take a value outside the range. `checkOptions` reports such a value, and `clampOptions` moves it into the range.\n */\nexport interface NumberOption extends OptionBase {\n /** The type `integer` takes only whole numbers. */\n readonly type: \"number\" | \"integer\";\n readonly min: number;\n readonly max: number;\n /** The grain of a control and of a sweep. A value off the step is valid. Without it, the grain is free (or 1 for an integer). */\n readonly step?: number;\n /** The scale of a control and of a sweep. The default is `linear`. The scale `log` needs a `min` above 0. */\n readonly scale?: OptionScale;\n /** These values are valid outside the range. For example, `Infinity` sets no limit. */\n readonly special?: readonly number[];\n /** These values are the notable values of the option: the default and the values of the sweeps of the benchmark. */\n readonly marks?: readonly number[];\n /**\n * These values are the only valid values of the option, in the order of a control. A control shows them as a list, and a sweep gives them.\n * Without them, each value on the range is valid.\n */\n readonly values?: readonly number[];\n /** The strategy uses this value when the caller and `defaults` give no value. */\n readonly default?: number;\n}\n\n/** The declaration of a boolean option. */\nexport interface BooleanOption extends OptionBase {\n readonly type: \"boolean\";\n /** The strategy uses this value when the caller and `defaults` give no value. */\n readonly default?: boolean;\n}\n\n/** The declaration of an option with a fixed list of string values. */\nexport interface EnumOption<V extends string = string> extends OptionBase {\n readonly type: \"enum\";\n /** The values of the option, in the order of a control. */\n readonly values: readonly V[];\n /**\n * With `function`, the option also takes a rule of the caller in place of a name. A control sets only the names.\n * Each name is a known rule of the strategy.\n */\n readonly custom?: \"function\";\n /** The strategy uses this value when the caller and `defaults` give no value. */\n readonly default?: V;\n}\n\n/**\n * The declaration of an option that a control or a sweep cannot set from a range.\n * The type `function` is a rule, `strategy` is a strategy of the step `step`, `list` is an array and `object` is any other object.\n */\nexport interface ValueOption<V = unknown, S extends string = string> extends OptionBase {\n readonly type: \"function\" | \"strategy\" | \"list\" | \"object\";\n /** The step of the strategy, for the type `strategy`. A control lists the strategies of this step of a registry. */\n readonly step?: S;\n /** The kinds of strategy that the option takes, for the type `strategy`. Without them, the option takes each kind. */\n readonly kinds?: readonly string[];\n /** The key of the option that holds the options of the chosen strategy, for the type `strategy`. */\n readonly optionsKey?: string;\n /** The value `true` lets a value hold its options: a key, or an object with the fields `strategy`, `options` and `id`. This field is for the type `strategy`, and also for an item of a list. */\n readonly inlineOptions?: boolean;\n /** The value `false` leaves out the opt-in strategies, because the option finds only the default set of the engine. This field is for the type `strategy`. */\n readonly optIn?: boolean;\n /** For each dimension of `supports`, the value that a chosen strategy must take. This field is for the type `strategy`, and also for an item of a list. */\n readonly needs?: Readonly<Record<string, string>>;\n /** The declaration of each item, for the type `list`. */\n readonly of?: ListItem<S>;\n /** The smallest number of items, for the type `list`. */\n readonly min?: number;\n /** The largest number of items, for the type `list`. */\n readonly max?: number;\n /** The strategy uses this value when the caller and `defaults` give no value. */\n readonly default?: V;\n}\n\n/** The declaration of one option of any type. */\nexport type AnyOption<S extends string = string> = NumberOption | BooleanOption | EnumOption | ValueOption<unknown, S>;\n\n/** This type removes the fields of a whole option from a declaration. */\ntype ItemOf<T> = T extends unknown ? Omit<T, \"describe\" | \"default\" | \"noDefault\" | \"when\"> : never;\n\n/** The declaration of one item of a list option: an option without its text, its default and its condition. */\nexport type ListItem<S extends string = string> = ItemOf<AnyOption<S>>;\n\n/**\n * The declaration that fits the type of an option value: numbers, booleans, string unions or other values.\n * A union of strings and other values takes an enum of the strings or a value declaration. An example is a rule or the name of a rule.\n * A plain `string` takes an enum or a value declaration, because the value can be the key of a strategy.\n */\nexport type OptionDeclaration<V, S extends string = string> = [V] extends [number]\n ? NumberOption\n : [V] extends [boolean]\n ? BooleanOption\n : [V] extends [string]\n ? string extends V\n ? EnumOption<V> | ValueOption<V, S>\n : EnumOption<V>\n : [Extract<V, string>] extends [never]\n ? ValueOption<V, S>\n : EnumOption<Extract<V, string>> | ValueOption<V, S>;\n\n/** The declarations of the options of a strategy. The schema has one declaration for each key of the options type, and no other key. */\nexport type OptionSchema<O, S extends string = string> = { readonly [K in keyof O]-?: OptionDeclaration<NonNullable<O[K]>, S> };\n\n/** The fields of a strategy that the functions of this module read. An engine can add other fields. */\nexport interface DeclaredStrategy<O extends object = object, S extends string = string> {\n /** The name of the strategy in a message. */\n readonly name: string;\n readonly defaults: O;\n readonly schema?: OptionSchema<O, S>;\n}\n\n/** One problem of an option value against its declaration. */\nexport interface OptionIssue {\n /** The key of the option. */\n readonly key: string;\n readonly value: unknown;\n /** The kind of the problem: no declaration, the wrong type, out of the range, not a whole number or not one of the values. */\n readonly problem: \"unknown\" | \"type\" | \"range\" | \"integer\" | \"value\";\n /** One sentence that tells the problem. */\n readonly message: string;\n}\n\n/** One setting of a sweep: a name for the rows of a table, and the options of the strategy. */\nexport interface OptionSetting<O extends object> {\n /** The key and the value of each option of the setting, for example `stretch 1.5`. */\n readonly name: string;\n readonly options: Partial<O>;\n}\n\n/** The options of `sweepValues`, `sweepOf` and `sweepGrid`. */\nexport interface SweepOptions {\n /**\n * The number of values on the range of a number option. Without it, the sweep gives the `marks` of the declaration.\n * A declaration without `marks` gets 5 values.\n */\n readonly count?: number;\n /** With `true`, a sweep of a number option on the range also gives the `special` values. The default is `false`. */\n readonly special?: boolean;\n}\n\n/** The number of values of a sweep on a range when the call and the declaration give no number. */\nconst SWEEP_COUNT = 5;\n\n/** This function gives the declarations of a strategy as a record. A strategy without a schema gives an empty record. */\nfunction schemaOf<S extends string>(strategy: DeclaredStrategy<object, S>): Readonly<Record<string, AnyOption<S>>> {\n return (strategy.schema ?? {}) as Readonly<Record<string, AnyOption<S>>>;\n}\n\n/** This function gives the declared options of a strategy, in the order of its schema, with the effective default of each one. */\nexport function listOptions<O extends object, S extends string = string>(\n strategy: DeclaredStrategy<O, S>,\n): { readonly key: keyof O & string; readonly declaration: AnyOption<S>; readonly value: unknown }[] {\n const defaults = optionDefaults(strategy) as Record<string, unknown>;\n return Object.entries(schemaOf(strategy)).map(([key, declaration]) => ({ key: key as keyof O & string, declaration, value: defaults[key] }));\n}\n\n/**\n * This function gives the effective default of each declared option: the value of `defaults`, else the `default` of the declaration.\n * An option without either value stays out. The strategy gives the same output with this object as with no options.\n */\nexport function optionDefaults<O extends object, S extends string = string>(strategy: DeclaredStrategy<O, S>): Partial<O> {\n const out: Record<string, unknown> = {};\n const defaults = strategy.defaults as Readonly<Record<string, unknown>>;\n for (const [key, declaration] of Object.entries(schemaOf(strategy))) {\n if (key in defaults) out[key] = defaults[key];\n else if (declaration.default !== undefined) out[key] = declaration.default;\n }\n for (const key of Object.keys(defaults)) if (!(key in out)) out[key] = defaults[key];\n return out as Partial<O>;\n}\n\n/** This function gives `true` if the number is one of the special values of the declaration. */\nconst isSpecial = (d: NumberOption, v: number): boolean => (d.special ?? []).some((s) => Object.is(s, v) || s === v);\n\n/** This function gives the problem of one value against its declaration, or `undefined` when the value fits. */\nexport function optionIssue(key: string, value: unknown, d: AnyOption): OptionIssue | undefined {\n const issue = (problem: OptionIssue[\"problem\"], message: string): OptionIssue => ({ key, value, problem, message });\n if (value === undefined) return undefined;\n switch (d.type) {\n case \"number\":\n case \"integer\": {\n if (typeof value !== \"number\" || Number.isNaN(value)) return issue(\"type\", `The option \"${key}\" takes a number.`);\n if (isSpecial(d, value)) return undefined;\n if (d.values !== undefined && !d.values.includes(value)) return issue(\"value\", `The option \"${key}\" takes ${d.values.join(\", \")}, not ${value}.`);\n if (value < d.min || value > d.max) return issue(\"range\", `The option \"${key}\" is ${value}, out of the range ${d.min} to ${d.max}.`);\n if (d.type === \"integer\" && !Number.isInteger(value)) return issue(\"integer\", `The option \"${key}\" takes a whole number, not ${value}.`);\n return undefined;\n }\n case \"boolean\":\n return typeof value === \"boolean\" ? undefined : issue(\"type\", `The option \"${key}\" takes true or false.`);\n case \"enum\":\n if (d.custom === \"function\" && typeof value === \"function\") return undefined;\n return d.values.includes(value as string) ? undefined : issue(\"value\", `The option \"${key}\" takes ${d.values.join(\", \")}, not ${String(value)}.`);\n case \"function\":\n return typeof value === \"function\" ? undefined : issue(\"type\", `The option \"${key}\" takes a function.`);\n case \"list\":\n return Array.isArray(value) ? undefined : issue(\"type\", `The option \"${key}\" takes a list.`);\n default:\n return typeof value === \"object\" && value !== null ? undefined : issue(\"type\", `The option \"${key}\" takes an object.`);\n }\n}\n\n/**\n * This function examines option values against the schema of a strategy. It gives one issue for each key without a declaration.\n * It also gives one issue for each value of the wrong type, out of the range, not whole or not one of the values.\n * It changes no value.\n * A strategy without a schema gives no issue.\n */\nexport function checkOptions<O extends object>(strategy: DeclaredStrategy<O>, options: Partial<O>): OptionIssue[] {\n if (strategy.schema === undefined) return [];\n const schema = schemaOf(strategy);\n const out: OptionIssue[] = [];\n for (const [key, value] of Object.entries(options)) {\n const d = schema[key];\n const issue = d ? optionIssue(key, value, d) : { key, value, problem: \"unknown\" as const, message: `The strategy \"${strategy.name}\" has no option \"${key}\".` };\n if (issue) out.push(issue);\n }\n return out;\n}\n\n/**\n * This function moves each number option into the range of its declaration, for a control. An integer option gets the nearest whole number.\n * An option with a list of `values` gets the nearest value of the list. A special value stays. The function keeps each other value as it is. `checkOptions` reports the values that this function cannot correct.\n */\nexport function clampOptions<O extends object>(strategy: DeclaredStrategy<O>, options: Partial<O>): Partial<O> {\n const schema = schemaOf(strategy);\n const out: Record<string, unknown> = { ...options };\n for (const [key, value] of Object.entries(options)) {\n const d = schema[key];\n if (!d || (d.type !== \"number\" && d.type !== \"integer\") || typeof value !== \"number\" || Number.isNaN(value) || isSpecial(d, value)) continue;\n if (d.values !== undefined && d.values.length > 0) {\n out[key] = d.values.reduce((best, v) => (Math.abs(v - value) < Math.abs(best - value) ? v : best));\n continue;\n }\n const v = Math.min(d.max, Math.max(d.min, value));\n out[key] = d.type === \"integer\" ? Math.min(d.max, Math.max(d.min, Math.round(v))) : v;\n }\n return out as Partial<O>;\n}\n\n/** This function gives `count` values from `min` to `max` on the scale, on the grain of the step, without repeats. */\nfunction rangeValues(d: NumberOption, count: number): number[] {\n const n = Math.max(1, Math.floor(count));\n const log = d.scale === \"log\" && d.min > 0;\n const at = (t: number): number => (log ? d.min * (d.max / d.min) ** t : d.min + (d.max - d.min) * t);\n const step = d.step ?? (d.type === \"integer\" ? 1 : undefined);\n const snap = (v: number): number => {\n const s = step === undefined ? v : d.min + Math.round((v - d.min) / step) * step;\n const r = Number(s.toPrecision(12));\n return Math.min(d.max, Math.max(d.min, d.type === \"integer\" ? Math.round(r) : r));\n };\n const out: number[] = [];\n for (let i = 0; i < n; i++) {\n const v = snap(at(n === 1 ? 0 : i / (n - 1)));\n if (!out.includes(v)) out.push(v);\n }\n return out;\n}\n\n/**\n * This function gives the values of a sweep of one option declaration.\n * A number option gives its `marks`, or its list of `values`, or `count` values on its range and its scale. A boolean gives `false` and `true`. An enum gives its values.\n * An option of another type has no sweep, so the function throws an error.\n */\nexport function sweepValues(declaration: AnyOption, options: SweepOptions = {}): unknown[] {\n switch (declaration.type) {\n case \"number\":\n case \"integer\": {\n if (options.count === undefined && declaration.marks !== undefined) return [...declaration.marks];\n if (declaration.values !== undefined) return [...declaration.values];\n const values = rangeValues(declaration, options.count ?? SWEEP_COUNT);\n return options.special ? [...values, ...(declaration.special ?? []).filter((s) => !values.includes(s))] : values;\n }\n case \"boolean\":\n return [false, true];\n case \"enum\":\n return [...declaration.values];\n default:\n throw new Error(`An option of the type \"${declaration.type}\" has no sweep. A sweep takes a number, an integer, a boolean or an enum.`);\n }\n}\n\n/** This function gives the declaration of one option of a strategy. When the strategy has no such declaration, the function throws an error. */\nfunction declarationOf(strategy: DeclaredStrategy, key: string): AnyOption {\n const d = schemaOf(strategy)[key];\n if (!d) throw new Error(`The strategy \"${strategy.name}\" has no declaration of the option \"${key}\".`);\n return d;\n}\n\n/**\n * This function gives the settings of a sweep of one option of a strategy, from its declaration only.\n * The name of each setting is the key and the value, for example `stretch 1.5`.\n */\nexport function sweepOf<O extends object>(strategy: DeclaredStrategy<O>, key: keyof O & string, options: SweepOptions = {}): OptionSetting<O>[] {\n return sweepValues(declarationOf(strategy, key), options).map((value) => ({ name: `${key} ${String(value)}`, options: { [key]: value } as Partial<O> }));\n}\n\n/**\n * This function gives the settings of a grid of options: each combination of the values of the sweeps of the keys.\n * The name of a setting joins the names of its values with commas, in the order of the keys.\n */\nexport function sweepGrid<O extends object>(strategy: DeclaredStrategy<O>, keys: readonly (keyof O & string)[], options: SweepOptions = {}): OptionSetting<O>[] {\n let out: OptionSetting<O>[] = [{ name: \"\", options: {} }];\n for (const key of keys) {\n const sweep = sweepOf(strategy, key, options);\n out = out.flatMap((s) => sweep.map((t) => ({ name: s.name === \"\" ? t.name : `${s.name}, ${t.name}`, options: { ...s.options, ...t.options } })));\n }\n return keys.length === 0 ? [] : out;\n}\n\n/** This function gives the problems of one declaration: a bad range, a bad step, or marks and a default that do not fit. */\nexport function declarationIssues(key: string, d: AnyOption): string[] {\n const out: string[] = [];\n if (d.describe.trim().length === 0) out.push(`The option \"${key}\" has no description.`);\n if (d.type === \"number\" || d.type === \"integer\") {\n if (!Number.isFinite(d.min) || !Number.isFinite(d.max) || d.min > d.max) out.push(`The option \"${key}\" has the bad range ${d.min} to ${d.max}.`);\n if (d.type === \"integer\" && (!Number.isInteger(d.min) || !Number.isInteger(d.max))) out.push(`The integer option \"${key}\" has a range that is not whole.`);\n if (d.step !== undefined && !(d.step > 0)) out.push(`The option \"${key}\" has the step ${d.step}. A step is more than 0.`);\n if (d.scale === \"log\" && !(d.min > 0)) out.push(`The option \"${key}\" has the scale log and the min ${d.min}. The scale log needs a min above 0.`);\n if (d.values !== undefined && d.values.length === 0) out.push(`The number option \"${key}\" has an empty list of values.`);\n for (const v of d.values ?? []) {\n if (v < d.min || v > d.max || (d.type === \"integer\" && !Number.isInteger(v))) out.push(`The value ${v} of the option \"${key}\" is not on its range ${d.min} to ${d.max}.`);\n }\n for (const v of [...(d.marks ?? []), ...(d.default === undefined ? [] : [d.default])]) {\n const issue = optionIssue(key, v, d);\n if (issue) out.push(issue.message);\n }\n } else if (d.type === \"enum\") {\n if (d.values.length === 0) out.push(`The enum option \"${key}\" has no values.`);\n if (d.default !== undefined && !d.values.includes(d.default)) out.push(`The default of the option \"${key}\" is not one of its values.`);\n } else if (d.type === \"boolean\") {\n if (d.default !== undefined && typeof d.default !== \"boolean\") out.push(`The default of the option \"${key}\" is not true or false.`);\n }\n return out;\n}\n\n/**\n * This function examines the schema of a strategy. It gives one message for each option of `defaults` without a declaration.\n * It also gives one message for each bad declaration, and for each value of `defaults` that does not fit its declaration.\n * A good schema gives an empty list.\n */\nexport function checkSchema(strategy: DeclaredStrategy): string[] {\n const schema = schemaOf(strategy);\n const out: string[] = [];\n for (const key of Object.keys(strategy.defaults)) if (!(key in schema)) out.push(`The strategy \"${strategy.name}\" has the option \"${key}\" in its defaults, without a declaration.`);\n for (const [key, d] of Object.entries(schema)) out.push(...declarationIssues(key, d).map((m) => `The strategy \"${strategy.name}\": ${m}`));\n out.push(...checkOptions(strategy, strategy.defaults).filter((i) => i.problem !== \"unknown\").map((i) => `The strategy \"${strategy.name}\": ${i.message}`));\n return out;\n}\n","// The strategy catalog: every strategy and every option of an engine, as JSON (`docs/STRATEGY-CATALOG.md`).\nimport { canonicalJson } from \"./hash.ts\";\nimport type { Supports } from \"./record.ts\";\nimport { type AnyOption, declarationIssues, type ListItem, type NoDefaultReason, optionIssue, type OptionScale, type ValueOption } from \"./strategy-options.ts\";\nimport type { ParamValue, StrategySpace } from \"./strategy-space.ts\";\n\n/** The newest schema of a strategy catalog. A new field is a new version of the schema. */\nexport const STRATEGY_CATALOG_SCHEMA = \"strategy-catalog/3\";\n\n/** The schemas that `parseStrategyCatalog` reads, oldest first. Schema 2 adds the field `output` of an entry, and schema 3 adds the field `fingerprint`. */\nexport const STRATEGY_CATALOG_SCHEMAS: readonly [\"strategy-catalog/1\", \"strategy-catalog/2\", \"strategy-catalog/3\"] = [\"strategy-catalog/1\", \"strategy-catalog/2\", STRATEGY_CATALOG_SCHEMA];\n\n/** The form of the field `fingerprint` of an entry: the 16 lowercase hex digits that `fingerprintOf` gives. */\nconst FINGERPRINT = /^[0-9a-f]{16}$/u;\n\n/** The name of one schema of a strategy catalog. */\nexport type StrategyCatalogSchema = (typeof STRATEGY_CATALOG_SCHEMAS)[number];\n\n/**\n * The dimension of `supports` that tells who owns the positions of the nodes. The value `host` means that the strategy keeps the positions that the host gives.\n * The value `engine` means that the strategy can set them. A strategy that moves nodes has only `engine`. A `SupportProbe` tests the claim with a run.\n */\nexport const NODE_POSITIONS_DIMENSION = \"nodePositions\";\n\n/** A limit on one measure of the input. The key of the record of limits names the measure, for example `nodes`. */\nexport interface CatalogLimit {\n /** The smallest value that the strategy takes. */\n readonly min?: number;\n /** The largest value that the strategy takes. */\n readonly max?: number;\n /** One short sentence that tells what the strategy does outside the limit. */\n readonly describe: string;\n}\n\n/** The kind of a strategy: it places on its own, it wraps other strategies, or it is for one shape of item. */\nexport type StrategyKind = \"single\" | \"composite\" | \"shape\";\n\n/** The output properties that tell if the numbers of a result are whole: the positions and the sizes. The parser examines the class of these properties. */\nexport const OUTPUT_GRID_PROPERTIES: readonly string[] = [\"position-grid\", \"size-grid\"];\n\n/** The class of a grid property of an output. */\nexport type OutputGridClass = \"whole\" | \"near-whole\" | \"fractional\" | \"untested\";\n\n/** The largest distance from a whole number for a near-whole value. A value at a larger distance is fractional. */\nexport const OUTPUT_NEAR_WHOLE = 1e-9;\n\n/** The fewest packed inputs for the class `whole` or `near-whole`. A fraction needs no such count, because one counterexample is a proof. */\nexport const OUTPUT_CLASS_MIN_INPUTS = 30;\n\n/** What one read of an output covers. The row states no promise beyond this evidence. */\nexport interface OutputEvidence {\n /** The count of inputs that the strategy packed in this read. */\n readonly inputs: number;\n /** The count of inputs with a fractional value of the property. A grid property must have this field. */\n readonly fractionalInputs?: number;\n /** The count of inputs with a near-whole value and no fractional value of the property. A grid property must have this field. */\n readonly nearWholeInputs?: number;\n /** The input family or the study of the read. */\n readonly source: string;\n /** The name of the options of the read, for example `default`. */\n readonly optionSet: string;\n /** The version of the catalog that the read used. */\n readonly catalogVersion: string;\n}\n\n/** One property of the output of a strategy, as a read found it. An entry has one row for each pair of `property` and `optionSet`. */\nexport interface OutputRow {\n /** The property, for example `position-grid`. */\n readonly property: string;\n /** The class of the property. For a grid property, `outputGridClass` gives the only class that the evidence permits. */\n readonly class: string;\n readonly evidence: OutputEvidence;\n}\n\n/** The counts that decide the class of a grid property. */\nexport interface OutputGridCounts {\n readonly inputs: number;\n readonly fractionalInputs: number;\n readonly nearWholeInputs: number;\n}\n\n/**\n * This function gives the class of a grid property from its counts. One fractional input gives `fractional` at any count.\n * With no fraction, fewer than `OUTPUT_CLASS_MIN_INPUTS` inputs give `untested`. Each other read gives `near-whole` or `whole`.\n */\nexport function outputGridClass(counts: OutputGridCounts): OutputGridClass {\n if (counts.fractionalInputs > 0) return \"fractional\";\n if (counts.inputs < OUTPUT_CLASS_MIN_INPUTS) return \"untested\";\n return counts.nearWholeInputs > 0 ? \"near-whole\" : \"whole\";\n}\n\n/** One strategy of a catalog. */\nexport interface CatalogEntry {\n /** The key is unique in the catalog: `<step>/<id>` with a step, else `id`. */\n readonly key: string;\n /** The name that the engine reads. */\n readonly id: string;\n /** The step of the pipeline of the engine. An engine without steps leaves it out. */\n readonly step?: string;\n /** The group of the strategy in a chooser. */\n readonly family: string;\n readonly kind: StrategyKind;\n /** One line that tells what the strategy does. */\n readonly describe: string;\n /** For each dimension, the values that the strategy takes. A dimension that is not here has no declared limit. */\n readonly supports: Supports;\n /** The limits of the strategy on the measures of the input. An empty record means that the engine declares no limit. */\n readonly limits: Readonly<Record<string, CatalogLimit>>;\n /** The value is `true` when, with the default options, the result depends only on the input, the options and the seed. */\n readonly deterministic: boolean;\n /** One sentence that tells what can change this claim, for example a clock. */\n readonly determinismNote?: string;\n /** The value is `true` when the strategy is outside the default set of the engine, and a caller asks for it by name. */\n readonly optIn: boolean;\n /** The value `true` tells that the strategy is a baseline of a bench. It has `optIn` true, and a chooser does not offer it. */\n readonly baseline?: true;\n /** The reads of the output of the strategy. A file with this field has the schema 2. */\n readonly output?: readonly OutputRow[];\n /** The fingerprint of the outputs of the strategy on the probes of its engine, from `fingerprintOf`. A file with this field has the schema 3. */\n readonly fingerprint?: string;\n /** The declarations of the options, in the order of a form. */\n readonly options: Readonly<Record<string, AnyOption>>;\n}\n\n/** The form of a catalog that an engine exports as data. It holds no version: the build gives the version from `package.json`. */\nexport interface StrategyCatalogSource {\n /** The npm name of the engine, without its scope. */\n readonly engine: string;\n readonly strategies: readonly CatalogEntry[];\n}\n\n/** A catalog document: the form that `writeStrategyCatalog` writes and `parseStrategyCatalog` reads. */\nexport interface StrategyCatalog extends StrategyCatalogSource {\n readonly schema: StrategyCatalogSchema;\n /** The npm version of the engine. */\n readonly version: string;\n}\n\n/** The result of `parseStrategyCatalog`. */\nexport type StrategyCatalogParse = { readonly ok: true; readonly catalog: StrategyCatalog } | { readonly ok: false; readonly faults: readonly string[] };\n\n/** The live facts of one strategy, for `checkCatalog`. */\nexport interface RegistryEntry {\n readonly key: string;\n /** The live defaults of the strategy. */\n readonly defaults: Readonly<Record<string, unknown>>;\n readonly optIn: boolean;\n /** The value `true` tells that the strategy is a baseline of a bench. */\n readonly baseline?: boolean;\n /** The limits in the code of the engine. Without them, the engine has no limits. */\n readonly limits?: Readonly<Record<string, { readonly min?: number; readonly max?: number }>>;\n /** This function runs the strategy on a small fixture and gives its output as text. The text does not hold times. */\n readonly run?: () => string;\n}\n\n/** A test of one value of `supports`: each strategy runs on an input with this value. */\nexport interface SupportProbe {\n /** The dimension of `supports`. */\n readonly field: string;\n readonly value: string;\n /** This function gives `true` if the strategy refuses the input, and `undefined` if the input cannot go to this strategy. */\n readonly refuses: (key: string) => boolean | undefined;\n}\n\n/**\n * The statement of how one place of a space reaches the options of an engine. The file of a catalog does not hold it, because a value can hold code.\n *\n * - `spaceOnly` tells that the place sets no option, with one sentence that tells why. A stage option without an entry can also have this statement.\n * - `option` names the option of the param, when the option has another name. `value` gives the option value of one param value, and `undefined` when the param value sets no option.\n */\nexport type ParamRoute =\n | { readonly spaceOnly: string }\n | { readonly option?: string; readonly value?: (value: ParamValue) => unknown };\n\n/** The options of `checkCatalog`. */\nexport interface CatalogCheckOptions {\n /** Each param of these spaces is examined against the declaration of its option. */\n readonly spaces?: readonly StrategySpace[];\n /** The routes of the params of `spaces`. The key is `<stage>/<option>.<param>`, or `<stage>/<option>` for a stage option. A route that matches nothing is a fault. */\n readonly paramRoutes?: Readonly<Record<string, ParamRoute>>;\n readonly probes?: readonly SupportProbe[];\n /** This function runs `owner` with `choice` in its option `option`. It gives `true` for a refusal, or `undefined` if the input cannot go to `owner`. */\n readonly refusesChoice?: (owner: string, option: string, choice: string) => boolean | undefined;\n}\n\n/** The result of `checkCatalog`. */\nexport interface CatalogCheck {\n /** Each break of a rule, as one sentence. A good catalog has none. */\n readonly faults: readonly string[];\n /** The claims that no run examined, by key and with the reason. */\n readonly notRun: readonly string[];\n /** The stage options and the params of a space that have no entry, no declaration and no route. */\n readonly notMatched: readonly string[];\n /** The places of a space with a `spaceOnly` route, each with its reason. */\n readonly spaceOnly: readonly string[];\n}\n\n/** The value of a strategy option that holds the options of the chosen strategy. A declaration with `inlineOptions` takes it. */\nexport interface StrategyMember {\n /** The key of the chosen strategy. */\n readonly strategy: string;\n /** The options of the chosen strategy, in the JSON form of its declarations. */\n readonly options?: Readonly<Record<string, unknown>>;\n /** The name of the member in the output. */\n readonly id?: string;\n}\n\n/** The options of `catalogOptions`. */\nexport interface CatalogOptionsOptions {\n /** This function gives the key of a strategy from a default value of the type `strategy`. */\n readonly strategyKey?: (value: unknown) => string | undefined;\n}\n\nconst STRATEGY_KINDS: readonly string[] = [\"single\", \"composite\", \"shape\"];\nconst NO_DEFAULT_REASONS: readonly NoDefaultReason[] = [\"unset\", \"required\", \"derived\", \"function\"];\nconst SCALES: readonly OptionScale[] = [\"linear\", \"log\"];\nconst TOP_FIELDS: readonly string[] = [\"schema\", \"engine\", \"version\", \"strategies\"];\nconst ENTRY_FIELDS: readonly string[] = [\"key\", \"id\", \"step\", \"family\", \"kind\", \"describe\", \"supports\", \"limits\", \"deterministic\", \"determinismNote\", \"optIn\", \"baseline\", \"output\", \"fingerprint\", \"options\"];\nconst COMMON_FIELDS: readonly string[] = [\"type\", \"describe\", \"default\", \"noDefault\", \"when\"];\nconst NUMBER_FIELDS: readonly string[] = [...COMMON_FIELDS, \"min\", \"max\", \"step\", \"scale\", \"special\", \"marks\", \"values\"];\nconst ENUM_FIELDS: readonly string[] = [...COMMON_FIELDS, \"values\", \"custom\"];\nconst STRATEGY_FIELDS: readonly string[] = [...COMMON_FIELDS, \"step\", \"kinds\", \"optionsKey\", \"inlineOptions\", \"optIn\", \"needs\"];\nconst MEMBER_FIELDS: readonly string[] = [\"strategy\", \"options\", \"id\"];\nconst LIST_FIELDS: readonly string[] = [...COMMON_FIELDS, \"of\", \"min\", \"max\"];\nconst ROW_FIELDS: readonly string[] = [\"property\", \"class\", \"evidence\"];\nconst EVIDENCE_FIELDS: readonly string[] = [\"inputs\", \"fractionalInputs\", \"nearWholeInputs\", \"source\", \"optionSet\", \"catalogVersion\"];\n/** The fields of a declaration, in the order of the file. */\nconst OPTION_ORDER: readonly string[] = [\"type\", \"describe\", \"min\", \"max\", \"step\", \"scale\", \"special\", \"marks\", \"values\", \"custom\", \"kinds\", \"optionsKey\", \"inlineOptions\", \"optIn\", \"needs\", \"of\", \"default\", \"noDefault\", \"when\"];\n\ntype Fields = Readonly<Record<string, unknown>>;\n\nconst isFields = (v: unknown): v is Fields => typeof v === \"object\" && v !== null && !Array.isArray(v);\nconst isText = (v: unknown): v is string => typeof v === \"string\" && v.trim() !== \"\";\nconst isTextList = (v: unknown): v is readonly string[] => Array.isArray(v) && v.every(isText);\nconst isFiniteNumber = (v: unknown): v is number => typeof v === \"number\" && Number.isFinite(v);\nconst isMember = (v: unknown): v is StrategyMember =>\n isFields(v) &&\n isText(v[\"strategy\"]) &&\n (v[\"options\"] === undefined || isFields(v[\"options\"])) &&\n (v[\"id\"] === undefined || isText(v[\"id\"])) &&\n Object.keys(v).every((k) => MEMBER_FIELDS.includes(k));\n\n/** This function gives the key of a strategy from its step and its id. */\nexport function catalogKey(id: string, step?: string): string {\n return step === undefined ? id : `${step}/${id}`;\n}\n\n/** This function adds one fault for each field of `o` that is not in `allowed`. */\nfunction refuseUnknown(at: string, o: Fields, allowed: readonly string[], faults: string[]): void {\n for (const key of Object.keys(o)) if (!allowed.includes(key)) faults.push(`${at}: the field \"${key}\" is unknown.`);\n}\n\n/** This function restores a number field of a file. It gives `undefined` for each value that is not a finite number, `\"Infinity\"` or `\"-Infinity\"`. */\nfunction readNumber(v: unknown): number | undefined {\n if (v === \"Infinity\") return Infinity;\n if (v === \"-Infinity\") return -Infinity;\n return isFiniteNumber(v) ? v : undefined;\n}\n\n/** This function restores a list of number fields, with one fault for each bad value. */\nfunction readNumbers(at: string, v: unknown, faults: string[]): number[] | undefined {\n if (!Array.isArray(v)) {\n faults.push(`${at} is not a list.`);\n return undefined;\n }\n const out: number[] = [];\n for (const x of v) {\n const n = readNumber(x);\n if (n === undefined) faults.push(`${at} holds a value that is not a number.`);\n else out.push(n);\n }\n return out;\n}\n\n/** This function gives the fields of a number declaration, restored from a file. */\nfunction readNumberFields(at: string, raw: Fields, faults: string[]): Fields {\n const out: Record<string, unknown> = {};\n for (const f of [\"min\", \"max\"]) {\n if (isFiniteNumber(raw[f])) out[f] = raw[f];\n else faults.push(`${at}: \"${f}\" is not a finite number.`);\n }\n if (raw[\"step\"] !== undefined) {\n if (isFiniteNumber(raw[\"step\"])) out[\"step\"] = raw[\"step\"];\n else faults.push(`${at}: \"step\" is not a finite number.`);\n }\n if (raw[\"scale\"] !== undefined) {\n if (SCALES.includes(raw[\"scale\"] as OptionScale)) out[\"scale\"] = raw[\"scale\"];\n else faults.push(`${at}: \"scale\" is not linear or log.`);\n }\n for (const f of [\"special\", \"marks\"]) {\n if (raw[f] === undefined) continue;\n const list = readNumbers(`${at}: \"${f}\"`, raw[f], faults);\n if (list !== undefined) out[f] = list;\n }\n if (raw[\"values\"] !== undefined) {\n if (Array.isArray(raw[\"values\"]) && raw[\"values\"].every(isFiniteNumber)) out[\"values\"] = raw[\"values\"];\n else faults.push(`${at}: \"values\" is not a list of finite numbers.`);\n }\n if (raw[\"default\"] !== undefined) {\n const n = readNumber(raw[\"default\"]);\n if (n === undefined) faults.push(`${at}: the default is not a number.`);\n else out[\"default\"] = n;\n }\n return out;\n}\n\n/** This function gives the fields of a list declaration, restored from a file. */\nfunction readListFields(at: string, raw: Fields, faults: string[]): Fields {\n const out: Record<string, unknown> = {};\n if (raw[\"of\"] !== undefined) {\n const item = readOption(`${at}: \"of\"`, raw[\"of\"], true, faults);\n if (item !== undefined) out[\"of\"] = item;\n if (isFields(raw[\"of\"]) && raw[\"of\"][\"optionsKey\"] !== undefined) faults.push(`${at}: an item of a list has no sibling for \"optionsKey\". Use \"inlineOptions\".`);\n }\n for (const f of [\"min\", \"max\"]) {\n if (raw[f] === undefined) continue;\n if (Number.isInteger(raw[f]) && (raw[f] as number) >= 0) out[f] = raw[f];\n else faults.push(`${at}: \"${f}\" is not a whole number.`);\n }\n if (raw[\"default\"] !== undefined) {\n if (Array.isArray(raw[\"default\"])) out[\"default\"] = raw[\"default\"];\n else faults.push(`${at}: the default is not a list.`);\n }\n if (typeof out[\"min\"] === \"number\" && typeof out[\"max\"] === \"number\" && out[\"min\"] > out[\"max\"]) faults.push(`${at}: \"min\" is more than \"max\".`);\n return out;\n}\n\n/** This function gives the fields of a `strategy` declaration, restored from a file. */\nfunction readStrategyFields(at: string, raw: Fields, faults: string[]): Fields {\n const out: Record<string, unknown> = {};\n if (raw[\"step\"] !== undefined) {\n if (isText(raw[\"step\"])) out[\"step\"] = raw[\"step\"];\n else faults.push(`${at}: \"step\" is not a text.`);\n }\n if (raw[\"kinds\"] !== undefined) {\n if (isTextList(raw[\"kinds\"]) && raw[\"kinds\"].every((k) => STRATEGY_KINDS.includes(k))) out[\"kinds\"] = raw[\"kinds\"];\n else faults.push(`${at}: \"kinds\" is not a list of strategy kinds.`);\n }\n if (raw[\"optionsKey\"] !== undefined) {\n if (isText(raw[\"optionsKey\"])) out[\"optionsKey\"] = raw[\"optionsKey\"];\n else faults.push(`${at}: \"optionsKey\" is not a text.`);\n }\n for (const f of [\"inlineOptions\", \"optIn\"]) {\n if (raw[f] === undefined) continue;\n if (typeof raw[f] === \"boolean\") out[f] = raw[f];\n else faults.push(`${at}: \"${f}\" is not true or false.`);\n }\n if (raw[\"needs\"] !== undefined) {\n if (isFields(raw[\"needs\"]) && Object.values(raw[\"needs\"]).every(isText)) out[\"needs\"] = raw[\"needs\"];\n else faults.push(`${at}: \"needs\" is not a record of texts.`);\n }\n if (raw[\"inlineOptions\"] === true && raw[\"optionsKey\"] !== undefined) faults.push(`${at}: \"inlineOptions\" and \"optionsKey\" give two places for the options.`);\n if (raw[\"default\"] !== undefined) {\n if (isText(raw[\"default\"]) || (raw[\"inlineOptions\"] === true && isMember(raw[\"default\"]))) out[\"default\"] = raw[\"default\"];\n else faults.push(`${at}: the default is not the key of a strategy.`);\n }\n return out;\n}\n\n/** This function gives the fields that belong only to the type of a declaration, restored from a file. */\nfunction readTypeFields(at: string, type: string, raw: Fields, faults: string[]): Fields {\n switch (type) {\n case \"number\":\n case \"integer\":\n refuseUnknown(at, raw, NUMBER_FIELDS, faults);\n return readNumberFields(at, raw, faults);\n case \"boolean\":\n refuseUnknown(at, raw, COMMON_FIELDS, faults);\n if (raw[\"default\"] !== undefined && typeof raw[\"default\"] !== \"boolean\") faults.push(`${at}: the default is not true or false.`);\n return raw[\"default\"] === undefined ? {} : { default: raw[\"default\"] };\n case \"enum\": {\n refuseUnknown(at, raw, ENUM_FIELDS, faults);\n if (!isTextList(raw[\"values\"])) faults.push(`${at}: \"values\" is not a list of texts.`);\n if (raw[\"custom\"] !== undefined && raw[\"custom\"] !== \"function\") faults.push(`${at}: \"custom\" is not \"function\".`);\n return { values: raw[\"values\"], ...(raw[\"custom\"] === undefined ? {} : { custom: raw[\"custom\"] }), ...(raw[\"default\"] === undefined ? {} : { default: raw[\"default\"] }) };\n }\n case \"strategy\":\n refuseUnknown(at, raw, STRATEGY_FIELDS, faults);\n return readStrategyFields(at, raw, faults);\n case \"list\":\n refuseUnknown(at, raw, LIST_FIELDS, faults);\n return readListFields(at, raw, faults);\n case \"object\":\n refuseUnknown(at, raw, COMMON_FIELDS, faults);\n return raw[\"default\"] === undefined ? {} : { default: raw[\"default\"] };\n case \"function\":\n refuseUnknown(at, raw, COMMON_FIELDS, faults);\n if (raw[\"default\"] !== undefined) faults.push(`${at}: a function option has no default in JSON.`);\n return {};\n default:\n faults.push(`${at}: the type \"${type}\" is unknown.`);\n return {};\n }\n}\n\n/** This function adds the faults of the statement of an absent default, and gives the statement. */\nfunction readNoDefault(at: string, raw: unknown, faults: string[]): Fields | undefined {\n if (!isFields(raw)) {\n faults.push(`${at}: \"noDefault\" is not an object.`);\n return undefined;\n }\n refuseUnknown(`${at}: \"noDefault\"`, raw, [\"reason\", \"describe\"], faults);\n if (!NO_DEFAULT_REASONS.includes(raw[\"reason\"] as NoDefaultReason)) faults.push(`${at}: the reason of \"noDefault\" is unknown.`);\n if (!isText(raw[\"describe\"])) faults.push(`${at}: \"noDefault\" has no description.`);\n return { reason: raw[\"reason\"], describe: raw[\"describe\"] };\n}\n\n/** This function restores one declaration of a file. An item of a list has only the fields of its type. */\nfunction readOption(at: string, raw: unknown, item: boolean, faults: string[]): AnyOption | ListItem | undefined {\n if (!isFields(raw)) {\n faults.push(`${at} is not an object.`);\n return undefined;\n }\n const type = raw[\"type\"];\n if (typeof type !== \"string\") {\n faults.push(`${at} has no type.`);\n return undefined;\n }\n const before = faults.length;\n const fields = readTypeFields(at, type, raw, faults);\n const out: Record<string, unknown> = { type, ...fields };\n if (item) {\n for (const f of [\"describe\", \"default\", \"noDefault\", \"when\"]) if (raw[f] !== undefined) faults.push(`${at}: an item of a list has no \"${f}\".`);\n } else {\n if (isText(raw[\"describe\"])) out[\"describe\"] = raw[\"describe\"];\n else faults.push(`${at} has no description.`);\n const hasDefault = raw[\"default\"] !== undefined;\n const hasNoDefault = raw[\"noDefault\"] !== undefined;\n if (hasDefault === hasNoDefault) faults.push(`${at} has ${hasDefault ? \"both\" : \"neither\"} of \"default\" and \"noDefault\".`);\n if (hasNoDefault) out[\"noDefault\"] = readNoDefault(at, raw[\"noDefault\"], faults);\n if (raw[\"when\"] !== undefined) out[\"when\"] = raw[\"when\"];\n }\n return faults.length === before ? (out as unknown as AnyOption) : undefined;\n}\n\n/** This function adds the faults of the condition of an option, against the options before it. */\nfunction checkWhen(at: string, when: unknown, earlier: readonly string[], faults: string[]): void {\n if (!isFields(when) || !isText(when[\"param\"]) || !Array.isArray(when[\"in\"])) {\n faults.push(`${at}: \"when\" has no \"param\" and \"in\".`);\n return;\n }\n refuseUnknown(`${at}: \"when\"`, when, [\"param\", \"in\"], faults);\n if (!earlier.includes(when[\"param\"])) faults.push(`${at}: \"when\" names \"${when[\"param\"]}\", which is not an earlier option.`);\n}\n\n/** This function adds the faults of the limits of an entry. */\nfunction checkLimits(at: string, limits: unknown, faults: string[]): void {\n if (!isFields(limits)) {\n faults.push(`${at}: \"limits\" is not an object.`);\n return;\n }\n for (const [name, raw] of Object.entries(limits)) {\n const place = `${at}: the limit \"${name}\"`;\n if (!isFields(raw)) {\n faults.push(`${place} is not an object.`);\n continue;\n }\n refuseUnknown(place, raw, [\"min\", \"max\", \"describe\"], faults);\n if (!isText(raw[\"describe\"])) faults.push(`${place} has no description.`);\n if (raw[\"min\"] === undefined && raw[\"max\"] === undefined) faults.push(`${place} has no \"min\" and no \"max\".`);\n for (const f of [\"min\", \"max\"]) if (raw[f] !== undefined && !isFiniteNumber(raw[f])) faults.push(`${place}: \"${f}\" is not a finite number.`);\n if (isFiniteNumber(raw[\"min\"]) && isFiniteNumber(raw[\"max\"]) && raw[\"min\"] > raw[\"max\"]) faults.push(`${place}: \"min\" is more than \"max\".`);\n }\n}\n\n/** This function adds the faults of the evidence of one output row. */\nfunction checkEvidence(at: string, property: unknown, rowClass: unknown, raw: unknown, faults: string[]): void {\n if (!isFields(raw)) {\n faults.push(`${at}: \"evidence\" is not an object.`);\n return;\n }\n refuseUnknown(`${at}: the evidence`, raw, EVIDENCE_FIELDS, faults);\n for (const f of [\"source\", \"optionSet\", \"catalogVersion\"]) if (!isText(raw[f])) faults.push(`${at}: the evidence field \"${f}\" is not a text.`);\n const count = (v: unknown): v is number => Number.isInteger(v) && (v as number) >= 0;\n if (!count(raw[\"inputs\"])) faults.push(`${at}: the evidence field \"inputs\" is not a count.`);\n const grid = OUTPUT_GRID_PROPERTIES.includes(property as string);\n for (const f of [\"fractionalInputs\", \"nearWholeInputs\"]) if (grid ? !count(raw[f]) : raw[f] !== undefined && !count(raw[f])) faults.push(`${at}: the evidence field \"${f}\" is not a count.`);\n const [inputs, fractionalInputs, nearWholeInputs] = [raw[\"inputs\"], raw[\"fractionalInputs\"], raw[\"nearWholeInputs\"]];\n if (!grid || !count(inputs) || !count(fractionalInputs) || !count(nearWholeInputs)) return;\n if (fractionalInputs + nearWholeInputs > inputs) faults.push(`${at}: the fractional and near-whole counts are more than the inputs.`);\n const expected = outputGridClass({ inputs, fractionalInputs, nearWholeInputs });\n if (rowClass !== expected) faults.push(`${at}: the evidence gives the class \"${expected}\".`);\n}\n\n/** This function adds the faults of the field `output` of one entry. */\nfunction checkOutput(at: string, raw: unknown, schema: unknown, faults: string[]): void {\n if (schema === STRATEGY_CATALOG_SCHEMAS[0]) faults.push(`${at}: the field \"output\" needs the schema ${STRATEGY_CATALOG_SCHEMAS[1]} or a newer schema.`);\n if (!Array.isArray(raw) || raw.length === 0) {\n faults.push(`${at}: \"output\" is not a list with rows.`);\n return;\n }\n const seen = new Set<string>();\n (raw as readonly unknown[]).forEach((row, i) => {\n const place = `${at}: the output row ${i}`;\n if (!isFields(row)) {\n faults.push(`${place} is not an object.`);\n return;\n }\n refuseUnknown(place, row, ROW_FIELDS, faults);\n for (const f of [\"property\", \"class\"]) if (!isText(row[f])) faults.push(`${place}: \"${f}\" is not a text.`);\n checkEvidence(place, row[\"property\"], row[\"class\"], row[\"evidence\"], faults);\n const optionSet = isFields(row[\"evidence\"]) ? row[\"evidence\"][\"optionSet\"] : undefined;\n const name = JSON.stringify([row[\"property\"], optionSet]);\n if (seen.has(name)) faults.push(`${place}: the property and the option set are not unique.`);\n seen.add(name);\n });\n}\n\n/** This function restores one entry of a file. */\nfunction readEntry(at: string, raw: unknown, schema: unknown, faults: string[]): CatalogEntry | undefined {\n if (!isFields(raw)) {\n faults.push(`${at} is not an object.`);\n return undefined;\n }\n const before = faults.length;\n refuseUnknown(at, raw, ENTRY_FIELDS, faults);\n for (const f of [\"key\", \"id\", \"family\", \"describe\"]) if (!isText(raw[f])) faults.push(`${at}: \"${f}\" is not a text.`);\n if (raw[\"step\"] !== undefined && !isText(raw[\"step\"])) faults.push(`${at}: \"step\" is not a text.`);\n if (raw[\"determinismNote\"] !== undefined && !isText(raw[\"determinismNote\"])) faults.push(`${at}: \"determinismNote\" is not a text.`);\n if (!STRATEGY_KINDS.includes(raw[\"kind\"] as string)) faults.push(`${at}: \"kind\" is unknown.`);\n for (const f of [\"deterministic\", \"optIn\"]) if (typeof raw[f] !== \"boolean\") faults.push(`${at}: \"${f}\" is not true or false.`);\n if (raw[\"baseline\"] !== undefined && raw[\"baseline\"] !== true) faults.push(`${at}: \"baseline\" is not true.`);\n if (raw[\"baseline\"] === true && raw[\"optIn\"] !== true) faults.push(`${at}: a baseline has \"optIn\" true.`);\n if (!isFields(raw[\"supports\"]) || !Object.values(raw[\"supports\"]).every(isTextList)) faults.push(`${at}: \"supports\" is not a record of text lists.`);\n checkLimits(at, raw[\"limits\"], faults);\n if (raw[\"output\"] !== undefined) checkOutput(at, raw[\"output\"], schema, faults);\n if (raw[\"fingerprint\"] !== undefined) {\n if (schema !== STRATEGY_CATALOG_SCHEMAS[2]) faults.push(`${at}: the field \"fingerprint\" needs the schema ${STRATEGY_CATALOG_SCHEMAS[2]}.`);\n if (!isText(raw[\"fingerprint\"]) || !FINGERPRINT.test(raw[\"fingerprint\"])) faults.push(`${at}: \"fingerprint\" is not 16 lowercase hex digits.`);\n }\n if (isText(raw[\"id\"]) && raw[\"key\"] !== catalogKey(raw[\"id\"], raw[\"step\"] as string | undefined)) faults.push(`${at}: the key does not follow from \"step\" and \"id\".`);\n if (!isFields(raw[\"options\"])) {\n faults.push(`${at}: \"options\" is not an object.`);\n return undefined;\n }\n const options: Record<string, AnyOption> = {};\n const earlier: string[] = [];\n for (const [key, value] of Object.entries(raw[\"options\"])) {\n const place = `${at}: the option \"${key}\"`;\n const option = readOption(place, value, false, faults) as AnyOption | undefined;\n if (option !== undefined) {\n options[key] = option;\n for (const message of declarationIssues(key, option)) faults.push(`${at}: ${message}`);\n if (option.when !== undefined) checkWhen(place, option.when, earlier, faults);\n }\n earlier.push(key);\n }\n if (faults.length !== before) return undefined;\n const { step, determinismNote } = raw as { readonly step?: string; readonly determinismNote?: string };\n return {\n key: raw[\"key\"] as string,\n id: raw[\"id\"] as string,\n ...(step === undefined ? {} : { step }),\n family: raw[\"family\"] as string,\n kind: raw[\"kind\"] as StrategyKind,\n describe: raw[\"describe\"] as string,\n supports: raw[\"supports\"] as Supports,\n limits: raw[\"limits\"] as Readonly<Record<string, CatalogLimit>>,\n deterministic: raw[\"deterministic\"] as boolean,\n ...(determinismNote === undefined ? {} : { determinismNote }),\n optIn: raw[\"optIn\"] as boolean,\n ...(raw[\"baseline\"] === true ? { baseline: true as const } : {}),\n ...(raw[\"output\"] === undefined ? {} : { output: raw[\"output\"] as readonly OutputRow[] }),\n ...(raw[\"fingerprint\"] === undefined ? {} : { fingerprint: raw[\"fingerprint\"] as string }),\n options,\n };\n}\n\n/**\n * This function gives the strategies that a chooser offers, by the `step`, `kinds`, `optIn` and `needs` of an option. Thus no chooser keeps a copy of this rule.\n * A baseline is not in the result. A list gives the strategies of its items. An option of each other type gives nothing.\n * A strategy that does not list a dimension of `needs` has no declared limit there, so the option offers it.\n * Without a declaration, the function gives each strategy that is not a baseline.\n */\nexport function catalogChoices(strategies: readonly CatalogEntry[], declaration?: AnyOption | ListItem): readonly CatalogEntry[] {\n const offered = strategies.filter((e) => e.baseline !== true);\n if (declaration === undefined) return offered;\n const d = (declaration.type === \"list\" ? declaration.of : declaration) as ValueOption | undefined;\n if (d?.type !== \"strategy\") return [];\n const needs = Object.entries(d.needs ?? {});\n return offered.filter(\n (e) =>\n (d.step === undefined || e.step === d.step) &&\n (d.kinds === undefined || d.kinds.includes(e.kind)) &&\n (d.optIn === undefined || d.optIn === e.optIn) &&\n needs.every(([dimension, value]) => e.supports[dimension]?.includes(value) !== false),\n );\n}\n\n/** This function adds one fault for each option of a member that its chosen strategy does not take. */\nfunction checkMember(at: string, member: StrategyMember, chosen: CatalogEntry, faults: string[]): void {\n for (const [key, value] of Object.entries(member.options ?? {})) {\n const declaration = chosen.options[key];\n if (declaration === undefined) {\n faults.push(`${at}: the default gives \"${key}\", and ${chosen.key} has no such option.`);\n continue;\n }\n const issue = declaration.type === \"strategy\" ? undefined : optionIssue(key, decodeOptionValue(value, declaration), declaration);\n if (issue !== undefined) faults.push(`${at}: ${issue.message}`);\n }\n}\n\n/** This function adds one fault for each reference that names no strategy of the catalog, or a strategy that the option does not take. */\nfunction checkReferences(entries: readonly CatalogEntry[], faults: string[]): void {\n const check = (at: string, o: AnyOption | ListItem, values: readonly unknown[]): void => {\n const choices = catalogChoices(entries, o);\n if (choices.length === 0) faults.push(`${at} takes no strategy of the catalog.`);\n for (const value of values) {\n const inline = ((o.type === \"list\" ? o.of : o) as ValueOption).inlineOptions === true && isMember(value);\n const key = inline ? value.strategy : value;\n const chosen = choices.find((e) => e.key === key);\n if (chosen === undefined) faults.push(`${at}: the default ${JSON.stringify(key)} is not a strategy that the option takes.`);\n else if (inline) checkMember(at, value, chosen, faults);\n }\n };\n for (const entry of entries) {\n for (const [key, o] of Object.entries(entry.options)) {\n const at = `${entry.key}: the option \"${key}\"`;\n if (o.type === \"strategy\") {\n check(at, o, o.default === undefined ? [] : [o.default]);\n if (o.optionsKey !== undefined && (o.optionsKey === key || entry.options[o.optionsKey]?.type !== \"object\")) faults.push(`${at}: \"optionsKey\" does not name an object option.`);\n } else if (o.type === \"list\" && o.of?.type === \"strategy\") {\n check(at, o, Array.isArray(o.default) ? o.default : []);\n }\n if (o.type === \"list\" && Array.isArray(o.default)) {\n if (o.min !== undefined && o.default.length < o.min) faults.push(`${at}: the default has fewer than ${o.min} items.`);\n if (o.max !== undefined && o.default.length > o.max) faults.push(`${at}: the default has more than ${o.max} items.`);\n }\n }\n }\n}\n\n/**\n * This function reads a catalog from parsed JSON, in each schema of `STRATEGY_CATALOG_SCHEMAS`. It refuses each unknown field and each other schema.\n * It gives the catalog with its `Infinity` values restored, or the list of all faults.\n */\nexport function parseStrategyCatalog(value: unknown): StrategyCatalogParse {\n const faults: string[] = [];\n if (!isFields(value)) return { ok: false, faults: [\"The catalog is not an object.\"] };\n refuseUnknown(\"The catalog\", value, TOP_FIELDS, faults);\n const schema = value[\"schema\"];\n if (!(STRATEGY_CATALOG_SCHEMAS as readonly unknown[]).includes(schema)) faults.push(`The schema is not one of ${STRATEGY_CATALOG_SCHEMAS.join(\", \")}.`);\n if (!isText(value[\"engine\"])) faults.push(`\"engine\" is not a text.`);\n if (!isText(value[\"version\"])) faults.push(`\"version\" is not a text.`);\n if (!Array.isArray(value[\"strategies\"])) return { ok: false, faults: [...faults, `\"strategies\" is not a list.`] };\n const entries: CatalogEntry[] = [];\n (value[\"strategies\"] as readonly unknown[]).forEach((raw, i) => {\n const entry = readEntry(`The strategy ${isFields(raw) && isText(raw[\"key\"]) ? raw[\"key\"] : i}`, raw, schema, faults);\n if (entry !== undefined) entries.push(entry);\n });\n for (let i = 1; i < entries.length; i++) {\n const [a, b] = [entries[i - 1]!.key, entries[i]!.key];\n if (a === b) faults.push(`The key ${a} is not unique.`);\n else if (a > b) faults.push(`The key ${b} is out of order.`);\n }\n // A bad entry is not in the list, so each reference to it would give a false fault.\n if (faults.length === 0) checkReferences(entries, faults);\n if (faults.length > 0) return { ok: false, faults };\n return { ok: true, catalog: { schema: schema as StrategyCatalogSchema, engine: value[\"engine\"] as string, version: value[\"version\"] as string, strategies: entries } };\n}\n\n/** This function gives the file form of a number. A value that is not finite becomes its name, and `NaN` stays for the writer to refuse. */\nconst writeNumber = (v: unknown): unknown => (v === Infinity ? \"Infinity\" : v === -Infinity ? \"-Infinity\" : v);\n\n/**\n * This function gives the value of an option for a call of the engine, from its JSON form.\n * The strings `\"Infinity\"` and `\"-Infinity\"` become numbers in a number option, and in a list of numbers. Each other value stays as it is.\n */\nexport function decodeOptionValue(value: unknown, declaration: AnyOption | ListItem): unknown {\n if (declaration.type === \"number\" || declaration.type === \"integer\") return readNumber(value) ?? value;\n if (declaration.type === \"list\" && declaration.of !== undefined && Array.isArray(value)) {\n const item = declaration.of;\n return value.map((v: unknown) => decodeOptionValue(v, item));\n }\n return value;\n}\n\n/** This function gives the JSON form of the value of an option. It is the inverse of `decodeOptionValue`. */\nexport function encodeOptionValue(value: unknown, declaration: AnyOption | ListItem): unknown {\n if (declaration.type === \"number\" || declaration.type === \"integer\") return writeNumber(value);\n if (declaration.type === \"list\" && declaration.of !== undefined && Array.isArray(value)) {\n const item = declaration.of;\n return value.map((v: unknown) => encodeOptionValue(v, item));\n }\n return value;\n}\n\n/** This function gives the file form of a declaration, with its fields in the order of the file. */\nfunction writeOption(option: AnyOption | ListItem): Fields {\n const o = option as unknown as Fields;\n for (const key of Object.keys(o)) if (!OPTION_ORDER.includes(key) && o[key] !== undefined) throw new Error(`The field \"${key}\" is not a field of a declaration.`);\n const numeric = o[\"type\"] === \"number\" || o[\"type\"] === \"integer\";\n const out: Record<string, unknown> = {};\n for (const f of OPTION_ORDER) {\n const v = o[f];\n if (v === undefined) continue;\n if (f === \"of\") out[f] = writeOption(v as ListItem);\n else if (numeric && f === \"default\") out[f] = writeNumber(v);\n else if (numeric && (f === \"special\" || f === \"marks\")) out[f] = (v as readonly number[]).map(writeNumber);\n else out[f] = v;\n }\n return out;\n}\n\n/** This function gives the file form of one output row, with the fields in the order of the file. */\nfunction writeRow(row: OutputRow): unknown {\n const e = row.evidence;\n return {\n property: row.property,\n class: row.class,\n evidence: {\n inputs: e.inputs,\n ...(e.fractionalInputs === undefined ? {} : { fractionalInputs: e.fractionalInputs }),\n ...(e.nearWholeInputs === undefined ? {} : { nearWholeInputs: e.nearWholeInputs }),\n source: e.source,\n optionSet: e.optionSet,\n catalogVersion: e.catalogVersion,\n },\n };\n}\n\n/** This function gives the file form of an entry, with its fields in the order of the file. */\nfunction writeEntry(e: CatalogEntry): Fields {\n const options = Object.fromEntries(Object.entries(e.options).map(([key, o]) => [key, writeOption(o)]));\n return {\n key: e.key,\n id: e.id,\n ...(e.step === undefined ? {} : { step: e.step }),\n family: e.family,\n kind: e.kind,\n describe: e.describe,\n supports: e.supports,\n limits: e.limits,\n deterministic: e.deterministic,\n ...(e.determinismNote === undefined ? {} : { determinismNote: e.determinismNote }),\n optIn: e.optIn,\n ...(e.baseline === true ? { baseline: true } : {}),\n ...(e.output === undefined ? {} : { output: e.output.map(writeRow) }),\n ...(e.fingerprint === undefined ? {} : { fingerprint: e.fingerprint }),\n options,\n };\n}\n\n/** This function gives the place of each value that JSON cannot hold: a function, `undefined` in a list, or a number that is not finite. */\nfunction unsafeValues(v: unknown, at: string): string[] {\n if (typeof v === \"function\") return [`${at} is a function.`];\n if (typeof v === \"number\") return Number.isFinite(v) ? [] : [`${at} is ${v}.`];\n if (Array.isArray(v)) return v.flatMap((x: unknown, i) => (x === undefined ? [`${at}[${i}] is undefined.`] : unsafeValues(x, `${at}[${i}]`)));\n if (isFields(v)) return Object.entries(v).flatMap(([k, x]) => unsafeValues(x, `${at}.${k}`));\n return [];\n}\n\n/**\n * This function gives the text of the catalog file, sorted by key. The same source and version give the same bytes.\n * The file has the oldest schema that holds it. A catalog with no `output` and no `fingerprint` stays valid for a reader of the schema 1.\n * A catalog with no `fingerprint` stays valid for a reader of the schema 2.\n * The caller gives the version from `package.json`. The function throws an error if the file breaks a rule of the format.\n */\nexport function writeStrategyCatalog(source: StrategyCatalogSource, version: string): string {\n const strategies = [...source.strategies].sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0)).map(writeEntry);\n const has = (field: \"output\" | \"fingerprint\"): boolean => source.strategies.some((e) => e[field] !== undefined);\n const schema = has(\"fingerprint\") ? STRATEGY_CATALOG_SCHEMAS[2] : has(\"output\") ? STRATEGY_CATALOG_SCHEMAS[1] : STRATEGY_CATALOG_SCHEMAS[0];\n const doc = { schema, engine: source.engine, version, strategies };\n const unsafe = unsafeValues(doc, \"catalog\");\n if (unsafe.length > 0) throw new Error(`The catalog of ${source.engine} has values that JSON cannot hold: ${unsafe.join(\" \")}`);\n const text = `${JSON.stringify(doc, null, 2)}\\n`;\n const parsed = parseStrategyCatalog(JSON.parse(text));\n if (!parsed.ok) throw new Error(`The catalog of ${source.engine} breaks the format: ${parsed.faults.join(\" \")}`);\n return text;\n}\n\n/** This function gives the default of each option of an entry that has a default. */\nexport function catalogDefaults(entry: CatalogEntry): Record<string, unknown> {\n return Object.fromEntries(Object.entries(entry.options).flatMap(([key, o]) => (o.default === undefined ? [] : [[key, o.default]])));\n}\n\n/**\n * This function gives the catalog declarations of a strategy from its live `defaults` and its schema. Thus each engine has no copy of this rule.\n * A live default goes on its declaration. A function stays out, so the declaration needs its own `noDefault`.\n */\nexport function catalogOptions(defaults: Readonly<Record<string, unknown>>, schema: Readonly<Record<string, AnyOption>>, options: CatalogOptionsOptions = {}): Record<string, AnyOption> {\n const out: Record<string, AnyOption> = {};\n for (const [key, declaration] of Object.entries(schema)) {\n const live = key in defaults ? defaults[key] : declaration.default;\n const object = declaration.type === \"strategy\" && typeof live === \"object\" && live !== null;\n const value = object && !(declaration.inlineOptions === true && isMember(live)) ? options.strategyKey?.(live) : live;\n const { default: _unused, ...rest } = declaration;\n out[key] = (value === undefined || typeof value === \"function\" ? rest : { ...rest, default: value }) as AnyOption;\n }\n return out;\n}\n\n/** This function adds the faults of one entry against its live facts. */\nfunction checkLive(entry: CatalogEntry, live: RegistryEntry, faults: string[]): void {\n const defaults = catalogDefaults(entry);\n if (entry.optIn !== live.optIn) faults.push(`${entry.key}: \"optIn\" is ${entry.optIn}, and the engine gives ${live.optIn}.`);\n if ((entry.baseline === true) !== (live.baseline === true)) faults.push(`${entry.key}: \"baseline\" differs from the engine.`);\n const limits = Object.fromEntries(Object.entries(entry.limits).map(([name, { min, max }]) => [name, { min, max }]));\n if (canonicalJson(limits) !== canonicalJson(live.limits ?? {})) faults.push(`${entry.key}: \"limits\" differ from the limits of the engine.`);\n for (const [key, value] of Object.entries(live.defaults)) {\n const option = entry.options[key];\n if (option === undefined) {\n faults.push(`${entry.key}: the default \"${key}\" has no declaration.`);\n } else if (typeof value === \"function\") {\n if (option.noDefault?.reason !== \"function\") faults.push(`${entry.key}: the default \"${key}\" is code, and its \"noDefault\" does not say it.`);\n } else if (option.type !== \"strategy\" || typeof value === \"string\" || (option.inlineOptions === true && isMember(value))) {\n const same = Object.is(value, defaults[key]) || canonicalJson(value) === canonicalJson(defaults[key]);\n if (!same) faults.push(`${entry.key}: the default \"${key}\" differs from the live default.`);\n }\n }\n}\n\n/** This function runs each entry that claims determinism two times, and compares the bytes. */\nfunction checkDeterminism(entry: CatalogEntry, live: RegistryEntry, faults: string[], notRun: string[]): void {\n if (!entry.deterministic) return;\n if (live.run === undefined) {\n notRun.push(`${entry.key}: the engine gives no fixture.`);\n return;\n }\n try {\n if (live.run() !== live.run()) faults.push(`${entry.key}: \"deterministic\" is true, and two runs differ.`);\n } catch (error) {\n notRun.push(`${entry.key}: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/** This function runs each probe on an entry, and compares the refusal with `supports`. */\nfunction checkProbes(entry: CatalogEntry, probes: readonly SupportProbe[], faults: string[], notRun: string[]): void {\n for (const probe of probes) {\n const name = `${entry.key} on ${probe.field} ${probe.value}`;\n const declared = entry.supports[probe.field];\n const takes = declared === undefined || declared.includes(probe.value);\n let refused: boolean | undefined;\n try {\n refused = probe.refuses(entry.key);\n } catch (error) {\n notRun.push(`${name}: ${error instanceof Error ? error.message : String(error)}`);\n continue;\n }\n if (refused === undefined) notRun.push(`${name}: the input cannot go to this strategy.`);\n else if (refused === takes) faults.push(`${name}: \"supports\" ${takes ? \"takes\" : \"refuses\"} the value, and the engine ${refused ? \"refuses\" : \"takes\"} it.`);\n }\n}\n\n/** This function runs each strategy that an option of an entry offers, because a chooser must not offer a strategy that fails. */\nfunction checkChoices(entry: CatalogEntry, strategies: readonly CatalogEntry[], refuses: NonNullable<CatalogCheckOptions[\"refusesChoice\"]>, faults: string[], notRun: string[]): void {\n for (const [key, declaration] of Object.entries(entry.options)) {\n for (const choice of catalogChoices(strategies, declaration)) {\n const name = `${entry.key}: the option \"${key}\" with ${choice.key}`;\n let refused: boolean | undefined;\n try {\n refused = refuses(entry.key, key, choice.key);\n } catch (error) {\n notRun.push(`${name}: ${error instanceof Error ? error.message : String(error)}`);\n continue;\n }\n if (refused === undefined) notRun.push(`${name}: the input cannot go to this strategy.`);\n else if (refused) faults.push(`${name}: the option offers this strategy, and the engine refuses it.`);\n }\n }\n}\n\n/** The lists that the check of the spaces writes, and the routes that it reads. */\ninterface SpaceCheck {\n readonly routes: Readonly<Record<string, ParamRoute>>;\n /** The keys of the routes that matched a place. */\n readonly used: Set<string>;\n readonly faults: string[];\n readonly notMatched: string[];\n readonly spaceOnly: string[];\n}\n\n/** This function examines each value of one param against the declaration of its option, through the route of the param. */\nfunction checkParamValues(entry: CatalogEntry, engine: string, place: string, option: string, values: readonly ParamValue[], route: ParamRoute | undefined, check: SpaceCheck): void {\n const declaration = entry.options[option]!;\n const toOption = route !== undefined && \"value\" in route ? route.value : undefined;\n for (const value of values) {\n let mapped: unknown = value;\n try {\n if (toOption !== undefined) mapped = toOption(value);\n } catch (error) {\n check.faults.push(`${entry.key}: the route \"${place}\" fails on ${String(value)}: ${error instanceof Error ? error.message : String(error)}`);\n continue;\n }\n if (mapped === undefined) continue;\n const issue = optionIssue(option, mapped, declaration);\n if (issue !== undefined) check.faults.push(`${entry.key}: the space ${engine} is outside the declaration. ${issue.message}`);\n }\n}\n\n/** This function examines each param of a space against the declaration of its option, with the routes of the engine. */\nfunction checkSpaceParams(space: StrategySpace, entries: ReadonlyMap<string, CatalogEntry>, check: SpaceCheck): void {\n const { routes, used, faults, notMatched, spaceOnly } = check;\n const routeOf = (place: string): ParamRoute | undefined => {\n const route = routes[place];\n if (route !== undefined) used.add(place);\n return route;\n };\n for (const stage of space.stages) {\n for (const option of stage.options) {\n const name = `${stage.name}/${option.id}`;\n const entry = entries.get(name) ?? entries.get(option.id);\n if (entry === undefined) {\n const reason = routes[name];\n if (reason !== undefined && \"spaceOnly\" in reason) {\n used.add(name);\n spaceOnly.push(`${name}: ${reason.spaceOnly}`);\n } else {\n notMatched.push(name);\n }\n continue;\n }\n for (const param of option.params) {\n const place = `${name}.${param.name}`;\n const route = routeOf(place);\n if (route !== undefined && \"spaceOnly\" in route) {\n if (entry.options[param.name] === undefined) spaceOnly.push(`${place}: ${route.spaceOnly}`);\n else faults.push(`${entry.key}: the route \"${place}\" says that the param is only in the space, and the strategy has this option.`);\n continue;\n }\n const target = route?.option ?? param.name;\n if (entry.options[target] === undefined) {\n if (route === undefined) notMatched.push(place);\n else faults.push(`${entry.key}: the route \"${place}\" names \"${target}\", and the strategy has no such option.`);\n continue;\n }\n const values = [param.min, param.max, ...(param.values ?? []), param.default].filter((v): v is ParamValue => v !== undefined);\n checkParamValues(entry, space.engine, place, target, values, route, check);\n }\n }\n }\n}\n\n/** This function adds one fault for each route that matched nothing, and for each `spaceOnly` route with no reason. */\nfunction checkRoutes({ routes, used, faults }: SpaceCheck): void {\n for (const [place, route] of Object.entries(routes)) {\n if (!used.has(place)) faults.push(`The route \"${place}\" matches nothing in the spaces.`);\n if (\"spaceOnly\" in route && !isText(route.spaceOnly)) faults.push(`The route \"${place}\" has no reason.`);\n }\n}\n\n/**\n * This function examines a catalog against its engine: the live defaults, the set of strategies and a round trip through JSON.\n * It also examines the claims of determinism, `supports`, `limits`, the choices of each strategy option and the spaces.\n * A claim that no run can examine goes to `notRun`, by key, so a test can state their count.\n */\nexport function checkCatalog(source: StrategyCatalogSource, registry: readonly RegistryEntry[], options: CatalogCheckOptions = {}): CatalogCheck {\n const faults: string[] = [];\n const notRun: string[] = [];\n const notMatched: string[] = [];\n const spaceOnly: string[] = [];\n let text: string | undefined;\n try {\n text = writeStrategyCatalog(source, \"0.0.0\");\n } catch (error) {\n faults.push(error instanceof Error ? error.message : String(error));\n }\n if (text !== undefined) {\n const parsed = parseStrategyCatalog(JSON.parse(text));\n if (!parsed.ok || writeStrategyCatalog(parsed.catalog, \"0.0.0\") !== text) faults.push(\"A round trip through JSON changes the catalog.\");\n }\n const entries = new Map(source.strategies.map((e) => [e.key, e]));\n const live = new Map(registry.map((e) => [e.key, e]));\n for (const key of live.keys()) if (!entries.has(key)) faults.push(`${key} is in the engine, and not in the catalog.`);\n for (const key of entries.keys()) if (!live.has(key)) faults.push(`${key} is in the catalog, and not in the engine.`);\n for (const [key, entry] of entries) {\n const facts = live.get(key);\n if (facts === undefined) continue;\n checkLive(entry, facts, faults);\n checkDeterminism(entry, facts, faults, notRun);\n checkProbes(entry, options.probes ?? [], faults, notRun);\n if (options.refusesChoice !== undefined) checkChoices(entry, source.strategies, options.refusesChoice, faults, notRun);\n }\n const spaceCheck: SpaceCheck = { routes: options.paramRoutes ?? {}, used: new Set(), faults, notMatched, spaceOnly };\n for (const space of options.spaces ?? []) checkSpaceParams(space, entries, spaceCheck);\n checkRoutes(spaceCheck);\n return { faults, notRun, notMatched, spaceOnly };\n}\n","// The verdict over families (`docs/VERDICT.md`). highways, packing and the joint bench use the same rule, so they give the same verdict.\nimport { deriveSeed } from \"@mark1russell7/rigor-generators\";\nimport { bootstrap, bootstrapStrata, type Interval, signFlipTest, signTest } from \"@mark1russell7/rigor-statistics\";\nimport { compareMeasure, type MeasureSpec } from \"./measures.ts\";\nimport type { LayoutRecord } from \"./record.ts\";\n\n/**\n * The largest count of inputs for the exact permutation test. Up to this count, the test enumerates all `2^n` sign sets.\n * At 16 inputs, that is 65 536 sign sets, approximately 3 times the default draws. Above it, the cost doubles with each input, so the test uses seeded draws.\n */\nexport const VERDICT_EXACT_MAX = 16;\n\n/** The largest value of the option `exactMax`. At 20 inputs, the exact test has approximately 1 million sign sets. */\nexport const VERDICT_EXACT_CAP = 20;\n\n/** The default count of the samples of each bootstrap. It is the parameter `bootstrapRuns` of `docs/PROMOTION.md`. */\nexport const VERDICT_RUNS = 10000;\n\n/** The default count of the random sign sets of the permutation test above `VERDICT_EXACT_MAX` inputs. */\nexport const VERDICT_DRAWS = 20000;\n\n/** The default seed of the bootstraps and of the random sign sets. */\nexport const VERDICT_SEED = 1;\n\n/** The fields of a record that the verdict reads. */\nexport type VerdictRecord = Pick<LayoutRecord, \"strategy\" | \"input\" | \"seed\" | \"measures\"> & { readonly skipped?: string };\n\n/** One side of a verdict: a strategy id, or a test that selects the records of the side. */\nexport type VerdictSide<R extends VerdictRecord = VerdictRecord> = string | ((record: R) => boolean);\n\n/** The arguments of `verdict`. `tie` and `level` have no default. */\nexport interface VerdictOptions<R extends VerdictRecord = VerdictRecord> {\n /** The unit of the verdict. The family is the only unit. */\n readonly by: \"family\";\n /** The hook that gives the family of a record, for example `familyOf` of the cell of its input. */\n readonly family: (record: R) => string;\n /** The measure. Its direction tells which side is better. */\n readonly measure: Pick<MeasureSpec, \"id\" | \"direction\">;\n /** The baseline side. */\n readonly a: VerdictSide<R>;\n /** The candidate side. A positive difference tells that `b` is better than `a`. */\n readonly b: VerdictSide<R>;\n /**\n * The minimum effect of the sign of a family, as `minEffect` of `MeasureSpec`. A smaller change of the family mean is a tie.\n * `compareMeasure` compares the two family means, so the smallest tie is one grid step of `RECORD_EPS`.\n */\n readonly tie: number | { readonly rel: number };\n /** The significance level, from 0 to 1. The permutation p must be below it. The intervals have the level `1 - level`. */\n readonly level: number;\n /** The count of the samples of each bootstrap. The default is `VERDICT_RUNS`. */\n readonly runs?: number;\n /** The count of the random sign sets above the exact limit. The default is `VERDICT_DRAWS`. */\n readonly draws?: number;\n /** The seed of the bootstraps and of the random sign sets. The default is `VERDICT_SEED`. */\n readonly seed?: number;\n /** The largest count of inputs for the exact test. The default is `VERDICT_EXACT_MAX`. The value 0 always uses draws. */\n readonly exactMax?: number;\n}\n\n/** A mean with its bootstrap interval. The interval is clear of 0 when `lo > 0` or `hi < 0`. */\nexport interface VerdictInterval {\n readonly mean: number;\n readonly lo: number;\n readonly hi: number;\n}\n\n/** The difference of one family: the count of its inputs, the mean of their differences and its sign. */\nexport interface FamilyVerdict {\n readonly family: string;\n readonly n: number;\n readonly mean: number;\n /** The value 1 tells that `b` is better, -1 that `b` is worse, and 0 a tie by `tie`. */\n readonly sign: -1 | 0 | 1;\n}\n\n/** The stratified paired permutation test. With `exact`, `draws` is the count of all the sign sets. */\nexport interface VerdictPermutation {\n readonly p: number;\n readonly exact: boolean;\n readonly draws: number;\n readonly seed: number;\n}\n\n/** The two-sided exact sign test of the family signs. It is a report only. Ties do not count. */\nexport interface VerdictSignTest {\n readonly wins: number;\n readonly losses: number;\n readonly ties: number;\n readonly p: number;\n}\n\n/** The label of a verdict. `better` and `worse` tell the side of `b`. */\nexport type VerdictLabel = \"better\" | \"worse\" | \"depends on the mix\" | \"no verdict\";\n\n/**\n * The scope of a verdict. The test keeps the families of the corpus as fixed, so its claim is about these families only.\n * It is not a claim about a new kind of input.\n */\nexport type VerdictScope = \"these families\";\n\n/**\n * The breadth of a verdict: the count of the families against its side.\n * The side is the side of the label. For `depends on the mix` and `no verdict`, it is the sign of the stratified mean.\n */\nexport interface VerdictBreadth {\n /** The count of the families with a sign against the side. A stratified mean of exactly 0 has no side, so this count is 0. */\n readonly against: number;\n /** The count of the families. */\n readonly of: number;\n /** The count of the families with the sign 0. */\n readonly ties: number;\n}\n\n/** The result of `verdict`. */\nexport interface VerdictResult {\n readonly measure: string;\n /** The count of the paired inputs. */\n readonly n: number;\n /** The mean of the family means, with a bootstrap of the seeds inside each family. */\n readonly stratified: VerdictInterval;\n /** The mean of the inputs, with a bootstrap of the inputs. */\n readonly pooled: VerdictInterval;\n readonly permutation: VerdictPermutation;\n /** The families, in sort order. */\n readonly families: readonly FamilyVerdict[];\n readonly signTest: VerdictSignTest;\n /** `true` only when the two means have the same sign, the two intervals are clear of 0 and the permutation p is below `level`. */\n readonly agree: boolean;\n readonly label: VerdictLabel;\n /** The scope of the claim: the families of the corpus, not a new kind of input. */\n readonly scope: VerdictScope;\n /** The count of the families against the side of the verdict, of all the families and of the ties. */\n readonly breadth: VerdictBreadth;\n /** The label, the scope and the breadth in one line, for example `better on these families, worse on 2 of 6 (1 tie)`. */\n readonly summary: string;\n /** The inputs without a pair: one side has no record, a skipped record or no value of the measure. */\n readonly dropped: readonly string[];\n}\n\n/** One paired input: its key, its family, the two values and the difference in the direction of the measure. */\ninterface Pair {\n readonly key: string;\n readonly family: string;\n readonly a: number;\n readonly b: number;\n readonly d: number;\n}\n\n/** This function gives the mean of a list that is not empty. */\nconst meanOf = (values: readonly number[]): number => values.reduce((s, v) => s + v, 0) / values.length;\n\n/** This function gives the mean of a sample of the differences, in the order of the sample. */\nfunction sampleMean(list: readonly number[]): number {\n let s = 0;\n for (const d of list) s += d;\n return s / list.length;\n}\n\n/** This function gives the mean of the means of the samples of the families. */\nfunction meanOfMeans(lists: readonly (readonly number[])[]): number {\n let sum = 0;\n for (const list of lists) sum += sampleMean(list);\n return sum / lists.length;\n}\n\n/** This function gives the interval of a bootstrap, with the mean of the data. */\nconst intervalOf = (mean: number, i: Interval): VerdictInterval => ({ mean, lo: i.low, hi: i.high });\n\n/** This function tells if an interval is clear of 0 on the side of the sign `sign`. */\nconst clearOn = (i: VerdictInterval, sign: number): boolean => (sign > 0 ? i.lo > 0 : sign < 0 ? i.hi < 0 : false);\n\n/** This function gives the breadth of a verdict with the side `side`: 1, -1, or 0 for no side. */\nfunction breadthOf(families: readonly FamilyVerdict[], side: number): VerdictBreadth {\n const ties = families.filter((f) => f.sign === 0).length;\n const against = side === 0 ? 0 : families.filter((f) => f.sign === -side).length;\n return { against, of: families.length, ties };\n}\n\n/** This function gives the line of a verdict: its label, its scope and its breadth (`docs/VERDICT.md`). */\nfunction summaryOf(label: VerdictLabel, side: number, breadth: VerdictBreadth): string {\n const ties = breadth.ties === 0 ? \"\" : ` (${breadth.ties} ${breadth.ties === 1 ? \"tie\" : \"ties\"})`;\n const word = side > 0 ? \"better\" : \"worse\";\n const other = side > 0 ? \"worse\" : \"better\";\n const count = breadth.against === 0 ? \"none\" : String(breadth.against);\n if (label === \"better\" || label === \"worse\") return `${label} on these families, ${other} on ${count} of ${breadth.of}${ties}`;\n if (side === 0) return `${label}: the family mean is 0, on ${breadth.of} families${ties}`;\n return `${label}: ${word} on the family mean, ${other} on ${count} of ${breadth.of}${ties}`;\n}\n\n/** This function tells if a value is a positive whole number. */\nconst isCount = (v: number): boolean => Number.isInteger(v) && v > 0;\n\n/** This function gives the test of one side. */\nfunction sideTest<R extends VerdictRecord>(side: VerdictSide<R>): (record: R) => boolean {\n return typeof side === \"string\" ? (r) => r.strategy === side : side;\n}\n\n/** This function pairs the records of `a` and `b` by input and seed, and gives the pairs in the order of family and key. */\nfunction pairsOf<R extends VerdictRecord>(records: Iterable<R>, options: VerdictOptions<R>): { pairs: Pair[]; dropped: string[] } {\n const isA = sideTest(options.a);\n const isB = sideTest(options.b);\n const sides = new Map<string, { a?: R; b?: R }>();\n for (const r of records) {\n const inA = isA(r);\n const inB = isB(r);\n if (inA && inB) throw new RangeError(`verdict: the record of the input \"${r.input}\" is in the two sides`);\n if (!inA && !inB) continue;\n const key = `${r.input}#${r.seed}`;\n const entry = sides.get(key) ?? {};\n const side = inA ? \"a\" : \"b\";\n if (entry[side] !== undefined) throw new RangeError(`verdict: the side ${side} has two records of the input \"${r.input}\" and the seed ${r.seed}`);\n entry[side] = r;\n sides.set(key, entry);\n }\n const pairs: Pair[] = [];\n const dropped: string[] = [];\n const id = options.measure.id;\n for (const [key, { a, b }] of sides) {\n const va = a?.skipped === undefined ? a?.measures[id] : undefined;\n const vb = b?.skipped === undefined ? b?.measures[id] : undefined;\n if (a === undefined || b === undefined || va === undefined || vb === undefined) {\n dropped.push(key);\n continue;\n }\n if (!Number.isFinite(va) || !Number.isFinite(vb)) throw new RangeError(`verdict: the measure ${id} of the input \"${a.input}\" is not finite`);\n const family = options.family(a);\n if (options.family(b) !== family) throw new RangeError(`verdict: the two records of the input \"${a.input}\" have different families`);\n pairs.push({ key, family, a: va, b: vb, d: options.measure.direction === \"higher\" ? vb - va : va - vb });\n }\n pairs.sort((x, y) => (x.family < y.family ? -1 : x.family > y.family ? 1 : x.key < y.key ? -1 : x.key > y.key ? 1 : 0));\n dropped.sort();\n return { pairs, dropped };\n}\n\n/**\n * This function gives the verdict of the candidate `b` against the baseline `a` on one measure, with the family as the unit (`docs/VERDICT.md`).\n *\n * - It pairs the records by input and seed. The difference of a pair is `b - a` for a measure where more is better, else `a - b`.\n * - `stratified` is the mean of the family means. Its bootstrap draws the seeds inside each family. `pooled` is the mean of the inputs.\n * - The permutation test changes the sign of each difference inside its family. Its statistic is the mean of the family means.\n * - The label is `better` or `worse` only when `agree` is `true`. Opposite signs of the two means give `depends on the mix`.\n * - `scope`, `breadth` and `summary` tell that the claim is about these families, and how many families are against it.\n *\n * It throws a `RangeError` for a missing `tie` or `level`, and for no pair. Two records of one side and input, or a value that is not finite, also cause a `RangeError`.\n */\nexport function verdict<R extends VerdictRecord>(records: Iterable<R>, options: VerdictOptions<R>): VerdictResult {\n const { tie, level, measure } = options;\n if (options.by !== \"family\") throw new RangeError(`verdict: the unit is \"family\", not \"${String(options.by)}\"`);\n if (tie === undefined || (typeof tie === \"number\" ? !(tie >= 0) : !(tie.rel >= 0))) throw new RangeError(\"verdict: tie is a required number of 0 or more, or { rel } of 0 or more\");\n if (level === undefined || !(level > 0 && level < 1)) throw new RangeError(\"verdict: level is a required number between 0 and 1\");\n const runs = options.runs ?? VERDICT_RUNS;\n const draws = options.draws ?? VERDICT_DRAWS;\n const seed = options.seed ?? VERDICT_SEED;\n const exactMax = options.exactMax ?? VERDICT_EXACT_MAX;\n if (!isCount(runs) || !isCount(draws)) throw new RangeError(\"verdict: runs and draws are whole numbers above 0\");\n if (!Number.isInteger(exactMax) || exactMax < 0 || exactMax > VERDICT_EXACT_CAP) throw new RangeError(`verdict: exactMax is a whole number from 0 to ${VERDICT_EXACT_CAP}`);\n\n const { pairs, dropped } = pairsOf(records, options);\n const n = pairs.length;\n if (n === 0) throw new RangeError(`verdict: the records give no pair of the measure ${measure.id}`);\n\n const groups = new Map<string, Pair[]>();\n for (const p of pairs) groups.set(p.family, [...(groups.get(p.family) ?? []), p]);\n const lists = [...groups.values()];\n const spec = { direction: measure.direction, minEffect: tie };\n const families: FamilyVerdict[] = lists.map((list) => {\n const verdictOf = compareMeasure(meanOf(list.map((p) => p.b)), meanOf(list.map((p) => p.a)), spec);\n return { family: list[0]!.family, n: list.length, mean: meanOf(list.map((p) => p.d)), sign: verdictOf === \"better\" ? 1 : verdictOf === \"worse\" ? -1 : 0 };\n });\n\n // The bootstraps of `@mark1russell7/rigor-statistics`. The stream of a step is `random(deriveSeed(seed, step))`, which is `stepRandom(seed, step)`.\n // `bootstrapStrata` draws the seeds of each family with replacement, in the order of the families. `bootstrap` draws all the inputs.\n const ends: readonly [number, number] = [level / 2, 1 - level / 2];\n const diffs = lists.map((list) => list.map((p) => p.d));\n const stratMean = meanOf(families.map((f) => f.mean));\n const stratified = intervalOf(stratMean, bootstrapStrata(diffs, meanOfMeans, { runs, ends, seed: deriveSeed(seed, \"verdict.stratified\") }));\n const pooledMean = meanOf(pairs.map((p) => p.d));\n const pooled = intervalOf(pooledMean, bootstrap(diffs.flat(), sampleMean, { runs, ends, seed: deriveSeed(seed, \"verdict.pooled\") }));\n\n // The statistic is a weighted sum: the weight of an input is 1 / (the count of families × the count of its family).\n // `signFlipTest` enumerates the sign sets up to `exactMax` terms. Above it, a drawn p counts the observed sign set as one draw.\n const terms = lists.flatMap((list) => list.map((p) => p.d / (lists.length * list.length)));\n const flips = signFlipTest(terms, { exactMax, runs: draws, seed: deriveSeed(seed, \"verdict.permutation\") });\n const permutation: VerdictPermutation = { p: flips.p, exact: flips.exact, draws: flips.runs, seed };\n\n const wins = families.filter((f) => f.sign === 1).length;\n const losses = families.filter((f) => f.sign === -1).length;\n const signs: VerdictSignTest = { wins, losses, ties: families.length - wins - losses, p: signTest(wins, losses, 2) };\n\n const sign = Math.sign(stratified.mean);\n const agree = sign !== 0 && sign === Math.sign(pooled.mean) && clearOn(stratified, sign) && clearOn(pooled, sign) && permutation.p < level;\n const label: VerdictLabel = agree ? (sign > 0 ? \"better\" : \"worse\") : sign * Math.sign(pooled.mean) < 0 ? \"depends on the mix\" : \"no verdict\";\n const breadth = breadthOf(families, sign);\n const summary = summaryOf(label, sign, breadth);\n return { measure: measure.id, n, stratified, pooled, permutation, families, signTest: signs, agree, label, scope: \"these families\", breadth, summary, dropped };\n}\n","// The shared corpus generator (`docs/CORPUS.md`): the dimension schema, the family registry and the seeded random numbers.\n// An engine owns its families and gives them to a registry. This file imports no engine and no API of Node, so a browser can run it.\nimport type { FamilyBy } from \"./corpus.ts\";\nimport { EDGE_KEY_STEP_VERSION, edgeKeyStep, edgeStep, type EdgeKey, type EdgeStepParams } from \"./edges.ts\";\nimport { documentHash } from \"./hash.ts\";\nimport type { LayoutInput, Obstacle } from \"./input.ts\";\nimport { mulberry32, randomInt, stepRandom } from \"./random.ts\";\nimport { SHAPE_KIND_IDS } from \"./shapes.ts\";\nimport { paramActive, paramLevels, paramProblem, paramValue, type ParamValue, type SpaceParam } from \"./strategy-space.ts\";\n\n/**\n * One dimension of a corpus: a param of `strategy-space.ts` with its meaning and the engines that use it.\n * The field `when` has the form of `SpaceParam.when`: the dimension is active only for some values of an earlier dimension.\n */\nexport interface CorpusDimension extends SpaceParam {\n /** The meaning of the dimension, in one sentence. */\n readonly meaning: string;\n /** The engines that read the dimension, for example `packing`, `highways` and `joint`. */\n readonly engines: readonly string[];\n /** The values of a sweep. Without them, a sweep uses the values of an `enum`, `false` and `true` of a `bool`, or the default. */\n readonly levels?: readonly ParamValue[];\n /**\n * The values that the family accepts. Without it, the family accepts each value of the dimension.\n * A list is for an `enum` or a `bool`. A sub-range is for an `int` or a `real`.\n * The default and each level are supported values. `resolve` and `generate` refuse a value that is not supported.\n */\n readonly supported?: SupportedValues;\n /**\n * The output fields that a value other than the default makes wrong, for example `known`.\n * Then `generate` of a registry removes these fields from the output, and lists them in `invalidated`.\n */\n readonly invalidates?: readonly string[];\n /**\n * The count of decimal places that the family uses for a value of a numeric dimension: a whole number of 0 or more.\n * Only the `invalidates` compare reads it. The registry rounds the value and the default to it before the compare.\n * The cells, the cell keys, `rngOf` and the value that `generate` gets do not change.\n */\n readonly precision?: number;\n}\n\n/**\n * The supported values of a dimension (`CorpusDimension.supported`).\n * The list form gives the values of an `enum` or a `bool`. The range form gives a sub-range of an `int` or a `real`.\n * A range without `min` or `max` keeps that end of the dimension.\n */\nexport type SupportedValues = readonly ParamValue[] | SupportedRange;\n\n/** The range form of `SupportedValues`: the least and the largest supported value of a numeric dimension. */\nexport interface SupportedRange {\n readonly min?: number;\n readonly max?: number;\n}\n\n/** The name of the output field that lists the fields that `generate` of a registry removed. */\nexport const INVALIDATED_FIELD = \"invalidated\";\n\n/** The values of the dimensions of one input: one value for each name. */\nexport type DimensionValues = Readonly<Record<string, ParamValue>>;\n\n/** A factory of seeded random numbers: it gives a source of numbers in [0, 1) for a seed. */\nexport type RngFactory = (seed: number) => () => number;\n\n/**\n * The cross-engine note of a family. `exact` tells that each JavaScript engine gives the same output.\n * `libm-dependent` tells that the family uses a function that is not correctly rounded in each engine, for example `Math.log`, `Math.cos` or `**`.\n */\nexport type CrossEngine = \"exact\" | \"libm-dependent\";\n\n/** The random numbers of the default factory: `mulberry32` of `random.ts`. Its stream is pinned in `families.test.ts`. */\nexport const DEFAULT_RNG: RngFactory = mulberry32;\n\n/** The context that a registry gives to `generate`. */\nexport interface GenerateContext {\n /** The random factory of the family: its own `rng`, or `DEFAULT_RNG`. */\n readonly rng: RngFactory;\n /** The source of random numbers of the input: `rng(rngSeed(seed, dims))`. A family that does not use it takes no numbers from it. */\n readonly random: () => number;\n /** The name of the corpus of the input, when the caller gives one. */\n readonly set?: string;\n}\n\n/**\n * A family of a corpus: a seeded generator with declared dimensions. The engine that owns it gives it to a registry.\n * The registry gives `generate` the raw seed and the full dimension values.\n * The registry changes the output only for a dimension with `invalidates` at a value other than its default.\n */\nexport interface CorpusFamily<O = LayoutInput> {\n /** The name of the family, for example `rect-grid`. */\n readonly name: string;\n /** The version. A change of the output of the family needs a new version. A dimension of only some versions is in the list of those versions only. */\n readonly version: number;\n /** The engine that owns the definition of the family, for example `packing`. */\n readonly owner: string;\n /** The meaning of the family, in one sentence. */\n readonly meaning: string;\n /** The dimensions of the family, in their order. A dimension with `when` comes after the dimension that its `when` names. The name `kind` is reserved. */\n readonly dimensions: readonly CorpusDimension[];\n /** The text of the rule that gives the random numbers of an input from its seed and its dimensions. */\n readonly seeding: string;\n /** The cross-engine note of the family. */\n readonly crossEngine: CrossEngine;\n /** The random factory of the family. The default is `DEFAULT_RNG`. */\n readonly rng?: RngFactory;\n /** This function gives the seed of `context.random` from the input seed and the full dimension values. The default gives the input seed. */\n readonly rngSeed?: (seed: number, dims: DimensionValues) => number;\n /** The dimensions of the family key of `familyBy`, after the kind of the cell. A dimension with `when` is not permitted. The default is no dimension. */\n readonly familyBy?: readonly string[];\n /**\n * This function gives the hash of an output after the registry removes the fields of `invalidates`. The default is `documentHash` of `hash.ts`.\n * The registry uses it only for an output with a `hash` field of text. The registry gives it an output of the family.\n * Its parameter has the type `never`, so a family of each output type can be a `CorpusFamily<unknown>`.\n */\n readonly hash?: (output: never) => string;\n /** This function gives the input of a seed. `dims` has a value for each dimension, also for an inactive dimension. */\n generate(seed: number, dims: DimensionValues, context: GenerateContext): O;\n}\n\n/** The options of `generate` of a registry. */\nexport interface GenerateOptions {\n /** The version of the family. The default is the first version that the registry got. */\n readonly version?: number;\n /** The name of the corpus. The registry gives it to the family in `context.set`. */\n readonly set?: string;\n}\n\n/** The options of `cells` and `cellCount` of a registry. */\nexport interface CellsOptions {\n readonly version?: number;\n /** The dimensions of the sweep. The other dimensions keep their defaults. The default is each dimension of the family. */\n readonly sweep?: readonly string[];\n /** The values of a sweep for some dimensions, in place of the levels of the dimensions. */\n readonly levels?: Readonly<Record<string, readonly ParamValue[]>>;\n}\n\n/** The cell of an input of a registry: `<name>@<version>` of its family in `kind` (`familyKind`), and the value of each active dimension. */\nexport type RegistryCell = Readonly<Record<string, ParamValue>> & { readonly kind: string };\n\n/** This function gives the `kind` of the cells of a version of a family: `<name>@<version>`, for example `rect-grid@2`. Thus two versions do not share a family key. */\nexport function familyKind(name: string, version: number): string {\n return `${name}@${version}`;\n}\n\n/** A registry of families. An import registers nothing: a host makes a registry from the lists of families of the engines. */\nexport interface FamilyRegistry<O = LayoutInput> {\n /** This method adds a family. It throws a `RangeError` for a second family with the same name and version, or for a bad dimension. */\n register(family: CorpusFamily<O>): FamilyRegistry<O>;\n /** This method gives a family. Without a version, it gives the first version that the registry got. It throws a `RangeError` for an unknown family. */\n family(name: string, version?: number): CorpusFamily<O>;\n /** This method gives each family, in the order of registration. */\n families(): readonly CorpusFamily<O>[];\n /**\n * This method gives the full dimension values of an input. It throws a `RangeError` for an unknown dimension, a bad value or a value that is not supported.\n * The methods with `dims` accept a cell of `cellOf`: they ignore a `kind` that is the `familyKind` of the family, and refuse another `kind`.\n */\n resolve(name: string, dims?: Readonly<Record<string, ParamValue>>, version?: number): DimensionValues;\n /**\n * This method gives the input of a seed: the output of the family. A dimension with `invalidates` at a value other than its default changes it.\n * Then the method removes those fields, adds their names to `invalidated` and calculates the `hash` again. Another output has no change.\n */\n generate(name: string, seed: number, dims?: Readonly<Record<string, ParamValue>>, options?: GenerateOptions): O;\n /** This method gives the cell of an input: the `familyKind` of the family version and the value of each active dimension. */\n cellOf(name: string, dims?: Readonly<Record<string, ParamValue>>, version?: number): RegistryCell;\n /** This method gives the full dimension values of each cell of a sweep, without the dead combinations of `when`. */\n cells(name: string, options?: CellsOptions): Generator<DimensionValues>;\n /** This method gives the count of the cells of `cells`. It makes no input. */\n cellCount(name: string, options?: CellsOptions): number;\n /** This method gives the defaults, and each end of each numeric range. The dimensions that a `when` needs get its first value. The other dimensions keep their defaults. */\n boundaryCells(name: string, version?: number): DimensionValues[];\n /** This method gives the random source of an input: the stream that `generate` gets in `context.random`. */\n rngOf(name: string, version?: number): (seed: number, dims?: Readonly<Record<string, ParamValue>>) => () => number;\n /** This method gives the map form of `FamilyBy` for the cells of `cellOf`: the `familyKind` of each family version, with its own `familyBy`. */\n familyBy(): FamilyBy;\n}\n\n/** The default key of a family in a manifest: the kind of the cell alone. It is the map form of `FamilyBy` with the entry `\"*\"`. */\nexport const DEFAULT_FAMILY_BY: FamilyBy = /* @__PURE__ */ Object.freeze({ \"*\": /* @__PURE__ */ Object.freeze([]) as readonly string[] });\n\n/** This function gives an `enum` dimension. */\nconst choice = (name: string, values: readonly string[], value: string, meaning: string, engines: readonly string[]): CorpusDimension =>\n Object.freeze({ name, kind: \"enum\", values: Object.freeze([...values]), default: value, meaning, engines: Object.freeze([...engines]) });\n\n/** This function gives an `int` or a `real` dimension. */\nconst range = (\n name: string,\n kind: \"int\" | \"real\",\n limits: { readonly min: number; readonly max: number; readonly value: number; readonly scale?: \"linear\" | \"log\"; readonly levels?: readonly number[] },\n meaning: string,\n engines: readonly string[],\n): CorpusDimension =>\n Object.freeze({\n name,\n kind,\n min: limits.min,\n max: limits.max,\n default: limits.value,\n scale: limits.scale ?? \"linear\",\n ...(limits.levels === undefined ? {} : { levels: Object.freeze([...limits.levels]) }),\n meaning,\n engines: Object.freeze([...engines]),\n });\n\n/**\n * This function gives a dimension with the condition `when`, as a frozen object.\n * A spread in the literal of `CORPUS_DIMENSIONS` is a side effect for a bundler, so the copy is in this function.\n */\nconst withWhen = (dimension: CorpusDimension, when: NonNullable<CorpusDimension[\"when\"]>): CorpusDimension => Object.freeze({ ...dimension, when });\n\nconst P = \"packing\";\nconst H = \"highways\";\nconst J = \"joint\";\n\n/**\n * The shared dimension table. A family takes a dimension of it with `sharedDimension`, or declares its own dimension.\n * The coverage table of each dimension and each engine is in `docs/CORPUS.md`.\n */\nexport const CORPUS_DIMENSIONS: Readonly<Record<string, CorpusDimension>> = /* @__PURE__ */ Object.freeze({\n count: /* @__PURE__ */ range(\"count\", \"int\", { min: 0, max: 100_000, value: 100, scale: \"log\", levels: [1, 10, 100, 1000, 10_000] }, \"The count of the items (n) of an input.\", [P, H, J]),\n sizes: /* @__PURE__ */ choice(\"sizes\", [\"identical\", \"nearIdentical\", \"uniform\", \"heavyTail\", \"bimodal\", \"extremeAspect\"], \"uniform\", \"The distribution of the sizes of the items.\", [P, J]),\n aspect: /* @__PURE__ */ range(\"aspect\", \"real\", { min: 0.25, max: 4, value: 1, scale: \"log\" }, \"The width over the height of a container with no fixed size.\", [P]),\n density: /* @__PURE__ */ range(\"density\", \"real\", { min: 0.05, max: 1, value: 0.4, scale: \"linear\" }, \"The area of the items over the area of the frame of the container.\", [P]),\n obstacles: /* @__PURE__ */ choice(\"obstacles\", [\"none\", \"center\", \"scattered\", \"wall\", \"corridors\", \"touching\", \"edge\"], \"none\", \"The layout of the fixed obstacles.\", [P, J]),\n containerSize: /* @__PURE__ */ choice(\"containerSize\", [\"fixed\", \"freeHeight\", \"freeWidth\", \"freeAspect\", \"freeArea\"], \"fixed\", \"The sides of the container that the engine can change.\", [P, J]),\n containerShape: /* @__PURE__ */ choice(\"containerShape\", [\"rect\", \"convex\", \"polygon\", \"circle\", \"ellipse\", \"holes\"], \"rect\", \"The kind of the shape of the container.\", [P, J]),\n shape: /* @__PURE__ */ choice(\"shape\", SHAPE_KIND_IDS, \"rect\", \"The shape kind of each item: a `ShapeKind` of `shapes.ts`.\", [P]),\n order: /* @__PURE__ */ choice(\"order\", [\"free\", \"soft\"], \"free\", \"The reading order of the items: no order, or a rank on each item.\", [P]),\n groups: /* @__PURE__ */ choice(\"groups\", [\"none\", \"flat\", \"nested\"], \"none\", \"The groups of the items: no groups, one level, or groups in groups.\", [H, J]),\n edgeDensity: /* @__PURE__ */ choice(\"edgeDensity\", [\"sparse\", \"medium\", \"dense\"], \"medium\", \"The mean count of the edges of each item: 0.5, 1.5 or 4.\", [H, J]),\n edgeShape: /* @__PURE__ */ choice(\"edgeShape\", [\"random\", \"clustered\", \"hubChain\", \"hubs\", \"longRange\", \"tree\", \"bundled\"], \"random\", \"The topology of the edges.\", [H, J]),\n ports: /* @__PURE__ */ choice(\"ports\", [\"free\", \"sides\", \"fixed\"], \"free\", \"The ports of the edges: free, a side for each end, or fixed ports.\", [H, J]),\n edgeKey: /* @__PURE__ */ choice(\"edgeKey\", [\"none\", \"random\", \"cluster\"], \"none\", \"The key of each edge in `data.collection`: absent, a random name for each target box, or a name for each cluster of boxes.\", [H, J]),\n hubBy: /* @__PURE__ */ withWhen(\n /* @__PURE__ */ choice(\"hubBy\", [\"area\", \"random\"], \"area\", \"The order of the hubs of the shapes hubs and tree: the largest item first, or random.\", [J]),\n /* @__PURE__ */ Object.freeze({ param: \"edgeShape\", in: /* @__PURE__ */ Object.freeze([\"hubs\", \"tree\"]) }),\n ),\n spacing: /* @__PURE__ */ choice(\"spacing\", [\"stress\", \"gap\", \"margin\", \"both\"], \"both\", \"The split of the route clearance between the margins and the gap. `stress` has neither.\", [J]),\n margin: /* @__PURE__ */ range(\"margin\", \"real\", { min: 0, max: 32, value: 0 }, \"The margin of each item, in units.\", [P, J]),\n gap: /* @__PURE__ */ range(\"gap\", \"real\", { min: 0, max: 32, value: 0 }, \"The free space between two items, in units.\", [P, J]),\n});\n\n/**\n * This function gives a dimension of `CORPUS_DIMENSIONS`, with the fields of `patch` over it. It throws a `RangeError` for an unknown name.\n * With `supported`, `invalidates` or `precision` in the patch, it also throws a `RangeError` for a bad dimension, as `ownerDimension` does.\n */\nexport function sharedDimension(name: string, patch: Partial<CorpusDimension> = {}): CorpusDimension {\n const base = Object.hasOwn(CORPUS_DIMENSIONS, name) ? CORPUS_DIMENSIONS[name] : undefined;\n if (base === undefined) throw new RangeError(`The shared dimension table has no dimension \"${name}\".`);\n const dim: CorpusDimension = Object.freeze({ ...base, ...patch, name });\n if (patch.supported !== undefined || patch.invalidates !== undefined || patch.precision !== undefined)\n throwProblems(`sharedDimension: the dimension \"${name}\"`, ownProblems(dim));\n return dim;\n}\n\n/** The fields of a dimension that the owner declares: each field of `CorpusDimension` but the name. */\nexport type OwnerDimensionSpec = Omit<CorpusDimension, \"name\">;\n\n/**\n * This function gives a dimension that only its owner declares, for example `cut` of a family of `packing`.\n * It throws a `RangeError` for a name of `CORPUS_DIMENSIONS`, the reserved name `kind`, or a bad default, level, `supported`, `invalidates` or `precision`.\n * The registry examines the `when` of the dimension, because it needs the earlier dimensions.\n */\nexport function ownerDimension(name: string, spec: OwnerDimensionSpec): CorpusDimension {\n const where = `ownerDimension: the dimension \"${name}\"`;\n if (typeof name !== \"string\" || name === \"\") throw new RangeError(\"ownerDimension: the name of a dimension is a text that is not empty.\");\n if (name === \"kind\") throw new RangeError(`${where} has a reserved name: the cell of \\`cellOf\\` has the \\`familyKind\\` of the family in \\`kind\\`.`);\n if (Object.hasOwn(CORPUS_DIMENSIONS, name)) throw new RangeError(`${where} is in the shared dimension table. Use sharedDimension(\"${name}\") for it.`);\n const dim: CorpusDimension = Object.freeze({ ...spec, name });\n throwProblems(where, ownProblems(dim));\n return dim;\n}\n\n/** This function throws a `RangeError` with each problem of a list. An empty list throws nothing. */\nfunction throwProblems(where: string, problems: readonly string[]): void {\n if (problems.length > 0) throw new RangeError(`${where} is not good: ${problems.join(\"; \")}.`);\n}\n\n/** This function tells if a value of the stable form of a dimension is in its `supported` values. Without `supported`, each value is in them. */\nfunction inSupported(dim: CorpusDimension, value: ParamValue): boolean {\n const s = dim.supported;\n if (s === undefined) return true;\n if (isSupportedList(s)) return s.some((v) => paramValue(dim, v) === value);\n if (typeof value !== \"number\") return false;\n return (s.min === undefined || value >= s.min) && (s.max === undefined || value <= s.max);\n}\n\n/** This function tells if `SupportedValues` has the list form. */\nconst isSupportedList = (s: SupportedValues): s is readonly ParamValue[] => Array.isArray(s);\n\n/**\n * This function tells if a family accepts a value of a dimension. A site uses it to show the values that a family does not support.\n * It gives `false` for a bad value, and for a value outside `supported`. Without `supported`, it gives `true` for each good value.\n */\nexport function dimensionSupports(dim: CorpusDimension, value: unknown): boolean {\n if (paramProblem(dim, value) !== undefined) return false;\n return inSupported(dim, paramValue(dim, value as ParamValue));\n}\n\n/** This function gives the text of the supported values of a dimension, for a message. */\nfunction supportedText(dim: CorpusDimension): string {\n const s = dim.supported;\n if (s === undefined) return \"each value\";\n if (isSupportedList(s)) return s.map((v) => JSON.stringify(v)).join(\", \");\n return `the values from ${s.min ?? dim.min} to ${s.max ?? dim.max}`;\n}\n\n/** This function gives the problems of one dimension that need no other dimension: the default, the levels, `supported`, `invalidates` and `precision`. */\nfunction ownProblems(d: CorpusDimension): string[] {\n const out: string[] = [];\n const bad = paramProblem(d, d.default);\n if (bad !== undefined) out.push(`the default of \"${d.name}\" is bad: ${bad}`);\n for (const v of d.levels ?? []) {\n const p = paramProblem(d, v);\n if (p !== undefined) out.push(`a level of \"${d.name}\" is bad: ${p}`);\n }\n out.push(...supportProblems(d, bad === undefined));\n out.push(...invalidatesProblems(d));\n out.push(...precisionProblems(d));\n return out;\n}\n\n/** This function gives the problems of the `supported` values of a dimension. `goodDefault` tells that the default is a good value. */\nfunction supportProblems(d: CorpusDimension, goodDefault: boolean): string[] {\n const s = d.supported;\n if (s === undefined) return [];\n const out: string[] = [];\n const numeric = d.kind === \"int\" || d.kind === \"real\";\n if (isSupportedList(s)) {\n if (numeric) return [`the supported values of \"${d.name}\" are a range with min and max, because the dimension is numeric`];\n if (s.length === 0) return [`the supported values of \"${d.name}\" are an empty list`];\n for (const v of s) {\n const p = paramProblem(d, v);\n if (p !== undefined) out.push(`a supported value of \"${d.name}\" is bad: ${p}`);\n }\n if (new Set(s).size !== s.length) out.push(`the supported values of \"${d.name}\" have a value two times`);\n } else {\n if (s === null || typeof s !== \"object\") return [`the supported values of \"${d.name}\" are a list or a range`];\n if (!numeric) return [`the supported values of \"${d.name}\" are a list, because the dimension is not numeric`];\n for (const end of [s.min, s.max]) {\n if (end === undefined) continue;\n const p = paramProblem(d, end);\n if (p !== undefined) out.push(`an end of the supported range of \"${d.name}\" is bad: ${p}`);\n }\n if (s.min !== undefined && s.max !== undefined && s.min > s.max) out.push(`the supported range of \"${d.name}\" has a min above its max`);\n }\n if (out.length > 0) return out;\n if (goodDefault && !inSupported(d, paramValue(d, d.default))) out.push(`the default of \"${d.name}\" is not a supported value`);\n for (const v of d.levels ?? []) if (paramProblem(d, v) === undefined && !inSupported(d, paramValue(d, v))) out.push(`the level ${JSON.stringify(v)} of \"${d.name}\" is not a supported value`);\n return out;\n}\n\n/** This function gives the problems of the `invalidates` fields of a dimension. */\nfunction invalidatesProblems(d: CorpusDimension): string[] {\n const list = d.invalidates;\n if (list === undefined) return [];\n if (!Array.isArray(list) || !list.every((f) => typeof f === \"string\" && f !== \"\")) return [`the invalidates of \"${d.name}\" is not a list of field names`];\n const out: string[] = [];\n if (new Set(list).size !== list.length) out.push(`the invalidates of \"${d.name}\" has a field two times`);\n for (const f of [\"hash\", INVALIDATED_FIELD]) if (list.includes(f)) out.push(`the invalidates of \"${d.name}\" has the field \"${f}\", which the registry writes`);\n return out;\n}\n\n/** This function gives the problems of the `precision` of a dimension. A bad value and a dimension that is not numeric are problems. */\nfunction precisionProblems(d: CorpusDimension): string[] {\n const p: unknown = d.precision;\n if (p === undefined) return [];\n if (typeof p !== \"number\" || !Number.isInteger(p) || p < 0) return [`the precision of \"${d.name}\" is ${JSON.stringify(p)}, not a whole number of 0 or more`];\n if (d.kind !== \"int\" && d.kind !== \"real\") return [`the precision of \"${d.name}\" is for a numeric dimension, but the dimension is a ${d.kind}`];\n return [];\n}\n\n/** This function rounds a number to `places` decimal places: `Math.round(v * 10 ** places) / 10 ** places`. */\nconst roundTo = (v: number, places: number): number => Math.round(v * 10 ** places) / 10 ** places;\n\n/** This function tells if a value is the default of a dimension. With `precision`, it compares the two numbers after it rounds them. */\nfunction isDefault(d: CorpusDimension, value: ParamValue | undefined): boolean {\n const def = paramValue(d, d.default);\n if (d.precision === undefined || typeof value !== \"number\" || typeof def !== \"number\") return value === def;\n return roundTo(value, d.precision) === roundTo(def, d.precision);\n}\n\n/** This function tells if a log scale of a range starts at 0. Then the scale is the log of `1 + x - min`. */\nconst fromZero = (d: SpaceParam): boolean => d.scale === \"log\" && (d.min ?? 0) <= 0;\n\n/**\n * This function gives the value at the fraction `t` of the range of a numeric dimension, on its scale. A slider of a site uses it.\n * A log scale with a `min` of 0 or less is the log of `1 + x - min`. An `int` dimension gives a whole number.\n */\nexport function dimensionAt(dim: SpaceParam, t: number): number {\n const min = dim.min ?? 0;\n const max = dim.max ?? min;\n const u = Math.min(1, Math.max(0, t));\n let v: number;\n if (dim.scale !== \"log\") v = min + u * (max - min);\n else if (fromZero(dim)) v = min + Math.expm1(u * Math.log1p(max - min));\n else v = Math.exp(Math.log(min) + u * (Math.log(max) - Math.log(min)));\n v = Math.min(max, Math.max(min, v));\n return dim.kind === \"int\" ? Math.round(v) : (paramValue(dim, v) as number);\n}\n\n/** This function gives the fraction of the range of a numeric dimension at a value, on its scale. It is the inverse of `dimensionAt`. */\nexport function dimensionUnit(dim: SpaceParam, value: number): number {\n const min = dim.min ?? 0;\n const max = dim.max ?? min;\n if (max === min) return 0;\n const v = Math.min(max, Math.max(min, value));\n if (dim.scale !== \"log\") return (v - min) / (max - min);\n if (fromZero(dim)) return Math.log1p(v - min) / Math.log1p(max - min);\n return (Math.log(v) - Math.log(min)) / (Math.log(max) - Math.log(min));\n}\n\n/** This function gives the range of the supported values of a numeric dimension: its own `min` and `max` in place of the ends of `supported`. */\nfunction supportedSpan(dim: CorpusDimension): { readonly min: number | undefined; readonly max: number | undefined } {\n const s = dim.supported;\n const range = s === undefined || isSupportedList(s) ? {} : s;\n return { min: range.min ?? dim.min, max: range.max ?? dim.max };\n}\n\n/**\n * This function gives the values of a sweep of a dimension. `levels` of the dimension come first. Then an `enum` gives its values, and a `bool` gives `false` and `true`.\n * With `steps`, a numeric dimension gives `steps` points from `min` to `max` on its scale. Else it gives its default.\n * With `supported`, an `enum` and a `bool` give only the supported values, and the points of a numeric dimension stay in the supported range.\n */\nexport function levelsOf(dim: CorpusDimension, steps?: number): ParamValue[] {\n if (dim.levels !== undefined) return [...dim.levels];\n if (dim.kind === \"enum\" || dim.kind === \"bool\") return paramLevels(dim, 1).filter((v) => inSupported(dim, paramValue(dim, v)));\n if (steps === undefined) return paramLevels(dim, 1);\n if (dim.supported !== undefined) {\n const { supported: _supported, ...rest } = dim;\n const span = supportedSpan(dim);\n return levelsOf({ ...rest, ...(span.min === undefined ? {} : { min: span.min }), ...(span.max === undefined ? {} : { max: span.max }) }, steps);\n }\n if (!fromZero(dim)) return paramLevels(dim, steps);\n if (!Number.isInteger(steps) || steps < 1) throw new RangeError(`The steps of a sweep are a whole number of 1 or more, not ${steps}.`);\n if (steps === 1) return [paramValue(dim, dim.default)];\n return [...new Set(Array.from({ length: steps }, (_, j) => dimensionAt(dim, j / (steps - 1))))];\n}\n\n/** This function gives the problems of the dimensions of a family: a repeated name, a bad default, level, `supported`, `invalidates` or `when`. */\nfunction dimensionProblems(dims: readonly CorpusDimension[]): string[] {\n const out: string[] = [];\n const names = dims.map((d) => d.name);\n dims.forEach((d, i) => {\n if (names.indexOf(d.name) !== i) out.push(`the dimension \"${d.name}\" is in the list two times`);\n out.push(...ownProblems(d));\n if (d.when === undefined) return;\n const j = names.indexOf(d.when.param);\n if (j < 0 || j >= i) out.push(`the when of \"${d.name}\" names \"${d.when.param}\", which is not an earlier dimension`);\n else if (d.when.in.length === 0) out.push(`the when of \"${d.name}\" has no values`);\n else for (const v of d.when.in) if (paramProblem(dims[j]!, v) !== undefined) out.push(`the when of \"${d.name}\" has a value that \"${d.when.param}\" does not have`);\n });\n return out;\n}\n\n/**\n * This function gives the full dimension values of an input. A missing dimension gets its default. An inactive dimension of `when` also gets its default.\n * Thus a default that the caller gives, a missing value and an inactive value give the same values. A real number gets its stable form.\n *\n * The function throws a `RangeError` for an unknown dimension or a bad value, also for a bad value of an inactive dimension.\n * It also throws a `RangeError` for a value outside `supported`, with the text \"not supported by\" and `by`.\n */\nexport function resolveDimensions(\n dimensions: readonly CorpusDimension[],\n dims: Readonly<Record<string, ParamValue>> = {},\n where: string = \"The family\",\n by: string = \"the family\",\n): DimensionValues {\n const known = new Set(dimensions.map((d) => d.name));\n for (const key of Object.keys(dims)) if (!known.has(key)) throw new RangeError(`${where} has no dimension \"${key}\".`);\n const active: Record<string, ParamValue> = {};\n const out: Record<string, ParamValue> = {};\n for (const d of dimensions) {\n const given = Object.hasOwn(dims, d.name) ? dims[d.name] : undefined;\n if (given !== undefined) {\n const bad = paramProblem(d, given);\n if (bad !== undefined) throw new RangeError(`${where}: the dimension \"${d.name}\" is bad: ${bad}.`);\n if (!inSupported(d, paramValue(d, given))) {\n throw new RangeError(`${where}: the value ${JSON.stringify(given)} of the dimension \"${d.name}\" is not supported by ${by}. The supported values are ${supportedText(d)}.`);\n }\n }\n const on = paramActive(d, active);\n const value = paramValue(d, on && given !== undefined ? given : d.default);\n if (on) active[d.name] = value;\n out[d.name] = value;\n }\n return out;\n}\n\n/** This function gives the values of the active dimensions only. */\nfunction activeValues(dimensions: readonly CorpusDimension[], full: DimensionValues): Record<string, ParamValue> {\n const active: Record<string, ParamValue> = {};\n for (const d of dimensions) if (paramActive(d, active)) active[d.name] = full[d.name]!;\n return active;\n}\n\n/** This function gives the active values of each cell of a sweep, in the order of the dimensions. The last dimension changes first. */\nfunction* sweepOf(dimensions: readonly CorpusDimension[], levels: readonly (readonly ParamValue[] | undefined)[], i = 0, values: Record<string, ParamValue> = {}): Generator<Record<string, ParamValue>> {\n if (i === dimensions.length) {\n yield { ...values };\n return;\n }\n const d = dimensions[i]!;\n const lv = levels[i];\n if (lv === undefined || !paramActive(d, values)) {\n yield* sweepOf(dimensions, levels, i + 1, paramActive(d, values) ? { ...values, [d.name]: paramValue(d, d.default) } : values);\n return;\n }\n for (const v of lv) yield* sweepOf(dimensions, levels, i + 1, { ...values, [d.name]: paramValue(d, v) });\n}\n\n/** This function counts the cells of a sweep with no list of the cells. A dimension that a later `when` reads splits the count. */\nfunction countOf(dimensions: readonly CorpusDimension[], levels: readonly (readonly ParamValue[] | undefined)[], i = 0, values: Record<string, ParamValue> = {}): number {\n if (i === dimensions.length) return 1;\n const d = dimensions[i]!;\n if (!paramActive(d, values)) return countOf(dimensions, levels, i + 1, values);\n const lv = levels[i] ?? [d.default];\n const readLater = dimensions.slice(i + 1).some((q) => q.when?.param === d.name);\n if (!readLater) return lv.length * countOf(dimensions, levels, i + 1, values);\n let sum = 0;\n for (const v of lv) sum += countOf(dimensions, levels, i + 1, { ...values, [d.name]: paramValue(d, v) });\n return sum;\n}\n\n/** This function gives the levels of each dimension of a sweep. A dimension outside the sweep has `undefined`, so it keeps its default. */\nfunction sweepLevels(dimensions: readonly CorpusDimension[], options: CellsOptions, where: string, by: string): (readonly ParamValue[] | undefined)[] {\n const names = new Set(dimensions.map((d) => d.name));\n for (const name of [...(options.sweep ?? []), ...Object.keys(options.levels ?? {})]) if (!names.has(name)) throw new RangeError(`${where} has no dimension \"${name}\".`);\n return dimensions.map((d) => {\n if (options.sweep !== undefined && !options.sweep.includes(d.name)) return undefined;\n const lv = options.levels !== undefined && Object.hasOwn(options.levels, d.name) ? options.levels[d.name]! : levelsOf(d);\n for (const v of lv) {\n const bad = paramProblem(d, v);\n if (bad !== undefined) throw new RangeError(`${where}: a level of \"${d.name}\" is bad: ${bad}.`);\n if (!inSupported(d, paramValue(d, v))) throw new RangeError(`${where}: the level ${JSON.stringify(v)} of \"${d.name}\" is not supported by ${by}.`);\n }\n return lv;\n });\n}\n\n/**\n * This function gives the output fields that the values make wrong: the `invalidates` of each dimension with a value other than its default, sorted.\n * A dimension with `precision` compares the rounded value with the rounded default.\n */\nfunction invalidFields(dimensions: readonly CorpusDimension[], full: DimensionValues): string[] {\n const out = new Set<string>();\n for (const d of dimensions) {\n if (d.invalidates === undefined || d.invalidates.length === 0) continue;\n if (!isDefault(d, full[d.name])) for (const f of d.invalidates) out.add(f);\n }\n return [...out].sort(byCode);\n}\n\n/** This function compares two strings by their UTF-16 code units. */\nconst byCode = (x: string, y: string): number => (x < y ? -1 : x > y ? 1 : 0);\n\n/**\n * This function removes the fields of `fields` from an output, and adds their names to its field `invalidated`, sorted.\n * Only a field of the output counts. The `hash` of text gets the value of `hash` again. An output with none of the fields is the same object.\n */\nfunction dropFields<O>(output: O, fields: readonly string[], hash: (output: O) => string, where: string): O {\n if (fields.length === 0) return output;\n if (output === null || typeof output !== \"object\" || Array.isArray(output)) throw new RangeError(`${where} invalidates the fields ${fields.join(\", \")}, but its output is not an object.`);\n const o = output as Record<string, unknown>;\n const dropped = fields.filter((f) => Object.hasOwn(o, f));\n if (dropped.length === 0) return output;\n const before = o[INVALIDATED_FIELD];\n const prior = Array.isArray(before) ? before.filter((f): f is string => typeof f === \"string\") : [];\n const body: Record<string, unknown> = {};\n for (const key of Object.keys(o)) if (key !== \"hash\" && key !== INVALIDATED_FIELD && !dropped.includes(key)) body[key] = o[key];\n body[INVALIDATED_FIELD] = [...new Set([...prior, ...dropped])].sort(byCode);\n if (typeof o[\"hash\"] !== \"string\") return (Object.hasOwn(o, \"hash\") ? { ...body, hash: o[\"hash\"] } : body) as O;\n return { ...body, hash: hash(body as O) } as O;\n}\n\n/** This function gives the values that make a dimension active: the first value of its `when`, and the values that make that dimension active. */\nfunction activation(dimensions: readonly CorpusDimension[], dim: CorpusDimension): Record<string, ParamValue> {\n const out: Record<string, ParamValue> = {};\n let d: CorpusDimension | undefined = dim;\n while (d?.when !== undefined) {\n const param: string = d.when.param;\n out[param] = d.when.in[0]!;\n d = dimensions.find((q) => q.name === param);\n }\n return out;\n}\n\n/** This function throws a `RangeError` when a seed is not a whole number of 0 or more. */\nfunction checkSeed(seed: number): void {\n if (!Number.isSafeInteger(seed) || seed < 0) throw new RangeError(`The seed is a whole number of 0 or more, not ${seed}.`);\n}\n\n/** This function gives a new registry with the families of the list. Each engine gives the list of its families. An import registers nothing. */\nexport function createFamilyRegistry<O = LayoutInput>(families: Iterable<CorpusFamily<O>> = []): FamilyRegistry<O> {\n const list: CorpusFamily<O>[] = [];\n const label = (f: CorpusFamily<O>): string => `The family \"${f.name}\" version ${f.version}`;\n const find = (name: string, version?: number): CorpusFamily<O> => {\n const named = list.filter((f) => f.name === name);\n if (named.length === 0) throw new RangeError(`The registry has no family \"${name}\".`);\n if (version === undefined) return named[0]!;\n const found = named.find((f) => f.version === version);\n if (found === undefined) throw new RangeError(`The family \"${name}\" has the versions ${named.map((f) => f.version).join(\", \")}, not ${version}.`);\n return found;\n };\n /** This function removes the `kind` of a cell of `cellOf` when it is the `familyKind` of `f`. It throws a `RangeError` for another kind. */\n const ownDims = (f: CorpusFamily<O>, dims: Readonly<Record<string, ParamValue>> | undefined): Readonly<Record<string, ParamValue>> | undefined => {\n if (dims === undefined || !Object.hasOwn(dims, \"kind\")) return dims;\n const kind = familyKind(f.name, f.version);\n if (dims[\"kind\"] !== kind) throw new RangeError(`${label(f)} has the kind \"${kind}\", not the kind ${JSON.stringify(dims[\"kind\"])} of the cell.`);\n const { kind: _kind, ...rest } = dims;\n return rest;\n };\n /** This function gives the full dimension values of an input of `f`. A message names the family as `familyKind` gives it. */\n const resolveIn = (f: CorpusFamily<O>, dims: Readonly<Record<string, ParamValue>> | undefined): DimensionValues =>\n resolveDimensions(f.dimensions, dims, label(f), familyKind(f.name, f.version));\n const streamOf = (f: CorpusFamily<O>, seed: number, full: DimensionValues): { readonly rng: RngFactory; readonly random: () => number } => {\n const rng = f.rng ?? DEFAULT_RNG;\n return { rng, random: rng(f.rngSeed === undefined ? seed : f.rngSeed(seed, full)) };\n };\n const registry: FamilyRegistry<O> = {\n register(family) {\n if (!Number.isInteger(family.version) || family.version < 1) throw new RangeError(`${label(family)} has a version that is not a whole number of 1 or more.`);\n if (list.some((f) => f.name === family.name && f.version === family.version)) throw new RangeError(`${label(family)} is in the registry already.`);\n const problems = dimensionProblems(family.dimensions);\n const names = family.dimensions.map((d) => d.name);\n if (names.includes(\"kind\")) problems.push('the dimension name \"kind\" is reserved: the cell of `cellOf` has the `familyKind` of the family in `kind`');\n for (const key of family.familyBy ?? []) {\n const d = family.dimensions.find((q) => q.name === key);\n if (d === undefined) problems.push(`the familyBy dimension \"${key}\" is not a dimension of the family`);\n else if (d.when !== undefined) problems.push(`the familyBy dimension \"${key}\" has a when, so a cell without it has no family key`);\n }\n if (problems.length > 0) throw new RangeError(`${label(family)} is not good: ${problems.join(\"; \")}.`);\n list.push(family);\n return registry;\n },\n family: find,\n families: () => [...list],\n resolve(name, dims, version) {\n const f = find(name, version);\n return resolveIn(f, ownDims(f, dims));\n },\n generate(name, seed, dims, options = {}) {\n checkSeed(seed);\n const f = find(name, options.version);\n const full = resolveIn(f, ownDims(f, dims));\n const context: GenerateContext = { ...streamOf(f, seed, full), ...(options.set === undefined ? {} : { set: options.set }) };\n const output = f.generate(seed, full, context);\n const hash = (f.hash ?? documentHash) as (o: O) => string;\n return dropFields(output, invalidFields(f.dimensions, full), hash, label(f));\n },\n cellOf(name, dims, version) {\n const f = find(name, version);\n return { kind: familyKind(f.name, f.version), ...activeValues(f.dimensions, resolveIn(f, ownDims(f, dims))) };\n },\n *cells(name, options = {}) {\n const f = find(name, options.version);\n for (const values of sweepOf(f.dimensions, sweepLevels(f.dimensions, options, label(f), familyKind(f.name, f.version)))) yield resolveIn(f, values);\n },\n cellCount(name, options = {}) {\n const f = find(name, options.version);\n return countOf(f.dimensions, sweepLevels(f.dimensions, options, label(f), familyKind(f.name, f.version)));\n },\n boundaryCells(name, version) {\n const f = find(name, version);\n const base = resolveIn(f, {});\n const out: DimensionValues[] = [base];\n const seen = new Set([JSON.stringify(base)]);\n for (const d of f.dimensions) {\n if (d.kind !== \"int\" && d.kind !== \"real\") continue;\n const span = supportedSpan(d);\n for (const end of [span.min, span.max]) {\n if (end === undefined) continue;\n const cell = resolveIn(f, { ...activation(f.dimensions, d), [d.name]: end });\n const key = JSON.stringify(cell);\n if (!seen.has(key)) {\n seen.add(key);\n out.push(cell);\n }\n }\n }\n return out;\n },\n rngOf(name, version) {\n const f = find(name, version);\n return (seed, dims) => {\n checkSeed(seed);\n return streamOf(f, seed, resolveIn(f, ownDims(f, dims))).random;\n };\n },\n familyBy() {\n const out: Record<string, readonly string[]> = {};\n for (const f of list) out[familyKind(f.name, f.version)] = [...(f.familyBy ?? [])];\n return out;\n },\n };\n for (const f of families) registry.register(f);\n return registry;\n}\n\n/** A step of a composed family: a pure function that changes an input after its base family, as `edgeStep` does. */\nexport interface CorpusStep {\n readonly name: string;\n readonly version: number;\n /** The engine that owns the definition of the step. */\n readonly owner: string;\n readonly meaning: string;\n /** The dimensions of the step. Their names are not names of the dimensions of the base family. */\n readonly dimensions: readonly CorpusDimension[];\n /** The text of the rule that gives the random numbers of the step from the seed. */\n readonly seeding: string;\n readonly crossEngine: CrossEngine;\n /** This function gives the part of the family of the input that tells the values of the step. Without it, the family does not change. */\n readonly familyPart?: (dims: DimensionValues) => string;\n /** This function gives the changed input. It removes the old `hash` of the input. */\n apply(input: LayoutInput, seed: number, dims: DimensionValues): LayoutInput;\n}\n\n/** The options of `composeFamily`. */\nexport interface ComposeOptions {\n /** The default is the name of the base family and the names of the steps, with `+` between them. */\n readonly name?: string;\n /** The default is the owner of the base family. */\n readonly owner?: string;\n readonly meaning?: string;\n /** The hash of the composed input. The default is `documentHash` of `hash.ts`. The composed family also gives it to the registry in `hash`. */\n readonly hash?: (input: LayoutInput) => string;\n}\n\n/** This function gives the values of a list of dimensions from the full values. */\nconst pick = (dims: readonly CorpusDimension[], full: DimensionValues): DimensionValues => Object.fromEntries(dims.map((d) => [d.name, full[d.name]!]));\n\n/**\n * This function gives a family that runs the base family and then each step, with the same seed.\n * The family of the input gets the part of each step after a dot. The id becomes `<set>/<family>/s<seed>`, and the input gets the hash of `options.hash`.\n * The function throws a `RangeError` when a step has a dimension with the name of an earlier dimension.\n */\nexport function composeFamily(base: CorpusFamily<LayoutInput>, steps: readonly CorpusStep[], options: ComposeOptions = {}): CorpusFamily<LayoutInput> {\n const dimensions = [...base.dimensions, ...steps.flatMap((s) => s.dimensions)];\n const seen = new Set<string>();\n for (const d of dimensions) {\n if (seen.has(d.name)) throw new RangeError(`composeFamily: the dimension \"${d.name}\" is in the base family or in an earlier step already.`);\n seen.add(d.name);\n }\n const hash = options.hash ?? documentHash;\n const libm = base.crossEngine === \"libm-dependent\" || steps.some((s) => s.crossEngine === \"libm-dependent\");\n return Object.freeze({\n name: options.name ?? [base.name, ...steps.map((s) => s.name)].join(\"+\"),\n version: base.version,\n owner: options.owner ?? base.owner,\n meaning: options.meaning ?? `${base.meaning} Then the steps ${steps.map((s) => s.name).join(\", \")}.`,\n dimensions,\n seeding: [base.seeding, ...steps.map((s) => `${s.name}: ${s.seeding}`)].join(\" \"),\n crossEngine: libm ? \"libm-dependent\" : \"exact\",\n ...(base.rng === undefined ? {} : { rng: base.rng }),\n ...(base.rngSeed === undefined ? {} : { rngSeed: (seed: number, full: DimensionValues) => base.rngSeed!(seed, pick(base.dimensions, full)) }),\n ...(base.familyBy === undefined ? {} : { familyBy: base.familyBy }),\n ...(options.hash === undefined ? {} : { hash: options.hash }),\n generate(seed: number, full: DimensionValues, context: GenerateContext): LayoutInput {\n let input = base.generate(seed, pick(base.dimensions, full), context);\n const parts: string[] = [];\n for (const step of steps) {\n const values = pick(step.dimensions, full);\n input = step.apply(input, seed, values);\n if (step.familyPart !== undefined) parts.push(step.familyPart(values));\n }\n const family = [input.family ?? base.name, ...parts].join(\".\");\n const set = input.set ?? context.set;\n const id = `${set === undefined ? \"\" : `${set}/`}${family}/s${seed}`;\n const stepped: LayoutInput = { ...input, id, family };\n return { ...stepped, hash: hash(stepped) };\n },\n });\n}\n\n/** The dimensions of `EDGES_STEP`: the parameters of `edgeStep`, from the shared table. */\nconst EDGE_DIMENSIONS: readonly CorpusDimension[] = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ [\"edgeDensity\", \"edgeShape\", \"groups\", \"ports\", \"hubBy\"].map((n) => CORPUS_DIMENSIONS[n]!));\n\n/** This function gives the parameters of `edgeStep` from the values of the dimensions. It throws a `RangeError` for a missing or a bad value. */\nfunction edgeParams(d: DimensionValues): EdgeStepParams {\n const text = (name: string): string => {\n const dim = EDGE_DIMENSIONS.find((q) => q.name === name)!;\n const value = Object.hasOwn(d, name) ? d[name] : undefined;\n const bad = value === undefined ? \"the value is missing\" : paramProblem(dim, value);\n if (bad !== undefined || typeof value !== \"string\") throw new RangeError(`EDGES_STEP: the dimension \"${name}\" is bad: ${bad ?? \"it is not text\"}.`);\n return value;\n };\n return {\n edgeDensity: text(\"edgeDensity\") as EdgeStepParams[\"edgeDensity\"],\n edgeShape: text(\"edgeShape\") as EdgeStepParams[\"edgeShape\"],\n groups: text(\"groups\") as NonNullable<EdgeStepParams[\"groups\"]>,\n ports: text(\"ports\") as NonNullable<EdgeStepParams[\"ports\"]>,\n hubBy: text(\"hubBy\") as NonNullable<EdgeStepParams[\"hubBy\"]>,\n };\n}\n\n/**\n * The step `edges` of `edgeStep` (version 1), as a corpus step. Its family part is `e-<edgeDensity>.<edgeShape>.<groups>.<ports>`.\n * The value `random` of `hubBy` adds the part `.hub-random`.\n */\nexport const EDGES_STEP: CorpusStep = /* @__PURE__ */ Object.freeze({\n name: \"edges\",\n version: 1,\n owner: \"layout-contract\",\n meaning: \"The edges, the groups and the ports of an input, from its topology alone.\",\n dimensions: EDGE_DIMENSIONS,\n seeding: \"stepRandom(seed, step) for the steps edges and ports.\",\n crossEngine: \"libm-dependent\",\n familyPart: (d: DimensionValues) => `e-${d[\"edgeDensity\"]}.${d[\"edgeShape\"]}.${d[\"groups\"]}.${d[\"ports\"]}${d[\"hubBy\"] === \"random\" ? \".hub-random\" : \"\"}`,\n apply: (input: LayoutInput, seed: number, d: DimensionValues) => edgeStep(input, edgeParams(d), seed),\n});\n\n/** The dimension of `EDGE_KEY_STEP`, from the shared table. */\nconst EDGE_KEY_DIMENSIONS: readonly CorpusDimension[] = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ [\"edgeKey\"].map((n) => CORPUS_DIMENSIONS[n]!));\n\n/** This function gives the value of `edgeKey`. It throws a `RangeError` for a missing or a bad value. */\nfunction edgeKeyOf(d: DimensionValues): EdgeKey {\n const value = Object.hasOwn(d, \"edgeKey\") ? d[\"edgeKey\"] : undefined;\n const bad = value === undefined ? \"the value is missing\" : paramProblem(EDGE_KEY_DIMENSIONS[0]!, value);\n if (bad !== undefined) throw new RangeError(`EDGE_KEY_STEP: the dimension \"edgeKey\" is bad: ${bad}.`);\n return value as EdgeKey;\n}\n\n/**\n * The step `edge-key` of `edgeKeyStep` (version 1), as a corpus step. It comes directly after `EDGES_STEP`. Its family part is `key-<edgeKey>`.\n */\nexport const EDGE_KEY_STEP: CorpusStep = /* @__PURE__ */ Object.freeze({\n name: \"edge-key\",\n version: EDGE_KEY_STEP_VERSION,\n owner: \"layout-contract\",\n meaning: \"The key of each edge: absent, with no meaning, or with the meaning of a cluster of boxes.\",\n dimensions: EDGE_KEY_DIMENSIONS,\n seeding: \"stepRandom(seed, step) for the value random. The value cluster reads the stream edges again, as edgeStep does.\",\n crossEngine: \"exact\",\n familyPart: (d: DimensionValues) => `key-${d[\"edgeKey\"]}`,\n apply: (input: LayoutInput, seed: number, d: DimensionValues) => edgeKeyStep(input, { edgeKey: edgeKeyOf(d) }, seed),\n});\n\n/** The set of `CIRCLE_SCATTERED` when the caller gives no set. */\nconst CIRCLE_SET = \"circle-v1\";\n\n/**\n * The shared family `circle-scattered`, version 1: circle items of random whole radii in a fixed container, with no obstacles and no edges.\n *\n * - The dimension `containerShape` takes `rect` or `circle`. One seed gives the same radii in the 2 containers, so a pair joins on the seed.\n * - The circles fill approximately half of the container, and the container is at least as large as the largest circle.\n * - The stream `items` gives each radius, from 8 to 40. The stream `container` gives the width of a rectangle over its side, from 0.80 to 1.25.\n * - The family has no margin and no gap. Each value comes from whole numbers and `Math.sqrt`, which each engine rounds correctly, so the family is `exact`.\n */\nexport const CIRCLE_SCATTERED: CorpusFamily<LayoutInput> = /* @__PURE__ */ Object.freeze({\n name: \"circle-scattered\",\n version: 1,\n owner: \"layout-contract\",\n meaning: \"Circle items of random radii in a fixed rectangle or circle container, which they fill approximately half.\",\n dimensions: /* @__PURE__ */ Object.freeze([/* @__PURE__ */ sharedDimension(\"count\", { default: 40 }), /* @__PURE__ */ sharedDimension(\"containerShape\", { supported: [\"rect\", \"circle\"] })]),\n seeding: \"stepRandom(seed, items) gives the radius of each item. stepRandom(seed, container) gives the width over the side of a rectangle, in hundredths.\",\n crossEngine: \"exact\",\n generate(seed: number, dims: DimensionValues, context: GenerateContext): LayoutInput {\n const count = dims[\"count\"];\n if (typeof count !== \"number\" || !Number.isInteger(count) || count < 0) throw new RangeError(`circle-scattered: the count is a whole number of 0 or more, not ${String(count)}.`);\n const containerShape = dims[\"containerShape\"];\n if (containerShape !== \"rect\" && containerShape !== \"circle\") throw new RangeError(`circle-scattered: the container shape is rect or circle, not ${String(containerShape)}.`);\n const set = context.set ?? CIRCLE_SET;\n let r = stepRandom(seed, \"items\");\n const radii = Array.from({ length: count }, () => randomInt(r, 8, 40));\n const largest = radii.reduce((m, v) => Math.max(m, v), 1);\n const squares = radii.reduce((sum, v) => sum + v * v, 0);\n let container: LayoutInput[\"container\"];\n if (containerShape === \"circle\") {\n const big = Math.max(largest, Math.ceil(Math.sqrt(2 * squares)));\n container = { w: 2 * big, h: 2 * big, fixed: \"size\", shape: { kind: \"circle\", cx: big, cy: big, r: big } };\n } else {\n // The circles have the area PI * squares. A rectangle of 6.3 * squares holds them at approximately half, and 6.3 keeps PI out of the input.\n const area = Math.ceil((63 * squares) / 10);\n r = stepRandom(seed, \"container\");\n const w = Math.max(2 * largest, Math.ceil((Math.sqrt(area) * randomInt(r, 80, 125)) / 100));\n container = { w, h: Math.max(2 * largest, Math.ceil(area / w)), fixed: \"size\" };\n }\n const body: LayoutInput = {\n schema: \"layout-input/1\",\n id: `${set}/circle-scattered/${containerShape}/s${seed}`,\n set,\n family: \"circle-scattered\",\n seed,\n source: \"made-up\",\n generator: { name: \"circle-scattered\", version: 1, params: { count, containerShape }, seed },\n container,\n boxes: radii.map((v, i) => ({ id: `c${i}`, w: 2 * v, h: 2 * v, shape: { kind: \"circle\", cx: v, cy: v, r: v } })),\n edges: [],\n };\n return { ...body, hash: documentHash(body) };\n },\n});\n\n/** The set of `RECT_SCATTERED` when the caller gives no set. */\nconst XCHECK_SET = \"xcheck-v1\";\n\n/**\n * The shared family `rect-scattered`, version 1: a fixed rectangle container, rectangle obstacles at random places and boxes without positions.\n * It is the one copy of the generator of `docs/FORMAT.md` of `packing`. Its input is the input of `packing`, byte for byte.\n * The steps `container`, `obstacles` and `boxes` each have a stream of `stepRandom`. Each value is a whole number, so the family is `exact`.\n */\nexport const RECT_SCATTERED: CorpusFamily<LayoutInput> = /* @__PURE__ */ Object.freeze({\n name: \"rect-scattered\",\n version: 1,\n owner: \"layout-contract\",\n meaning: \"Rectangle obstacles at random places in a fixed rectangle container, and boxes of random sizes.\",\n dimensions: /* @__PURE__ */ Object.freeze([/* @__PURE__ */ sharedDimension(\"count\", { default: 40 })]),\n seeding: \"stepRandom(seed, container) gives w and h. stepRandom(seed, obstacles) gives n, then ow, oh, x and y of each obstacle. stepRandom(seed, boxes) gives bw and bh of each box.\",\n crossEngine: \"exact\",\n generate(seed: number, dims: DimensionValues, context: GenerateContext): LayoutInput {\n const count = dims[\"count\"];\n if (typeof count !== \"number\" || !Number.isInteger(count) || count < 0) throw new RangeError(`rect-scattered: the count is a whole number of 0 or more, not ${String(count)}.`);\n const set = context.set ?? XCHECK_SET;\n let r = stepRandom(seed, \"container\");\n const w = randomInt(r, 600, 1000);\n const h = randomInt(r, 400, 800);\n r = stepRandom(seed, \"obstacles\");\n const n = randomInt(r, 3, 8);\n const obstacles: Obstacle[] = [];\n for (let i = 0; i < n; i++) {\n const ow = randomInt(r, 40, 160);\n const oh = randomInt(r, 40, 160);\n const x = randomInt(r, 0, w - ow);\n const y = randomInt(r, 0, h - oh);\n obstacles.push({ id: `o${i}`, region: { kind: \"rect\", x, y, w: ow, h: oh } });\n }\n r = stepRandom(seed, \"boxes\");\n const boxes = Array.from({ length: count }, (_, i) => {\n const bw = randomInt(r, 20, 120);\n const bh = randomInt(r, 20, 80);\n return { id: `b${i}`, w: bw, h: bh };\n });\n const body: LayoutInput = {\n schema: \"layout-input/1\",\n id: `${set}/rect-scattered/s${seed}`,\n set,\n family: \"rect-scattered\",\n seed,\n source: \"made-up\",\n generator: { name: \"rect-scattered\", version: 1, params: { count }, seed },\n container: { w, h, fixed: \"size\" },\n obstacles,\n boxes,\n edges: [],\n };\n return { ...body, hash: documentHash(body) };\n },\n});\n"],"mappings":";;;;AAIA,MAAa,QAAyB;CAAC;CAAO;CAAS;CAAU;AAAM;;AA2BvE,SAAgB,OAAO,MAAuB;CAC5C,OAAO;EAAE,GAAG,KAAK;EAAG,GAAG,KAAK;EAAG,GAAG,KAAK;EAAO,GAAG,KAAK;CAAO;AAC/D;;AAGA,SAAgB,YAAY,MAAuB;CACjD,OAAO;EAAE,GAAG,KAAK;EAAG,GAAG,KAAK;EAAG,OAAO,KAAK;EAAG,QAAQ,KAAK;CAAE;AAC/D;;AA4BA,SAAgB,YAAY,QAAmC;CAC7D,IAAI,WAAW,KAAA,GAAW,OAAO;EAAE,KAAK;EAAG,OAAO;EAAG,QAAQ;EAAG,MAAM;CAAE;CACxE,IAAI,OAAO,WAAW,UAAU,OAAO;EAAE,KAAK;EAAQ,OAAO;EAAQ,QAAQ;EAAQ,MAAM;CAAO;CAClG,OAAO;AACT;;AAGA,SAAgB,KAAK,MAAY,QAAkC;CACjE,MAAM,IAAI,YAAY,MAAM;CAC5B,OAAO;EAAE,GAAG,KAAK,IAAI,EAAE;EAAM,GAAG,KAAK,IAAI,EAAE;EAAK,GAAG,KAAK,IAAI,EAAE,OAAO,EAAE;EAAO,GAAG,KAAK,IAAI,EAAE,MAAM,EAAE;CAAO;AAC7G;;AAGA,SAAgB,SAAS,QAAsB;CAC7C,QAAQ,OAAO,MAAf;EACE,KAAK,QACH,OAAO;GAAE,GAAG,OAAO;GAAG,GAAG,OAAO;GAAG,GAAG,OAAO;GAAG,GAAG,OAAO;EAAE;EAC9D,KAAK,UACH,OAAO;GAAE,GAAG,OAAO,KAAK,OAAO;GAAG,GAAG,OAAO,KAAK,OAAO;GAAG,GAAG,IAAI,OAAO;GAAG,GAAG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