@mark1russell7/layout-contract 0.10.4 → 0.10.5

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
@@ -20,6 +20,7 @@ The package has one runtime dependency: `@mark1russell7/rigor-generators`, the h
20
20
  | The cell measures | `cellsOf`, `Cells`, `CellItem`, `cellMeasures`, `cellMeasureSpecs`, `cellMeasureEntries`, `CELL_MEASURE_SUFFIXES`, `CellMeasureSuffix`, `CELL_SOURCE`, `SQUARE_COMPACTNESS` |
21
21
  | The paths | `PathSegment`, `PathMove`, `PathLine`, `PathCubic`, `PathArc`, `PathTangent`, `PATH_KINDS`, `pathOf`, `samplePath`, `pathBounds`, `pathStart`, `pathEnd`, `toSvgPath`, `cubicAt`, `checkPath` |
22
22
  | The picture `layout-picture/1` | `LayoutPicture`, `PictureBox`, `PictureRoute`, `PictureLabel`, `LabelAlign`, `LABEL_ALIGNS`, `PICTURE_SCHEMA`, `pictureOf`, `PictureParts`, `PictureRouteSource`, `checkPicture`, `parsePicture`, `pictureBounds` |
23
+ | The boxes in boxes | `BoxNode`, `boxTree`, `topBoxes`, `siblingEdges`, `flattenInput`, `FlattenOptions`, `FLATTEN_SIDES`, `flatPortId` |
23
24
  | Text layout, in the subpath `/text` | `layoutText`, `TextLayout`, `TextLayoutOptions`, `TextSizing`, `createTextCharset`, `TextCharset`, `TextCharsetOptions`, `DIGITS`, `PRINTABLE_ASCII`, `createTextLayoutCache`, `TextLayoutCache`, `TextLayoutCacheOptions`, `TextLayoutCacheStats`, `createMeasurer`, `TextMeasurer`, `canvasAdvance`, `AdvanceFn`, `fontKey`, `graphemesOf`, `textMeasures`, `TEXT_MEASURES`, `TEXT_UNITS` |
24
25
  | The edges step | `edgeStep`, `EdgeShape`, `EdgeStepParams`, `EDGE_DENSITY`, `EDGE_STEP_VERSION` |
25
26
  | The random numbers | `mulberry32`, `fnv1a32`, `stepRandom`, `randomInt` |
@@ -119,6 +120,7 @@ The comments of the source name each doc as `docs/<NAME>.md`. The docs are in th
119
120
  | [`docs/FRAMES.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/FRAMES.md) | The frame record `layout-frame/1`, the frames between two layouts and their laws |
120
121
  | [`docs/GEOMETRY-3D.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/GEOMETRY-3D.md) | The 3D records: points, boxes, rotations and rigid transforms |
121
122
  | [`docs/PICTURE.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/PICTURE.md) | The picture record `layout-picture/1`: the placed boxes, the path of each route and the labels that a viewer draws |
123
+ | [`docs/NESTED.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/NESTED.md) | The boxes in boxes of an input: the tree for a layout engine, and the flat input with ports for a router |
122
124
  | [`docs/TEXT.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/TEXT.md) | The text layout of the subpath `/text`: the rules, the units and the measures |
123
125
  | [`docs/CORPUS.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/CORPUS.md) | The shared corpus registry, its dimensions and families |
124
126
  | [`docs/CORPUS-CHECKS.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/CORPUS-CHECKS.md) | The corpus checks and the split files |
package/build/index.d.ts CHANGED
@@ -1097,6 +1097,69 @@ export declare function pictureOf(input: Pick<LayoutInput, "id" | "boxes" | "edg
1097
1097
  * A picture with no record gives `undefined`. The picture must be good (`checkPicture`).
1098
1098
  */
1099
1099
  export declare function pictureBounds(picture: LayoutPicture): Rect | undefined;
1100
+ /** One box of a tree of boxes, with the boxes that it contains. */
1101
+ export interface BoxNode {
1102
+ readonly box: LayoutBox;
1103
+ /** The boxes that have this box as their `parent`, in the order of the input. */
1104
+ readonly children: readonly BoxNode[];
1105
+ }
1106
+ /**
1107
+ * This function gives the tree of the boxes of an input. Each box with no `parent` is a root, in the order of the input.
1108
+ * The children of a box are in the order of the input too. An adapter of a layout engine makes the nodes of the engine from this tree.
1109
+ *
1110
+ * A `RangeError` comes for an id that is two times in the list, and for a parent that is not in the list.
1111
+ * It comes also for a loop of parents.
1112
+ */
1113
+ export declare function boxTree(boxes: readonly LayoutBox[]): BoxNode[];
1114
+ /**
1115
+ * This function gives the top box of each box of an input, by the id of the box. The top box of a box is the box with no `parent` that contains it.
1116
+ * A box with no parent is its own top box.
1117
+ *
1118
+ * A `RangeError` comes for each list that `boxTree` refuses.
1119
+ */
1120
+ export declare function topBoxes(boxes: readonly LayoutBox[]): Map<string, string>;
1121
+ /**
1122
+ * This function gives the edges of an input between boxes with the same parent. A layout of the children of one box reads them, for example as springs.
1123
+ *
1124
+ * - An edge between two boxes with the same parent stays as it is. Two boxes with no parent have the same parent.
1125
+ * - Each other edge goes up the tree: its ends become the two boxes with the same parent that contain its ends.
1126
+ * - An end that goes up loses its port. The edge keeps its id and its `data`.
1127
+ * - An edge has no result if one end contains the other end, or if the two ends are one box.
1128
+ * - An edge with an end that is not a box of the input has no result.
1129
+ *
1130
+ * The result has the order of the edges of the input. A `RangeError` comes for each list of boxes that `boxTree` refuses.
1131
+ */
1132
+ export declare function siblingEdges(input: Pick<LayoutInput, "boxes" | "edges">): LayoutEdge[];
1133
+ /** The options of `flattenInput`. */
1134
+ export interface FlattenOptions {
1135
+ /**
1136
+ * The sides of a top box that can hold the port of a box inside it. The default is `right` and `left`, for rows in a column.
1137
+ * The first side of the list wins a tie. With an empty list, an edge of a box inside a top box goes to the top box with no port.
1138
+ */
1139
+ readonly sides?: readonly Side[];
1140
+ }
1141
+ /** The sides of `flattenInput` with no option: the two ends of a row. */
1142
+ export declare const FLATTEN_SIDES: readonly Side[];
1143
+ /** This function gives the id of the port that `flattenInput` makes for a box inside a top box, on a side of the top box. */
1144
+ export declare function flatPortId(box: string, side: Side): string;
1145
+ /**
1146
+ * This function gives the input of the top boxes of an input, for a router that does not go into a box.
1147
+ * The top boxes are the boxes with no `parent`. Each top box is one obstacle, and a box inside it becomes a port on its border.
1148
+ *
1149
+ * - An edge between two top boxes stays as it is.
1150
+ * - An edge with an end inside a top box goes to that top box, at a port. The port is on the side that points most to the top box of the other end.
1151
+ * - The port is at the middle of the inner box along that side. Its id comes from `flatPortId`. Only an end of an edge makes a port.
1152
+ * - An end that moves to a top box loses the port that it had.
1153
+ * - An edge has no result if its two ends are in one top box, or if an end is not a box of the input.
1154
+ *
1155
+ * Each edge keeps its id and its `data`. Thus a route of the flat input is the route of the edge with the same id in the input.
1156
+ * `pictureOf` puts that route between the inner boxes.
1157
+ *
1158
+ * The other fields of the input stay. The result has no `hash`, because it is a different document, and no `pairGaps` entry of an inner box.
1159
+ * A port needs the place of its inner box and of the two top boxes. A `RangeError` comes for a box with no place there.
1160
+ * It comes also for a top box that has a port with the id of a new port. Each list of boxes that `boxTree` refuses gives one too.
1161
+ */
1162
+ export declare function flattenInput(input: LayoutInput, options?: FlattenOptions): LayoutInput;
1100
1163
  /**
1101
1164
  * The common fields of a strategy of an engine. Each engine adds its own function, for example `pack` or `route`.
1102
1165
  * `O` is the type of the options, and `S` is the type of `supports`.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["StrategySpace","KindOptions","SpaceSizeOptions","SpaceSize","EnumerateOptions","StrategyConfig"],"sources":["../src/geometry3.ts","../src/curves.ts","../src/tolerance.ts","../src/output.ts","../src/record.ts","../src/rules.ts","../src/turn.ts","../src/resize.ts","../src/balance.ts","../src/measure-registry.ts","../src/cell.ts","../src/frame.ts","../src/path.ts","../src/picture.ts","../src/strategy.ts","../src/random.ts","../src/edges.ts","../src/hash.ts","../src/portfolio.ts","../src/corpus-manifest.ts","../src/strategy-space.ts","../src/strategy-catalog.ts","../src/verdict.ts","../src/families.ts","../src/measure-survey.ts"],"mappings":";;;;;;;;iBAOiB;WACN;WACA;WACA;;;qBAIE,SAAS;;;;;iBAML;WACN;WACA;WACA;WACA;WACA;WACA;;;;;;iBAOM;WACN;WACA;WACA;WACA;;;qBAIE,cAAc;;;;;iBAMV;WACN,UAAU;WACV,UAAU;;;qBAIR,eAAe;;wBAGZ,WA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xD,kBAAkB,KAAK,iBAAiB;;;;;wBA+FxC,YAAY,KAAK,YAAY;;wBAM7B,cAAc,KAAK,YAAY;;;;;;wBAgB/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;;;;;;;;;qBAuBf,kBAAkB,aAAa;;;;;;qBAqD/B,gBAAgB,aAAa;;qBCl3B7B;;iBAGI;WACN;WACA;WACA,WAAW;WACX;WACA;;WAEA;;;iBAIM;WACN;WACA;WACA,mBAAmB;;;iBAIb;WACN,eAAe;;WAEf;WACA,kBAAkB;;;;;;iBAOZ;WACN;WACA;;WAEA;aAA4B;aAAqB;aAAyB;;;;iBAIpE;;WAEN;;WAEA,UAAU,SAAS;;WAEnB;aAA+B;aAAqB;aAAsC;;;WAE1F,gBAAgB;;WAEhB;;WAEA,OAAO,SAAS;;;wBAOX,YAAY;;wBA8CZ,eAAe;;wBAMf,eAAe,QAAQ,gBAAgB"}
1
+ {"version":3,"file":"index.d.ts","names":["StrategySpace","KindOptions","SpaceSizeOptions","SpaceSize","EnumerateOptions","StrategyConfig"],"sources":["../src/geometry3.ts","../src/curves.ts","../src/tolerance.ts","../src/output.ts","../src/record.ts","../src/rules.ts","../src/turn.ts","../src/resize.ts","../src/balance.ts","../src/measure-registry.ts","../src/cell.ts","../src/frame.ts","../src/path.ts","../src/picture.ts","../src/nest.ts","../src/strategy.ts","../src/random.ts","../src/edges.ts","../src/hash.ts","../src/portfolio.ts","../src/corpus-manifest.ts","../src/strategy-space.ts","../src/strategy-catalog.ts","../src/verdict.ts","../src/families.ts","../src/measure-survey.ts"],"mappings":";;;;;;;;iBAOiB;WACN;WACA;WACA;;;qBAIE,SAAS;;;;;iBAML;WACN;WACA;WACA;WACA;WACA;WACA;;;;;;iBAOM;WACN;WACA;WACA;WACA;;;qBAIE,cAAc;;;;;iBAMV;WACN,UAAU;WACV,UAAU;;;qBAIR,eAAe;;wBAGZ,WAAW,GAAG,QAAQ,GAAG,SAAS;;wBAKlC,gBAAgB,GAAG,QAAQ,GAAG,SAAS;;wBAKvC,YAAY,OAAO,QAAQ,iBAAiB;;wBAK5C,KAAK,GAAG,QAAQ,GAAG;;wBAKnB,OAAO,GAAG,QAAQ,GAAG,SAAS;;wBAK9B,QAAQ,QAAQ;;wBAKhB,UAAU,GAAG,QAAQ,GAAG;;;;;;wBASxB,cAAc,MAAM,QAAQ,gBAAgB;;;;;wBAa5C,kBAAkB,OAAO,WAAW,OAAO,YAAY;;wBAUvD,iBAAiB,UAAU,YAAY;;;;;wBAQvC,mBAAmB,UAAU,YAAY;;wBAOzC,aAAa,UAAU,WAAW,OAAO,SAAS;;wBAYlD,gBAAgB,WAAW,YAAY,OAAO,SAAS;;;;;wBAQvD,mBAAmB,OAAO,YAAY,OAAO,aAAa;;wBAQ1D,kBAAkB,WAAW,aAAa;;;;;wBAS1C,iBAAiB,WAAW;;wBAwB5B,WAAW,KAAK,OAAO;;wBAKvB,WAAW,KAAK;;;;;wBAQhB,YAAY,KAAK,gBAAgB;;wBAajC,UAAU,iBAAiB,WAAW;;;;;wBAwBtC,mBAAmB,KAAK,MAAM,WAAW,aAAa;;;;;wBAStD,WAAW,GAAG,MAAM,GAAG,OAAO;;;;;YCnPlC;;qBAmBC,2BAA2B;;YAG5B;;YAGA,yBAAyB,eAAe,eAAe,eAAe;;iBAGjE;WAC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;;qBAuBf,kBAAkB,aAAa;;;;;;qBAqD/B,gBAAgB,aAAa;;qBCl3B7B;;iBAGI;WACN;WACA;WACA,WAAW;WACX;WACA;;WAEA;;;iBAIM;WACN;WACA;WACA,mBAAmB;;;iBAIb;WACN,eAAe;;WAEf;WACA,kBAAkB;;;;;;iBAOZ;WACN;WACA;;WAEA;aAA4B;aAAqB;aAAyB;;;;iBAIpE;;WAEN;;WAEA,UAAU,SAAS;;WAEnB;aAA+B;aAAqB;aAAsC;;;WAE1F,gBAAgB;;WAEhB;;WAEA,OAAO,SAAS;;;wBAOX,YAAY;;wBA8CZ,eAAe;;wBAMf,eAAe,QAAQ,gBAAgB"}
package/build/index.js CHANGED
@@ -849,7 +849,7 @@ function inverseSymmetry(symmetry) {
849
849
  return symmetry === "rise" ? "fall" : symmetry === "fall" ? "rise" : symmetry;
850
850
  }
851
851
  /** This function gives the count of levels of a side. A side that is not a power of 2 from 1 to `CURVE_MAX_SIDE` is a `RangeError`. */
852
- function levelsOf$1(side) {
852
+ function levelsOf$2(side) {
853
853
  if (!Number.isInteger(side) || side < 1 || side > 67108864 || (side & side - 1) !== 0) throw new RangeError(`The side of a curve grid must be a power of 2 from 1 to ${CURVE_MAX_SIDE}, not ${side}.`);
854
854
  return Math.round(Math.log2(side));
855
855
  }
@@ -859,7 +859,7 @@ function levelsOf$1(side) {
859
859
  * The cost is `O(log side)`.
860
860
  */
861
861
  function curveCell(curve, index, side) {
862
- const levels = levelsOf$1(side);
862
+ const levels = levelsOf$2(side);
863
863
  if (!Number.isInteger(index) || index < 0 || index >= side * side) throw new RangeError(`The index ${index} is not a cell of a grid of side ${side}.`);
864
864
  let x = 0;
865
865
  let y = 0;
@@ -880,7 +880,7 @@ function curveCell(curve, index, side) {
880
880
  * of `curveCell`. A side that is not a power of 2, or a cell outside the grid, is a `RangeError`. The cost is `O(log side)`.
881
881
  */
882
882
  function curveIndex(curve, x, y, side) {
883
- const levels = levelsOf$1(side);
883
+ const levels = levelsOf$2(side);
884
884
  for (const value of [x, y]) if (!Number.isInteger(value) || value < 0 || value >= side) throw new RangeError(`The cell (${x}, ${y}) is not in a grid of side ${side}.`);
885
885
  let index = 0;
886
886
  let s = x;
@@ -924,7 +924,7 @@ function mortonCell(index, side) {
924
924
  * A side that is not a power of 2 is a `RangeError`.
925
925
  */
926
926
  function curveCells(curve, side) {
927
- levelsOf$1(side);
927
+ levelsOf$2(side);
928
928
  return Array.from({ length: side * side }, (_, index) => curveCell(curve, index, side));
929
929
  }
930
930
  // src/shapes.ts
@@ -3792,6 +3792,241 @@ function pictureBounds(picture) {
3792
3792
  h: y1 - y0
3793
3793
  };
3794
3794
  }
3795
+ // src/nest.ts
3796
+ /** This function gives the tree of a list of boxes, with the depth and the top box of each box. `name` is the function in the text of an error. */
3797
+ function levelsOf$1(boxes, name) {
3798
+ const nodes = /* @__PURE__ */ new Map();
3799
+ for (const box of boxes) {
3800
+ if (nodes.has(box.id)) throw new RangeError(`${name}: the id ${box.id} is two times in the boxes.`);
3801
+ nodes.set(box.id, {
3802
+ box,
3803
+ children: []
3804
+ });
3805
+ }
3806
+ const roots = [];
3807
+ for (const node of nodes.values()) {
3808
+ const { id, parent } = node.box;
3809
+ if (parent === void 0) {
3810
+ roots.push(node);
3811
+ continue;
3812
+ }
3813
+ const above = nodes.get(parent);
3814
+ if (above === void 0) throw new RangeError(`${name}: the parent ${parent} of the box ${id} is not a box of the input.`);
3815
+ above.children.push(node);
3816
+ }
3817
+ const depth = /* @__PURE__ */ new Map();
3818
+ const top = /* @__PURE__ */ new Map();
3819
+ for (const root of roots) {
3820
+ const stack = [[root, 0]];
3821
+ for (let next = stack.pop(); next !== void 0; next = stack.pop()) {
3822
+ const [node, level] = next;
3823
+ depth.set(node.box.id, level);
3824
+ top.set(node.box.id, root.box.id);
3825
+ for (const child of node.children) stack.push([child, level + 1]);
3826
+ }
3827
+ }
3828
+ if (depth.size < nodes.size) throw new RangeError(`${name}: the parents of the boxes make a loop.`);
3829
+ return {
3830
+ roots,
3831
+ depth,
3832
+ top
3833
+ };
3834
+ }
3835
+ /**
3836
+ * This function gives the tree of the boxes of an input. Each box with no `parent` is a root, in the order of the input.
3837
+ * The children of a box are in the order of the input too. An adapter of a layout engine makes the nodes of the engine from this tree.
3838
+ *
3839
+ * A `RangeError` comes for an id that is two times in the list, and for a parent that is not in the list.
3840
+ * It comes also for a loop of parents.
3841
+ */
3842
+ function boxTree(boxes) {
3843
+ return [...levelsOf$1(boxes, "boxTree").roots];
3844
+ }
3845
+ /**
3846
+ * This function gives the top box of each box of an input, by the id of the box. The top box of a box is the box with no `parent` that contains it.
3847
+ * A box with no parent is its own top box.
3848
+ *
3849
+ * A `RangeError` comes for each list that `boxTree` refuses.
3850
+ */
3851
+ function topBoxes(boxes) {
3852
+ return new Map(levelsOf$1(boxes, "topBoxes").top);
3853
+ }
3854
+ /**
3855
+ * This function gives the edges of an input between boxes with the same parent. A layout of the children of one box reads them, for example as springs.
3856
+ *
3857
+ * - An edge between two boxes with the same parent stays as it is. Two boxes with no parent have the same parent.
3858
+ * - Each other edge goes up the tree: its ends become the two boxes with the same parent that contain its ends.
3859
+ * - An end that goes up loses its port. The edge keeps its id and its `data`.
3860
+ * - An edge has no result if one end contains the other end, or if the two ends are one box.
3861
+ * - An edge with an end that is not a box of the input has no result.
3862
+ *
3863
+ * The result has the order of the edges of the input. A `RangeError` comes for each list of boxes that `boxTree` refuses.
3864
+ */
3865
+ function siblingEdges(input) {
3866
+ const { depth } = levelsOf$1(input.boxes, "siblingEdges");
3867
+ const parent = new Map(input.boxes.map((box) => [box.id, box.parent]));
3868
+ const out = [];
3869
+ for (const edge of input.edges ?? []) {
3870
+ let a = edge.source;
3871
+ let b = edge.target;
3872
+ let da = depth.get(a);
3873
+ let db = depth.get(b);
3874
+ if (da === void 0 || db === void 0) continue;
3875
+ for (; da > db; da--) a = parent.get(a);
3876
+ for (; db > da; db--) b = parent.get(b);
3877
+ if (a === b) continue;
3878
+ while (parent.get(a) !== parent.get(b)) {
3879
+ a = parent.get(a);
3880
+ b = parent.get(b);
3881
+ }
3882
+ out.push({
3883
+ id: edge.id,
3884
+ source: a,
3885
+ target: b,
3886
+ ...a === edge.source && edge.sourcePort !== void 0 ? { sourcePort: edge.sourcePort } : {},
3887
+ ...b === edge.target && edge.targetPort !== void 0 ? { targetPort: edge.targetPort } : {},
3888
+ ...edge.data === void 0 ? {} : { data: edge.data }
3889
+ });
3890
+ }
3891
+ return out;
3892
+ }
3893
+ /** The sides of `flattenInput` with no option: the two ends of a row. */
3894
+ const FLATTEN_SIDES = /* @__PURE__ */ Object.freeze(["right", "left"]);
3895
+ /** The direction out of each side of a box. The y axis points down. */
3896
+ const OUT = {
3897
+ top: {
3898
+ x: 0,
3899
+ y: -1
3900
+ },
3901
+ right: {
3902
+ x: 1,
3903
+ y: 0
3904
+ },
3905
+ bottom: {
3906
+ x: 0,
3907
+ y: 1
3908
+ },
3909
+ left: {
3910
+ x: -1,
3911
+ y: 0
3912
+ }
3913
+ };
3914
+ /** This function gives the rectangle of a placed box. A `RangeError` comes for a box with no place. */
3915
+ function placeOf(box) {
3916
+ if (box.x === void 0 || box.y === void 0) throw new RangeError(`flattenInput: the box ${box.id} has no place, and the port of a box in a top box needs it.`);
3917
+ return {
3918
+ x: box.x,
3919
+ y: box.y,
3920
+ w: box.w,
3921
+ h: box.h
3922
+ };
3923
+ }
3924
+ /** This function gives the id of the port that `flattenInput` makes for a box inside a top box, on a side of the top box. */
3925
+ function flatPortId(box, side) {
3926
+ return `${box}:${side}`;
3927
+ }
3928
+ /** This function gives the share `part` of `whole`, from 0 to 1. A whole of 0 gives the middle. */
3929
+ function shareOf(part, whole) {
3930
+ return whole > 0 ? Math.min(1, Math.max(0, part / whole)) : .5;
3931
+ }
3932
+ /**
3933
+ * This function gives the input of the top boxes of an input, for a router that does not go into a box.
3934
+ * The top boxes are the boxes with no `parent`. Each top box is one obstacle, and a box inside it becomes a port on its border.
3935
+ *
3936
+ * - An edge between two top boxes stays as it is.
3937
+ * - An edge with an end inside a top box goes to that top box, at a port. The port is on the side that points most to the top box of the other end.
3938
+ * - The port is at the middle of the inner box along that side. Its id comes from `flatPortId`. Only an end of an edge makes a port.
3939
+ * - An end that moves to a top box loses the port that it had.
3940
+ * - An edge has no result if its two ends are in one top box, or if an end is not a box of the input.
3941
+ *
3942
+ * Each edge keeps its id and its `data`. Thus a route of the flat input is the route of the edge with the same id in the input.
3943
+ * `pictureOf` puts that route between the inner boxes.
3944
+ *
3945
+ * The other fields of the input stay. The result has no `hash`, because it is a different document, and no `pairGaps` entry of an inner box.
3946
+ * A port needs the place of its inner box and of the two top boxes. A `RangeError` comes for a box with no place there.
3947
+ * It comes also for a top box that has a port with the id of a new port. Each list of boxes that `boxTree` refuses gives one too.
3948
+ */
3949
+ function flattenInput(input, options = {}) {
3950
+ const sides = options.sides ?? FLATTEN_SIDES;
3951
+ const { top } = levelsOf$1(input.boxes, "flattenInput");
3952
+ const byId = new Map(input.boxes.map((box) => [box.id, box]));
3953
+ const ports = /* @__PURE__ */ new Map();
3954
+ const made = /* @__PURE__ */ new Set();
3955
+ /** This function gives the end of an edge in the flat input: the top box of `id`, and its port. `other` is the top box of the other end. */
3956
+ const endOf = (id, own, other, port) => {
3957
+ if (own === id) return port === void 0 ? { box: id } : {
3958
+ box: id,
3959
+ port
3960
+ };
3961
+ if (sides.length === 0) return { box: own };
3962
+ const card = byId.get(own);
3963
+ const outer = placeOf(card);
3964
+ const from = rectCenter(outer);
3965
+ const to = rectCenter(placeOf(byId.get(other)));
3966
+ let side = sides[0];
3967
+ let most = -Infinity;
3968
+ for (const s of sides) {
3969
+ const toward = (to.x - from.x) * OUT[s].x + (to.y - from.y) * OUT[s].y;
3970
+ if (toward > most) {
3971
+ most = toward;
3972
+ side = s;
3973
+ }
3974
+ }
3975
+ const name = flatPortId(id, side);
3976
+ if (!made.has(name)) {
3977
+ if (card.ports?.some((p) => p.id === name) === true) throw new RangeError(`flattenInput: the box ${own} has a port with the id ${name} of a new port.`);
3978
+ const middle = rectCenter(placeOf(byId.get(id)));
3979
+ const along = side === "left" || side === "right" ? shareOf(middle.y - outer.y, outer.h) : shareOf(middle.x - outer.x, outer.w);
3980
+ const list = ports.get(own);
3981
+ if (list === void 0) ports.set(own, [{
3982
+ id: name,
3983
+ side,
3984
+ along
3985
+ }]);
3986
+ else list.push({
3987
+ id: name,
3988
+ side,
3989
+ along
3990
+ });
3991
+ made.add(name);
3992
+ }
3993
+ return {
3994
+ box: own,
3995
+ port: name
3996
+ };
3997
+ };
3998
+ const edges = [];
3999
+ for (const edge of input.edges ?? []) {
4000
+ const s = top.get(edge.source);
4001
+ const t = top.get(edge.target);
4002
+ if (s === void 0 || t === void 0 || s === t) continue;
4003
+ const source = endOf(edge.source, s, t, edge.sourcePort);
4004
+ const target = endOf(edge.target, t, s, edge.targetPort);
4005
+ edges.push({
4006
+ id: edge.id,
4007
+ source: source.box,
4008
+ target: target.box,
4009
+ ...source.port === void 0 ? {} : { sourcePort: source.port },
4010
+ ...target.port === void 0 ? {} : { targetPort: target.port },
4011
+ ...edge.data === void 0 ? {} : { data: edge.data }
4012
+ });
4013
+ }
4014
+ const boxes = input.boxes.filter((box) => box.parent === void 0).map((box) => {
4015
+ const more = ports.get(box.id);
4016
+ return more === void 0 ? box : {
4017
+ ...box,
4018
+ ports: [...box.ports ?? [], ...more]
4019
+ };
4020
+ });
4021
+ const { hash: _hash, pairGaps, ...rest } = input;
4022
+ const gaps = pairGaps?.filter((pair) => top.get(pair.a) === pair.a && top.get(pair.b) === pair.b);
4023
+ return {
4024
+ ...rest,
4025
+ ...gaps === void 0 ? {} : { pairGaps: gaps },
4026
+ boxes,
4027
+ ...input.edges === void 0 ? {} : { edges }
4028
+ };
4029
+ }
3795
4030
  // src/random.ts
3796
4031
  /**
3797
4032
  * This function gives a generator of random numbers in [0, 1). It is `mulberry32`, as in `docs/FORMAT.md` of `packing`.
@@ -6952,6 +7187,6 @@ function surveyFindings(survey) {
6952
7187
  units
6953
7188
  };
6954
7189
  }
6955
- export { BALANCE_MEASURE_SUFFIXES, BALANCE_SIDE_DEPTH, CELL_MEASURE_SUFFIXES, CELL_SOURCE, CIRCLE_SCATTERED, CORPUS_DIMENSIONS, CORPUS_MANIFEST_SCHEMA, CURVE_MAX_SIDE, CURVE_SYMMETRIES, DEFAULT_FAMILY_BY, DEFAULT_RNG, DEFAULT_SHAPES, DEFAULT_TOLERANCE, EDGES_STEP, EDGE_DENSITY, EDGE_KEY_STEP, EDGE_KEY_STEP_VERSION, EDGE_STEP_VERSION, EPS, EPS_STEPS, FAMILY_ANY_KIND, FRAME_SCHEMA, FRAME_STATES, HARD_RULE_VERSION, HILBERT_CURVE, HILBERT_PATTERN, INVALIDATED_FIELD, JOINT_MEASURES, JOINT_MOVED_MIN, JOINT_SOURCE, LABEL_ALIGNS, MEASURE_REGISTRY, MEASURE_SURVEY_SCHEMA, MOORE_CURVE, MOORE_PATTERN, MORTON_CURVE, NODE_POSITIONS_DIMENSION, NOISE_KINDS, NO_FINITE_RANGE, NO_ROTATION3, NO_TRANSFORM3, NO_UNIT, ORIGIN3, OUTPUT_CLASS_MIN_INPUTS, OUTPUT_GRID_PROPERTIES, OUTPUT_NEAR_WHOLE, PACK_HARD_RULES, PATH_KINDS, PICTURE_SCHEMA, RECORD_EPS, RECORD_SCALE, RECT_SCATTERED, REFUSED_PROBE, SHAPE_KINDS, SHAPE_KIND_IDS, SHARE_UNIT, SIDES, SPLIT_SCHEMA, SQUARE_COMPACTNESS, STRATEGY_CATALOG_SCHEMA, STRATEGY_CATALOG_SCHEMAS, STRATEGY_SPACE_SCHEMA, VERDICT_DRAWS, VERDICT_EXACT_CAP, VERDICT_EXACT_MAX, VERDICT_RUNS, VERDICT_SEED, addPoints3, applyPack, applySymmetry, balanceMeasureSpecs, balanceMeasures, balanceOf, boundsOf, boundsOf3, box3Center, box3Corners, box3Volume, boxArea, boxCenterDistance, canonicalConfig, canonicalInput, canonicalJson, carryRecord, catalogChoices, catalogDefaults, catalogKey, catalogOptions, cellMeasureEntries, cellMeasureSpecs, cellMeasures, cellsOf, checkCatalog, checkConfig, checkDeclared, checkInput, checkLayoutRecord, checkOptions, checkPath, checkPicture, checkRegistry, checkSchema, checkShapes, checkSpace, checkSplit, checkSurvey, circleOverlaps, circlesOutside, clampOptions, clipRing, compareMeasure, composeFamily, composeRotations3, composeTransforms3, configId, convexCorners, convexOverlap, cornersInConvex, corpusHashOf, corpusManifestText, countLinksThroughShapes, countObstacleHits, countOutside, countOverlaps, countPortsOffBorder, countResizeBreaks, createFamilyRegistry, cross3, crossingPoint, cubicAt, curveCell, curveCells, curveIndex, declarationIssues, declaredClaimOf, declaredCounts, decodeOptionValue, defaultNormalize, dimensionAt, dimensionSupports, dimensionUnit, distance3, documentHash, dot3, dropIndex, edgeKeyStep, edgeStep, encodeOptionValue, enumerateSpace, exercised, familyKind, familyOf, fingerprintOf, fixedPointMove, fnv1a32, frameAt, frameMove, frameOf, grow, hardRuleOf, hilbertCell, hilbertIndex, inputShapeLevel, inverseRotation3, inverseSymmetry, inverseTransform3, isShapeKind, itemShapeOf, joinConfigs, leaveOneSeedOut, length3, levelsOf, lineJson, listOptions, manifestText, marginSides, measureEntry, minEffectOf, mooreCell, mooreIndex, mortonCell, mortonIndex, mulberry32, nameAfterStage, nearestGaps, normalizeMeasure, normalizeRotation3, optionDefaults, optionIssue, outputGridClass, outputGroups, outputHash, outputOf, overlapOf, overlapOf3, ownerDimension, packHard, packLinks, packOutputForm, paramActive, paramAt, paramLevels, paramProblem, paramUnit, paramValue, parseLayoutRecord, parsePicture, parseStrategyCatalog, pathBounds, pathEnd, pathOf, pathStart, perChange, pickMoves, pictureBounds, pictureOf, placedCircle, placedConvex, placedRect, pointInRing, pointInRings, pointPolylineDistance, pointRegionDistance, pointSegmentDistance, portPoint, portfolio, probeHash, procrustesOf, productSpace, randomInt, rectCenter, rectInRegion, regionArea, regionHitsRect, regionPerimeter, resizeBox, resizeProblems, resolveDimensions, ringCentroid, rotatePoint3, rotationAbout, ruleLevel, samplePath, scalePoint3, scaleRect, segmentThroughShape, segmentsCross, selectBest, sha256Hex, shapeFits, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, shapesOverlap, sharedDimension, sizeBoundsOf, sizeFits, snapRect, spaceShapeKinds, spaceSize, splitConfig, splitFileName, splitFolds, stepRandom, subtractPoints3, surveyFindings, sweepGrid, sweepOf, sweepValues, toLayoutRecord, toPackInput, toRect, toSizedRect, toSvgPath, transformMatrix4, transformPoint3, transformedBounds3, translate, turnBox, turnMargin, turnPoint, turnPort, turnRegion, turnResize, turnSide, unitFault, verdict, writeStrategyCatalog };
7190
+ export { BALANCE_MEASURE_SUFFIXES, BALANCE_SIDE_DEPTH, CELL_MEASURE_SUFFIXES, CELL_SOURCE, CIRCLE_SCATTERED, CORPUS_DIMENSIONS, CORPUS_MANIFEST_SCHEMA, CURVE_MAX_SIDE, CURVE_SYMMETRIES, DEFAULT_FAMILY_BY, DEFAULT_RNG, DEFAULT_SHAPES, DEFAULT_TOLERANCE, EDGES_STEP, EDGE_DENSITY, EDGE_KEY_STEP, EDGE_KEY_STEP_VERSION, EDGE_STEP_VERSION, EPS, EPS_STEPS, FAMILY_ANY_KIND, FLATTEN_SIDES, FRAME_SCHEMA, FRAME_STATES, HARD_RULE_VERSION, HILBERT_CURVE, HILBERT_PATTERN, INVALIDATED_FIELD, JOINT_MEASURES, JOINT_MOVED_MIN, JOINT_SOURCE, LABEL_ALIGNS, MEASURE_REGISTRY, MEASURE_SURVEY_SCHEMA, MOORE_CURVE, MOORE_PATTERN, MORTON_CURVE, NODE_POSITIONS_DIMENSION, NOISE_KINDS, NO_FINITE_RANGE, NO_ROTATION3, NO_TRANSFORM3, NO_UNIT, ORIGIN3, OUTPUT_CLASS_MIN_INPUTS, OUTPUT_GRID_PROPERTIES, OUTPUT_NEAR_WHOLE, PACK_HARD_RULES, PATH_KINDS, PICTURE_SCHEMA, RECORD_EPS, RECORD_SCALE, RECT_SCATTERED, REFUSED_PROBE, SHAPE_KINDS, SHAPE_KIND_IDS, SHARE_UNIT, SIDES, SPLIT_SCHEMA, SQUARE_COMPACTNESS, STRATEGY_CATALOG_SCHEMA, STRATEGY_CATALOG_SCHEMAS, STRATEGY_SPACE_SCHEMA, VERDICT_DRAWS, VERDICT_EXACT_CAP, VERDICT_EXACT_MAX, VERDICT_RUNS, VERDICT_SEED, addPoints3, applyPack, applySymmetry, balanceMeasureSpecs, balanceMeasures, balanceOf, boundsOf, boundsOf3, box3Center, box3Corners, box3Volume, boxArea, boxCenterDistance, boxTree, canonicalConfig, canonicalInput, canonicalJson, carryRecord, catalogChoices, catalogDefaults, catalogKey, catalogOptions, cellMeasureEntries, cellMeasureSpecs, cellMeasures, cellsOf, checkCatalog, checkConfig, checkDeclared, checkInput, checkLayoutRecord, checkOptions, checkPath, checkPicture, checkRegistry, checkSchema, checkShapes, checkSpace, checkSplit, checkSurvey, circleOverlaps, circlesOutside, clampOptions, clipRing, compareMeasure, composeFamily, composeRotations3, composeTransforms3, configId, convexCorners, convexOverlap, cornersInConvex, corpusHashOf, corpusManifestText, countLinksThroughShapes, countObstacleHits, countOutside, countOverlaps, countPortsOffBorder, countResizeBreaks, createFamilyRegistry, cross3, crossingPoint, cubicAt, curveCell, curveCells, curveIndex, declarationIssues, declaredClaimOf, declaredCounts, decodeOptionValue, defaultNormalize, dimensionAt, dimensionSupports, dimensionUnit, distance3, documentHash, dot3, dropIndex, edgeKeyStep, edgeStep, encodeOptionValue, enumerateSpace, exercised, familyKind, familyOf, fingerprintOf, fixedPointMove, flatPortId, flattenInput, fnv1a32, frameAt, frameMove, frameOf, grow, hardRuleOf, hilbertCell, hilbertIndex, inputShapeLevel, inverseRotation3, inverseSymmetry, inverseTransform3, isShapeKind, itemShapeOf, joinConfigs, leaveOneSeedOut, length3, levelsOf, lineJson, listOptions, manifestText, marginSides, measureEntry, minEffectOf, mooreCell, mooreIndex, mortonCell, mortonIndex, mulberry32, nameAfterStage, nearestGaps, normalizeMeasure, normalizeRotation3, optionDefaults, optionIssue, outputGridClass, outputGroups, outputHash, outputOf, overlapOf, overlapOf3, ownerDimension, packHard, packLinks, packOutputForm, paramActive, paramAt, paramLevels, paramProblem, paramUnit, paramValue, parseLayoutRecord, parsePicture, parseStrategyCatalog, pathBounds, pathEnd, pathOf, pathStart, perChange, pickMoves, pictureBounds, pictureOf, placedCircle, placedConvex, placedRect, pointInRing, pointInRings, pointPolylineDistance, pointRegionDistance, pointSegmentDistance, portPoint, portfolio, probeHash, procrustesOf, productSpace, randomInt, rectCenter, rectInRegion, regionArea, regionHitsRect, regionPerimeter, resizeBox, resizeProblems, resolveDimensions, ringCentroid, rotatePoint3, rotationAbout, ruleLevel, samplePath, scalePoint3, scaleRect, segmentThroughShape, segmentsCross, selectBest, sha256Hex, shapeFits, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, shapesOverlap, sharedDimension, siblingEdges, sizeBoundsOf, sizeFits, snapRect, spaceShapeKinds, spaceSize, splitConfig, splitFileName, splitFolds, stepRandom, subtractPoints3, surveyFindings, sweepGrid, sweepOf, sweepValues, toLayoutRecord, toPackInput, toRect, toSizedRect, toSvgPath, topBoxes, transformMatrix4, transformPoint3, transformedBounds3, translate, turnBox, turnMargin, turnPoint, turnPort, turnRegion, turnResize, turnSide, unitFault, verdict, writeStrategyCatalog };
6956
7191
 
6957
7192
  //# sourceMappingURL=index.js.map