@mark1russell7/layout-contract 0.3.12 → 0.4.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/README.md CHANGED
@@ -33,7 +33,7 @@ The package has one runtime dependency: `@mark1russell7/rigor-generators`, the h
33
33
  | The strategy catalog | `StrategyCatalog`, `StrategyCatalogSource`, `CatalogEntry`, `ParamRoute`, `StrategyMember`, `CatalogLimit`, `STRATEGY_CATALOG_SCHEMA`, `NODE_POSITIONS_DIMENSION`, `parseStrategyCatalog`, `writeStrategyCatalog`, `checkCatalog`, `catalogDefaults`, `catalogOptions`, `catalogChoices`, `catalogKey`, `decodeOptionValue`, `encodeOptionValue` |
34
34
  | The turn | `turnBox`, `turnPort`, `turnMargin`, `turnRegion`, `turnSide`, `turnPoint` |
35
35
  | The tolerances | `EPS`, `RECORD_EPS`, `RECORD_SCALE`, `Tolerance`, `DEFAULT_TOLERANCE` |
36
- | The hard rules | `countOverlaps`, `countObstacleHits`, `regionHitsRect`, `rectInRegion`, `countOutside`, `ContainerTest`, `countPortsOffBorder`, `packHard`, `PackHard`, `PACK_HARD_RULES`, `placedRect`, `checkInput` |
36
+ | The hard rules | `HARD_RULE_VERSION`, `shapesOverlap`, `circleOverlaps`, `circlesOutside`, `placedCircle`, `PlacedCircle`, `countOverlaps`, `countObstacleHits`, `regionHitsRect`, `rectInRegion`, `countOutside`, `ContainerTest`, `countPortsOffBorder`, `packHard`, `PackHard`, `PACK_HARD_RULES`, `placedRect`, `checkInput` |
37
37
 
38
38
  ## The rules
39
39
 
@@ -54,9 +54,10 @@ The package has one runtime dependency: `@mark1russell7/rigor-generators`, the h
54
54
  - `portPoint(box, port)` gives the point of a port, relative to the top-left corner of the box. A port without a fixed point gives `undefined`, because the router picks the point.
55
55
  - A turn changes `along` of `left` and `right` to `1 - along`, because the start of the side moves to its other end. `along` of `top` and `bottom` stays.
56
56
  - An input without `along` keeps its hash.
57
- - **The hard rules of a pack.** `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. A locked box without a placement, or with a move of more than `RECORD_EPS`, breaks `locked-kept`. `checkInput` refuses a locked box without a position. Another box without a placement and not in `overflow` breaks `complete`.
58
- - **The container rule.** `in-container` counts each box that goes out of the container made smaller by `inset`. The box counts with its margin. By default, a shaped container counts as its bounding box.
59
- - **The exact container.** Give `{ exactContainer: true }` to `packHard` or `countOutside`. Then a box of a shaped container with the size `fixed` must stay inside the shape. A cut corner, a notch and a hole count. A container with a free side keeps the bounding test. The default changes to the exact test at the next breaking version.
57
+ - **The hard rules of a pack.** `no-overlap` counts the pairs of boxes and the pairs of a box and an obstacle. Two circles count by the distance of their centers, and each other pair counts by its bounding boxes. A pair of `pairGaps` uses its gap in place of the margins. A locked box without a placement, or with a move of more than `RECORD_EPS`, breaks `locked-kept`. `checkInput` refuses a locked box without a position. Another box without a placement and not in `overflow` breaks `complete`.
58
+ - **The container rule.** `in-container` counts each box that goes out of the container made smaller by `inset`. The box counts with its margin. A circle in a circle container counts by distance, also when the size is free.
59
+ - **The exact container.** Since 0.4.0, a box of a shaped container with the size `fixed` must stay inside the shape. A cut corner, a notch and a hole count. A container with a free side keeps the bounding test. Give `{ exactContainer: false }` to `packHard` or `countOutside` for the bounding test on each shape.
60
+ - **The version of the rules.** `HARD_RULE_VERSION` is 2. A record states the version in `hardRule`, and `hardRuleOf` gives 1 for a record without the field. On version 1, a count on a circle is an upper bound.
60
61
  - **The shape kinds.** An item is a `rect`, a `polygon`, a `circle` or a `free` shape. Each measure and rule declares its kinds. `checkShapes` refuses the other kinds. `docs/SHAPES.md` tells the rules.
61
62
  - `regionArea(region)` gives the exact area of a region. `boxArea(box)` gives the exact area of a box, or `undefined` for a `free` box. A box with an ellipse shape is `free`.
62
63
  - `ShapeSupport.safe` lists the kinds with a safe count: an upper bound that does not miss a break. `ruleLevel(rule, kind)` gives `exact`, `safe` or `none`.
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as FAMILY_ANY_KIND, A as shapesOf, At as toSizedRect, B as PackInputOptions, C as itemShapeOf, Ct as grow, D as shapeKindsOf, Dt as regionArea, E as shapeKindProblem, Et as pointSegmentDistance, F as LayoutEdge, G as packLinks, H as PairGap, I as LayoutGenerator, J as ClaimBreak, K as portPoint, L as LayoutInput, M as LayoutBox, N as LayoutCell, O as shapeLevel, Ot as segmentsCross, P as LayoutContainer, Q as Declares, R as Obstacle, S as isShapeKind, St as boundsOf, T as shapeKindOf, Tt as overlapOf, U as Port, V as PackLink, W as canonicalInput, X as CorpusSplit, Y as CorpusEntry, Z as DeclaredClaim, _ as ShapeKindSpec, _t as Region, a as MeasureSpec, at as checkDeclared, b as boxArea, bt as Sides, c as minEffectOf, ct as declaredClaimOf, d as SHAPE_KINDS, dt as leaveOneSeedOut, et as FamilyBy, f as SHAPE_KIND_IDS, ft as splitFileName, g as ShapeKind, gt as Rect, h as ShapeGeometry, ht as Point, i as JointMeasureId, it as SplitFold, j as Item, jt as translate, k as shapeSupportProblems, kt as toRect, l as DEFAULT_SHAPES, lt as declaredCounts, m as ShapeCheck, mt as Margin, n as JOINT_MEASURES, nt as SPLIT_SCHEMA, o as Verdict, ot as checkSplit, p as ShapeBound, pt as splitFolds, q as toPackInput, r as JOINT_MOVED_MIN, rt as SplitCorpus, s as compareMeasure, st as corpusHashOf, t as Direction, tt as FamilyCell, u as RuleLevel, ut as familyOf, v as ShapeLevel, vt as SIDES, w as ruleLevel, wt as marginSides, x as checkShapes, xt as SizedRect, y as ShapeSupport, yt as Side, z as PackInput } from "./measures-C-Tuv8GU.js";
1
+ import { $ as CorpusSplit, A as shapeKindsOf, At as regionArea, B as LayoutInput, C as checkShapes, Ct as Sides, D as ruleLevel, Dt as marginSides, E as itemShapeOf, Et as grow, F as LayoutBox, G as PairGap, H as PackInput, I as LayoutCell, J as packLinks, K as Port, L as LayoutContainer, M as shapeSupportProblems, Mt as toRect, N as shapesOf, Nt as toSizedRect, O as shapeKindOf, Ot as overlapOf, P as Item, Pt as translate, Q as CorpusEntry, R as LayoutEdge, S as boxArea, St as Side, T as isShapeKind, Tt as boundsOf, U as PackInputOptions, V as Obstacle, W as PackLink, X as toPackInput, Y as portPoint, Z as ClaimBreak, _ as ShapeKind, _t as Margin, a as MeasureSpec, at as SPLIT_SCHEMA, b as ShapeLimit, bt as Region, c as minEffectOf, ct as checkDeclared, d as SHAPE_KINDS, dt as declaredClaimOf, et as DeclaredClaim, f as SHAPE_KIND_IDS, ft as declaredCounts, g as ShapeInput, gt as splitFolds, h as ShapeGeometry, ht as splitFileName, i as JointMeasureId, it as FamilyCell, j as shapeLevel, jt as segmentsCross, k as shapeKindProblem, kt as pointSegmentDistance, l as DEFAULT_SHAPES, lt as checkSplit, m as ShapeCheck, mt as leaveOneSeedOut, n as JOINT_MEASURES, nt as FAMILY_ANY_KIND, o as Verdict, ot as SplitCorpus, p as ShapeBound, pt as familyOf, q as canonicalInput, r as JOINT_MOVED_MIN, rt as FamilyBy, s as compareMeasure, st as SplitFold, t as Direction, tt as Declares, u as RuleLevel, ut as corpusHashOf, v as ShapeKindSpec, vt as Point, w as inputShapeLevel, wt as SizedRect, x as ShapeSupport, xt as SIDES, y as ShapeLevel, yt as Rect, z as LayoutGenerator } from "./measures-KWg_was6.js";
2
2
  /** The epsilon for the float compares in an engine. */
3
3
  export declare const EPS = 1e-6;
4
4
  /**
@@ -90,6 +90,8 @@ export interface LayoutRecord {
90
90
  readonly hard: Readonly<Record<string, number>>;
91
91
  /** The tolerance of each hard rule of the run. */
92
92
  readonly tolerance?: Readonly<Partial<Tolerance>>;
93
+ /** The version of the rules that made the counts of `hard`: `HARD_RULE_VERSION` at the run. `hardRuleOf` reads it. */
94
+ readonly hardRule?: number;
93
95
  /**
94
96
  * The value is `true` when two runs with the same seed give the same positions.
95
97
  * A skipped record has `null`, because no run made a claim. Each other record has a boolean.
@@ -151,6 +153,11 @@ export type RunFacts = Omit<LayoutRecord, "schema" | "input" | "inputHash" | "se
151
153
  * The input also gives `shapes`. An input with only `rect` boxes gets no `shapes`, so its record does not change.
152
154
  */
153
155
  export declare function toLayoutRecord(input: LayoutInput, run: RunFacts): LayoutRecord;
156
+ /**
157
+ * This function gives the version of the rules that made the counts of `hard` of a record. A record without `hardRule` has version 1.
158
+ * 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.
159
+ */
160
+ export declare function hardRuleOf(record: Pick<LayoutRecord, "hardRule">): number;
154
161
  /**
155
162
  * This function gives the problems of one `layout-record/1` value. An empty list means a good record.
156
163
  * A record that has `skipped` has `deterministic: null`. An old skipped record with a boolean is also correct.
@@ -166,27 +173,70 @@ export declare function parseLayoutRecord(value: unknown): LayoutRecord;
166
173
  /** This function gives the area of a placed box: its shape or its rectangle, at its position. A box without a position gives `undefined`. */
167
174
  export declare function placedRect(box: LayoutBox): Rect | undefined;
168
175
  /**
169
- * This function counts the pairs of placed boxes whose insides, with their margins, overlap by more than `tolerance` on each axis.
170
- * A box with a shape counts as its bounding box. That area is larger, thus the count is safe.
176
+ * The version of the rules that count `no-overlap` and `in-container`. A record states it in `LayoutRecord.hardRule`.
177
+ *
178
+ * - Version 1 counts each shape by its bounding box. On a circle, that count is an upper bound. A count over 0 proves nothing.
179
+ * - 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.
180
+ */
181
+ export declare const HARD_RULE_VERSION = 2;
182
+ /** A circle at its place on the board: its center and its radius, without a margin. */
183
+ export interface PlacedCircle {
184
+ readonly cx: number;
185
+ readonly cy: number;
186
+ readonly r: number;
187
+ }
188
+ /** This function gives the circle of a placed box. A box without a position, or with another shape, gives `undefined`. */
189
+ export declare function placedCircle(box: LayoutBox): PlacedCircle | undefined;
190
+ /**
191
+ * This function tells if two placed boxes break `no-overlap`. It is the rule for one pair of `countOverlaps`.
192
+ *
193
+ * - 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.
194
+ * - 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.
195
+ * - 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.
196
+ * - A box without a position does not overlap.
197
+ */
198
+ export declare function shapesOverlap(a: LayoutBox, b: LayoutBox, tolerance?: number, gap?: number): boolean;
199
+ /**
200
+ * This function counts the pairs of placed boxes that break `no-overlap`. `shapesOverlap` is the rule for one pair.
201
+ * 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).
171
202
  *
172
203
  * 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.
173
204
  * Thus the pair breaks the rule only when the boxes are nearer than the gap on each axis. The other pairs do not change.
174
205
  */
175
206
  export declare function countOverlaps(boxes: readonly LayoutBox[], tolerance?: number, pairGaps?: readonly PairGap[]): number;
207
+ /**
208
+ * This function counts the pairs of placed circles that break `no-overlap`, by the distance of their centers. Each other box does not count.
209
+ *
210
+ * - Two circles break the rule when their centers are nearer than the two radii, the two margins and `gap`, less `tolerance`.
211
+ * - The margin of a circle is the largest side of its margin.
212
+ * - A pair of `pairGaps` is apart by the two radii and its gap, in place of the margins and `gap`.
213
+ * - `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.
214
+ */
215
+ export declare function circleOverlaps(boxes: readonly LayoutBox[], tolerance?: number, pairGaps?: readonly PairGap[], gap?: number): number;
176
216
  /** The options of the container test of `countOutside` and `packHard`. */
177
217
  export interface ContainerTest {
178
218
  /**
179
219
  * With `true`, a box of a shaped container with the size `fixed` must stay inside the shape, not only inside its bounding box.
180
- * The default is `false`. The default changes to `true` at the next breaking version.
220
+ * 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.
181
221
  */
182
222
  readonly exactContainer?: boolean;
183
223
  }
224
+ /**
225
+ * This function counts the placed circles that go out of a circle container, by the distance of the centers.
226
+ *
227
+ * - The reach of a circle is the sum of the center distance, the radius, the largest side of the margin and the inset.
228
+ * - A circle breaks the rule when its reach is more than the container radius plus `tolerance`.
229
+ * - 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`.
230
+ * - Each other box does not count. The function throws a `RangeError` for a container that is not a circle.
231
+ */
232
+ export declare function circlesOutside(input: LayoutInput, tolerance?: number): number;
184
233
  /**
185
234
  * This function counts the placed boxes that go out of the container.
186
235
  * 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.
187
236
  *
188
- * With `exactContainer`, a box of a shaped container with the size `fixed` also counts when `rectInRegion` tells that it is not inside the shape.
237
+ * 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`.
189
238
  * 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.
239
+ * A circle in a circle container does not use `rectInRegion`. It counts by distance, as in `circlesOutside`, also when the size is free.
190
240
  * An input without a container gives 0.
191
241
  */
192
242
  export declare function countOutside(input: LayoutInput, tolerance?: number, options?: ContainerTest): number;
@@ -201,8 +251,8 @@ export interface PackHard {
201
251
  }
202
252
  /**
203
253
  * The hard rules of a pack, with the shape kinds that each rule supports.
204
- * `no-overlap` and `in-container` test the bounding box of a shape. That count is exact only for a `rect`.
205
- * For the other kinds, 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.
254
+ * `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).
255
+ * 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.
206
256
  * `locked-kept` and `complete` read only the positions and the ids, so they support each kind.
207
257
  */
208
258
  export declare const PACK_HARD_RULES: readonly ShapeSupport<keyof PackHard>[];
@@ -221,7 +271,7 @@ export declare function countObstacleHits(boxes: readonly LayoutBox[], obstacles
221
271
  /**
222
272
  * This function gives the count of each hard rule of the output of a packer.
223
273
  * It applies the output with `applyPack`. Only the placed boxes and the locked boxes count for the overlaps and the container.
224
- * `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.
274
+ * `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.
225
275
  *
226
276
  * A locked box without a placement, or with a move of more than `RECORD_EPS`, breaks `locked-kept`.
227
277
  * A locked box without a position in the input is a bad input, not a break. `checkInput` finds it.
@@ -1550,5 +1600,5 @@ export declare const EDGE_KEY_STEP: CorpusStep;
1550
1600
  * The steps `container`, `obstacles` and `boxes` each have a stream of `stepRandom`. Each value is a whole number, so the family is `exact`.
1551
1601
  */
1552
1602
  export declare const RECT_SCATTERED: CorpusFamily<LayoutInput>;
1553
- export { ClaimBreak, CorpusEntry, CorpusSplit, DEFAULT_SHAPES, DeclaredClaim, Declares, Direction, FAMILY_ANY_KIND, FamilyBy, FamilyCell, Item, JOINT_MEASURES, JOINT_MOVED_MIN, JointMeasureId, LayoutBox, LayoutCell, LayoutContainer, LayoutEdge, LayoutGenerator, LayoutInput, Margin, MeasureSpec, Obstacle, PackInput, PackInputOptions, PackLink, PairGap, Point, Port, Rect, Region, RuleLevel, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, ShapeBound, ShapeCheck, ShapeGeometry, ShapeKind, ShapeKindSpec, ShapeLevel, ShapeSupport, Side, Sides, SizedRect, SplitCorpus, SplitFold, Verdict, boundsOf, boxArea, canonicalInput, checkDeclared, checkShapes, checkSplit, compareMeasure, corpusHashOf, declaredClaimOf, declaredCounts, familyOf, grow, isShapeKind, itemShapeOf, leaveOneSeedOut, marginSides, minEffectOf, overlapOf, packLinks, pointSegmentDistance, portPoint, regionArea, ruleLevel, segmentsCross, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, splitFileName, splitFolds, toPackInput, toRect, toSizedRect, translate };
1603
+ export { ClaimBreak, CorpusEntry, CorpusSplit, DEFAULT_SHAPES, DeclaredClaim, Declares, Direction, FAMILY_ANY_KIND, FamilyBy, FamilyCell, Item, JOINT_MEASURES, JOINT_MOVED_MIN, JointMeasureId, LayoutBox, LayoutCell, LayoutContainer, LayoutEdge, LayoutGenerator, LayoutInput, Margin, MeasureSpec, Obstacle, PackInput, PackInputOptions, PackLink, PairGap, Point, Port, Rect, Region, RuleLevel, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, ShapeBound, ShapeCheck, ShapeGeometry, ShapeInput, ShapeKind, ShapeKindSpec, ShapeLevel, ShapeLimit, ShapeSupport, Side, Sides, SizedRect, SplitCorpus, SplitFold, Verdict, boundsOf, boxArea, canonicalInput, checkDeclared, checkShapes, checkSplit, compareMeasure, corpusHashOf, declaredClaimOf, declaredCounts, familyOf, grow, inputShapeLevel, isShapeKind, itemShapeOf, leaveOneSeedOut, marginSides, minEffectOf, overlapOf, packLinks, pointSegmentDistance, portPoint, regionArea, ruleLevel, segmentsCross, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, splitFileName, splitFolds, toPackInput, toRect, toSizedRect, translate };
1554
1604
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/tolerance.ts","../src/output.ts","../src/record.ts","../src/rules.ts","../src/turn.ts","../src/balance.ts","../src/strategy.ts","../src/random.ts","../src/edges.ts","../src/hash.ts","../src/portfolio.ts","../src/strategy-space.ts","../src/strategy-options.ts","../src/strategy-catalog.ts","../src/verdict.ts","../src/families.ts"],"mappings":";;qBACa;;;;;qBAMA;;;;;qBAMA;;;;;iBAMI;;WAEN;;WAEA;;;;;;qBAOE,mBAAmB;;iBCzBf;WACN;WACA;WACA;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AAc,MAAM,aAAa,cAAc,gBAAgB,cAAc,UAAS,iBAAsB,aAAa;;;;;qBA+D5H,YAAY;;;;qBA0BZ,eAAe;;;;;;qBAoBf,gBAAgB,aAAa"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/tolerance.ts","../src/output.ts","../src/record.ts","../src/rules.ts","../src/turn.ts","../src/balance.ts","../src/strategy.ts","../src/random.ts","../src/edges.ts","../src/hash.ts","../src/portfolio.ts","../src/strategy-space.ts","../src/strategy-options.ts","../src/strategy-catalog.ts","../src/verdict.ts","../src/families.ts"],"mappings":";;qBACa;;;;;qBAMA;;;;;qBAMA;;;;;iBAMI;;WAEN;;WAEA;;;;;;qBAOE,mBAAmB;;iBCzBf;WACN;WACA;WACA;WACA;;;iBAIM;WACN;WACA;WACA,WAAW,SAAS;;;iBAId;WACN,qBAAqB;;WAErB;;WAEA;aAAiB;aAAoB;;;WAErC;aAA2B;aAAqB;aAAoB;;WACpE,iBAAiB;;;;;;;wBAQZ,UAAU,OAAO,aAAa,QAAQ,aAAa;;YC/BvD;;iBAGK;WACN;WACA,OAAO;WACP;WACA;;WAEA,SAAS,SAAS;WAClB;;WAEA;;WAEA;WACA;WACA;WACA;WACA;;WAEA,kBAAkB;;WAElB,UAAU,SAAS;;WAEnB,MAAM,SAAS;;WAEf,YAAY,SAAS,QAAQ;;WAE7B;;;;;WAKA;;WAEA;;WAEA;;WAEA;;;;;WAKA;;WAEA;;WAEA;;WAEA;;;;;WAKA;;WAEA,MAAM;;WAEN;WACA;;;;;;YAOC,WAAW,SAAS;;iBAGf;WACN;WACA;WACA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;YAIC,WAAW,KAAK;;;;;wBAMZ,eAAe,OAAO,aAAa,KAAK,WAAW;;;;;wBAkDnD,WAAW,QAAQ,KAAK;;;;;;wBASxB,kBAAkB;;;;;;wBAkClB,kBAAkB,iBAAiB;;wBCxLnC,WAAW,KAAK,YAAY;;;;;;;qBAa/B;;iBAGI;WAC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,cAAc,cAAc,mBAAmB;;EAE/C,MAAM,cAAc,oBAAoB,cAAc,OAAO,SAAS,eAAe;;EAErF,YAAY;;;qBAID,mBAAmB;;;;;qBAwCnB,mBAAmB,SAAS,eAAe;;;;;wBA4BxC,gBAAgB,cAAc,QAAO,QAAQ,mBAAwB;;YAUzE,qBAAqB,KAAK;;;;;;wBAOtB,eAAe,cAAc,MAAM,qBAAqB;;;;;wBA+BxD,kBAAkB,KAAK,iBAAiB;;;;;wBA+FxC,YAAY,KAAK,YAAY;;wBAa7B,cAAc,KAAK,YAAY;;;;;;wBAsB/B,SAAS,KAAK,iBAAiB,iBAAiB;;;;;;;;wBAsChD,kBACd,qBAAqB,mBACrB,OAAM,SAAS,eAAe,cAC9B,gBACA,cACC;;wBA8Ha,qBAAqB,IAAI,aAAa,WAAU,SAAS,aAAa,MAAW,eAAe;;iBA2G/F;WACN;WACA;;WAEA;WACA;;WAEA,qBAAqB;;WAErB;WACA,aAAa;;WAEb,cAAc,MAAM;;EAE7B,MAAM,OAAO,aAAa,cAAc,MAAM,kBAAkB;;;iBAIjD;;WAEN;;WAEA;WACA;;WAEA,QAAQ,OAAO;;;;;;;wBAWV,cAAc,MAAM,aAAa,cAAc,gBAAgB,cAAc,UAAS,iBAAsB,aAAa;;;;;qBA+D5H,YAAY;;;;qBA0BZ,eAAe;;;;;;qBAoBf,gBAAgB,aAAa"}
package/build/index.js CHANGED
@@ -177,7 +177,7 @@ function pointSegmentDistance(p, a, b) {
177
177
  // src/shapes.ts
178
178
  /**
179
179
  * The declared shape kinds, in their order. Only `rect` has all of its geometry.
180
- * `polygon` and `circle` have their bounding box and their exact area. `free` has its bounding box only.
180
+ * `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.
181
181
  */
182
182
  const SHAPE_KINDS = /* @__PURE__ */ Object.freeze([
183
183
  {
@@ -214,7 +214,7 @@ const SHAPE_KINDS = /* @__PURE__ */ Object.freeze([
214
214
  bounds: true,
215
215
  area: true,
216
216
  contains: false,
217
- overlap: false
217
+ overlap: true
218
218
  }
219
219
  },
220
220
  {
@@ -256,14 +256,35 @@ function shapeLevel(use, kind) {
256
256
  if (level !== "none") return level;
257
257
  return use.bound?.shapes.includes(kind) === true ? "bound" : "none";
258
258
  }
259
+ /** This function tells if a limit names an input. An input without a circle box is not in a limit. */
260
+ function inLimit(limit, input) {
261
+ const kinds = shapeKindsOf(input);
262
+ if (!kinds.includes("circle")) return false;
263
+ if (limit.reads === "neighbours") return kinds.length > 1 || (input.obstacles?.length ?? 0) > 0;
264
+ const shape = input.container?.shape?.kind;
265
+ return shape === "polygon" || shape === "ellipse";
266
+ }
267
+ /**
268
+ * 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.
269
+ * When the limit names the input, the level `exact` becomes `safe`. Each other level does not change.
270
+ */
271
+ function inputShapeLevel(use, kind, input) {
272
+ const level = shapeLevel(use, kind);
273
+ return level === "exact" && use.limit !== void 0 && inLimit(use.limit, input) ? "safe" : level;
274
+ }
259
275
  /**
260
276
  * This function gives the problems of a list of measures and rules. An empty list tells that the list is good.
261
277
  * 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`.
262
278
  * It also refuses a `bound` without a list of kinds, and a `side` that is not `upper` or `lower`.
279
+ * It also refuses a `limit` with a bad `reads` or a bad `until`.
263
280
  */
264
281
  function shapeSupportProblems(uses) {
265
282
  const out = [];
266
283
  for (const use of uses) {
284
+ if (use.limit !== void 0) {
285
+ if (use.limit.reads !== "neighbours" && use.limit.reads !== "container") out.push(`${use.id}: the limit reads ${String(use.limit.reads)}, not neighbours or container`);
286
+ 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`);
287
+ }
267
288
  const bound = use.bound;
268
289
  const isBound = typeof bound === "object" && bound !== null && !Array.isArray(bound);
269
290
  if (bound !== void 0 && !isBound) out.push(`${use.id}: the bound value is not an object with shapes and a side`);
@@ -364,7 +385,7 @@ function checkShapes(input, uses, options = {}) {
364
385
  for (const use of uses) {
365
386
  const shapes = shapesOf(use);
366
387
  for (const kind of kinds) {
367
- const level = shapeLevel(use, kind);
388
+ const level = inputShapeLevel(use, kind, input);
368
389
  if (level === "exact" || level === "safe" && (options.level === "safe" || options.level === "bound") || level === "bound" && options.level === "bound") continue;
369
390
  const ids = input.boxes.filter((b) => shapeKindOf(b) === kind).map((b) => b.id);
370
391
  const shown = ids.slice(0, 5).join(", ") + (ids.length > 5 ? `, and ${ids.length - 5} more` : "");
@@ -664,7 +685,11 @@ const RECORD_OPTIONAL_STRINGS = [
664
685
  "skipped",
665
686
  "commit"
666
687
  ];
667
- const RECORD_OPTIONAL_NUMBERS = ["budgetMs", "msAtLeast"];
688
+ const RECORD_OPTIONAL_NUMBERS = [
689
+ "budgetMs",
690
+ "msAtLeast",
691
+ "hardRule"
692
+ ];
668
693
  const ENV_STRINGS = [
669
694
  "node",
670
695
  "os",
@@ -691,6 +716,13 @@ function envProblems(env) {
691
716
  return out;
692
717
  }
693
718
  /**
719
+ * This function gives the version of the rules that made the counts of `hard` of a record. A record without `hardRule` has version 1.
720
+ * 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.
721
+ */
722
+ function hardRuleOf(record) {
723
+ return record.hardRule ?? 1;
724
+ }
725
+ /**
694
726
  * This function gives the problems of one `layout-record/1` value. An empty list means a good record.
695
727
  * A record that has `skipped` has `deterministic: null`. An old skipped record with a boolean is also correct.
696
728
  * A record without `skipped` has a boolean. The check accepts fields that the format does not know.
@@ -756,45 +788,136 @@ function placedRect(box) {
756
788
  };
757
789
  }
758
790
  /**
759
- * This function counts the pairs of placed boxes whose insides, with their margins, overlap by more than `tolerance` on each axis.
760
- * A box with a shape counts as its bounding box. That area is larger, thus the count is safe.
791
+ * The version of the rules that count `no-overlap` and `in-container`. A record states it in `LayoutRecord.hardRule`.
761
792
  *
762
- * 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.
763
- * Thus the pair breaks the rule only when the boxes are nearer than the gap on each axis. The other pairs do not change.
793
+ * - Version 1 counts each shape by its bounding box. On a circle, that count is an upper bound. A count over 0 proves nothing.
794
+ * - 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.
764
795
  */
765
- function countOverlaps(boxes, tolerance = DEFAULT_TOLERANCE.overlap, pairGaps) {
766
- if (pairGaps === void 0 || pairGaps.length === 0) return marginOverlaps(boxes, tolerance, void 0);
796
+ const HARD_RULE_VERSION = 2;
797
+ /** This function gives the circle of a placed box. A box without a position, or with another shape, gives `undefined`. */
798
+ function placedCircle(box) {
799
+ if (box.shape?.kind !== "circle" || box.x === void 0 || box.y === void 0) return void 0;
800
+ return {
801
+ cx: box.x + box.shape.cx,
802
+ cy: box.y + box.shape.cy,
803
+ r: box.shape.r
804
+ };
805
+ }
806
+ /** 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. */
807
+ function marginReach(margin) {
808
+ const m = marginSides(margin);
809
+ return Math.max(m.top, m.right, m.bottom, m.left);
810
+ }
811
+ /** This function tells if the centers of two circles are nearer than `need`. It compares the squares, so it does not take a root. */
812
+ function nearerThan(a, b, need) {
813
+ if (need <= 0) return false;
814
+ const dx = a.cx - b.cx;
815
+ const dy = a.cy - b.cy;
816
+ return dx * dx + dy * dy < need * need;
817
+ }
818
+ /**
819
+ * This function tells if two placed boxes break `no-overlap`. It is the rule for one pair of `countOverlaps`.
820
+ *
821
+ * - 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.
822
+ * - 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.
823
+ * - 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.
824
+ * - A box without a position does not overlap.
825
+ */
826
+ function shapesOverlap(a, b, tolerance = DEFAULT_TOLERANCE.overlap, gap) {
827
+ const ca = placedCircle(a);
828
+ const cb = placedCircle(b);
829
+ if (ca !== void 0 && cb !== void 0) return nearerThan(ca, cb, ca.r + cb.r + (gap ?? marginReach(a.margin) + marginReach(b.margin)) - tolerance);
830
+ const ra = placedRect(a);
831
+ const rb = placedRect(b);
832
+ if (ra === void 0 || rb === void 0) return false;
833
+ const o = gap === void 0 ? overlapOf(grow(ra, a.margin), grow(rb, b.margin)) : overlapOf(grow(ra, gap), rb);
834
+ return o.x > tolerance && o.y > tolerance;
835
+ }
836
+ /** 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. */
837
+ function gapsOf(pairGaps) {
767
838
  const gaps = /* @__PURE__ */ new Map();
768
- for (const p of pairGaps) {
839
+ for (const p of pairGaps ?? []) {
769
840
  const key = pairKey(p.a, p.b);
770
841
  if (p.a !== p.b && !gaps.has(key)) gaps.set(key, p.gap);
771
842
  }
843
+ return gaps;
844
+ }
845
+ /**
846
+ * This function counts the pairs of placed boxes that break `no-overlap`. `shapesOverlap` is the rule for one pair.
847
+ * 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).
848
+ *
849
+ * 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.
850
+ * Thus the pair breaks the rule only when the boxes are nearer than the gap on each axis. The other pairs do not change.
851
+ */
852
+ function countOverlaps(boxes, tolerance = DEFAULT_TOLERANCE.overlap, pairGaps) {
853
+ const circles = circleOverlaps(boxes, tolerance, pairGaps);
854
+ if (pairGaps === void 0 || pairGaps.length === 0) return circles + marginOverlaps(boxes, tolerance, void 0);
855
+ const gaps = gapsOf(pairGaps);
772
856
  const raw = /* @__PURE__ */ new Map();
773
- for (const box of boxes) {
774
- const r = placedRect(box);
775
- if (r !== void 0 && !raw.has(box.id)) raw.set(box.id, r);
776
- }
777
- let count = marginOverlaps(boxes, tolerance, gaps);
857
+ for (const box of boxes) if (placedRect(box) !== void 0 && !raw.has(box.id)) raw.set(box.id, box);
858
+ let count = circles + marginOverlaps(boxes, tolerance, gaps);
778
859
  for (const [key, gap] of gaps) {
779
860
  const [a, b] = JSON.parse(key);
780
- const ra = raw.get(a);
781
- const rb = raw.get(b);
782
- if (ra === void 0 || rb === void 0) continue;
783
- const o = overlapOf(grow(ra, gap), rb);
784
- if (o.x > tolerance && o.y > tolerance) count++;
861
+ const ba = raw.get(a);
862
+ const bb = raw.get(b);
863
+ if (ba === void 0 || bb === void 0) continue;
864
+ if (placedCircle(ba) !== void 0 && placedCircle(bb) !== void 0) continue;
865
+ if (shapesOverlap(ba, bb, tolerance, gap)) count++;
785
866
  }
786
867
  return count;
787
868
  }
788
869
  /** This function gives the key of a pair of box ids, with the same key for each order. */
789
870
  const pairKey = (a, b) => JSON.stringify(a < b ? [a, b] : [b, a]);
790
- /** This function counts the overlaps of the boxes with their margins. It skips the pairs of `skip`. Without `skip`, it is the rule of 0.2.13. */
871
+ /**
872
+ * This function counts the pairs of placed circles that break `no-overlap`, by the distance of their centers. Each other box does not count.
873
+ *
874
+ * - Two circles break the rule when their centers are nearer than the two radii, the two margins and `gap`, less `tolerance`.
875
+ * - The margin of a circle is the largest side of its margin.
876
+ * - A pair of `pairGaps` is apart by the two radii and its gap, in place of the margins and `gap`.
877
+ * - `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.
878
+ */
879
+ function circleOverlaps(boxes, tolerance = DEFAULT_TOLERANCE.overlap, pairGaps, gap = 0) {
880
+ const gaps = gapsOf(pairGaps);
881
+ const discs = [];
882
+ const first = /* @__PURE__ */ new Map();
883
+ for (const box of boxes) {
884
+ const c = placedCircle(box);
885
+ if (c === void 0) continue;
886
+ discs.push({
887
+ id: box.id,
888
+ c,
889
+ reach: c.r + marginReach(box.margin) + gap / 2
890
+ });
891
+ if (!first.has(box.id)) first.set(box.id, c);
892
+ }
893
+ discs.sort((a, b) => a.c.cx - a.reach - (b.c.cx - b.reach));
894
+ let count = 0;
895
+ for (let i = 0; i < discs.length; i++) {
896
+ const a = discs[i];
897
+ for (let j = i + 1; j < discs.length; j++) {
898
+ const b = discs[j];
899
+ if (b.c.cx - b.reach >= a.c.cx + a.reach - tolerance) break;
900
+ if (gaps.has(pairKey(a.id, b.id))) continue;
901
+ if (nearerThan(a.c, b.c, a.reach + b.reach - tolerance)) count++;
902
+ }
903
+ }
904
+ for (const [key, g] of gaps) {
905
+ const [a, b] = JSON.parse(key);
906
+ const ca = first.get(a);
907
+ const cb = first.get(b);
908
+ if (ca !== void 0 && cb !== void 0 && nearerThan(ca, cb, ca.r + cb.r + g - tolerance)) count++;
909
+ }
910
+ return count;
911
+ }
912
+ /** This function counts the overlaps by the bounding boxes with their margins. It skips the pairs of `skip` and the pairs of two circles. */
791
913
  function marginOverlaps(boxes, tolerance, skip) {
792
914
  const rects = [];
793
915
  for (const box of boxes) {
794
916
  const r = placedRect(box);
795
917
  if (r !== void 0) rects.push({
796
918
  id: box.id,
797
- r: grow(r, box.margin)
919
+ r: grow(r, box.margin),
920
+ circle: box.shape?.kind === "circle"
798
921
  });
799
922
  }
800
923
  rects.sort((a, b) => a.r.x - b.r.x);
@@ -804,6 +927,7 @@ function marginOverlaps(boxes, tolerance, skip) {
804
927
  for (let j = i + 1; j < rects.length; j++) {
805
928
  const b = rects[j].r;
806
929
  if (b.x >= a.x + a.w - tolerance) break;
930
+ if (rects[i].circle && rects[j].circle) continue;
807
931
  if (skip !== void 0 && skip.has(pairKey(rects[i].id, rects[j].id))) continue;
808
932
  const o = overlapOf(a, b);
809
933
  if (o.x > tolerance && o.y > tolerance) count++;
@@ -811,18 +935,61 @@ function marginOverlaps(boxes, tolerance, skip) {
811
935
  }
812
936
  return count;
813
937
  }
938
+ /** 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`. */
939
+ function containerCircle(c) {
940
+ const s = c.shape;
941
+ if (s?.kind !== "circle") return void 0;
942
+ if (c.fixed === "size") return s;
943
+ if (c.w === void 0) return void 0;
944
+ const r = c.w / 2;
945
+ return {
946
+ cx: s.cx - s.r + r,
947
+ cy: s.cy - s.r + r,
948
+ r
949
+ };
950
+ }
951
+ /** 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. */
952
+ function circleOutside(disc, extra, ring, tolerance) {
953
+ const room = ring.r + tolerance - disc.r - extra;
954
+ if (room < 0) return true;
955
+ const dx = disc.cx - ring.cx;
956
+ const dy = disc.cy - ring.cy;
957
+ return dx * dx + dy * dy > room * room;
958
+ }
959
+ /**
960
+ * This function counts the placed circles that go out of a circle container, by the distance of the centers.
961
+ *
962
+ * - The reach of a circle is the sum of the center distance, the radius, the largest side of the margin and the inset.
963
+ * - A circle breaks the rule when its reach is more than the container radius plus `tolerance`.
964
+ * - 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`.
965
+ * - Each other box does not count. The function throws a `RangeError` for a container that is not a circle.
966
+ */
967
+ function circlesOutside(input, tolerance = DEFAULT_TOLERANCE.overlap) {
968
+ const c = input.container;
969
+ const ring = c === void 0 ? void 0 : containerCircle(c);
970
+ if (c === void 0 || ring === void 0) throw new RangeError("The function circlesOutside needs a circle container, with w when its size is free.");
971
+ let count = 0;
972
+ for (const box of input.boxes) {
973
+ const disc = placedCircle(box);
974
+ if (disc !== void 0 && circleOutside(disc, marginReach(box.margin) + (c.inset ?? 0), ring, tolerance)) count++;
975
+ }
976
+ return count;
977
+ }
814
978
  /**
815
979
  * This function counts the placed boxes that go out of the container.
816
980
  * 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.
817
981
  *
818
- * With `exactContainer`, a box of a shaped container with the size `fixed` also counts when `rectInRegion` tells that it is not inside the shape.
982
+ * 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`.
819
983
  * 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.
984
+ * A circle in a circle container does not use `rectInRegion`. It counts by distance, as in `circlesOutside`, also when the size is free.
820
985
  * An input without a container gives 0.
821
986
  */
822
987
  function countOutside(input, tolerance = DEFAULT_TOLERANCE.overlap, options = {}) {
823
988
  const c = input.container;
824
989
  if (c === void 0) return 0;
825
- const shape = options.exactContainer === true && c.fixed === "size" ? c.shape : void 0;
990
+ const exact = options.exactContainer !== false;
991
+ const shape = exact && c.fixed === "size" ? c.shape : void 0;
992
+ const ring = exact ? containerCircle(c) : void 0;
826
993
  const area = c.shape === void 0 ? {
827
994
  x: 0,
828
995
  y: 0,
@@ -839,8 +1006,11 @@ function countOutside(input, tolerance = DEFAULT_TOLERANCE.overlap, options = {}
839
1006
  const r = grow(r0, box.margin);
840
1007
  const outX = r.x < area.x + inset - tolerance || r.x + r.w > area.x + area.w - inset + tolerance;
841
1008
  const outY = r.y < area.y + inset - tolerance || r.y + r.h > area.y + area.h - inset + tolerance;
1009
+ const disc = ring === void 0 ? void 0 : placedCircle(box);
842
1010
  if (fixW && outX || fixH && outY) count++;
843
- else if (shape !== void 0 && !rectInRegion(shape, shrink(grow(r, inset), tolerance))) count++;
1011
+ else if (ring !== void 0 && disc !== void 0) {
1012
+ if (circleOutside(disc, marginReach(box.margin) + inset, ring, tolerance)) count++;
1013
+ } else if (shape !== void 0 && !rectInRegion(shape, shrink(grow(r, inset), tolerance))) count++;
844
1014
  }
845
1015
  return count;
846
1016
  }
@@ -863,28 +1033,30 @@ function countPortsOffBorder(boxes, eps = RECORD_EPS) {
863
1033
  }
864
1034
  /**
865
1035
  * The hard rules of a pack, with the shape kinds that each rule supports.
866
- * `no-overlap` and `in-container` test the bounding box of a shape. That count is exact only for a `rect`.
867
- * For the other kinds, 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.
1036
+ * `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).
1037
+ * 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.
868
1038
  * `locked-kept` and `complete` read only the positions and the ids, so they support each kind.
869
1039
  */
870
1040
  const PACK_HARD_RULES = /* @__PURE__ */ Object.freeze([
871
1041
  {
872
1042
  id: "no-overlap",
873
- shapes: ["rect"],
874
- safe: [
875
- "polygon",
876
- "circle",
877
- "free"
878
- ]
1043
+ shapes: ["rect", "circle"],
1044
+ safe: ["polygon", "free"],
1045
+ limit: {
1046
+ reads: "neighbours",
1047
+ because: "A circle beside another shape kind or an obstacle counts by its bounding box.",
1048
+ until: "2026-11-28"
1049
+ }
879
1050
  },
880
1051
  {
881
1052
  id: "in-container",
882
- shapes: ["rect"],
883
- safe: [
884
- "polygon",
885
- "circle",
886
- "free"
887
- ]
1053
+ shapes: ["rect", "circle"],
1054
+ safe: ["polygon", "free"],
1055
+ limit: {
1056
+ reads: "container",
1057
+ because: "A circle in a polygon or an ellipse container counts by its bounding box.",
1058
+ until: "2026-11-28"
1059
+ }
888
1060
  },
889
1061
  {
890
1062
  id: "locked-kept",
@@ -1050,7 +1222,7 @@ function countObstacleHits(boxes, obstacles, tolerance = DEFAULT_TOLERANCE.overl
1050
1222
  /**
1051
1223
  * This function gives the count of each hard rule of the output of a packer.
1052
1224
  * It applies the output with `applyPack`. Only the placed boxes and the locked boxes count for the overlaps and the container.
1053
- * `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.
1225
+ * `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.
1054
1226
  *
1055
1227
  * A locked box without a placement, or with a move of more than `RECORD_EPS`, breaks `locked-kept`.
1056
1228
  * A locked box without a position in the input is a bad input, not a break. `checkInput` finds it.
@@ -5565,6 +5737,6 @@ const RECT_SCATTERED = /* @__PURE__ */ Object.freeze({
5565
5737
  };
5566
5738
  }
5567
5739
  });
5568
- export { BALANCE_MEASURE_SUFFIXES, BALANCE_SIDE_DEPTH, CORPUS_DIMENSIONS, DEFAULT_FAMILY_BY, DEFAULT_RNG, DEFAULT_SHAPES, DEFAULT_TOLERANCE, EDGES_STEP, EDGE_DENSITY, EDGE_KEY_STEP, EDGE_KEY_STEP_VERSION, EDGE_STEP_VERSION, EPS, FAMILY_ANY_KIND, INVALIDATED_FIELD, JOINT_MEASURES, JOINT_MOVED_MIN, NODE_POSITIONS_DIMENSION, PACK_HARD_RULES, RECORD_EPS, RECORD_SCALE, RECT_SCATTERED, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, STRATEGY_CATALOG_SCHEMA, STRATEGY_SPACE_SCHEMA, VERDICT_DRAWS, VERDICT_EXACT_CAP, VERDICT_EXACT_MAX, VERDICT_RUNS, VERDICT_SEED, applyPack, balanceMeasureSpecs, balanceMeasures, balanceOf, boundsOf, boxArea, canonicalConfig, canonicalInput, canonicalJson, catalogChoices, catalogDefaults, catalogKey, catalogOptions, checkCatalog, checkConfig, checkDeclared, checkInput, checkLayoutRecord, checkOptions, checkSchema, checkShapes, checkSpace, checkSplit, clampOptions, compareMeasure, composeFamily, configId, corpusHashOf, countObstacleHits, countOutside, countOverlaps, countPortsOffBorder, createFamilyRegistry, declarationIssues, declaredClaimOf, declaredCounts, decodeOptionValue, dimensionAt, dimensionSupports, dimensionUnit, documentHash, edgeKeyStep, edgeStep, encodeOptionValue, enumerateSpace, exercised, familyKind, familyOf, fnv1a32, grow, isShapeKind, itemShapeOf, joinConfigs, leaveOneSeedOut, levelsOf, listOptions, marginSides, minEffectOf, mulberry32, nearestGaps, optionDefaults, optionIssue, outputGroups, outputHash, overlapOf, ownerDimension, packHard, packLinks, paramActive, paramLevels, paramProblem, paramValue, parseLayoutRecord, parseStrategyCatalog, perChange, pickMoves, placedRect, pointSegmentDistance, portPoint, portfolio, procrustesOf, productSpace, randomInt, rectInRegion, regionArea, regionHitsRect, resolveDimensions, ruleLevel, segmentsCross, selectBest, sha256Hex, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, sharedDimension, spaceShapeKinds, spaceSize, splitConfig, splitFileName, splitFolds, stepRandom, sweepGrid, sweepOf, sweepValues, toLayoutRecord, toPackInput, toRect, toSizedRect, translate, turnBox, turnMargin, turnPoint, turnPort, turnRegion, turnSide, verdict, writeStrategyCatalog };
5740
+ export { BALANCE_MEASURE_SUFFIXES, BALANCE_SIDE_DEPTH, CORPUS_DIMENSIONS, DEFAULT_FAMILY_BY, DEFAULT_RNG, DEFAULT_SHAPES, DEFAULT_TOLERANCE, EDGES_STEP, EDGE_DENSITY, EDGE_KEY_STEP, EDGE_KEY_STEP_VERSION, EDGE_STEP_VERSION, EPS, FAMILY_ANY_KIND, HARD_RULE_VERSION, INVALIDATED_FIELD, JOINT_MEASURES, JOINT_MOVED_MIN, NODE_POSITIONS_DIMENSION, PACK_HARD_RULES, RECORD_EPS, RECORD_SCALE, RECT_SCATTERED, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, STRATEGY_CATALOG_SCHEMA, STRATEGY_SPACE_SCHEMA, VERDICT_DRAWS, VERDICT_EXACT_CAP, VERDICT_EXACT_MAX, VERDICT_RUNS, VERDICT_SEED, applyPack, balanceMeasureSpecs, balanceMeasures, balanceOf, boundsOf, boxArea, canonicalConfig, canonicalInput, canonicalJson, catalogChoices, catalogDefaults, catalogKey, catalogOptions, checkCatalog, checkConfig, checkDeclared, checkInput, checkLayoutRecord, checkOptions, checkSchema, checkShapes, checkSpace, checkSplit, circleOverlaps, circlesOutside, clampOptions, compareMeasure, composeFamily, configId, corpusHashOf, countObstacleHits, countOutside, countOverlaps, countPortsOffBorder, createFamilyRegistry, declarationIssues, declaredClaimOf, declaredCounts, decodeOptionValue, dimensionAt, dimensionSupports, dimensionUnit, documentHash, edgeKeyStep, edgeStep, encodeOptionValue, enumerateSpace, exercised, familyKind, familyOf, fnv1a32, grow, hardRuleOf, inputShapeLevel, isShapeKind, itemShapeOf, joinConfigs, leaveOneSeedOut, levelsOf, listOptions, marginSides, minEffectOf, mulberry32, nearestGaps, optionDefaults, optionIssue, outputGroups, outputHash, overlapOf, ownerDimension, packHard, packLinks, paramActive, paramLevels, paramProblem, paramValue, parseLayoutRecord, parseStrategyCatalog, perChange, pickMoves, placedCircle, placedRect, pointSegmentDistance, portPoint, portfolio, procrustesOf, productSpace, randomInt, rectInRegion, regionArea, regionHitsRect, resolveDimensions, ruleLevel, segmentsCross, selectBest, sha256Hex, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, shapesOverlap, sharedDimension, spaceShapeKinds, spaceSize, splitConfig, splitFileName, splitFolds, stepRandom, sweepGrid, sweepOf, sweepValues, toLayoutRecord, toPackInput, toRect, toSizedRect, translate, turnBox, turnMargin, turnPoint, turnPort, turnRegion, turnSide, verdict, writeStrategyCatalog };
5569
5741
 
5570
5742
  //# sourceMappingURL=index.js.map