@roomle/web-sdk 7.0.0-alpha.1 → 7.0.0-alpha.2

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 (87) hide show
  1. package/THIRD-PARTY-NOTICES.txt +2 -2
  2. package/lib/{BufferGeometry-CzBRCIk3.mjs → BufferGeometry-YaAhwXNX.mjs} +2 -2
  3. package/lib/{BufferGeometry-CzBRCIk3.mjs.map → BufferGeometry-YaAhwXNX.mjs.map} +1 -1
  4. package/lib/ConfiguratorKernel.wasm +0 -0
  5. package/lib/{Object3D-Bkmul_of.mjs → Object3D-Dx0HN7Wz.mjs} +1 -1
  6. package/lib/{Object3D-Bkmul_of.mjs.map → Object3D-Dx0HN7Wz.mjs.map} +1 -1
  7. package/lib/{PointLightHelper-DOW-3Hvn.mjs → PointLightHelper-B8k3nJVr.mjs} +4 -4
  8. package/lib/{PointLightHelper-DOW-3Hvn.mjs.map → PointLightHelper-B8k3nJVr.mjs.map} +1 -1
  9. package/lib/RoomleCore.wasm +0 -0
  10. package/lib/RoomleToolsCore.wasm +0 -0
  11. package/lib/{SpotLightHelper-sE9yZPeq.mjs → SpotLightHelper-jqI3QyNE.mjs} +3 -3
  12. package/lib/{SpotLightHelper-sE9yZPeq.mjs.map → SpotLightHelper-jqI3QyNE.mjs.map} +1 -1
  13. package/lib/{USDZExporter-zhEk6F4K.mjs → USDZExporter-BS1qa3HO.mjs} +2 -2
  14. package/lib/{USDZExporter-zhEk6F4K.mjs.map → USDZExporter-BS1qa3HO.mjs.map} +1 -1
  15. package/lib/{Vector4-CmUR_DSp.mjs → Vector4-BmWb-htx.mjs} +2 -2
  16. package/lib/{Vector4-CmUR_DSp.mjs.map → Vector4-BmWb-htx.mjs.map} +1 -1
  17. package/lib/{api-1YHSF8TD.mjs → api-DOHbOr7K.mjs} +2 -2
  18. package/lib/{api-1YHSF8TD.mjs.map → api-DOHbOr7K.mjs.map} +1 -1
  19. package/lib/asset-loader.worker-Bdvb-pt7.mjs.map +1 -1
  20. package/lib/budgeteer.sw-ByZxiRBr.mjs.map +1 -1
  21. package/lib/{common-utils-DZiN8bjs.mjs → common-utils-zPOllvAT.mjs} +3 -2
  22. package/lib/common-utils-zPOllvAT.mjs.map +1 -0
  23. package/lib/{component-raycast-helper-BSFG09WY.mjs → component-raycast-helper-CMFpSJXC.mjs} +3 -3
  24. package/lib/{component-raycast-helper-BSFG09WY.mjs.map → component-raycast-helper-CMFpSJXC.mjs.map} +1 -1
  25. package/lib/{configuration-operations-DI677LMN.mjs → configuration-operations-DJD9A1xP.mjs} +38 -38
  26. package/lib/{configuration-operations-DI677LMN.mjs.map → configuration-operations-DJD9A1xP.mjs.map} +1 -1
  27. package/lib/configurator-D5Ehj649.mjs +3 -0
  28. package/lib/configurator-DCynrn7X.mjs +46 -0
  29. package/lib/{configurator-CgFJ2voV.mjs.map → configurator-DCynrn7X.mjs.map} +1 -1
  30. package/lib/{configurator-capabilities-CLqul800.mjs → configurator-capabilities-BfSMwdWh.mjs} +12 -12
  31. package/lib/{configurator-capabilities-CLqul800.mjs.map → configurator-capabilities-BfSMwdWh.mjs.map} +1 -1
  32. package/lib/configurator-capabilities-DAJuxSTw.mjs +3 -0
  33. package/lib/{fflate.module-CpWr9KGw.mjs → fflate.module-BfCRKtjc.mjs} +1 -1
  34. package/lib/{fflate.module-CpWr9KGw.mjs.map → fflate.module-BfCRKtjc.mjs.map} +1 -1
  35. package/lib/{glb-viewer-B2WH46su.mjs → glb-viewer-BhiCqjpE.mjs} +24 -24
  36. package/lib/{glb-viewer-B2WH46su.mjs.map → glb-viewer-BhiCqjpE.mjs.map} +1 -1
  37. package/lib/glb-viewer-BrggGLte.mjs +3 -0
  38. package/lib/{hi-mcp-server-tVF1bn28.mjs → hi-mcp-server-rSu1HL4m.mjs} +2 -2
  39. package/lib/{hi-mcp-server-tVF1bn28.mjs.map → hi-mcp-server-rSu1HL4m.mjs.map} +1 -1
  40. package/lib/{highlight-coordinator-CiBzWsMf.mjs → highlight-coordinator-DbqhP7Hy.mjs} +3 -3
  41. package/lib/{highlight-coordinator-CiBzWsMf.mjs.map → highlight-coordinator-DbqhP7Hy.mjs.map} +1 -1
  42. package/lib/{homag-intelligence-CdYda0Mb.mjs → homag-intelligence-DuFtYgdG.mjs} +3 -3
  43. package/lib/{homag-intelligence-CdYda0Mb.mjs.map → homag-intelligence-DuFtYgdG.mjs.map} +1 -1
  44. package/lib/{material-viewer-BrARE0p0.mjs → material-viewer-uEDqIbCx.mjs} +25 -21
  45. package/lib/material-viewer-uEDqIbCx.mjs.map +1 -0
  46. package/lib/{packages-DhBz4dX3.mjs → packages-DOCmEOxI.mjs} +6 -6
  47. package/lib/{packages-DhBz4dX3.mjs.map → packages-DOCmEOxI.mjs.map} +1 -1
  48. package/lib/planner-B9GbQLSB.mjs +3 -0
  49. package/lib/{planner-SRvOM5ZQ.mjs → planner-D8UVNfkJ.mjs} +16 -16
  50. package/lib/{planner-SRvOM5ZQ.mjs.map → planner-D8UVNfkJ.mjs.map} +1 -1
  51. package/lib/roomle-headless.d.ts +14 -18
  52. package/lib/roomle-headless.js +35 -32
  53. package/lib/roomle-headless.js.map +1 -1
  54. package/lib/{roomle-sdk-Sdrd7K0F.mjs → roomle-sdk-C0YpFZdj.mjs} +24740 -24770
  55. package/lib/roomle-sdk-C0YpFZdj.mjs.map +1 -0
  56. package/lib/roomle-sdk.d.ts +14 -18
  57. package/lib/roomle-sdk.js +9 -9
  58. package/lib/{roomle-webgpu-renderer-CWoN5YzU.mjs → roomle-webgpu-renderer-DZ9LaZfc.mjs} +3 -3
  59. package/lib/{roomle-webgpu-renderer-CWoN5YzU.mjs.map → roomle-webgpu-renderer-DZ9LaZfc.mjs.map} +1 -1
  60. package/lib/{scene-renderer-CsbP23gu.mjs → scene-renderer-BmtXHWEw.mjs} +3 -3
  61. package/lib/{scene-renderer-CsbP23gu.mjs.map → scene-renderer-BmtXHWEw.mjs.map} +1 -1
  62. package/lib/{script-loader-D9Tr-8LN.mjs → script-loader-jRBMP-ca.mjs} +2 -2
  63. package/lib/{script-loader-D9Tr-8LN.mjs.map → script-loader-jRBMP-ca.mjs.map} +1 -1
  64. package/lib/{shading-settings-mnQRn2LO.mjs → shading-settings-CpXZmOnx.mjs} +2 -2
  65. package/lib/{shading-settings-mnQRn2LO.mjs.map → shading-settings-CpXZmOnx.mjs.map} +1 -1
  66. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/package.json +1 -1
  67. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/ConfiguratorKernel.wasm +0 -0
  68. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleCore.wasm +0 -0
  69. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleToolsCore.wasm +0 -0
  70. package/lib/{stats-helper-Q25NjvCQ.mjs → stats-helper-jzrLyoHV.mjs} +2 -2
  71. package/lib/{stats-helper-Q25NjvCQ.mjs.map → stats-helper-jzrLyoHV.mjs.map} +1 -1
  72. package/lib/{threejs-utils-C3CWKZXa.mjs → threejs-utils-D1gtvxiA.mjs} +7 -15
  73. package/lib/{threejs-utils-C3CWKZXa.mjs.map → threejs-utils-D1gtvxiA.mjs.map} +1 -1
  74. package/lib/{tools-core-BBYYzygJ.mjs → tools-core-k93qrqfB.mjs} +6 -6
  75. package/lib/{tools-core-BBYYzygJ.mjs.map → tools-core-k93qrqfB.mjs.map} +1 -1
  76. package/lib/{util-BdWrqTeC.mjs → util-LmkV26fg.mjs} +1 -1
  77. package/lib/{util-BdWrqTeC.mjs.map → util-LmkV26fg.mjs.map} +1 -1
  78. package/package.json +2 -2
  79. package/sbom.cdx.json +5 -5
  80. package/lib/common-utils-DZiN8bjs.mjs.map +0 -1
  81. package/lib/configurator-AwPowYQR.mjs +0 -3
  82. package/lib/configurator-CgFJ2voV.mjs +0 -46
  83. package/lib/configurator-capabilities-Dg8oD49T.mjs +0 -3
  84. package/lib/glb-viewer-sxVA5IgD.mjs +0 -3
  85. package/lib/material-viewer-BrARE0p0.mjs.map +0 -1
  86. package/lib/planner-D6uV0kCw.mjs +0 -3
  87. package/lib/roomle-sdk-Sdrd7K0F.mjs.map +0 -1
@@ -1,11 +1,11 @@
1
1
 
2
- import { K as e, ft as t, n, q as r } from "./roomle-sdk-Sdrd7K0F.mjs";
3
- import { t as i } from "./script-loader-D9Tr-8LN.mjs";
2
+ import { M as e, ft as t, j as n, n as r } from "./roomle-sdk-C0YpFZdj.mjs";
3
+ import { t as i } from "./script-loader-jRBMP-ca.mjs";
4
4
  //#region packages/tools-core/src/utils/injectables.ts
5
- var a = [new t("script-loader", i)], o = class extends r {
5
+ var a = [new t("script-loader", i)], o = class extends e {
6
6
  setupGlobals() {}
7
7
  setupDependencies() {
8
- n.setup(a), this.lookup("logger", this._context);
8
+ r.setup(a), this.lookup("logger", this._context);
9
9
  }
10
10
  cleanUpGlobals() {
11
11
  this._tools = void 0, window.RoomleToolsCore && delete window.RoomleToolsCore;
@@ -22,10 +22,10 @@ var a = [new t("script-loader", i)], o = class extends r {
22
22
  return this._tools;
23
23
  }
24
24
  getContextName() {
25
- return e.TOOLS_CORE;
25
+ return n.TOOLS_CORE;
26
26
  }
27
27
  };
28
28
  //#endregion
29
29
  export { o as ToolsCore };
30
30
 
31
- //# sourceMappingURL=tools-core-BBYYzygJ.mjs.map
31
+ //# sourceMappingURL=tools-core-k93qrqfB.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"tools-core-BBYYzygJ.mjs","names":[],"sources":["../../packages/tools-core/src/utils/injectables.ts","../../packages/tools-core/src/tools-core.ts"],"sourcesContent":["import ScriptLoader from '../../../common-core/src/script-loader';\nimport { DependencyInjectionAssignment } from '../../../common-core/src/di/container';\n\nexport const INJECTABLES: DependencyInjectionAssignment[] = [\n new DependencyInjectionAssignment('script-loader', ScriptLoader),\n];\n","import './utils/global-definitions';\n\nimport { Main, BASE_CONTEXT } from '../../common-core/src/main';\nimport type Logger from '../../common-core/src/logger';\nimport RoomleDependencyInjection from '../../common-core/src/di/roomle-dependency-injection';\nimport type RoomleToolsCore from './roomle-tools-core';\nimport type ScriptLoader from '../../common-core/src/script-loader';\nimport { INJECTABLES } from './utils/injectables';\n\nexport class ToolsCore extends Main {\n private _tools: RoomleToolsCore | undefined;\n\n protected setupGlobals(): void {\n //globals are initialized in bootFinished()\n }\n\n protected setupDependencies(): void {\n RoomleDependencyInjection.setup(INJECTABLES);\n this.lookup<Logger>('logger', this._context);\n }\n\n protected cleanUpGlobals(): void {\n this._tools = undefined;\n if (window.RoomleToolsCore) {\n delete window.RoomleToolsCore;\n }\n }\n\n protected cleanUpDependencies(): void {\n const scriptLoader = this.lookup<ScriptLoader>('script-loader');\n if (scriptLoader) {\n scriptLoader.cleanUp();\n }\n }\n\n protected async bootFinished(): Promise<void> {\n this._tools = this.lookup<RoomleToolsCore>(\n 'roomle-tools-core',\n this._context,\n );\n\n if (!window.RoomleToolsCore) {\n window.RoomleToolsCore = this._tools;\n }\n }\n\n public getApi(): RoomleToolsCore {\n if (this._tools === undefined) {\n throw new Error('ToolsCore not initialized. Call boot() first.');\n }\n return this._tools;\n }\n\n protected getContextName(): string {\n return BASE_CONTEXT.TOOLS_CORE;\n }\n}\n"],"mappings":";;;;AAGA,IAAa,IAA+C,CAC1D,IAAI,EAA8B,iBAAiB,EAAa,CACjE,ECIY,IAAb,cAA+B,EAAK;CAGlC,eAA+B;CAI/B,oBAAoC;AAElC,EADA,EAA0B,MAAM,EAAY,EAC5C,KAAK,OAAe,UAAU,KAAK,SAAS;;CAG9C,iBAAiC;AAE/B,EADA,KAAK,SAAS,KAAA,GACV,OAAO,mBACT,OAAO,OAAO;;CAIlB,sBAAsC;EACpC,IAAM,IAAe,KAAK,OAAqB,gBAAgB;AAC/D,EAAI,KACF,EAAa,SAAS;;CAI1B,MAAgB,eAA8B;AAM5C,EALA,KAAK,SAAS,KAAK,OACjB,qBACA,KAAK,SACN,EAEI,OAAO,oBACV,OAAO,kBAAkB,KAAK;;CAIlC,SAAiC;AAC/B,MAAI,KAAK,WAAW,KAAA,EAClB,OAAU,MAAM,gDAAgD;AAElE,SAAO,KAAK;;CAGd,iBAAmC;AACjC,SAAO,EAAa"}
1
+ {"version":3,"file":"tools-core-k93qrqfB.mjs","names":[],"sources":["../../packages/tools-core/src/utils/injectables.ts","../../packages/tools-core/src/tools-core.ts"],"sourcesContent":["import ScriptLoader from '../../../common-core/src/script-loader';\nimport { DependencyInjectionAssignment } from '../../../common-core/src/di/container';\n\nexport const INJECTABLES: DependencyInjectionAssignment[] = [\n new DependencyInjectionAssignment('script-loader', ScriptLoader),\n];\n","import './utils/global-definitions';\n\nimport { Main, BASE_CONTEXT } from '../../common-core/src/main';\nimport type Logger from '../../common-core/src/logger';\nimport RoomleDependencyInjection from '../../common-core/src/di/roomle-dependency-injection';\nimport type RoomleToolsCore from './roomle-tools-core';\nimport type ScriptLoader from '../../common-core/src/script-loader';\nimport { INJECTABLES } from './utils/injectables';\n\nexport class ToolsCore extends Main {\n private _tools: RoomleToolsCore | undefined;\n\n protected setupGlobals(): void {\n //globals are initialized in bootFinished()\n }\n\n protected setupDependencies(): void {\n RoomleDependencyInjection.setup(INJECTABLES);\n this.lookup<Logger>('logger', this._context);\n }\n\n protected cleanUpGlobals(): void {\n this._tools = undefined;\n if (window.RoomleToolsCore) {\n delete window.RoomleToolsCore;\n }\n }\n\n protected cleanUpDependencies(): void {\n const scriptLoader = this.lookup<ScriptLoader>('script-loader');\n if (scriptLoader) {\n scriptLoader.cleanUp();\n }\n }\n\n protected async bootFinished(): Promise<void> {\n this._tools = this.lookup<RoomleToolsCore>(\n 'roomle-tools-core',\n this._context,\n );\n\n if (!window.RoomleToolsCore) {\n window.RoomleToolsCore = this._tools;\n }\n }\n\n public getApi(): RoomleToolsCore {\n if (this._tools === undefined) {\n throw new Error('ToolsCore not initialized. Call boot() first.');\n }\n return this._tools;\n }\n\n protected getContextName(): string {\n return BASE_CONTEXT.TOOLS_CORE;\n }\n}\n"],"mappings":";;;;AAGA,IAAa,IAA+C,CAC1D,IAAI,EAA8B,iBAAiB,EAAa,CACjE,ECIY,IAAb,cAA+B,EAAK;CAGlC,eAA+B;CAI/B,oBAAoC;AAElC,EADA,EAA0B,MAAM,EAAY,EAC5C,KAAK,OAAe,UAAU,KAAK,SAAS;;CAG9C,iBAAiC;AAE/B,EADA,KAAK,SAAS,KAAA,GACV,OAAO,mBACT,OAAO,OAAO;;CAIlB,sBAAsC;EACpC,IAAM,IAAe,KAAK,OAAqB,gBAAgB;AAC/D,EAAI,KACF,EAAa,SAAS;;CAI1B,MAAgB,eAA8B;AAM5C,EALA,KAAK,SAAS,KAAK,OACjB,qBACA,KAAK,SACN,EAEI,OAAO,oBACV,OAAO,kBAAkB,KAAK;;CAIlC,SAAiC;AAC/B,MAAI,KAAK,WAAW,KAAA,EAClB,OAAU,MAAM,gDAAgD;AAElE,SAAO,KAAK;;CAGd,iBAAmC;AACjC,SAAO,EAAa"}
@@ -493,4 +493,4 @@ var e = (e) => Math.round(e * 100) / 100 + 0, t = (e) => e * Math.PI / 180, n =
493
493
  //#endregion
494
494
  export { e as A, $ as B, pe as C, ce as D, le as E, V as F, O as I, A as L, J as M, i as N, W as O, a as P, U as R, M as S, ie as T, ue as V, _, c as a, he as b, m as c, se as d, B as f, d as g, C as h, Z as i, H as j, x as k, g as l, fe as m, _e as n, me as o, ae as p, E as r, L as s, ve as t, h as u, N as v, j as w, oe as x, o as y, de as z };
495
495
 
496
- //# sourceMappingURL=util-BdWrqTeC.mjs.map
496
+ //# sourceMappingURL=util-LmkV26fg.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"util-BdWrqTeC.mjs","names":[],"sources":["../../packages/homag-intelligence/src/hi-plan-space.ts","../../packages/homag-intelligence/src/util.ts"],"sourcesContent":["import type { RepositioningData } from './hi-group-placement';\nimport type {\n HiPlanFootprint,\n HiPlanWall,\n HiPlanWallSide,\n} from './hi-plan-context';\n\nexport type WallSide = HiPlanWallSide;\n\nexport type DerivedWall = HiPlanWall;\n\n// A wall as the user sees it: contour segments of one side in a straight\n// line, its pieces of wall and the doors and windows between them (D81).\nexport interface WallFace extends DerivedWall {\n pieces: DerivedWall[];\n}\n\nexport type GroupFootprint = HiPlanFootprint;\n\nexport type WallAlignment = 'start' | 'center' | 'end' | WallSide;\n\ninterface FootprintPart {\n hidden?: boolean;\n relPos?: number[];\n dim?: number[];\n fullMatrix?: number[];\n}\n\ninterface FootprintModule {\n modules?: FootprintModule[];\n containers?: FootprintModule[];\n parts?: FootprintPart[];\n}\n\ninterface FootprintRoot extends FootprintModule {\n id?: string;\n articleId?: string;\n isGenerated?: boolean;\n articlePos?: number[];\n rotationY?: number;\n dockInfos?: Array<{ id?: string; start?: number[]; end?: number[] }>;\n attributes?: Array<{ id: string; value?: unknown }>;\n}\n\nexport interface CornerGeometry {\n rootId: string;\n point: [number, number];\n directions: [[number, number], [number, number]];\n}\n\nexport interface FootprintGroup {\n ver?: number;\n roots?: FootprintRoot[];\n}\n\n// + 0 turns IEEE -0 into +0 so serialized values never show -0\nexport const round2 = (value: number): number =>\n Math.round(value * 100) / 100 + 0;\n\nconst toRadians = (degrees: number): number => (degrees * Math.PI) / 180;\n\nconst toDegrees = (radians: number): number => (radians * 180) / Math.PI;\n\nconst normalizeDegrees = (degrees: number): number => {\n const normalized = degrees % 360;\n return normalized < 0 ? normalized + 360 : normalized;\n};\n\ntype Point3 = [number, number, number];\n\nexport const transformPointByMatrix = (\n matrix: number[],\n point: Point3,\n): Point3 => {\n const [x, y, z] = point;\n return [\n matrix[0] * x + matrix[4] * y + matrix[8] * z + matrix[12],\n matrix[1] * x + matrix[5] * y + matrix[9] * z + matrix[13],\n matrix[2] * x + matrix[6] * y + matrix[10] * z + matrix[14],\n ];\n};\n\nexport const transformPointByRoot = (\n root: FootprintRoot,\n point: Point3,\n): Point3 => {\n const theta = toRadians(root.rotationY ?? 0);\n const [translationX, translationY, translationZ] = root.articlePos ?? [\n 0, 0, 0,\n ];\n const [x, y, z] = point;\n return [\n translationX + x * Math.cos(theta) + z * Math.sin(theta),\n translationY + y,\n translationZ - x * Math.sin(theta) + z * Math.cos(theta),\n ];\n};\n\nexport const groupPointToRoot = (\n root: { articlePos?: number[]; rotationY?: number },\n point: Point3,\n): Point3 => {\n const theta = toRadians(root.rotationY ?? 0);\n const [translationX, translationY, translationZ] = root.articlePos ?? [\n 0, 0, 0,\n ];\n const x = point[0] - translationX;\n const z = point[2] - translationZ;\n return [\n x * Math.cos(theta) - z * Math.sin(theta),\n point[1] - translationY,\n x * Math.sin(theta) + z * Math.cos(theta),\n ];\n};\n\nconst collectParts = (module: FootprintModule, parts: FootprintPart[]) => {\n for (const part of module.parts ?? []) {\n if (\n !part.hidden &&\n (part.relPos?.length ?? 0) >= 3 &&\n (part.dim?.length ?? 0) >= 3 &&\n part.fullMatrix?.length === 16\n ) {\n parts.push(part);\n }\n }\n for (const subModule of module.modules ?? []) {\n collectParts(subModule, parts);\n }\n for (const container of module.containers ?? []) {\n collectParts(container, parts);\n }\n};\n\nexport const boxCorners = (minimum: number[], size: number[]): Point3[] => {\n const corners: Point3[] = [];\n for (const offsetX of [0, size[0]]) {\n for (const offsetY of [0, size[1]]) {\n for (const offsetZ of [0, size[2]]) {\n corners.push([\n minimum[0] + offsetX,\n minimum[1] + offsetY,\n minimum[2] + offsetZ,\n ]);\n }\n }\n }\n return corners;\n};\n\nconst dimensionAttribute = (\n root: FootprintRoot,\n attributeId: string,\n): number | undefined => {\n const value = Number(\n root.attributes?.find((attribute) => attribute.id === attributeId)?.value,\n );\n return Number.isFinite(value) && value > 0 ? value : undefined;\n};\n\nconst rootFootprintPoints = (\n root: FootprintRoot,\n partMatricesAreGroupSpace: boolean,\n): Array<[number, number]> => {\n const parts: FootprintPart[] = [];\n collectParts(root, parts);\n const points: Array<[number, number]> = [];\n for (const part of parts) {\n for (const corner of boxCorners(part.relPos!, part.dim!)) {\n let point = transformPointByMatrix(part.fullMatrix!, corner);\n if (!partMatricesAreGroupSpace) {\n point = transformPointByRoot(root, point);\n }\n points.push([point[0], point[2]]);\n }\n }\n if (points.length > 0) {\n return points;\n }\n for (const dockInfo of root.dockInfos ?? []) {\n for (const dockPoint of [dockInfo.start, dockInfo.end]) {\n if ((dockPoint?.length ?? 0) >= 3) {\n const point = transformPointByRoot(root, [\n dockPoint![0],\n dockPoint![1],\n dockPoint![2],\n ]);\n points.push([point[0], point[2]]);\n }\n }\n }\n if (points.length > 0) {\n return points;\n }\n const width = dimensionAttribute(root, 'b');\n const depth = dimensionAttribute(root, 't');\n if (width !== undefined && depth !== undefined) {\n for (const corner of boxCorners([0, 0, 0], [width, 0, depth])) {\n const point = transformPointByRoot(root, corner);\n points.push([point[0], point[2]]);\n }\n }\n return points;\n};\n\nexport const groupFootprint = (\n group: FootprintGroup,\n): GroupFootprint | undefined => {\n const partMatricesAreGroupSpace = (group.ver ?? 0) > 0;\n const points: Array<[number, number]> = [];\n for (const root of group.roots ?? []) {\n points.push(...rootFootprintPoints(root, partMatricesAreGroupSpace));\n }\n if (points.length === 0) {\n return undefined;\n }\n let minX = Number.POSITIVE_INFINITY;\n let maxX = Number.NEGATIVE_INFINITY;\n let minZ = Number.POSITIVE_INFINITY;\n let maxZ = Number.NEGATIVE_INFINITY;\n for (const [x, z] of points) {\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n minZ = Math.min(minZ, z);\n maxZ = Math.max(maxZ, z);\n }\n return {\n x: [round2(minX), round2(maxX)],\n z: [round2(minZ), round2(maxZ)],\n widthMm: round2(maxX - minX),\n depthMm: round2(maxZ - minZ),\n };\n};\n\nconst rootHeights = (\n root: FootprintRoot,\n partMatricesAreGroupSpace: boolean,\n): number[] => {\n const parts: FootprintPart[] = [];\n collectParts(root, parts);\n const heights: number[] = [];\n for (const part of parts) {\n for (const corner of boxCorners(part.relPos!, part.dim!)) {\n let point = transformPointByMatrix(part.fullMatrix!, corner);\n if (!partMatricesAreGroupSpace) {\n point = transformPointByRoot(root, point);\n }\n heights.push(point[1]);\n }\n }\n if (heights.length > 0) {\n return heights;\n }\n for (const dockInfo of root.dockInfos ?? []) {\n for (const dockPoint of [dockInfo.start, dockInfo.end]) {\n if ((dockPoint?.length ?? 0) >= 3) {\n heights.push(\n transformPointByRoot(root, [\n dockPoint![0],\n dockPoint![1],\n dockPoint![2],\n ])[1],\n );\n }\n }\n }\n const height = dimensionAttribute(root, 'h');\n if (height !== undefined) {\n const bottom = root.articlePos?.[1] ?? 0;\n heights.push(bottom, bottom + height);\n }\n return heights;\n};\n\n// The kernel docks a CollisionBox too, which is no docking vector.\nconst dockingVectorsOf = (root: FootprintRoot) =>\n (root.dockInfos ?? []).filter(\n (dockInfo) =>\n dockInfo.id !== 'CollisionBox' &&\n (dockInfo.start?.length ?? 0) >= 3 &&\n (dockInfo.end?.length ?? 0) >= 3,\n );\n\nexport interface DockingBox {\n min: [number, number, number];\n max: [number, number, number];\n}\n\n// The box of a root module's docking vectors in group space; undefined\n// without docking vectors.\nexport const dockingVectorBox = (\n root: FootprintRoot,\n): DockingBox | undefined => {\n const points = dockingVectorsOf(root).flatMap((dockInfo) =>\n [dockInfo.start!, dockInfo.end!].map((point) =>\n transformPointByRoot(root, [point[0], point[1], point[2]]),\n ),\n );\n if (points.length === 0) {\n return undefined;\n }\n const axis = (index: number, pick: (...values: number[]) => number) =>\n pick(...points.map((point) => point[index]));\n return {\n min: [axis(0, Math.min), axis(1, Math.min), axis(2, Math.min)],\n max: [axis(0, Math.max), axis(1, Math.max), axis(2, Math.max)],\n };\n};\n\n// The start point of a root module's docking vector in group space.\nexport const dockingVectorStart = (\n root: FootprintRoot,\n vectorId: string,\n): [number, number, number] | undefined => {\n const start = dockingVectorsOf(root).find(\n (dockInfo) => dockInfo.id === vectorId,\n )?.start;\n return start && transformPointByRoot(root, [start[0], start[1], start[2]]);\n};\n\n// The direction of a root module's docking vector in group space, as a unit\n// vector; undefined for a vector the root does not have or one without length.\nexport const dockingVectorDirection = (\n root: FootprintRoot,\n vectorId: string,\n): [number, number, number] | undefined => {\n const vector = dockingVectorsOf(root).find(\n (dockInfo) => dockInfo.id === vectorId,\n );\n if (!vector) {\n return undefined;\n }\n const [start, end] = [vector.start!, vector.end!].map((point) =>\n transformPointByRoot(root, [point[0], point[1], point[2]]),\n );\n const length = Math.hypot(\n end[0] - start[0],\n end[1] - start[1],\n end[2] - start[2],\n );\n return length < 1e-6\n ? undefined\n : [\n (end[0] - start[0]) / length,\n (end[1] - start[1]) / length,\n (end[2] - start[2]) / length,\n ];\n};\n\n// The vertical extent of a group in group space; undefined without height data.\nexport const groupHeightRange = (\n group: FootprintGroup,\n): [number, number] | undefined => {\n const partMatricesAreGroupSpace = (group.ver ?? 0) > 0;\n const heights = (group.roots ?? []).flatMap((root) =>\n rootHeights(root, partMatricesAreGroupSpace),\n );\n if (heights.length === 0) {\n return undefined;\n }\n const bottom = Math.min(...heights);\n const top = Math.max(...heights);\n return top - bottom < 1 ? undefined : [round2(bottom), round2(top)];\n};\n\nconst POINT_EPSILON_MM = 1;\n\nconst samePoint = (a: [number, number], b: [number, number]): boolean =>\n Math.hypot(a[0] - b[0], a[1] - b[1]) < POINT_EPSILON_MM;\n\nconst unitDirection = (\n from: [number, number],\n to: [number, number],\n): [number, number] | undefined => {\n const length = Math.hypot(to[0] - from[0], to[1] - from[1]);\n return length < 1e-6\n ? undefined\n : [(to[0] - from[0]) / length, (to[1] - from[1]) / length];\n};\n\nexport const rotateDirection = (\n [x, z]: [number, number],\n degrees: number,\n): [number, number] => {\n const theta = toRadians(degrees);\n return [\n x * Math.cos(theta) + z * Math.sin(theta),\n -x * Math.sin(theta) + z * Math.cos(theta),\n ];\n};\n\nconst sameDirection = (a: [number, number], b: [number, number]): boolean =>\n a[0] * b[0] + a[1] * b[1] > 0.999;\n\nconst rootCornerGeometry = (\n root: FootprintRoot,\n): CornerGeometry | undefined => {\n const vectorPair = (row: 'Bottom' | 'Top') => ({\n left: root.dockInfos?.find((dockInfo) => dockInfo.id === `LeftBack${row}`),\n right: root.dockInfos?.find(\n (dockInfo) => dockInfo.id === `RightBack${row}`,\n ),\n });\n const bottom = vectorPair('Bottom');\n const { left, right } =\n bottom.left && bottom.right ? bottom : vectorPair('Top');\n if (!left?.start || !left.end || !right?.start || !right.end) {\n return undefined;\n }\n const toGroupXz = (point: number[]): [number, number] => {\n const [x, , z] = transformPointByRoot(root, [point[0], point[1], point[2]]);\n return [x, z];\n };\n const leftStart = toGroupXz(left.start);\n const rightStart = toGroupXz(right.start);\n const leftDirection = unitDirection(leftStart, toGroupXz(left.end));\n const rightDirection = unitDirection(rightStart, toGroupXz(right.end));\n // one corner point and two back edges running along different walls\n if (\n !samePoint(leftStart, rightStart) ||\n !leftDirection ||\n !rightDirection ||\n Math.abs(\n leftDirection[0] * rightDirection[0] +\n leftDirection[1] * rightDirection[1],\n ) > 0.01\n ) {\n return undefined;\n }\n return {\n rootId: root.id ?? '',\n point: rightStart,\n directions: [leftDirection, rightDirection],\n };\n};\n\nexport const groupCornerGeometry = (\n group: FootprintGroup,\n): CornerGeometry | undefined => {\n for (const root of group.roots ?? []) {\n const geometry = rootCornerGeometry(root);\n if (geometry) {\n return geometry;\n }\n }\n return undefined;\n};\n\nconst wallFloorPoints = ({\n start,\n end,\n}: DerivedWall): [[number, number], [number, number]] => [\n [start[0], start[2]],\n [end[0], end[2]],\n];\n\nexport const sharedCorner = (\n wall: DerivedWall,\n other: DerivedWall,\n): [number, number] | undefined =>\n wallFloorPoints(wall).find((point) =>\n wallFloorPoints(other).some((candidate) => samePoint(point, candidate)),\n );\n\n// The wall on the given side of the room that meets this wall in a corner.\nexport const adjoiningWall = (\n walls: DerivedWall[],\n wall: DerivedWall,\n side: WallSide,\n): DerivedWall | undefined =>\n walls.find(\n (candidate) =>\n candidate.index !== wall.index &&\n candidate.side === side &&\n candidate.type === 'wall' &&\n sharedCorner(wall, candidate) !== undefined,\n );\n\nconst continuesStraight = (from: DerivedWall, to: DerivedWall): boolean => {\n const [fromStart, fromEnd] = wallFloorPoints(from);\n const [toStart, toEnd] = wallFloorPoints(to);\n const along = unitDirection(fromStart, fromEnd);\n const next = unitDirection(toStart, toEnd);\n return (\n from !== to &&\n from.side === to.side &&\n samePoint(fromEnd, toStart) &&\n along !== undefined &&\n next !== undefined &&\n along[0] * next[0] + along[1] * next[1] > 0.999\n );\n};\n\nconst faceOf = (pieces: DerivedWall[]): WallFace => {\n const first = pieces[0];\n const solid = pieces.find((piece) => piece.type === 'wall');\n return {\n ...(solid ?? first),\n index: first.index,\n start: first.start,\n end: pieces[pieces.length - 1].end,\n lengthMm: round2(pieces.reduce((sum, piece) => sum + piece.lengthMm, 0)),\n type: solid ? 'wall' : first.type,\n pieces,\n };\n};\n\n// The faces of a room's walls: every run of walls that continue each other\n// in a straight line - a door or a floor-to-ceiling window splits the wall in\n// the contour (D61) - also across the start of the contour. A face is a wall\n// when one of its pieces is.\nexport const wallFaces = (walls: DerivedWall[]): WallFace[] => {\n const next = new Map<DerivedWall, DerivedWall>();\n for (const wall of walls) {\n const following = walls.find((candidate) =>\n continuesStraight(wall, candidate),\n );\n if (following) {\n next.set(wall, following);\n }\n }\n const continued = new Set(next.values());\n const visited = new Set<DerivedWall>();\n const faces: WallFace[] = [];\n for (const first of [\n ...walls.filter((wall) => !continued.has(wall)),\n ...walls,\n ]) {\n const pieces: DerivedWall[] = [];\n for (\n let piece: DerivedWall | undefined = first;\n piece && !visited.has(piece);\n piece = next.get(piece)\n ) {\n visited.add(piece);\n pieces.push(piece);\n }\n if (pieces.length > 0) {\n faces.push(faceOf(pieces));\n }\n }\n return faces;\n};\n\nconst WALL_NAMES: Record<WallSide, string> = {\n top: 'back wall',\n bottom: 'front wall',\n left: 'left wall',\n right: 'right wall',\n};\n\n// The name of a wall in the words of the user: back and front for the top and\n// the bottom of the top-view image.\nexport const wallName = (side: WallSide): string =>\n WALL_NAMES[side] ?? `${side} wall`;\n\nexport interface RoomCorner {\n name: string;\n point: [number, number, number];\n posRotationY: number;\n}\n\n// The corners of a room: where a wall or an opening ends and the next starts\n// at an angle that turns into the room - towards the side the ending one\n// faces, as the room lies left of the contour (D61). A partition and the inner\n// corner of an L-shaped room turn away from it and give none. The name is\n// back/front plus left/right, and posRotationY is the facingRotationY of the\n// wall that ends in the corner - the rotation of a corner kitchen there, for\n// both hands of corner article (D13, D33, D83).\nexport const roomCorners = (walls: DerivedWall[]): RoomCorner[] => {\n const corners: RoomCorner[] = [];\n for (const ending of walls) {\n const [endingStart, endPoint] = wallFloorPoints(ending);\n const along = unitDirection(endingStart, endPoint);\n for (const starting of walls) {\n const [startPoint, startingEnd] = wallFloorPoints(starting);\n const next = unitDirection(startPoint, startingEnd);\n if (\n starting === ending ||\n !samePoint(endPoint, startPoint) ||\n !along ||\n !next ||\n Math.abs(along[0] * next[0] + along[1] * next[1]) > 0.999 ||\n along[1] * next[0] - along[0] * next[1] <= 0\n ) {\n continue;\n }\n const sides = [ending.side, starting.side];\n const depth = sides.find((side) => side === 'top' || side === 'bottom');\n const hand = sides.find((side) => side === 'left' || side === 'right');\n if (!depth || !hand) {\n continue;\n }\n corners.push({\n name: `${depth === 'top' ? 'back' : 'front'} ${hand}`,\n point: [endPoint[0], 0, endPoint[1]],\n posRotationY: ending.facingRotationY,\n });\n }\n }\n return corners;\n};\n\n// The floor rings of a room: the start points of its walls in contour order\n// (openings included - they are contour segments too), one ring per contour\n// subpath - the outer contour, then a partition or column inside it.\nconst roomRings = (walls: DerivedWall[]): Array<Array<[number, number]>> => {\n const rings: Array<Array<[number, number]>> = [];\n let previous: DerivedWall | undefined;\n for (const wall of walls) {\n const continues =\n previous &&\n Math.hypot(\n previous.end[0] - wall.start[0],\n previous.end[2] - wall.start[2],\n ) < 1e-6;\n if (!continues) {\n rings.push([]);\n }\n rings[rings.length - 1].push([wall.start[0], wall.start[2]]);\n previous = wall;\n }\n return rings.filter((ring) => ring.length >= 3);\n};\n\nconst distanceToSegment = (\n [px, pz]: [number, number],\n [ax, az]: [number, number],\n [bx, bz]: [number, number],\n): number => {\n const lengthSquared = (bx - ax) ** 2 + (bz - az) ** 2;\n const t =\n lengthSquared < 1e-9\n ? 0\n : Math.max(\n 0,\n Math.min(\n 1,\n ((px - ax) * (bx - ax) + (pz - az) * (bz - az)) / lengthSquared,\n ),\n );\n return Math.hypot(px - (ax + t * (bx - ax)), pz - (az + t * (bz - az)));\n};\n\n// Whether a floor point lies inside the room's contour or within the\n// tolerance of one of its walls - also for an L-shaped room, whose cut-out\n// lies inside the bounding box of its walls.\nexport const pointInsideRoom = (\n point: [number, number],\n walls: DerivedWall[],\n toleranceMm: number,\n): boolean => {\n const rings = roomRings(walls);\n if (rings.length === 0) {\n return false;\n }\n // even-odd over every ring: inside the outer contour, and not inside a\n // partition or column\n let inside = false;\n for (const ring of rings) {\n for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {\n const [xi, zi] = ring[i];\n const [xj, zj] = ring[j];\n if (\n zi > point[1] !== zj > point[1] &&\n point[0] < ((xj - xi) * (point[1] - zi)) / (zj - zi) + xi\n ) {\n inside = !inside;\n }\n }\n }\n return (\n inside ||\n walls.some(\n (wall) =>\n distanceToSegment(\n point,\n [wall.start[0], wall.start[2]],\n [wall.end[0], wall.end[2]],\n ) <= toleranceMm,\n )\n );\n};\n\n// The room of the plan whose floor holds the point; undefined when none does.\nexport const roomOfPoint = <T extends { walls?: DerivedWall[] }>(\n rooms: T[],\n point: [number, number],\n toleranceMm: number,\n): T | undefined =>\n rooms.find((room) => pointInsideRoom(point, room.walls ?? [], toleranceMm));\n\n// The point nearest to `near` where a footprint - its corners relative to the\n// point, at its heights - lies inside the room and overlaps no blocker: the\n// square rings around `near` in steps of stepMm, up to maxRadiusMm, nearest\n// ring first. Undefined when there is no such point.\nexport const freePointInRoom = (\n walls: DerivedWall[],\n blockers: PlacedVolume[],\n footprint: PlacedVolume,\n near: [number, number],\n toleranceMm: number,\n stepMm = 300,\n maxRadiusMm = 3000,\n): [number, number] | undefined => {\n const isFree = (point: [number, number]): boolean => {\n const corners = footprint.corners.map(([x, z]): [number, number] => [\n point[0] + x,\n point[1] + z,\n ]);\n if (!footprintInsideRoom(corners, walls, toleranceMm)) {\n return false;\n }\n if (!footprint.heights) {\n return true;\n }\n const volume: PlacedVolume = { corners, heights: footprint.heights };\n return !blockers.some((blocker) =>\n volumesOverlap(volume, blocker, toleranceMm),\n );\n };\n if (isFree(near)) {\n return near;\n }\n for (let radius = stepMm; radius <= maxRadiusMm; radius += stepMm) {\n for (let dx = -radius; dx <= radius; dx += stepMm) {\n for (let dz = -radius; dz <= radius; dz += stepMm) {\n if (Math.max(Math.abs(dx), Math.abs(dz)) !== radius) {\n continue;\n }\n const point: [number, number] = [near[0] + dx, near[1] + dz];\n if (isFree(point)) {\n return point;\n }\n }\n }\n }\n return undefined;\n};\n\n// Puts the corner point of a corner article into the corner the two walls\n// share and turns the group so that its two back edges run along the walls.\n// Undefined when the article's back edges cannot be matched to both walls.\nexport const placeCornerAtWalls = (\n wall: DerivedWall,\n adjoining: DerivedWall,\n corner: CornerGeometry,\n offsetMm: number,\n): { pos: [number, number, number]; rotationY: number } | undefined => {\n const cornerPoint = sharedCorner(wall, adjoining);\n if (!cornerPoint) {\n return undefined;\n }\n const otherEnd = (candidate: DerivedWall): [number, number] => {\n const [start, end] = wallFloorPoints(candidate);\n return samePoint(start, cornerPoint) ? end : start;\n };\n const alongWall = unitDirection(cornerPoint, otherEnd(wall));\n const alongAdjoining = unitDirection(cornerPoint, otherEnd(adjoining));\n if (!alongWall || !alongAdjoining) {\n return undefined;\n }\n const [leftDirection, rightDirection] = corner.directions;\n const assignments: Array<[[number, number], [number, number]]> = [\n [alongWall, alongAdjoining],\n [alongAdjoining, alongWall],\n ];\n for (const [leftTarget, rightTarget] of assignments) {\n const angle = toDegrees(\n Math.atan2(leftDirection[1], leftDirection[0]) -\n Math.atan2(leftTarget[1], leftTarget[0]),\n );\n for (const rotationY of [angle, -angle]) {\n if (\n sameDirection(rotateDirection(leftDirection, rotationY), leftTarget) &&\n sameDirection(rotateDirection(rightDirection, rotationY), rightTarget)\n ) {\n const rotatedPoint = rotateDirection(corner.point, rotationY);\n return {\n pos: [\n round2(cornerPoint[0] - rotatedPoint[0] + alongWall[0] * offsetMm),\n 0,\n round2(cornerPoint[1] - rotatedPoint[1] + alongWall[1] * offsetMm),\n ],\n rotationY: round2(normalizeDegrees(rotationY)),\n };\n }\n }\n }\n return undefined;\n};\n\nexport interface GroupPlacementTransform {\n pos: [number, number, number];\n rotationY: number;\n}\n\ninterface PlacedGroup {\n pos?: number[];\n rotationY?: number;\n}\n\nexport const groupPointToRoom = (\n group: PlacedGroup,\n [x, z]: [number, number],\n): [number, number] => {\n const [roomX, , roomZ] = transformPointByRoot(\n { articlePos: group.pos, rotationY: group.rotationY },\n [x, 0, z],\n );\n return [roomX, roomZ];\n};\n\nexport const footprintCornersInRoom = (\n footprint: GroupFootprint,\n group: PlacedGroup,\n): Array<[number, number]> => {\n const [minX, maxX] = footprint.x;\n const [minZ, maxZ] = footprint.z;\n const corners: Array<[number, number]> = [\n [minX, minZ],\n [maxX, minZ],\n [maxX, maxZ],\n [minX, maxZ],\n ];\n return corners.map((corner) => groupPointToRoom(group, corner));\n};\n\nexport const rootFootprintInRoom = (\n group: FootprintGroup & PlacedGroup,\n root: FootprintRoot,\n): Array<[number, number]> =>\n rootFootprintPoints(root, (group.ver ?? 0) > 0).map((point) =>\n groupPointToRoom(group, point),\n );\n\nconst edgeNormals = (\n polygon: Array<[number, number]>,\n): Array<[number, number]> => {\n const normals: Array<[number, number]> = [];\n for (let index = 0; index < polygon.length; index++) {\n const [fromX, fromZ] = polygon[index];\n const [toX, toZ] = polygon[(index + 1) % polygon.length];\n const normal = unitDirection([fromX, fromZ], [toX, toZ]);\n if (normal) {\n normals.push([-normal[1], normal[0]]);\n }\n }\n return normals;\n};\n\nconst projectOntoAxis = (\n polygon: Array<[number, number]>,\n [axisX, axisZ]: [number, number],\n): [number, number] => {\n let minimum = Number.POSITIVE_INFINITY;\n let maximum = Number.NEGATIVE_INFINITY;\n for (const [x, z] of polygon) {\n const projection = x * axisX + z * axisZ;\n minimum = Math.min(minimum, projection);\n maximum = Math.max(maximum, projection);\n }\n return [minimum, maximum];\n};\n\nconst cross = (\n [originX, originZ]: [number, number],\n [aX, aZ]: [number, number],\n [bX, bZ]: [number, number],\n): number => (aX - originX) * (bZ - originZ) - (aZ - originZ) * (bX - originX);\n\n// The convex hull of floor points (monotone chain). convexPolygonsTouch holds\n// for convex outlines only; an L-shaped sofa is tested like its hull.\nexport const convexHull = (\n points: Array<[number, number]>,\n): Array<[number, number]> => {\n const sorted = [...points].sort(([aX, aZ], [bX, bZ]) => aX - bX || aZ - bZ);\n if (sorted.length < 3) {\n return sorted;\n }\n const halfHull = (\n ordered: Array<[number, number]>,\n ): Array<[number, number]> => {\n const chain: Array<[number, number]> = [];\n for (const point of ordered) {\n while (\n chain.length >= 2 &&\n cross(chain[chain.length - 2], chain[chain.length - 1], point) <= 0\n ) {\n chain.pop();\n }\n chain.push(point);\n }\n return chain.slice(0, -1);\n };\n return [...halfHull(sorted), ...halfHull([...sorted].reverse())];\n};\n\n// Two convex footprints touch when no edge normal of either separates them by\n// more than the tolerance (separating axis theorem); flush contact counts.\nexport const convexPolygonsTouch = (\n a: Array<[number, number]>,\n b: Array<[number, number]>,\n toleranceMm: number,\n): boolean => {\n if (a.length < 3 || b.length < 3) {\n return false;\n }\n for (const axis of [...edgeNormals(a), ...edgeNormals(b)]) {\n const [minA, maxA] = projectOntoAxis(a, axis);\n const [minB, maxB] = projectOntoAxis(b, axis);\n if (maxA < minB - toleranceMm || maxB < minA - toleranceMm) {\n return false;\n }\n }\n return true;\n};\n\n// Whether a wall reaches into a convex footprint by more than the tolerance:\n// the separating axis test with the wall as a segment; flush contact is none.\nconst wallEntersFootprint = (\n wall: DerivedWall,\n footprint: Array<[number, number]>,\n toleranceMm: number,\n): boolean => {\n const segment: Array<[number, number]> = [\n [wall.start[0], wall.start[2]],\n [wall.end[0], wall.end[2]],\n ];\n return [...edgeNormals(footprint), ...edgeNormals(segment)].every((axis) => {\n const [minFootprint, maxFootprint] = projectOntoAxis(footprint, axis);\n const [minWall, maxWall] = projectOntoAxis(segment, axis);\n return (\n maxFootprint - minWall > toleranceMm &&\n maxWall - minFootprint > toleranceMm\n );\n });\n};\n\n// Whether a convex footprint lies inside the room: its corners inside the\n// contour or within the tolerance of a wall, and no wall reaching into it -\n// the edge of an L-shaped room's cut-out between two corners, or a partition\n// or column the footprint encloses.\nexport const footprintInsideRoom = (\n corners: Array<[number, number]>,\n walls: DerivedWall[],\n toleranceMm: number,\n): boolean =>\n corners.every((corner) => pointInsideRoom(corner, walls, toleranceMm)) &&\n !walls.some((wall) => wallEntersFootprint(wall, corners, toleranceMm));\n\nexport interface PlacedVolume {\n corners: Array<[number, number]>;\n heights?: [number, number];\n}\n\n// Two placed groups overlap when their footprints and their height ranges\n// overlap by more than the tolerance; touching is no overlap, and a group\n// without height data overlaps nothing.\nexport const volumesOverlap = (\n a: PlacedVolume,\n b: PlacedVolume,\n toleranceMm: number,\n): boolean =>\n a.heights !== undefined &&\n b.heights !== undefined &&\n a.heights[1] > b.heights[0] + toleranceMm &&\n b.heights[1] > a.heights[0] + toleranceMm &&\n convexPolygonsTouch(a.corners, b.corners, -toleranceMm);\n\n// The extent of room points along a wall, measured from the wall's start.\nexport const spanAlongWall = (\n wall: DerivedWall,\n points: Array<[number, number]>,\n): [number, number] => {\n const [[startX, startZ], [endX, endZ]] = wallFloorPoints(wall);\n const length = Math.hypot(endX - startX, endZ - startZ);\n const along: [number, number] = [\n (endX - startX) / length,\n (endZ - startZ) / length,\n ];\n return projectOntoAxis(\n points.map(([x, z]) => [x - startX, z - startZ]),\n along,\n );\n};\n\nexport interface WallOfOpening {\n roomIndex: number;\n wall: number;\n fromEndMm: [number, number];\n}\n\n// The wall a door or a window lies in: the wall whose line its floor outline\n// touches - within the wall's thickness - over the longest stretch. The span\n// is measured from the wall's end, like the d of a placement.\nexport const wallOfOpening = (\n outline: Array<[number, number]>,\n rooms: Array<{ walls?: DerivedWall[] }>,\n): WallOfOpening | undefined => {\n let found: WallOfOpening | undefined;\n let longestOverlap = POINT_EPSILON_MM;\n rooms.forEach((room, roomIndex) => {\n for (const wall of room.walls ?? []) {\n const [[startX, startZ], [endX, endZ]] = wallFloorPoints(wall);\n const along = unitDirection([startX, startZ], [endX, endZ]);\n if (!along) {\n continue;\n }\n const distanceToLine = Math.min(\n ...outline.map(([x, z]) =>\n Math.abs((x - startX) * along[1] - (z - startZ) * along[0]),\n ),\n );\n if (distanceToLine > (wall.thicknessMm ?? 0) + POINT_EPSILON_MM) {\n continue;\n }\n const length = Math.hypot(endX - startX, endZ - startZ);\n const [from, to] = spanAlongWall(wall, outline);\n const overlap = Math.min(to, length) - Math.max(from, 0);\n if (overlap > longestOverlap) {\n longestOverlap = overlap;\n found = {\n roomIndex,\n wall: wall.index,\n fromEndMm: [\n round2(length - Math.min(to, length)),\n round2(length - Math.max(from, 0)),\n ],\n };\n }\n }\n });\n return found;\n};\n\nexport interface RootVolume extends PlacedVolume {\n id: string;\n articleId?: string;\n rotationY: number;\n}\n\n// Every root module of a calculated group but the generated ones, as the box\n// of its parts in room space with its height and its rotation in the room.\nexport const rootVolumesInRoom = (\n group: FootprintGroup & PlacedGroup,\n): RootVolume[] => {\n const partMatricesAreGroupSpace = (group.ver ?? 0) > 0;\n const groupY = group.pos?.[1] ?? 0;\n return (group.roots ?? []).flatMap((root) => {\n const points = root.isGenerated\n ? []\n : rootFootprintPoints(root, partMatricesAreGroupSpace);\n if (points.length === 0) {\n return [];\n }\n const xs = points.map(([x]) => x);\n const zs = points.map(([, z]) => z);\n const [minX, maxX] = [Math.min(...xs), Math.max(...xs)];\n const [minZ, maxZ] = [Math.min(...zs), Math.max(...zs)];\n const corners = (\n [\n [minX, minZ],\n [maxX, minZ],\n [maxX, maxZ],\n [minX, maxZ],\n ] as Array<[number, number]>\n ).map((corner) => groupPointToRoom(group, corner));\n const heights = rootHeights(root, partMatricesAreGroupSpace);\n const [bottom, top] = [Math.min(...heights), Math.max(...heights)];\n return [\n {\n id: root.id ?? '',\n ...(root.articleId !== undefined && { articleId: root.articleId }),\n corners,\n ...(top - bottom >= 1 && {\n heights: [bottom + groupY, top + groupY] as [number, number],\n }),\n rotationY: normalizeDegrees(\n (group.rotationY ?? 0) + (root.rotationY ?? 0),\n ),\n },\n ];\n });\n};\n\n// Every root module of a calculated group but the generated ones, as the box\n// of its docking vectors in room space: the body its neighbours dock to,\n// without the parts that reach past the docking edges over a neighbour (D146).\nexport const rootDockingVolumesInRoom = (\n group: FootprintGroup & PlacedGroup,\n): RootVolume[] => {\n const groupY = group.pos?.[1] ?? 0;\n return (group.roots ?? []).flatMap((root) => {\n const box = root.isGenerated ? undefined : dockingVectorBox(root);\n if (!box) {\n return [];\n }\n const corners = (\n [\n [box.min[0], box.min[2]],\n [box.max[0], box.min[2]],\n [box.max[0], box.max[2]],\n [box.min[0], box.max[2]],\n ] as Array<[number, number]>\n ).map((corner) => groupPointToRoom(group, corner));\n return [\n {\n id: root.id ?? '',\n ...(root.articleId !== undefined && { articleId: root.articleId }),\n corners,\n ...(box.max[1] - box.min[1] >= 1 && {\n heights: [box.min[1] + groupY, box.max[1] + groupY] as [\n number,\n number,\n ],\n }),\n rotationY: normalizeDegrees(\n (group.rotationY ?? 0) + (root.rotationY ?? 0),\n ),\n },\n ];\n });\n};\n\n// Into the room from a wall: the front of a group with its back to the wall.\nconst intoRoom = (wall: DerivedWall): [number, number] =>\n rotateDirection([0, 1], wall.facingRotationY);\n\nconst distanceFromWall = (\n wall: DerivedWall,\n [x, z]: [number, number],\n): number => {\n const [[startX, startZ]] = wallFloorPoints(wall);\n const [inX, inZ] = intoRoom(wall);\n return (x - startX) * inX + (z - startZ) * inZ;\n};\n\nconst pointAlongWall = (\n wall: DerivedWall,\n fromEndMm: number,\n intoRoomMm: number,\n): [number, number] => {\n const [[startX, startZ], [endX, endZ]] = wallFloorPoints(wall);\n const length = Math.hypot(endX - startX, endZ - startZ);\n const [inX, inZ] = intoRoom(wall);\n return [\n endX + ((startX - endX) * fromEndMm) / length + inX * intoRoomMm,\n endZ + ((startZ - endZ) * fromEndMm) / length + inZ * intoRoomMm,\n ];\n};\n\n// The floor in front of a span of a wall, measured from the wall's end,\n// reaching depthMm into the room.\nexport const stripInFrontOfWall = (\n wall: DerivedWall,\n [fromEndMm, toEndMm]: [number, number],\n depthMm: number,\n): Array<[number, number]> => [\n pointAlongWall(wall, fromEndMm, 0),\n pointAlongWall(wall, toEndMm, 0),\n pointAlongWall(wall, toEndMm, depthMm),\n pointAlongWall(wall, fromEndMm, depthMm),\n];\n\nconst sameAngle = (a: number, b: number): boolean => {\n const turn = normalizeDegrees(a - b);\n return Math.min(turn, 360 - turn) < 0.5;\n};\n\n// Two walls that face the same way or opposite ways: neither adjoins the\n// other.\nexport const wallsRunParallel = (a: DerivedWall, b: DerivedWall): boolean =>\n sameAngle(a.facingRotationY, b.facingRotationY) ||\n sameAngle(a.facingRotationY, b.facingRotationY + 180);\n\n// The wall a root module faces away from: turned like the wall's\n// facingRotationY, beside it along the wall, and with its back nearest to it,\n// at most depthMm away. A corner unit touches two walls; its rotation tells.\nexport const wallOfRoot = <T extends DerivedWall>(\n walls: T[],\n root: RootVolume,\n depthMm: number,\n): T | undefined => {\n let found: T | undefined;\n let nearest = depthMm;\n for (const wall of walls) {\n if (\n wall.type !== 'wall' ||\n !sameAngle(wall.facingRotationY, root.rotationY)\n ) {\n continue;\n }\n const [from, to] = spanAlongWall(wall, root.corners);\n if (Math.min(to, wall.lengthMm) - Math.max(from, 0) <= POINT_EPSILON_MM) {\n continue;\n }\n const back = Math.abs(\n Math.min(...root.corners.map((corner) => distanceFromWall(wall, corner))),\n );\n if (back <= nearest) {\n nearest = back;\n found = wall;\n }\n }\n return found;\n};\n\n// The stretches of a wall, measured from its end, where the root module -\n// as deep and at the height it is - stands clear of every blocker; stretches\n// narrower than the root module are left out.\nexport const freeStretchesAlongWall = (\n wall: DerivedWall,\n root: RootVolume,\n blockers: PlacedVolume[],\n toleranceMm: number,\n): Array<[number, number]> => {\n const length = wall.lengthMm;\n const depth = Math.max(\n ...root.corners.map((corner) => distanceFromWall(wall, corner)),\n );\n const [rootFrom, rootTo] = spanAlongWall(wall, root.corners);\n if (depth <= 0 || !root.heights) {\n return [];\n }\n const strip: PlacedVolume = {\n corners: stripInFrontOfWall(wall, [0, length], depth),\n heights: root.heights,\n };\n const taken = blockers\n .filter((blocker) => volumesOverlap(strip, blocker, toleranceMm))\n .map((blocker) => spanAlongWall(wall, blocker.corners))\n .map(([from, to]): [number, number] => [\n Math.max(from, 0),\n Math.min(to, length),\n ])\n .filter(([from, to]) => to > from)\n .sort(([a], [b]) => a - b);\n const free: Array<[number, number]> = [];\n let start = 0;\n for (const [from, to] of taken) {\n if (from > start) {\n free.push([start, from]);\n }\n start = Math.max(start, to);\n }\n if (start < length) {\n free.push([start, length]);\n }\n return free\n .filter(([from, to]) => to - from >= rootTo - rootFrom - toleranceMm)\n .map(([from, to]): [number, number] => [\n Math.round(length - to) + 0,\n Math.round(length - from) + 0,\n ])\n .reverse();\n};\n\n// The group placement expressed as the room transform of one root module, so\n// the planner derives the group position from its own arrangement and no root\n// position has to travel in the payload.\nexport const repositioningFromPlacement = (\n placement: GroupPlacementTransform,\n anchor: { id: string; articlePos?: number[]; rotationY?: number },\n): RepositioningData => {\n const [x, y, z] = transformPointByRoot(\n { articlePos: placement.pos, rotationY: placement.rotationY },\n [\n anchor.articlePos?.[0] ?? 0,\n anchor.articlePos?.[1] ?? 0,\n anchor.articlePos?.[2] ?? 0,\n ],\n );\n return {\n posGroup: [round2(x), round2(y), round2(z)],\n posRotationY: round2(\n normalizeDegrees(placement.rotationY + (anchor.rotationY ?? 0)),\n ),\n rootId: anchor.id,\n };\n};\n\nconst alignmentAxis = (alignment: WallSide): 0 | 1 =>\n alignment === 'left' || alignment === 'right' ? 0 : 1;\n\n// A side label names a corner of this wall only when the wall runs towards\n// that side.\nexport const alignmentRunsParallel = (\n wall: DerivedWall,\n alignment: WallSide,\n): boolean => {\n const axis = alignmentAxis(alignment);\n const [start, end] = wallFloorPoints(wall);\n return Math.abs(start[axis] - end[axis]) < 1e-6;\n};\n\n// A side label as alignment means: flush into the corner this wall shares\n// with the wall on that side of the room.\nexport const resolveWallAlignment = (\n wall: DerivedWall,\n alignment: WallAlignment,\n): 'start' | 'center' | 'end' => {\n if (alignment === 'start' || alignment === 'center' || alignment === 'end') {\n return alignment;\n }\n const axis = alignmentAxis(alignment);\n const [start, end] = wallFloorPoints(wall);\n const startCoordinate = start[axis];\n const endCoordinate = end[axis];\n if (alignmentRunsParallel(wall, alignment)) {\n throw new Error(\n `Alignment '${alignment}' runs parallel to this '${wall.side}' wall - ` +\n \"use 'start', 'center', 'end' or the side of an adjoining wall.\",\n );\n }\n const smallerIsCloser = alignment === 'left' || alignment === 'top';\n const startIsCloser = smallerIsCloser\n ? startCoordinate < endCoordinate\n : startCoordinate > endCoordinate;\n return startIsCloser ? 'start' : 'end';\n};\n\n// Where the group's span along the wall starts, measured from the wall's start.\nexport const wallSpanStart = (\n wall: DerivedWall,\n footprint: GroupFootprint,\n alignment: WallAlignment,\n offsetMm: number,\n): number => {\n const resolvedAlignment = resolveWallAlignment(wall, alignment);\n const [[startX, startZ], [endX, endZ]] = wallFloorPoints(wall);\n const length = Math.hypot(endX - startX, endZ - startZ);\n const width = footprint.widthMm;\n if (resolvedAlignment === 'start') {\n return offsetMm;\n }\n if (resolvedAlignment === 'end') {\n return length - width - offsetMm;\n }\n return (length - width) / 2 + offsetMm;\n};\n\n// The offsetMm of the same wall and alignment that moves a group standing\n// along the wall out of a span blocked at one end of it. The spans - of the\n// group, of its root modules in the blocked span and of that span - are\n// measured along the wall from its start. Undefined when the blocked span\n// lies at neither end or at both, or when the moved group would reach past an\n// end of the wall.\nexport const clearingOffsetMm = (\n wall: DerivedWall,\n alignment: WallAlignment,\n [groupFrom, groupTo]: [number, number],\n [rootFrom, rootTo]: [number, number],\n [blockedFrom, blockedTo]: [number, number],\n toleranceMm: number,\n): number | undefined => {\n const [[startX, startZ], [endX, endZ]] = wallFloorPoints(wall);\n const length = Math.hypot(endX - startX, endZ - startZ);\n const atStart = blockedFrom <= toleranceMm;\n const atEnd = blockedTo >= length - toleranceMm;\n if (atStart === atEnd) {\n return undefined;\n }\n const width = groupTo - groupFrom;\n const spanStart =\n groupFrom + (atStart ? blockedTo - rootFrom : blockedFrom - rootTo);\n if (spanStart < -toleranceMm || spanStart + width > length + toleranceMm) {\n return undefined;\n }\n const resolvedAlignment = resolveWallAlignment(wall, alignment);\n const offsetMm =\n resolvedAlignment === 'start'\n ? spanStart\n : resolvedAlignment === 'end'\n ? length - width - spanStart\n : spanStart - (length - width) / 2;\n return Math.round(offsetMm) + 0;\n};\n\nexport const placeAgainstWall = (\n wall: DerivedWall,\n footprint: GroupFootprint,\n alignment: WallAlignment,\n offsetMm: number,\n): { pos: [number, number, number]; rotationY: number } => {\n const [[startX, startZ], [endX, endZ]] = wallFloorPoints(wall);\n const length = Math.hypot(endX - startX, endZ - startZ);\n const alongX = (endX - startX) / length;\n const alongZ = (endZ - startZ) / length;\n const width = footprint.widthMm;\n const spanStart = wallSpanStart(wall, footprint, alignment, offsetMm);\n // The group's local x axis runs against the wall direction, so the group\n // origin corner sits at the far end of the occupied span.\n const anchorX = startX + alongX * (spanStart + width);\n const anchorZ = startZ + alongZ * (spanStart + width);\n const theta = toRadians(wall.facingRotationY);\n const [minX] = footprint.x;\n const [minZ] = footprint.z;\n return {\n pos: [\n round2(anchorX - (minX * Math.cos(theta) + minZ * Math.sin(theta))),\n 0,\n round2(anchorZ - (-minX * Math.sin(theta) + minZ * Math.cos(theta))),\n ],\n rotationY: wall.facingRotationY,\n };\n};\n","type Logable = string | number | boolean | object | null | undefined;\n\nexport const logApiCallback = (...args: Logable[]) =>\n console.log('[HI]', 'API Callback:', ...args);\n\nexport const logMessage = (...args: Logable[]) =>\n console.log('[HI]', 'Message:', ...args);\n\nexport const logApiCall = (...args: Logable[]) =>\n console.log('[HI]', 'API Call:', ...args);\n\n// The library spells one way, the agent often the other: both read alike.\nconst SPELLINGS: Array<[RegExp, string]> = [\n [/colour/g, 'color'],\n [/grey/g, 'gray'],\n [/worktop/g, 'countertop'],\n];\n\nexport const searchableText = (text: string): string =>\n SPELLINGS.reduce(\n (normalized, [spelling, as]) => normalized.replace(spelling, as),\n text.toLowerCase(),\n );\n\n// The description the agent reads of a library item: the library writes it\n// for the agent into llmData, and desc is the planner catalog's text.\nexport const agentDescription = (\n item: { desc?: string; llmData?: string } | undefined,\n): string | undefined => (item?.llmData?.trim() ? item.llmData : item?.desc);\n"],"mappings":";;AAwDA,IAAa,KAAU,MACrB,KAAK,MAAM,IAAQ,IAAI,GAAG,MAAM,GAE5B,KAAa,MAA6B,IAAU,KAAK,KAAM,KAE/D,KAAa,MAA6B,IAAU,MAAO,KAAK,IAEhE,KAAoB,MAA4B;CACpD,IAAM,IAAa,IAAU;AAC7B,QAAO,IAAa,IAAI,IAAa,MAAM;GAKhC,KACX,GACA,MACW;CACX,IAAM,CAAC,GAAG,GAAG,KAAK;AAClB,QAAO;EACL,EAAO,KAAK,IAAI,EAAO,KAAK,IAAI,EAAO,KAAK,IAAI,EAAO;EACvD,EAAO,KAAK,IAAI,EAAO,KAAK,IAAI,EAAO,KAAK,IAAI,EAAO;EACvD,EAAO,KAAK,IAAI,EAAO,KAAK,IAAI,EAAO,MAAM,IAAI,EAAO;EACzD;GAGU,KACX,GACA,MACW;CACX,IAAM,IAAQ,EAAU,EAAK,aAAa,EAAE,EACtC,CAAC,GAAc,GAAc,KAAgB,EAAK,cAAc;EACpE;EAAG;EAAG;EACP,EACK,CAAC,GAAG,GAAG,KAAK;AAClB,QAAO;EACL,IAAe,IAAI,KAAK,IAAI,EAAM,GAAG,IAAI,KAAK,IAAI,EAAM;EACxD,IAAe;EACf,IAAe,IAAI,KAAK,IAAI,EAAM,GAAG,IAAI,KAAK,IAAI,EAAM;EACzD;GAG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AQ,IACjB,KAAa,IAAS,KAAS;AACvC,QAAO,KAAK,MAAM,EAAS,GAAG;GAGnB,MACX,GACA,GACA,GACA,MACyD;CACzD,IAAM,CAAC,CAAC,GAAQ,IAAS,CAAC,GAAM,MAAS,EAAgB,EAAK,EACxD,IAAS,KAAK,MAAM,IAAO,GAAQ,IAAO,EAAO,EACjD,KAAU,IAAO,KAAU,GAC3B,KAAU,IAAO,KAAU,GAC3B,IAAQ,EAAU,SAClB,IAAY,EAAc,GAAM,GAAW,GAAW,EAAS,EAG/D,IAAU,IAAS,KAAU,IAAY,IACzC,IAAU,IAAS,KAAU,IAAY,IACzC,IAAQ,EAAU,EAAK,gBAAgB,EACvC,CAAC,KAAQ,EAAU,GACnB,CAAC,KAAQ,EAAU;AACzB,QAAO;EACL,KAAK;GACH,EAAO,KAAW,IAAO,KAAK,IAAI,EAAM,GAAG,IAAO,KAAK,IAAI,EAAM,EAAE;GACnE;GACA,EAAO,KAAW,CAAC,IAAO,KAAK,IAAI,EAAM,GAAG,IAAO,KAAK,IAAI,EAAM,EAAE;GACrE;EACD,WAAW,EAAK;EACjB;GCj3CG,KAAqC;CACzC,CAAC,WAAW,QAAQ;CACpB,CAAC,SAAS,OAAO;CACjB,CAAC,YAAY,aAAa;CAC3B,EAEY,MAAkB,MAC7B,GAAU,QACP,GAAY,CAAC,GAAU,OAAQ,EAAW,QAAQ,GAAU,EAAG,EAChE,EAAK,aAAa,CACnB,EAIU,MACX,MACwB,GAAM,SAAS,MAAM,GAAG,EAAK,UAAU,GAAM"}
1
+ {"version":3,"file":"util-LmkV26fg.mjs","names":[],"sources":["../../packages/homag-intelligence/src/hi-plan-space.ts","../../packages/homag-intelligence/src/util.ts"],"sourcesContent":["import type { RepositioningData } from './hi-group-placement';\nimport type {\n HiPlanFootprint,\n HiPlanWall,\n HiPlanWallSide,\n} from './hi-plan-context';\n\nexport type WallSide = HiPlanWallSide;\n\nexport type DerivedWall = HiPlanWall;\n\n// A wall as the user sees it: contour segments of one side in a straight\n// line, its pieces of wall and the doors and windows between them (D81).\nexport interface WallFace extends DerivedWall {\n pieces: DerivedWall[];\n}\n\nexport type GroupFootprint = HiPlanFootprint;\n\nexport type WallAlignment = 'start' | 'center' | 'end' | WallSide;\n\ninterface FootprintPart {\n hidden?: boolean;\n relPos?: number[];\n dim?: number[];\n fullMatrix?: number[];\n}\n\ninterface FootprintModule {\n modules?: FootprintModule[];\n containers?: FootprintModule[];\n parts?: FootprintPart[];\n}\n\ninterface FootprintRoot extends FootprintModule {\n id?: string;\n articleId?: string;\n isGenerated?: boolean;\n articlePos?: number[];\n rotationY?: number;\n dockInfos?: Array<{ id?: string; start?: number[]; end?: number[] }>;\n attributes?: Array<{ id: string; value?: unknown }>;\n}\n\nexport interface CornerGeometry {\n rootId: string;\n point: [number, number];\n directions: [[number, number], [number, number]];\n}\n\nexport interface FootprintGroup {\n ver?: number;\n roots?: FootprintRoot[];\n}\n\n// + 0 turns IEEE -0 into +0 so serialized values never show -0\nexport const round2 = (value: number): number =>\n Math.round(value * 100) / 100 + 0;\n\nconst toRadians = (degrees: number): number => (degrees * Math.PI) / 180;\n\nconst toDegrees = (radians: number): number => (radians * 180) / Math.PI;\n\nconst normalizeDegrees = (degrees: number): number => {\n const normalized = degrees % 360;\n return normalized < 0 ? normalized + 360 : normalized;\n};\n\ntype Point3 = [number, number, number];\n\nexport const transformPointByMatrix = (\n matrix: number[],\n point: Point3,\n): Point3 => {\n const [x, y, z] = point;\n return [\n matrix[0] * x + matrix[4] * y + matrix[8] * z + matrix[12],\n matrix[1] * x + matrix[5] * y + matrix[9] * z + matrix[13],\n matrix[2] * x + matrix[6] * y + matrix[10] * z + matrix[14],\n ];\n};\n\nexport const transformPointByRoot = (\n root: FootprintRoot,\n point: Point3,\n): Point3 => {\n const theta = toRadians(root.rotationY ?? 0);\n const [translationX, translationY, translationZ] = root.articlePos ?? [\n 0, 0, 0,\n ];\n const [x, y, z] = point;\n return [\n translationX + x * Math.cos(theta) + z * Math.sin(theta),\n translationY + y,\n translationZ - x * Math.sin(theta) + z * Math.cos(theta),\n ];\n};\n\nexport const groupPointToRoot = (\n root: { articlePos?: number[]; rotationY?: number },\n point: Point3,\n): Point3 => {\n const theta = toRadians(root.rotationY ?? 0);\n const [translationX, translationY, translationZ] = root.articlePos ?? [\n 0, 0, 0,\n ];\n const x = point[0] - translationX;\n const z = point[2] - translationZ;\n return [\n x * Math.cos(theta) - z * Math.sin(theta),\n point[1] - translationY,\n x * Math.sin(theta) + z * Math.cos(theta),\n ];\n};\n\nconst collectParts = (module: FootprintModule, parts: FootprintPart[]) => {\n for (const part of module.parts ?? []) {\n if (\n !part.hidden &&\n (part.relPos?.length ?? 0) >= 3 &&\n (part.dim?.length ?? 0) >= 3 &&\n part.fullMatrix?.length === 16\n ) {\n parts.push(part);\n }\n }\n for (const subModule of module.modules ?? []) {\n collectParts(subModule, parts);\n }\n for (const container of module.containers ?? []) {\n collectParts(container, parts);\n }\n};\n\nexport const boxCorners = (minimum: number[], size: number[]): Point3[] => {\n const corners: Point3[] = [];\n for (const offsetX of [0, size[0]]) {\n for (const offsetY of [0, size[1]]) {\n for (const offsetZ of [0, size[2]]) {\n corners.push([\n minimum[0] + offsetX,\n minimum[1] + offsetY,\n minimum[2] + offsetZ,\n ]);\n }\n }\n }\n return corners;\n};\n\nconst dimensionAttribute = (\n root: FootprintRoot,\n attributeId: string,\n): number | undefined => {\n const value = Number(\n root.attributes?.find((attribute) => attribute.id === attributeId)?.value,\n );\n return Number.isFinite(value) && value > 0 ? value : undefined;\n};\n\nconst rootFootprintPoints = (\n root: FootprintRoot,\n partMatricesAreGroupSpace: boolean,\n): Array<[number, number]> => {\n const parts: FootprintPart[] = [];\n collectParts(root, parts);\n const points: Array<[number, number]> = [];\n for (const part of parts) {\n for (const corner of boxCorners(part.relPos!, part.dim!)) {\n let point = transformPointByMatrix(part.fullMatrix!, corner);\n if (!partMatricesAreGroupSpace) {\n point = transformPointByRoot(root, point);\n }\n points.push([point[0], point[2]]);\n }\n }\n if (points.length > 0) {\n return points;\n }\n for (const dockInfo of root.dockInfos ?? []) {\n for (const dockPoint of [dockInfo.start, dockInfo.end]) {\n if ((dockPoint?.length ?? 0) >= 3) {\n const point = transformPointByRoot(root, [\n dockPoint![0],\n dockPoint![1],\n dockPoint![2],\n ]);\n points.push([point[0], point[2]]);\n }\n }\n }\n if (points.length > 0) {\n return points;\n }\n const width = dimensionAttribute(root, 'b');\n const depth = dimensionAttribute(root, 't');\n if (width !== undefined && depth !== undefined) {\n for (const corner of boxCorners([0, 0, 0], [width, 0, depth])) {\n const point = transformPointByRoot(root, corner);\n points.push([point[0], point[2]]);\n }\n }\n return points;\n};\n\nexport const groupFootprint = (\n group: FootprintGroup,\n): GroupFootprint | undefined => {\n const partMatricesAreGroupSpace = (group.ver ?? 0) > 0;\n const points: Array<[number, number]> = [];\n for (const root of group.roots ?? []) {\n points.push(...rootFootprintPoints(root, partMatricesAreGroupSpace));\n }\n if (points.length === 0) {\n return undefined;\n }\n let minX = Number.POSITIVE_INFINITY;\n let maxX = Number.NEGATIVE_INFINITY;\n let minZ = Number.POSITIVE_INFINITY;\n let maxZ = Number.NEGATIVE_INFINITY;\n for (const [x, z] of points) {\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n minZ = Math.min(minZ, z);\n maxZ = Math.max(maxZ, z);\n }\n return {\n x: [round2(minX), round2(maxX)],\n z: [round2(minZ), round2(maxZ)],\n widthMm: round2(maxX - minX),\n depthMm: round2(maxZ - minZ),\n };\n};\n\nconst rootHeights = (\n root: FootprintRoot,\n partMatricesAreGroupSpace: boolean,\n): number[] => {\n const parts: FootprintPart[] = [];\n collectParts(root, parts);\n const heights: number[] = [];\n for (const part of parts) {\n for (const corner of boxCorners(part.relPos!, part.dim!)) {\n let point = transformPointByMatrix(part.fullMatrix!, corner);\n if (!partMatricesAreGroupSpace) {\n point = transformPointByRoot(root, point);\n }\n heights.push(point[1]);\n }\n }\n if (heights.length > 0) {\n return heights;\n }\n for (const dockInfo of root.dockInfos ?? []) {\n for (const dockPoint of [dockInfo.start, dockInfo.end]) {\n if ((dockPoint?.length ?? 0) >= 3) {\n heights.push(\n transformPointByRoot(root, [\n dockPoint![0],\n dockPoint![1],\n dockPoint![2],\n ])[1],\n );\n }\n }\n }\n const height = dimensionAttribute(root, 'h');\n if (height !== undefined) {\n const bottom = root.articlePos?.[1] ?? 0;\n heights.push(bottom, bottom + height);\n }\n return heights;\n};\n\n// The kernel docks a CollisionBox too, which is no docking vector.\nconst dockingVectorsOf = (root: FootprintRoot) =>\n (root.dockInfos ?? []).filter(\n (dockInfo) =>\n dockInfo.id !== 'CollisionBox' &&\n (dockInfo.start?.length ?? 0) >= 3 &&\n (dockInfo.end?.length ?? 0) >= 3,\n );\n\nexport interface DockingBox {\n min: [number, number, number];\n max: [number, number, number];\n}\n\n// The box of a root module's docking vectors in group space; undefined\n// without docking vectors.\nexport const dockingVectorBox = (\n root: FootprintRoot,\n): DockingBox | undefined => {\n const points = dockingVectorsOf(root).flatMap((dockInfo) =>\n [dockInfo.start!, dockInfo.end!].map((point) =>\n transformPointByRoot(root, [point[0], point[1], point[2]]),\n ),\n );\n if (points.length === 0) {\n return undefined;\n }\n const axis = (index: number, pick: (...values: number[]) => number) =>\n pick(...points.map((point) => point[index]));\n return {\n min: [axis(0, Math.min), axis(1, Math.min), axis(2, Math.min)],\n max: [axis(0, Math.max), axis(1, Math.max), axis(2, Math.max)],\n };\n};\n\n// The start point of a root module's docking vector in group space.\nexport const dockingVectorStart = (\n root: FootprintRoot,\n vectorId: string,\n): [number, number, number] | undefined => {\n const start = dockingVectorsOf(root).find(\n (dockInfo) => dockInfo.id === vectorId,\n )?.start;\n return start && transformPointByRoot(root, [start[0], start[1], start[2]]);\n};\n\n// The direction of a root module's docking vector in group space, as a unit\n// vector; undefined for a vector the root does not have or one without length.\nexport const dockingVectorDirection = (\n root: FootprintRoot,\n vectorId: string,\n): [number, number, number] | undefined => {\n const vector = dockingVectorsOf(root).find(\n (dockInfo) => dockInfo.id === vectorId,\n );\n if (!vector) {\n return undefined;\n }\n const [start, end] = [vector.start!, vector.end!].map((point) =>\n transformPointByRoot(root, [point[0], point[1], point[2]]),\n );\n const length = Math.hypot(\n end[0] - start[0],\n end[1] - start[1],\n end[2] - start[2],\n );\n return length < 1e-6\n ? undefined\n : [\n (end[0] - start[0]) / length,\n (end[1] - start[1]) / length,\n (end[2] - start[2]) / length,\n ];\n};\n\n// The vertical extent of a group in group space; undefined without height data.\nexport const groupHeightRange = (\n group: FootprintGroup,\n): [number, number] | undefined => {\n const partMatricesAreGroupSpace = (group.ver ?? 0) > 0;\n const heights = (group.roots ?? []).flatMap((root) =>\n rootHeights(root, partMatricesAreGroupSpace),\n );\n if (heights.length === 0) {\n return undefined;\n }\n const bottom = Math.min(...heights);\n const top = Math.max(...heights);\n return top - bottom < 1 ? undefined : [round2(bottom), round2(top)];\n};\n\nconst POINT_EPSILON_MM = 1;\n\nconst samePoint = (a: [number, number], b: [number, number]): boolean =>\n Math.hypot(a[0] - b[0], a[1] - b[1]) < POINT_EPSILON_MM;\n\nconst unitDirection = (\n from: [number, number],\n to: [number, number],\n): [number, number] | undefined => {\n const length = Math.hypot(to[0] - from[0], to[1] - from[1]);\n return length < 1e-6\n ? undefined\n : [(to[0] - from[0]) / length, (to[1] - from[1]) / length];\n};\n\nexport const rotateDirection = (\n [x, z]: [number, number],\n degrees: number,\n): [number, number] => {\n const theta = toRadians(degrees);\n return [\n x * Math.cos(theta) + z * Math.sin(theta),\n -x * Math.sin(theta) + z * Math.cos(theta),\n ];\n};\n\nconst sameDirection = (a: [number, number], b: [number, number]): boolean =>\n a[0] * b[0] + a[1] * b[1] > 0.999;\n\nconst rootCornerGeometry = (\n root: FootprintRoot,\n): CornerGeometry | undefined => {\n const vectorPair = (row: 'Bottom' | 'Top') => ({\n left: root.dockInfos?.find((dockInfo) => dockInfo.id === `LeftBack${row}`),\n right: root.dockInfos?.find(\n (dockInfo) => dockInfo.id === `RightBack${row}`,\n ),\n });\n const bottom = vectorPair('Bottom');\n const { left, right } =\n bottom.left && bottom.right ? bottom : vectorPair('Top');\n if (!left?.start || !left.end || !right?.start || !right.end) {\n return undefined;\n }\n const toGroupXz = (point: number[]): [number, number] => {\n const [x, , z] = transformPointByRoot(root, [point[0], point[1], point[2]]);\n return [x, z];\n };\n const leftStart = toGroupXz(left.start);\n const rightStart = toGroupXz(right.start);\n const leftDirection = unitDirection(leftStart, toGroupXz(left.end));\n const rightDirection = unitDirection(rightStart, toGroupXz(right.end));\n // one corner point and two back edges running along different walls\n if (\n !samePoint(leftStart, rightStart) ||\n !leftDirection ||\n !rightDirection ||\n Math.abs(\n leftDirection[0] * rightDirection[0] +\n leftDirection[1] * rightDirection[1],\n ) > 0.01\n ) {\n return undefined;\n }\n return {\n rootId: root.id ?? '',\n point: rightStart,\n directions: [leftDirection, rightDirection],\n };\n};\n\nexport const groupCornerGeometry = (\n group: FootprintGroup,\n): CornerGeometry | undefined => {\n for (const root of group.roots ?? []) {\n const geometry = rootCornerGeometry(root);\n if (geometry) {\n return geometry;\n }\n }\n return undefined;\n};\n\nconst wallFloorPoints = ({\n start,\n end,\n}: DerivedWall): [[number, number], [number, number]] => [\n [start[0], start[2]],\n [end[0], end[2]],\n];\n\nexport const sharedCorner = (\n wall: DerivedWall,\n other: DerivedWall,\n): [number, number] | undefined =>\n wallFloorPoints(wall).find((point) =>\n wallFloorPoints(other).some((candidate) => samePoint(point, candidate)),\n );\n\n// The wall on the given side of the room that meets this wall in a corner.\nexport const adjoiningWall = (\n walls: DerivedWall[],\n wall: DerivedWall,\n side: WallSide,\n): DerivedWall | undefined =>\n walls.find(\n (candidate) =>\n candidate.index !== wall.index &&\n candidate.side === side &&\n candidate.type === 'wall' &&\n sharedCorner(wall, candidate) !== undefined,\n );\n\nconst continuesStraight = (from: DerivedWall, to: DerivedWall): boolean => {\n const [fromStart, fromEnd] = wallFloorPoints(from);\n const [toStart, toEnd] = wallFloorPoints(to);\n const along = unitDirection(fromStart, fromEnd);\n const next = unitDirection(toStart, toEnd);\n return (\n from !== to &&\n from.side === to.side &&\n samePoint(fromEnd, toStart) &&\n along !== undefined &&\n next !== undefined &&\n along[0] * next[0] + along[1] * next[1] > 0.999\n );\n};\n\nconst faceOf = (pieces: DerivedWall[]): WallFace => {\n const first = pieces[0];\n const solid = pieces.find((piece) => piece.type === 'wall');\n return {\n ...(solid ?? first),\n index: first.index,\n start: first.start,\n end: pieces[pieces.length - 1].end,\n lengthMm: round2(pieces.reduce((sum, piece) => sum + piece.lengthMm, 0)),\n type: solid ? 'wall' : first.type,\n pieces,\n };\n};\n\n// The faces of a room's walls: every run of walls that continue each other\n// in a straight line - a door or a floor-to-ceiling window splits the wall in\n// the contour (D61) - also across the start of the contour. A face is a wall\n// when one of its pieces is.\nexport const wallFaces = (walls: DerivedWall[]): WallFace[] => {\n const next = new Map<DerivedWall, DerivedWall>();\n for (const wall of walls) {\n const following = walls.find((candidate) =>\n continuesStraight(wall, candidate),\n );\n if (following) {\n next.set(wall, following);\n }\n }\n const continued = new Set(next.values());\n const visited = new Set<DerivedWall>();\n const faces: WallFace[] = [];\n for (const first of [\n ...walls.filter((wall) => !continued.has(wall)),\n ...walls,\n ]) {\n const pieces: DerivedWall[] = [];\n for (\n let piece: DerivedWall | undefined = first;\n piece && !visited.has(piece);\n piece = next.get(piece)\n ) {\n visited.add(piece);\n pieces.push(piece);\n }\n if (pieces.length > 0) {\n faces.push(faceOf(pieces));\n }\n }\n return faces;\n};\n\nconst WALL_NAMES: Record<WallSide, string> = {\n top: 'back wall',\n bottom: 'front wall',\n left: 'left wall',\n right: 'right wall',\n};\n\n// The name of a wall in the words of the user: back and front for the top and\n// the bottom of the top-view image.\nexport const wallName = (side: WallSide): string =>\n WALL_NAMES[side] ?? `${side} wall`;\n\nexport interface RoomCorner {\n name: string;\n point: [number, number, number];\n posRotationY: number;\n}\n\n// The corners of a room: where a wall or an opening ends and the next starts\n// at an angle that turns into the room - towards the side the ending one\n// faces, as the room lies left of the contour (D61). A partition and the inner\n// corner of an L-shaped room turn away from it and give none. The name is\n// back/front plus left/right, and posRotationY is the facingRotationY of the\n// wall that ends in the corner - the rotation of a corner kitchen there, for\n// both hands of corner article (D13, D33, D83).\nexport const roomCorners = (walls: DerivedWall[]): RoomCorner[] => {\n const corners: RoomCorner[] = [];\n for (const ending of walls) {\n const [endingStart, endPoint] = wallFloorPoints(ending);\n const along = unitDirection(endingStart, endPoint);\n for (const starting of walls) {\n const [startPoint, startingEnd] = wallFloorPoints(starting);\n const next = unitDirection(startPoint, startingEnd);\n if (\n starting === ending ||\n !samePoint(endPoint, startPoint) ||\n !along ||\n !next ||\n Math.abs(along[0] * next[0] + along[1] * next[1]) > 0.999 ||\n along[1] * next[0] - along[0] * next[1] <= 0\n ) {\n continue;\n }\n const sides = [ending.side, starting.side];\n const depth = sides.find((side) => side === 'top' || side === 'bottom');\n const hand = sides.find((side) => side === 'left' || side === 'right');\n if (!depth || !hand) {\n continue;\n }\n corners.push({\n name: `${depth === 'top' ? 'back' : 'front'} ${hand}`,\n point: [endPoint[0], 0, endPoint[1]],\n posRotationY: ending.facingRotationY,\n });\n }\n }\n return corners;\n};\n\n// The floor rings of a room: the start points of its walls in contour order\n// (openings included - they are contour segments too), one ring per contour\n// subpath - the outer contour, then a partition or column inside it.\nconst roomRings = (walls: DerivedWall[]): Array<Array<[number, number]>> => {\n const rings: Array<Array<[number, number]>> = [];\n let previous: DerivedWall | undefined;\n for (const wall of walls) {\n const continues =\n previous &&\n Math.hypot(\n previous.end[0] - wall.start[0],\n previous.end[2] - wall.start[2],\n ) < 1e-6;\n if (!continues) {\n rings.push([]);\n }\n rings[rings.length - 1].push([wall.start[0], wall.start[2]]);\n previous = wall;\n }\n return rings.filter((ring) => ring.length >= 3);\n};\n\nconst distanceToSegment = (\n [px, pz]: [number, number],\n [ax, az]: [number, number],\n [bx, bz]: [number, number],\n): number => {\n const lengthSquared = (bx - ax) ** 2 + (bz - az) ** 2;\n const t =\n lengthSquared < 1e-9\n ? 0\n : Math.max(\n 0,\n Math.min(\n 1,\n ((px - ax) * (bx - ax) + (pz - az) * (bz - az)) / lengthSquared,\n ),\n );\n return Math.hypot(px - (ax + t * (bx - ax)), pz - (az + t * (bz - az)));\n};\n\n// Whether a floor point lies inside the room's contour or within the\n// tolerance of one of its walls - also for an L-shaped room, whose cut-out\n// lies inside the bounding box of its walls.\nexport const pointInsideRoom = (\n point: [number, number],\n walls: DerivedWall[],\n toleranceMm: number,\n): boolean => {\n const rings = roomRings(walls);\n if (rings.length === 0) {\n return false;\n }\n // even-odd over every ring: inside the outer contour, and not inside a\n // partition or column\n let inside = false;\n for (const ring of rings) {\n for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {\n const [xi, zi] = ring[i];\n const [xj, zj] = ring[j];\n if (\n zi > point[1] !== zj > point[1] &&\n point[0] < ((xj - xi) * (point[1] - zi)) / (zj - zi) + xi\n ) {\n inside = !inside;\n }\n }\n }\n return (\n inside ||\n walls.some(\n (wall) =>\n distanceToSegment(\n point,\n [wall.start[0], wall.start[2]],\n [wall.end[0], wall.end[2]],\n ) <= toleranceMm,\n )\n );\n};\n\n// The room of the plan whose floor holds the point; undefined when none does.\nexport const roomOfPoint = <T extends { walls?: DerivedWall[] }>(\n rooms: T[],\n point: [number, number],\n toleranceMm: number,\n): T | undefined =>\n rooms.find((room) => pointInsideRoom(point, room.walls ?? [], toleranceMm));\n\n// The point nearest to `near` where a footprint - its corners relative to the\n// point, at its heights - lies inside the room and overlaps no blocker: the\n// square rings around `near` in steps of stepMm, up to maxRadiusMm, nearest\n// ring first. Undefined when there is no such point.\nexport const freePointInRoom = (\n walls: DerivedWall[],\n blockers: PlacedVolume[],\n footprint: PlacedVolume,\n near: [number, number],\n toleranceMm: number,\n stepMm = 300,\n maxRadiusMm = 3000,\n): [number, number] | undefined => {\n const isFree = (point: [number, number]): boolean => {\n const corners = footprint.corners.map(([x, z]): [number, number] => [\n point[0] + x,\n point[1] + z,\n ]);\n if (!footprintInsideRoom(corners, walls, toleranceMm)) {\n return false;\n }\n if (!footprint.heights) {\n return true;\n }\n const volume: PlacedVolume = { corners, heights: footprint.heights };\n return !blockers.some((blocker) =>\n volumesOverlap(volume, blocker, toleranceMm),\n );\n };\n if (isFree(near)) {\n return near;\n }\n for (let radius = stepMm; radius <= maxRadiusMm; radius += stepMm) {\n for (let dx = -radius; dx <= radius; dx += stepMm) {\n for (let dz = -radius; dz <= radius; dz += stepMm) {\n if (Math.max(Math.abs(dx), Math.abs(dz)) !== radius) {\n continue;\n }\n const point: [number, number] = [near[0] + dx, near[1] + dz];\n if (isFree(point)) {\n return point;\n }\n }\n }\n }\n return undefined;\n};\n\n// Puts the corner point of a corner article into the corner the two walls\n// share and turns the group so that its two back edges run along the walls.\n// Undefined when the article's back edges cannot be matched to both walls.\nexport const placeCornerAtWalls = (\n wall: DerivedWall,\n adjoining: DerivedWall,\n corner: CornerGeometry,\n offsetMm: number,\n): { pos: [number, number, number]; rotationY: number } | undefined => {\n const cornerPoint = sharedCorner(wall, adjoining);\n if (!cornerPoint) {\n return undefined;\n }\n const otherEnd = (candidate: DerivedWall): [number, number] => {\n const [start, end] = wallFloorPoints(candidate);\n return samePoint(start, cornerPoint) ? end : start;\n };\n const alongWall = unitDirection(cornerPoint, otherEnd(wall));\n const alongAdjoining = unitDirection(cornerPoint, otherEnd(adjoining));\n if (!alongWall || !alongAdjoining) {\n return undefined;\n }\n const [leftDirection, rightDirection] = corner.directions;\n const assignments: Array<[[number, number], [number, number]]> = [\n [alongWall, alongAdjoining],\n [alongAdjoining, alongWall],\n ];\n for (const [leftTarget, rightTarget] of assignments) {\n const angle = toDegrees(\n Math.atan2(leftDirection[1], leftDirection[0]) -\n Math.atan2(leftTarget[1], leftTarget[0]),\n );\n for (const rotationY of [angle, -angle]) {\n if (\n sameDirection(rotateDirection(leftDirection, rotationY), leftTarget) &&\n sameDirection(rotateDirection(rightDirection, rotationY), rightTarget)\n ) {\n const rotatedPoint = rotateDirection(corner.point, rotationY);\n return {\n pos: [\n round2(cornerPoint[0] - rotatedPoint[0] + alongWall[0] * offsetMm),\n 0,\n round2(cornerPoint[1] - rotatedPoint[1] + alongWall[1] * offsetMm),\n ],\n rotationY: round2(normalizeDegrees(rotationY)),\n };\n }\n }\n }\n return undefined;\n};\n\nexport interface GroupPlacementTransform {\n pos: [number, number, number];\n rotationY: number;\n}\n\ninterface PlacedGroup {\n pos?: number[];\n rotationY?: number;\n}\n\nexport const groupPointToRoom = (\n group: PlacedGroup,\n [x, z]: [number, number],\n): [number, number] => {\n const [roomX, , roomZ] = transformPointByRoot(\n { articlePos: group.pos, rotationY: group.rotationY },\n [x, 0, z],\n );\n return [roomX, roomZ];\n};\n\nexport const footprintCornersInRoom = (\n footprint: GroupFootprint,\n group: PlacedGroup,\n): Array<[number, number]> => {\n const [minX, maxX] = footprint.x;\n const [minZ, maxZ] = footprint.z;\n const corners: Array<[number, number]> = [\n [minX, minZ],\n [maxX, minZ],\n [maxX, maxZ],\n [minX, maxZ],\n ];\n return corners.map((corner) => groupPointToRoom(group, corner));\n};\n\nexport const rootFootprintInRoom = (\n group: FootprintGroup & PlacedGroup,\n root: FootprintRoot,\n): Array<[number, number]> =>\n rootFootprintPoints(root, (group.ver ?? 0) > 0).map((point) =>\n groupPointToRoom(group, point),\n );\n\nconst edgeNormals = (\n polygon: Array<[number, number]>,\n): Array<[number, number]> => {\n const normals: Array<[number, number]> = [];\n for (let index = 0; index < polygon.length; index++) {\n const [fromX, fromZ] = polygon[index];\n const [toX, toZ] = polygon[(index + 1) % polygon.length];\n const normal = unitDirection([fromX, fromZ], [toX, toZ]);\n if (normal) {\n normals.push([-normal[1], normal[0]]);\n }\n }\n return normals;\n};\n\nconst projectOntoAxis = (\n polygon: Array<[number, number]>,\n [axisX, axisZ]: [number, number],\n): [number, number] => {\n let minimum = Number.POSITIVE_INFINITY;\n let maximum = Number.NEGATIVE_INFINITY;\n for (const [x, z] of polygon) {\n const projection = x * axisX + z * axisZ;\n minimum = Math.min(minimum, projection);\n maximum = Math.max(maximum, projection);\n }\n return [minimum, maximum];\n};\n\nconst cross = (\n [originX, originZ]: [number, number],\n [aX, aZ]: [number, number],\n [bX, bZ]: [number, number],\n): number => (aX - originX) * (bZ - originZ) - (aZ - originZ) * (bX - originX);\n\n// The convex hull of floor points (monotone chain). convexPolygonsTouch holds\n// for convex outlines only; an L-shaped sofa is tested like its hull.\nexport const convexHull = (\n points: Array<[number, number]>,\n): Array<[number, number]> => {\n const sorted = [...points].sort(([aX, aZ], [bX, bZ]) => aX - bX || aZ - bZ);\n if (sorted.length < 3) {\n return sorted;\n }\n const halfHull = (\n ordered: Array<[number, number]>,\n ): Array<[number, number]> => {\n const chain: Array<[number, number]> = [];\n for (const point of ordered) {\n while (\n chain.length >= 2 &&\n cross(chain[chain.length - 2], chain[chain.length - 1], point) <= 0\n ) {\n chain.pop();\n }\n chain.push(point);\n }\n return chain.slice(0, -1);\n };\n return [...halfHull(sorted), ...halfHull([...sorted].reverse())];\n};\n\n// Two convex footprints touch when no edge normal of either separates them by\n// more than the tolerance (separating axis theorem); flush contact counts.\nexport const convexPolygonsTouch = (\n a: Array<[number, number]>,\n b: Array<[number, number]>,\n toleranceMm: number,\n): boolean => {\n if (a.length < 3 || b.length < 3) {\n return false;\n }\n for (const axis of [...edgeNormals(a), ...edgeNormals(b)]) {\n const [minA, maxA] = projectOntoAxis(a, axis);\n const [minB, maxB] = projectOntoAxis(b, axis);\n if (maxA < minB - toleranceMm || maxB < minA - toleranceMm) {\n return false;\n }\n }\n return true;\n};\n\n// Whether a wall reaches into a convex footprint by more than the tolerance:\n// the separating axis test with the wall as a segment; flush contact is none.\nconst wallEntersFootprint = (\n wall: DerivedWall,\n footprint: Array<[number, number]>,\n toleranceMm: number,\n): boolean => {\n const segment: Array<[number, number]> = [\n [wall.start[0], wall.start[2]],\n [wall.end[0], wall.end[2]],\n ];\n return [...edgeNormals(footprint), ...edgeNormals(segment)].every((axis) => {\n const [minFootprint, maxFootprint] = projectOntoAxis(footprint, axis);\n const [minWall, maxWall] = projectOntoAxis(segment, axis);\n return (\n maxFootprint - minWall > toleranceMm &&\n maxWall - minFootprint > toleranceMm\n );\n });\n};\n\n// Whether a convex footprint lies inside the room: its corners inside the\n// contour or within the tolerance of a wall, and no wall reaching into it -\n// the edge of an L-shaped room's cut-out between two corners, or a partition\n// or column the footprint encloses.\nexport const footprintInsideRoom = (\n corners: Array<[number, number]>,\n walls: DerivedWall[],\n toleranceMm: number,\n): boolean =>\n corners.every((corner) => pointInsideRoom(corner, walls, toleranceMm)) &&\n !walls.some((wall) => wallEntersFootprint(wall, corners, toleranceMm));\n\nexport interface PlacedVolume {\n corners: Array<[number, number]>;\n heights?: [number, number];\n}\n\n// Two placed groups overlap when their footprints and their height ranges\n// overlap by more than the tolerance; touching is no overlap, and a group\n// without height data overlaps nothing.\nexport const volumesOverlap = (\n a: PlacedVolume,\n b: PlacedVolume,\n toleranceMm: number,\n): boolean =>\n a.heights !== undefined &&\n b.heights !== undefined &&\n a.heights[1] > b.heights[0] + toleranceMm &&\n b.heights[1] > a.heights[0] + toleranceMm &&\n convexPolygonsTouch(a.corners, b.corners, -toleranceMm);\n\n// The extent of room points along a wall, measured from the wall's start.\nexport const spanAlongWall = (\n wall: DerivedWall,\n points: Array<[number, number]>,\n): [number, number] => {\n const [[startX, startZ], [endX, endZ]] = wallFloorPoints(wall);\n const length = Math.hypot(endX - startX, endZ - startZ);\n const along: [number, number] = [\n (endX - startX) / length,\n (endZ - startZ) / length,\n ];\n return projectOntoAxis(\n points.map(([x, z]) => [x - startX, z - startZ]),\n along,\n );\n};\n\nexport interface WallOfOpening {\n roomIndex: number;\n wall: number;\n fromEndMm: [number, number];\n}\n\n// The wall a door or a window lies in: the wall whose line its floor outline\n// touches - within the wall's thickness - over the longest stretch. The span\n// is measured from the wall's end, like the d of a placement.\nexport const wallOfOpening = (\n outline: Array<[number, number]>,\n rooms: Array<{ walls?: DerivedWall[] }>,\n): WallOfOpening | undefined => {\n let found: WallOfOpening | undefined;\n let longestOverlap = POINT_EPSILON_MM;\n rooms.forEach((room, roomIndex) => {\n for (const wall of room.walls ?? []) {\n const [[startX, startZ], [endX, endZ]] = wallFloorPoints(wall);\n const along = unitDirection([startX, startZ], [endX, endZ]);\n if (!along) {\n continue;\n }\n const distanceToLine = Math.min(\n ...outline.map(([x, z]) =>\n Math.abs((x - startX) * along[1] - (z - startZ) * along[0]),\n ),\n );\n if (distanceToLine > (wall.thicknessMm ?? 0) + POINT_EPSILON_MM) {\n continue;\n }\n const length = Math.hypot(endX - startX, endZ - startZ);\n const [from, to] = spanAlongWall(wall, outline);\n const overlap = Math.min(to, length) - Math.max(from, 0);\n if (overlap > longestOverlap) {\n longestOverlap = overlap;\n found = {\n roomIndex,\n wall: wall.index,\n fromEndMm: [\n round2(length - Math.min(to, length)),\n round2(length - Math.max(from, 0)),\n ],\n };\n }\n }\n });\n return found;\n};\n\nexport interface RootVolume extends PlacedVolume {\n id: string;\n articleId?: string;\n rotationY: number;\n}\n\n// Every root module of a calculated group but the generated ones, as the box\n// of its parts in room space with its height and its rotation in the room.\nexport const rootVolumesInRoom = (\n group: FootprintGroup & PlacedGroup,\n): RootVolume[] => {\n const partMatricesAreGroupSpace = (group.ver ?? 0) > 0;\n const groupY = group.pos?.[1] ?? 0;\n return (group.roots ?? []).flatMap((root) => {\n const points = root.isGenerated\n ? []\n : rootFootprintPoints(root, partMatricesAreGroupSpace);\n if (points.length === 0) {\n return [];\n }\n const xs = points.map(([x]) => x);\n const zs = points.map(([, z]) => z);\n const [minX, maxX] = [Math.min(...xs), Math.max(...xs)];\n const [minZ, maxZ] = [Math.min(...zs), Math.max(...zs)];\n const corners = (\n [\n [minX, minZ],\n [maxX, minZ],\n [maxX, maxZ],\n [minX, maxZ],\n ] as Array<[number, number]>\n ).map((corner) => groupPointToRoom(group, corner));\n const heights = rootHeights(root, partMatricesAreGroupSpace);\n const [bottom, top] = [Math.min(...heights), Math.max(...heights)];\n return [\n {\n id: root.id ?? '',\n ...(root.articleId !== undefined && { articleId: root.articleId }),\n corners,\n ...(top - bottom >= 1 && {\n heights: [bottom + groupY, top + groupY] as [number, number],\n }),\n rotationY: normalizeDegrees(\n (group.rotationY ?? 0) + (root.rotationY ?? 0),\n ),\n },\n ];\n });\n};\n\n// Every root module of a calculated group but the generated ones, as the box\n// of its docking vectors in room space: the body its neighbours dock to,\n// without the parts that reach past the docking edges over a neighbour (D146).\nexport const rootDockingVolumesInRoom = (\n group: FootprintGroup & PlacedGroup,\n): RootVolume[] => {\n const groupY = group.pos?.[1] ?? 0;\n return (group.roots ?? []).flatMap((root) => {\n const box = root.isGenerated ? undefined : dockingVectorBox(root);\n if (!box) {\n return [];\n }\n const corners = (\n [\n [box.min[0], box.min[2]],\n [box.max[0], box.min[2]],\n [box.max[0], box.max[2]],\n [box.min[0], box.max[2]],\n ] as Array<[number, number]>\n ).map((corner) => groupPointToRoom(group, corner));\n return [\n {\n id: root.id ?? '',\n ...(root.articleId !== undefined && { articleId: root.articleId }),\n corners,\n ...(box.max[1] - box.min[1] >= 1 && {\n heights: [box.min[1] + groupY, box.max[1] + groupY] as [\n number,\n number,\n ],\n }),\n rotationY: normalizeDegrees(\n (group.rotationY ?? 0) + (root.rotationY ?? 0),\n ),\n },\n ];\n });\n};\n\n// Into the room from a wall: the front of a group with its back to the wall.\nconst intoRoom = (wall: DerivedWall): [number, number] =>\n rotateDirection([0, 1], wall.facingRotationY);\n\nconst distanceFromWall = (\n wall: DerivedWall,\n [x, z]: [number, number],\n): number => {\n const [[startX, startZ]] = wallFloorPoints(wall);\n const [inX, inZ] = intoRoom(wall);\n return (x - startX) * inX + (z - startZ) * inZ;\n};\n\nconst pointAlongWall = (\n wall: DerivedWall,\n fromEndMm: number,\n intoRoomMm: number,\n): [number, number] => {\n const [[startX, startZ], [endX, endZ]] = wallFloorPoints(wall);\n const length = Math.hypot(endX - startX, endZ - startZ);\n const [inX, inZ] = intoRoom(wall);\n return [\n endX + ((startX - endX) * fromEndMm) / length + inX * intoRoomMm,\n endZ + ((startZ - endZ) * fromEndMm) / length + inZ * intoRoomMm,\n ];\n};\n\n// The floor in front of a span of a wall, measured from the wall's end,\n// reaching depthMm into the room.\nexport const stripInFrontOfWall = (\n wall: DerivedWall,\n [fromEndMm, toEndMm]: [number, number],\n depthMm: number,\n): Array<[number, number]> => [\n pointAlongWall(wall, fromEndMm, 0),\n pointAlongWall(wall, toEndMm, 0),\n pointAlongWall(wall, toEndMm, depthMm),\n pointAlongWall(wall, fromEndMm, depthMm),\n];\n\nconst sameAngle = (a: number, b: number): boolean => {\n const turn = normalizeDegrees(a - b);\n return Math.min(turn, 360 - turn) < 0.5;\n};\n\n// Two walls that face the same way or opposite ways: neither adjoins the\n// other.\nexport const wallsRunParallel = (a: DerivedWall, b: DerivedWall): boolean =>\n sameAngle(a.facingRotationY, b.facingRotationY) ||\n sameAngle(a.facingRotationY, b.facingRotationY + 180);\n\n// The wall a root module faces away from: turned like the wall's\n// facingRotationY, beside it along the wall, and with its back nearest to it,\n// at most depthMm away. A corner unit touches two walls; its rotation tells.\nexport const wallOfRoot = <T extends DerivedWall>(\n walls: T[],\n root: RootVolume,\n depthMm: number,\n): T | undefined => {\n let found: T | undefined;\n let nearest = depthMm;\n for (const wall of walls) {\n if (\n wall.type !== 'wall' ||\n !sameAngle(wall.facingRotationY, root.rotationY)\n ) {\n continue;\n }\n const [from, to] = spanAlongWall(wall, root.corners);\n if (Math.min(to, wall.lengthMm) - Math.max(from, 0) <= POINT_EPSILON_MM) {\n continue;\n }\n const back = Math.abs(\n Math.min(...root.corners.map((corner) => distanceFromWall(wall, corner))),\n );\n if (back <= nearest) {\n nearest = back;\n found = wall;\n }\n }\n return found;\n};\n\n// The stretches of a wall, measured from its end, where the root module -\n// as deep and at the height it is - stands clear of every blocker; stretches\n// narrower than the root module are left out.\nexport const freeStretchesAlongWall = (\n wall: DerivedWall,\n root: RootVolume,\n blockers: PlacedVolume[],\n toleranceMm: number,\n): Array<[number, number]> => {\n const length = wall.lengthMm;\n const depth = Math.max(\n ...root.corners.map((corner) => distanceFromWall(wall, corner)),\n );\n const [rootFrom, rootTo] = spanAlongWall(wall, root.corners);\n if (depth <= 0 || !root.heights) {\n return [];\n }\n const strip: PlacedVolume = {\n corners: stripInFrontOfWall(wall, [0, length], depth),\n heights: root.heights,\n };\n const taken = blockers\n .filter((blocker) => volumesOverlap(strip, blocker, toleranceMm))\n .map((blocker) => spanAlongWall(wall, blocker.corners))\n .map(([from, to]): [number, number] => [\n Math.max(from, 0),\n Math.min(to, length),\n ])\n .filter(([from, to]) => to > from)\n .sort(([a], [b]) => a - b);\n const free: Array<[number, number]> = [];\n let start = 0;\n for (const [from, to] of taken) {\n if (from > start) {\n free.push([start, from]);\n }\n start = Math.max(start, to);\n }\n if (start < length) {\n free.push([start, length]);\n }\n return free\n .filter(([from, to]) => to - from >= rootTo - rootFrom - toleranceMm)\n .map(([from, to]): [number, number] => [\n Math.round(length - to) + 0,\n Math.round(length - from) + 0,\n ])\n .reverse();\n};\n\n// The group placement expressed as the room transform of one root module, so\n// the planner derives the group position from its own arrangement and no root\n// position has to travel in the payload.\nexport const repositioningFromPlacement = (\n placement: GroupPlacementTransform,\n anchor: { id: string; articlePos?: number[]; rotationY?: number },\n): RepositioningData => {\n const [x, y, z] = transformPointByRoot(\n { articlePos: placement.pos, rotationY: placement.rotationY },\n [\n anchor.articlePos?.[0] ?? 0,\n anchor.articlePos?.[1] ?? 0,\n anchor.articlePos?.[2] ?? 0,\n ],\n );\n return {\n posGroup: [round2(x), round2(y), round2(z)],\n posRotationY: round2(\n normalizeDegrees(placement.rotationY + (anchor.rotationY ?? 0)),\n ),\n rootId: anchor.id,\n };\n};\n\nconst alignmentAxis = (alignment: WallSide): 0 | 1 =>\n alignment === 'left' || alignment === 'right' ? 0 : 1;\n\n// A side label names a corner of this wall only when the wall runs towards\n// that side.\nexport const alignmentRunsParallel = (\n wall: DerivedWall,\n alignment: WallSide,\n): boolean => {\n const axis = alignmentAxis(alignment);\n const [start, end] = wallFloorPoints(wall);\n return Math.abs(start[axis] - end[axis]) < 1e-6;\n};\n\n// A side label as alignment means: flush into the corner this wall shares\n// with the wall on that side of the room.\nexport const resolveWallAlignment = (\n wall: DerivedWall,\n alignment: WallAlignment,\n): 'start' | 'center' | 'end' => {\n if (alignment === 'start' || alignment === 'center' || alignment === 'end') {\n return alignment;\n }\n const axis = alignmentAxis(alignment);\n const [start, end] = wallFloorPoints(wall);\n const startCoordinate = start[axis];\n const endCoordinate = end[axis];\n if (alignmentRunsParallel(wall, alignment)) {\n throw new Error(\n `Alignment '${alignment}' runs parallel to this '${wall.side}' wall - ` +\n \"use 'start', 'center', 'end' or the side of an adjoining wall.\",\n );\n }\n const smallerIsCloser = alignment === 'left' || alignment === 'top';\n const startIsCloser = smallerIsCloser\n ? startCoordinate < endCoordinate\n : startCoordinate > endCoordinate;\n return startIsCloser ? 'start' : 'end';\n};\n\n// Where the group's span along the wall starts, measured from the wall's start.\nexport const wallSpanStart = (\n wall: DerivedWall,\n footprint: GroupFootprint,\n alignment: WallAlignment,\n offsetMm: number,\n): number => {\n const resolvedAlignment = resolveWallAlignment(wall, alignment);\n const [[startX, startZ], [endX, endZ]] = wallFloorPoints(wall);\n const length = Math.hypot(endX - startX, endZ - startZ);\n const width = footprint.widthMm;\n if (resolvedAlignment === 'start') {\n return offsetMm;\n }\n if (resolvedAlignment === 'end') {\n return length - width - offsetMm;\n }\n return (length - width) / 2 + offsetMm;\n};\n\n// The offsetMm of the same wall and alignment that moves a group standing\n// along the wall out of a span blocked at one end of it. The spans - of the\n// group, of its root modules in the blocked span and of that span - are\n// measured along the wall from its start. Undefined when the blocked span\n// lies at neither end or at both, or when the moved group would reach past an\n// end of the wall.\nexport const clearingOffsetMm = (\n wall: DerivedWall,\n alignment: WallAlignment,\n [groupFrom, groupTo]: [number, number],\n [rootFrom, rootTo]: [number, number],\n [blockedFrom, blockedTo]: [number, number],\n toleranceMm: number,\n): number | undefined => {\n const [[startX, startZ], [endX, endZ]] = wallFloorPoints(wall);\n const length = Math.hypot(endX - startX, endZ - startZ);\n const atStart = blockedFrom <= toleranceMm;\n const atEnd = blockedTo >= length - toleranceMm;\n if (atStart === atEnd) {\n return undefined;\n }\n const width = groupTo - groupFrom;\n const spanStart =\n groupFrom + (atStart ? blockedTo - rootFrom : blockedFrom - rootTo);\n if (spanStart < -toleranceMm || spanStart + width > length + toleranceMm) {\n return undefined;\n }\n const resolvedAlignment = resolveWallAlignment(wall, alignment);\n const offsetMm =\n resolvedAlignment === 'start'\n ? spanStart\n : resolvedAlignment === 'end'\n ? length - width - spanStart\n : spanStart - (length - width) / 2;\n return Math.round(offsetMm) + 0;\n};\n\nexport const placeAgainstWall = (\n wall: DerivedWall,\n footprint: GroupFootprint,\n alignment: WallAlignment,\n offsetMm: number,\n): { pos: [number, number, number]; rotationY: number } => {\n const [[startX, startZ], [endX, endZ]] = wallFloorPoints(wall);\n const length = Math.hypot(endX - startX, endZ - startZ);\n const alongX = (endX - startX) / length;\n const alongZ = (endZ - startZ) / length;\n const width = footprint.widthMm;\n const spanStart = wallSpanStart(wall, footprint, alignment, offsetMm);\n // The group's local x axis runs against the wall direction, so the group\n // origin corner sits at the far end of the occupied span.\n const anchorX = startX + alongX * (spanStart + width);\n const anchorZ = startZ + alongZ * (spanStart + width);\n const theta = toRadians(wall.facingRotationY);\n const [minX] = footprint.x;\n const [minZ] = footprint.z;\n return {\n pos: [\n round2(anchorX - (minX * Math.cos(theta) + minZ * Math.sin(theta))),\n 0,\n round2(anchorZ - (-minX * Math.sin(theta) + minZ * Math.cos(theta))),\n ],\n rotationY: wall.facingRotationY,\n };\n};\n","type Logable = string | number | boolean | object | null | undefined;\n\nexport const logApiCallback = (...args: Logable[]) =>\n console.log('[HI]', 'API Callback:', ...args);\n\nexport const logMessage = (...args: Logable[]) =>\n console.log('[HI]', 'Message:', ...args);\n\nexport const logApiCall = (...args: Logable[]) =>\n console.log('[HI]', 'API Call:', ...args);\n\n// The library spells one way, the agent often the other: both read alike.\nconst SPELLINGS: Array<[RegExp, string]> = [\n [/colour/g, 'color'],\n [/grey/g, 'gray'],\n [/worktop/g, 'countertop'],\n];\n\nexport const searchableText = (text: string): string =>\n SPELLINGS.reduce(\n (normalized, [spelling, as]) => normalized.replace(spelling, as),\n text.toLowerCase(),\n );\n\n// The description the agent reads of a library item: the library writes it\n// for the agent into llmData, and desc is the planner catalog's text.\nexport const agentDescription = (\n item: { desc?: string; llmData?: string } | undefined,\n): string | undefined => (item?.llmData?.trim() ? item.llmData : item?.desc);\n"],"mappings":";;AAwDA,IAAa,KAAU,MACrB,KAAK,MAAM,IAAQ,IAAI,GAAG,MAAM,GAE5B,KAAa,MAA6B,IAAU,KAAK,KAAM,KAE/D,KAAa,MAA6B,IAAU,MAAO,KAAK,IAEhE,KAAoB,MAA4B;CACpD,IAAM,IAAa,IAAU;AAC7B,QAAO,IAAa,IAAI,IAAa,MAAM;GAKhC,KACX,GACA,MACW;CACX,IAAM,CAAC,GAAG,GAAG,KAAK;AAClB,QAAO;EACL,EAAO,KAAK,IAAI,EAAO,KAAK,IAAI,EAAO,KAAK,IAAI,EAAO;EACvD,EAAO,KAAK,IAAI,EAAO,KAAK,IAAI,EAAO,KAAK,IAAI,EAAO;EACvD,EAAO,KAAK,IAAI,EAAO,KAAK,IAAI,EAAO,MAAM,IAAI,EAAO;EACzD;GAGU,KACX,GACA,MACW;CACX,IAAM,IAAQ,EAAU,EAAK,aAAa,EAAE,EACtC,CAAC,GAAc,GAAc,KAAgB,EAAK,cAAc;EACpE;EAAG;EAAG;EACP,EACK,CAAC,GAAG,GAAG,KAAK;AAClB,QAAO;EACL,IAAe,IAAI,KAAK,IAAI,EAAM,GAAG,IAAI,KAAK,IAAI,EAAM;EACxD,IAAe;EACf,IAAe,IAAI,KAAK,IAAI,EAAM,GAAG,IAAI,KAAK,IAAI,EAAM;EACzD;GAGU,KACX,GACA,MACW;CACX,IAAM,IAAQ,EAAU,EAAK,aAAa,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EAAS,GAAG;GAGnB,MACX,GACA,GACA,GACA,MACyD;CACzD,IAAM,CAAC,CAAC,GAAQ,IAAS,CAAC,GAAM,MAAS,EAAgB,EAAK,EACxD,IAAS,KAAK,MAAM,IAAO,GAAQ,IAAO,EAAO,EACjD,KAAU,IAAO,KAAU,GAC3B,KAAU,IAAO,KAAU,GAC3B,IAAQ,EAAU,SAClB,IAAY,EAAc,GAAM,GAAW,GAAW,EAAS,EAG/D,IAAU,IAAS,KAAU,IAAY,IACzC,IAAU,IAAS,KAAU,IAAY,IACzC,IAAQ,EAAU,EAAK,gBAAgB,EACvC,CAAC,KAAQ,EAAU,GACnB,CAAC,KAAQ,EAAU;AACzB,QAAO;EACL,KAAK;GACH,EAAO,KAAW,IAAO,KAAK,IAAI,EAAM,GAAG,IAAO,KAAK,IAAI,EAAM,EAAE;GACnE;GACA,EAAO,KAAW,CAAC,IAAO,KAAK,IAAI,EAAM,GAAG,IAAO,KAAK,IAAI,EAAM,EAAE;GACrE;EACD,WAAW,EAAK;EACjB;GCj3CG,KAAqC;CACzC,CAAC,WAAW,QAAQ;CACpB,CAAC,SAAS,OAAO;CACjB,CAAC,YAAY,aAAa;CAC3B,EAEY,MAAkB,MAC7B,GAAU,QACP,GAAY,CAAC,GAAU,OAAQ,EAAW,QAAQ,GAAU,EAAG,EAChE,EAAK,aAAa,CACnB,EAIU,MACX,MACwB,GAAM,SAAS,MAAM,GAAG,EAAK,UAAU,GAAM"}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@roomle/web-sdk",
3
- "version": "7.0.0-alpha.1",
3
+ "version": "7.0.0-alpha.2",
4
4
  "description": "Roomle Web SDK",
5
5
  "author": "Roomle Development",
6
- "main": "./lib/roomle-sdk-Sdrd7K0F.mjs",
6
+ "main": "./lib/roomle-sdk-C0YpFZdj.mjs",
7
7
  "scripts": {
8
8
  "release": "node ../scripts/run-semantic-release.mjs"
9
9
  },
package/sbom.cdx.json CHANGED
@@ -3,14 +3,14 @@
3
3
  "bomFormat": "CycloneDX",
4
4
  "specVersion": "1.6",
5
5
  "version": 1,
6
- "serialNumber": "urn:uuid:0038ecd0-a1f1-550b-bdad-aee2cb6078f7",
6
+ "serialNumber": "urn:uuid:9068aaca-7c08-5750-bf76-1e6ce485abdc",
7
7
  "metadata": {
8
- "timestamp": "2026-11-09T19:39:39.000Z",
8
+ "timestamp": "2026-11-10T12:13:11.000Z",
9
9
  "component": {
10
10
  "type": "library",
11
11
  "name": "@roomle/web-sdk",
12
- "version": "74570fef0c256d9c51b34ef2a4376ec43e3f7ca5",
13
- "bom-ref": "@roomle/web-sdk@74570fef0c256d9c51b34ef2a4376ec43e3f7ca5"
12
+ "version": "b02859bd7c70b9817b5b7948e626131a4605f87d",
13
+ "bom-ref": "@roomle/web-sdk@b02859bd7c70b9817b5b7948e626131a4605f87d"
14
14
  }
15
15
  },
16
16
  "components": [
@@ -712,7 +712,7 @@
712
712
  ],
713
713
  "dependencies": [
714
714
  {
715
- "ref": "@roomle/web-sdk@74570fef0c256d9c51b34ef2a4376ec43e3f7ca5"
715
+ "ref": "@roomle/web-sdk@b02859bd7c70b9817b5b7948e626131a4605f87d"
716
716
  },
717
717
  {
718
718
  "ref": "Draco@1.5.6"
@@ -1 +0,0 @@
1
- {"version":3,"file":"common-utils-DZiN8bjs.mjs","names":[],"sources":["../../packages/typings/rapi-types.ts","../../../../node_modules/crypt/crypt.js","../../../../node_modules/charenc/charenc.js","../../../../node_modules/is-buffer/index.js","../../../../node_modules/md5/md5.js","../../packages/common-core/src/utils/common-utils.ts"],"sourcesContent":["import type { Enumify } from '#/common/src/utils/types';\nimport type { InitDataDefinition } from '../common-core/src/utils/shims';\nimport type { UiPossibleChild } from './kernel';\n\nexport type RapiId = string;\nexport type AssetUrl = string;\nexport type ConfigurationString = string;\nexport type ConfigurationHash = string;\nexport type Base64String = string;\nexport type RapiServerUrlType = 'live' | 'test';\nexport type HexColorString = string; // #ffffff\nexport type HexColorNumber = number; // 0xffffff\nexport type PriceId = string;\nexport type ArticleNumber = string;\n\nexport interface LinksCollection {\n [key: string]: string;\n}\n\nexport interface RoomleSortable {\n sort?: number;\n}\n\nexport interface RapiJsonBox {\n meta?: RapiMeta;\n\n [key: string]: RapiMeta | RapiJson | RapiJson[] | undefined;\n}\n\nexport interface RapiMeta {\n serverTime: string;\n total: number;\n\n [key: string]: string | number;\n}\n\nexport interface RapiJson {\n id?: RapiId | number | null;\n isLocally?: boolean;\n __rapi_path__?: string;\n\n links?: LinksCollection;\n [key: string]: any;\n}\n\nexport interface RapiPackage extends RapiJson {\n components: RapiComponent[];\n materials: RapiMaterial[];\n textures: RapiTexture[];\n}\n\nexport interface RapiBaseColor {\n r: number;\n g: number;\n b: number;\n\n [key: string]: number;\n}\n\nexport interface RapiMesh extends RapiJson {\n catalog: RapiId;\n id: RapiId;\n}\n\nexport interface RapiMeshData {\n format: string;\n quality: number;\n url: string;\n created: string;\n changed: string;\n meshId: RapiId;\n\n [key: string]: number | string | RapiId;\n}\n\nexport interface RapiMaterialShading {\n version?: string;\n alpha: number;\n metallic: number;\n specularity?: number;\n basecolor: RapiBaseColor;\n roughness: number;\n doubleSided: boolean;\n alphaCutoff?: number;\n occlusion?: number;\n transmission?: number;\n reflectivity?: number;\n transmissionIOR?: number;\n emissiveColor?: RapiBaseColor;\n emissiveIntensity?: number;\n clearcoatIntensity?: number;\n clearcoatRoughness?: number;\n clearcoatNormalScale?: number;\n sheenColor?: RapiBaseColor;\n sheenIntensity?: number;\n sheenRoughness?: number;\n specularColor?: RapiBaseColor;\n thicknessFactor?: number;\n attenuationColor?: RapiBaseColor;\n attenuationDistance?: number;\n embeddedTextures?: RapiTexture[];\n\n [key: string]:\n | number\n | boolean\n | string\n | RapiBaseColor\n | RapiTexture[]\n | undefined;\n}\n\nexport interface RapiMaterial extends RapiJson {\n id: RapiId;\n name: string;\n externalIdentifier: string;\n group: string;\n groupLabel: string;\n color: string;\n thumbnail: AssetUrl;\n label: string;\n textures: number[];\n shading: RapiMaterialShading;\n tags: RapiId[];\n active: boolean;\n additionalInfos?: AdditionalInfo[];\n properties?: Record<string, string>;\n sort?: number;\n\n [key: string]:\n | string\n | RapiMaterialShading\n | AssetUrl\n | RapiId\n | number[]\n | AdditionalInfo[]\n | boolean\n | number\n | LinksCollection\n | RapiId[]\n | Record<string, string>\n | undefined;\n}\n\nexport interface RapiMaterialGroup extends RapiJson {\n id: RapiId | null;\n label?: string | null;\n materials: RapiMaterial[];\n legacyId?: RapiId;\n sort?: number;\n\n [key: string]:\n | string\n | RapiMaterial[]\n | RapiId\n | boolean\n | LinksCollection\n | number\n | null\n | undefined;\n}\n\nexport const enum RAPI_TEXTURE_TYPE {\n RGB = 'RGB', // diffuse color texture\n RGBA = 'RGBA', // Diffuse color texture and opacity map\n XYZ = 'XYZ', // normal vectors encoded in the 3 color channels\n ORM = 'ORM', // ambient Occlusion, roughness and metalness stored in the red, green and blue channels of the texture (in this order)\n EMRGB = 'EMRGB', // emissive color texture\n CCRG = 'CCRG', // clear coat intensity and clear coat roughness stored in the red and green channels of the texture (in this order)\n CCXYZ = 'CCXYZ', // separate normal vectors for the clear coat effect\n SHRGBA = 'SHRGBA', // sheen effect color texture and sheen roughness, the color is stored in the RGB channels and the roughness is stored in the alpha channel\n SPRGBA = 'SPRGBA', // specular color texture and specular intensity, the color is stored in the RGB channels and the intensity is stored in the alpha channel\n TTRG = 'TTRG', // transmission degree and thickness stored in the red and green channels of the texture (in this order)\n}\n\nexport interface RapiTexture extends RapiJson {\n mapping: RAPI_TEXTURE_TYPE;\n url: AssetUrl;\n image: AssetUrl;\n height: number;\n width: number;\n mmHeight: number;\n mmWidth: number;\n tileable: boolean;\n material: RapiId;\n\n [key: string]:\n | string\n | number\n | boolean\n | AssetUrl\n | RapiId\n | LinksCollection\n | null\n | undefined;\n}\n\nexport interface RapiCatalog extends RapiJson {\n id: RapiId;\n name: string;\n featuredImage: string;\n externalIdentifier: string;\n cover: string;\n brandIcon: string;\n description: string;\n free: boolean;\n public: boolean;\n featured: boolean;\n sort: number;\n created: string;\n updated: string;\n hidden: boolean;\n hiddenByUser: boolean;\n hiddenByTenant: boolean;\n tenantIsOwner: boolean;\n orderable: boolean;\n active: boolean;\n purchased: boolean;\n branded: boolean;\n\n tenant: RapiTenant;\n items: RapiItem[];\n allItems: RapiItem[];\n components: RapiComponent[];\n materials: RapiMaterial[];\n tags: RapiId[];\n allTags: RapiTag[];\n rootTags: RapiTag[];\n retailers: RapiRetailer[];\n\n [key: string]:\n | string\n | number\n | boolean\n | RapiRetailer[]\n | RapiTag[]\n | RapiMaterial[]\n | RapiComponent[]\n | RapiItem[]\n | RapiId[]\n | RapiTenant\n | LinksCollection\n | undefined;\n}\n\nexport interface RapiTenant extends RapiJson {\n name: string;\n label: string;\n defaultLanguage: string;\n active: boolean;\n showLanguageSwitch: boolean;\n branded: boolean;\n authenticationRequired: boolean;\n configuration: string;\n privacyUrl: string;\n\n catalogs: RapiCatalog[];\n users: RapiUser[];\n roles: RapiRole[];\n skin: RapiSkin[];\n plans: RapiPlan[];\n}\n\nexport interface RapiUser extends RapiJson {\n username: string;\n salutationCode: number;\n firstname: string;\n lastname: string;\n email: string;\n street: string;\n zipcode: string;\n city: string;\n countryCode: string;\n birthdate: string;\n phone: string;\n locale: string;\n registerDate: string;\n password: string;\n lastLogin: string;\n active: boolean;\n newsletter: boolean;\n emailValidated: string;\n termsChanged: boolean;\n providedConsentInTenant: boolean;\n priceLists: any;\n\n // Relationships\n tenants: RapiTenant[];\n roles: RapiRole[];\n catalogs: RapiCatalog[];\n plans: RapiPlan[];\n favorites: RapiFavorite[];\n setting: RapiUserSetting;\n}\n\nexport const enum RapiFavoriteType {\n ITEM = 1,\n CONFIG = 2,\n AFFILIATE = 3,\n}\n\nexport interface RapiFavorite extends RapiJson {\n objectId: string;\n type: RapiFavoriteType;\n created: string;\n user: RapiUser;\n}\n\nexport interface RapiUserSetting extends RapiJson {\n metric: boolean;\n measurements: boolean;\n area: boolean;\n furnitureSnap: boolean;\n\n user: RapiUser;\n}\n\nexport interface RapiRole extends RapiJson {\n // Data\n role: number;\n\n allowedModules: any;\n\n // Relationships\n tenantId: RapiTenant;\n userId: RapiUser;\n}\n\nexport interface RapiSkin extends RapiJson {\n accentColor: string;\n appIcon: string;\n backgroundImage: string;\n btnColorDark: string;\n btnColorLight: string;\n ciColor: string;\n dashboardBackground: string;\n loginBackground: string;\n dashboardLogo: string;\n fontColor: string;\n headerBackgroundColor: string;\n headerForegroundColor: string;\n logo: string;\n mailBackgroundColor: string;\n mailHeaderImage: string;\n planBackground: string;\n planLogo: string;\n splashScreenImage: string;\n tenantUrl: string;\n watermarkImage: string;\n brandedCatalogsIcon: string;\n planNote: string;\n inquiryImage: string;\n inquiryLink: string;\n hideMadeByRoomle: boolean;\n hidePressLink: boolean;\n hideShareButton: boolean;\n translationPath: string;\n hideFeedbackButton: boolean;\n referralUrl: string;\n hideCatalogOverview: boolean;\n // Relationships\n tenant: RapiTenant;\n catalogEntryTags: RapiTag;\n}\n\nexport interface RapiPlan extends RapiJson {\n name: string;\n description: string;\n changeDate: string;\n created: string;\n draftId: number | null; // THIS IS NOT USED BY THE BACKEND! USE DRAFT INSTEAD!!!!\n thumbnail: string;\n planObjects: string | null;\n active: boolean;\n right?: number;\n draft?: number;\n open: number;\n planDirectory: number;\n changed: number;\n version: number;\n floorLevel: number;\n //assets: array;\n visibility: number;\n\n // Relationships\n user: RapiUser | RapiId | null;\n tenant: RapiTenant | RapiId | null;\n assets: RapiPlanAsset[];\n parent: RapiPlan | RapiId | null;\n setting: RapiPlanSetting | null;\n}\n\nexport interface RapiPlanAsset extends RapiJson {\n image: string;\n}\n\nexport interface RapiPlanSetting extends RapiJson {\n metric: boolean;\n measurements: boolean;\n area: boolean;\n furnitureSnap: boolean;\n\n plan: RapiPlan;\n}\n\nexport type RapiPlanSnapshotId = `ps_${string}`;\nexport interface RapiPlanSnapshotPostData extends RapiJson {\n parentId: RapiId | null;\n planObjects: Array<{\n combinedId: RapiId;\n position: string;\n }>;\n plan: string;\n}\n\nexport interface RapiPlanSnapshotGetData extends RapiPlanSnapshotPostData {\n combinedIds: RapiId[];\n embedId: RapiId;\n perspectiveImage: string;\n topImage: string;\n}\n\n/* eslint-disable */\nexport interface RapiRetailer extends RapiJson {\n // NO ATTRS --> ask KUEGI how table looks\n}\n\n/* eslint:enable */\n\nexport interface RapiConfiguration extends RapiJson {\n id: RapiId;\n created: string;\n lastAccess: string;\n configuration: ConfigurationString;\n configurationHash: string;\n parts: string;\n perspectiveImage?: AssetUrl | null;\n topImage?: AssetUrl | null;\n rootComponentId: RapiId;\n orderable?: boolean;\n requestable?: boolean;\n width: number;\n height: number;\n depth: number;\n catalog?: RapiId;\n assets?: AssetItem;\n\n [key: string]:\n | string\n | number\n | boolean\n | AssetUrl\n | RapiId\n | LinksCollection\n | AssetItem\n | null\n | undefined;\n}\n\nexport interface RapiConfigurationEnhanced extends RapiConfiguration {\n label: string;\n}\n\nexport interface Element {\n id: string;\n label: string;\n perspectiveImage: AssetUrl;\n}\n\nexport interface RapiElement extends RapiJson, RoomleSortable, Element {\n id: RapiId;\n configuration?: ConfigurationString;\n externalIdentifier: string;\n tags: RapiId[];\n\n [key: string]:\n | string\n | number\n | boolean\n | AssetUrl\n | RapiId\n | RapiId[]\n | LinksCollection\n | AdditionalInfo[]\n | UiPossibleChild[]\n | AssetItem\n | undefined;\n}\nexport const CATALOG_INFOS_TYPES = {\n PARAMETER: 'parameter',\n PARAMETER_VALUE: 'paramValue',\n MATERIAL: 'material',\n COMPONENT: 'component',\n ITEM: 'item',\n} as const;\nexport interface AdditionalInfo {\n type: Enumify<typeof CATALOG_INFOS_TYPES>;\n key: string;\n parentIdFilter: string;\n catalog: string;\n tooltip: {\n [key: string]: string;\n };\n fullInfo: {\n type: string;\n url: {\n [key: string]: string;\n };\n };\n}\nexport interface RapiComponent extends RapiElement {\n active: boolean;\n additionalInfos: AdditionalInfo[];\n}\n\nexport interface Asset {\n format: string;\n url: string;\n}\n\nexport interface AssetItem {\n [key: string]: Asset;\n}\n\nexport interface RapiItem extends RapiElement {\n width: number;\n height: number;\n depth: number;\n perspectiveImageHD: AssetUrl;\n topImage: AssetUrl;\n // Dropped by RAPI v3, still sent by v2 — read `width`/`height`/`depth` and\n // `assets` instead, these only remain so v2 responses stay typed.\n basecolor?: number;\n displayedWidth?: number;\n displayedHeight?: number;\n displayedDepth?: number;\n threeDimensionalAssetWeb?: AssetUrl;\n threeDimensionalAssetIOS?: AssetUrl;\n threeDimensionalAsset?: AssetUrl;\n flipable: boolean;\n scaleable: boolean;\n meta: string;\n hidden: boolean;\n link?: string;\n colorable: boolean;\n layer: number;\n language: string;\n type: string;\n detailType: string;\n currencySymbol?: string;\n customerPrice?: number;\n sort: number;\n orderable: boolean;\n requestable: boolean;\n catalog: RapiId;\n assets?: AssetItem;\n rootComponentId?: string;\n}\n\nexport const enum RAPI_ADDITIONAL_CONTENTS {\n UNKNOWN,\n LINK,\n TEXT,\n VIDEO,\n DOWNLOAD,\n IMAGE,\n SKETCH,\n}\n\nexport interface RapiAdditionalContent extends RapiJson {\n changed: string;\n content: string;\n created: string;\n itemId: RapiId;\n label: string;\n language: string;\n type: RAPI_ADDITIONAL_CONTENTS;\n}\n\nexport interface RapiTagGeneric extends RapiJson {\n label?: string;\n externalIdentifier: string;\n pngIcon?: AssetUrl;\n svgIcon?: AssetUrl;\n inspirationImage?: AssetUrl;\n global: boolean;\n sort?: number;\n created: string;\n updated: string;\n language: string;\n description?: string;\n\n // Relationships\n catalog: RapiId;\n tags: RapiId[];\n parents: RapiId[];\n\n [key: string]:\n | string\n | number\n | boolean\n | AssetUrl\n | RapiId\n | RapiId[]\n | RapiElement[]\n | RapiMaterial[]\n | LinksCollection\n | null\n | undefined;\n}\n\nexport interface RapiTag extends RapiTagGeneric {\n id: RapiId;\n items: RapiId[];\n materials: RapiId[];\n}\n\nexport interface RapiTagForUi extends RapiTagGeneric {\n materials: RapiMaterial[];\n items: RapiItem[];\n}\n\nexport interface RapiShortId {\n shortId: string;\n referencedId: string;\n url: string;\n type: number;\n created: string;\n lastAccess: string;\n\n [key: string]: string | number;\n}\n\nexport interface RapiPrice {\n priceId: PriceId;\n price: number;\n currencySymbol: string;\n}\n\nexport interface RapiConfiguratorSettings {\n id: string;\n tenant: number;\n allowedHosts: string;\n settings: InitDataDefinition;\n}\n\nexport interface UserAction {\n module: number;\n action: number;\n planId: RapiId;\n actionId: RapiId;\n actionValue: number;\n actionLabel: number;\n}\n\nexport const enum MAIL_TYPE {\n STANDARD = 1,\n AUGMENTED_REALITY = 2,\n SAVE_DRAFT = 3,\n PLANNER_SHARE = 13,\n}\n\nexport interface RapiAuth {\n token: string;\n lastActionDate: string;\n loginDate: string;\n userId: RapiId;\n}\n","(function() {\n var base64map\n = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',\n\n crypt = {\n // Bit-wise rotation left\n rotl: function(n, b) {\n return (n << b) | (n >>> (32 - b));\n },\n\n // Bit-wise rotation right\n rotr: function(n, b) {\n return (n << (32 - b)) | (n >>> b);\n },\n\n // Swap big-endian to little-endian and vice versa\n endian: function(n) {\n // If number given, swap endian\n if (n.constructor == Number) {\n return crypt.rotl(n, 8) & 0x00FF00FF | crypt.rotl(n, 24) & 0xFF00FF00;\n }\n\n // Else, assume array and swap all items\n for (var i = 0; i < n.length; i++)\n n[i] = crypt.endian(n[i]);\n return n;\n },\n\n // Generate an array of any length of random bytes\n randomBytes: function(n) {\n for (var bytes = []; n > 0; n--)\n bytes.push(Math.floor(Math.random() * 256));\n return bytes;\n },\n\n // Convert a byte array to big-endian 32-bit words\n bytesToWords: function(bytes) {\n for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8)\n words[b >>> 5] |= bytes[i] << (24 - b % 32);\n return words;\n },\n\n // Convert big-endian 32-bit words to a byte array\n wordsToBytes: function(words) {\n for (var bytes = [], b = 0; b < words.length * 32; b += 8)\n bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);\n return bytes;\n },\n\n // Convert a byte array to a hex string\n bytesToHex: function(bytes) {\n for (var hex = [], i = 0; i < bytes.length; i++) {\n hex.push((bytes[i] >>> 4).toString(16));\n hex.push((bytes[i] & 0xF).toString(16));\n }\n return hex.join('');\n },\n\n // Convert a hex string to a byte array\n hexToBytes: function(hex) {\n for (var bytes = [], c = 0; c < hex.length; c += 2)\n bytes.push(parseInt(hex.substr(c, 2), 16));\n return bytes;\n },\n\n // Convert a byte array to a base-64 string\n bytesToBase64: function(bytes) {\n for (var base64 = [], i = 0; i < bytes.length; i += 3) {\n var triplet = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];\n for (var j = 0; j < 4; j++)\n if (i * 8 + j * 6 <= bytes.length * 8)\n base64.push(base64map.charAt((triplet >>> 6 * (3 - j)) & 0x3F));\n else\n base64.push('=');\n }\n return base64.join('');\n },\n\n // Convert a base-64 string to a byte array\n base64ToBytes: function(base64) {\n // Remove non-base-64 characters\n base64 = base64.replace(/[^A-Z0-9+\\/]/ig, '');\n\n for (var bytes = [], i = 0, imod4 = 0; i < base64.length;\n imod4 = ++i % 4) {\n if (imod4 == 0) continue;\n bytes.push(((base64map.indexOf(base64.charAt(i - 1))\n & (Math.pow(2, -2 * imod4 + 8) - 1)) << (imod4 * 2))\n | (base64map.indexOf(base64.charAt(i)) >>> (6 - imod4 * 2)));\n }\n return bytes;\n }\n };\n\n module.exports = crypt;\n})();\n","var charenc = {\n // UTF-8 encoding\n utf8: {\n // Convert a string to a byte array\n stringToBytes: function(str) {\n return charenc.bin.stringToBytes(unescape(encodeURIComponent(str)));\n },\n\n // Convert a byte array to a string\n bytesToString: function(bytes) {\n return decodeURIComponent(escape(charenc.bin.bytesToString(bytes)));\n }\n },\n\n // Binary encoding\n bin: {\n // Convert a string to a byte array\n stringToBytes: function(str) {\n for (var bytes = [], i = 0; i < str.length; i++)\n bytes.push(str.charCodeAt(i) & 0xFF);\n return bytes;\n },\n\n // Convert a byte array to a string\n bytesToString: function(bytes) {\n for (var str = [], i = 0; i < bytes.length; i++)\n str.push(String.fromCharCode(bytes[i]));\n return str.join('');\n }\n }\n};\n\nmodule.exports = charenc;\n","/*!\n * Determine if an object is a Buffer\n *\n * @author Feross Aboukhadijeh <https://feross.org>\n * @license MIT\n */\n\n// The _isBuffer check is for Safari 5-7 support, because it's missing\n// Object.prototype.constructor. Remove this eventually\nmodule.exports = function (obj) {\n return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)\n}\n\nfunction isBuffer (obj) {\n return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)\n}\n\n// For Node v0.10 support. Remove this eventually.\nfunction isSlowBuffer (obj) {\n return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))\n}\n","(function(){\r\n var crypt = require('crypt'),\r\n utf8 = require('charenc').utf8,\r\n isBuffer = require('is-buffer'),\r\n bin = require('charenc').bin,\r\n\r\n // The core\r\n md5 = function (message, options) {\r\n // Convert to byte array\r\n if (message.constructor == String)\r\n if (options && options.encoding === 'binary')\r\n message = bin.stringToBytes(message);\r\n else\r\n message = utf8.stringToBytes(message);\r\n else if (isBuffer(message))\r\n message = Array.prototype.slice.call(message, 0);\r\n else if (!Array.isArray(message))\r\n message = message.toString();\r\n // else, assume byte array already\r\n\r\n var m = crypt.bytesToWords(message),\r\n l = message.length * 8,\r\n a = 1732584193,\r\n b = -271733879,\r\n c = -1732584194,\r\n d = 271733878;\r\n\r\n // Swap endian\r\n for (var i = 0; i < m.length; i++) {\r\n m[i] = ((m[i] << 8) | (m[i] >>> 24)) & 0x00FF00FF |\r\n ((m[i] << 24) | (m[i] >>> 8)) & 0xFF00FF00;\r\n }\r\n\r\n // Padding\r\n m[l >>> 5] |= 0x80 << (l % 32);\r\n m[(((l + 64) >>> 9) << 4) + 14] = l;\r\n\r\n // Method shortcuts\r\n var FF = md5._ff,\r\n GG = md5._gg,\r\n HH = md5._hh,\r\n II = md5._ii;\r\n\r\n for (var i = 0; i < m.length; i += 16) {\r\n\r\n var aa = a,\r\n bb = b,\r\n cc = c,\r\n dd = d;\r\n\r\n a = FF(a, b, c, d, m[i+ 0], 7, -680876936);\r\n d = FF(d, a, b, c, m[i+ 1], 12, -389564586);\r\n c = FF(c, d, a, b, m[i+ 2], 17, 606105819);\r\n b = FF(b, c, d, a, m[i+ 3], 22, -1044525330);\r\n a = FF(a, b, c, d, m[i+ 4], 7, -176418897);\r\n d = FF(d, a, b, c, m[i+ 5], 12, 1200080426);\r\n c = FF(c, d, a, b, m[i+ 6], 17, -1473231341);\r\n b = FF(b, c, d, a, m[i+ 7], 22, -45705983);\r\n a = FF(a, b, c, d, m[i+ 8], 7, 1770035416);\r\n d = FF(d, a, b, c, m[i+ 9], 12, -1958414417);\r\n c = FF(c, d, a, b, m[i+10], 17, -42063);\r\n b = FF(b, c, d, a, m[i+11], 22, -1990404162);\r\n a = FF(a, b, c, d, m[i+12], 7, 1804603682);\r\n d = FF(d, a, b, c, m[i+13], 12, -40341101);\r\n c = FF(c, d, a, b, m[i+14], 17, -1502002290);\r\n b = FF(b, c, d, a, m[i+15], 22, 1236535329);\r\n\r\n a = GG(a, b, c, d, m[i+ 1], 5, -165796510);\r\n d = GG(d, a, b, c, m[i+ 6], 9, -1069501632);\r\n c = GG(c, d, a, b, m[i+11], 14, 643717713);\r\n b = GG(b, c, d, a, m[i+ 0], 20, -373897302);\r\n a = GG(a, b, c, d, m[i+ 5], 5, -701558691);\r\n d = GG(d, a, b, c, m[i+10], 9, 38016083);\r\n c = GG(c, d, a, b, m[i+15], 14, -660478335);\r\n b = GG(b, c, d, a, m[i+ 4], 20, -405537848);\r\n a = GG(a, b, c, d, m[i+ 9], 5, 568446438);\r\n d = GG(d, a, b, c, m[i+14], 9, -1019803690);\r\n c = GG(c, d, a, b, m[i+ 3], 14, -187363961);\r\n b = GG(b, c, d, a, m[i+ 8], 20, 1163531501);\r\n a = GG(a, b, c, d, m[i+13], 5, -1444681467);\r\n d = GG(d, a, b, c, m[i+ 2], 9, -51403784);\r\n c = GG(c, d, a, b, m[i+ 7], 14, 1735328473);\r\n b = GG(b, c, d, a, m[i+12], 20, -1926607734);\r\n\r\n a = HH(a, b, c, d, m[i+ 5], 4, -378558);\r\n d = HH(d, a, b, c, m[i+ 8], 11, -2022574463);\r\n c = HH(c, d, a, b, m[i+11], 16, 1839030562);\r\n b = HH(b, c, d, a, m[i+14], 23, -35309556);\r\n a = HH(a, b, c, d, m[i+ 1], 4, -1530992060);\r\n d = HH(d, a, b, c, m[i+ 4], 11, 1272893353);\r\n c = HH(c, d, a, b, m[i+ 7], 16, -155497632);\r\n b = HH(b, c, d, a, m[i+10], 23, -1094730640);\r\n a = HH(a, b, c, d, m[i+13], 4, 681279174);\r\n d = HH(d, a, b, c, m[i+ 0], 11, -358537222);\r\n c = HH(c, d, a, b, m[i+ 3], 16, -722521979);\r\n b = HH(b, c, d, a, m[i+ 6], 23, 76029189);\r\n a = HH(a, b, c, d, m[i+ 9], 4, -640364487);\r\n d = HH(d, a, b, c, m[i+12], 11, -421815835);\r\n c = HH(c, d, a, b, m[i+15], 16, 530742520);\r\n b = HH(b, c, d, a, m[i+ 2], 23, -995338651);\r\n\r\n a = II(a, b, c, d, m[i+ 0], 6, -198630844);\r\n d = II(d, a, b, c, m[i+ 7], 10, 1126891415);\r\n c = II(c, d, a, b, m[i+14], 15, -1416354905);\r\n b = II(b, c, d, a, m[i+ 5], 21, -57434055);\r\n a = II(a, b, c, d, m[i+12], 6, 1700485571);\r\n d = II(d, a, b, c, m[i+ 3], 10, -1894986606);\r\n c = II(c, d, a, b, m[i+10], 15, -1051523);\r\n b = II(b, c, d, a, m[i+ 1], 21, -2054922799);\r\n a = II(a, b, c, d, m[i+ 8], 6, 1873313359);\r\n d = II(d, a, b, c, m[i+15], 10, -30611744);\r\n c = II(c, d, a, b, m[i+ 6], 15, -1560198380);\r\n b = II(b, c, d, a, m[i+13], 21, 1309151649);\r\n a = II(a, b, c, d, m[i+ 4], 6, -145523070);\r\n d = II(d, a, b, c, m[i+11], 10, -1120210379);\r\n c = II(c, d, a, b, m[i+ 2], 15, 718787259);\r\n b = II(b, c, d, a, m[i+ 9], 21, -343485551);\r\n\r\n a = (a + aa) >>> 0;\r\n b = (b + bb) >>> 0;\r\n c = (c + cc) >>> 0;\r\n d = (d + dd) >>> 0;\r\n }\r\n\r\n return crypt.endian([a, b, c, d]);\r\n };\r\n\r\n // Auxiliary functions\r\n md5._ff = function (a, b, c, d, x, s, t) {\r\n var n = a + (b & c | ~b & d) + (x >>> 0) + t;\r\n return ((n << s) | (n >>> (32 - s))) + b;\r\n };\r\n md5._gg = function (a, b, c, d, x, s, t) {\r\n var n = a + (b & d | c & ~d) + (x >>> 0) + t;\r\n return ((n << s) | (n >>> (32 - s))) + b;\r\n };\r\n md5._hh = function (a, b, c, d, x, s, t) {\r\n var n = a + (b ^ c ^ d) + (x >>> 0) + t;\r\n return ((n << s) | (n >>> (32 - s))) + b;\r\n };\r\n md5._ii = function (a, b, c, d, x, s, t) {\r\n var n = a + (c ^ (b | ~d)) + (x >>> 0) + t;\r\n return ((n << s) | (n >>> (32 - s))) + b;\r\n };\r\n\r\n // Package private blocksize\r\n md5._blocksize = 16;\r\n md5._digestsize = 16;\r\n\r\n module.exports = function (message, options) {\r\n if (message === undefined || message === null)\r\n throw new Error('Illegal argument ' + message);\r\n\r\n var digestbytes = crypt.wordsToBytes(md5(message, options));\r\n return options && options.asBytes ? digestbytes :\r\n options && options.asString ? bin.bytesToString(digestbytes) :\r\n crypt.bytesToHex(digestbytes);\r\n };\r\n\r\n})();\r\n","import '../../../typings/global-definitions';\nimport type {\n RapiId,\n RapiItem,\n RapiJson,\n RapiMaterial,\n RapiTexture,\n} from '../../../typings/rapi-types';\nimport { RAPI_TEXTURE_TYPE } from '../../../typings/rapi-types';\nimport type {\n KernelFloorMaterial,\n KernelWallMaterial,\n} from '../../../typings/planner';\nimport type { BatchPaintMaterial } from '../../../planner-core/src/roomle-planner';\nimport { Color } from 'three';\nimport md5 from 'md5';\nimport type { CameraParameter } from '../cameracontrol/camera-control';\n\nexport const enum CURSOR_STYLE {\n HOVER = 'pointer',\n DEFAULT = 'default',\n MOVE = 'move',\n DRAGGING = 'grabbing',\n ROTATE = 'ew-resize',\n NODE_HOVER = 'crosshair',\n // eslint-disable-next-line @typescript-eslint/quotes\n DRAW = \"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 3 20, auto\",\n // eslint-disable-next-line @typescript-eslint/quotes\n DRAW_FALLBACK = \"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 0 15, auto\",\n}\n\n/**\n * Colors can be set as hex value, eg 0x00ff00 or as official HTML color name: https://www.w3schools.com/colors/colors_names.asp\n */\nexport const ROOMLE_COLORS = {\n PRIMARY: 0xdb0000,\n ON_PRIMARY: 0xffffff,\n DEFAULT_BACKGROUND: 0xf7f7f7,\n SELECTION: 0xffffff,\n PREVIEW_DOCKING_COLOR: 0xfdddddd,\n SNAP_DOCKING: 0x80ff80,\n SNAP_COLLISION: 0xff8080,\n} as const;\n\nexport const ROOMLE_HIGHLIGHTNG = {\n SMART: 'smart',\n OFF: 'off',\n ALWAYS: 'always',\n};\n\nexport const setCursor = (style: CURSOR_STYLE) => {\n // refactor into dom helper to be save in SDK\n document.body.style.cursor = style;\n};\n\nexport const handleJsonResponse = (response: Response): Promise<any> => {\n const contentType = response.headers.get('content-type');\n if (contentType && contentType.includes('application/json')) {\n return response.json();\n }\n throw new TypeError('No JSON returned');\n};\n\nexport const uuid = (a: string | null = null): string => {\n return a\n ? (\n parseInt(a, 10) ^\n ((Math.random() * 16) >> (parseInt(a, 10) / 4))\n ).toString(16)\n : ((1e7).toString() + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, uuid);\n};\n\nexport const setEnumerable = (\n target: any,\n property: string,\n isEnumerable: boolean,\n) => {\n setDescriptor(target, property, { enumerable: isEnumerable });\n};\n\nexport const setWriteable = (\n target: any,\n property: string,\n isWritable: boolean,\n) => {\n setDescriptor(target, property, { writable: isWritable });\n};\n\nexport const setDescriptor = (\n target: any,\n property: string,\n options: PropertyDescriptor,\n) => {\n const descriptor = Object.getOwnPropertyDescriptor(target, property);\n if (!descriptor) {\n throw new Error(`Property \"${property}\" not found on target`);\n }\n for (const prop in options) {\n if (options.hasOwnProperty(prop)) {\n (descriptor as any)[prop] = (options as any)[prop]; // as any because there are no signature types defined in std.lib\n }\n }\n Object.defineProperty(target, property, descriptor);\n};\n\nexport const setPropertiesFromOptions = (\n target: any,\n options: any,\n writeable?: true,\n) => {\n if (!options) {\n return;\n }\n Object.keys(options).forEach((key) => {\n Object.defineProperty(target, key, {\n value: options[key],\n writable: writeable,\n });\n });\n};\n\nexport const createBenchmarkMaterial = (materialId: string): RapiMaterial => {\n const color = new Color(0.5, 0.5, 0.5);\n const hexColor = color.getHexString();\n const material: RapiMaterial = {\n id: materialId,\n name: materialId,\n externalIdentifier: 'test-identifier',\n group: 'test-group',\n groupLabel: 'test-group-label',\n color: '#' + hexColor,\n thumbnail: createBenchmarkUrl(materialId, 15),\n label: 'test-label',\n textures: [1, 2, 3],\n shading: {\n alpha: 1,\n metallic: 0.5,\n basecolor: {\n r: 0.5,\n g: 0.5,\n b: 0.5,\n },\n roughness: 0.5,\n doubleSided: false,\n alphaCutoff: 0.5,\n },\n active: true,\n tags: [],\n };\n\n return material;\n};\n\nexport const createBenchmarkTexture = (materialId: string): RapiTexture => {\n const parts = materialId.split('_');\n const size = parseInt(parts[1], 10);\n const texture = {\n mapping: RAPI_TEXTURE_TYPE.RGB,\n id: materialId,\n material: materialId,\n image: createBenchmarkUrl(materialId),\n url: createBenchmarkUrl(materialId),\n height: size,\n width: size,\n mmHeight: 1,\n mmWidth: 1,\n tileable: true,\n };\n\n return texture;\n};\n\nexport const createBenchmarkUrl = (\n materialId: string,\n size?: number,\n): string => {\n const parts = materialId.split('_');\n if (!size) {\n size = parseInt(parts[1], 10);\n }\n const uniqueId = Math.abs(parseFloat(parts[2]));\n const dummyUrl =\n 'https://loremflickr.com/' + size + '/' + size + '?lock=' + uniqueId;\n return dummyUrl;\n};\n\nexport const isString = (value: unknown): boolean => {\n return typeof value === 'string' || value instanceof String;\n};\n\nexport const objectArrayToMap = <K extends V[keyof V], V extends object>(\n arr: V[],\n key: keyof V,\n): Map<K, V> => {\n return arr.reduce((acc, data) => {\n if (typeof data !== 'object') {\n console.warn('objectArrayToMap only works for arrays of objects');\n return acc;\n }\n const mapKey = data[key];\n if (!mapKey) {\n console.warn(\n 'Object has no key \"' +\n key.toString() +\n '\" therefore we do not know where to put it',\n );\n return acc;\n }\n if (!acc.has(mapKey)) {\n acc.set(mapKey, data);\n }\n return acc;\n }, new Map());\n};\n\nexport const throttle = <T extends (...args: any[]) => any>(\n func: T,\n delay: number = 16,\n): ((...funcArgs: Parameters<T>) => void) => {\n let time: number;\n let called = false;\n let skippedCalls = 0;\n let trailingCall: NodeJS.Timeout | null = null;\n return function (this: T, ..._args: Parameters<T>): void {\n if (!time) {\n time = Date.now();\n }\n if (!called || time + delay - Date.now() < 0) {\n func.apply(this, [...arguments]);\n time = Date.now();\n called = true;\n } else {\n skippedCalls++;\n }\n if (!trailingCall) {\n trailingCall = setInterval(() => {\n if (skippedCalls) {\n func.apply(this, [...arguments]);\n }\n skippedCalls = 0;\n if (trailingCall !== null) {\n clearInterval(trailingCall);\n }\n trailingCall = null;\n }, delay);\n }\n };\n};\n\n/**\n * Calls the function only if there has been no call for x (param after) milliseconds\n * @param func\n * @param after\n */\nexport const callAgainAfter = <T extends (...args: any[]) => any>(\n func: T,\n after: number = 16,\n): ((...funcArgs: Parameters<T>) => void) => {\n let lastCall: number;\n let called = false;\n return function (this: T, ..._args: Parameters<T>): void {\n if (!called || lastCall + after - Date.now() < 0) {\n lastCall = Date.now();\n func.apply(this, [...arguments]);\n called = true;\n } else {\n lastCall = Date.now();\n }\n };\n};\n\nexport const debounce = <Params extends any[]>(\n func: (...args: Params) => any,\n timeout: number,\n): ((...args: Params) => void) => {\n let timer: NodeJS.Timeout;\n return (...args: Params) => {\n clearTimeout(timer);\n timer = setTimeout(() => {\n func(...args);\n }, timeout);\n };\n};\n\n/**\n * A generic type for a function.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyFunction = (...args: any[]) => any;\n\n/**\n * Creates a debounced function that delays invoking `func` until after `delay`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked with the same key. The debounced function comes with a `cancel`\n * method to cancel delayed `func` invocations and a `flush` method to\n * immediately invoke them.\n *\n * T The type of the function to debounce.\n * @param {T} func The function to debounce.\n * @param {number} delay The number of milliseconds to delay.\n * @param {(...args: Parameters<T>) => unknown} [keyResolver]\n * Optional. A function to resolve the key from the arguments.\n * Defaults to using the first argument as the key.\n * @returns {((...args: Parameters<T>) => void)} The new debounced function.\n */\nexport const debounceByKey = <T extends AnyFunction>(\n func: T,\n delay: number,\n keyResolver?: (...args: Parameters<T>) => unknown,\n) => {\n // 1. Use a Map to store timers, keyed by your object or resolved key.\n // The key can be of any type, and the value is the timer ID from setTimeout.\n const timers = new Map<unknown, ReturnType<typeof setTimeout>>();\n\n // 2. The default resolver just uses the first argument as the key.\n const resolver = keyResolver || ((...args: Parameters<T>) => args[0]);\n\n // 3. Return the new debounced function.\n // It accepts the same parameters as the original function.\n return function (this: ThisParameterType<T>, ...args: Parameters<T>): void {\n // 4. Capture the 'this' context from the call.\n const context = this;\n\n // 5. Get the unique key for this specific call (e.g., the object itself).\n const key = resolver.apply(context, args);\n\n // 6. Check for an existing timer *for this specific key*.\n const existingTimer = timers.get(key);\n\n // 7. If a timer already exists for this key, clear it.\n if (existingTimer) {\n clearTimeout(existingTimer);\n }\n\n // 8. Set a new timer.\n const newTimer = setTimeout(() => {\n // 9. When the timer finally fires, call the original function\n // with the saved context and arguments from the *last* call.\n func.apply(context, args);\n\n // 10. Clean up the map to prevent memory leaks for this key.\n timers.delete(key);\n }, delay);\n\n // 11. Store the new timer ID, associated with its key.\n timers.set(key, newTimer);\n };\n};\n\n/**\n * Interface for storing a single promise's resolve and reject handlers.\n */\ninterface PromiseHandlers<T extends AnyFunction> {\n resolve: (value: ReturnType<T> | PromiseLike<ReturnType<T>>) => void;\n reject: (reason?: any) => void;\n}\n\n/**\n * Interface for storing timer details along with promise handlers for a given key.\n */\ninterface TimerDetails<T extends AnyFunction> {\n timer: ReturnType<typeof setTimeout>;\n handlers: Array<PromiseHandlers<T>>;\n context: ThisParameterType<T>;\n args: Parameters<T>;\n}\n\n/**\n * A key-debounced async function that additionally exposes `flush()` to run all\n * currently pending invocations immediately and resolve once they settle.\n */\nexport type DebouncedByKeyAsync<T extends AnyFunction> = ((\n ...args: Parameters<T>\n) => Promise<Awaited<ReturnType<T>>>) & {\n /**\n * Fire every pending (still-debouncing) invocation right now instead of waiting\n * for its timer, and resolve once all of them have settled.\n */\n flush: () => Promise<void>;\n};\n\n/**\n * Creates a debounced function that delays invoking `func` until after `delay`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked with the same key. All calls made with the same key during the\n * delay period will have their returned promises resolved with the result\n * of the single final invocation.\n *\n * T The type of the function to debounce.\n * @param {T} func The function to debounce. This function can be synchronous or asynchronous.\n * @param {number} delay The number of milliseconds to delay.\n * @param {(...args: Parameters<T>) => unknown} [keyResolver]\n * Optional. A function to resolve the key from the arguments.\n * Defaults to using the first argument as the key.\n * @returns {((...args: Parameters<T>) => Promise<ReturnType<T>>)} The new debounced function.\n */\nexport const debounceByKeyAsync = <T extends AnyFunction>(\n func: T,\n delay: number,\n keyResolver?: (...args: Parameters<T>) => unknown,\n): DebouncedByKeyAsync<T> => {\n // 1. Use a Map to store timers and promise handlers, keyed by the resolved key.\n const timers = new Map<unknown, TimerDetails<T>>();\n\n // 2. The default resolver uses the first argument as the key.\n const resolver = keyResolver || ((...args: Parameters<T>) => args[0]);\n\n // Invoke `func` for a single pending key now, resolve/reject its handlers, and\n // remove it from the map. Shared by the timer callback and `flush()`.\n const fire = (key: unknown, details: TimerDetails<T>): Promise<void> => {\n clearTimeout(details.timer);\n timers.delete(key);\n return Promise.resolve(func.apply(details.context, details.args))\n .then((result) => {\n details.handlers.forEach((handler) => handler.resolve(result));\n })\n .catch((error) => {\n details.handlers.forEach((handler) => handler.reject(error));\n });\n };\n\n // 3. Return the new promise-based debounced function.\n const debounced = function (\n this: ThisParameterType<T>,\n ...args: Parameters<T>\n ): Promise<Awaited<ReturnType<T>>> {\n const context = this;\n const key = resolver.apply(context, args);\n\n return new Promise((resolve, reject) => {\n // 4. Check for existing timer details for this specific key.\n const existingTimerDetails = timers.get(key);\n\n // 5. If a timer already exists, clear it.\n if (existingTimerDetails) {\n clearTimeout(existingTimerDetails.timer);\n }\n\n // 6. Get the list of promise handlers, or create a new one.\n const handlers = existingTimerDetails?.handlers || [];\n handlers.push({ resolve, reject }); // Add the current promise's handlers.\n\n // 7. Store the timer plus the latest context/args so the invocation can be\n // fired either by the timer or eagerly by flush().\n const details: TimerDetails<T> = {\n timer: undefined as unknown as ReturnType<typeof setTimeout>,\n handlers,\n context,\n args,\n };\n details.timer = setTimeout(() => {\n void fire(key, details);\n }, delay);\n timers.set(key, details);\n });\n };\n\n // Run every pending invocation immediately (skipping the remaining debounce\n // delay) and resolve once all of them have settled.\n debounced.flush = (): Promise<void> => {\n const pending = Array.from(timers.entries()).map(([key, details]) =>\n fire(key, details),\n );\n return Promise.allSettled(pending).then(() => undefined);\n };\n\n return debounced;\n};\n\nexport const wait = async (delay: number): Promise<void> =>\n new Promise((resolve) => setTimeout(resolve, delay));\n\nexport const nextTick = async (): Promise<void> => wait(0);\n\nexport const withTimeout = <T>(\n promise: Promise<T>,\n message: string,\n timeout: number,\n): Promise<T> => {\n let timer: ReturnType<typeof setTimeout> | undefined;\n const expired = new Promise<never>((_resolve, reject) => {\n timer = setTimeout(\n () => reject(new Error(`${message} (timed out after ${timeout}ms)`)),\n timeout,\n );\n });\n return Promise.race([promise, expired]).finally(() => clearTimeout(timer));\n};\n\nexport const roundWithPrecision = (float: number, precision: number) => {\n if (precision === -1) {\n return float;\n }\n const factor = Math.pow(10, precision);\n return Math.round(float * factor) / factor;\n};\n\nconst LEGACY_ASSET_URL_REG_EX = new RegExp(/\\/3d\\/[0-9]+\\//);\n\nexport const getGlbUrl = (item: RapiItem): string | null => {\n // use glb asset without ktx textures as default\n // glb2 used ktx textures\n if (item.assets?.glb?.url) {\n return item.assets.glb.url;\n }\n if (item.threeDimensionalAsset) {\n return item.threeDimensionalAsset;\n }\n const assetUrl = item.threeDimensionalAssetWeb;\n if (!assetUrl || typeof assetUrl !== 'string') {\n // Maybe we should introduce Nullable so we can turn on\n // strict null checks for SDK? But that's probably\n // a separate user story\n return null;\n }\n return !assetUrl.match(LEGACY_ASSET_URL_REG_EX)\n ? assetUrl\n : assetUrl\n .replace(LEGACY_ASSET_URL_REG_EX, '/3d/glb/')\n .replace('.flash.u3d', '.glb');\n};\n\n/**\n * Recursively merge properties of two objects.\n * If a property exists in both, property of obj2 is used\n * @param obj1\n * @param obj2\n */\nexport const deepMerge = (obj1: any, obj2: any): any => {\n for (const p in obj2) {\n try {\n // Property in destination object set; update its value.\n if (obj2[p].constructor === Object) {\n obj1[p] = deepMerge(obj1[p], obj2[p]);\n } else {\n obj1[p] = obj2[p];\n }\n } catch (_e) {\n // Property in destination object not set; create it and set its value.\n obj1[p] = obj2[p];\n }\n }\n return obj1;\n};\n\nexport const getValue = (value: any, defaultValue: any): any => {\n if (value === undefined) {\n return defaultValue;\n }\n return value;\n};\n\nexport const removeItem = (arr: any[], element: any) => {\n const index = arr.indexOf(element);\n if (index > -1) {\n arr.splice(index, 1);\n }\n};\n\nexport type ValuesFromObject<T> = T[keyof T];\n\nexport type MaybePromise<T> = (() => T) | (() => Promise<T>);\n\nexport const copy = <T>(object: T): T => {\n if (!object) {\n return object;\n }\n return JSON.parse(JSON.stringify(object));\n};\n\nexport const isWebGl2 = (): boolean => {\n const canvas = document.createElement('canvas');\n if (\n !canvas ||\n !canvas.getContext ||\n typeof canvas.getContext !== 'function'\n ) {\n return false;\n }\n try {\n return canvas ? !!canvas.getContext('webgl2') : false;\n } catch (_e) {\n return false;\n }\n};\n\n/**\n * Creates a proxy around that class that logs all calls to it\n * @param obj the class to trace\n * @param name the tag under which it will be logged\n */\nexport const traceMethodCalls = (obj: object, name: string) => {\n const handler = {\n get(target: any, propKey: any, receiver: any) {\n const targetValue = Reflect.get(target, propKey, receiver);\n if (typeof targetValue === 'function') {\n return function (...args: any) {\n console.trace(name, propKey, args);\n // @ts-ignore -- helper for better debugging, TS does not know what we are doing\n return targetValue.apply(this, args); // (A)\n };\n } else {\n return targetValue;\n }\n },\n };\n return new Proxy(obj, handler);\n};\n\n/**\n * Creates a proxy around that class that can be used to track property access\n * @param obj the class to track\n * @param name the tag under which it will be logged\n */\nexport const trackPropertyAccess = (obj: object, _name: string) => {\n const handler = {\n get(target: any, propKey: any, _receiver: any) {\n return target[propKey];\n },\n set(target: any, propKey: any, value: any, _receiver: any) {\n target[propKey] = value;\n return true;\n },\n };\n return new Proxy(obj, handler);\n};\n\nexport const getColor = (value: string | number | Color): Color => {\n if (isThreeJsColor(value)) {\n return value;\n }\n if (typeof value === 'string' && (isHex(value) || isOnlyNumbers(value))) {\n return new Color(Number(value));\n } else {\n return new Color(value);\n }\n};\n\nexport const isThreeJsColor = (value: any): value is Color => {\n return value instanceof Color;\n};\n\nexport const isHex = (num: string) => {\n return Boolean(num.match(/^0x[0-9a-f]+$/i));\n};\n\nexport const isOnlyNumbers = (num: string) => {\n return Boolean(num.match(/^[0-9]+$/i));\n};\n\nexport const parseColorToHexDecimal = (color: string) =>\n !color ? -1 : Number('0x' + color.substring(1));\n\n/**\n * Copies the properties of an incoming material to a kernel material, used mainly\n * to avoid copying core data when applying a material to a planObject\n * @param materialPtr Kernel material pointer to apply properties to\n * @param material material to copy color properties from\n */\nexport const applyMaterialToKernelMaterial = (\n materialPtr: KernelWallMaterial | KernelFloorMaterial,\n material: BatchPaintMaterial,\n): KernelWallMaterial | KernelFloorMaterial => {\n if (material.materialId) {\n materialPtr.materialId = material.materialId;\n } else if (material.color) {\n // Material is a hex string, so we convert it to a rgb value.\n materialPtr.rgbValue = parseColorToHexDecimal(material.color);\n } else if (material.rgbValue) {\n materialPtr.rgbValue = material.rgbValue;\n } else if (material.catalogItemId !== undefined) {\n materialPtr.catalogItemId = material.catalogItemId;\n } else if (material.id) {\n materialPtr.materialId = material.id;\n } else {\n console.warn(\n 'Can not set material because neither a texture nor a RGB value was found',\n );\n }\n return materialPtr;\n};\n\n/**\n * MD5 hex digest of a string, e.g. the hashed password RapiAccess.signinUser expects\n */\nexport const md5Hash = (value: string): string => md5(value);\n\nexport const download = (filename: string, content: string): void => {\n const element = document.createElement('a');\n element.setAttribute('href', content);\n element.setAttribute('download', filename);\n\n element.style.display = 'none';\n document.body.appendChild(element);\n\n element.click();\n\n document.body.removeChild(element);\n};\n\nexport const areCameraParametersEqual = (\n start: CameraParameter,\n end: CameraParameter,\n): boolean => {\n if (!start || !end) {\n return false;\n }\n if (\n start.targetX === undefined ||\n end.targetX === undefined ||\n Math.abs(start.targetX - end.targetX) > 0.01\n ) {\n return false;\n }\n if (\n start.targetY === undefined ||\n end.targetY === undefined ||\n Math.abs(start.targetY - end.targetY) > 0.01\n ) {\n return false;\n }\n if (\n start.targetZ === undefined ||\n end.targetZ === undefined ||\n Math.abs(start.targetZ - end.targetZ) > 0.01\n ) {\n return false;\n }\n if (\n start.yaw === undefined ||\n end.yaw === undefined ||\n Math.abs(start.yaw - end.yaw) > 0.01\n ) {\n return false;\n }\n if (\n start.distance === undefined ||\n end.distance === undefined ||\n Math.abs(start.distance - end.distance) > 0.01\n ) {\n return false;\n }\n return true;\n};\n\n/**\n * transforms a value from one range (oldMin, oldMax) to a new range (newMin, newMax)\n * @param value the value to transform\n * @param oldMin\n * @param oldMax\n * @param newMin\n * @param newMax\n * @returns the transformed value\n */\nexport const transformRange = (\n value: number,\n oldMin: number,\n oldMax: number,\n newMin: number,\n newMax: number,\n): number => {\n return ((value - oldMin) * (newMax - newMin)) / (oldMax - oldMin) + newMin;\n};\n\nexport const hashCode = (value: string): number => {\n let hash = 0;\n if (value.length === 0) {\n return hash;\n }\n for (let i = 0; i < value.length; i++) {\n const chr = value.charCodeAt(i);\n hash = (hash << 5) - hash + chr;\n hash |= 0; // Convert to 32bit integer\n }\n return hash;\n};\n\nexport const rearrangeArrayByIdOrder = <T extends RapiJson>(\n idsInOrder: RapiId[],\n rapiJson: T[],\n idKey: string = 'id',\n): T[] => {\n const indexMap = new Map<RapiId, number>();\n const length = idsInOrder.length;\n for (let i = 0; i < length; i++) {\n indexMap.set(idsInOrder[i], i);\n }\n\n const sortedResult = new Array<T>(length);\n\n // Place each element from the result array at its corresponding index in sortedResult\n const rapiJsonLength = rapiJson.length;\n for (let j = 0; j < rapiJsonLength; j++) {\n const entry = rapiJson[j];\n const id = entry[idKey];\n const index = indexMap.get(id as RapiId);\n if (index !== undefined) {\n sortedResult[index] = entry;\n } else {\n sortedResult.push(entry);\n }\n }\n\n return sortedResult.filter((element) => element !== undefined);\n};\n\nexport interface PromiseWithResolvers<T> {\n promise: Promise<T>;\n resolve: (value: T) => void;\n reject: (reason?: any) => void;\n}\n\nexport const promiseWithResolvers = <T>(): PromiseWithResolvers<T> => {\n let resolve!: (value: T) => void;\n let reject!: (reason?: any) => void;\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n};\n\nexport const clamp = (value: number, min: number, max: number): number => {\n return Math.max(min, Math.min(max, value));\n};\n\nexport const randomString = (length: number = 8): string => {\n return [...Array(length)]\n .map(() => Math.random().toString(36).charAt(2))\n .join('');\n};\n\nexport const deepCopy = <T>(obj: T): T => {\n return JSON.parse(JSON.stringify(obj));\n};\n\nexport const isRecord = (value: any): value is Record<string, any> => {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n};\n\nexport const getIdQueryParam = (urlString: string): string | null => {\n try {\n const url = new URL(urlString);\n const params = new URLSearchParams(url.search);\n return params.get('id');\n } catch (_error) {\n return null; // Return null if URL is invalid or 'id' param is not found\n }\n};\n\nexport const isCtrlOrCmd = (event: KeyboardEvent) =>\n event.key === 'Meta' || event.key === 'Control';\n\nexport const ctrlOrCmd = (\n event: KeyboardEvent,\n checkIfItIsTheOnlyKey: boolean = false,\n) => {\n const isMultiSelectKey =\n checkIfItIsTheOnlyKey === false\n ? checkIfItIsTheOnlyKey\n : isCtrlOrCmd(event);\n return event.key && (event.metaKey || event.ctrlKey || isMultiSelectKey);\n};\n\nexport const runIfNotEmpty = <T extends any[]>(\n ids: string[],\n executor: () => Promise<T>,\n): Promise<T> => {\n if (!ids || ids.length === 0) {\n return Promise.resolve([] as unknown as T);\n }\n return executor();\n};\n"],"x_google_ignoreList":[1,2,3,4],"mappings":";;;;AAiKA,IAAkB,IAAX,yBAAA,GAAA;QACL,EAAA,MAAA,OACA,EAAA,OAAA,QACA,EAAA,MAAA,OACA,EAAA,MAAA,OACA,EAAA,QAAA,SACA,EAAA,OAAA,QACA,EAAA,QAAA,SACA,EAAA,SAAA,UACA,EAAA,SAAA,UACA,EAAA,OAAA;KACD,EAkYiB,IAAX,yBAAA,GAAA;QACL,EAAA,EAAA,UAAA,KAAA,WACA,EAAA,EAAA,OAAA,KAAA,QACA,EAAA,EAAA,OAAA,KAAA,QACA,EAAA,EAAA,QAAA,KAAA,SACA,EAAA,EAAA,WAAA,KAAA,YACA,EAAA,EAAA,QAAA,KAAA,SACA,EAAA,EAAA,SAAA,KAAA;KACD;ACtjBD,EAAC,WAAW;EACV,IAAI,IACE,oEAEN,IAAQ;GAEN,MAAM,SAAS,GAAG,GAAG;AACnB,WAAQ,KAAK,IAAM,MAAO,KAAK;;GAIjC,MAAM,SAAS,GAAG,GAAG;AACnB,WAAQ,KAAM,KAAK,IAAO,MAAM;;GAIlC,QAAQ,SAAS,GAAG;AAElB,QAAI,EAAE,eAAe,OACnB,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