@mark1russell7/room-view 0.1.2 → 0.1.4
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 +2 -2
- package/build/anchors-BEnxNnSV.d.ts +75 -0
- package/build/anchors-BEnxNnSV.d.ts.map +1 -0
- package/build/frames-BYMK5ZId.d.ts +39 -0
- package/build/frames-BYMK5ZId.d.ts.map +1 -0
- package/build/index.d.ts +7 -75
- package/build/index.d.ts.map +1 -1
- package/build/index.js +5 -1
- package/build/index.js.map +1 -1
- package/build/{level-Cgja5fXb.d.ts → level-Bmz-H5iH.d.ts} +2 -2
- package/build/{level-Cgja5fXb.d.ts.map → level-Bmz-H5iH.d.ts.map} +1 -1
- package/build/level-Cu8vgrwN.js.map +1 -1
- package/build/{loads-spBbQkb0.d.ts → loads-D95Z0Vtk.d.ts} +5 -39
- package/build/loads-D95Z0Vtk.d.ts.map +1 -0
- package/build/{room-x9FxGjGi.d.ts → room-NREa6vXr.d.ts} +5 -1
- package/build/room-NREa6vXr.d.ts.map +1 -0
- package/build/sample.d.ts +2 -2
- package/build/sample.js +10 -0
- package/build/sample.js.map +1 -1
- package/build/schema.d.ts +8 -2
- package/build/schema.d.ts.map +1 -1
- package/build/schema.js +37 -1
- package/build/schema.js.map +1 -1
- package/build/three.d.ts +2 -2
- package/package.json +1 -1
- package/build/loads-spBbQkb0.d.ts.map +0 -1
- package/build/room-x9FxGjGi.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ roomSolids(room); // => the floor, and the parts of each wall around the door
|
|
|
51
51
|
- A **wall** is a straight line in the plan, with a thickness and a height. The field `side` tells which side of the line has the wall.
|
|
52
52
|
- An **opening** is a door, a window or a gap in a wall.
|
|
53
53
|
- A **floor** is one area of the plan.
|
|
54
|
-
- An **outlet** is a point on a face of a wall. A **circuit** gives power to outlets, and it has a limit in watts.
|
|
54
|
+
- An **outlet** is a point on a face of a wall. A **circuit** gives power to outlets, and it has a limit in watts. A circuit can also keep the rating of its breaker in amperes and its voltage. The limit does not change with them.
|
|
55
55
|
|
|
56
56
|
A scene is one room with its placed objects and the loads of its circuits. A placed object is a box: a desk, a rack, a computer. An object can have a parent, and then its position is relative to the parent.
|
|
57
57
|
|
|
@@ -303,7 +303,7 @@ The option `cut` gives a floor plan: the plan keeps only the solids that start b
|
|
|
303
303
|
| Entry | What it has |
|
|
304
304
|
| --- | --- |
|
|
305
305
|
| `@mark1russell7/room-view` | The record types, the model, the plan, the checks, the loads, the survey and the level. It has no schema library. |
|
|
306
|
-
| `@mark1russell7/room-view/schema` | `roomSchema`, `sceneSchema`, `surveySchema` and `
|
|
306
|
+
| `@mark1russell7/room-view/schema` | `roomSchema`, `sceneSchema`, `surveySchema`, `levelSchema` and `anchorSchema`: the zod schemas that examine the form of a JSON record. |
|
|
307
307
|
| `@mark1russell7/room-view/sample` | `SAMPLE_ROOM`, `SAMPLE_SCENE`, `SAMPLE_SURVEY` and `SAMPLE_LEVEL`: a room with a rack and an apartment of four rooms, for demos and tests. |
|
|
308
308
|
| `@mark1russell7/room-view/three` | `createRoomViewer`, the themes and `solidGeometry`: the viewer in a page. It needs the package `three`. |
|
|
309
309
|
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { t as WallFrame } from "./frames-BYMK5ZId.js";
|
|
2
|
+
import { _ as WallFace, c as PlacedObject, l as PlanPoint, p as Scene } from "./room-NREa6vXr.js";
|
|
3
|
+
import { Point3, Transform3 } from "@mark1russell7/layout-contract";
|
|
4
|
+
/** These are the surfaces that an anchor can be on. */
|
|
5
|
+
declare const ANCHOR_SURFACES: readonly ["wall", "floor", "ceiling", "object"];
|
|
6
|
+
/** A surface of an anchor. */
|
|
7
|
+
type AnchorSurface = (typeof ANCHOR_SURFACES)[number];
|
|
8
|
+
/** An anchor on a face of a wall. The lengths are in the unit of the room. */
|
|
9
|
+
interface WallAnchor {
|
|
10
|
+
readonly on: "wall";
|
|
11
|
+
/** The `id` of the wall. */
|
|
12
|
+
readonly wall: string;
|
|
13
|
+
readonly face: WallFace;
|
|
14
|
+
/** The distance along the line of the wall, from `from` to the anchor. */
|
|
15
|
+
readonly offset: number;
|
|
16
|
+
/** The height of the anchor above the floor. */
|
|
17
|
+
readonly height: number;
|
|
18
|
+
}
|
|
19
|
+
/** An anchor on the floor, at a point of the plan. */
|
|
20
|
+
interface FloorAnchor {
|
|
21
|
+
readonly on: "floor";
|
|
22
|
+
readonly at: PlanPoint;
|
|
23
|
+
/** The `id` of the floor that has the point. Without it, the point is on any floor of the room. */
|
|
24
|
+
readonly floor?: string | undefined;
|
|
25
|
+
}
|
|
26
|
+
/** An anchor on the ceiling, above a point of the plan. The ceiling is at the height of the room. */
|
|
27
|
+
interface CeilingAnchor {
|
|
28
|
+
readonly on: "ceiling";
|
|
29
|
+
readonly at: PlanPoint;
|
|
30
|
+
/** The `id` of the floor below the point. Without it, the point is above any floor of the room. */
|
|
31
|
+
readonly floor?: string | undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* An anchor on a placed object. The point and the direction are in the frame of the object, before its turn.
|
|
35
|
+
* The origin of that frame is the center of the bottom of the object.
|
|
36
|
+
*/
|
|
37
|
+
interface ObjectAnchor {
|
|
38
|
+
readonly on: "object";
|
|
39
|
+
/** The `id` of the placed object. */
|
|
40
|
+
readonly object: string;
|
|
41
|
+
/** The point in the frame of the object. The default is the center of its top. */
|
|
42
|
+
readonly at?: readonly [number, number, number] | undefined;
|
|
43
|
+
/** The direction out of the surface, in the frame of the object. The default is up: `[0, 0, 1]`. */
|
|
44
|
+
readonly out?: readonly [number, number, number] | undefined;
|
|
45
|
+
}
|
|
46
|
+
/** An anchor: a place in the space of the core, for a record of an add-on. */
|
|
47
|
+
type Anchor = WallAnchor | FloorAnchor | CeilingAnchor | ObjectAnchor;
|
|
48
|
+
/** The position of an anchor in the room, in meters. */
|
|
49
|
+
interface AnchorFrame {
|
|
50
|
+
/** The point of the anchor. */
|
|
51
|
+
readonly at: Point3;
|
|
52
|
+
/** The unit vector out of the surface, into the space of the room. */
|
|
53
|
+
readonly out: Point3;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The space of a scene, for the add-ons. It reads each wall, object and anchor of the scene.
|
|
57
|
+
* Make it once with `sceneSpace`, and give it to each add-on.
|
|
58
|
+
*/
|
|
59
|
+
interface SceneSpace {
|
|
60
|
+
readonly scene: Scene;
|
|
61
|
+
/** The length of the unit of the room, in meters. */
|
|
62
|
+
readonly scale: number;
|
|
63
|
+
/** This function gives the frame of a wall in meters, or `undefined` when the room does not have the wall. */
|
|
64
|
+
readonly wall: (id: string) => WallFrame | undefined;
|
|
65
|
+
/** This function gives a placed object of the scene, or `undefined` when the scene does not have it. */
|
|
66
|
+
readonly object: (id: string) => PlacedObject | undefined;
|
|
67
|
+
/** This function gives the transform of a placed object in meters, or `undefined` when the object has no place. */
|
|
68
|
+
readonly transform: (id: string) => Transform3 | undefined;
|
|
69
|
+
/** This function gives the position of an anchor, or `undefined` when the anchor has no position. `checkAnchor` tells the reason. */
|
|
70
|
+
readonly frame: (anchor: Anchor) => AnchorFrame | undefined;
|
|
71
|
+
}
|
|
72
|
+
/** This function gives the space of a scene. The transforms of the objects are calculated one time, at the first use. */
|
|
73
|
+
declare function sceneSpace(scene: Scene): SceneSpace;
|
|
74
|
+
export { CeilingAnchor as a, SceneSpace as c, AnchorSurface as i, WallAnchor as l, Anchor as n, FloorAnchor as o, AnchorFrame as r, ObjectAnchor as s, ANCHOR_SURFACES as t, sceneSpace as u };
|
|
75
|
+
//# sourceMappingURL=anchors-BEnxNnSV.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anchors-BEnxNnSV.d.ts","names":[],"sources":["../src/anchors.ts"],"mappings":";;;;cAUa;;KAGD,wBAAwB;;UAGnB;WACN;;WAEA;WACA,MAAM;;WAEN;;WAEA;;;UAIM;WACN;WACA,IAAI;;WAEJ;;;UAIM;WACN;WACA,IAAI;;WAEJ;;;;;;UAOM;WACN;;WAEA;;WAEA;;WAEA;;;KAIC,SAAS,aAAa,cAAc,gBAAgB;;UAG/C;;WAEN,IAAI;;WAEJ,KAAK;;;;;;UAOC;WACN,OAAO;;WAEP;;WAEA,OAAO,eAAe;;WAEtB,SAAS,eAAe;;WAExB,YAAY,eAAe;;WAE3B,QAAQ,QAAQ,WAAW;;;iBAYtB,WAAW,OAAO,QAAQ"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { d as Room } from "./room-NREa6vXr.js";
|
|
2
|
+
import { Point, Transform3 } from "@mark1russell7/layout-contract";
|
|
3
|
+
/**
|
|
4
|
+
* The frame of a wall, in meters. A point of the wall has a distance along the line and a distance across it.
|
|
5
|
+
* The distance across is positive to the left, for a person who looks from the start to the end.
|
|
6
|
+
*/
|
|
7
|
+
interface WallFrame {
|
|
8
|
+
/** The `id` of the wall. */
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly start: Point;
|
|
11
|
+
readonly end: Point;
|
|
12
|
+
/** The unit vector from the start to the end. A wall with the length 0, or with a length that is not finite, has the vector (1, 0). */
|
|
13
|
+
readonly along: Point;
|
|
14
|
+
/** The unit vector to the left of `along`. */
|
|
15
|
+
readonly left: Point;
|
|
16
|
+
readonly length: number;
|
|
17
|
+
readonly thickness: number;
|
|
18
|
+
readonly height: number;
|
|
19
|
+
/** The distance across of the left face. It is 0 or more. */
|
|
20
|
+
readonly leftOffset: number;
|
|
21
|
+
/** The distance across of the right face. It is 0 or less. */
|
|
22
|
+
readonly rightOffset: number;
|
|
23
|
+
}
|
|
24
|
+
/** This function gives the frame of each wall of a room, in the sequence of the walls. */
|
|
25
|
+
declare function wallFrames(room: Room): readonly WallFrame[];
|
|
26
|
+
/**
|
|
27
|
+
* This function tells if a wall has an outline in the plan. Its ends and its thickness must be lengths in the range of the model,
|
|
28
|
+
* and its length and its thickness must be above 0. Only such a wall makes a corner, and the model makes only such a wall.
|
|
29
|
+
*/
|
|
30
|
+
declare function wallHasOutline(frame: WallFrame): boolean;
|
|
31
|
+
/** This function gives the point of the plan at a distance along a wall and a distance across it, in meters. */
|
|
32
|
+
declare function wallPoint(frame: WallFrame, along: number, across: number): Point;
|
|
33
|
+
/**
|
|
34
|
+
* This function gives the transform from the frame of a wall to the room.
|
|
35
|
+
* In the frame of a wall, x is the distance along the wall and y is the distance across it. The height above the floor is z.
|
|
36
|
+
*/
|
|
37
|
+
declare function wallTransform(frame: WallFrame): Transform3;
|
|
38
|
+
export { wallTransform as a, wallPoint as i, wallFrames as n, wallHasOutline as r, WallFrame as t };
|
|
39
|
+
//# sourceMappingURL=frames-BYMK5ZId.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frames-BYMK5ZId.d.ts","names":[],"sources":["../src/frames.ts"],"mappings":";;;;;;UAQiB;;WAEN;WACA,OAAO;WACP,KAAK;;WAEL,OAAO;;WAEP,MAAM;WACN;WACA;WACA;;WAEA;;WAEA;;;iBA2BK,WAAW,MAAM,gBAAgB;;;;;iBASjC,eAAe,OAAO;;iBAKtB,UAAU,OAAO,WAAW,eAAe,iBAAiB;;;;;iBAW5D,cAAc,OAAO,YAAY"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { C as lengthsInRange, S as LengthUnit, T as unitsPer, _ as WallFace, a as Opening, b as LARGEST_LENGTH, c as PlacedObject, d as Room, f as SCENE_SCHEMA, g as Wall, h as WALL_SIDES, i as OPENING_KINDS, l as PlanPoint, m as WALL_FACES, n as CircuitLoad, o as OpeningKind, p as Scene, r as Floor, s as Outlet, t as Circuit, u as ROOM_SCHEMA, v as WallSide, w as metersPer, x as LENGTH_UNITS, y as isLayerName } from "./room-
|
|
2
|
-
import {
|
|
3
|
-
import { A as
|
|
4
|
-
import {
|
|
1
|
+
import { C as lengthsInRange, S as LengthUnit, T as unitsPer, _ as WallFace, a as Opening, b as LARGEST_LENGTH, c as PlacedObject, d as Room, f as SCENE_SCHEMA, g as Wall, h as WALL_SIDES, i as OPENING_KINDS, l as PlanPoint, m as WALL_FACES, n as CircuitLoad, o as OpeningKind, p as Scene, r as Floor, s as Outlet, t as Circuit, u as ROOM_SCHEMA, v as WallSide, w as metersPer, x as LENGTH_UNITS, y as isLayerName } from "./room-NREa6vXr.js";
|
|
2
|
+
import { a as wallTransform, i as wallPoint, n as wallFrames, r as wallHasOutline, t as WallFrame } from "./frames-BYMK5ZId.js";
|
|
3
|
+
import { A as solidVolume, C as SolidShape, D as roomSolids, E as objectTransforms, F as wallFootprints, M as JoinOptions, N as MITER_LIMIT, O as sceneSolids, P as WallFootprint, S as SolidOptions, T as boundsOfSolids, _ as PlacedBox, a as LoadLevel, b as Solid, c as SHAPE_OUTLINES, d as levelShape, f as outletLevels, g as OUTLET_PLATE, h as GLASS_THICKNESS, i as LevelShape, j as JOIN_TOLERANCE, k as solidCorners, l as ShapeOutline, m as FLOOR_DEPTH, n as LEVEL_SHAPES, o as LoadOptions, p as shapeRing, r as LOAD_LEVELS, s as NEAR_LIMIT, t as CircuitState, u as circuitStates, v as Prism, w as TO_Y_UP, x as SolidKind, y as SOLID_KINDS } from "./loads-D95Z0Vtk.js";
|
|
4
|
+
import { a as CeilingAnchor, c as SceneSpace, i as AnchorSurface, l as WallAnchor, n as Anchor, o as FloorAnchor, r as AnchorFrame, s as ObjectAnchor, t as ANCHOR_SURFACES, u as sceneSpace } from "./anchors-BEnxNnSV.js";
|
|
5
|
+
import { A as SurveyTurn, C as SurveyCheckResult, D as SurveyOutlet, E as SurveyOptions, M as expandSurvey, O as SurveyResult, S as SurveyCheck, T as SurveyObject, _ as expandLevel, a as ConnectionFault, b as SURVEY_SCHEMA, c as Level, d as LevelOptions, f as LevelResult, g as RoomPlace, h as ROOM_PLACES, i as ConnectionEnd, j as convertSurvey, k as SurveySide, l as LevelConnection, m as LevelRoomResult, n as CONNECTION_TURN_LIMIT, o as ConnectionUse, p as LevelRoom, r as CONNECTION_USES, s as LEVEL_SCHEMA, t as CONNECTION_FAULTS, u as LevelConnectionResult, v as CLOSURE_LIMIT, w as SurveyClosure, x as Survey, y as SQUARE_TURNS } from "./level-Bmz-H5iH.js";
|
|
6
|
+
import { Ring } from "@mark1russell7/layout-contract";
|
|
5
7
|
/** The outline of one solid in the plan of a room: the solid as a camera above the room sees it. */
|
|
6
8
|
export interface PlanShape {
|
|
7
9
|
/** The `id` of the solid. */
|
|
@@ -35,76 +37,6 @@ export interface PlanOptions extends SolidOptions {
|
|
|
35
37
|
* Thus a drawing in this sequence shows the room as a camera above it sees the room.
|
|
36
38
|
*/
|
|
37
39
|
export declare function planShapes(scene: Scene, options?: PlanOptions): readonly PlanShape[];
|
|
38
|
-
/** These are the surfaces that an anchor can be on. */
|
|
39
|
-
export declare const ANCHOR_SURFACES: readonly ["wall", "floor", "ceiling", "object"];
|
|
40
|
-
/** A surface of an anchor. */
|
|
41
|
-
export type AnchorSurface = (typeof ANCHOR_SURFACES)[number];
|
|
42
|
-
/** An anchor on a face of a wall. The lengths are in the unit of the room. */
|
|
43
|
-
export interface WallAnchor {
|
|
44
|
-
readonly on: "wall";
|
|
45
|
-
/** The `id` of the wall. */
|
|
46
|
-
readonly wall: string;
|
|
47
|
-
readonly face: WallFace;
|
|
48
|
-
/** The distance along the line of the wall, from `from` to the anchor. */
|
|
49
|
-
readonly offset: number;
|
|
50
|
-
/** The height of the anchor above the floor. */
|
|
51
|
-
readonly height: number;
|
|
52
|
-
}
|
|
53
|
-
/** An anchor on the floor, at a point of the plan. */
|
|
54
|
-
export interface FloorAnchor {
|
|
55
|
-
readonly on: "floor";
|
|
56
|
-
readonly at: PlanPoint;
|
|
57
|
-
/** The `id` of the floor that has the point. Without it, the point is on any floor of the room. */
|
|
58
|
-
readonly floor?: string | undefined;
|
|
59
|
-
}
|
|
60
|
-
/** An anchor on the ceiling, above a point of the plan. The ceiling is at the height of the room. */
|
|
61
|
-
export interface CeilingAnchor {
|
|
62
|
-
readonly on: "ceiling";
|
|
63
|
-
readonly at: PlanPoint;
|
|
64
|
-
/** The `id` of the floor below the point. Without it, the point is above any floor of the room. */
|
|
65
|
-
readonly floor?: string | undefined;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* An anchor on a placed object. The point and the direction are in the frame of the object, before its turn.
|
|
69
|
-
* The origin of that frame is the center of the bottom of the object.
|
|
70
|
-
*/
|
|
71
|
-
export interface ObjectAnchor {
|
|
72
|
-
readonly on: "object";
|
|
73
|
-
/** The `id` of the placed object. */
|
|
74
|
-
readonly object: string;
|
|
75
|
-
/** The point in the frame of the object. The default is the center of its top. */
|
|
76
|
-
readonly at?: readonly [number, number, number] | undefined;
|
|
77
|
-
/** The direction out of the surface, in the frame of the object. The default is up: `[0, 0, 1]`. */
|
|
78
|
-
readonly out?: readonly [number, number, number] | undefined;
|
|
79
|
-
}
|
|
80
|
-
/** An anchor: a place in the space of the core, for a record of an add-on. */
|
|
81
|
-
export type Anchor = WallAnchor | FloorAnchor | CeilingAnchor | ObjectAnchor;
|
|
82
|
-
/** The position of an anchor in the room, in meters. */
|
|
83
|
-
export interface AnchorFrame {
|
|
84
|
-
/** The point of the anchor. */
|
|
85
|
-
readonly at: Point3;
|
|
86
|
-
/** The unit vector out of the surface, into the space of the room. */
|
|
87
|
-
readonly out: Point3;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* The space of a scene, for the add-ons. It reads each wall, object and anchor of the scene.
|
|
91
|
-
* Make it once with `sceneSpace`, and give it to each add-on.
|
|
92
|
-
*/
|
|
93
|
-
export interface SceneSpace {
|
|
94
|
-
readonly scene: Scene;
|
|
95
|
-
/** The length of the unit of the room, in meters. */
|
|
96
|
-
readonly scale: number;
|
|
97
|
-
/** This function gives the frame of a wall in meters, or `undefined` when the room does not have the wall. */
|
|
98
|
-
readonly wall: (id: string) => WallFrame | undefined;
|
|
99
|
-
/** This function gives a placed object of the scene, or `undefined` when the scene does not have it. */
|
|
100
|
-
readonly object: (id: string) => PlacedObject | undefined;
|
|
101
|
-
/** This function gives the transform of a placed object in meters, or `undefined` when the object has no place. */
|
|
102
|
-
readonly transform: (id: string) => Transform3 | undefined;
|
|
103
|
-
/** This function gives the position of an anchor, or `undefined` when the anchor has no position. `checkAnchor` tells the reason. */
|
|
104
|
-
readonly frame: (anchor: Anchor) => AnchorFrame | undefined;
|
|
105
|
-
}
|
|
106
|
-
/** This function gives the space of a scene. The transforms of the objects are calculated one time, at the first use. */
|
|
107
|
-
export declare function sceneSpace(scene: Scene): SceneSpace;
|
|
108
40
|
/** These are the levels of a finding. An error is a fault that the model cannot show. A warning is a fault that the model can show. */
|
|
109
41
|
export declare const FINDING_LEVELS: readonly ["error", "warning"];
|
|
110
42
|
/** A level of a finding. */
|
|
@@ -243,5 +175,5 @@ export declare function readLayer<Layer>(scene: Scene, addOn: AddOn<Layer>): Lay
|
|
|
243
175
|
* `checkScene` examines the core, and this function examines the layers.
|
|
244
176
|
*/
|
|
245
177
|
export declare function checkLayers(scene: Scene, addOns: readonly AddOn<unknown>[]): readonly LayerFinding[];
|
|
246
|
-
export { CLOSURE_LIMIT, CONNECTION_FAULTS, CONNECTION_TURN_LIMIT, CONNECTION_USES, Circuit, CircuitLoad, CircuitState, ConnectionEnd, ConnectionFault, ConnectionUse, FLOOR_DEPTH, Floor, GLASS_THICKNESS, JOIN_TOLERANCE, JoinOptions, LARGEST_LENGTH, LENGTH_UNITS, LEVEL_SCHEMA, LEVEL_SHAPES, LOAD_LEVELS, LengthUnit, Level, LevelConnection, LevelConnectionResult, LevelOptions, LevelResult, LevelRoom, LevelRoomResult, LevelShape, LoadLevel, LoadOptions, MITER_LIMIT, NEAR_LIMIT, OPENING_KINDS, OUTLET_PLATE, Opening, OpeningKind, Outlet, PlacedBox, PlacedObject, PlanPoint, Prism, ROOM_PLACES, ROOM_SCHEMA, Room, RoomPlace, SCENE_SCHEMA, SHAPE_OUTLINES, SOLID_KINDS, SQUARE_TURNS, SURVEY_SCHEMA, Scene, ShapeOutline, Solid, SolidKind, SolidOptions, SolidShape, Survey, SurveyCheck, SurveyCheckResult, SurveyClosure, SurveyObject, SurveyOptions, SurveyOutlet, SurveyResult, SurveySide, SurveyTurn, TO_Y_UP, WALL_FACES, WALL_SIDES, Wall, WallFace, WallFootprint, WallFrame, WallSide, boundsOfSolids, circuitStates, convertSurvey, expandLevel, expandSurvey, isLayerName, lengthsInRange, levelShape, metersPer, objectTransforms, outletLevels, roomSolids, sceneSolids, shapeRing, solidCorners, solidVolume, unitsPer, wallFootprints, wallFrames, wallHasOutline, wallPoint, wallTransform };
|
|
178
|
+
export { ANCHOR_SURFACES, Anchor, AnchorFrame, AnchorSurface, CLOSURE_LIMIT, CONNECTION_FAULTS, CONNECTION_TURN_LIMIT, CONNECTION_USES, CeilingAnchor, Circuit, CircuitLoad, CircuitState, ConnectionEnd, ConnectionFault, ConnectionUse, FLOOR_DEPTH, Floor, FloorAnchor, GLASS_THICKNESS, JOIN_TOLERANCE, JoinOptions, LARGEST_LENGTH, LENGTH_UNITS, LEVEL_SCHEMA, LEVEL_SHAPES, LOAD_LEVELS, LengthUnit, Level, LevelConnection, LevelConnectionResult, LevelOptions, LevelResult, LevelRoom, LevelRoomResult, LevelShape, LoadLevel, LoadOptions, MITER_LIMIT, NEAR_LIMIT, OPENING_KINDS, OUTLET_PLATE, ObjectAnchor, Opening, OpeningKind, Outlet, PlacedBox, PlacedObject, PlanPoint, Prism, ROOM_PLACES, ROOM_SCHEMA, Room, RoomPlace, SCENE_SCHEMA, SHAPE_OUTLINES, SOLID_KINDS, SQUARE_TURNS, SURVEY_SCHEMA, Scene, SceneSpace, ShapeOutline, Solid, SolidKind, SolidOptions, SolidShape, Survey, SurveyCheck, SurveyCheckResult, SurveyClosure, SurveyObject, SurveyOptions, SurveyOutlet, SurveyResult, SurveySide, SurveyTurn, TO_Y_UP, WALL_FACES, WALL_SIDES, Wall, WallAnchor, WallFace, WallFootprint, WallFrame, WallSide, boundsOfSolids, circuitStates, convertSurvey, expandLevel, expandSurvey, isLayerName, lengthsInRange, levelShape, metersPer, objectTransforms, outletLevels, roomSolids, sceneSolids, sceneSpace, shapeRing, solidCorners, solidVolume, unitsPer, wallFootprints, wallFrames, wallHasOutline, wallPoint, wallTransform };
|
|
247
179
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/plan.ts","../src/
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/plan.ts","../src/check.ts","../src/layers.ts"],"mappings":";;;;;;;iBAKiB;;WAEN;WACA,MAAM;;WAEN;;WAEA,MAAM;;WAEN;;WAEA;;;;;;wBAOK,UAAU,OAAO,QAAQ;;iBAgBxB,oBAAoB;;;;;WAK1B;;;;;;;wBAQK,WAAW,OAAO,OAAO,UAAS,uBAA4B;;qBC3CjE;;YAGD,uBAAuB;;qBAGtB;;YAYD,qBAAqB;;;;;wBAMjB,WAAW,cAAc;;wBAKzB,gBAAgB;WAA0B;WAAuB;;;qBAMpE;;YAuDD,sBAAsB;;iBAGjB;WACN,OAAO;WACP,MAAM;;WAEN,QAAQ;;WAER;;WAEA;;;;;WAKA;;;iBAIM;;WAEN,QAAQ;;;;;;;wBA2CH,UAAU,MAAM,MAAM,UAAS,wBAA6B;;;;;wBAwK5D,WAAW,OAAO,OAAO,UAAS,wBAA6B;;qBAkFlE;;YAYD,qBAAqB;;iBAGhB;WACN,OAAO;WACP,MAAM;;WAEN;;WAEA;;;;;;wBAOK,YAAY,QAAQ,QAAQ,OAAO,YAAY,yBAAuC;;YCjb1F,WAAW;WAAoB;WAAmB,OAAO;;WAAqB;WAAoB;;;iBAG7F;WACN,OAAO;;WAEP;;WAEA;;WAEA;;WAEA;;;;;;iBAOM,MAAM;;WAEZ;;EAET,MAAM,iBAAiB,WAAW;;;;;EAKlC,QAAQ,OAAO,QAAQ,oBAAoB;;EAE3C,YAAY,OAAO,OAAO,SAAS,oBAAoB,UAAU;;EAEjE,MAAM,OAAO,OAAO,OAAO,sBAAsB;;;qBAItC;;iBAGI;WACN,OAAO;;WAEP;;WAEA;;WAEA;;WAEA;;WAEA;;;wBAgBK,UAAU,OAAO,OAAO,OAAO,OAAO,MAAM,SAAS,WAAW;;;;;;;;;wBAahE,YAAY,OAAO,OAAO,iBAAiB,4BAA4B"}
|
package/build/index.js
CHANGED
|
@@ -284,7 +284,11 @@ function checkRoom(room, options = {}) {
|
|
|
284
284
|
kind: "polygon",
|
|
285
285
|
points: floor.ring
|
|
286
286
|
}) * scale * scale > SMALL * SMALL)) error("floor-ring", "floor", floor.id, `The floor "${floor.id}" has no area. Its ring must have 3 or more corners that are not on one line.`);
|
|
287
|
-
for (const circuit of circuits)
|
|
287
|
+
for (const circuit of circuits) {
|
|
288
|
+
if (!(circuit.limit > 0)) error("circuit-limit", "circuit", circuit.id, `The limit of the circuit "${circuit.id}" is ${show(circuit.limit)} W. It must be above 0.`);
|
|
289
|
+
if (circuit.breaker !== void 0 && !(circuit.breaker > 0)) error("circuit-limit", "circuit", circuit.id, `The breaker of the circuit "${circuit.id}" is ${show(circuit.breaker)} A. It must be above 0.`);
|
|
290
|
+
if (circuit.voltage !== void 0 && !(circuit.voltage > 0)) error("circuit-limit", "circuit", circuit.id, `The voltage of the circuit "${circuit.id}" is ${show(circuit.voltage)} V. It must be above 0.`);
|
|
291
|
+
}
|
|
288
292
|
return findings;
|
|
289
293
|
}
|
|
290
294
|
/** This function gives the extent of a placed object from its transform. The turn of each object is about the vertical axis, so the outline is a rectangle. */
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/plan.ts","../src/check.ts","../src/anchors.ts","../src/layers.ts"],"sourcesContent":["import { transformPoint3, type Ring } from \"@mark1russell7/layout-contract\";\nimport type { Scene } from \"./room.ts\";\nimport { sceneSolids, type Solid, type SolidKind, type SolidOptions } from \"./solids.ts\";\n\n/** The outline of one solid in the plan of a room: the solid as a camera above the room sees it. */\nexport interface PlanShape {\n /** The `id` of the solid. */\n readonly solid: string;\n readonly kind: SolidKind;\n /** The `id` of the record that the solid comes from. */\n readonly source: string;\n /** The outline in the plan, in meters. */\n readonly ring: Ring;\n /** The height of the bottom of the solid above the floor, in meters. */\n readonly bottom: number;\n /** The height of the top of the solid above the floor, in meters. */\n readonly top: number;\n}\n\n/**\n * This function gives the outline of a solid in the plan.\n * Each box of a model stands on its bottom face, so the outline of a box is that face.\n */\nexport function planShape(solid: Solid): PlanShape {\n const { id, kind, source, shape } = solid;\n if (shape.kind === \"prism\") return { solid: id, kind, source, ring: shape.ring, bottom: shape.z, top: shape.z + shape.d };\n const { box, transform } = shape;\n const face = [\n { x: box.x, y: box.y, z: box.z },\n { x: box.x + box.w, y: box.y, z: box.z },\n { x: box.x + box.w, y: box.y + box.h, z: box.z },\n { x: box.x, y: box.y + box.h, z: box.z },\n ].map((corner) => transformPoint3(transform, corner));\n const bottom = face[0]!.z;\n const top = transformPoint3(transform, { x: box.x, y: box.y, z: box.z + box.d }).z;\n return { solid: id, kind, source, ring: face.map((corner) => [corner.x, corner.y] as const), bottom: Math.min(bottom, top), top: Math.max(bottom, top) };\n}\n\n/** The options of a plan. */\nexport interface PlanOptions extends SolidOptions {\n /**\n * The height of the cut of the plan above the floor, in meters. The plan has only the solids with a bottom below the cut.\n * Thus a cut below the top of a door shows the door as a gap in its wall. Without a cut, the plan has each solid.\n */\n readonly cut?: number | undefined;\n}\n\n/**\n * This function gives the plan of a scene: the outline of each solid of its model.\n * The sequence goes from the solid with the lowest top to the solid with the highest top.\n * Thus a drawing in this sequence shows the room as a camera above it sees the room.\n */\nexport function planShapes(scene: Scene, options: PlanOptions = {}): readonly PlanShape[] {\n const cut = options.cut ?? Infinity;\n return sceneSolids(scene, options)\n .map((solid) => planShape(solid))\n .filter((shape) => shape.bottom < cut)\n .map((shape, index) => ({ shape, index }))\n .sort((a, b) => a.shape.top - b.shape.top || a.index - b.index)\n .map(({ shape }) => shape);\n}\n","import { convexOverlap, length3, pointInRing, regionArea, transformPoint3, type Ring, type Transform3 } from \"@mark1russell7/layout-contract\";\nimport type { Anchor, SceneSpace } from \"./anchors.ts\";\nimport { wallFrames, wallHasOutline } from \"./frames.ts\";\nimport { wallFootprints, type JoinOptions } from \"./joins.ts\";\nimport type { PlacedObject, Room, Scene } from \"./room.ts\";\nimport { objectTransforms } from \"./solids.ts\";\nimport { LARGEST_LENGTH, lengthsInRange, metersPer } from \"./units.ts\";\n\n/** These are the levels of a finding. An error is a fault that the model cannot show. A warning is a fault that the model can show. */\nexport const FINDING_LEVELS: readonly [\"error\", \"warning\"] = [\"error\", \"warning\"];\n\n/** A level of a finding. */\nexport type FindingLevel = (typeof FINDING_LEVELS)[number];\n\n/** These are the kinds of the records that a finding can name. */\nexport const RECORD_KINDS: readonly [\"room\", \"wall\", \"opening\", \"floor\", \"outlet\", \"circuit\", \"object\", \"load\"] = [\n \"room\",\n \"wall\",\n \"opening\",\n \"floor\",\n \"outlet\",\n \"circuit\",\n \"object\",\n \"load\",\n];\n\n/** A kind of record. */\nexport type RecordKind = (typeof RECORD_KINDS)[number];\n\n/**\n * This function gives the name of a record: its kind, a colon and its `id`, for example `object:desk`.\n * The kind of a record of a layer is the name of the layer, for example `electrical/1`. A finding, a mark and the selection use this name.\n */\nexport function recordName(kind: string, id: string): string {\n return `${kind}:${id}`;\n}\n\n/** This function gives the kind and the `id` of a record name, or `undefined` for a text with no kind. A kind has no colon, so the first colon ends it. */\nexport function parseRecordName(name: string): { readonly kind: string; readonly id: string } | undefined {\n const colon = name.indexOf(\":\");\n return colon < 1 ? undefined : { kind: name.slice(0, colon), id: name.slice(colon + 1) };\n}\n\n/** These are the codes of the findings. */\nexport const FINDING_CODES: readonly [\n \"number-not-finite\",\n \"number-too-large\",\n \"id-duplicate\",\n \"size-not-positive\",\n \"wall-length\",\n \"wall-short\",\n \"wall-overlap\",\n \"opening-wall\",\n \"opening-range\",\n \"opening-height\",\n \"opening-overlap\",\n \"outlet-wall\",\n \"outlet-circuit\",\n \"outlet-range\",\n \"outlet-in-opening\",\n \"floor-ring\",\n \"circuit-limit\",\n \"object-parent\",\n \"object-cycle\",\n \"object-outlet\",\n \"object-outside\",\n \"object-overlap\",\n \"object-in-wall\",\n \"load-circuit\",\n \"load-watts\",\n] = [\n \"number-not-finite\",\n \"number-too-large\",\n \"id-duplicate\",\n \"size-not-positive\",\n \"wall-length\",\n \"wall-short\",\n \"wall-overlap\",\n \"opening-wall\",\n \"opening-range\",\n \"opening-height\",\n \"opening-overlap\",\n \"outlet-wall\",\n \"outlet-circuit\",\n \"outlet-range\",\n \"outlet-in-opening\",\n \"floor-ring\",\n \"circuit-limit\",\n \"object-parent\",\n \"object-cycle\",\n \"object-outlet\",\n \"object-outside\",\n \"object-overlap\",\n \"object-in-wall\",\n \"load-circuit\",\n \"load-watts\",\n];\n\n/** A code of a finding. */\nexport type FindingCode = (typeof FINDING_CODES)[number];\n\n/** A finding: one fault of a room record or a scene record. */\nexport interface Finding {\n readonly level: FindingLevel;\n readonly code: FindingCode;\n /** The kind of the record with the fault. */\n readonly record: RecordKind;\n /** The `id` of the record with the fault. For a load, it is the `id` of the circuit. For the room record, it is empty. */\n readonly at: string;\n /** The fault in plain words, with the values. */\n readonly message: string;\n /**\n * The `id` of the second record of the fault. It is the other opening or the other object of an overlap, or the opening that an outlet is in.\n * It is also the wall that an object overlaps, or the parent or the outlet that an object names. A fault of one record has none.\n */\n readonly other?: string | undefined;\n}\n\n/** The options of the checks. Give the options that the model gets. */\nexport interface CheckOptions {\n /** The options of the corners of the walls. */\n readonly joins?: JoinOptions | undefined;\n}\n\n/** A length in meters at this value or less is 0 for the checks: a size must be above it. */\nconst SMALL = 1e-6;\n\n/** This function gives a number with 3 decimals at most. */\nfunction show(value: number): string {\n return String(Math.round(value * 1000) / 1000);\n}\n\n/** This function tells if a value is a number that is not finite, or if it holds such a number. */\nfunction holdsBadNumber(value: unknown): boolean {\n if (typeof value === \"number\") return !Number.isFinite(value);\n if (Array.isArray(value)) return value.some((item) => holdsBadNumber(item));\n if (typeof value === \"object\" && value !== null) return Object.values(value).some((item) => holdsBadNumber(item));\n return false;\n}\n\n/** This function tells if a value is a finite number with a size above a limit, or if it holds such a number. */\nfunction holdsLargeNumber(value: unknown, limit: number): boolean {\n if (typeof value === \"number\") return Number.isFinite(value) && Math.abs(value) > limit;\n if (Array.isArray(value)) return value.some((item) => holdsLargeNumber(item, limit));\n if (typeof value === \"object\" && value !== null) return Object.values(value).some((item) => holdsLargeNumber(item, limit));\n return false;\n}\n\n/** This function gives each value that a list has two or more times. */\nfunction repeated(ids: readonly string[]): readonly string[] {\n const seen = new Set<string>();\n const twice = new Set<string>();\n for (const id of ids) {\n if (seen.has(id)) twice.add(id);\n seen.add(id);\n }\n return [...twice];\n}\n\n/**\n * This function gives each fault of a room record. A room with no finding of the level `error` gives a full model.\n *\n * The function examines the meaning of the record: for example, an opening must be in its wall. The schema examines the form of the record.\n */\nexport function checkRoom(room: Room, options: CheckOptions = {}): readonly Finding[] {\n const findings: Finding[] = [];\n const error = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"error\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const warning = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"warning\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const scale = metersPer(room.unit);\n /** The largest length of the model, in the unit of the room. */\n const largest = LARGEST_LENGTH / scale;\n /** This function tells if a size of the record is 0 for the checks. */\n const none = (size: number): boolean => !(size * scale > SMALL);\n const openings = room.openings ?? [];\n const outlets = room.outlets ?? [];\n const circuits = room.circuits ?? [];\n const floors = room.floors ?? [];\n\n if (holdsBadNumber([room.height, room.wallThickness])) error(\"number-not-finite\", \"room\", \"\", \"The height or the wall thickness of the room is not a finite number.\");\n if (holdsLargeNumber([room.height, room.wallThickness], largest)) error(\"number-too-large\", \"room\", \"\", `The height or the wall thickness of the room is above 1 000 km, the largest length of the model.`);\n const lists: readonly (readonly [RecordKind, readonly { readonly id: string }[]])[] = [\n [\"wall\", room.walls],\n [\"opening\", openings],\n [\"floor\", floors],\n [\"outlet\", outlets],\n [\"circuit\", circuits],\n ];\n for (const [record, list] of lists) {\n for (const item of list) {\n if (holdsBadNumber(item)) error(\"number-not-finite\", record, item.id, `A number of the ${record} \"${item.id}\" is not finite.`);\n // The limit of a circuit is a power, not a length.\n if (record !== \"circuit\" && holdsLargeNumber(item, largest)) error(\"number-too-large\", record, item.id, `A length of the ${record} \"${item.id}\" is above 1 000 km, the largest length of the model.`);\n }\n for (const id of repeated(list.map((item) => item.id))) error(\"id-duplicate\", record, id, `Two or more records of the kind ${record} have the id \"${id}\".`);\n }\n\n if (none(room.height)) error(\"size-not-positive\", \"room\", \"\", `The height of the room is ${show(room.height)}. It must be above 0.`);\n if (none(room.wallThickness)) error(\"size-not-positive\", \"room\", \"\", `The wall thickness of the room is ${show(room.wallThickness)}. It must be above 0.`);\n\n const frames = wallFrames(room);\n const footprints = wallFootprints(frames, options.joins);\n frames.forEach((frame, index) => {\n const wall = room.walls[index]!;\n if (wall.thickness !== undefined && none(wall.thickness)) error(\"size-not-positive\", \"wall\", wall.id, `The thickness of the wall \"${wall.id}\" is ${show(wall.thickness)}. It must be above 0.`);\n if (wall.height !== undefined && none(wall.height)) error(\"size-not-positive\", \"wall\", wall.id, `The height of the wall \"${wall.id}\" is ${show(wall.height)}. It must be above 0.`);\n const [clearFrom, clearTo] = footprints[index]!.clear;\n if (!(frame.length > SMALL)) error(\"wall-length\", \"wall\", wall.id, `The wall \"${wall.id}\" has the length 0: its two ends are one point.`);\n else if (wallHasOutline(frame) && !(clearTo - clearFrom > SMALL)) warning(\"wall-short\", \"wall\", wall.id, `The wall \"${wall.id}\" is too short for the corners at its ends: no part of it has its full thickness.`);\n });\n for (let i = 0; i < footprints.length; i++) {\n for (let j = i + 1; j < footprints.length; j++) {\n const a = footprints[i]!;\n const b = footprints[j]!;\n if (a.ring.length < 3 || b.ring.length < 3 || !(convexOverlap(a.ring, b.ring) > SMALL)) continue;\n warning(\"wall-overlap\", \"wall\", a.wall, `The walls \"${a.wall}\" and \"${b.wall}\" overlap. Walls connect only at their ends: divide a wall at the point where a different wall crosses it.`);\n }\n }\n\n const frameOf = new Map(frames.map((frame, index) => [frame.id, { frame, footprint: footprints[index]! }] as const));\n const holes = new Map<string, { id: string; from: number; to: number; sill: number; top: number }[]>();\n for (const opening of openings) {\n const found = frameOf.get(opening.wall);\n if (found === undefined) {\n error(\"opening-wall\", \"opening\", opening.id, `The opening \"${opening.id}\" is on the wall \"${opening.wall}\", which the room does not have.`);\n continue;\n }\n if (none(opening.width)) error(\"size-not-positive\", \"opening\", opening.id, `The width of the opening \"${opening.id}\" is ${show(opening.width)}. It must be above 0.`);\n if (none(opening.height)) error(\"size-not-positive\", \"opening\", opening.id, `The height of the opening \"${opening.id}\" is ${show(opening.height)}. It must be above 0.`);\n if (none(opening.width) || none(opening.height)) continue;\n const from = opening.offset * scale;\n const to = (opening.offset + opening.width) * scale;\n const sill = (opening.sill ?? 0) * scale;\n const top = sill + opening.height * scale;\n const [clearFrom, clearTo] = found.footprint.clear;\n if (from < clearFrom - SMALL || to > clearTo + SMALL) {\n error(\n \"opening-range\",\n \"opening\",\n opening.id,\n `The opening \"${opening.id}\" is from ${show(opening.offset)} to ${show(opening.offset + opening.width)} along the wall \"${opening.wall}\". The straight part of that wall is from ${show(clearFrom / scale)} to ${show(clearTo / scale)}.`,\n );\n }\n if (sill < 0 || top > found.frame.height + SMALL) {\n error(\n \"opening-height\",\n \"opening\",\n opening.id,\n `The opening \"${opening.id}\" is from the height ${show(sill / scale)} to ${show(top / scale)}. The wall \"${opening.wall}\" is from 0 to ${show(found.frame.height / scale)}.`,\n );\n }\n const list = holes.get(opening.wall) ?? [];\n list.push({ id: opening.id, from, to, sill, top });\n holes.set(opening.wall, list);\n }\n for (const [wall, list] of holes) {\n list.sort((a, b) => a.from - b.from);\n for (let i = 1; i < list.length; i++) {\n const before = list[i - 1]!;\n const hole = list[i]!;\n if (hole.from < before.to - SMALL) error(\"opening-overlap\", \"opening\", hole.id, `The openings \"${before.id}\" and \"${hole.id}\" of the wall \"${wall}\" overlap.`, before.id);\n }\n }\n\n const circuitIds = new Set(circuits.map((circuit) => circuit.id));\n for (const outlet of outlets) {\n if (outlet.circuit !== undefined && !circuitIds.has(outlet.circuit)) error(\"outlet-circuit\", \"outlet\", outlet.id, `The outlet \"${outlet.id}\" is on the circuit \"${outlet.circuit}\", which the room does not have.`);\n const found = frameOf.get(outlet.wall);\n if (found === undefined) {\n error(\"outlet-wall\", \"outlet\", outlet.id, `The outlet \"${outlet.id}\" is on the wall \"${outlet.wall}\", which the room does not have.`);\n continue;\n }\n const along = outlet.offset * scale;\n const height = outlet.height * scale;\n if (!(along >= 0 && along <= found.frame.length + SMALL && height >= 0 && height <= found.frame.height + SMALL)) {\n error(\n \"outlet-range\",\n \"outlet\",\n outlet.id,\n `The outlet \"${outlet.id}\" is at ${show(outlet.offset)} along the wall \"${outlet.wall}\" and at the height ${show(outlet.height)}. The wall has the length ${show(found.frame.length / scale)} and the height ${show(found.frame.height / scale)}.`,\n );\n continue;\n }\n const hole = (holes.get(outlet.wall) ?? []).find((item) => along > item.from && along < item.to && height > item.sill && height < item.top);\n if (hole !== undefined) warning(\"outlet-in-opening\", \"outlet\", outlet.id, `The outlet \"${outlet.id}\" is in the opening \"${hole.id}\" of the wall \"${outlet.wall}\".`, hole.id);\n }\n\n for (const floor of floors) {\n if (floor.ring.length < 3 || !(regionArea({ kind: \"polygon\", points: floor.ring }) * scale * scale > SMALL * SMALL)) {\n error(\"floor-ring\", \"floor\", floor.id, `The floor \"${floor.id}\" has no area. Its ring must have 3 or more corners that are not on one line.`);\n }\n }\n for (const circuit of circuits) {\n if (!(circuit.limit > 0)) error(\"circuit-limit\", \"circuit\", circuit.id, `The limit of the circuit \"${circuit.id}\" is ${show(circuit.limit)} W. It must be above 0.`);\n }\n return findings;\n}\n\n/** The outline in the plan and the range of heights of a placed object, in meters. */\ninterface Extent {\n readonly object: PlacedObject;\n readonly ring: Ring;\n readonly z: number;\n readonly top: number;\n}\n\n/** This function gives the extent of a placed object from its transform. The turn of each object is about the vertical axis, so the outline is a rectangle. */\nfunction extentOf(object: PlacedObject, transform: Transform3, scale: number): Extent {\n const w = (object.size[0] * scale) / 2;\n const h = (object.size[1] * scale) / 2;\n const corners: readonly (readonly [number, number])[] = [\n [0 - w, 0 - h],\n [w, 0 - h],\n [w, h],\n [0 - w, h],\n ];\n const ring = corners.map(([x, y]) => {\n const point = transformPoint3(transform, { x, y, z: 0 });\n return [point.x, point.y] as const;\n });\n return { object, ring, z: transform.position.z, top: transform.position.z + object.size[2] * scale };\n}\n\n/**\n * This function gives each fault of a scene record: the faults of its room, then the faults of its placed objects and its loads.\n * A scene with no finding of the level `error` gives a full model.\n */\nexport function checkScene(scene: Scene, options: CheckOptions = {}): readonly Finding[] {\n const findings: Finding[] = [...checkRoom(scene.room, options)];\n const error = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"error\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const warning = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"warning\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const room = scene.room;\n const scale = metersPer(room.unit);\n const objects = scene.objects ?? [];\n const byId = new Map(objects.map((object) => [object.id, object] as const));\n const outletIds = new Set((room.outlets ?? []).map((outlet) => outlet.id));\n const circuitIds = new Set((room.circuits ?? []).map((circuit) => circuit.id));\n /** This function tells if each size of an object is above 0 for the checks. */\n const hasSize = (object: PlacedObject): boolean => object.size.every((size) => size * scale > SMALL);\n\n for (const id of repeated(objects.map((object) => object.id))) error(\"id-duplicate\", \"object\", id, `Two or more records of the kind object have the id \"${id}\".`);\n\n /** The objects that hold an object, from its parent up. A loop of parents gives `undefined`. */\n const holders = (object: PlacedObject): ReadonlySet<string> | undefined => {\n const seen = new Set<string>([object.id]);\n const above = new Set<string>();\n let parent = object.parent === undefined ? undefined : byId.get(object.parent);\n while (parent !== undefined) {\n if (seen.has(parent.id)) return undefined;\n seen.add(parent.id);\n above.add(parent.id);\n parent = parent.parent === undefined ? undefined : byId.get(parent.parent);\n }\n return above;\n };\n\n for (const object of objects) {\n if (holdsBadNumber(object)) error(\"number-not-finite\", \"object\", object.id, `A number of the object \"${object.id}\" is not finite.`);\n // The turn of an object is an angle, so it has no such limit.\n if (holdsLargeNumber([object.size, object.at, object.lift], LARGEST_LENGTH / scale)) error(\"number-too-large\", \"object\", object.id, `A length of the object \"${object.id}\" is above 1 000 km, the largest length of the model.`);\n if (!hasSize(object)) error(\"size-not-positive\", \"object\", object.id, `The size of the object \"${object.id}\" is ${object.size.map(show).join(\" by \")}. Each number must be above 0.`);\n if (object.parent !== undefined && !byId.has(object.parent)) error(\"object-parent\", \"object\", object.id, `The object \"${object.id}\" is on the object \"${object.parent}\", which the scene does not have.`, object.parent);\n else if (holders(object) === undefined) error(\"object-cycle\", \"object\", object.id, `The parents of the object \"${object.id}\" make a loop.`);\n if (object.outlet !== undefined && !outletIds.has(object.outlet)) error(\"object-outlet\", \"object\", object.id, `The object \"${object.id}\" uses the outlet \"${object.outlet}\", which the room does not have.`, object.outlet);\n }\n\n const transforms = objectTransforms(scene);\n const extents: Extent[] = [];\n for (const object of objects) {\n const transform = transforms.get(object.id);\n if (transform !== undefined && hasSize(object)) extents.push(extentOf(object, transform, scale));\n }\n\n const floors = (room.floors ?? []).filter((floor) => floor.ring.length >= 3).map((floor) => floor.ring.map(([x, y]) => [x * scale, y * scale] as const));\n const frames = wallFrames(room);\n const footprints = wallFootprints(frames, options.joins);\n for (const extent of extents) {\n const { object } = extent;\n const transform = transforms.get(object.id)!;\n if (object.parent === undefined && floors.length > 0 && !floors.some((ring) => pointInRing(transform.position.x, transform.position.y, ring))) {\n warning(\"object-outside\", \"object\", object.id, `The center of the object \"${object.id}\" is not on a floor of the room.`);\n }\n footprints.forEach((footprint, index) => {\n if (footprint.ring.length < 3 || !(extent.z < frames[index]!.height - SMALL) || !(convexOverlap(footprint.ring, extent.ring) > SMALL)) return;\n warning(\"object-in-wall\", \"object\", object.id, `The object \"${object.id}\" overlaps the wall \"${footprint.wall}\".`, footprint.wall);\n });\n }\n for (let i = 0; i < extents.length; i++) {\n for (let j = i + 1; j < extents.length; j++) {\n const a = extents[i]!;\n const b = extents[j]!;\n if (holders(a.object)?.has(b.object.id) === true || holders(b.object)?.has(a.object.id) === true) continue;\n if (!(Math.min(a.top, b.top) - Math.max(a.z, b.z) > SMALL) || !(convexOverlap(a.ring, b.ring) > SMALL)) continue;\n warning(\"object-overlap\", \"object\", a.object.id, `The objects \"${a.object.id}\" and \"${b.object.id}\" overlap.`, b.object.id);\n }\n }\n\n for (const load of scene.loads ?? []) {\n if (!circuitIds.has(load.circuit)) error(\"load-circuit\", \"load\", load.circuit, `A load is on the circuit \"${load.circuit}\", which the room does not have.`);\n if (!(load.watts >= 0 && Number.isFinite(load.watts))) error(\"load-watts\", \"load\", load.circuit, `A load of the circuit \"${load.circuit}\" is ${show(load.watts)} W. It must be a finite number, 0 or more.`);\n }\n return findings;\n}\n\n/** These are the codes of the faults of an anchor. */\nexport const ANCHOR_CODES: readonly [\n \"anchor-not-finite\",\n \"anchor-wall\",\n \"anchor-object\",\n \"anchor-floor\",\n \"anchor-range\",\n \"anchor-direction\",\n \"anchor-in-opening\",\n \"anchor-outside\",\n] = [\"anchor-not-finite\", \"anchor-wall\", \"anchor-object\", \"anchor-floor\", \"anchor-range\", \"anchor-direction\", \"anchor-in-opening\", \"anchor-outside\"];\n\n/** A code of a fault of an anchor. */\nexport type AnchorCode = (typeof ANCHOR_CODES)[number];\n\n/** A fault of an anchor. `checkLayers` gives it the layer and the key of the anchor. */\nexport interface AnchorFault {\n readonly level: FindingLevel;\n readonly code: AnchorCode;\n /** The fault in plain words, with the values. */\n readonly message: string;\n /** The `id` of the second record of the fault: the opening that the anchor is in. A different fault has none. */\n readonly other?: string | undefined;\n}\n\n/**\n * This function gives the faults of an anchor in the space of a scene. `name` starts each message.\n * An error tells that the anchor has no position. A warning tells a fault that the model can show.\n */\nexport function checkAnchor(anchor: Anchor, space: SceneSpace, name: string = \"The anchor\"): readonly AnchorFault[] {\n const error = (code: AnchorCode, message: string): readonly AnchorFault[] => [{ level: \"error\", code, message: `${name} ${message}` }];\n const { scene, scale } = space;\n if (holdsBadNumber(anchor)) return error(\"anchor-not-finite\", \"has a number that is not finite.\");\n if (anchor.on === \"wall\") {\n const wall = space.wall(anchor.wall);\n if (wall === undefined) return error(\"anchor-wall\", `is on the wall \"${anchor.wall}\", which the room does not have.`);\n const along = anchor.offset * scale;\n const height = anchor.height * scale;\n if (!(along >= 0 && along <= wall.length + SMALL && height >= 0 && height <= wall.height + SMALL)) {\n return error(\n \"anchor-range\",\n `is at ${show(anchor.offset)} along the wall \"${anchor.wall}\" and at the height ${show(anchor.height)}. The wall has the length ${show(wall.length / scale)} and the height ${show(wall.height / scale)}.`,\n );\n }\n const hole = (scene.room.openings ?? []).find((opening) => {\n const sill = (opening.sill ?? 0) * scale;\n return opening.wall === anchor.wall && along > opening.offset * scale && along < (opening.offset + opening.width) * scale && height > sill && height < sill + opening.height * scale;\n });\n return hole === undefined ? [] : [{ level: \"warning\", code: \"anchor-in-opening\", message: `${name} is in the opening \"${hole.id}\" of the wall \"${anchor.wall}\".`, other: hole.id }];\n }\n if (anchor.on === \"object\") {\n const object = space.object(anchor.object);\n if (object === undefined) return error(\"anchor-object\", `is on the object \"${anchor.object}\", which the scene does not have.`);\n // An object with no place has a fault of its own, which `checkScene` tells. Here, the anchor tells that it has no position.\n if (space.transform(anchor.object) === undefined) return error(\"anchor-object\", `is on the object \"${anchor.object}\", which has no place in the room.`);\n const small = SMALL / scale;\n if (anchor.at !== undefined) {\n const [x, y, z] = anchor.at;\n const [width, depth, height] = object.size;\n if (!(Math.abs(x) <= width / 2 + small && Math.abs(y) <= depth / 2 + small && z >= -small && z <= height + small)) {\n return error(\"anchor-range\", `is at (${anchor.at.map(show).join(\", \")}) in the frame of the object \"${anchor.object}\". The object has the size ${object.size.map(show).join(\" by \")}.`);\n }\n }\n if (anchor.out !== undefined) {\n const [x, y, z] = anchor.out;\n if (!(length3({ x, y, z }) > 0)) return error(\"anchor-direction\", \"has a direction with the length 0. A direction must have a length above 0.\");\n }\n return [];\n }\n const [x, y] = anchor.at;\n if (!lengthsInRange(x * scale, y * scale)) return error(\"anchor-range\", \"is at a point above 1 000 km, the largest length of the model.\");\n const word = anchor.on === \"floor\" ? \"on\" : \"above\";\n const floors = scene.room.floors ?? [];\n if (anchor.floor !== undefined) {\n const floor = floors.find((item) => item.id === anchor.floor);\n if (floor === undefined) return error(\"anchor-floor\", `is ${word} the floor \"${anchor.floor}\", which the room does not have.`);\n return pointInRing(x, y, floor.ring) ? [] : [{ level: \"warning\", code: \"anchor-outside\", message: `${name} is not ${word} the floor \"${anchor.floor}\".` }];\n }\n if (floors.length === 0 || floors.some((floor) => pointInRing(x, y, floor.ring))) return [];\n return [{ level: \"warning\", code: \"anchor-outside\", message: `${name} is not ${word} a floor of the room.` }];\n}\n","import { length3, rotatePoint3, scalePoint3, transformPoint3, type Point3, type Transform3 } from \"@mark1russell7/layout-contract\";\nimport { wallFrames, wallPoint, type WallFrame } from \"./frames.ts\";\nimport type { PlacedObject, PlanPoint, Scene, WallFace } from \"./room.ts\";\nimport { objectTransforms } from \"./solids.ts\";\nimport { lengthsInRange, metersPer } from \"./units.ts\";\n\n// The anchors of the core: the places where an add-on puts its records. The core gives each anchor its position.\n// An anchor names no topic. An outlet, a tap and a lamp are records of add-ons, and each one is on an anchor.\n\n/** These are the surfaces that an anchor can be on. */\nexport const ANCHOR_SURFACES: readonly [\"wall\", \"floor\", \"ceiling\", \"object\"] = [\"wall\", \"floor\", \"ceiling\", \"object\"];\n\n/** A surface of an anchor. */\nexport type AnchorSurface = (typeof ANCHOR_SURFACES)[number];\n\n/** An anchor on a face of a wall. The lengths are in the unit of the room. */\nexport interface WallAnchor {\n readonly on: \"wall\";\n /** The `id` of the wall. */\n readonly wall: string;\n readonly face: WallFace;\n /** The distance along the line of the wall, from `from` to the anchor. */\n readonly offset: number;\n /** The height of the anchor above the floor. */\n readonly height: number;\n}\n\n/** An anchor on the floor, at a point of the plan. */\nexport interface FloorAnchor {\n readonly on: \"floor\";\n readonly at: PlanPoint;\n /** The `id` of the floor that has the point. Without it, the point is on any floor of the room. */\n readonly floor?: string | undefined;\n}\n\n/** An anchor on the ceiling, above a point of the plan. The ceiling is at the height of the room. */\nexport interface CeilingAnchor {\n readonly on: \"ceiling\";\n readonly at: PlanPoint;\n /** The `id` of the floor below the point. Without it, the point is above any floor of the room. */\n readonly floor?: string | undefined;\n}\n\n/**\n * An anchor on a placed object. The point and the direction are in the frame of the object, before its turn.\n * The origin of that frame is the center of the bottom of the object.\n */\nexport interface ObjectAnchor {\n readonly on: \"object\";\n /** The `id` of the placed object. */\n readonly object: string;\n /** The point in the frame of the object. The default is the center of its top. */\n readonly at?: readonly [number, number, number] | undefined;\n /** The direction out of the surface, in the frame of the object. The default is up: `[0, 0, 1]`. */\n readonly out?: readonly [number, number, number] | undefined;\n}\n\n/** An anchor: a place in the space of the core, for a record of an add-on. */\nexport type Anchor = WallAnchor | FloorAnchor | CeilingAnchor | ObjectAnchor;\n\n/** The position of an anchor in the room, in meters. */\nexport interface AnchorFrame {\n /** The point of the anchor. */\n readonly at: Point3;\n /** The unit vector out of the surface, into the space of the room. */\n readonly out: Point3;\n}\n\n/**\n * The space of a scene, for the add-ons. It reads each wall, object and anchor of the scene.\n * Make it once with `sceneSpace`, and give it to each add-on.\n */\nexport interface SceneSpace {\n readonly scene: Scene;\n /** The length of the unit of the room, in meters. */\n readonly scale: number;\n /** This function gives the frame of a wall in meters, or `undefined` when the room does not have the wall. */\n readonly wall: (id: string) => WallFrame | undefined;\n /** This function gives a placed object of the scene, or `undefined` when the scene does not have it. */\n readonly object: (id: string) => PlacedObject | undefined;\n /** This function gives the transform of a placed object in meters, or `undefined` when the object has no place. */\n readonly transform: (id: string) => Transform3 | undefined;\n /** This function gives the position of an anchor, or `undefined` when the anchor has no position. `checkAnchor` tells the reason. */\n readonly frame: (anchor: Anchor) => AnchorFrame | undefined;\n}\n\nconst UP: Point3 = { x: 0, y: 0, z: 1 };\nconst DOWN: Point3 = { x: 0, y: 0, z: -1 };\n\n/** This function tells if each value of a point is a length in the range of the model. */\nfunction inRange(point: Point3): boolean {\n return Number.isFinite(point.x) && Number.isFinite(point.y) && Number.isFinite(point.z) && lengthsInRange(point.x, point.y, point.z);\n}\n\n/** This function gives the space of a scene. The transforms of the objects are calculated one time, at the first use. */\nexport function sceneSpace(scene: Scene): SceneSpace {\n const scale = metersPer(scene.room.unit);\n const walls = new Map(wallFrames(scene.room).map((frame) => [frame.id, frame] as const));\n const objects = new Map((scene.objects ?? []).map((object) => [object.id, object] as const));\n let transforms: ReadonlyMap<string, Transform3> | undefined;\n const transform = (id: string): Transform3 | undefined => {\n transforms ??= objectTransforms(scene);\n return transforms.get(id);\n };\n const frame = (anchor: Anchor): AnchorFrame | undefined => {\n let found: AnchorFrame | undefined;\n if (anchor.on === \"wall\") {\n const wall = walls.get(anchor.wall);\n if (wall === undefined) return undefined;\n const point = wallPoint(wall, anchor.offset * scale, anchor.face === \"left\" ? wall.leftOffset : wall.rightOffset);\n const sign = anchor.face === \"left\" ? 1 : -1;\n found = { at: { x: point.x, y: point.y, z: anchor.height * scale }, out: { x: wall.left.x * sign, y: wall.left.y * sign, z: 0 } };\n } else if (anchor.on === \"floor\") {\n found = { at: { x: anchor.at[0] * scale, y: anchor.at[1] * scale, z: 0 }, out: UP };\n } else if (anchor.on === \"ceiling\") {\n found = { at: { x: anchor.at[0] * scale, y: anchor.at[1] * scale, z: scene.room.height * scale }, out: DOWN };\n } else {\n const object = objects.get(anchor.object);\n const place = transform(anchor.object);\n if (object === undefined || place === undefined) return undefined;\n const [x, y, z] = anchor.at ?? [0, 0, object.size[2]];\n const [ox, oy, oz] = anchor.out ?? [0, 0, 1];\n const out = { x: ox, y: oy, z: oz };\n const size = length3(out);\n if (!(size > 0) || !Number.isFinite(size)) return undefined;\n found = { at: transformPoint3(place, { x: x * scale, y: y * scale, z: z * scale }), out: rotatePoint3(place.rotation, scalePoint3(out, 1 / size)) };\n }\n return inRange(found.at) && inRange(found.out) ? found : undefined;\n };\n return { scene, scale, wall: (id) => walls.get(id), object: (id) => objects.get(id), transform, frame };\n}\n","import { sceneSpace, type Anchor, type SceneSpace } from \"./anchors.ts\";\nimport { checkAnchor, type FindingLevel } from \"./check.ts\";\nimport { isLayerName, type Scene } from \"./room.ts\";\n\n// The layers of a scene: the records of the add-ons. The core keeps each layer, and it does not read one.\n// An add-on reads its layer, gives the anchors of its records, and examines the meaning of its records.\n// The core examines the anchors. Thus each add-on composes on the core, and the add-ons do not know each other.\n\n/** The result of the read of a layer: the layer, or the faults of its form. */\nexport type LayerParse<Layer> = { readonly ok: true; readonly layer: Layer } | { readonly ok: false; readonly errors: readonly string[] };\n\n/** A fault that an add-on finds in its layer. */\nexport interface AddOnFault {\n readonly level: FindingLevel;\n /** The code of the fault. The add-on gives its own codes. */\n readonly code: string;\n /** The `id` of the record with the fault. For the layer, it is empty. */\n readonly at: string;\n /** The fault in plain words, with the values. */\n readonly message: string;\n /** The `id` of the second record of the fault. A fault of one record has none. */\n readonly other?: string | undefined;\n}\n\n/**\n * An add-on: one topic on the core, for example electrical, plumbing or light.\n * A host gives a list of add-ons to `checkLayers`. The core knows only this type.\n */\nexport interface AddOn<Layer> {\n /** The name of the format of the layer, for example `electrical/1`. It is the key of the layer in `Scene.layers`. */\n readonly schema: string;\n /** This function reads the JSON of a layer. */\n parse(value: unknown): LayerParse<Layer>;\n /**\n * This function gives the anchors of the records of a layer, by a key.\n * The key is the `id` of a record, or the `id` and a position for a record with many anchors.\n */\n anchors(layer: Layer): ReadonlyMap<string, Anchor>;\n /** This function gives the layer with new anchors, by the keys of `anchors`. The core uses it when it moves the records of a room. */\n withAnchors(layer: Layer, anchors: ReadonlyMap<string, Anchor>): Layer;\n /** This function gives the faults of the meaning of a layer. The core examines the anchors, so this function does not. */\n check(layer: Layer, space: SceneSpace): readonly AddOnFault[];\n}\n\n/** These are the codes of the faults of a layer that the core finds. */\nexport const LAYER_CODES: readonly [\"layer-name\", \"layer-unknown\", \"layer-form\"] = [\"layer-name\", \"layer-unknown\", \"layer-form\"];\n\n/** A finding of a layer: a fault of its form, of an anchor or of the meaning of its records. */\nexport interface LayerFinding {\n readonly level: FindingLevel;\n /** A code of `LAYER_CODES` or `ANCHOR_CODES`, or a code of the add-on. */\n readonly code: string;\n /** The key of the layer in `Scene.layers`. */\n readonly layer: string;\n /** The key of the anchor, or the `id` of the record with the fault. For the layer, it is empty. */\n readonly at: string;\n /** The fault in plain words, with the values. */\n readonly message: string;\n /** The `id` of the second record of the fault. A fault of one record has none. */\n readonly other?: string | undefined;\n}\n\n/** This function compares two texts by their code points, so the order does not change with the language of a computer. */\nfunction compareText(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n\n/** This function gives the add-on of each schema name. The first add-on of a name is used. */\nfunction addOnsByName(addOns: readonly AddOn<unknown>[]): ReadonlyMap<string, AddOn<unknown>> {\n const byName = new Map<string, AddOn<unknown>>();\n for (const addOn of addOns) if (!byName.has(addOn.schema)) byName.set(addOn.schema, addOn);\n return byName;\n}\n\n/** This function reads the layer of an add-on in a scene. It gives `undefined` when the scene has no layer of the add-on. */\nexport function readLayer<Layer>(scene: Scene, addOn: AddOn<Layer>): LayerParse<Layer> | undefined {\n const layers = scene.layers ?? {};\n return Object.hasOwn(layers, addOn.schema) ? addOn.parse(layers[addOn.schema]) : undefined;\n}\n\n/**\n * This function gives the findings of the layers of a scene, with a list of add-ons.\n * Each layer gets the faults of its form, of each anchor and of the meaning of its records. A layer of no add-on of the list gets a warning.\n * The findings are in the order of the layer keys, then of the record keys. Thus equal inputs give equal findings.\n *\n * The name of the record of a finding is `recordName(finding.layer, finding.at)`, so a finding selects its mark.\n * `checkScene` examines the core, and this function examines the layers.\n */\nexport function checkLayers(scene: Scene, addOns: readonly AddOn<unknown>[]): readonly LayerFinding[] {\n const byName = addOnsByName(addOns);\n const layers = scene.layers ?? {};\n const findings: LayerFinding[] = [];\n let space: SceneSpace | undefined;\n for (const name of Object.keys(layers).sort(compareText)) {\n if (!isLayerName(name)) {\n findings.push({ level: \"error\", code: \"layer-name\", layer: name, at: \"\", message: `The layer \"${name}\" has a name that is not a word, a slash and a version, for example \"electrical/1\".` });\n continue;\n }\n const addOn = byName.get(name);\n if (addOn === undefined) {\n findings.push({ level: \"warning\", code: \"layer-unknown\", layer: name, at: \"\", message: `The scene has the layer \"${name}\", and no add-on of the check reads it. The scene keeps the layer.` });\n continue;\n }\n const read = addOn.parse(layers[name]);\n if (!read.ok) {\n for (const message of read.errors) findings.push({ level: \"error\", code: \"layer-form\", layer: name, at: \"\", message });\n continue;\n }\n space ??= sceneSpace(scene);\n const own: LayerFinding[] = [];\n for (const [key, anchor] of addOn.anchors(read.layer)) {\n for (const fault of checkAnchor(anchor, space, `The anchor \"${key}\" of the layer \"${name}\"`)) own.push({ ...fault, layer: name, at: key });\n }\n for (const fault of addOn.check(read.layer, space)) own.push({ ...fault, layer: name });\n // The sort is stable, so the faults of one record keep their order.\n own.sort((a, b) => compareText(a.at, b.at));\n findings.push(...own);\n }\n return findings;\n}\n"],"mappings":";;;;;;;;;AAuBA,SAAgB,UAAU,OAAyB;CACjD,MAAM,EAAE,IAAI,MAAM,QAAQ,UAAU;CACpC,IAAI,MAAM,SAAS,SAAS,OAAO;EAAE,OAAO;EAAI;EAAM;EAAQ,MAAM,MAAM;EAAM,QAAQ,MAAM;EAAG,KAAK,MAAM,IAAI,MAAM;CAAE;CACxH,MAAM,EAAE,KAAK,cAAc;CAC3B,MAAM,OAAO;EACX;GAAE,GAAG,IAAI;GAAG,GAAG,IAAI;G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CAAC,KAAK,WAAW,GAAG;EACxD,IAAI,CAAC,YAAY,IAAI,GAAG;GACtB,SAAS,KAAK;IAAE,OAAO;IAAS,MAAM;IAAc,OAAO;IAAM,IAAI;IAAI,SAAS,cAAc,KAAK;GAAqF,CAAC;GAC3L;EACF;EACA,MAAM,QAAQ,OAAO,IAAI,IAAI;EAC7B,IAAI,UAAU,KAAA,GAAW;GACvB,SAAS,KAAK;IAAE,OAAO;IAAW,MAAM;IAAiB,OAAO;IAAM,IAAI;IAAI,SAAS,4BAA4B,KAAK;GAAoE,CAAC;GAC7L;EACF;EACA,MAAM,OAAO,MAAM,MAAM,OAAO,KAAK;EACrC,IAAI,CAAC,KAAK,IAAI;GACZ,KAAK,MAAM,WAAW,KAAK,QAAQ,SAAS,KAAK;IAAE,OAAO;IAAS,MAAM;IAAc,OAAO;IAAM,IAAI;IAAI;GAAQ,CAAC;GACrH;EACF;EACA,UAAU,WAAW,KAAK;EAC1B,MAAM,MAAsB,CAAC;EAC7B,KAAK,MAAM,CAAC,KAAK,WAAW,MAAM,QAAQ,KAAK,KAAK,GAClD,KAAK,MAAM,SAAS,YAAY,QAAQ,OAAO,eAAe,IAAI,kBAAkB,KAAK,EAAE,GAAG,IAAI,KAAK;GAAE,GAAG;GAAO,OAAO;GAAM,IAAI;EAAI,CAAC;EAE3I,KAAK,MAAM,SAAS,MAAM,MAAM,KAAK,OAAO,KAAK,GAAG,IAAI,KAAK;GAAE,GAAG;GAAO,OAAO;EAAK,CAAC;EAEtF,IAAI,MAAM,GAAG,MAAM,YAAY,EAAE,IAAI,EAAE,EAAE,CAAC;EAC1C,SAAS,KAAK,GAAG,GAAG;CACtB;CACA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/plan.ts","../src/check.ts","../src/anchors.ts","../src/layers.ts"],"sourcesContent":["import { transformPoint3, type Ring } from \"@mark1russell7/layout-contract\";\nimport type { Scene } from \"./room.ts\";\nimport { sceneSolids, type Solid, type SolidKind, type SolidOptions } from \"./solids.ts\";\n\n/** The outline of one solid in the plan of a room: the solid as a camera above the room sees it. */\nexport interface PlanShape {\n /** The `id` of the solid. */\n readonly solid: string;\n readonly kind: SolidKind;\n /** The `id` of the record that the solid comes from. */\n readonly source: string;\n /** The outline in the plan, in meters. */\n readonly ring: Ring;\n /** The height of the bottom of the solid above the floor, in meters. */\n readonly bottom: number;\n /** The height of the top of the solid above the floor, in meters. */\n readonly top: number;\n}\n\n/**\n * This function gives the outline of a solid in the plan.\n * Each box of a model stands on its bottom face, so the outline of a box is that face.\n */\nexport function planShape(solid: Solid): PlanShape {\n const { id, kind, source, shape } = solid;\n if (shape.kind === \"prism\") return { solid: id, kind, source, ring: shape.ring, bottom: shape.z, top: shape.z + shape.d };\n const { box, transform } = shape;\n const face = [\n { x: box.x, y: box.y, z: box.z },\n { x: box.x + box.w, y: box.y, z: box.z },\n { x: box.x + box.w, y: box.y + box.h, z: box.z },\n { x: box.x, y: box.y + box.h, z: box.z },\n ].map((corner) => transformPoint3(transform, corner));\n const bottom = face[0]!.z;\n const top = transformPoint3(transform, { x: box.x, y: box.y, z: box.z + box.d }).z;\n return { solid: id, kind, source, ring: face.map((corner) => [corner.x, corner.y] as const), bottom: Math.min(bottom, top), top: Math.max(bottom, top) };\n}\n\n/** The options of a plan. */\nexport interface PlanOptions extends SolidOptions {\n /**\n * The height of the cut of the plan above the floor, in meters. The plan has only the solids with a bottom below the cut.\n * Thus a cut below the top of a door shows the door as a gap in its wall. Without a cut, the plan has each solid.\n */\n readonly cut?: number | undefined;\n}\n\n/**\n * This function gives the plan of a scene: the outline of each solid of its model.\n * The sequence goes from the solid with the lowest top to the solid with the highest top.\n * Thus a drawing in this sequence shows the room as a camera above it sees the room.\n */\nexport function planShapes(scene: Scene, options: PlanOptions = {}): readonly PlanShape[] {\n const cut = options.cut ?? Infinity;\n return sceneSolids(scene, options)\n .map((solid) => planShape(solid))\n .filter((shape) => shape.bottom < cut)\n .map((shape, index) => ({ shape, index }))\n .sort((a, b) => a.shape.top - b.shape.top || a.index - b.index)\n .map(({ shape }) => shape);\n}\n","import { convexOverlap, length3, pointInRing, regionArea, transformPoint3, type Ring, type Transform3 } from \"@mark1russell7/layout-contract\";\nimport type { Anchor, SceneSpace } from \"./anchors.ts\";\nimport { wallFrames, wallHasOutline } from \"./frames.ts\";\nimport { wallFootprints, type JoinOptions } from \"./joins.ts\";\nimport type { PlacedObject, Room, Scene } from \"./room.ts\";\nimport { objectTransforms } from \"./solids.ts\";\nimport { LARGEST_LENGTH, lengthsInRange, metersPer } from \"./units.ts\";\n\n/** These are the levels of a finding. An error is a fault that the model cannot show. A warning is a fault that the model can show. */\nexport const FINDING_LEVELS: readonly [\"error\", \"warning\"] = [\"error\", \"warning\"];\n\n/** A level of a finding. */\nexport type FindingLevel = (typeof FINDING_LEVELS)[number];\n\n/** These are the kinds of the records that a finding can name. */\nexport const RECORD_KINDS: readonly [\"room\", \"wall\", \"opening\", \"floor\", \"outlet\", \"circuit\", \"object\", \"load\"] = [\n \"room\",\n \"wall\",\n \"opening\",\n \"floor\",\n \"outlet\",\n \"circuit\",\n \"object\",\n \"load\",\n];\n\n/** A kind of record. */\nexport type RecordKind = (typeof RECORD_KINDS)[number];\n\n/**\n * This function gives the name of a record: its kind, a colon and its `id`, for example `object:desk`.\n * The kind of a record of a layer is the name of the layer, for example `electrical/1`. A finding, a mark and the selection use this name.\n */\nexport function recordName(kind: string, id: string): string {\n return `${kind}:${id}`;\n}\n\n/** This function gives the kind and the `id` of a record name, or `undefined` for a text with no kind. A kind has no colon, so the first colon ends it. */\nexport function parseRecordName(name: string): { readonly kind: string; readonly id: string } | undefined {\n const colon = name.indexOf(\":\");\n return colon < 1 ? undefined : { kind: name.slice(0, colon), id: name.slice(colon + 1) };\n}\n\n/** These are the codes of the findings. */\nexport const FINDING_CODES: readonly [\n \"number-not-finite\",\n \"number-too-large\",\n \"id-duplicate\",\n \"size-not-positive\",\n \"wall-length\",\n \"wall-short\",\n \"wall-overlap\",\n \"opening-wall\",\n \"opening-range\",\n \"opening-height\",\n \"opening-overlap\",\n \"outlet-wall\",\n \"outlet-circuit\",\n \"outlet-range\",\n \"outlet-in-opening\",\n \"floor-ring\",\n \"circuit-limit\",\n \"object-parent\",\n \"object-cycle\",\n \"object-outlet\",\n \"object-outside\",\n \"object-overlap\",\n \"object-in-wall\",\n \"load-circuit\",\n \"load-watts\",\n] = [\n \"number-not-finite\",\n \"number-too-large\",\n \"id-duplicate\",\n \"size-not-positive\",\n \"wall-length\",\n \"wall-short\",\n \"wall-overlap\",\n \"opening-wall\",\n \"opening-range\",\n \"opening-height\",\n \"opening-overlap\",\n \"outlet-wall\",\n \"outlet-circuit\",\n \"outlet-range\",\n \"outlet-in-opening\",\n \"floor-ring\",\n \"circuit-limit\",\n \"object-parent\",\n \"object-cycle\",\n \"object-outlet\",\n \"object-outside\",\n \"object-overlap\",\n \"object-in-wall\",\n \"load-circuit\",\n \"load-watts\",\n];\n\n/** A code of a finding. */\nexport type FindingCode = (typeof FINDING_CODES)[number];\n\n/** A finding: one fault of a room record or a scene record. */\nexport interface Finding {\n readonly level: FindingLevel;\n readonly code: FindingCode;\n /** The kind of the record with the fault. */\n readonly record: RecordKind;\n /** The `id` of the record with the fault. For a load, it is the `id` of the circuit. For the room record, it is empty. */\n readonly at: string;\n /** The fault in plain words, with the values. */\n readonly message: string;\n /**\n * The `id` of the second record of the fault. It is the other opening or the other object of an overlap, or the opening that an outlet is in.\n * It is also the wall that an object overlaps, or the parent or the outlet that an object names. A fault of one record has none.\n */\n readonly other?: string | undefined;\n}\n\n/** The options of the checks. Give the options that the model gets. */\nexport interface CheckOptions {\n /** The options of the corners of the walls. */\n readonly joins?: JoinOptions | undefined;\n}\n\n/** A length in meters at this value or less is 0 for the checks: a size must be above it. */\nconst SMALL = 1e-6;\n\n/** This function gives a number with 3 decimals at most. */\nfunction show(value: number): string {\n return String(Math.round(value * 1000) / 1000);\n}\n\n/** This function tells if a value is a number that is not finite, or if it holds such a number. */\nfunction holdsBadNumber(value: unknown): boolean {\n if (typeof value === \"number\") return !Number.isFinite(value);\n if (Array.isArray(value)) return value.some((item) => holdsBadNumber(item));\n if (typeof value === \"object\" && value !== null) return Object.values(value).some((item) => holdsBadNumber(item));\n return false;\n}\n\n/** This function tells if a value is a finite number with a size above a limit, or if it holds such a number. */\nfunction holdsLargeNumber(value: unknown, limit: number): boolean {\n if (typeof value === \"number\") return Number.isFinite(value) && Math.abs(value) > limit;\n if (Array.isArray(value)) return value.some((item) => holdsLargeNumber(item, limit));\n if (typeof value === \"object\" && value !== null) return Object.values(value).some((item) => holdsLargeNumber(item, limit));\n return false;\n}\n\n/** This function gives each value that a list has two or more times. */\nfunction repeated(ids: readonly string[]): readonly string[] {\n const seen = new Set<string>();\n const twice = new Set<string>();\n for (const id of ids) {\n if (seen.has(id)) twice.add(id);\n seen.add(id);\n }\n return [...twice];\n}\n\n/**\n * This function gives each fault of a room record. A room with no finding of the level `error` gives a full model.\n *\n * The function examines the meaning of the record: for example, an opening must be in its wall. The schema examines the form of the record.\n */\nexport function checkRoom(room: Room, options: CheckOptions = {}): readonly Finding[] {\n const findings: Finding[] = [];\n const error = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"error\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const warning = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"warning\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const scale = metersPer(room.unit);\n /** The largest length of the model, in the unit of the room. */\n const largest = LARGEST_LENGTH / scale;\n /** This function tells if a size of the record is 0 for the checks. */\n const none = (size: number): boolean => !(size * scale > SMALL);\n const openings = room.openings ?? [];\n const outlets = room.outlets ?? [];\n const circuits = room.circuits ?? [];\n const floors = room.floors ?? [];\n\n if (holdsBadNumber([room.height, room.wallThickness])) error(\"number-not-finite\", \"room\", \"\", \"The height or the wall thickness of the room is not a finite number.\");\n if (holdsLargeNumber([room.height, room.wallThickness], largest)) error(\"number-too-large\", \"room\", \"\", `The height or the wall thickness of the room is above 1 000 km, the largest length of the model.`);\n const lists: readonly (readonly [RecordKind, readonly { readonly id: string }[]])[] = [\n [\"wall\", room.walls],\n [\"opening\", openings],\n [\"floor\", floors],\n [\"outlet\", outlets],\n [\"circuit\", circuits],\n ];\n for (const [record, list] of lists) {\n for (const item of list) {\n if (holdsBadNumber(item)) error(\"number-not-finite\", record, item.id, `A number of the ${record} \"${item.id}\" is not finite.`);\n // The limit of a circuit is a power, not a length.\n if (record !== \"circuit\" && holdsLargeNumber(item, largest)) error(\"number-too-large\", record, item.id, `A length of the ${record} \"${item.id}\" is above 1 000 km, the largest length of the model.`);\n }\n for (const id of repeated(list.map((item) => item.id))) error(\"id-duplicate\", record, id, `Two or more records of the kind ${record} have the id \"${id}\".`);\n }\n\n if (none(room.height)) error(\"size-not-positive\", \"room\", \"\", `The height of the room is ${show(room.height)}. It must be above 0.`);\n if (none(room.wallThickness)) error(\"size-not-positive\", \"room\", \"\", `The wall thickness of the room is ${show(room.wallThickness)}. It must be above 0.`);\n\n const frames = wallFrames(room);\n const footprints = wallFootprints(frames, options.joins);\n frames.forEach((frame, index) => {\n const wall = room.walls[index]!;\n if (wall.thickness !== undefined && none(wall.thickness)) error(\"size-not-positive\", \"wall\", wall.id, `The thickness of the wall \"${wall.id}\" is ${show(wall.thickness)}. It must be above 0.`);\n if (wall.height !== undefined && none(wall.height)) error(\"size-not-positive\", \"wall\", wall.id, `The height of the wall \"${wall.id}\" is ${show(wall.height)}. It must be above 0.`);\n const [clearFrom, clearTo] = footprints[index]!.clear;\n if (!(frame.length > SMALL)) error(\"wall-length\", \"wall\", wall.id, `The wall \"${wall.id}\" has the length 0: its two ends are one point.`);\n else if (wallHasOutline(frame) && !(clearTo - clearFrom > SMALL)) warning(\"wall-short\", \"wall\", wall.id, `The wall \"${wall.id}\" is too short for the corners at its ends: no part of it has its full thickness.`);\n });\n for (let i = 0; i < footprints.length; i++) {\n for (let j = i + 1; j < footprints.length; j++) {\n const a = footprints[i]!;\n const b = footprints[j]!;\n if (a.ring.length < 3 || b.ring.length < 3 || !(convexOverlap(a.ring, b.ring) > SMALL)) continue;\n warning(\"wall-overlap\", \"wall\", a.wall, `The walls \"${a.wall}\" and \"${b.wall}\" overlap. Walls connect only at their ends: divide a wall at the point where a different wall crosses it.`);\n }\n }\n\n const frameOf = new Map(frames.map((frame, index) => [frame.id, { frame, footprint: footprints[index]! }] as const));\n const holes = new Map<string, { id: string; from: number; to: number; sill: number; top: number }[]>();\n for (const opening of openings) {\n const found = frameOf.get(opening.wall);\n if (found === undefined) {\n error(\"opening-wall\", \"opening\", opening.id, `The opening \"${opening.id}\" is on the wall \"${opening.wall}\", which the room does not have.`);\n continue;\n }\n if (none(opening.width)) error(\"size-not-positive\", \"opening\", opening.id, `The width of the opening \"${opening.id}\" is ${show(opening.width)}. It must be above 0.`);\n if (none(opening.height)) error(\"size-not-positive\", \"opening\", opening.id, `The height of the opening \"${opening.id}\" is ${show(opening.height)}. It must be above 0.`);\n if (none(opening.width) || none(opening.height)) continue;\n const from = opening.offset * scale;\n const to = (opening.offset + opening.width) * scale;\n const sill = (opening.sill ?? 0) * scale;\n const top = sill + opening.height * scale;\n const [clearFrom, clearTo] = found.footprint.clear;\n if (from < clearFrom - SMALL || to > clearTo + SMALL) {\n error(\n \"opening-range\",\n \"opening\",\n opening.id,\n `The opening \"${opening.id}\" is from ${show(opening.offset)} to ${show(opening.offset + opening.width)} along the wall \"${opening.wall}\". The straight part of that wall is from ${show(clearFrom / scale)} to ${show(clearTo / scale)}.`,\n );\n }\n if (sill < 0 || top > found.frame.height + SMALL) {\n error(\n \"opening-height\",\n \"opening\",\n opening.id,\n `The opening \"${opening.id}\" is from the height ${show(sill / scale)} to ${show(top / scale)}. The wall \"${opening.wall}\" is from 0 to ${show(found.frame.height / scale)}.`,\n );\n }\n const list = holes.get(opening.wall) ?? [];\n list.push({ id: opening.id, from, to, sill, top });\n holes.set(opening.wall, list);\n }\n for (const [wall, list] of holes) {\n list.sort((a, b) => a.from - b.from);\n for (let i = 1; i < list.length; i++) {\n const before = list[i - 1]!;\n const hole = list[i]!;\n if (hole.from < before.to - SMALL) error(\"opening-overlap\", \"opening\", hole.id, `The openings \"${before.id}\" and \"${hole.id}\" of the wall \"${wall}\" overlap.`, before.id);\n }\n }\n\n const circuitIds = new Set(circuits.map((circuit) => circuit.id));\n for (const outlet of outlets) {\n if (outlet.circuit !== undefined && !circuitIds.has(outlet.circuit)) error(\"outlet-circuit\", \"outlet\", outlet.id, `The outlet \"${outlet.id}\" is on the circuit \"${outlet.circuit}\", which the room does not have.`);\n const found = frameOf.get(outlet.wall);\n if (found === undefined) {\n error(\"outlet-wall\", \"outlet\", outlet.id, `The outlet \"${outlet.id}\" is on the wall \"${outlet.wall}\", which the room does not have.`);\n continue;\n }\n const along = outlet.offset * scale;\n const height = outlet.height * scale;\n if (!(along >= 0 && along <= found.frame.length + SMALL && height >= 0 && height <= found.frame.height + SMALL)) {\n error(\n \"outlet-range\",\n \"outlet\",\n outlet.id,\n `The outlet \"${outlet.id}\" is at ${show(outlet.offset)} along the wall \"${outlet.wall}\" and at the height ${show(outlet.height)}. The wall has the length ${show(found.frame.length / scale)} and the height ${show(found.frame.height / scale)}.`,\n );\n continue;\n }\n const hole = (holes.get(outlet.wall) ?? []).find((item) => along > item.from && along < item.to && height > item.sill && height < item.top);\n if (hole !== undefined) warning(\"outlet-in-opening\", \"outlet\", outlet.id, `The outlet \"${outlet.id}\" is in the opening \"${hole.id}\" of the wall \"${outlet.wall}\".`, hole.id);\n }\n\n for (const floor of floors) {\n if (floor.ring.length < 3 || !(regionArea({ kind: \"polygon\", points: floor.ring }) * scale * scale > SMALL * SMALL)) {\n error(\"floor-ring\", \"floor\", floor.id, `The floor \"${floor.id}\" has no area. Its ring must have 3 or more corners that are not on one line.`);\n }\n }\n for (const circuit of circuits) {\n if (!(circuit.limit > 0)) error(\"circuit-limit\", \"circuit\", circuit.id, `The limit of the circuit \"${circuit.id}\" is ${show(circuit.limit)} W. It must be above 0.`);\n if (circuit.breaker !== undefined && !(circuit.breaker > 0)) error(\"circuit-limit\", \"circuit\", circuit.id, `The breaker of the circuit \"${circuit.id}\" is ${show(circuit.breaker)} A. It must be above 0.`);\n if (circuit.voltage !== undefined && !(circuit.voltage > 0)) error(\"circuit-limit\", \"circuit\", circuit.id, `The voltage of the circuit \"${circuit.id}\" is ${show(circuit.voltage)} V. It must be above 0.`);\n }\n return findings;\n}\n\n/** The outline in the plan and the range of heights of a placed object, in meters. */\ninterface Extent {\n readonly object: PlacedObject;\n readonly ring: Ring;\n readonly z: number;\n readonly top: number;\n}\n\n/** This function gives the extent of a placed object from its transform. The turn of each object is about the vertical axis, so the outline is a rectangle. */\nfunction extentOf(object: PlacedObject, transform: Transform3, scale: number): Extent {\n const w = (object.size[0] * scale) / 2;\n const h = (object.size[1] * scale) / 2;\n const corners: readonly (readonly [number, number])[] = [\n [0 - w, 0 - h],\n [w, 0 - h],\n [w, h],\n [0 - w, h],\n ];\n const ring = corners.map(([x, y]) => {\n const point = transformPoint3(transform, { x, y, z: 0 });\n return [point.x, point.y] as const;\n });\n return { object, ring, z: transform.position.z, top: transform.position.z + object.size[2] * scale };\n}\n\n/**\n * This function gives each fault of a scene record: the faults of its room, then the faults of its placed objects and its loads.\n * A scene with no finding of the level `error` gives a full model.\n */\nexport function checkScene(scene: Scene, options: CheckOptions = {}): readonly Finding[] {\n const findings: Finding[] = [...checkRoom(scene.room, options)];\n const error = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"error\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const warning = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"warning\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const room = scene.room;\n const scale = metersPer(room.unit);\n const objects = scene.objects ?? [];\n const byId = new Map(objects.map((object) => [object.id, object] as const));\n const outletIds = new Set((room.outlets ?? []).map((outlet) => outlet.id));\n const circuitIds = new Set((room.circuits ?? []).map((circuit) => circuit.id));\n /** This function tells if each size of an object is above 0 for the checks. */\n const hasSize = (object: PlacedObject): boolean => object.size.every((size) => size * scale > SMALL);\n\n for (const id of repeated(objects.map((object) => object.id))) error(\"id-duplicate\", \"object\", id, `Two or more records of the kind object have the id \"${id}\".`);\n\n /** The objects that hold an object, from its parent up. A loop of parents gives `undefined`. */\n const holders = (object: PlacedObject): ReadonlySet<string> | undefined => {\n const seen = new Set<string>([object.id]);\n const above = new Set<string>();\n let parent = object.parent === undefined ? undefined : byId.get(object.parent);\n while (parent !== undefined) {\n if (seen.has(parent.id)) return undefined;\n seen.add(parent.id);\n above.add(parent.id);\n parent = parent.parent === undefined ? undefined : byId.get(parent.parent);\n }\n return above;\n };\n\n for (const object of objects) {\n if (holdsBadNumber(object)) error(\"number-not-finite\", \"object\", object.id, `A number of the object \"${object.id}\" is not finite.`);\n // The turn of an object is an angle, so it has no such limit.\n if (holdsLargeNumber([object.size, object.at, object.lift], LARGEST_LENGTH / scale)) error(\"number-too-large\", \"object\", object.id, `A length of the object \"${object.id}\" is above 1 000 km, the largest length of the model.`);\n if (!hasSize(object)) error(\"size-not-positive\", \"object\", object.id, `The size of the object \"${object.id}\" is ${object.size.map(show).join(\" by \")}. Each number must be above 0.`);\n if (object.parent !== undefined && !byId.has(object.parent)) error(\"object-parent\", \"object\", object.id, `The object \"${object.id}\" is on the object \"${object.parent}\", which the scene does not have.`, object.parent);\n else if (holders(object) === undefined) error(\"object-cycle\", \"object\", object.id, `The parents of the object \"${object.id}\" make a loop.`);\n if (object.outlet !== undefined && !outletIds.has(object.outlet)) error(\"object-outlet\", \"object\", object.id, `The object \"${object.id}\" uses the outlet \"${object.outlet}\", which the room does not have.`, object.outlet);\n }\n\n const transforms = objectTransforms(scene);\n const extents: Extent[] = [];\n for (const object of objects) {\n const transform = transforms.get(object.id);\n if (transform !== undefined && hasSize(object)) extents.push(extentOf(object, transform, scale));\n }\n\n const floors = (room.floors ?? []).filter((floor) => floor.ring.length >= 3).map((floor) => floor.ring.map(([x, y]) => [x * scale, y * scale] as const));\n const frames = wallFrames(room);\n const footprints = wallFootprints(frames, options.joins);\n for (const extent of extents) {\n const { object } = extent;\n const transform = transforms.get(object.id)!;\n if (object.parent === undefined && floors.length > 0 && !floors.some((ring) => pointInRing(transform.position.x, transform.position.y, ring))) {\n warning(\"object-outside\", \"object\", object.id, `The center of the object \"${object.id}\" is not on a floor of the room.`);\n }\n footprints.forEach((footprint, index) => {\n if (footprint.ring.length < 3 || !(extent.z < frames[index]!.height - SMALL) || !(convexOverlap(footprint.ring, extent.ring) > SMALL)) return;\n warning(\"object-in-wall\", \"object\", object.id, `The object \"${object.id}\" overlaps the wall \"${footprint.wall}\".`, footprint.wall);\n });\n }\n for (let i = 0; i < extents.length; i++) {\n for (let j = i + 1; j < extents.length; j++) {\n const a = extents[i]!;\n const b = extents[j]!;\n if (holders(a.object)?.has(b.object.id) === true || holders(b.object)?.has(a.object.id) === true) continue;\n if (!(Math.min(a.top, b.top) - Math.max(a.z, b.z) > SMALL) || !(convexOverlap(a.ring, b.ring) > SMALL)) continue;\n warning(\"object-overlap\", \"object\", a.object.id, `The objects \"${a.object.id}\" and \"${b.object.id}\" overlap.`, b.object.id);\n }\n }\n\n for (const load of scene.loads ?? []) {\n if (!circuitIds.has(load.circuit)) error(\"load-circuit\", \"load\", load.circuit, `A load is on the circuit \"${load.circuit}\", which the room does not have.`);\n if (!(load.watts >= 0 && Number.isFinite(load.watts))) error(\"load-watts\", \"load\", load.circuit, `A load of the circuit \"${load.circuit}\" is ${show(load.watts)} W. It must be a finite number, 0 or more.`);\n }\n return findings;\n}\n\n/** These are the codes of the faults of an anchor. */\nexport const ANCHOR_CODES: readonly [\n \"anchor-not-finite\",\n \"anchor-wall\",\n \"anchor-object\",\n \"anchor-floor\",\n \"anchor-range\",\n \"anchor-direction\",\n \"anchor-in-opening\",\n \"anchor-outside\",\n] = [\"anchor-not-finite\", \"anchor-wall\", \"anchor-object\", \"anchor-floor\", \"anchor-range\", \"anchor-direction\", \"anchor-in-opening\", \"anchor-outside\"];\n\n/** A code of a fault of an anchor. */\nexport type AnchorCode = (typeof ANCHOR_CODES)[number];\n\n/** A fault of an anchor. `checkLayers` gives it the layer and the key of the anchor. */\nexport interface AnchorFault {\n readonly level: FindingLevel;\n readonly code: AnchorCode;\n /** The fault in plain words, with the values. */\n readonly message: string;\n /** The `id` of the second record of the fault: the opening that the anchor is in. A different fault has none. */\n readonly other?: string | undefined;\n}\n\n/**\n * This function gives the faults of an anchor in the space of a scene. `name` starts each message.\n * An error tells that the anchor has no position. A warning tells a fault that the model can show.\n */\nexport function checkAnchor(anchor: Anchor, space: SceneSpace, name: string = \"The anchor\"): readonly AnchorFault[] {\n const error = (code: AnchorCode, message: string): readonly AnchorFault[] => [{ level: \"error\", code, message: `${name} ${message}` }];\n const { scene, scale } = space;\n if (holdsBadNumber(anchor)) return error(\"anchor-not-finite\", \"has a number that is not finite.\");\n if (anchor.on === \"wall\") {\n const wall = space.wall(anchor.wall);\n if (wall === undefined) return error(\"anchor-wall\", `is on the wall \"${anchor.wall}\", which the room does not have.`);\n const along = anchor.offset * scale;\n const height = anchor.height * scale;\n if (!(along >= 0 && along <= wall.length + SMALL && height >= 0 && height <= wall.height + SMALL)) {\n return error(\n \"anchor-range\",\n `is at ${show(anchor.offset)} along the wall \"${anchor.wall}\" and at the height ${show(anchor.height)}. The wall has the length ${show(wall.length / scale)} and the height ${show(wall.height / scale)}.`,\n );\n }\n const hole = (scene.room.openings ?? []).find((opening) => {\n const sill = (opening.sill ?? 0) * scale;\n return opening.wall === anchor.wall && along > opening.offset * scale && along < (opening.offset + opening.width) * scale && height > sill && height < sill + opening.height * scale;\n });\n return hole === undefined ? [] : [{ level: \"warning\", code: \"anchor-in-opening\", message: `${name} is in the opening \"${hole.id}\" of the wall \"${anchor.wall}\".`, other: hole.id }];\n }\n if (anchor.on === \"object\") {\n const object = space.object(anchor.object);\n if (object === undefined) return error(\"anchor-object\", `is on the object \"${anchor.object}\", which the scene does not have.`);\n // An object with no place has a fault of its own, which `checkScene` tells. Here, the anchor tells that it has no position.\n if (space.transform(anchor.object) === undefined) return error(\"anchor-object\", `is on the object \"${anchor.object}\", which has no place in the room.`);\n const small = SMALL / scale;\n if (anchor.at !== undefined) {\n const [x, y, z] = anchor.at;\n const [width, depth, height] = object.size;\n if (!(Math.abs(x) <= width / 2 + small && Math.abs(y) <= depth / 2 + small && z >= -small && z <= height + small)) {\n return error(\"anchor-range\", `is at (${anchor.at.map(show).join(\", \")}) in the frame of the object \"${anchor.object}\". The object has the size ${object.size.map(show).join(\" by \")}.`);\n }\n }\n if (anchor.out !== undefined) {\n const [x, y, z] = anchor.out;\n if (!(length3({ x, y, z }) > 0)) return error(\"anchor-direction\", \"has a direction with the length 0. A direction must have a length above 0.\");\n }\n return [];\n }\n const [x, y] = anchor.at;\n if (!lengthsInRange(x * scale, y * scale)) return error(\"anchor-range\", \"is at a point above 1 000 km, the largest length of the model.\");\n const word = anchor.on === \"floor\" ? \"on\" : \"above\";\n const floors = scene.room.floors ?? [];\n if (anchor.floor !== undefined) {\n const floor = floors.find((item) => item.id === anchor.floor);\n if (floor === undefined) return error(\"anchor-floor\", `is ${word} the floor \"${anchor.floor}\", which the room does not have.`);\n return pointInRing(x, y, floor.ring) ? [] : [{ level: \"warning\", code: \"anchor-outside\", message: `${name} is not ${word} the floor \"${anchor.floor}\".` }];\n }\n if (floors.length === 0 || floors.some((floor) => pointInRing(x, y, floor.ring))) return [];\n return [{ level: \"warning\", code: \"anchor-outside\", message: `${name} is not ${word} a floor of the room.` }];\n}\n","import { length3, rotatePoint3, scalePoint3, transformPoint3, type Point3, type Transform3 } from \"@mark1russell7/layout-contract\";\nimport { wallFrames, wallPoint, type WallFrame } from \"./frames.ts\";\nimport type { PlacedObject, PlanPoint, Scene, WallFace } from \"./room.ts\";\nimport { objectTransforms } from \"./solids.ts\";\nimport { lengthsInRange, metersPer } from \"./units.ts\";\n\n// The anchors of the core: the places where an add-on puts its records. The core gives each anchor its position.\n// An anchor names no topic. An outlet, a tap and a lamp are records of add-ons, and each one is on an anchor.\n\n/** These are the surfaces that an anchor can be on. */\nexport const ANCHOR_SURFACES: readonly [\"wall\", \"floor\", \"ceiling\", \"object\"] = [\"wall\", \"floor\", \"ceiling\", \"object\"];\n\n/** A surface of an anchor. */\nexport type AnchorSurface = (typeof ANCHOR_SURFACES)[number];\n\n/** An anchor on a face of a wall. The lengths are in the unit of the room. */\nexport interface WallAnchor {\n readonly on: \"wall\";\n /** The `id` of the wall. */\n readonly wall: string;\n readonly face: WallFace;\n /** The distance along the line of the wall, from `from` to the anchor. */\n readonly offset: number;\n /** The height of the anchor above the floor. */\n readonly height: number;\n}\n\n/** An anchor on the floor, at a point of the plan. */\nexport interface FloorAnchor {\n readonly on: \"floor\";\n readonly at: PlanPoint;\n /** The `id` of the floor that has the point. Without it, the point is on any floor of the room. */\n readonly floor?: string | undefined;\n}\n\n/** An anchor on the ceiling, above a point of the plan. The ceiling is at the height of the room. */\nexport interface CeilingAnchor {\n readonly on: \"ceiling\";\n readonly at: PlanPoint;\n /** The `id` of the floor below the point. Without it, the point is above any floor of the room. */\n readonly floor?: string | undefined;\n}\n\n/**\n * An anchor on a placed object. The point and the direction are in the frame of the object, before its turn.\n * The origin of that frame is the center of the bottom of the object.\n */\nexport interface ObjectAnchor {\n readonly on: \"object\";\n /** The `id` of the placed object. */\n readonly object: string;\n /** The point in the frame of the object. The default is the center of its top. */\n readonly at?: readonly [number, number, number] | undefined;\n /** The direction out of the surface, in the frame of the object. The default is up: `[0, 0, 1]`. */\n readonly out?: readonly [number, number, number] | undefined;\n}\n\n/** An anchor: a place in the space of the core, for a record of an add-on. */\nexport type Anchor = WallAnchor | FloorAnchor | CeilingAnchor | ObjectAnchor;\n\n/** The position of an anchor in the room, in meters. */\nexport interface AnchorFrame {\n /** The point of the anchor. */\n readonly at: Point3;\n /** The unit vector out of the surface, into the space of the room. */\n readonly out: Point3;\n}\n\n/**\n * The space of a scene, for the add-ons. It reads each wall, object and anchor of the scene.\n * Make it once with `sceneSpace`, and give it to each add-on.\n */\nexport interface SceneSpace {\n readonly scene: Scene;\n /** The length of the unit of the room, in meters. */\n readonly scale: number;\n /** This function gives the frame of a wall in meters, or `undefined` when the room does not have the wall. */\n readonly wall: (id: string) => WallFrame | undefined;\n /** This function gives a placed object of the scene, or `undefined` when the scene does not have it. */\n readonly object: (id: string) => PlacedObject | undefined;\n /** This function gives the transform of a placed object in meters, or `undefined` when the object has no place. */\n readonly transform: (id: string) => Transform3 | undefined;\n /** This function gives the position of an anchor, or `undefined` when the anchor has no position. `checkAnchor` tells the reason. */\n readonly frame: (anchor: Anchor) => AnchorFrame | undefined;\n}\n\nconst UP: Point3 = { x: 0, y: 0, z: 1 };\nconst DOWN: Point3 = { x: 0, y: 0, z: -1 };\n\n/** This function tells if each value of a point is a length in the range of the model. */\nfunction inRange(point: Point3): boolean {\n return Number.isFinite(point.x) && Number.isFinite(point.y) && Number.isFinite(point.z) && lengthsInRange(point.x, point.y, point.z);\n}\n\n/** This function gives the space of a scene. The transforms of the objects are calculated one time, at the first use. */\nexport function sceneSpace(scene: Scene): SceneSpace {\n const scale = metersPer(scene.room.unit);\n const walls = new Map(wallFrames(scene.room).map((frame) => [frame.id, frame] as const));\n const objects = new Map((scene.objects ?? []).map((object) => [object.id, object] as const));\n let transforms: ReadonlyMap<string, Transform3> | undefined;\n const transform = (id: string): Transform3 | undefined => {\n transforms ??= objectTransforms(scene);\n return transforms.get(id);\n };\n const frame = (anchor: Anchor): AnchorFrame | undefined => {\n let found: AnchorFrame | undefined;\n if (anchor.on === \"wall\") {\n const wall = walls.get(anchor.wall);\n if (wall === undefined) return undefined;\n const point = wallPoint(wall, anchor.offset * scale, anchor.face === \"left\" ? wall.leftOffset : wall.rightOffset);\n const sign = anchor.face === \"left\" ? 1 : -1;\n found = { at: { x: point.x, y: point.y, z: anchor.height * scale }, out: { x: wall.left.x * sign, y: wall.left.y * sign, z: 0 } };\n } else if (anchor.on === \"floor\") {\n found = { at: { x: anchor.at[0] * scale, y: anchor.at[1] * scale, z: 0 }, out: UP };\n } else if (anchor.on === \"ceiling\") {\n found = { at: { x: anchor.at[0] * scale, y: anchor.at[1] * scale, z: scene.room.height * scale }, out: DOWN };\n } else {\n const object = objects.get(anchor.object);\n const place = transform(anchor.object);\n if (object === undefined || place === undefined) return undefined;\n const [x, y, z] = anchor.at ?? [0, 0, object.size[2]];\n const [ox, oy, oz] = anchor.out ?? [0, 0, 1];\n const out = { x: ox, y: oy, z: oz };\n const size = length3(out);\n if (!(size > 0) || !Number.isFinite(size)) return undefined;\n found = { at: transformPoint3(place, { x: x * scale, y: y * scale, z: z * scale }), out: rotatePoint3(place.rotation, scalePoint3(out, 1 / size)) };\n }\n return inRange(found.at) && inRange(found.out) ? found : undefined;\n };\n return { scene, scale, wall: (id) => walls.get(id), object: (id) => objects.get(id), transform, frame };\n}\n","import { sceneSpace, type Anchor, type SceneSpace } from \"./anchors.ts\";\nimport { checkAnchor, type FindingLevel } from \"./check.ts\";\nimport { isLayerName, type Scene } from \"./room.ts\";\n\n// The layers of a scene: the records of the add-ons. The core keeps each layer, and it does not read one.\n// An add-on reads its layer, gives the anchors of its records, and examines the meaning of its records.\n// The core examines the anchors. Thus each add-on composes on the core, and the add-ons do not know each other.\n\n/** The result of the read of a layer: the layer, or the faults of its form. */\nexport type LayerParse<Layer> = { readonly ok: true; readonly layer: Layer } | { readonly ok: false; readonly errors: readonly string[] };\n\n/** A fault that an add-on finds in its layer. */\nexport interface AddOnFault {\n readonly level: FindingLevel;\n /** The code of the fault. The add-on gives its own codes. */\n readonly code: string;\n /** The `id` of the record with the fault. For the layer, it is empty. */\n readonly at: string;\n /** The fault in plain words, with the values. */\n readonly message: string;\n /** The `id` of the second record of the fault. A fault of one record has none. */\n readonly other?: string | undefined;\n}\n\n/**\n * An add-on: one topic on the core, for example electrical, plumbing or light.\n * A host gives a list of add-ons to `checkLayers`. The core knows only this type.\n */\nexport interface AddOn<Layer> {\n /** The name of the format of the layer, for example `electrical/1`. It is the key of the layer in `Scene.layers`. */\n readonly schema: string;\n /** This function reads the JSON of a layer. */\n parse(value: unknown): LayerParse<Layer>;\n /**\n * This function gives the anchors of the records of a layer, by a key.\n * The key is the `id` of a record, or the `id` and a position for a record with many anchors.\n */\n anchors(layer: Layer): ReadonlyMap<string, Anchor>;\n /** This function gives the layer with new anchors, by the keys of `anchors`. The core uses it when it moves the records of a room. */\n withAnchors(layer: Layer, anchors: ReadonlyMap<string, Anchor>): Layer;\n /** This function gives the faults of the meaning of a layer. The core examines the anchors, so this function does not. */\n check(layer: Layer, space: SceneSpace): readonly AddOnFault[];\n}\n\n/** These are the codes of the faults of a layer that the core finds. */\nexport const LAYER_CODES: readonly [\"layer-name\", \"layer-unknown\", \"layer-form\"] = [\"layer-name\", \"layer-unknown\", \"layer-form\"];\n\n/** A finding of a layer: a fault of its form, of an anchor or of the meaning of its records. */\nexport interface LayerFinding {\n readonly level: FindingLevel;\n /** A code of `LAYER_CODES` or `ANCHOR_CODES`, or a code of the add-on. */\n readonly code: string;\n /** The key of the layer in `Scene.layers`. */\n readonly layer: string;\n /** The key of the anchor, or the `id` of the record with the fault. For the layer, it is empty. */\n readonly at: string;\n /** The fault in plain words, with the values. */\n readonly message: string;\n /** The `id` of the second record of the fault. A fault of one record has none. */\n readonly other?: string | undefined;\n}\n\n/** This function compares two texts by their code points, so the order does not change with the language of a computer. */\nfunction compareText(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n\n/** This function gives the add-on of each schema name. The first add-on of a name is used. */\nfunction addOnsByName(addOns: readonly AddOn<unknown>[]): ReadonlyMap<string, AddOn<unknown>> {\n const byName = new Map<string, AddOn<unknown>>();\n for (const addOn of addOns) if (!byName.has(addOn.schema)) byName.set(addOn.schema, addOn);\n return byName;\n}\n\n/** This function reads the layer of an add-on in a scene. It gives `undefined` when the scene has no layer of the add-on. */\nexport function readLayer<Layer>(scene: Scene, addOn: AddOn<Layer>): LayerParse<Layer> | undefined {\n const layers = scene.layers ?? {};\n return Object.hasOwn(layers, addOn.schema) ? addOn.parse(layers[addOn.schema]) : undefined;\n}\n\n/**\n * This function gives the findings of the layers of a scene, with a list of add-ons.\n * Each layer gets the faults of its form, of each anchor and of the meaning of its records. A layer of no add-on of the list gets a warning.\n * The findings are in the order of the layer keys, then of the record keys. Thus equal inputs give equal findings.\n *\n * The name of the record of a finding is `recordName(finding.layer, finding.at)`, so a finding selects its mark.\n * `checkScene` examines the core, and this function examines the layers.\n */\nexport function checkLayers(scene: Scene, addOns: readonly AddOn<unknown>[]): readonly LayerFinding[] {\n const byName = addOnsByName(addOns);\n const layers = scene.layers ?? {};\n const findings: LayerFinding[] = [];\n let space: SceneSpace | undefined;\n for (const name of Object.keys(layers).sort(compareText)) {\n if (!isLayerName(name)) {\n findings.push({ level: \"error\", code: \"layer-name\", layer: name, at: \"\", message: `The layer \"${name}\" has a name that is not a word, a slash and a version, for example \"electrical/1\".` });\n continue;\n }\n const addOn = byName.get(name);\n if (addOn === undefined) {\n findings.push({ level: \"warning\", code: \"layer-unknown\", layer: name, at: \"\", message: `The scene has the layer \"${name}\", and no add-on of the check reads it. The scene keeps the layer.` });\n continue;\n }\n const read = addOn.parse(layers[name]);\n if (!read.ok) {\n for (const message of read.errors) findings.push({ level: \"error\", code: \"layer-form\", layer: name, at: \"\", message });\n continue;\n }\n space ??= sceneSpace(scene);\n const own: LayerFinding[] = [];\n for (const [key, anchor] of addOn.anchors(read.layer)) {\n for (const fault of checkAnchor(anchor, space, `The anchor \"${key}\" of the layer \"${name}\"`)) own.push({ ...fault, layer: name, at: key });\n }\n for (const fault of addOn.check(read.layer, space)) own.push({ ...fault, layer: name });\n // The sort is stable, so the faults of one record keep their order.\n own.sort((a, b) => compareText(a.at, b.at));\n findings.push(...own);\n }\n return findings;\n}\n"],"mappings":";;;;;;;;;AAuBA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C7B,KAAK,MAAM,CAAC,KAAK,WAAW,MAAM,QAAQ,KAAK,KAAK,GAClD,KAAK,MAAM,SAAS,YAAY,QAAQ,OAAO,eAAe,IAAI,kBAAkB,KAAK,EAAE,GAAG,IAAI,KAAK;GAAE,GAAG;GAAO,OAAO;GAAM,IAAI;EAAI,CAAC;EAE3I,KAAK,MAAM,SAAS,MAAM,MAAM,KAAK,OAAO,KAAK,GAAG,IAAI,KAAK;GAAE,GAAG;GAAO,OAAO;EAAK,CAAC;EAEtF,IAAI,MAAM,GAAG,MAAM,YAAY,EAAE,IAAI,EAAE,EAAE,CAAC;EAC1C,SAAS,KAAK,GAAG,GAAG;CACtB;CACA,OAAO;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as LengthUnit, a as Opening, c as PlacedObject, d as Room, l as PlanPoint, s as Outlet, t as Circuit } from "./room-
|
|
1
|
+
import { S as LengthUnit, a as Opening, c as PlacedObject, d as Room, l as PlanPoint, s as Outlet, t as Circuit } from "./room-NREa6vXr.js";
|
|
2
2
|
/** The name of the format of a survey record. */
|
|
3
3
|
declare const SURVEY_SCHEMA = "survey/1";
|
|
4
4
|
/** These are the names of the turns at a square corner. */
|
|
@@ -341,4 +341,4 @@ declare const CONNECTION_TURN_LIMIT = 2;
|
|
|
341
341
|
*/
|
|
342
342
|
declare function expandLevel(level: Level, options?: LevelOptions): LevelResult;
|
|
343
343
|
export { SurveyTurn as A, SurveyCheckResult as C, SurveyOutlet as D, SurveyOptions as E, expandSurvey as M, SurveyResult as O, SurveyCheck as S, SurveyObject as T, expandLevel as _, ConnectionFault as a, SURVEY_SCHEMA as b, Level as c, LevelOptions as d, LevelResult as f, RoomPlace as g, ROOM_PLACES as h, ConnectionEnd as i, convertSurvey as j, SurveySide as k, LevelConnection as l, LevelRoomResult as m, CONNECTION_TURN_LIMIT as n, ConnectionUse as o, LevelRoom as p, CONNECTION_USES as r, LEVEL_SCHEMA as s, CONNECTION_FAULTS as t, LevelConnectionResult as u, CLOSURE_LIMIT as v, SurveyClosure as w, Survey as x, SQUARE_TURNS as y };
|
|
344
|
-
//# sourceMappingURL=level-
|
|
344
|
+
//# sourceMappingURL=level-Bmz-H5iH.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"level-
|
|
1
|
+
{"version":3,"file":"level-Bmz-H5iH.d.ts","names":[],"sources":["../src/survey.ts","../src/level.ts"],"mappings":";;cAKa;;cAGA;;;;;;;KAQD,qBAAqB;;UAGhB;;WAEN;;WAEA;;WAEA,MAAM;;WAEN;;WAEA;;;UAIM;WACN;;WAEA;;WAEA;;WAEA;;;KAIC,eAAe,KAAK;;;;;;;;;;;;UAaf;WACN;;WAEA;WACA;;WAEA;;WAEA;;;;;WAKA;;WAEA;;WAEA;WACA;;;;;WAKA;;;;;WAKA;;WAEA;;;;;;;;;UAUM;WACN,eAAe;WACf;;WAEA,MAAM;;WAEN;;WAEA;;WAEA,gBAAgB;;WAEhB,QAAQ;;WAER;WACA,kBAAkB;WAClB,oBAAoB;WACpB,mBAAmB;WACnB,oBAAoB;WACpB,mBAAmB;;;UAIb;;WAEN;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN,MAAM;;WAEN,kBAAkB;;WAElB,eAAe;WACf,SAAS;;WAET,iBAAiB;;;;;WAKjB,kBAAkB;;;cAIhB;;UAGI;;WAEN;;;;;;iBAmBK,cAAc,QAAQ,QAAQ,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8EjD,aAAa,QAAQ,QAAQ,UAAS,gBAAqB;;cClQ9D;;UAGI;WACN;WACA,QAAQ;;;UAIF;;WAEN;;WAEA;;;;;;UAOM;WACN;WACA,MAAM;WACN,IAAI;;;;;WAKJ;;;;;;;;UASM;WACN,eAAe;WACf;;WAEA,MAAM;WACN,gBAAgB;WAChB,uBAAuB;;WAEvB,oBAAoB;;;;;;;;;cAUlB;;KAGD,oB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