@mark1russell7/room-view 0.3.0 → 0.3.1

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.
Files changed (42) hide show
  1. package/README.md +28 -0
  2. package/build/{check-DI_B57qy.js → check-lFfxIUS3.js} +3 -29
  3. package/build/check-lFfxIUS3.js.map +1 -0
  4. package/build/index.d.ts +4 -3
  5. package/build/index.d.ts.map +1 -1
  6. package/build/index.js +5 -3
  7. package/build/index.js.map +1 -1
  8. package/build/{layers-CYZwt1bH.d.ts → layers-BiiyFJwZ.d.ts} +3 -2
  9. package/build/layers-BiiyFJwZ.d.ts.map +1 -0
  10. package/build/{layers-CDNFVXds.js → layers-DmTro5Ny.js} +5 -29
  11. package/build/layers-DmTro5Ny.js.map +1 -0
  12. package/build/{level-BERjgyrT.js → level-CvbiwvhH.js} +4 -3
  13. package/build/{level-BERjgyrT.js.map → level-CvbiwvhH.js.map} +1 -1
  14. package/build/{level-m-mJ_3Ok.d.ts → level-DmEftWYn.d.ts} +3 -3
  15. package/build/{level-m-mJ_3Ok.d.ts.map → level-DmEftWYn.d.ts.map} +1 -1
  16. package/build/marks.d.ts +2 -2
  17. package/build/marks.js +1 -1
  18. package/build/plan-import.d.ts +325 -0
  19. package/build/plan-import.d.ts.map +1 -0
  20. package/build/plan-import.js +855 -0
  21. package/build/plan-import.js.map +1 -0
  22. package/build/room-BQua5eSs.d.ts +124 -0
  23. package/build/room-BQua5eSs.d.ts.map +1 -0
  24. package/build/room-CiVZ_07s.js +29 -0
  25. package/build/room-CiVZ_07s.js.map +1 -0
  26. package/build/sample.d.ts +2 -2
  27. package/build/schema.d.ts +3 -3
  28. package/build/schema.js +4 -3
  29. package/build/schema.js.map +1 -1
  30. package/build/{solids-OiTlb_Pm.d.ts → solids-CdJf0U39.d.ts} +3 -123
  31. package/build/solids-CdJf0U39.d.ts.map +1 -0
  32. package/build/three.d.ts +2 -1
  33. package/build/three.d.ts.map +1 -1
  34. package/build/three.js +2 -1
  35. package/build/three.js.map +1 -1
  36. package/build/units-BZmvVyu4.js +30 -0
  37. package/build/units-BZmvVyu4.js.map +1 -0
  38. package/package.json +7 -1
  39. package/build/check-DI_B57qy.js.map +0 -1
  40. package/build/layers-CDNFVXds.js.map +0 -1
  41. package/build/layers-CYZwt1bH.d.ts.map +0 -1
  42. package/build/solids-OiTlb_Pm.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layers-DmTro5Ny.js","names":[],"sources":["../src/anchors.ts","../src/order.ts","../src/layers.ts"],"sourcesContent":["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 a point with no negative zero. JSON has no negative zero, so a frame goes through JSON with no change. */\nfunction plainPoint(point: Point3): Point3 {\n return { x: point.x + 0, y: point.y + 0, z: point.z + 0 };\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;\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 const plain: AnchorFrame = { at: plainPoint(found.at), out: plainPoint(found.out) };\n return inRange(plain.at) && inRange(plain.out) ? plain : undefined;\n };\n return { scene, scale, wall: (id) => walls.get(id), object: (id) => objects.get(id), transform, frame };\n}\n\n/**\n * This function gives an anchor with each length times a factor. A direction stays, because it has no unit.\n * `convertSurvey` uses it to change the unit of the anchors of a layer.\n */\nexport function scaleAnchor(anchor: Anchor, factor: number): Anchor {\n if (anchor.on === \"wall\") return { ...anchor, offset: anchor.offset * factor, height: anchor.height * factor };\n if (anchor.on === \"object\") {\n if (anchor.at === undefined) return anchor;\n const [x, y, z] = anchor.at;\n return { ...anchor, at: [x * factor, y * factor, z * factor] };\n }\n const [x, y] = anchor.at;\n return { ...anchor, at: [x * factor, y * factor] };\n}\n","// The order of texts in the results of the core. The entries do not export this module.\n\n/** This function compares two texts by their code points, so the order does not change with the language of a computer. */\nexport function compareText(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n","import { sceneSpace, type Anchor, type SceneSpace } from \"./anchors.ts\";\nimport { checkAnchor, type FindingLevel } from \"./check.ts\";\nimport { compareText } from \"./order.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 * This function gives one layer from the parts of a level: the layer of the level record, then the layer of each room.\n *\n * - A record of a part gets the name `part.name(id)`. Each `id` of the layer that names such a record or a placed object gets it too.\n * - A record that all the rooms share keeps its `id`, for example a circuit of an apartment. The first record of an `id` stays.\n * - The core changes the anchors before this function, so the function does not change an anchor.\n *\n * `expandLevel` does not carry the layer of a room when its add-on has no such function.\n */\n join?(parts: readonly LayerPart<Layer>[]): Layer;\n /**\n * The read of the old records of the topic. A record of version 1 of the core kept some of them in fields of its own.\n * `readRecord` of the entry `/schema` uses it. An add-on with no such records has none.\n */\n readonly v1?: AddOnV1<Layer> | undefined;\n}\n\n/** These are the kinds of the files of the core: `room`, `scene`, `survey` and `level`. */\nexport const FILE_KINDS: readonly [\"room\", \"scene\", \"survey\", \"level\"] = [\"room\", \"scene\", \"survey\", \"level\"];\n\n/** A kind of a file of the core. */\nexport type FileKind = (typeof FILE_KINDS)[number];\n\n/** The old records of an add-on in the records of version 1 of the core: their fields, and the read of their layer. */\nexport interface AddOnV1<Layer> {\n /**\n * The names of the fields of each kind of record that keep the old records. Version 2 of the core does not have these fields.\n * The names of `object` are the fields of each placed object of a scene and of each object of a survey.\n */\n readonly fields: { readonly [Kind in FileKind | \"object\"]?: readonly string[] | undefined };\n /**\n * This function gives the layer of the old records of a record of version 1, or `undefined` for a record with none of them.\n * The record is the JSON of the file, or the JSON of the survey of a room of a level. The function examines the form of its own fields.\n * The schema of version 2 examines the other fields after the read. A layer of a survey has the anchors of a survey, as `Survey.layers` tells.\n * A room record has no layers, so the layer of a `room` is the layer of a scene of that room.\n */\n read(record: unknown, kind: FileKind): LayerParse<Layer> | undefined;\n}\n\n/** One part of the layers of a level, for the function `join` of an add-on. `layerPart` makes it. */\nexport interface LayerPart<Layer> {\n /** The `id` of the room of the layer. The layer of the level record has no room. */\n readonly room?: string | undefined;\n readonly layer: Layer;\n /**\n * This function gives the name in the level of a record of the part, from its `id` in the part.\n * A record of a room gets the name that `roomName` gives, and a record of the level record keeps its `id`.\n * The function also gives the name of a record of the core that the part names, for example a placed object.\n */\n readonly name: (id: string) => string;\n}\n\n/**\n * This function gives the name in a level of a record of a room. The name is the `id` of the room, a slash and the `id` in the survey.\n * `expandLevel` gives each wall, each opening and each placed object such a name. The function `join` of an add-on gives it to the records of a room.\n */\nexport function roomName(room: string, id: string): string {\n return `${room}/${id}`;\n}\n\n/**\n * This function makes one part of the layers of a level. With no room, the part is the layer of the level record.\n * Its function `name` has the rule of `roomName`, so an add-on does not write that rule again.\n */\nexport function layerPart<Layer>(layer: Layer, room?: string): LayerPart<Layer> {\n return room === undefined ? { layer, name: (id) => id } : { room, layer, name: (id) => roomName(room, id) };\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 /** The `id` of the room of the layer. Only a finding of `expandLevel` about the layer of a room has it. */\n readonly room?: string | undefined;\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\n/** The result of a change of layers: the layers that the function carried, and a finding for each layer that it did not carry. */\nexport interface LayersMove {\n /** The layers of the result, in the order of their names. */\n readonly layers: Readonly<Record<string, unknown>>;\n /** One finding or more for each layer that is not in the result. Each finding has the level `error`. */\n readonly findings: readonly LayerFinding[];\n}\n\n/** The read of one layer for a change: the add-on and the layer, or the findings that tell why the layer has no read. */\ntype LayerRead = { readonly addOn: AddOn<unknown>; readonly layer: unknown } | readonly LayerFinding[];\n\n/** This function reads one layer with the add-on of its name. `room` is the `id` of the room of the layer, in a level. */\nfunction readForChange(name: string, value: unknown, byName: ReadonlyMap<string, AddOn<unknown>>, room?: string): LayerRead {\n const where = room === undefined ? {} : { room };\n const of = room === undefined ? \"\" : ` of the room \"${room}\"`;\n const finding = (code: (typeof LAYER_CODES)[number], message: string): LayerFinding => ({ level: \"error\", code, layer: name, at: \"\", message, ...where });\n if (!isLayerName(name)) {\n return [finding(\"layer-name\", `The layer \"${name}\"${of} has a name that is not a word, a slash and a version, for example \"electrical/1\". The result does not have the layer.`)];\n }\n const addOn = byName.get(name);\n if (addOn === undefined) return [finding(\"layer-unknown\", `No add-on of the list reads the layer \"${name}\"${of}. The result does not have the layer.`)];\n const read = addOn.parse(value);\n if (!read.ok) return read.errors.map((message) => finding(\"layer-form\", message));\n return { addOn, layer: read.layer };\n}\n\n/**\n * This function gives layers with each anchor changed by `move`. The add-on of each layer comes from the list.\n * `expandSurvey` uses it to put the layers of a survey on the room record. A host uses it when it moves the records of a room.\n *\n * A layer that the function cannot read is not in the result, because its anchors are in the old space. A finding tells each such layer:\n *\n * - `layer-name`: the name is not a layer name.\n * - `layer-unknown`: no add-on of the list has the name.\n * - `layer-form`: the add-on found a fault in the form of the layer.\n *\n * `room` is the `id` of the room of the layers, in a level. Each finding gets it.\n */\nexport function moveLayers(\n layers: Readonly<Record<string, unknown>> | undefined,\n addOns: readonly AddOn<unknown>[],\n move: (anchor: Anchor) => Anchor,\n room?: string,\n): LayersMove {\n const byName = addOnsByName(addOns);\n const given = layers ?? {};\n const moved: [string, unknown][] = [];\n const findings: LayerFinding[] = [];\n for (const name of Object.keys(given).sort(compareText)) {\n const read = readForChange(name, given[name], byName, room);\n if (\"addOn\" in read) {\n const anchors = new Map<string, Anchor>();\n for (const [key, anchor] of read.addOn.anchors(read.layer)) anchors.set(key, move(anchor));\n moved.push([name, read.addOn.withAnchors(read.layer, anchors)]);\n } else findings.push(...read);\n }\n return { layers: Object.fromEntries(moved), findings };\n}\n\n/** The layers of one room of a level, for `joinLayers`. The anchors have the names of the level already. */\nexport interface RoomLayers {\n /** The `id` of the room. */\n readonly room: string;\n readonly layers: Readonly<Record<string, unknown>> | undefined;\n}\n\n/**\n * This function gives the layers of a level. Each name gets one layer, from the layer of the level record and the layers of the rooms.\n * The function `join` of the add-on of each name makes that layer. `expandLevel` uses this function.\n *\n * - A layer that only the level record has stays as it is, because its anchors are on the room record of the level already.\n * `checkLayers` examines it.\n * - The layer of a room needs an add-on of its name with the function `join`. Without it, a finding tells the layer of each room,\n * and the layer of the level record stays as it is. The codes are the codes of `moveLayers`.\n * An add-on with no function `join` gives the code `layer-unknown`.\n * - With such an add-on, a part with a fault in its form is not in the layer of the result. A finding tells the part.\n */\nexport function joinLayers(own: Readonly<Record<string, unknown>> | undefined, rooms: readonly RoomLayers[], addOns: readonly AddOn<unknown>[]): LayersMove {\n const byName = addOnsByName(addOns);\n const level = own ?? {};\n const names = new Set(Object.keys(level));\n for (const room of rooms) for (const name of Object.keys(room.layers ?? {})) names.add(name);\n const joined: [string, unknown][] = [];\n const findings: LayerFinding[] = [];\n for (const name of [...names].sort(compareText)) {\n const inLevel = Object.hasOwn(level, name);\n const inRooms = rooms.filter((room) => room.layers !== undefined && Object.hasOwn(room.layers, name));\n const addOn = isLayerName(name) ? byName.get(name) : undefined;\n const join = addOn?.join?.bind(addOn);\n if (join === undefined || inRooms.length === 0) {\n if (inLevel) joined.push([name, level[name]]);\n for (const { room, layers } of inRooms) {\n if (addOn === undefined) {\n const read = readForChange(name, layers?.[name], byName, room);\n if (!(\"addOn\" in read)) findings.push(...read);\n } else {\n const message = `The add-on of the layer \"${name}\" has no function \"join\", so the result does not have the layer of the room \"${room}\".`;\n findings.push({ level: \"error\", code: \"layer-unknown\", layer: name, at: \"\", message, room });\n }\n }\n continue;\n }\n const parts: LayerPart<unknown>[] = [];\n if (inLevel) {\n const read = readForChange(name, level[name], byName);\n if (\"addOn\" in read) parts.push(layerPart(read.layer));\n else findings.push(...read);\n }\n for (const { room, layers } of inRooms) {\n const read = readForChange(name, layers?.[name], byName, room);\n if (\"addOn\" in read) parts.push(layerPart(read.layer, room));\n else findings.push(...read);\n }\n if (parts.length > 0) joined.push([name, join(parts)]);\n }\n return { layers: Object.fromEntries(joined), findings };\n}\n"],"mappings":";;;;;;AAUA,MAAa,kBAAmE;CAAC;CAAQ;CAAS;CAAW;AAAQ;AA4ErH,MAAM,KAAa;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;AACtC,MAAM,OAAe;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;AAAG;;AAGzC,SAAS,QAAQ,OAAwB;CACvC,OAAO,OAAO,SAAS,MAAM,CAAC,KAAK,OAAO,SAAS,MAAM,CAAC,KAAK,OAAO,SAAS,MAAM,CAAC,KAAK,eAAe,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AACrI;;AAGA,SAAS,WAAW,OAAuB;CACzC,OAAO;EAAE,GAAG,MAAM,IAAI;EAAG,GAAG,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7D,IAAI,WAAW,MAAM,MAAM,KAAK,UAAU,KAAK,OAAO,IAAI,CAAC;QACtD,SAAS,KAAK,GAAG,IAAI;EAC5B;EACA,IAAI,MAAM,SAAS,GAAG,OAAO,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC;CACvD;CACA,OAAO;EAAE,QAAQ,OAAO,YAAY,MAAM;EAAG;CAAS;AACxD"}
@@ -1,5 +1,6 @@
1
- import { c as roomName, d as scaleAnchor, h as SCENE_SCHEMA, i as joinLayers, m as ROOM_SCHEMA, o as moveLayers } from "./layers-CDNFVXds.js";
2
- import { M as unitsPer, j as metersPer } from "./check-DI_B57qy.js";
1
+ import { c as roomName, d as scaleAnchor, i as joinLayers, o as moveLayers } from "./layers-DmTro5Ny.js";
2
+ import { n as ROOM_SCHEMA, r as SCENE_SCHEMA } from "./room-CiVZ_07s.js";
3
+ import { a as unitsPer, i as metersPer } from "./units-BZmvVyu4.js";
3
4
  /** This function gives the unit vector of a direction in degrees. A direction along an axis gives an exact vector. */
4
5
  function directionOf(degrees) {
5
6
  const turn = (degrees % 360 + 360) % 360;
@@ -813,4 +814,4 @@ function expandLevel(level, options = {}) {
813
814
  }
814
815
  export { ROOM_PLACES as a, SQUARE_TURNS as c, convertSurvey as d, expandSurvey as f, LEVEL_SCHEMA as i, SURVEY_FLOOR as l, surveyAnchor as m, CONNECTION_TURN_LIMIT as n, expandLevel as o, resultScene as p, CONNECTION_USES as r, CLOSURE_LIMIT as s, CONNECTION_FAULTS as t, SURVEY_SCHEMA as u };
815
816
 
816
- //# sourceMappingURL=level-BERjgyrT.js.map
817
+ //# sourceMappingURL=level-CvbiwvhH.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"level-BERjgyrT.js","names":[],"sources":["../src/direction.ts","../src/survey.ts","../src/level.ts"],"sourcesContent":["import type { PlanPoint } from \"./room.ts\";\n\n/** The turn at a square corner, in degrees. */\nexport const SQUARE = 90;\n\n/** One full turn, in degrees. */\nexport const FULL = 360;\n\n/** An angle with an error below this value is exact for the model, in degrees. The value is larger than the error of a sum of numbers. */\nexport const TURN_NOISE = 1e-9;\n\n/** This function gives the unit vector of a direction in degrees. A direction along an axis gives an exact vector. */\nexport function directionOf(degrees: number): PlanPoint {\n const turn = ((degrees % FULL) + FULL) % FULL;\n if (turn === 0) return [1, 0];\n if (turn === SQUARE) return [0, 1];\n if (turn === 2 * SQUARE) return [-1, 0];\n if (turn === 3 * SQUARE) return [0, -1];\n const angle = (turn * Math.PI) / 180;\n return [Math.cos(angle), Math.sin(angle)];\n}\n\n/** This function turns a vector of the plan by an angle in degrees, counter-clockwise. A turn by 90, 180 or 270 degrees is exact. */\nexport function turned([x, y]: PlanPoint, degrees: number): PlanPoint {\n const [cos, sin] = directionOf(degrees);\n return [x * cos - y * sin, x * sin + y * cos];\n}\n\n/**\n * This function gives the direction of a vector in degrees, from 0 to 360, counter-clockwise from the x axis.\n * A direction near 0, 90, 180 or 270 degrees becomes that value, so a room with square corners keeps exact numbers.\n */\nexport function headingOf([x, y]: PlanPoint): number {\n return squared((Math.atan2(y, x) * 180) / Math.PI);\n}\n\n/** This function gives an angle in degrees from 0 to 360. An angle near 0, 90, 180 or 270 degrees becomes that value. */\nexport function squared(degrees: number): number {\n const turn = ((degrees % FULL) + FULL) % FULL;\n const near = Math.round(turn / SQUARE) * SQUARE;\n return Math.abs(turn - near) < TURN_NOISE ? near % FULL : turn;\n}\n","import { scaleAnchor, type Anchor } from \"./anchors.ts\";\nimport { directionOf, FULL, headingOf, SQUARE, TURN_NOISE } from \"./direction.ts\";\nimport { moveLayers, type AddOn, type LayerFinding } from \"./layers.ts\";\nimport {\n ROOM_SCHEMA,\n SCENE_SCHEMA,\n type Opening,\n type PlacedObject,\n type PlanPoint,\n type Room,\n type Scene,\n type Wall,\n type WallFace,\n} from \"./room.ts\";\nimport { LARGEST_LENGTH, metersPer, unitsPer, type LengthUnit } from \"./units.ts\";\n\n/** The name of the format of a survey record. */\nexport const SURVEY_SCHEMA = \"survey/2\";\n\n/** These are the names of the turns at a square corner. */\nexport const SQUARE_TURNS: readonly [\"left\", \"right\"] = [\"left\", \"right\"];\n\n/**\n * The turn of the person at the end of a side, to the direction of the next side.\n *\n * `left` and `right` are the turns at a square corner: 90 degrees. They are exact.\n * A number is a measured angle in degrees, from -360 to 360, and a turn to the left is positive.\n */\nexport type SurveyTurn = (typeof SQUARE_TURNS)[number] | number;\n\n/** One side of a survey: the inner face of one wall, from a corner to the next corner. */\nexport interface SurveySide {\n /** The `id` of the wall of the side. */\n readonly id: string;\n /** The length of the inner face, from corner to corner. */\n readonly length: number;\n /** The turn at the end of the side. */\n readonly turn: SurveyTurn;\n /** The thickness of the wall. The default is `wallThickness` of the survey. */\n readonly thickness?: number | undefined;\n /** The height of the wall. The default is `height` of the survey. */\n readonly height?: number | undefined;\n}\n\n/** A measured distance between two corners of a survey, for example a diagonal of the room. It examines the walk. */\nexport interface SurveyCheck {\n readonly id: string;\n /** The `id` of a side. The first corner is the corner at the start of that side. */\n readonly from: string;\n /** The `id` of a side. The second corner is the corner at the start of that side. */\n readonly to: string;\n /** The measured distance between the two corners. */\n readonly length: number;\n}\n\n/**\n * An object of a survey: a box that a person measures from a side, for example a desk, a shelf or a rack.\n *\n * The back of the object is parallel to the inner face of the side. The person measures along the face to the near edge of the object,\n * and out from the face to its back. The near edge is the edge that is nearest to the first corner of the side.\n * Thus the record has no coordinate.\n *\n * An object with `on` is on a different object or in it, for example a display on a desk or a computer in a rack.\n * Then the person measures from the near edge and from the back of that object, which is the holder.\n * An object has `wall` or `on`. When it has the two, `on` applies.\n */\nexport interface SurveyObject {\n readonly id: string;\n /** The class of the object, for example `desk`, `rack` or `computer`. A viewer gives each class a color. */\n readonly kind: string;\n readonly name?: string | undefined;\n /** The `id` of the side. */\n readonly wall?: string | undefined;\n /** The `id` of the holder. The first object with the `id` applies. */\n readonly on?: string | undefined;\n /**\n * The distance along the inner face, from the first corner of the side to the near edge of the object.\n * With `on`, this is the distance from the near edge of the holder to the near edge of the object.\n */\n readonly offset: number;\n /** The size of the object along the wall. */\n readonly width: number;\n /** The size of the object out from the wall. */\n readonly depth: number;\n readonly height: number;\n /**\n * The distance from the inner face to the back of the object. With `on`, this is the distance from the back of the holder.\n * The default is 0: the object touches the wall, or its back is level with the back of the holder.\n */\n readonly gap?: number | undefined;\n /**\n * The height of the bottom of the object above the floor. The default is 0.\n * With `on`, this is the height above the bottom of the holder. Then the default is the height of the holder: the object is on its top.\n */\n readonly lift?: number | undefined;\n}\n\n/**\n * A survey: the measurements of one room by a person with a tape measure.\n *\n * The person goes around the room along the inner faces of the walls, in one direction.\n * Each side has the length of one face, and the turn at its end. The last turn gives the direction of the first side again.\n * An opening and an object name their side in `wall`. Their `offset` starts at the first corner of that side.\n */\nexport interface Survey {\n readonly schema: typeof SURVEY_SCHEMA;\n readonly name?: string | undefined;\n /** The unit of each length of the record. */\n readonly unit: LengthUnit;\n /** The height of each wall that has no height of its own. */\n readonly height: number;\n /** The thickness of each wall that has no thickness of its own. */\n readonly wallThickness: number;\n /** The sides, in the sequence of the walk. */\n readonly sides: readonly SurveySide[];\n /** The place of the first corner in the plan. The default is the origin. */\n readonly start?: PlanPoint | undefined;\n /** The direction of the first side, in degrees counter-clockwise from the x axis. The default is 0. */\n readonly heading?: number | undefined;\n readonly checks?: readonly SurveyCheck[] | undefined;\n readonly openings?: readonly Opening[] | undefined;\n readonly objects?: readonly SurveyObject[] | undefined;\n /**\n * The records of each add-on, by the name of its layer, for example `electrical/1`. A layer has the format of a layer of a scene.\n * Its anchors are in the space of the survey: they name the sides and the objects of the survey. `surveyAnchor` tells that space.\n * `expandSurvey` moves the anchors to the room record. The core keeps each layer, and it does not read one.\n */\n readonly layers?: Readonly<Record<string, unknown>> | undefined;\n}\n\n/**\n * The place of the walk of a survey in its room record. `surveyAnchor` moves an anchor of the survey with it.\n * The record is plain data, so it goes through JSON with no change.\n */\nexport interface SurveyFrame {\n /** The face of each wall that is in the room: `left` for a walk to the left, and `right` for a walk to the right. */\n readonly face: WallFace;\n /** The place of the first corner in the plan. */\n readonly start: PlanPoint;\n /** The direction of the first side, in degrees counter-clockwise from the x axis. */\n readonly heading: number;\n /**\n * The factor of the length of each side that shares the gap, by the `id` of the side. A factor is the length of the wall as a part of the measured length.\n * A side with no factor keeps its length.\n */\n readonly factors: Readonly<Record<string, number>>;\n}\n\n/** The closure of a survey: the difference between the end of the walk and its start. */\nexport interface SurveyClosure {\n /** The distance from the end of the last side to the first corner, in the unit of the survey. */\n readonly gap: number;\n /** The gap as a part of the length of the walk. A walk with no length has 0. */\n readonly ratio: number;\n /** The sum of the turns minus one full turn in the direction of the walk, in degrees. */\n readonly turn: number;\n /** This value is true when the walk has 3 sides or more, its turns make one full turn, and its gap is in the limit. */\n readonly closed: boolean;\n}\n\n/** The result of one check of a survey. */\nexport interface SurveyCheckResult {\n /** The `id` of the check. */\n readonly id: string;\n /** The measured distance, in the unit of the survey. */\n readonly measured: number;\n /** The distance between the two corners in the room record. A check with a side that the survey does not have gets `undefined`. */\n readonly model: number | undefined;\n /** The measured distance minus the distance in the room record. */\n readonly difference: number | undefined;\n}\n\n/** The result of the expansion of a survey. */\nexport interface SurveyResult {\n /** The room record of the survey. */\n readonly room: Room;\n /** The corner at the start of each side, as the room record has it. */\n readonly corners: readonly PlanPoint[];\n /** The points of the walk before the correction of the gap. The walk has one point more than the survey has sides. */\n readonly walk: readonly PlanPoint[];\n readonly closure: SurveyClosure;\n /** The result of each check, in the sequence of the checks. */\n readonly checks: readonly SurveyCheckResult[];\n /**\n * The placed object of each object of the survey that has a place, in the sequence of the survey.\n * A scene record with the room record and these objects gives the model of the room with its objects.\n */\n readonly objects: readonly PlacedObject[];\n /** The place of the walk in the room record. */\n readonly frame: SurveyFrame;\n /**\n * The layers of the survey with their anchors on the room record. A survey with no layers gives none.\n * A layer is here only when an add-on of the options read it. The anchors of a different layer are in the space of the survey.\n */\n readonly layers?: Readonly<Record<string, unknown>> | undefined;\n /** One finding or more for each layer of the survey that is not in `layers`. `moveLayers` tells the codes. */\n readonly layerFindings: readonly LayerFinding[];\n}\n\n/** The `id` of the floor of the room record of a closed survey. */\nexport const SURVEY_FLOOR = \"floor\";\n\n/** The default limit of the gap of a closed walk, as a part of the length of the walk. */\nexport const CLOSURE_LIMIT = 0.01;\n\n/** The options of the expansion of a survey. */\nexport interface SurveyOptions {\n /** The largest gap of a closed walk, as a part of the length of the walk. The default is `CLOSURE_LIMIT`. */\n readonly limit?: number | undefined;\n /** The add-ons that read the layers of the survey. The default is no add-on, and then the result has no layer. */\n readonly addOns?: readonly AddOn<unknown>[] | undefined;\n}\n\n/**\n * This function gives an anchor of a survey on the room record of the survey. `frame` comes from the result of `expandSurvey`.\n *\n * - An anchor on a wall names a side. Its `offset` starts at the first corner of the side and goes along the inner face.\n * The result is on the face in the room, and its `offset` changes in the proportion of the side, as an opening does. Its `face` in the survey has no effect.\n * - A point of an anchor on the floor or on the ceiling is in the frame of the walk. The first corner is the origin, and the first side goes along the x axis.\n * The result is at its place in the plan. The correction of the gap does not move the point.\n * - An anchor on an object stays, because a placed object keeps the `id` and the frame of its object in the survey.\n */\nexport function surveyAnchor(anchor: Anchor, frame: SurveyFrame): Anchor {\n if (anchor.on === \"object\") return anchor;\n if (anchor.on === \"wall\") {\n const factor = Object.hasOwn(frame.factors, anchor.wall) ? (frame.factors[anchor.wall] ?? 1) : 1;\n return { ...anchor, face: frame.face, offset: anchor.offset * factor };\n }\n const [cos, sin] = directionOf(frame.heading);\n const [x, y] = anchor.at;\n return { ...anchor, at: [frame.start[0] + (x * cos - y * sin), frame.start[1] + (x * sin + y * cos)] };\n}\n\n/**\n * This function gives the scene record of the result of `expandSurvey` or of `expandLevel`: the room record, the placed objects and the layers.\n * The scene has the name of the room record. `checkScene` and `checkLayers` examine it.\n */\nexport function resultScene(result: { readonly room: Room; readonly objects: readonly PlacedObject[]; readonly layers?: Readonly<Record<string, unknown>> | undefined }): Scene {\n return {\n schema: SCENE_SCHEMA,\n ...(result.room.name === undefined ? {} : { name: result.room.name }),\n room: result.room,\n objects: result.objects,\n ...(result.layers === undefined ? {} : { layers: result.layers }),\n };\n}\n\n/** This function tells if a turn is a measured angle: an angle from -360 degrees to 360 degrees. */\nfunction isMeasured(turn: SurveyTurn): turn is number {\n return typeof turn === \"number\" && Math.abs(turn) <= FULL;\n}\n\n/** This function gives a turn in degrees. A turn that is not a square turn or a measured angle is 0. */\nfunction degreesOf(turn: SurveyTurn): number {\n if (turn === \"left\") return SQUARE;\n if (turn === \"right\") return 0 - SQUARE;\n return isMeasured(turn) ? turn : 0;\n}\n\n/**\n * This function gives a survey in a different unit. Each length of the record changes, and each angle stays.\n * A survey that has the unit already is the result.\n *\n * The anchors of a layer change through the add-on of the layer in `addOns`. An add-on keeps each different length of its layer in a fixed unit.\n * The result has only the layers that an add-on of the list reads, because the anchors of a different layer stay in the old unit.\n * `moveLayers` with `scaleAnchor` gives a finding for each layer that the result does not have.\n */\nexport function convertSurvey(survey: Survey, unit: LengthUnit, addOns: readonly AddOn<unknown>[] = []): Survey {\n if (survey.unit === unit) return survey;\n const factor = unitsPer(survey.unit, unit);\n const to = (value: number): number => value * factor;\n const start: PlanPoint | undefined = survey.start === undefined ? undefined : [to(survey.start[0]), to(survey.start[1])];\n const layers = survey.layers === undefined ? undefined : moveLayers(survey.layers, addOns, (anchor) => scaleAnchor(anchor, factor)).layers;\n return {\n ...survey,\n unit,\n ...(layers === undefined ? {} : { layers }),\n height: to(survey.height),\n wallThickness: to(survey.wallThickness),\n sides: survey.sides.map((side) => ({\n ...side,\n length: to(side.length),\n ...(side.thickness === undefined ? {} : { thickness: to(side.thickness) }),\n ...(side.height === undefined ? {} : { height: to(side.height) }),\n })),\n ...(start === undefined ? {} : { start }),\n ...(survey.checks === undefined ? {} : { checks: survey.checks.map((check) => ({ ...check, length: to(check.length) })) }),\n ...(survey.openings === undefined\n ? {}\n : {\n openings: survey.openings.map((opening) => ({\n ...opening,\n offset: to(opening.offset),\n width: to(opening.width),\n ...(opening.sill === undefined ? {} : { sill: to(opening.sill) }),\n height: to(opening.height),\n })),\n }),\n ...(survey.objects === undefined\n ? {}\n : {\n objects: survey.objects.map((object) => ({\n ...object,\n offset: to(object.offset),\n width: to(object.width),\n depth: to(object.depth),\n height: to(object.height),\n ...(object.gap === undefined ? {} : { gap: to(object.gap) }),\n ...(object.lift === undefined ? {} : { lift: to(object.lift) }),\n })),\n }),\n };\n}\n\n/**\n * This function makes the room record of a survey.\n *\n * The walk starts at `start` in the direction `heading`. Each side adds its length, and then the person turns.\n * A length that is not a finite number above 0, or is not in the range of the model, counts as 0.\n * A turn that is not a number from -360 to 360 counts as 0. Thus each number of the result is finite.\n *\n * A measured length has an error, so the walk does not end exactly at its start. The function corrects the two errors of a walk:\n *\n * 1. When the sum of the turns has an error below 45 degrees, each measured turn gets an equal part of the error.\n * The turns `left` and `right` are exact, so they do not change. A larger error is a mistake, for example a wrong turn.\n * 2. When the walk is closed, the sides share the gap. Along each axis of the first side, each side changes in proportion to its length along that axis.\n * This is the transit rule of land survey. A side along an axis stays along that axis, so a room with square corners keeps them.\n * Then the last wall ends exactly at the first corner, and the room gets a floor.\n *\n * An opening keeps its place on a side that changes its length: its `offset` and its `width` change in the same proportion.\n * Thus an opening that fits in its measured side fits in its wall, and two openings that do not overlap stay apart.\n *\n * An object keeps its size on a side that changes its length. It moves by a part of that change: its place in the free length of the side.\n * Thus an object that touches a corner continues to touch it. The x axis of a placed object goes along its wall,\n * and its y axis points into the room. An object with a holder has the holder as its parent, and its place is relative to the holder.\n *\n * Some objects have no place, and the result does not have them. A side that is not in the survey or has no length gives no place.\n * A holder with no place gives no place. A size that is not a finite number above 0 gives no place.\n * A distance that is not in the range of the model gives no place.\n *\n * A walk that is not closed gets no correction of the gap: its walls follow the walk, and the room has no floor.\n * Thus the record of a survey in progress shows the walls that the person measured.\n *\n * The wall of each side is on the outer side of its line. Thus each `offset` of the survey is a distance along the inner face.\n * `checkRoom` examines the room record.\n */\nexport function expandSurvey(survey: Survey, options: SurveyOptions = {}): SurveyResult {\n const scale = metersPer(survey.unit);\n const inRange = (value: number): boolean => Number.isFinite(value) && Math.abs(value) * scale <= LARGEST_LENGTH;\n const sides = survey.sides;\n const count = sides.length;\n const lengths = sides.map((side) => (side.length > 0 && inRange(side.length) ? side.length : 0));\n const turns = sides.map((side) => degreesOf(side.turn));\n const total = lengths.reduce((sum, length) => sum + length, 0);\n\n const sum = turns.reduce((all, turn) => all + turn, 0);\n const toLeft = sum >= 0;\n const error = sum - (toLeft ? FULL : 0 - FULL);\n const measured = sides.filter((side) => isMeasured(side.turn)).length;\n const corrected = measured > 0 && Math.abs(error) < SQUARE / 2;\n const share = corrected ? error / measured : 0;\n\n // The walk in its own frame: the first corner is the origin, and the first side goes along the x axis.\n let direction = 0;\n const steps = sides.map((side, index): PlanPoint => {\n const [dx, dy] = directionOf(direction);\n direction += turns[index]! - (isMeasured(side.turn) ? share : 0);\n return [dx * lengths[index]!, dy * lengths[index]!];\n });\n const points: PlanPoint[] = [[0, 0]];\n steps.forEach(([dx, dy], index) => {\n const [x, y] = points[index]!;\n points.push([x + dx, y + dy]);\n });\n\n const [gapX, gapY] = points[count]!;\n const gap = Math.hypot(gapX, gapY);\n const ratio = total > 0 ? gap / total : 0;\n const given = options.limit ?? CLOSURE_LIMIT;\n const limit = Number.isFinite(given) && given >= 0 ? given : CLOSURE_LIMIT;\n const closed = count >= 3 && total > 0 && (corrected || Math.abs(error) < TURN_NOISE) && ratio <= limit;\n\n // The transit rule: along each axis, a corner moves against the gap by the part of the movement before it.\n const moveX = steps.reduce((all, [dx]) => all + Math.abs(dx), 0);\n const moveY = steps.reduce((all, [, dy]) => all + Math.abs(dy), 0);\n let beforeX = 0;\n let beforeY = 0;\n const adjusted = steps.map(([dx, dy], index): PlanPoint => {\n const [x, y] = points[index]!;\n const partX = closed && moveX > 0 ? beforeX / moveX : 0;\n const partY = closed && moveY > 0 ? beforeY / moveY : 0;\n beforeX += Math.abs(dx);\n beforeY += Math.abs(dy);\n return [x - partX * gapX, y - partY * gapY];\n });\n\n // The frame of the walk goes to its place in the plan.\n const start: PlanPoint = survey.start !== undefined && inRange(survey.start[0]) && inRange(survey.start[1]) ? survey.start : [0, 0];\n const heading = survey.heading !== undefined && Number.isFinite(survey.heading) ? survey.heading : 0;\n const [cos, sin] = directionOf(heading);\n const place = ([x, y]: PlanPoint): PlanPoint => [start[0] + (x * cos - y * sin), start[1] + (x * sin + y * cos)];\n const walk = points.map(place);\n const corners = adjusted.map(place);\n\n const walls = sides.map((side, index): Wall => {\n const to = closed ? corners[(index + 1) % count]! : walk[index + 1]!;\n return {\n id: side.id,\n from: corners[index]!,\n to,\n side: toLeft ? \"right\" : \"left\",\n ...(side.thickness === undefined ? {} : { thickness: side.thickness }),\n ...(side.height === undefined ? {} : { height: side.height }),\n };\n });\n\n const cornerOf = new Map<string, PlanPoint>();\n sides.forEach((side, index) => {\n if (!cornerOf.has(side.id)) cornerOf.set(side.id, corners[index]!);\n });\n const checks = (survey.checks ?? []).map((check): SurveyCheckResult => {\n const from = cornerOf.get(check.from);\n const to = cornerOf.get(check.to);\n const model = from === undefined || to === undefined ? undefined : Math.hypot(to[0] - from[0], to[1] - from[1]);\n return { id: check.id, measured: check.length, model, difference: model === undefined ? undefined : check.length - model };\n });\n\n // A side that shares the gap changes its length. The length of its wall, as a part of the measured length, is the factor of the side.\n const shared = closed && gap > 0;\n const factorOf = new Map<string, number>();\n sides.forEach((side, index) => {\n if (!shared || factorOf.has(side.id) || !(lengths[index]! > 0)) return;\n const { from, to } = walls[index]!;\n factorOf.set(side.id, Math.hypot(to[0] - from[0], to[1] - from[1]) / lengths[index]!);\n });\n const openings = survey.openings?.map((opening): Opening => {\n const factor = factorOf.get(opening.wall) ?? 1;\n return factor === 1 ? opening : { ...opening, offset: opening.offset * factor, width: opening.width * factor };\n });\n\n const face = toLeft ? \"left\" : \"right\";\n const room: Room = {\n schema: ROOM_SCHEMA,\n ...(survey.name === undefined ? {} : { name: survey.name }),\n unit: survey.unit,\n height: survey.height,\n wallThickness: survey.wallThickness,\n walls,\n // A walk with no shared gap keeps the list of the survey.\n ...(survey.openings === undefined || openings === undefined ? {} : { openings: shared ? openings : survey.openings }),\n // A floor has a counter-clockwise outline.\n ...(closed ? { floors: [{ id: SURVEY_FLOOR, ...(survey.name === undefined ? {} : { name: survey.name }), ring: toLeft ? corners : [...corners].reverse() }] } : {}),\n };\n\n const sideOf = new Map<string, number>();\n sides.forEach((side, index) => {\n if (!sideOf.has(side.id)) sideOf.set(side.id, index);\n });\n const listed = new Map<string, SurveyObject>();\n for (const object of survey.objects ?? []) if (!listed.has(object.id)) listed.set(object.id, object);\n const places = new Map<SurveyObject, PlacedObject | undefined>();\n const placeOf = (object: SurveyObject): PlacedObject | undefined => {\n if (places.has(object)) return places.get(object);\n // An object in a ring of objects that hold one another finds itself here. Thus it has no place.\n places.set(object, undefined);\n const made = placed(object);\n places.set(object, made);\n return made;\n };\n const placed = (object: SurveyObject): PlacedObject | undefined => {\n const out = object.gap ?? 0;\n if (![object.width, object.depth, object.height].every((size) => size > 0 && inRange(size))) return undefined;\n if (![object.offset, out, object.lift ?? 0].every(inRange)) return undefined;\n const record = {\n id: object.id,\n kind: object.kind,\n ...(object.name === undefined ? {} : { name: object.name }),\n size: [object.width, object.depth, object.height] as const,\n };\n if (object.on !== undefined) {\n const holder = listed.get(object.on);\n if (holder === undefined || placeOf(holder) === undefined) return undefined;\n // The x axis of the holder goes along its side for a walk to the left, and against its side for a walk to the right.\n const x = object.offset + object.width / 2 - holder.width / 2;\n return { ...record, at: [toLeft ? x : 0 - x, out + object.depth / 2 - holder.depth / 2], lift: object.lift ?? holder.height, parent: holder.id };\n }\n const index = object.wall === undefined ? undefined : sideOf.get(object.wall);\n if (index === undefined) return undefined;\n const { from, to } = walls[index]!;\n const measure = lengths[index]!;\n const line = Math.hypot(to[0] - from[0], to[1] - from[1]);\n if (!(line > 0) || !(measure > 0)) return undefined;\n // The object keeps its size, so it moves by a part of the change of the length of its side.\n // The part is the place of the object in the free length of the side. An object that is longer than its side has no free length,\n // so the part is its place in the full length, as for an opening.\n const free = measure - object.width;\n const part = Math.min(1, Math.max(0, object.offset / (free > 0 ? free : measure)));\n const near = shared ? object.offset + (line - measure) * part : object.offset;\n const along: PlanPoint = [(to[0] - from[0]) / line, (to[1] - from[1]) / line];\n // The room is on the left of each side of a walk to the left, and on the right of each side of a walk to the right.\n const inward: PlanPoint = toLeft ? [0 - along[1], along[0]] : [along[1], 0 - along[0]];\n const a = near + object.width / 2;\n const b = out + object.depth / 2;\n // The y axis of the object is on the left of its x axis, so the x axis of a walk to the right goes against the side.\n const turn = headingOf(toLeft ? along : [0 - along[0], 0 - along[1]]);\n return {\n ...record,\n at: [from[0] + along[0] * a + inward[0] * b, from[1] + along[1] * a + inward[1] * b],\n ...(object.lift === undefined ? {} : { lift: object.lift }),\n ...(turn === 0 ? {} : { turn }),\n };\n };\n const objects = (survey.objects ?? []).flatMap((object) => {\n const made = placeOf(object);\n return made === undefined ? [] : [made];\n });\n // The layers go to the room record with the frame of the walk. A layer that no add-on reads stays in the survey.\n const frame: SurveyFrame = { face, start, heading, factors: Object.fromEntries(factorOf) };\n const moved = survey.layers === undefined ? undefined : moveLayers(survey.layers, options.addOns ?? [], (anchor) => surveyAnchor(anchor, frame));\n return {\n room,\n corners,\n walk,\n closure: { gap, ratio, turn: error, closed },\n checks,\n objects,\n frame,\n ...(moved === undefined ? {} : { layers: moved.layers }),\n layerFindings: moved?.findings ?? [],\n };\n}\n","import { scaleAnchor, type Anchor } from \"./anchors.ts\";\nimport { headingOf, squared, turned } from \"./direction.ts\";\nimport { joinLayers, moveLayers, roomName, type LayerFinding, type RoomLayers } from \"./layers.ts\";\nimport { ROOM_SCHEMA, type Floor, type Opening, type PlacedObject, type PlanPoint, type Room, type Wall } from \"./room.ts\";\nimport { CLOSURE_LIMIT, convertSurvey, expandSurvey, surveyAnchor, SURVEY_FLOOR, type Survey, type SurveyOptions, type SurveyResult } from \"./survey.ts\";\nimport { LARGEST_LENGTH, metersPer, unitsPer, type LengthUnit } from \"./units.ts\";\n\n/** The name of the format of a level record. */\nexport const LEVEL_SCHEMA = \"level/2\";\n\n/** One room of a level: the survey of the room, with an `id`. */\nexport interface LevelRoom {\n readonly id: string;\n readonly survey: Survey;\n}\n\n/** One end of a connection: an opening of a room of the level. */\nexport interface ConnectionEnd {\n /** The `id` of the room. */\n readonly room: string;\n /** The `id` of the opening in the survey of that room. */\n readonly opening: string;\n}\n\n/**\n * A connection: one hole through the wall between two rooms, for example a door.\n * A person measures the hole in each room, so the survey of each room has it as an opening.\n */\nexport interface LevelConnection {\n readonly id: string;\n readonly from: ConnectionEnd;\n readonly to: ConnectionEnd;\n /**\n * The thickness of the wall at the hole: the distance between the faces of the wall in the two rooms.\n * A person measures it in the frame of a door. The default is the thickness of the wall of `from`.\n */\n readonly thickness?: number | undefined;\n}\n\n/**\n * A level: the rooms of one level of a building, for example the rooms of an apartment.\n *\n * Each room has its own survey, so each room has its own first corner and its own first direction.\n * A connection gives the place of a room: its two openings are one hole, so the two walls are back to back.\n */\nexport interface Level {\n readonly schema: typeof LEVEL_SCHEMA;\n readonly name?: string | undefined;\n /** The unit of each length of the room record of the level. A survey can have a different unit. */\n readonly unit: LengthUnit;\n readonly rooms: readonly LevelRoom[];\n readonly connections?: readonly LevelConnection[] | undefined;\n /**\n * The records of each add-on for the level, by the name of its layer, for example the records of the whole apartment.\n * The anchors of such a layer are on the room record of the level, so they name a wall as `LevelResult.room` names it.\n * The survey of a room has the layers of that room.\n */\n readonly layers?: Readonly<Record<string, unknown>> | undefined;\n}\n\n/**\n * These are the sources of the place of a room.\n *\n * - `first`: the room is the first room of the level. It keeps the `start` and the `heading` of its survey.\n * - `connection`: a connection gives the place.\n * - `apart`: the room has no path of connections to a room before it, so its place is not known.\n */\nexport const ROOM_PLACES: readonly [\"first\", \"connection\", \"apart\"] = [\"first\", \"connection\", \"apart\"];\n\n/** A source of the place of a room. */\nexport type RoomPlace = (typeof ROOM_PLACES)[number];\n\n/** The result of one room of a level. */\nexport interface LevelRoomResult {\n /** The `id` of the room. */\n readonly id: string;\n readonly place: RoomPlace;\n /** The number of the group of the room, from 0. The rooms of one group have a path of connections between them. */\n readonly group: number;\n /**\n * The survey of the room in the unit of the level. Its `start` and its `heading` are the place of the room in the level.\n * It has no layers, because the layers of each room go to `LevelResult.layers`.\n */\n readonly survey: Survey;\n /** The expansion of that survey. Its `frame` moves an anchor of the room, in the unit of the level, to the room record of the level. */\n readonly result: SurveyResult;\n}\n\n/**\n * These are the uses of a connection.\n *\n * - `place`: the connection gives the place of a room.\n * - `check`: its two rooms have a place from other connections, so the connection examines the measurements.\n * - `none`: the connection has a fault, so the level does not use it.\n */\nexport const CONNECTION_USES: readonly [\"place\", \"check\", \"none\"] = [\"place\", \"check\", \"none\"];\n\n/** A use of a connection. */\nexport type ConnectionUse = (typeof CONNECTION_USES)[number];\n\n/**\n * These are the faults of a connection.\n *\n * - `room`: an end names a room that the level does not have.\n * - `opening`: an end names an opening that its room does not have, or the wall of the opening has no length.\n * - `one-room`: the two ends are in one room.\n */\nexport const CONNECTION_FAULTS: readonly [\"room\", \"opening\", \"one-room\"] = [\"room\", \"opening\", \"one-room\"];\n\n/** A fault of a connection. */\nexport type ConnectionFault = (typeof CONNECTION_FAULTS)[number];\n\n/** The result of one connection of a level. A connection with a fault has no numbers. */\nexport interface LevelConnectionResult {\n /** The `id` of the connection. */\n readonly id: string;\n readonly use: ConnectionUse;\n readonly fault?: ConnectionFault | undefined;\n /**\n * The distance between the two openings along the wall and through it, minus the thickness of the wall, in the unit of the level.\n * It is 0 for a connection that gives a place.\n */\n readonly gap: number | undefined;\n /** The gap as a part of the lengths of the walks of the two rooms. */\n readonly ratio: number | undefined;\n /** The angle between the two walls in degrees, from -180 to 180. Two walls that are back to back have 0. */\n readonly turn: number | undefined;\n /** The width of the opening of `to` minus the width of the opening of `from`, in the unit of the level. */\n readonly width: number | undefined;\n /** This value is true when the connection has no fault, its gap is in the limit, and its angle is `CONNECTION_TURN_LIMIT` or less. */\n readonly fits: boolean;\n}\n\n/** The result of the expansion of a level. */\nexport interface LevelResult {\n /**\n * One room record with each room of the level, in the unit of the level.\n * The `id` of a wall or an opening is the `id` of its room, then `/`, then its `id` in the survey.\n * Each closed room gives one floor with the `id` and the name of the room.\n */\n readonly room: Room;\n /** The result of each room, in the sequence of the rooms. */\n readonly rooms: readonly LevelRoomResult[];\n /** The result of each connection, in the sequence of the connections. */\n readonly connections: readonly LevelConnectionResult[];\n /**\n * The placed objects of each room, in the sequence of the rooms. The `id` of an object and of its parent\n * has the same form as the `id` of a wall. A scene record with the room record and these objects gives the model of the level.\n */\n readonly objects: readonly PlacedObject[];\n /**\n * The layers of the level on its room record. Each name has one layer, from the layer of the level and the layers of the rooms.\n * A level with no layers gives none. The function `join` of the add-on of each name makes the layer, as `joinLayers` tells.\n * A layer of a room is here only when an add-on of the options read it.\n */\n readonly layers?: Readonly<Record<string, unknown>> | undefined;\n /**\n * One finding or more for each layer of a room or of the level that is not in `layers`. A finding about a room has the `id` of the room.\n * The findings of the read of each room come first, in the sequence of the rooms. The findings of `joinLayers` follow.\n */\n readonly layerFindings: readonly LayerFinding[];\n}\n\n/** The options of the expansion of a level. */\nexport interface LevelOptions extends SurveyOptions {\n /** The distance between two groups of rooms, in the unit of the level. The default is 1 m. A value that is not a length of 0 or more gives the default. */\n readonly groupGap?: number | undefined;\n}\n\n/** This function gives a survey with no layers. */\nfunction withoutLayers(survey: Survey): Survey {\n const { layers, ...rest } = survey;\n return layers === undefined ? survey : rest;\n}\n\n/**\n * This function gives an anchor of a room with the names of the level. A wall and an object get the name that `roomName` gives.\n * The floor of a room has the `id` of the room in a level.\n */\nfunction inRoom(room: string, anchor: Anchor): Anchor {\n if (anchor.on === \"wall\") return { ...anchor, wall: roomName(room, anchor.wall) };\n if (anchor.on === \"object\") return { ...anchor, object: roomName(room, anchor.object) };\n if (anchor.floor === undefined) return anchor;\n return { ...anchor, floor: anchor.floor === SURVEY_FLOOR ? room : roomName(room, anchor.floor) };\n}\n\n/** The largest angle between the two walls of a connection that fits, in degrees. */\nexport const CONNECTION_TURN_LIMIT = 2;\n\n/** A length in meters at this value or less is 0 for the level. */\nconst SMALL = 1e-6;\n\n/** Two unit vectors with a cross product below this value are parallel. */\nconst PARALLEL = 1e-6;\n\n/** The number of steps of the grid of calculated lengths in one unit. The noise of float arithmetic is much smaller than one step. */\nconst GRID = 1e9;\n\n/** The place of a room in the level: the first corner of its walk, and the direction of its first side in degrees. */\ninterface Place {\n readonly start: PlanPoint;\n readonly heading: number;\n}\n\n/** An opening of a room, in the frame of its survey. The first corner is the origin, and the first side goes along the x axis. */\ninterface Hole {\n /** The position of the wall of the opening in the room record. */\n readonly wall: number;\n /** The center of the opening on the inner face of its wall. */\n readonly center: PlanPoint;\n /** The unit vector from the room through the wall. */\n readonly out: PlanPoint;\n readonly width: number;\n /** The thickness of the wall of the opening. */\n readonly thickness: number;\n}\n\n/** A connection with no fault: its two rooms as positions in the list of the rooms, and its two openings. */\ninterface Link {\n readonly from: number;\n readonly to: number;\n readonly fromHole: Hole;\n readonly toHole: Hole;\n /** The thickness of the wall at the hole. */\n readonly depth: number;\n}\n\n/** One wall of a room of the level, at its place. */\ninterface Face {\n readonly room: number;\n readonly wall: number;\n readonly from: PlanPoint;\n readonly to: PlanPoint;\n readonly along: PlanPoint;\n readonly out: PlanPoint;\n readonly length: number;\n readonly thickness: number;\n}\n\n/** This function gives the sum of two vectors of the plan. The second vector has a factor. */\nfunction plus(a: PlanPoint, b: PlanPoint, factor = 1): PlanPoint {\n return [a[0] + b[0] * factor, a[1] + b[1] * factor];\n}\n\n/** This function gives the dot product of two vectors of the plan. */\nfunction dot(a: PlanPoint, b: PlanPoint): number {\n return a[0] * b[0] + a[1] * b[1];\n}\n\n/** This function gives the cross product of two vectors of the plan. */\nfunction cross(a: PlanPoint, b: PlanPoint): number {\n return a[0] * b[1] - a[1] * b[0];\n}\n\n/**\n * This function gives a calculated length on the grid. It removes the noise of float arithmetic,\n * so a place of 0.1 does not become 0.10000000000000009 in a file.\n */\nfunction tidy(value: number): number {\n const steps = Math.round(value * GRID);\n // The sum with 0 changes -0 to 0.\n return Number.isSafeInteger(steps) ? steps / GRID + 0 : value;\n}\n\n/** This function gives a point of the frame of a room as a point of the level. */\nfunction placed(place: Place, point: PlanPoint): PlanPoint {\n return plus(place.start, turned(point, place.heading));\n}\n\n/** This function gives the unit vector along a wall and the unit vector from the room through the wall. A wall with no length has no vectors. */\nfunction vectorsOf(wall: Wall): { readonly along: PlanPoint; readonly out: PlanPoint; readonly length: number } | undefined {\n const dx = wall.to[0] - wall.from[0];\n const dy = wall.to[1] - wall.from[1];\n const length = Math.hypot(dx, dy);\n if (!(length > 0) || !Number.isFinite(length)) return undefined;\n const along: PlanPoint = [dx / length, dy / length];\n // The wall of a survey is on the outer side of its line.\n return { along, out: wall.side === \"left\" ? [0 - along[1], along[0]] : [along[1], 0 - along[0]], length };\n}\n\n/** This function gives an opening of a room in the frame of its survey. `own` is the expansion of the survey with no `start` and no `heading`. */\nfunction holeOf(own: SurveyResult, id: string, inRange: (value: number) => boolean): Hole | undefined {\n const opening = own.room.openings?.find((item) => item.id === id);\n if (opening === undefined || !inRange(opening.offset) || !inRange(opening.width)) return undefined;\n const wall = own.room.walls.findIndex((item) => item.id === opening.wall);\n const record = own.room.walls[wall];\n const vectors = record === undefined ? undefined : vectorsOf(record);\n if (record === undefined || vectors === undefined) return undefined;\n return {\n wall,\n center: plus(record.from, vectors.along, opening.offset + opening.width / 2),\n out: vectors.out,\n width: opening.width,\n thickness: record.thickness ?? own.room.wallThickness,\n };\n}\n\n/**\n * This function gives the place of a room from a connection to a room that has a place.\n * The two walls are back to back, and the centers of the two openings are opposite, at the distance `depth`.\n */\nfunction placeFrom(known: Place, knownHole: Hole, hole: Hole, depth: number): Place {\n const out = turned(knownHole.out, known.heading);\n const heading = squared(headingOf([0 - out[0], 0 - out[1]]) - headingOf(hole.out));\n const center = turned(hole.center, heading);\n const start = plus(plus(placed(known, knownHole.center), out, depth), center, -1);\n return { start: [tidy(start[0]), tidy(start[1])], heading };\n}\n\n/**\n * This function makes one room record from the rooms of a level.\n *\n * The first room keeps the `start` and the `heading` of its survey. The function goes from that room along the connections.\n * A connection to a room with no place gives the place of that room. The two walls are back to back, and the centers of the\n * two openings are opposite. The faces of the two walls are at the distance `thickness`.\n * A connection between two rooms that have a place examines the measurements: its `gap` and its `turn` tell a mistake.\n *\n * A room with no path of connections to a room before it starts a new group. Its place is not known,\n * so its group goes to the right of the groups before it. Thus a drawing of a level in progress shows each room.\n *\n * The survey of a room gives the thickness of each wall. Two rooms have one wall between them, so two walls that are\n * back to back share it. Each wall gets one half of the distance between the two faces.\n * This applies to the two walls of a connection, and to two walls that overlap.\n * A wall that is in part an outer wall gets the same thickness along its full length.\n *\n * The layers of each room go to the room record of the level in one change. The change has the unit of the level, the place of the room, then the names of the level.\n * Then the function `join` of each add-on gives one layer for the level. The layer of the level record comes first.\n *\n * `checkRoom` examines the room record. It tells when two rooms overlap.\n */\nexport function expandLevel(level: Level, options: LevelOptions = {}): LevelResult {\n const unit = level.unit;\n const scale = metersPer(unit);\n const inRange = (value: number): boolean => Number.isFinite(value) && Math.abs(value) * scale <= LARGEST_LENGTH;\n const size = (value: number | undefined): number | undefined => (value !== undefined && inRange(value) && value * scale > SMALL ? value : undefined);\n const count = level.rooms.length;\n // The layers of a room go to the level in one change after the places are known, so each survey of the walk has none.\n const surveys = level.rooms.map((room) => convertSurvey(withoutLayers(room.survey), unit));\n // Each room in the frame of its survey: the first corner is the origin, and the first side goes along the x axis.\n const owns = surveys.map((survey) => expandSurvey({ ...survey, start: undefined, heading: undefined }, options));\n\n const positionOf = new Map<string, number>();\n level.rooms.forEach((room, index) => {\n if (!positionOf.has(room.id)) positionOf.set(room.id, index);\n });\n\n const connections = level.connections ?? [];\n const faults: (ConnectionFault | undefined)[] = [];\n const links = connections.map((connection, index): Link | undefined => {\n const from = positionOf.get(connection.from.room);\n const to = positionOf.get(connection.to.room);\n if (from === undefined || to === undefined) {\n faults[index] = \"room\";\n return undefined;\n }\n if (from === to) {\n faults[index] = \"one-room\";\n return undefined;\n }\n const fromHole = holeOf(owns[from]!, connection.from.opening, inRange);\n const toHole = holeOf(owns[to]!, connection.to.opening, inRange);\n if (fromHole === undefined || toHole === undefined) {\n faults[index] = \"opening\";\n return undefined;\n }\n return { from, to, fromHole, toHole, depth: size(connection.thickness) ?? size(fromHole.thickness) ?? 0 };\n });\n\n // The place of each room: the function goes from the first room of each group along the connections.\n const places: Place[] = [];\n const sources: RoomPlace[] = [];\n const groups: number[] = [];\n const members: number[][] = [];\n const gives = new Set<number>();\n for (let root = 0; root < count; root++) {\n if (places[root] !== undefined) continue;\n const group = members.length;\n const survey = surveys[root]!;\n const heading = survey.heading !== undefined && Number.isFinite(survey.heading) ? survey.heading : 0;\n const start: PlanPoint = group === 0 && survey.start !== undefined && inRange(survey.start[0]) && inRange(survey.start[1]) ? survey.start : [0, 0];\n places[root] = { start, heading };\n sources[root] = group === 0 ? \"first\" : \"apart\";\n groups[root] = group;\n const queue = [root];\n for (let next = 0; next < queue.length; next++) {\n const known = queue[next]!;\n links.forEach((link, index) => {\n if (link === undefined) return;\n const forward = link.from === known;\n if (!forward && link.to !== known) return;\n const room = forward ? link.to : link.from;\n if (places[room] !== undefined) return;\n places[room] = placeFrom(places[known]!, forward ? link.fromHole : link.toHole, forward ? link.toHole : link.fromHole, link.depth);\n sources[room] = \"connection\";\n groups[room] = group;\n gives.add(index);\n queue.push(room);\n });\n }\n members.push(queue);\n }\n\n // A group with no known place goes to the right of the groups before it. The bottoms of the groups are on one line.\n const givenGap = options.groupGap;\n const groupGap = givenGap !== undefined && inRange(givenGap) && givenGap >= 0 ? givenGap : 1 / scale;\n let right: number | undefined;\n let base = 0;\n for (const [number, group] of members.entries()) {\n let low: PlanPoint | undefined;\n let high: PlanPoint | undefined;\n for (const room of group) {\n const survey = surveys[room]!;\n const margin = Math.max(0, ...[survey.wallThickness, ...survey.sides.map((side) => side.thickness)].map((value) => size(value) ?? 0));\n for (const point of [...owns[room]!.walk, ...owns[room]!.corners]) {\n const [x, y] = placed(places[room]!, point);\n low = low === undefined ? [x - margin, y - margin] : [Math.min(low[0], x - margin), Math.min(low[1], y - margin)];\n high = high === undefined ? [x + margin, y + margin] : [Math.max(high[0], x + margin), Math.max(high[1], y + margin)];\n }\n }\n if (low === undefined || high === undefined) continue;\n if (number === 0 || right === undefined) {\n right = right === undefined ? high[0] : Math.max(right, high[0]);\n if (number === 0) base = low[1];\n continue;\n }\n const move: PlanPoint = [right + groupGap - low[0], base - low[1]];\n for (const room of group) {\n const [x, y] = plus(places[room]!.start, move);\n places[room] = { start: [tidy(x), tidy(y)], heading: places[room]!.heading };\n }\n right = Math.max(right, high[0] + move[0]);\n }\n\n const rooms = level.rooms.map((room, index): LevelRoomResult => {\n const survey: Survey = { ...surveys[index]!, start: places[index]!.start, heading: places[index]!.heading };\n return { id: room.id, place: sources[index]!, group: groups[index]!, survey, result: expandSurvey(survey, options) };\n });\n\n // The measure of each connection, from the places of its two rooms.\n const givenLimit = options.limit ?? CLOSURE_LIMIT;\n const limit = Number.isFinite(givenLimit) && givenLimit >= 0 ? givenLimit : CLOSURE_LIMIT;\n const walkOf = (room: number): number => {\n const walk = owns[room]!.walk;\n return walk.reduce((sum, point, index) => (index === 0 ? 0 : sum + Math.hypot(point[0] - walk[index - 1]![0], point[1] - walk[index - 1]![1])), 0);\n };\n const results = connections.map((connection, index): LevelConnectionResult => {\n const link = links[index];\n if (link === undefined) return { id: connection.id, use: \"none\", fault: faults[index], gap: undefined, ratio: undefined, turn: undefined, width: undefined, fits: false };\n const width = link.toHole.width - link.fromHole.width;\n if (gives.has(index)) return { id: connection.id, use: \"place\", gap: 0, ratio: 0, turn: 0, width, fits: true };\n const from = places[link.from]!;\n const to = places[link.to]!;\n const out = turned(link.fromHole.out, from.heading);\n const back = turned(link.toHole.out, to.heading);\n const target = plus(placed(from, link.fromHole.center), out, link.depth);\n const center = placed(to, link.toHole.center);\n const miss = Math.hypot(center[0] - target[0], center[1] - target[1]);\n const walk = walkOf(link.from) + walkOf(link.to);\n const ratio = walk > 0 ? miss / walk : 0;\n const against: PlanPoint = [0 - out[0], 0 - out[1]];\n // The sum with 0 changes -0 to 0.\n const turn = (Math.atan2(cross(against, back), dot(against, back)) * 180) / Math.PI + 0;\n return { id: connection.id, use: \"check\", gap: miss, ratio, turn, width, fits: ratio <= limit && Math.abs(turn) <= CONNECTION_TURN_LIMIT };\n });\n\n // Each wall at its place. Two walls that are back to back share the wall between their rooms.\n const faces: Face[] = [];\n rooms.forEach(({ result }, room) => {\n result.room.walls.forEach((wall, index) => {\n const vectors = vectorsOf(wall);\n const thickness = size(wall.thickness ?? result.room.wallThickness);\n if (vectors === undefined || thickness === undefined) return;\n faces.push({ room, wall: index, from: wall.from, to: wall.to, along: vectors.along, out: vectors.out, length: vectors.length, thickness });\n });\n });\n const joined = new Set<string>();\n links.forEach((link, index) => {\n if (link === undefined || !results[index]!.fits) return;\n joined.add(`${link.from}:${link.fromHole.wall}:${link.to}:${link.toHole.wall}`);\n joined.add(`${link.to}:${link.toHole.wall}:${link.from}:${link.fromHole.wall}`);\n });\n const shared = new Map<string, number>();\n for (let i = 0; i < faces.length; i++) {\n for (let j = i + 1; j < faces.length; j++) {\n const a = faces[i]!;\n const b = faces[j]!;\n if (a.room === b.room || Math.abs(cross(a.along, b.along)) > PARALLEL || !(dot(a.out, b.out) < 0)) continue;\n const first: PlanPoint = [b.from[0] - a.from[0], b.from[1] - a.from[1]];\n const second: PlanPoint = [b.to[0] - a.from[0], b.to[1] - a.from[1]];\n const between = dot(first, a.out);\n const common = Math.min(a.length, Math.max(dot(first, a.along), dot(second, a.along))) - Math.max(0, Math.min(dot(first, a.along), dot(second, a.along)));\n if (!(between * scale > SMALL) || !(common * scale > SMALL)) continue;\n // The two walls of a connection are one wall. Two other walls are one wall when they overlap.\n if (!joined.has(`${a.room}:${a.wall}:${b.room}:${b.wall}`) && !((a.thickness + b.thickness - between) * scale > SMALL)) continue;\n const half = tidy(between / 2);\n for (const face of [a, b]) {\n const key = `${face.room}:${face.wall}`;\n shared.set(key, Math.min(shared.get(key) ?? Infinity, half));\n }\n }\n }\n\n const first = rooms[0]?.result.room;\n const height = first?.height ?? 1;\n const wallThickness = first?.wallThickness ?? 1;\n const walls: Wall[] = [];\n const openings: Opening[] = [];\n const floors: Floor[] = [];\n const objects: PlacedObject[] = [];\n rooms.forEach(({ id, survey, result }, room) => {\n const record = result.room;\n record.walls.forEach((wall, index) => {\n const thickness = shared.get(`${room}:${index}`) ?? wall.thickness ?? (record.wallThickness === wallThickness ? undefined : record.wallThickness);\n const tall = wall.height ?? (record.height === height ? undefined : record.height);\n walls.push({\n id: `${id}/${wall.id}`,\n from: wall.from,\n to: wall.to,\n ...(wall.side === undefined ? {} : { side: wall.side }),\n ...(thickness === undefined ? {} : { thickness }),\n ...(tall === undefined ? {} : { height: tall }),\n });\n });\n for (const opening of record.openings ?? []) openings.push({ ...opening, id: `${id}/${opening.id}`, wall: `${id}/${opening.wall}` });\n for (const floor of record.floors ?? []) floors.push({ id, ...(survey.name === undefined ? {} : { name: survey.name }), ring: floor.ring });\n for (const object of result.objects) {\n objects.push({\n ...object,\n id: `${id}/${object.id}`,\n ...(object.parent === undefined ? {} : { parent: `${id}/${object.parent}` }),\n });\n }\n });\n\n const room: Room = {\n schema: ROOM_SCHEMA,\n ...(level.name === undefined ? {} : { name: level.name }),\n unit,\n height,\n wallThickness,\n walls,\n ...(openings.length === 0 ? {} : { openings }),\n ...(floors.length === 0 ? {} : { floors }),\n };\n const addOns = options.addOns ?? [];\n const parts: RoomLayers[] = [];\n const findings: LayerFinding[] = [];\n rooms.forEach(({ id, result }, index) => {\n const given = level.rooms[index]?.survey;\n if (given?.layers === undefined) return;\n const factor = unitsPer(given.unit, unit);\n const moved = moveLayers(given.layers, addOns, (anchor) => inRoom(id, surveyAnchor(scaleAnchor(anchor, factor), result.frame)), id);\n parts.push({ room: id, layers: moved.layers });\n findings.push(...moved.findings);\n });\n const layers = level.layers === undefined && parts.length === 0 ? undefined : joinLayers(level.layers, parts, addOns);\n return {\n room,\n rooms,\n connections: results,\n objects,\n ...(layers === undefined ? {} : { layers: layers.layers }),\n layerFindings: layers === undefined ? findings : [...findings, ...layers.findings],\n };\n}\n"],"mappings":";;;AAYA,SAAgB,YAAY,SAA4B;CACtD,MAAM,QAAS,UAAA,MAAA,OAAA;CACf,IAAI,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC;CAC5B,IAAI,SAAA,IAAiB,OAAO,CAAC,GAAG,CAAC;CACjC,IAAI,SAAS,KAAY,OAAO,CAAC,IAAI,CAAC;CACtC,IAAI,SAAS,KAAY,OAAO,CAAC,GAAG,EAAE;CACtC,MAAM,QAAS,OAAO,KAAK,KAAM;CACjC,OAAO,CAAC,KAAK,IAAI,KAAK,GAAG,KAAK,IAAI,KAAK,CAAC;AAC1C;;AAGA,SAAgB,OAAO,CAAC,GAAG,IAAe,SAA4B;CACpE,MAAM,CAAC,KAAK,OAAO,YAAY,OAAO;CACtC,OAAO,CAAC,IAAI,MAAM,IAAI,KAAK,IAAI,MAAM,IAAI,GAAG;AAC9C;;;;;AAMA,SAAgB,UAAU,CAAC,GAAG,IAAuB;CACnD,OAAO,QAAS,KAAK,MAAM,GAAG,CAAC,IAAI,MAAO,KAAK,EAAE;AACnD;;AAGA,SAAgB,QAAQ,SAAyB;CAC/C,MAAM,QAAS,UAAA,MAAA,OAAA;CACf,MAAM,OAAO,KAAK,MAAM,OAAA,EAAa,IAAA;CACrC,OAAO,KAAK,IAAI,OAAO,IAAI,IAAA,OAAiB,OAAA,MAAc;AAC5D;;;ACxBA,MAAa,gBAAgB;;AAG7B,MAAa,eAA2C,CAAC,QAAQ,OAAO;;AAoLxE,MAAa,eAAe;;AAG5B,MAAa,gBAAgB;;;;;;;;;;AAmB7B,SAAgB,aAAa,QAAgB,OAA4B;CACvE,IAAI,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S;EAC5E,CAAC;CAEL,CAAC;CAED,MAAM,OAAa;EACjB,QAAQ;EACR,GAAI,MAAM,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,MAAM,KAAK;EACvD;EACA;EACA;EACA;EACA,GAAI,SAAS,WAAW,IAAI,CAAC,IAAI,EAAE,SAAS;EAC5C,GAAI,OAAO,WAAW,IAAI,CAAC,IAAI,EAAE,OAAO;CAC1C;CACA,MAAM,SAAS,QAAQ,UAAU,CAAC;CAClC,MAAM,QAAsB,CAAC;CAC7B,MAAM,WAA2B,CAAC;CAClC,MAAM,SAAS,EAAE,IAAI,UAAU,UAAU;EACvC,MAAM,QAAQ,MAAM,MAAM,MAAM,EAAE;EAClC,IAAI,OAAO,WAAW,KAAA,GAAW;EACjC,MAAM,SAAS,SAAS,MAAM,MAAM,IAAI;EACxC,MAAM,QAAQ,WAAW,MAAM,QAAQ,SAAS,WAAW,OAAO,IAAI,aAAa,YAAY,QAAQ,MAAM,GAAG,OAAO,KAAK,CAAC,GAAG,EAAE;EAClI,MAAM,KAAK;GAAE,MAAM;GAAI,QAAQ,MAAM;EAAO,CAAC;EAC7C,SAAS,KAAK,GAAG,MAAM,QAAQ;CACjC,CAAC;CACD,MAAM,SAAS,MAAM,WAAW,KAAA,KAAa,MAAM,WAAW,IAAI,KAAA,IAAY,WAAW,MAAM,QAAQ,OAAO,MAAM;CACpH,OAAO;EACL;EACA;EACA,aAAa;EACb;EACA,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,OAAO,OAAO;EACxD,eAAe,WAAW,KAAA,IAAY,WAAW,CAAC,GAAG,UAAU,GAAG,OAAO,QAAQ;CACnF;AACF"}
1
+ {"version":3,"file":"level-CvbiwvhH.js","names":[],"sources":["../src/direction.ts","../src/survey.ts","../src/level.ts"],"sourcesContent":["import type { PlanPoint } from \"./room.ts\";\n\n/** The turn at a square corner, in degrees. */\nexport const SQUARE = 90;\n\n/** One full turn, in degrees. */\nexport const FULL = 360;\n\n/** An angle with an error below this value is exact for the model, in degrees. The value is larger than the error of a sum of numbers. */\nexport const TURN_NOISE = 1e-9;\n\n/** This function gives the unit vector of a direction in degrees. A direction along an axis gives an exact vector. */\nexport function directionOf(degrees: number): PlanPoint {\n const turn = ((degrees % FULL) + FULL) % FULL;\n if (turn === 0) return [1, 0];\n if (turn === SQUARE) return [0, 1];\n if (turn === 2 * SQUARE) return [-1, 0];\n if (turn === 3 * SQUARE) return [0, -1];\n const angle = (turn * Math.PI) / 180;\n return [Math.cos(angle), Math.sin(angle)];\n}\n\n/** This function turns a vector of the plan by an angle in degrees, counter-clockwise. A turn by 90, 180 or 270 degrees is exact. */\nexport function turned([x, y]: PlanPoint, degrees: number): PlanPoint {\n const [cos, sin] = directionOf(degrees);\n return [x * cos - y * sin, x * sin + y * cos];\n}\n\n/**\n * This function gives the direction of a vector in degrees, from 0 to 360, counter-clockwise from the x axis.\n * A direction near 0, 90, 180 or 270 degrees becomes that value, so a room with square corners keeps exact numbers.\n */\nexport function headingOf([x, y]: PlanPoint): number {\n return squared((Math.atan2(y, x) * 180) / Math.PI);\n}\n\n/** This function gives an angle in degrees from 0 to 360. An angle near 0, 90, 180 or 270 degrees becomes that value. */\nexport function squared(degrees: number): number {\n const turn = ((degrees % FULL) + FULL) % FULL;\n const near = Math.round(turn / SQUARE) * SQUARE;\n return Math.abs(turn - near) < TURN_NOISE ? near % FULL : turn;\n}\n","import { scaleAnchor, type Anchor } from \"./anchors.ts\";\nimport { directionOf, FULL, headingOf, SQUARE, TURN_NOISE } from \"./direction.ts\";\nimport { moveLayers, type AddOn, type LayerFinding } from \"./layers.ts\";\nimport {\n ROOM_SCHEMA,\n SCENE_SCHEMA,\n type Opening,\n type PlacedObject,\n type PlanPoint,\n type Room,\n type Scene,\n type Wall,\n type WallFace,\n} from \"./room.ts\";\nimport { LARGEST_LENGTH, metersPer, unitsPer, type LengthUnit } from \"./units.ts\";\n\n/** The name of the format of a survey record. */\nexport const SURVEY_SCHEMA = \"survey/2\";\n\n/** These are the names of the turns at a square corner. */\nexport const SQUARE_TURNS: readonly [\"left\", \"right\"] = [\"left\", \"right\"];\n\n/**\n * The turn of the person at the end of a side, to the direction of the next side.\n *\n * `left` and `right` are the turns at a square corner: 90 degrees. They are exact.\n * A number is a measured angle in degrees, from -360 to 360, and a turn to the left is positive.\n */\nexport type SurveyTurn = (typeof SQUARE_TURNS)[number] | number;\n\n/** One side of a survey: the inner face of one wall, from a corner to the next corner. */\nexport interface SurveySide {\n /** The `id` of the wall of the side. */\n readonly id: string;\n /** The length of the inner face, from corner to corner. */\n readonly length: number;\n /** The turn at the end of the side. */\n readonly turn: SurveyTurn;\n /** The thickness of the wall. The default is `wallThickness` of the survey. */\n readonly thickness?: number | undefined;\n /** The height of the wall. The default is `height` of the survey. */\n readonly height?: number | undefined;\n}\n\n/** A measured distance between two corners of a survey, for example a diagonal of the room. It examines the walk. */\nexport interface SurveyCheck {\n readonly id: string;\n /** The `id` of a side. The first corner is the corner at the start of that side. */\n readonly from: string;\n /** The `id` of a side. The second corner is the corner at the start of that side. */\n readonly to: string;\n /** The measured distance between the two corners. */\n readonly length: number;\n}\n\n/**\n * An object of a survey: a box that a person measures from a side, for example a desk, a shelf or a rack.\n *\n * The back of the object is parallel to the inner face of the side. The person measures along the face to the near edge of the object,\n * and out from the face to its back. The near edge is the edge that is nearest to the first corner of the side.\n * Thus the record has no coordinate.\n *\n * An object with `on` is on a different object or in it, for example a display on a desk or a computer in a rack.\n * Then the person measures from the near edge and from the back of that object, which is the holder.\n * An object has `wall` or `on`. When it has the two, `on` applies.\n */\nexport interface SurveyObject {\n readonly id: string;\n /** The class of the object, for example `desk`, `rack` or `computer`. A viewer gives each class a color. */\n readonly kind: string;\n readonly name?: string | undefined;\n /** The `id` of the side. */\n readonly wall?: string | undefined;\n /** The `id` of the holder. The first object with the `id` applies. */\n readonly on?: string | undefined;\n /**\n * The distance along the inner face, from the first corner of the side to the near edge of the object.\n * With `on`, this is the distance from the near edge of the holder to the near edge of the object.\n */\n readonly offset: number;\n /** The size of the object along the wall. */\n readonly width: number;\n /** The size of the object out from the wall. */\n readonly depth: number;\n readonly height: number;\n /**\n * The distance from the inner face to the back of the object. With `on`, this is the distance from the back of the holder.\n * The default is 0: the object touches the wall, or its back is level with the back of the holder.\n */\n readonly gap?: number | undefined;\n /**\n * The height of the bottom of the object above the floor. The default is 0.\n * With `on`, this is the height above the bottom of the holder. Then the default is the height of the holder: the object is on its top.\n */\n readonly lift?: number | undefined;\n}\n\n/**\n * A survey: the measurements of one room by a person with a tape measure.\n *\n * The person goes around the room along the inner faces of the walls, in one direction.\n * Each side has the length of one face, and the turn at its end. The last turn gives the direction of the first side again.\n * An opening and an object name their side in `wall`. Their `offset` starts at the first corner of that side.\n */\nexport interface Survey {\n readonly schema: typeof SURVEY_SCHEMA;\n readonly name?: string | undefined;\n /** The unit of each length of the record. */\n readonly unit: LengthUnit;\n /** The height of each wall that has no height of its own. */\n readonly height: number;\n /** The thickness of each wall that has no thickness of its own. */\n readonly wallThickness: number;\n /** The sides, in the sequence of the walk. */\n readonly sides: readonly SurveySide[];\n /** The place of the first corner in the plan. The default is the origin. */\n readonly start?: PlanPoint | undefined;\n /** The direction of the first side, in degrees counter-clockwise from the x axis. The default is 0. */\n readonly heading?: number | undefined;\n readonly checks?: readonly SurveyCheck[] | undefined;\n readonly openings?: readonly Opening[] | undefined;\n readonly objects?: readonly SurveyObject[] | undefined;\n /**\n * The records of each add-on, by the name of its layer, for example `electrical/1`. A layer has the format of a layer of a scene.\n * Its anchors are in the space of the survey: they name the sides and the objects of the survey. `surveyAnchor` tells that space.\n * `expandSurvey` moves the anchors to the room record. The core keeps each layer, and it does not read one.\n */\n readonly layers?: Readonly<Record<string, unknown>> | undefined;\n}\n\n/**\n * The place of the walk of a survey in its room record. `surveyAnchor` moves an anchor of the survey with it.\n * The record is plain data, so it goes through JSON with no change.\n */\nexport interface SurveyFrame {\n /** The face of each wall that is in the room: `left` for a walk to the left, and `right` for a walk to the right. */\n readonly face: WallFace;\n /** The place of the first corner in the plan. */\n readonly start: PlanPoint;\n /** The direction of the first side, in degrees counter-clockwise from the x axis. */\n readonly heading: number;\n /**\n * The factor of the length of each side that shares the gap, by the `id` of the side. A factor is the length of the wall as a part of the measured length.\n * A side with no factor keeps its length.\n */\n readonly factors: Readonly<Record<string, number>>;\n}\n\n/** The closure of a survey: the difference between the end of the walk and its start. */\nexport interface SurveyClosure {\n /** The distance from the end of the last side to the first corner, in the unit of the survey. */\n readonly gap: number;\n /** The gap as a part of the length of the walk. A walk with no length has 0. */\n readonly ratio: number;\n /** The sum of the turns minus one full turn in the direction of the walk, in degrees. */\n readonly turn: number;\n /** This value is true when the walk has 3 sides or more, its turns make one full turn, and its gap is in the limit. */\n readonly closed: boolean;\n}\n\n/** The result of one check of a survey. */\nexport interface SurveyCheckResult {\n /** The `id` of the check. */\n readonly id: string;\n /** The measured distance, in the unit of the survey. */\n readonly measured: number;\n /** The distance between the two corners in the room record. A check with a side that the survey does not have gets `undefined`. */\n readonly model: number | undefined;\n /** The measured distance minus the distance in the room record. */\n readonly difference: number | undefined;\n}\n\n/** The result of the expansion of a survey. */\nexport interface SurveyResult {\n /** The room record of the survey. */\n readonly room: Room;\n /** The corner at the start of each side, as the room record has it. */\n readonly corners: readonly PlanPoint[];\n /** The points of the walk before the correction of the gap. The walk has one point more than the survey has sides. */\n readonly walk: readonly PlanPoint[];\n readonly closure: SurveyClosure;\n /** The result of each check, in the sequence of the checks. */\n readonly checks: readonly SurveyCheckResult[];\n /**\n * The placed object of each object of the survey that has a place, in the sequence of the survey.\n * A scene record with the room record and these objects gives the model of the room with its objects.\n */\n readonly objects: readonly PlacedObject[];\n /** The place of the walk in the room record. */\n readonly frame: SurveyFrame;\n /**\n * The layers of the survey with their anchors on the room record. A survey with no layers gives none.\n * A layer is here only when an add-on of the options read it. The anchors of a different layer are in the space of the survey.\n */\n readonly layers?: Readonly<Record<string, unknown>> | undefined;\n /** One finding or more for each layer of the survey that is not in `layers`. `moveLayers` tells the codes. */\n readonly layerFindings: readonly LayerFinding[];\n}\n\n/** The `id` of the floor of the room record of a closed survey. */\nexport const SURVEY_FLOOR = \"floor\";\n\n/** The default limit of the gap of a closed walk, as a part of the length of the walk. */\nexport const CLOSURE_LIMIT = 0.01;\n\n/** The options of the expansion of a survey. */\nexport interface SurveyOptions {\n /** The largest gap of a closed walk, as a part of the length of the walk. The default is `CLOSURE_LIMIT`. */\n readonly limit?: number | undefined;\n /** The add-ons that read the layers of the survey. The default is no add-on, and then the result has no layer. */\n readonly addOns?: readonly AddOn<unknown>[] | undefined;\n}\n\n/**\n * This function gives an anchor of a survey on the room record of the survey. `frame` comes from the result of `expandSurvey`.\n *\n * - An anchor on a wall names a side. Its `offset` starts at the first corner of the side and goes along the inner face.\n * The result is on the face in the room, and its `offset` changes in the proportion of the side, as an opening does. Its `face` in the survey has no effect.\n * - A point of an anchor on the floor or on the ceiling is in the frame of the walk. The first corner is the origin, and the first side goes along the x axis.\n * The result is at its place in the plan. The correction of the gap does not move the point.\n * - An anchor on an object stays, because a placed object keeps the `id` and the frame of its object in the survey.\n */\nexport function surveyAnchor(anchor: Anchor, frame: SurveyFrame): Anchor {\n if (anchor.on === \"object\") return anchor;\n if (anchor.on === \"wall\") {\n const factor = Object.hasOwn(frame.factors, anchor.wall) ? (frame.factors[anchor.wall] ?? 1) : 1;\n return { ...anchor, face: frame.face, offset: anchor.offset * factor };\n }\n const [cos, sin] = directionOf(frame.heading);\n const [x, y] = anchor.at;\n return { ...anchor, at: [frame.start[0] + (x * cos - y * sin), frame.start[1] + (x * sin + y * cos)] };\n}\n\n/**\n * This function gives the scene record of the result of `expandSurvey` or of `expandLevel`: the room record, the placed objects and the layers.\n * The scene has the name of the room record. `checkScene` and `checkLayers` examine it.\n */\nexport function resultScene(result: { readonly room: Room; readonly objects: readonly PlacedObject[]; readonly layers?: Readonly<Record<string, unknown>> | undefined }): Scene {\n return {\n schema: SCENE_SCHEMA,\n ...(result.room.name === undefined ? {} : { name: result.room.name }),\n room: result.room,\n objects: result.objects,\n ...(result.layers === undefined ? {} : { layers: result.layers }),\n };\n}\n\n/** This function tells if a turn is a measured angle: an angle from -360 degrees to 360 degrees. */\nfunction isMeasured(turn: SurveyTurn): turn is number {\n return typeof turn === \"number\" && Math.abs(turn) <= FULL;\n}\n\n/** This function gives a turn in degrees. A turn that is not a square turn or a measured angle is 0. */\nfunction degreesOf(turn: SurveyTurn): number {\n if (turn === \"left\") return SQUARE;\n if (turn === \"right\") return 0 - SQUARE;\n return isMeasured(turn) ? turn : 0;\n}\n\n/**\n * This function gives a survey in a different unit. Each length of the record changes, and each angle stays.\n * A survey that has the unit already is the result.\n *\n * The anchors of a layer change through the add-on of the layer in `addOns`. An add-on keeps each different length of its layer in a fixed unit.\n * The result has only the layers that an add-on of the list reads, because the anchors of a different layer stay in the old unit.\n * `moveLayers` with `scaleAnchor` gives a finding for each layer that the result does not have.\n */\nexport function convertSurvey(survey: Survey, unit: LengthUnit, addOns: readonly AddOn<unknown>[] = []): Survey {\n if (survey.unit === unit) return survey;\n const factor = unitsPer(survey.unit, unit);\n const to = (value: number): number => value * factor;\n const start: PlanPoint | undefined = survey.start === undefined ? undefined : [to(survey.start[0]), to(survey.start[1])];\n const layers = survey.layers === undefined ? undefined : moveLayers(survey.layers, addOns, (anchor) => scaleAnchor(anchor, factor)).layers;\n return {\n ...survey,\n unit,\n ...(layers === undefined ? {} : { layers }),\n height: to(survey.height),\n wallThickness: to(survey.wallThickness),\n sides: survey.sides.map((side) => ({\n ...side,\n length: to(side.length),\n ...(side.thickness === undefined ? {} : { thickness: to(side.thickness) }),\n ...(side.height === undefined ? {} : { height: to(side.height) }),\n })),\n ...(start === undefined ? {} : { start }),\n ...(survey.checks === undefined ? {} : { checks: survey.checks.map((check) => ({ ...check, length: to(check.length) })) }),\n ...(survey.openings === undefined\n ? {}\n : {\n openings: survey.openings.map((opening) => ({\n ...opening,\n offset: to(opening.offset),\n width: to(opening.width),\n ...(opening.sill === undefined ? {} : { sill: to(opening.sill) }),\n height: to(opening.height),\n })),\n }),\n ...(survey.objects === undefined\n ? {}\n : {\n objects: survey.objects.map((object) => ({\n ...object,\n offset: to(object.offset),\n width: to(object.width),\n depth: to(object.depth),\n height: to(object.height),\n ...(object.gap === undefined ? {} : { gap: to(object.gap) }),\n ...(object.lift === undefined ? {} : { lift: to(object.lift) }),\n })),\n }),\n };\n}\n\n/**\n * This function makes the room record of a survey.\n *\n * The walk starts at `start` in the direction `heading`. Each side adds its length, and then the person turns.\n * A length that is not a finite number above 0, or is not in the range of the model, counts as 0.\n * A turn that is not a number from -360 to 360 counts as 0. Thus each number of the result is finite.\n *\n * A measured length has an error, so the walk does not end exactly at its start. The function corrects the two errors of a walk:\n *\n * 1. When the sum of the turns has an error below 45 degrees, each measured turn gets an equal part of the error.\n * The turns `left` and `right` are exact, so they do not change. A larger error is a mistake, for example a wrong turn.\n * 2. When the walk is closed, the sides share the gap. Along each axis of the first side, each side changes in proportion to its length along that axis.\n * This is the transit rule of land survey. A side along an axis stays along that axis, so a room with square corners keeps them.\n * Then the last wall ends exactly at the first corner, and the room gets a floor.\n *\n * An opening keeps its place on a side that changes its length: its `offset` and its `width` change in the same proportion.\n * Thus an opening that fits in its measured side fits in its wall, and two openings that do not overlap stay apart.\n *\n * An object keeps its size on a side that changes its length. It moves by a part of that change: its place in the free length of the side.\n * Thus an object that touches a corner continues to touch it. The x axis of a placed object goes along its wall,\n * and its y axis points into the room. An object with a holder has the holder as its parent, and its place is relative to the holder.\n *\n * Some objects have no place, and the result does not have them. A side that is not in the survey or has no length gives no place.\n * A holder with no place gives no place. A size that is not a finite number above 0 gives no place.\n * A distance that is not in the range of the model gives no place.\n *\n * A walk that is not closed gets no correction of the gap: its walls follow the walk, and the room has no floor.\n * Thus the record of a survey in progress shows the walls that the person measured.\n *\n * The wall of each side is on the outer side of its line. Thus each `offset` of the survey is a distance along the inner face.\n * `checkRoom` examines the room record.\n */\nexport function expandSurvey(survey: Survey, options: SurveyOptions = {}): SurveyResult {\n const scale = metersPer(survey.unit);\n const inRange = (value: number): boolean => Number.isFinite(value) && Math.abs(value) * scale <= LARGEST_LENGTH;\n const sides = survey.sides;\n const count = sides.length;\n const lengths = sides.map((side) => (side.length > 0 && inRange(side.length) ? side.length : 0));\n const turns = sides.map((side) => degreesOf(side.turn));\n const total = lengths.reduce((sum, length) => sum + length, 0);\n\n const sum = turns.reduce((all, turn) => all + turn, 0);\n const toLeft = sum >= 0;\n const error = sum - (toLeft ? FULL : 0 - FULL);\n const measured = sides.filter((side) => isMeasured(side.turn)).length;\n const corrected = measured > 0 && Math.abs(error) < SQUARE / 2;\n const share = corrected ? error / measured : 0;\n\n // The walk in its own frame: the first corner is the origin, and the first side goes along the x axis.\n let direction = 0;\n const steps = sides.map((side, index): PlanPoint => {\n const [dx, dy] = directionOf(direction);\n direction += turns[index]! - (isMeasured(side.turn) ? share : 0);\n return [dx * lengths[index]!, dy * lengths[index]!];\n });\n const points: PlanPoint[] = [[0, 0]];\n steps.forEach(([dx, dy], index) => {\n const [x, y] = points[index]!;\n points.push([x + dx, y + dy]);\n });\n\n const [gapX, gapY] = points[count]!;\n const gap = Math.hypot(gapX, gapY);\n const ratio = total > 0 ? gap / total : 0;\n const given = options.limit ?? CLOSURE_LIMIT;\n const limit = Number.isFinite(given) && given >= 0 ? given : CLOSURE_LIMIT;\n const closed = count >= 3 && total > 0 && (corrected || Math.abs(error) < TURN_NOISE) && ratio <= limit;\n\n // The transit rule: along each axis, a corner moves against the gap by the part of the movement before it.\n const moveX = steps.reduce((all, [dx]) => all + Math.abs(dx), 0);\n const moveY = steps.reduce((all, [, dy]) => all + Math.abs(dy), 0);\n let beforeX = 0;\n let beforeY = 0;\n const adjusted = steps.map(([dx, dy], index): PlanPoint => {\n const [x, y] = points[index]!;\n const partX = closed && moveX > 0 ? beforeX / moveX : 0;\n const partY = closed && moveY > 0 ? beforeY / moveY : 0;\n beforeX += Math.abs(dx);\n beforeY += Math.abs(dy);\n return [x - partX * gapX, y - partY * gapY];\n });\n\n // The frame of the walk goes to its place in the plan.\n const start: PlanPoint = survey.start !== undefined && inRange(survey.start[0]) && inRange(survey.start[1]) ? survey.start : [0, 0];\n const heading = survey.heading !== undefined && Number.isFinite(survey.heading) ? survey.heading : 0;\n const [cos, sin] = directionOf(heading);\n const place = ([x, y]: PlanPoint): PlanPoint => [start[0] + (x * cos - y * sin), start[1] + (x * sin + y * cos)];\n const walk = points.map(place);\n const corners = adjusted.map(place);\n\n const walls = sides.map((side, index): Wall => {\n const to = closed ? corners[(index + 1) % count]! : walk[index + 1]!;\n return {\n id: side.id,\n from: corners[index]!,\n to,\n side: toLeft ? \"right\" : \"left\",\n ...(side.thickness === undefined ? {} : { thickness: side.thickness }),\n ...(side.height === undefined ? {} : { height: side.height }),\n };\n });\n\n const cornerOf = new Map<string, PlanPoint>();\n sides.forEach((side, index) => {\n if (!cornerOf.has(side.id)) cornerOf.set(side.id, corners[index]!);\n });\n const checks = (survey.checks ?? []).map((check): SurveyCheckResult => {\n const from = cornerOf.get(check.from);\n const to = cornerOf.get(check.to);\n const model = from === undefined || to === undefined ? undefined : Math.hypot(to[0] - from[0], to[1] - from[1]);\n return { id: check.id, measured: check.length, model, difference: model === undefined ? undefined : check.length - model };\n });\n\n // A side that shares the gap changes its length. The length of its wall, as a part of the measured length, is the factor of the side.\n const shared = closed && gap > 0;\n const factorOf = new Map<string, number>();\n sides.forEach((side, index) => {\n if (!shared || factorOf.has(side.id) || !(lengths[index]! > 0)) return;\n const { from, to } = walls[index]!;\n factorOf.set(side.id, Math.hypot(to[0] - from[0], to[1] - from[1]) / lengths[index]!);\n });\n const openings = survey.openings?.map((opening): Opening => {\n const factor = factorOf.get(opening.wall) ?? 1;\n return factor === 1 ? opening : { ...opening, offset: opening.offset * factor, width: opening.width * factor };\n });\n\n const face = toLeft ? \"left\" : \"right\";\n const room: Room = {\n schema: ROOM_SCHEMA,\n ...(survey.name === undefined ? {} : { name: survey.name }),\n unit: survey.unit,\n height: survey.height,\n wallThickness: survey.wallThickness,\n walls,\n // A walk with no shared gap keeps the list of the survey.\n ...(survey.openings === undefined || openings === undefined ? {} : { openings: shared ? openings : survey.openings }),\n // A floor has a counter-clockwise outline.\n ...(closed ? { floors: [{ id: SURVEY_FLOOR, ...(survey.name === undefined ? {} : { name: survey.name }), ring: toLeft ? corners : [...corners].reverse() }] } : {}),\n };\n\n const sideOf = new Map<string, number>();\n sides.forEach((side, index) => {\n if (!sideOf.has(side.id)) sideOf.set(side.id, index);\n });\n const listed = new Map<string, SurveyObject>();\n for (const object of survey.objects ?? []) if (!listed.has(object.id)) listed.set(object.id, object);\n const places = new Map<SurveyObject, PlacedObject | undefined>();\n const placeOf = (object: SurveyObject): PlacedObject | undefined => {\n if (places.has(object)) return places.get(object);\n // An object in a ring of objects that hold one another finds itself here. Thus it has no place.\n places.set(object, undefined);\n const made = placed(object);\n places.set(object, made);\n return made;\n };\n const placed = (object: SurveyObject): PlacedObject | undefined => {\n const out = object.gap ?? 0;\n if (![object.width, object.depth, object.height].every((size) => size > 0 && inRange(size))) return undefined;\n if (![object.offset, out, object.lift ?? 0].every(inRange)) return undefined;\n const record = {\n id: object.id,\n kind: object.kind,\n ...(object.name === undefined ? {} : { name: object.name }),\n size: [object.width, object.depth, object.height] as const,\n };\n if (object.on !== undefined) {\n const holder = listed.get(object.on);\n if (holder === undefined || placeOf(holder) === undefined) return undefined;\n // The x axis of the holder goes along its side for a walk to the left, and against its side for a walk to the right.\n const x = object.offset + object.width / 2 - holder.width / 2;\n return { ...record, at: [toLeft ? x : 0 - x, out + object.depth / 2 - holder.depth / 2], lift: object.lift ?? holder.height, parent: holder.id };\n }\n const index = object.wall === undefined ? undefined : sideOf.get(object.wall);\n if (index === undefined) return undefined;\n const { from, to } = walls[index]!;\n const measure = lengths[index]!;\n const line = Math.hypot(to[0] - from[0], to[1] - from[1]);\n if (!(line > 0) || !(measure > 0)) return undefined;\n // The object keeps its size, so it moves by a part of the change of the length of its side.\n // The part is the place of the object in the free length of the side. An object that is longer than its side has no free length,\n // so the part is its place in the full length, as for an opening.\n const free = measure - object.width;\n const part = Math.min(1, Math.max(0, object.offset / (free > 0 ? free : measure)));\n const near = shared ? object.offset + (line - measure) * part : object.offset;\n const along: PlanPoint = [(to[0] - from[0]) / line, (to[1] - from[1]) / line];\n // The room is on the left of each side of a walk to the left, and on the right of each side of a walk to the right.\n const inward: PlanPoint = toLeft ? [0 - along[1], along[0]] : [along[1], 0 - along[0]];\n const a = near + object.width / 2;\n const b = out + object.depth / 2;\n // The y axis of the object is on the left of its x axis, so the x axis of a walk to the right goes against the side.\n const turn = headingOf(toLeft ? along : [0 - along[0], 0 - along[1]]);\n return {\n ...record,\n at: [from[0] + along[0] * a + inward[0] * b, from[1] + along[1] * a + inward[1] * b],\n ...(object.lift === undefined ? {} : { lift: object.lift }),\n ...(turn === 0 ? {} : { turn }),\n };\n };\n const objects = (survey.objects ?? []).flatMap((object) => {\n const made = placeOf(object);\n return made === undefined ? [] : [made];\n });\n // The layers go to the room record with the frame of the walk. A layer that no add-on reads stays in the survey.\n const frame: SurveyFrame = { face, start, heading, factors: Object.fromEntries(factorOf) };\n const moved = survey.layers === undefined ? undefined : moveLayers(survey.layers, options.addOns ?? [], (anchor) => surveyAnchor(anchor, frame));\n return {\n room,\n corners,\n walk,\n closure: { gap, ratio, turn: error, closed },\n checks,\n objects,\n frame,\n ...(moved === undefined ? {} : { layers: moved.layers }),\n layerFindings: moved?.findings ?? [],\n };\n}\n","import { scaleAnchor, type Anchor } from \"./anchors.ts\";\nimport { headingOf, squared, turned } from \"./direction.ts\";\nimport { joinLayers, moveLayers, roomName, type LayerFinding, type RoomLayers } from \"./layers.ts\";\nimport { ROOM_SCHEMA, type Floor, type Opening, type PlacedObject, type PlanPoint, type Room, type Wall } from \"./room.ts\";\nimport { CLOSURE_LIMIT, convertSurvey, expandSurvey, surveyAnchor, SURVEY_FLOOR, type Survey, type SurveyOptions, type SurveyResult } from \"./survey.ts\";\nimport { LARGEST_LENGTH, metersPer, unitsPer, type LengthUnit } from \"./units.ts\";\n\n/** The name of the format of a level record. */\nexport const LEVEL_SCHEMA = \"level/2\";\n\n/** One room of a level: the survey of the room, with an `id`. */\nexport interface LevelRoom {\n readonly id: string;\n readonly survey: Survey;\n}\n\n/** One end of a connection: an opening of a room of the level. */\nexport interface ConnectionEnd {\n /** The `id` of the room. */\n readonly room: string;\n /** The `id` of the opening in the survey of that room. */\n readonly opening: string;\n}\n\n/**\n * A connection: one hole through the wall between two rooms, for example a door.\n * A person measures the hole in each room, so the survey of each room has it as an opening.\n */\nexport interface LevelConnection {\n readonly id: string;\n readonly from: ConnectionEnd;\n readonly to: ConnectionEnd;\n /**\n * The thickness of the wall at the hole: the distance between the faces of the wall in the two rooms.\n * A person measures it in the frame of a door. The default is the thickness of the wall of `from`.\n */\n readonly thickness?: number | undefined;\n}\n\n/**\n * A level: the rooms of one level of a building, for example the rooms of an apartment.\n *\n * Each room has its own survey, so each room has its own first corner and its own first direction.\n * A connection gives the place of a room: its two openings are one hole, so the two walls are back to back.\n */\nexport interface Level {\n readonly schema: typeof LEVEL_SCHEMA;\n readonly name?: string | undefined;\n /** The unit of each length of the room record of the level. A survey can have a different unit. */\n readonly unit: LengthUnit;\n readonly rooms: readonly LevelRoom[];\n readonly connections?: readonly LevelConnection[] | undefined;\n /**\n * The records of each add-on for the level, by the name of its layer, for example the records of the whole apartment.\n * The anchors of such a layer are on the room record of the level, so they name a wall as `LevelResult.room` names it.\n * The survey of a room has the layers of that room.\n */\n readonly layers?: Readonly<Record<string, unknown>> | undefined;\n}\n\n/**\n * These are the sources of the place of a room.\n *\n * - `first`: the room is the first room of the level. It keeps the `start` and the `heading` of its survey.\n * - `connection`: a connection gives the place.\n * - `apart`: the room has no path of connections to a room before it, so its place is not known.\n */\nexport const ROOM_PLACES: readonly [\"first\", \"connection\", \"apart\"] = [\"first\", \"connection\", \"apart\"];\n\n/** A source of the place of a room. */\nexport type RoomPlace = (typeof ROOM_PLACES)[number];\n\n/** The result of one room of a level. */\nexport interface LevelRoomResult {\n /** The `id` of the room. */\n readonly id: string;\n readonly place: RoomPlace;\n /** The number of the group of the room, from 0. The rooms of one group have a path of connections between them. */\n readonly group: number;\n /**\n * The survey of the room in the unit of the level. Its `start` and its `heading` are the place of the room in the level.\n * It has no layers, because the layers of each room go to `LevelResult.layers`.\n */\n readonly survey: Survey;\n /** The expansion of that survey. Its `frame` moves an anchor of the room, in the unit of the level, to the room record of the level. */\n readonly result: SurveyResult;\n}\n\n/**\n * These are the uses of a connection.\n *\n * - `place`: the connection gives the place of a room.\n * - `check`: its two rooms have a place from other connections, so the connection examines the measurements.\n * - `none`: the connection has a fault, so the level does not use it.\n */\nexport const CONNECTION_USES: readonly [\"place\", \"check\", \"none\"] = [\"place\", \"check\", \"none\"];\n\n/** A use of a connection. */\nexport type ConnectionUse = (typeof CONNECTION_USES)[number];\n\n/**\n * These are the faults of a connection.\n *\n * - `room`: an end names a room that the level does not have.\n * - `opening`: an end names an opening that its room does not have, or the wall of the opening has no length.\n * - `one-room`: the two ends are in one room.\n */\nexport const CONNECTION_FAULTS: readonly [\"room\", \"opening\", \"one-room\"] = [\"room\", \"opening\", \"one-room\"];\n\n/** A fault of a connection. */\nexport type ConnectionFault = (typeof CONNECTION_FAULTS)[number];\n\n/** The result of one connection of a level. A connection with a fault has no numbers. */\nexport interface LevelConnectionResult {\n /** The `id` of the connection. */\n readonly id: string;\n readonly use: ConnectionUse;\n readonly fault?: ConnectionFault | undefined;\n /**\n * The distance between the two openings along the wall and through it, minus the thickness of the wall, in the unit of the level.\n * It is 0 for a connection that gives a place.\n */\n readonly gap: number | undefined;\n /** The gap as a part of the lengths of the walks of the two rooms. */\n readonly ratio: number | undefined;\n /** The angle between the two walls in degrees, from -180 to 180. Two walls that are back to back have 0. */\n readonly turn: number | undefined;\n /** The width of the opening of `to` minus the width of the opening of `from`, in the unit of the level. */\n readonly width: number | undefined;\n /** This value is true when the connection has no fault, its gap is in the limit, and its angle is `CONNECTION_TURN_LIMIT` or less. */\n readonly fits: boolean;\n}\n\n/** The result of the expansion of a level. */\nexport interface LevelResult {\n /**\n * One room record with each room of the level, in the unit of the level.\n * The `id` of a wall or an opening is the `id` of its room, then `/`, then its `id` in the survey.\n * Each closed room gives one floor with the `id` and the name of the room.\n */\n readonly room: Room;\n /** The result of each room, in the sequence of the rooms. */\n readonly rooms: readonly LevelRoomResult[];\n /** The result of each connection, in the sequence of the connections. */\n readonly connections: readonly LevelConnectionResult[];\n /**\n * The placed objects of each room, in the sequence of the rooms. The `id` of an object and of its parent\n * has the same form as the `id` of a wall. A scene record with the room record and these objects gives the model of the level.\n */\n readonly objects: readonly PlacedObject[];\n /**\n * The layers of the level on its room record. Each name has one layer, from the layer of the level and the layers of the rooms.\n * A level with no layers gives none. The function `join` of the add-on of each name makes the layer, as `joinLayers` tells.\n * A layer of a room is here only when an add-on of the options read it.\n */\n readonly layers?: Readonly<Record<string, unknown>> | undefined;\n /**\n * One finding or more for each layer of a room or of the level that is not in `layers`. A finding about a room has the `id` of the room.\n * The findings of the read of each room come first, in the sequence of the rooms. The findings of `joinLayers` follow.\n */\n readonly layerFindings: readonly LayerFinding[];\n}\n\n/** The options of the expansion of a level. */\nexport interface LevelOptions extends SurveyOptions {\n /** The distance between two groups of rooms, in the unit of the level. The default is 1 m. A value that is not a length of 0 or more gives the default. */\n readonly groupGap?: number | undefined;\n}\n\n/** This function gives a survey with no layers. */\nfunction withoutLayers(survey: Survey): Survey {\n const { layers, ...rest } = survey;\n return layers === undefined ? survey : rest;\n}\n\n/**\n * This function gives an anchor of a room with the names of the level. A wall and an object get the name that `roomName` gives.\n * The floor of a room has the `id` of the room in a level.\n */\nfunction inRoom(room: string, anchor: Anchor): Anchor {\n if (anchor.on === \"wall\") return { ...anchor, wall: roomName(room, anchor.wall) };\n if (anchor.on === \"object\") return { ...anchor, object: roomName(room, anchor.object) };\n if (anchor.floor === undefined) return anchor;\n return { ...anchor, floor: anchor.floor === SURVEY_FLOOR ? room : roomName(room, anchor.floor) };\n}\n\n/** The largest angle between the two walls of a connection that fits, in degrees. */\nexport const CONNECTION_TURN_LIMIT = 2;\n\n/** A length in meters at this value or less is 0 for the level. */\nconst SMALL = 1e-6;\n\n/** Two unit vectors with a cross product below this value are parallel. */\nconst PARALLEL = 1e-6;\n\n/** The number of steps of the grid of calculated lengths in one unit. The noise of float arithmetic is much smaller than one step. */\nconst GRID = 1e9;\n\n/** The place of a room in the level: the first corner of its walk, and the direction of its first side in degrees. */\ninterface Place {\n readonly start: PlanPoint;\n readonly heading: number;\n}\n\n/** An opening of a room, in the frame of its survey. The first corner is the origin, and the first side goes along the x axis. */\ninterface Hole {\n /** The position of the wall of the opening in the room record. */\n readonly wall: number;\n /** The center of the opening on the inner face of its wall. */\n readonly center: PlanPoint;\n /** The unit vector from the room through the wall. */\n readonly out: PlanPoint;\n readonly width: number;\n /** The thickness of the wall of the opening. */\n readonly thickness: number;\n}\n\n/** A connection with no fault: its two rooms as positions in the list of the rooms, and its two openings. */\ninterface Link {\n readonly from: number;\n readonly to: number;\n readonly fromHole: Hole;\n readonly toHole: Hole;\n /** The thickness of the wall at the hole. */\n readonly depth: number;\n}\n\n/** One wall of a room of the level, at its place. */\ninterface Face {\n readonly room: number;\n readonly wall: number;\n readonly from: PlanPoint;\n readonly to: PlanPoint;\n readonly along: PlanPoint;\n readonly out: PlanPoint;\n readonly length: number;\n readonly thickness: number;\n}\n\n/** This function gives the sum of two vectors of the plan. The second vector has a factor. */\nfunction plus(a: PlanPoint, b: PlanPoint, factor = 1): PlanPoint {\n return [a[0] + b[0] * factor, a[1] + b[1] * factor];\n}\n\n/** This function gives the dot product of two vectors of the plan. */\nfunction dot(a: PlanPoint, b: PlanPoint): number {\n return a[0] * b[0] + a[1] * b[1];\n}\n\n/** This function gives the cross product of two vectors of the plan. */\nfunction cross(a: PlanPoint, b: PlanPoint): number {\n return a[0] * b[1] - a[1] * b[0];\n}\n\n/**\n * This function gives a calculated length on the grid. It removes the noise of float arithmetic,\n * so a place of 0.1 does not become 0.10000000000000009 in a file.\n */\nfunction tidy(value: number): number {\n const steps = Math.round(value * GRID);\n // The sum with 0 changes -0 to 0.\n return Number.isSafeInteger(steps) ? steps / GRID + 0 : value;\n}\n\n/** This function gives a point of the frame of a room as a point of the level. */\nfunction placed(place: Place, point: PlanPoint): PlanPoint {\n return plus(place.start, turned(point, place.heading));\n}\n\n/** This function gives the unit vector along a wall and the unit vector from the room through the wall. A wall with no length has no vectors. */\nfunction vectorsOf(wall: Wall): { readonly along: PlanPoint; readonly out: PlanPoint; readonly length: number } | undefined {\n const dx = wall.to[0] - wall.from[0];\n const dy = wall.to[1] - wall.from[1];\n const length = Math.hypot(dx, dy);\n if (!(length > 0) || !Number.isFinite(length)) return undefined;\n const along: PlanPoint = [dx / length, dy / length];\n // The wall of a survey is on the outer side of its line.\n return { along, out: wall.side === \"left\" ? [0 - along[1], along[0]] : [along[1], 0 - along[0]], length };\n}\n\n/** This function gives an opening of a room in the frame of its survey. `own` is the expansion of the survey with no `start` and no `heading`. */\nfunction holeOf(own: SurveyResult, id: string, inRange: (value: number) => boolean): Hole | undefined {\n const opening = own.room.openings?.find((item) => item.id === id);\n if (opening === undefined || !inRange(opening.offset) || !inRange(opening.width)) return undefined;\n const wall = own.room.walls.findIndex((item) => item.id === opening.wall);\n const record = own.room.walls[wall];\n const vectors = record === undefined ? undefined : vectorsOf(record);\n if (record === undefined || vectors === undefined) return undefined;\n return {\n wall,\n center: plus(record.from, vectors.along, opening.offset + opening.width / 2),\n out: vectors.out,\n width: opening.width,\n thickness: record.thickness ?? own.room.wallThickness,\n };\n}\n\n/**\n * This function gives the place of a room from a connection to a room that has a place.\n * The two walls are back to back, and the centers of the two openings are opposite, at the distance `depth`.\n */\nfunction placeFrom(known: Place, knownHole: Hole, hole: Hole, depth: number): Place {\n const out = turned(knownHole.out, known.heading);\n const heading = squared(headingOf([0 - out[0], 0 - out[1]]) - headingOf(hole.out));\n const center = turned(hole.center, heading);\n const start = plus(plus(placed(known, knownHole.center), out, depth), center, -1);\n return { start: [tidy(start[0]), tidy(start[1])], heading };\n}\n\n/**\n * This function makes one room record from the rooms of a level.\n *\n * The first room keeps the `start` and the `heading` of its survey. The function goes from that room along the connections.\n * A connection to a room with no place gives the place of that room. The two walls are back to back, and the centers of the\n * two openings are opposite. The faces of the two walls are at the distance `thickness`.\n * A connection between two rooms that have a place examines the measurements: its `gap` and its `turn` tell a mistake.\n *\n * A room with no path of connections to a room before it starts a new group. Its place is not known,\n * so its group goes to the right of the groups before it. Thus a drawing of a level in progress shows each room.\n *\n * The survey of a room gives the thickness of each wall. Two rooms have one wall between them, so two walls that are\n * back to back share it. Each wall gets one half of the distance between the two faces.\n * This applies to the two walls of a connection, and to two walls that overlap.\n * A wall that is in part an outer wall gets the same thickness along its full length.\n *\n * The layers of each room go to the room record of the level in one change. The change has the unit of the level, the place of the room, then the names of the level.\n * Then the function `join` of each add-on gives one layer for the level. The layer of the level record comes first.\n *\n * `checkRoom` examines the room record. It tells when two rooms overlap.\n */\nexport function expandLevel(level: Level, options: LevelOptions = {}): LevelResult {\n const unit = level.unit;\n const scale = metersPer(unit);\n const inRange = (value: number): boolean => Number.isFinite(value) && Math.abs(value) * scale <= LARGEST_LENGTH;\n const size = (value: number | undefined): number | undefined => (value !== undefined && inRange(value) && value * scale > SMALL ? value : undefined);\n const count = level.rooms.length;\n // The layers of a room go to the level in one change after the places are known, so each survey of the walk has none.\n const surveys = level.rooms.map((room) => convertSurvey(withoutLayers(room.survey), unit));\n // Each room in the frame of its survey: the first corner is the origin, and the first side goes along the x axis.\n const owns = surveys.map((survey) => expandSurvey({ ...survey, start: undefined, heading: undefined }, options));\n\n const positionOf = new Map<string, number>();\n level.rooms.forEach((room, index) => {\n if (!positionOf.has(room.id)) positionOf.set(room.id, index);\n });\n\n const connections = level.connections ?? [];\n const faults: (ConnectionFault | undefined)[] = [];\n const links = connections.map((connection, index): Link | undefined => {\n const from = positionOf.get(connection.from.room);\n const to = positionOf.get(connection.to.room);\n if (from === undefined || to === undefined) {\n faults[index] = \"room\";\n return undefined;\n }\n if (from === to) {\n faults[index] = \"one-room\";\n return undefined;\n }\n const fromHole = holeOf(owns[from]!, connection.from.opening, inRange);\n const toHole = holeOf(owns[to]!, connection.to.opening, inRange);\n if (fromHole === undefined || toHole === undefined) {\n faults[index] = \"opening\";\n return undefined;\n }\n return { from, to, fromHole, toHole, depth: size(connection.thickness) ?? size(fromHole.thickness) ?? 0 };\n });\n\n // The place of each room: the function goes from the first room of each group along the connections.\n const places: Place[] = [];\n const sources: RoomPlace[] = [];\n const groups: number[] = [];\n const members: number[][] = [];\n const gives = new Set<number>();\n for (let root = 0; root < count; root++) {\n if (places[root] !== undefined) continue;\n const group = members.length;\n const survey = surveys[root]!;\n const heading = survey.heading !== undefined && Number.isFinite(survey.heading) ? survey.heading : 0;\n const start: PlanPoint = group === 0 && survey.start !== undefined && inRange(survey.start[0]) && inRange(survey.start[1]) ? survey.start : [0, 0];\n places[root] = { start, heading };\n sources[root] = group === 0 ? \"first\" : \"apart\";\n groups[root] = group;\n const queue = [root];\n for (let next = 0; next < queue.length; next++) {\n const known = queue[next]!;\n links.forEach((link, index) => {\n if (link === undefined) return;\n const forward = link.from === known;\n if (!forward && link.to !== known) return;\n const room = forward ? link.to : link.from;\n if (places[room] !== undefined) return;\n places[room] = placeFrom(places[known]!, forward ? link.fromHole : link.toHole, forward ? link.toHole : link.fromHole, link.depth);\n sources[room] = \"connection\";\n groups[room] = group;\n gives.add(index);\n queue.push(room);\n });\n }\n members.push(queue);\n }\n\n // A group with no known place goes to the right of the groups before it. The bottoms of the groups are on one line.\n const givenGap = options.groupGap;\n const groupGap = givenGap !== undefined && inRange(givenGap) && givenGap >= 0 ? givenGap : 1 / scale;\n let right: number | undefined;\n let base = 0;\n for (const [number, group] of members.entries()) {\n let low: PlanPoint | undefined;\n let high: PlanPoint | undefined;\n for (const room of group) {\n const survey = surveys[room]!;\n const margin = Math.max(0, ...[survey.wallThickness, ...survey.sides.map((side) => side.thickness)].map((value) => size(value) ?? 0));\n for (const point of [...owns[room]!.walk, ...owns[room]!.corners]) {\n const [x, y] = placed(places[room]!, point);\n low = low === undefined ? [x - margin, y - margin] : [Math.min(low[0], x - margin), Math.min(low[1], y - margin)];\n high = high === undefined ? [x + margin, y + margin] : [Math.max(high[0], x + margin), Math.max(high[1], y + margin)];\n }\n }\n if (low === undefined || high === undefined) continue;\n if (number === 0 || right === undefined) {\n right = right === undefined ? high[0] : Math.max(right, high[0]);\n if (number === 0) base = low[1];\n continue;\n }\n const move: PlanPoint = [right + groupGap - low[0], base - low[1]];\n for (const room of group) {\n const [x, y] = plus(places[room]!.start, move);\n places[room] = { start: [tidy(x), tidy(y)], heading: places[room]!.heading };\n }\n right = Math.max(right, high[0] + move[0]);\n }\n\n const rooms = level.rooms.map((room, index): LevelRoomResult => {\n const survey: Survey = { ...surveys[index]!, start: places[index]!.start, heading: places[index]!.heading };\n return { id: room.id, place: sources[index]!, group: groups[index]!, survey, result: expandSurvey(survey, options) };\n });\n\n // The measure of each connection, from the places of its two rooms.\n const givenLimit = options.limit ?? CLOSURE_LIMIT;\n const limit = Number.isFinite(givenLimit) && givenLimit >= 0 ? givenLimit : CLOSURE_LIMIT;\n const walkOf = (room: number): number => {\n const walk = owns[room]!.walk;\n return walk.reduce((sum, point, index) => (index === 0 ? 0 : sum + Math.hypot(point[0] - walk[index - 1]![0], point[1] - walk[index - 1]![1])), 0);\n };\n const results = connections.map((connection, index): LevelConnectionResult => {\n const link = links[index];\n if (link === undefined) return { id: connection.id, use: \"none\", fault: faults[index], gap: undefined, ratio: undefined, turn: undefined, width: undefined, fits: false };\n const width = link.toHole.width - link.fromHole.width;\n if (gives.has(index)) return { id: connection.id, use: \"place\", gap: 0, ratio: 0, turn: 0, width, fits: true };\n const from = places[link.from]!;\n const to = places[link.to]!;\n const out = turned(link.fromHole.out, from.heading);\n const back = turned(link.toHole.out, to.heading);\n const target = plus(placed(from, link.fromHole.center), out, link.depth);\n const center = placed(to, link.toHole.center);\n const miss = Math.hypot(center[0] - target[0], center[1] - target[1]);\n const walk = walkOf(link.from) + walkOf(link.to);\n const ratio = walk > 0 ? miss / walk : 0;\n const against: PlanPoint = [0 - out[0], 0 - out[1]];\n // The sum with 0 changes -0 to 0.\n const turn = (Math.atan2(cross(against, back), dot(against, back)) * 180) / Math.PI + 0;\n return { id: connection.id, use: \"check\", gap: miss, ratio, turn, width, fits: ratio <= limit && Math.abs(turn) <= CONNECTION_TURN_LIMIT };\n });\n\n // Each wall at its place. Two walls that are back to back share the wall between their rooms.\n const faces: Face[] = [];\n rooms.forEach(({ result }, room) => {\n result.room.walls.forEach((wall, index) => {\n const vectors = vectorsOf(wall);\n const thickness = size(wall.thickness ?? result.room.wallThickness);\n if (vectors === undefined || thickness === undefined) return;\n faces.push({ room, wall: index, from: wall.from, to: wall.to, along: vectors.along, out: vectors.out, length: vectors.length, thickness });\n });\n });\n const joined = new Set<string>();\n links.forEach((link, index) => {\n if (link === undefined || !results[index]!.fits) return;\n joined.add(`${link.from}:${link.fromHole.wall}:${link.to}:${link.toHole.wall}`);\n joined.add(`${link.to}:${link.toHole.wall}:${link.from}:${link.fromHole.wall}`);\n });\n const shared = new Map<string, number>();\n for (let i = 0; i < faces.length; i++) {\n for (let j = i + 1; j < faces.length; j++) {\n const a = faces[i]!;\n const b = faces[j]!;\n if (a.room === b.room || Math.abs(cross(a.along, b.along)) > PARALLEL || !(dot(a.out, b.out) < 0)) continue;\n const first: PlanPoint = [b.from[0] - a.from[0], b.from[1] - a.from[1]];\n const second: PlanPoint = [b.to[0] - a.from[0], b.to[1] - a.from[1]];\n const between = dot(first, a.out);\n const common = Math.min(a.length, Math.max(dot(first, a.along), dot(second, a.along))) - Math.max(0, Math.min(dot(first, a.along), dot(second, a.along)));\n if (!(between * scale > SMALL) || !(common * scale > SMALL)) continue;\n // The two walls of a connection are one wall. Two other walls are one wall when they overlap.\n if (!joined.has(`${a.room}:${a.wall}:${b.room}:${b.wall}`) && !((a.thickness + b.thickness - between) * scale > SMALL)) continue;\n const half = tidy(between / 2);\n for (const face of [a, b]) {\n const key = `${face.room}:${face.wall}`;\n shared.set(key, Math.min(shared.get(key) ?? Infinity, half));\n }\n }\n }\n\n const first = rooms[0]?.result.room;\n const height = first?.height ?? 1;\n const wallThickness = first?.wallThickness ?? 1;\n const walls: Wall[] = [];\n const openings: Opening[] = [];\n const floors: Floor[] = [];\n const objects: PlacedObject[] = [];\n rooms.forEach(({ id, survey, result }, room) => {\n const record = result.room;\n record.walls.forEach((wall, index) => {\n const thickness = shared.get(`${room}:${index}`) ?? wall.thickness ?? (record.wallThickness === wallThickness ? undefined : record.wallThickness);\n const tall = wall.height ?? (record.height === height ? undefined : record.height);\n walls.push({\n id: `${id}/${wall.id}`,\n from: wall.from,\n to: wall.to,\n ...(wall.side === undefined ? {} : { side: wall.side }),\n ...(thickness === undefined ? {} : { thickness }),\n ...(tall === undefined ? {} : { height: tall }),\n });\n });\n for (const opening of record.openings ?? []) openings.push({ ...opening, id: `${id}/${opening.id}`, wall: `${id}/${opening.wall}` });\n for (const floor of record.floors ?? []) floors.push({ id, ...(survey.name === undefined ? {} : { name: survey.name }), ring: floor.ring });\n for (const object of result.objects) {\n objects.push({\n ...object,\n id: `${id}/${object.id}`,\n ...(object.parent === undefined ? {} : { parent: `${id}/${object.parent}` }),\n });\n }\n });\n\n const room: Room = {\n schema: ROOM_SCHEMA,\n ...(level.name === undefined ? {} : { name: level.name }),\n unit,\n height,\n wallThickness,\n walls,\n ...(openings.length === 0 ? {} : { openings }),\n ...(floors.length === 0 ? {} : { floors }),\n };\n const addOns = options.addOns ?? [];\n const parts: RoomLayers[] = [];\n const findings: LayerFinding[] = [];\n rooms.forEach(({ id, result }, index) => {\n const given = level.rooms[index]?.survey;\n if (given?.layers === undefined) return;\n const factor = unitsPer(given.unit, unit);\n const moved = moveLayers(given.layers, addOns, (anchor) => inRoom(id, surveyAnchor(scaleAnchor(anchor, factor), result.frame)), id);\n parts.push({ room: id, layers: moved.layers });\n findings.push(...moved.findings);\n });\n const layers = level.layers === undefined && parts.length === 0 ? undefined : joinLayers(level.layers, parts, addOns);\n return {\n room,\n rooms,\n connections: results,\n objects,\n ...(layers === undefined ? {} : { layers: layers.layers }),\n layerFindings: layers === undefined ? findings : [...findings, ...layers.findings],\n };\n}\n"],"mappings":";;;;AAYA,SAAgB,YAAY,SAA4B;CACtD,MAAM,QAAS,UAAA,MAAA,OAAA;CACf,IAAI,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC;CAC5B,IAAI,SAAA,IAAiB,OAAO,CAAC,GAAG,CAAC;CACjC,IAAI,SAAS,KAAY,OAAO,CAAC,IAAI,CAAC;CACtC,IAAI,SAAS,KAAY,OAAO,CAAC,GAAG,EAAE;CACtC,MAAM,QAAS,OAAO,KAAK,KAAM;CACjC,OAAO,CAAC,KAAK,IAAI,KAAK,GAAG,KAAK,IAAI,KAAK,CAAC;AAC1C;;AAGA,SAAgB,OAAO,CAAC,GAAG,IAAe,SAA4B;CACpE,MAAM,CAAC,KAAK,OAAO,YAAY,OAAO;CACtC,OAAO,CAAC,IAAI,MAAM,IAAI,KAAK,IAAI,MAAM,IAAI,GAAG;AAC9C;;;;;AAMA,SAAgB,UAAU,CAAC,GAAG,IAAuB;CACnD,OAAO,QAAS,KAAK,MAAM,GAAG,CAAC,IAAI,MAAO,KAAK,EAAE;AACnD;;AAGA,SAAgB,QAAQ,SAAyB;CAC/C,MAAM,QAAS,UAAA,MAAA,OAAA;CACf,MAAM,OAAO,KAAK,MAAM,OAAA,EAAa,IAAA;CACrC,OAAO,KAAK,IAAI,OAAO,IAAI,IAAA,OAAiB,OAAA,MAAc;AAC5D;;;ACxBA,MAAa,gBAAgB;;AAG7B,MAAa,eAA2C,CAAC,QAAQ,OAAO;;AAoLxE,MAAa,eAAe;;AAG5B,MAAa,gBAAgB;;;;;;;;;;AAmB7B,SAAgB,aAAa,QAAgB,OAA4B;CACvE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AO,SAAS;EAC5E,CAAC;CAEL,CAAC;CAED,MAAM,OAAa;EACjB,QAAQ;EACR,GAAI,MAAM,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,MAAM,KAAK;EACvD;EACA;EACA;EACA;EACA,GAAI,SAAS,WAAW,IAAI,CAAC,IAAI,EAAE,SAAS;EAC5C,GAAI,OAAO,WAAW,IAAI,CAAC,IAAI,EAAE,OAAO;CAC1C;CACA,MAAM,SAAS,QAAQ,UAAU,CAAC;CAClC,MAAM,QAAsB,CAAC;CAC7B,MAAM,WAA2B,CAAC;CAClC,MAAM,SAAS,EAAE,IAAI,UAAU,UAAU;EACvC,MAAM,QAAQ,MAAM,MAAM,MAAM,EAAE;EAClC,IAAI,OAAO,WAAW,KAAA,GAAW;EACjC,MAAM,SAAS,SAAS,MAAM,MAAM,IAAI;EACxC,MAAM,QAAQ,WAAW,MAAM,QAAQ,SAAS,WAAW,OAAO,IAAI,aAAa,YAAY,QAAQ,MAAM,GAAG,OAAO,KAAK,CAAC,GAAG,EAAE;EAClI,MAAM,KAAK;GAAE,MAAM;GAAI,QAAQ,MAAM;EAAO,CAAC;EAC7C,SAAS,KAAK,GAAG,MAAM,QAAQ;CACjC,CAAC;CACD,MAAM,SAAS,MAAM,WAAW,KAAA,KAAa,MAAM,WAAW,IAAI,KAAA,IAAY,WAAW,MAAM,QAAQ,OAAO,MAAM;CACpH,OAAO;EACL;EACA;EACA,aAAa;EACb;EACA,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,OAAO,OAAO;EACxD,eAAe,WAAW,KAAA,IAAY,WAAW,CAAC,GAAG,UAAU,GAAG,OAAO,QAAQ;CACnF;AACF"}
@@ -1,5 +1,5 @@
1
- import { I as Anchor, s as LayerFinding, t as AddOn } from "./layers-CYZwt1bH.js";
2
- import { B as WallFace, G as LengthUnit, I as Scene, M as PlanPoint, P as Room, j as PlacedObject, k as Opening } from "./solids-OiTlb_Pm.js";
1
+ import { I as Anchor, s as LayerFinding, t as AddOn } from "./layers-BiiyFJwZ.js";
2
+ import { a as PlacedObject, c as Room, m as WallFace, o as PlanPoint, r as Opening, u as Scene, y as LengthUnit } from "./room-BQua5eSs.js";
3
3
  /** The name of the format of a survey record. */
4
4
  declare const SURVEY_SCHEMA = "survey/2";
5
5
  /** These are the names of the turns at a square corner. */
@@ -416,4 +416,4 @@ declare const CONNECTION_TURN_LIMIT = 2;
416
416
  */
417
417
  declare function expandLevel(level: Level, options?: LevelOptions): LevelResult;
418
418
  export { SurveySide as A, SurveyCheck as C, SurveyObject as D, SurveyFrame as E, surveyAnchor as F, convertSurvey as M, expandSurvey as N, SurveyOptions as O, resultScene as P, Survey as S, SurveyClosure as T, expandLevel as _, ConnectionFault as a, SURVEY_FLOOR as b, Level as c, LevelOptions as d, LevelResult as f, RoomPlace as g, ROOM_PLACES as h, ConnectionEnd as i, SurveyTurn as j, SurveyResult 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, SurveyCheckResult as w, SURVEY_SCHEMA as x, SQUARE_TURNS as y };
419
- //# sourceMappingURL=level-m-mJ_3Ok.d.ts.map
419
+ //# sourceMappingURL=level-DmEftWYn.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"level-m-mJ_3Ok.d.ts","names":[],"sources":["../src/survey.ts","../src/level.ts"],"mappings":";;;cAiBa;;cAGA;;;;;;;KAQD,qBAAqB;;UAGhB;;WAEN;;WAEA;;WAEA,MAAM;;WAEN;;WAEA;;;UAIM;WACN;;WAEA;;WAEA;;WAEA;;;;;;;;;;;;;UAcM;WACN;;WAEA;WACA;;WAEA;;WAEA;;;;;WAKA;;WAEA;;WAEA;WACA;;;;;WAKA;;;;;WAKA;;;;;;;;;UAUM;WACN,eAAe;WACf;;WAEA,MAAM;;WAEN;;WAEA;;WAE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V9D;;UAGI;WACN;WACA,QAAQ;;;UAIF;;WAEN;;WAEA;;;;;;UAOM;WACN;WACA,MAAM;WACN,IAAI;;;;;WAKJ;;;;;;;;UASM;WACN,eAAe;WACf;;WAEA,MAAM;WACN,gBAAgB;WAChB,uBAAuB;;;;;;WAMvB,SAAS,SAAS;;;;;;;;;cAUhB;;KAGD,oBAAoB;;UAGf;;WAEN;WACA,OAAO;;WAEP;;;;;WAKA,QAAQ;;WAER,QAAQ;;;;;;;;;cAUN;;KAGD,wBAAwB;;;;;;;;cASvB;;KAGD,0BAA0B;;UAGrB;;WAEN;WACA,KAAK;WACL,QAAQ;;;;;WAKR;;WAEA;;WAEA;;WAEA;;WAEA;;;UAIM;;;;;;WAMN,MAAM;;WAEN,gBAAgB;;WAEhB,sBAAsB;;;;;WAKtB,kBAAkB;;;;;;WAMlB,SAAS,SAAS;;;;;WAKlB,wBAAwB;;;UAIlB,qBAAqB;;WAE3B;;;cAqBE;;;;;;;;;;;;;;;;;;;;;;iBA+IG,YAAY,OAAO,OAAO,UAAS,eAAoB"}
package/build/marks.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { H as SceneSpace, t as AddOn } from "./layers-CYZwt1bH.js";
2
- import { I as Scene } from "./solids-OiTlb_Pm.js";
1
+ import { H as SceneSpace, t as AddOn } from "./layers-BiiyFJwZ.js";
2
+ import { u as Scene } from "./room-BQua5eSs.js";
3
3
  import { Mark } from "@mark1russell7/visuals/marks";
4
4
  /**
5
5
  * The marks of one add-on. This value is in the entry `/marks` of the add-on, so the root entry of the add-on has no visual part.
package/build/marks.js CHANGED
@@ -1,4 +1,4 @@
1
- import { f as sceneSpace, l as compareText, s as readLayer } from "./layers-CDNFVXds.js";
1
+ import { f as sceneSpace, l as compareText, s as readLayer } from "./layers-DmTro5Ny.js";
2
2
  // src/marks.ts
3
3
  /**
4
4
  * This function gives the marks of the layers of a scene. Each value of `marks` gives the marks of the layer of its name.