@threekit-tools/treble 0.0.91 → 0.0.92-next-01

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 (189) hide show
  1. package/dist/Treble/Treble.d.ts +2 -2
  2. package/dist/Treble/Treble.js +2 -2
  3. package/dist/Treble/index.d.ts +1 -1
  4. package/dist/Treble/index.js +1 -1
  5. package/dist/components/ThreekitProvider/index.js +3 -2
  6. package/dist/connection.d.ts +4 -1
  7. package/dist/connection.js +16 -53
  8. package/dist/hooks/useAttribute/index.js +1 -5
  9. package/dist/hooks/useNestedConfigurator/index.js +1 -2
  10. package/dist/hooks/useSpaces/SpacesLayout.d.ts +11 -0
  11. package/dist/hooks/useSpaces/SpacesLayout.js +74 -0
  12. package/dist/hooks/useSpaces/SpacesState.d.ts +177 -0
  13. package/dist/hooks/useSpaces/SpacesState.js +1814 -0
  14. package/dist/hooks/useSpaces/constants.d.ts +79 -0
  15. package/dist/hooks/useSpaces/constants.js +130 -0
  16. package/dist/hooks/useSpaces/dataHandlers.d.ts +38 -0
  17. package/dist/hooks/useSpaces/dataHandlers.js +407 -0
  18. package/dist/hooks/useSpaces/draw/clearCanvas.d.ts +2 -0
  19. package/dist/hooks/useSpaces/draw/clearCanvas.js +9 -0
  20. package/dist/hooks/useSpaces/draw/drawBackground.d.ts +2 -0
  21. package/dist/hooks/useSpaces/draw/drawBackground.js +12 -0
  22. package/dist/hooks/useSpaces/draw/drawDimensions.d.ts +3 -0
  23. package/dist/hooks/useSpaces/draw/drawDimensions.js +53 -0
  24. package/dist/hooks/useSpaces/draw/drawDoors.d.ts +9 -0
  25. package/dist/hooks/useSpaces/draw/drawDoors.js +99 -0
  26. package/dist/hooks/useSpaces/draw/drawFloor.d.ts +3 -0
  27. package/dist/hooks/useSpaces/draw/drawFloor.js +36 -0
  28. package/dist/hooks/useSpaces/draw/drawGrid.d.ts +3 -0
  29. package/dist/hooks/useSpaces/draw/drawGrid.js +36 -0
  30. package/dist/hooks/useSpaces/draw/drawGuides.d.ts +3 -0
  31. package/dist/hooks/useSpaces/draw/drawGuides.js +23 -0
  32. package/dist/hooks/useSpaces/draw/drawOpenings.d.ts +9 -0
  33. package/dist/hooks/useSpaces/draw/drawOpenings.js +72 -0
  34. package/dist/hooks/useSpaces/draw/drawVertices.d.ts +8 -0
  35. package/dist/hooks/useSpaces/draw/drawVertices.js +61 -0
  36. package/dist/hooks/useSpaces/draw/drawWalls.d.ts +11 -0
  37. package/dist/hooks/useSpaces/draw/drawWalls.js +90 -0
  38. package/dist/hooks/useSpaces/draw/drawWindows.d.ts +9 -0
  39. package/dist/hooks/useSpaces/draw/drawWindows.js +82 -0
  40. package/dist/hooks/useSpaces/draw/index.d.ts +11 -0
  41. package/dist/hooks/useSpaces/draw/index.js +129 -0
  42. package/dist/hooks/useSpaces/geometry/addThicknessToLine.d.ts +3 -0
  43. package/dist/hooks/useSpaces/geometry/addThicknessToLine.js +13 -0
  44. package/dist/hooks/useSpaces/geometry/areLinesEqual.d.ts +3 -0
  45. package/dist/hooks/useSpaces/geometry/areLinesEqual.js +17 -0
  46. package/dist/hooks/useSpaces/geometry/arePointsEqual.d.ts +3 -0
  47. package/dist/hooks/useSpaces/geometry/arePointsEqual.js +8 -0
  48. package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.d.ts +3 -0
  49. package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.js +11 -0
  50. package/dist/hooks/useSpaces/geometry/closestPointOnLine.d.ts +3 -0
  51. package/dist/hooks/useSpaces/geometry/closestPointOnLine.js +13 -0
  52. package/dist/hooks/useSpaces/geometry/doLinesOverlap.d.ts +2 -0
  53. package/dist/hooks/useSpaces/geometry/doLinesOverlap.js +16 -0
  54. package/dist/hooks/useSpaces/geometry/euclideanMod.d.ts +2 -0
  55. package/dist/hooks/useSpaces/geometry/euclideanMod.js +6 -0
  56. package/dist/hooks/useSpaces/geometry/findLoops.d.ts +6 -0
  57. package/dist/hooks/{useRoomBuilder → useSpaces/geometry}/findLoops.js +31 -13
  58. package/dist/hooks/useSpaces/geometry/getAllLineIntersections.d.ts +6 -0
  59. package/dist/hooks/useSpaces/geometry/getAllLineIntersections.js +23 -0
  60. package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.d.ts +3 -0
  61. package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.js +7 -0
  62. package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.d.ts +3 -0
  63. package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.js +17 -0
  64. package/dist/hooks/useSpaces/geometry/getDistanceToLine.d.ts +3 -0
  65. package/dist/hooks/useSpaces/geometry/getDistanceToLine.js +10 -0
  66. package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.d.ts +3 -0
  67. package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.js +7 -0
  68. package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.d.ts +3 -0
  69. package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.js +17 -0
  70. package/dist/hooks/useSpaces/geometry/getLineOtherPoint.d.ts +3 -0
  71. package/dist/hooks/useSpaces/geometry/getLineOtherPoint.js +11 -0
  72. package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.d.ts +3 -0
  73. package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.js +43 -0
  74. package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.d.ts +3 -0
  75. package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.js +9 -0
  76. package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.d.ts +3 -0
  77. package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.js +20 -0
  78. package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.d.ts +3 -0
  79. package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.js +11 -0
  80. package/dist/hooks/useSpaces/geometry/getPolygonArea.d.ts +3 -0
  81. package/dist/hooks/useSpaces/geometry/getPolygonArea.js +15 -0
  82. package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.d.ts +3 -0
  83. package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.js +16 -0
  84. package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.d.ts +6 -0
  85. package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.js +17 -0
  86. package/dist/hooks/useSpaces/geometry/getTriangleArea.d.ts +3 -0
  87. package/dist/hooks/useSpaces/geometry/getTriangleArea.js +9 -0
  88. package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.d.ts +3 -0
  89. package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.js +12 -0
  90. package/dist/hooks/useSpaces/geometry/index.d.ts +30 -0
  91. package/dist/hooks/useSpaces/geometry/index.js +64 -0
  92. package/dist/hooks/useSpaces/geometry/isPointInPolygon.d.ts +3 -0
  93. package/dist/hooks/useSpaces/geometry/isPointInPolygon.js +21 -0
  94. package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.d.ts +3 -0
  95. package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.js +25 -0
  96. package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.d.ts +3 -0
  97. package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.js +11 -0
  98. package/dist/hooks/useSpaces/geometry/splitLineAtOffset.d.ts +3 -0
  99. package/dist/hooks/useSpaces/geometry/splitLineAtOffset.js +12 -0
  100. package/dist/hooks/useSpaces/geometry/splitLineAtPoint.d.ts +3 -0
  101. package/dist/hooks/useSpaces/geometry/splitLineAtPoint.js +9 -0
  102. package/dist/hooks/useSpaces/geometry/splitLineAtPoints.d.ts +3 -0
  103. package/dist/hooks/useSpaces/geometry/splitLineAtPoints.js +28 -0
  104. package/dist/hooks/useSpaces/index.d.ts +95 -0
  105. package/dist/hooks/useSpaces/index.js +557 -0
  106. package/dist/hooks/useSpaces/themes/blueprint.d.ts +3 -0
  107. package/dist/hooks/useSpaces/themes/blueprint.js +96 -0
  108. package/dist/hooks/useSpaces/themes/default.d.ts +3 -0
  109. package/dist/hooks/useSpaces/themes/default.js +96 -0
  110. package/dist/hooks/{useRoomBuilder/themes.d.ts → useSpaces/themes/index.d.ts} +3 -4
  111. package/dist/hooks/useSpaces/themes/index.js +21 -0
  112. package/dist/hooks/useSpaces/themes/light.d.ts +3 -0
  113. package/dist/hooks/useSpaces/themes/light.js +96 -0
  114. package/dist/hooks/useSpaces/types.d.ts +378 -0
  115. package/dist/hooks/{useRoomBuilder → useSpaces}/types.js +19 -1
  116. package/dist/hooks/useSpaces/validators/areWallsDuplicated.d.ts +3 -0
  117. package/dist/hooks/useSpaces/validators/areWallsDuplicated.js +61 -0
  118. package/dist/hooks/useSpaces/validators/areWallsIntersecting.d.ts +3 -0
  119. package/dist/hooks/useSpaces/validators/areWallsIntersecting.js +42 -0
  120. package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.d.ts +3 -0
  121. package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.js +52 -0
  122. package/dist/hooks/useSpaces/validators/areWallsTooShort.d.ts +3 -0
  123. package/dist/hooks/useSpaces/validators/areWallsTooShort.js +37 -0
  124. package/dist/hooks/useSpaces/validators/index.d.ts +15 -0
  125. package/dist/hooks/useSpaces/validators/index.js +40 -0
  126. package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.d.ts +3 -0
  127. package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.js +31 -0
  128. package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.d.ts +3 -0
  129. package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.js +19 -0
  130. package/dist/hooks/useSpaces/validators/isLineTooShort.d.ts +3 -0
  131. package/dist/hooks/useSpaces/validators/isLineTooShort.js +26 -0
  132. package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.d.ts +4 -0
  133. package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.js +19 -0
  134. package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.d.ts +3 -0
  135. package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.js +19 -0
  136. package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.d.ts +3 -0
  137. package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.js +41 -0
  138. package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.d.ts +3 -0
  139. package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.js +54 -0
  140. package/dist/hooks/useSpaces/validators/isWallTooShort.d.ts +3 -0
  141. package/dist/hooks/useSpaces/validators/isWallTooShort.js +10 -0
  142. package/dist/hooks/{useRoomBuilder → useSpaces/validators}/messaging.js +1 -1
  143. package/dist/icons/Boundary.d.ts +3 -0
  144. package/dist/icons/Boundary.js +21 -0
  145. package/dist/icons/Draw.js +3 -3
  146. package/dist/icons/Player3D.d.ts +3 -0
  147. package/dist/icons/Player3D.js +21 -0
  148. package/dist/icons/RulerBlank.d.ts +3 -0
  149. package/dist/icons/RulerBlank.js +25 -0
  150. package/dist/icons/RulerDetailed.d.ts +3 -0
  151. package/dist/icons/RulerDetailed.js +27 -0
  152. package/dist/icons/Window.js +4 -4
  153. package/dist/icons/index.js +28 -0
  154. package/dist/icons/types.d.ts +1 -1
  155. package/dist/index.d.ts +17 -2
  156. package/dist/index.js +35 -5
  157. package/dist/store/attributes.d.ts +2 -1
  158. package/dist/store/index.d.ts +17 -31
  159. package/dist/store/index.js +3 -1
  160. package/dist/store/product.js +4 -7
  161. package/dist/store/spaces.d.ts +74 -0
  162. package/dist/store/spaces.js +354 -0
  163. package/dist/store/treble.d.ts +4 -2
  164. package/dist/store/treble.js +58 -50
  165. package/dist/store/wishlist.d.ts +20 -2
  166. package/dist/types.d.ts +14 -3
  167. package/package.json +2 -1
  168. package/dist/hooks/useRoomBuilder/RoomBuilderState.d.ts +0 -95
  169. package/dist/hooks/useRoomBuilder/RoomBuilderState.js +0 -1237
  170. package/dist/hooks/useRoomBuilder/constants.d.ts +0 -41
  171. package/dist/hooks/useRoomBuilder/constants.js +0 -48
  172. package/dist/hooks/useRoomBuilder/dataHandlers.d.ts +0 -18
  173. package/dist/hooks/useRoomBuilder/dataHandlers.js +0 -187
  174. package/dist/hooks/useRoomBuilder/draw.d.ts +0 -55
  175. package/dist/hooks/useRoomBuilder/draw.js +0 -573
  176. package/dist/hooks/useRoomBuilder/findLoops.d.ts +0 -5
  177. package/dist/hooks/useRoomBuilder/geometry.d.ts +0 -33
  178. package/dist/hooks/useRoomBuilder/geometry.js +0 -325
  179. package/dist/hooks/useRoomBuilder/index.d.ts +0 -40
  180. package/dist/hooks/useRoomBuilder/index.js +0 -303
  181. package/dist/hooks/useRoomBuilder/themes.js +0 -273
  182. package/dist/hooks/useRoomBuilder/types.d.ts +0 -238
  183. package/dist/hooks/useRoomBuilder/validators.d.ts +0 -36
  184. package/dist/hooks/useRoomBuilder/validators.js +0 -362
  185. package/dist/hooks/useSpaces/Canvas.d.ts +0 -37
  186. package/dist/hooks/useSpaces/Canvas.js +0 -199
  187. /package/dist/Treble/{snapshots.d.ts → snapshot.d.ts} +0 -0
  188. /package/dist/Treble/{snapshots.js → snapshot.js} +0 -0
  189. /package/dist/hooks/{useRoomBuilder → useSpaces/validators}/messaging.d.ts +0 -0
@@ -0,0 +1,79 @@
1
+ import { ICoordinate2D, ISpacesAttributes, IWallsValidationConfig } from './types';
2
+ export declare enum SpacesMetadata {
3
+ VALUE = "_tkSpace_value"
4
+ }
5
+ export declare enum WallAttributes {
6
+ START_X = "_tkSpace_startX",
7
+ START_Y = "_tkSpace_startY",
8
+ START_Z = "_tkSpace_startZ",
9
+ END_X = "_tkSpace_endX",
10
+ END_Y = "_tkSpace_endY",
11
+ END_Z = "_tkSpace_endZ",
12
+ CONNECTIONS = "_tkSpace_connections",
13
+ WALL_HEIGHT = "_tkSpace_wallHeight",
14
+ WALL_THICKNESS = "_tkSpace_wallThickness",
15
+ WALL_MODE = "_tkSpace_visibility"
16
+ }
17
+ export declare enum WallModes {
18
+ WALL = "true",
19
+ BOUNDARY = "false"
20
+ }
21
+ export declare const wallModeLabels: {
22
+ true: string;
23
+ false: string;
24
+ };
25
+ export declare enum WallMetadata {
26
+ MIN_LENGTH = "_tkSpace_minLength",
27
+ PADDING = "_tkSpace_padding"
28
+ }
29
+ export declare enum DoorAttributes {
30
+ ORIENTATION = "_tkSpace_doorOrientation",
31
+ OPENING_DIRECTION = "_tkSpace_doorOpeningDirection",
32
+ SHOW_SWING = "_tkSpace_doorShowSwing"
33
+ }
34
+ export declare enum DoorOrientations {
35
+ LEFT = "left",
36
+ RIGHT = "right"
37
+ }
38
+ export declare enum DoorOpeningDirections {
39
+ INSIDE = "inside",
40
+ OUTSIDE = "outside"
41
+ }
42
+ export declare enum DoorShowSwing {
43
+ SHOW = "true",
44
+ HIDE = "false"
45
+ }
46
+ export declare const ATTRIBUTE_NAME_DEFAULTS: ISpacesAttributes;
47
+ export declare const SCALE = 0.02;
48
+ export declare const SNAP_PROXIMITY = 16;
49
+ export declare const ZOOM_MAX = 100;
50
+ export declare const ZOOM_MIN = 20;
51
+ export declare const ZOOM_DEFAULT = 40;
52
+ export declare const ZOOM_SENSITIVITY = 0.8;
53
+ export declare const TRANSLATE_MAX: ICoordinate2D;
54
+ export declare const TRANSLATE_MIN: ICoordinate2D;
55
+ export declare const TRANSLATE_DEFAULT: ICoordinate2D;
56
+ export declare const GRID_SNAPPING_ENABLED = true;
57
+ export declare const ANGLE_SNAPPING_ENABLED = false;
58
+ export declare const GUIDE_SNAPPING_ENABLED = true;
59
+ export declare const UNIT_LABELS: {
60
+ feet: string;
61
+ meter: string;
62
+ inch: string;
63
+ cm: string;
64
+ };
65
+ export declare const UNIT_FACTORS: {
66
+ cm: number;
67
+ meter: number;
68
+ feet: number;
69
+ inch: number;
70
+ };
71
+ export declare const FEATURE_LABELS: {
72
+ windows: string;
73
+ doors: string;
74
+ openings: string;
75
+ };
76
+ export declare const VALIDATION_CONFIG_DEFAULT: IWallsValidationConfig;
77
+ export declare const FEATURE_LENGTH = 1;
78
+ export declare const UI_ANCHOR_DISTANCE = -60;
79
+ export declare const WALL_SNAP_DISTANCE = 12;
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ var _a, _b, _c, _d, _e;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.WALL_SNAP_DISTANCE = exports.UI_ANCHOR_DISTANCE = exports.FEATURE_LENGTH = exports.VALIDATION_CONFIG_DEFAULT = exports.FEATURE_LABELS = exports.UNIT_FACTORS = exports.UNIT_LABELS = exports.GUIDE_SNAPPING_ENABLED = exports.ANGLE_SNAPPING_ENABLED = exports.GRID_SNAPPING_ENABLED = exports.TRANSLATE_DEFAULT = exports.TRANSLATE_MIN = exports.TRANSLATE_MAX = exports.ZOOM_SENSITIVITY = exports.ZOOM_DEFAULT = exports.ZOOM_MIN = exports.ZOOM_MAX = exports.SNAP_PROXIMITY = exports.SCALE = exports.ATTRIBUTE_NAME_DEFAULTS = exports.DoorShowSwing = exports.DoorOpeningDirections = exports.DoorOrientations = exports.DoorAttributes = exports.WallMetadata = exports.wallModeLabels = exports.WallModes = exports.WallAttributes = exports.SpacesMetadata = void 0;
5
+ var types_1 = require("./types");
6
+ var SpacesAttributes;
7
+ (function (SpacesAttributes) {
8
+ SpacesAttributes["WALLS"] = "_tkSpace_walls";
9
+ SpacesAttributes["WINDOWS"] = "_tkSpace_windows";
10
+ SpacesAttributes["DOORS"] = "_tkSpace_doors";
11
+ SpacesAttributes["OPENINGS"] = "_tkSpace_openings";
12
+ })(SpacesAttributes || (SpacesAttributes = {}));
13
+ var SpacesMetadata;
14
+ (function (SpacesMetadata) {
15
+ SpacesMetadata["VALUE"] = "_tkSpace_value";
16
+ })(SpacesMetadata = exports.SpacesMetadata || (exports.SpacesMetadata = {}));
17
+ var WallAttributes;
18
+ (function (WallAttributes) {
19
+ WallAttributes["START_X"] = "_tkSpace_startX";
20
+ WallAttributes["START_Y"] = "_tkSpace_startY";
21
+ WallAttributes["START_Z"] = "_tkSpace_startZ";
22
+ WallAttributes["END_X"] = "_tkSpace_endX";
23
+ WallAttributes["END_Y"] = "_tkSpace_endY";
24
+ WallAttributes["END_Z"] = "_tkSpace_endZ";
25
+ WallAttributes["CONNECTIONS"] = "_tkSpace_connections";
26
+ WallAttributes["WALL_HEIGHT"] = "_tkSpace_wallHeight";
27
+ WallAttributes["WALL_THICKNESS"] = "_tkSpace_wallThickness";
28
+ WallAttributes["WALL_MODE"] = "_tkSpace_visibility";
29
+ })(WallAttributes = exports.WallAttributes || (exports.WallAttributes = {}));
30
+ var WallModes;
31
+ (function (WallModes) {
32
+ WallModes["WALL"] = "true";
33
+ WallModes["BOUNDARY"] = "false";
34
+ })(WallModes = exports.WallModes || (exports.WallModes = {}));
35
+ exports.wallModeLabels = (_a = {},
36
+ _a[WallModes.WALL] = 'Wall',
37
+ _a[WallModes.BOUNDARY] = 'Boundary',
38
+ _a);
39
+ var WallMetadata;
40
+ (function (WallMetadata) {
41
+ WallMetadata["MIN_LENGTH"] = "_tkSpace_minLength";
42
+ WallMetadata["PADDING"] = "_tkSpace_padding";
43
+ })(WallMetadata = exports.WallMetadata || (exports.WallMetadata = {}));
44
+ var FeatureAttributes;
45
+ (function (FeatureAttributes) {
46
+ FeatureAttributes["POSITION_X"] = "_tkSpace_offsetX";
47
+ FeatureAttributes["POSITION_Y"] = "_tkSpace_offsetY";
48
+ FeatureAttributes["CONNECTED_TO"] = "_tkSpace_connectedTo";
49
+ FeatureAttributes["FEATURE_HEIGHT"] = "_tkSpace_featureHeight";
50
+ FeatureAttributes["FEATURE_LENGTH"] = "_tkSpace_featureWidth";
51
+ })(FeatureAttributes || (FeatureAttributes = {}));
52
+ var DoorAttributes;
53
+ (function (DoorAttributes) {
54
+ DoorAttributes["ORIENTATION"] = "_tkSpace_doorOrientation";
55
+ DoorAttributes["OPENING_DIRECTION"] = "_tkSpace_doorOpeningDirection";
56
+ DoorAttributes["SHOW_SWING"] = "_tkSpace_doorShowSwing";
57
+ })(DoorAttributes = exports.DoorAttributes || (exports.DoorAttributes = {}));
58
+ var DoorOrientations;
59
+ (function (DoorOrientations) {
60
+ DoorOrientations["LEFT"] = "left";
61
+ DoorOrientations["RIGHT"] = "right";
62
+ })(DoorOrientations = exports.DoorOrientations || (exports.DoorOrientations = {}));
63
+ var DoorOpeningDirections;
64
+ (function (DoorOpeningDirections) {
65
+ DoorOpeningDirections["INSIDE"] = "inside";
66
+ DoorOpeningDirections["OUTSIDE"] = "outside";
67
+ })(DoorOpeningDirections = exports.DoorOpeningDirections || (exports.DoorOpeningDirections = {}));
68
+ var DoorShowSwing;
69
+ (function (DoorShowSwing) {
70
+ DoorShowSwing["SHOW"] = "true";
71
+ DoorShowSwing["HIDE"] = "false";
72
+ })(DoorShowSwing = exports.DoorShowSwing || (exports.DoorShowSwing = {}));
73
+ exports.ATTRIBUTE_NAME_DEFAULTS = (_b = {},
74
+ _b[types_1.IElements.WALL] = SpacesAttributes.WALLS,
75
+ _b[types_1.IElements.WINDOW] = SpacesAttributes.WINDOWS,
76
+ _b[types_1.IElements.OPENING] = SpacesAttributes.OPENINGS,
77
+ _b[types_1.IElements.DOOR] = SpacesAttributes.DOORS,
78
+ _b.featurePositionX = FeatureAttributes.POSITION_X,
79
+ _b.featurePositionY = FeatureAttributes.POSITION_Y,
80
+ _b.featureConnectedTo = FeatureAttributes.CONNECTED_TO,
81
+ _b.featureHeight = FeatureAttributes.FEATURE_HEIGHT,
82
+ _b.featureLength = FeatureAttributes.FEATURE_LENGTH,
83
+ _b.wallStartX = WallAttributes.START_X,
84
+ _b.wallStartY = WallAttributes.START_Y,
85
+ _b.wallStartZ = WallAttributes.START_Z,
86
+ _b.wallEndX = WallAttributes.END_X,
87
+ _b.wallEndY = WallAttributes.END_Y,
88
+ _b.wallEndZ = WallAttributes.END_Z,
89
+ _b.wallConnections = WallAttributes.CONNECTIONS,
90
+ _b.wallMode = WallAttributes.WALL_MODE,
91
+ _b.doorOrientation = DoorAttributes.ORIENTATION,
92
+ _b.doorOpeningDirection = DoorAttributes.OPENING_DIRECTION,
93
+ _b.doorShowSwing = DoorAttributes.SHOW_SWING,
94
+ _b);
95
+ exports.SCALE = 0.02;
96
+ exports.SNAP_PROXIMITY = 16;
97
+ exports.ZOOM_MAX = 100;
98
+ exports.ZOOM_MIN = 20;
99
+ exports.ZOOM_DEFAULT = 40;
100
+ exports.ZOOM_SENSITIVITY = 0.8;
101
+ exports.TRANSLATE_MAX = [-400, -400];
102
+ exports.TRANSLATE_MIN = [400, 400];
103
+ exports.TRANSLATE_DEFAULT = [-200, -200];
104
+ exports.GRID_SNAPPING_ENABLED = true;
105
+ exports.ANGLE_SNAPPING_ENABLED = false;
106
+ exports.GUIDE_SNAPPING_ENABLED = true;
107
+ exports.UNIT_LABELS = (_c = {},
108
+ _c[types_1.IUnits.FEET] = 'ft',
109
+ _c[types_1.IUnits.METER] = 'm',
110
+ _c[types_1.IUnits.INCH] = 'in',
111
+ _c[types_1.IUnits.CM] = 'cm',
112
+ _c);
113
+ exports.UNIT_FACTORS = (_d = {},
114
+ _d[types_1.IUnits.CM] = 100,
115
+ _d[types_1.IUnits.METER] = 1,
116
+ _d[types_1.IUnits.FEET] = 3.28084,
117
+ _d[types_1.IUnits.INCH] = 39.37,
118
+ _d);
119
+ exports.FEATURE_LABELS = (_e = {},
120
+ _e[types_1.IElements.WINDOW] = 'Window',
121
+ _e[types_1.IElements.DOOR] = 'Door',
122
+ _e[types_1.IElements.OPENING] = 'Opening',
123
+ _e);
124
+ exports.VALIDATION_CONFIG_DEFAULT = {
125
+ padding: 0.2,
126
+ minLength: 0.5,
127
+ };
128
+ exports.FEATURE_LENGTH = 1;
129
+ exports.UI_ANCHOR_DISTANCE = -60;
130
+ exports.WALL_SNAP_DISTANCE = 12;
@@ -0,0 +1,38 @@
1
+ import type { IWalls, ISpacesStateProps, IVerticesState, IFeatures, ISpacesAttributes, IWallsValidationConfig, IAttributeDefaults } from './types';
2
+ import { IUnits } from './types';
3
+ import { WallModes } from './constants';
4
+ import type { IConfiguration, IHydratedAttribute, IThreekitConfigurator } from '../../types';
5
+ export declare function prepAttributesIncoming(attributes: Record<string, IHydratedAttribute>, config: ISpacesStateProps, attributeDefaults: IAttributeDefaults & {
6
+ wallMode: WallModes;
7
+ }): {
8
+ validationConfig: IWallsValidationConfig;
9
+ features: {};
10
+ walls: IWalls;
11
+ vertex: IVerticesState;
12
+ };
13
+ export declare function prepAttributesOutgoing(walls: IWalls, features: IFeatures, config: ISpacesStateProps): {
14
+ [x: string]: import("../../types").IConfigurationAttribute | {
15
+ assetId: string;
16
+ configuration: IConfiguration;
17
+ }[];
18
+ };
19
+ export declare function convertLengthUnit(value: number, from: IUnits, to: IUnits): number;
20
+ export declare function convertAreaUnit(value: number, from: IUnits, to: IUnits): number;
21
+ export declare function prepLengthForUser(value: number, unit: IUnits): string;
22
+ export declare function prepAreaForUser(value: number, unit: IUnits): string;
23
+ export declare function getAttributeData(configurator: IThreekitConfigurator, attributeNames: ISpacesAttributes): Promise<{
24
+ defaults: {
25
+ walls: string;
26
+ doors: string;
27
+ windows: string;
28
+ openings: string;
29
+ doorShowSwing: string;
30
+ doorOrientation: string;
31
+ doorOpeningDirection: string;
32
+ };
33
+ wallModes: {
34
+ options: WallModes[];
35
+ assetIds: Record<WallModes, string>;
36
+ value: WallModes;
37
+ };
38
+ }>;
@@ -0,0 +1,407 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.getAttributeData = exports.prepAreaForUser = exports.prepLengthForUser = exports.convertAreaUnit = exports.convertLengthUnit = exports.prepAttributesOutgoing = exports.prepAttributesIncoming = void 0;
51
+ var types_1 = require("./types");
52
+ var constants_1 = require("./constants");
53
+ var geometry_1 = require("./geometry");
54
+ function filterRestConfiguration(configuration, attributeNames) {
55
+ var attributes = __assign({}, attributeNames);
56
+ delete attributes.wallMode;
57
+ delete attributes.doorShowSwing;
58
+ delete attributes.doorOrientation;
59
+ delete attributes.doorOpeningDirection;
60
+ var keysToFilter = new Set(Object.values(attributes));
61
+ var filteredConfiguration = Object.entries(configuration).reduce(function (output, _a) {
62
+ var _b;
63
+ var key = _a[0], value = _a[1];
64
+ if (keysToFilter.has(key))
65
+ return output;
66
+ return Object.assign(output, (_b = {}, _b[key] = value, _b));
67
+ }, {});
68
+ return filteredConfiguration;
69
+ }
70
+ function prepConnectionOutgoing(connection) {
71
+ return "".concat(connection[0], ".").concat(connection[1]);
72
+ }
73
+ function prepConnectionIncoming(connection) {
74
+ var _a = connection.split('.'), attributeName = _a[0], indexStr = _a[1];
75
+ return [attributeName, parseInt(indexStr)];
76
+ }
77
+ function prepWallsAndVerticesIncoming(wallsAttribute, config, attributeDefaults) {
78
+ var _a;
79
+ var walls = [];
80
+ var vertices = {};
81
+ var attributeName = config.attributes;
82
+ ((wallsAttribute === null || wallsAttribute === void 0 ? void 0 : wallsAttribute.value) || []).forEach(function (_a, i) {
83
+ var _b, _c;
84
+ var assetId = _a.assetId, configuration = _a.configuration;
85
+ var point1 = [
86
+ (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.wallStartX]) / config.config.scale,
87
+ (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.wallStartZ]) / config.config.scale,
88
+ ];
89
+ var point2 = [
90
+ (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.wallEndX]) / config.config.scale,
91
+ (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.wallEndZ]) / config.config.scale,
92
+ ];
93
+ var point1Str = JSON.stringify(point1);
94
+ var point2Str = JSON.stringify(point2);
95
+ if (vertices[point1Str])
96
+ vertices[point1Str].push([i, 0]);
97
+ else
98
+ vertices[point1Str] = [[i, 0]];
99
+ if (vertices[point2Str])
100
+ vertices[point2Str].push([i, 1]);
101
+ else
102
+ vertices[point2Str] = [[i, 1]];
103
+ var connections = [];
104
+ var modeValue = (_c = (_b = configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.WallAttributes.WALL_MODE]) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c[constants_1.SpacesMetadata.VALUE];
105
+ var mode = modeValue !== null && modeValue !== void 0 ? modeValue : attributeDefaults.wallMode;
106
+ walls.push({
107
+ assetId: assetId,
108
+ mode: mode,
109
+ line: [point1, point2],
110
+ path: (0, geometry_1.addThicknessToLine)([point1, point2], config.config.styles.wall.thickness),
111
+ connections: connections,
112
+ restConfiguration: JSON.stringify(filterRestConfiguration(configuration, config.attributes)),
113
+ });
114
+ });
115
+ return _a = {}, _a[types_1.IElements.WALL] = walls, _a[types_1.IElements.VERTEX] = vertices, _a;
116
+ }
117
+ function getWallsVaidationConfig(wallsAttribute, config) {
118
+ var _a, _b;
119
+ var metadata = (wallsAttribute === null || wallsAttribute === void 0 ? void 0 : wallsAttribute.values[0].metadata) || {};
120
+ var validation = {
121
+ minLength: ((_a = metadata[constants_1.WallMetadata.MIN_LENGTH]) !== null && _a !== void 0 ? _a : constants_1.VALIDATION_CONFIG_DEFAULT.minLength) / config.config.scale,
122
+ padding: ((_b = metadata[constants_1.WallMetadata.PADDING]) !== null && _b !== void 0 ? _b : constants_1.VALIDATION_CONFIG_DEFAULT.padding) / config.config.scale,
123
+ };
124
+ return validation;
125
+ }
126
+ function prepFeatureIncoming(type, walls, featureAttribute, config, attributeDefaults) {
127
+ var _a;
128
+ var attributeName = config.attributes;
129
+ var feature = [];
130
+ (_a = featureAttribute === null || featureAttribute === void 0 ? void 0 : featureAttribute.value) === null || _a === void 0 ? void 0 : _a.forEach(function (_a) {
131
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k;
132
+ var assetId = _a.assetId, configuration = _a.configuration;
133
+ var offset = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featurePositionX]) / config.config.scale;
134
+ var length = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featureLength]) / config.config.scale;
135
+ var height = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featureHeight]) / config.config.scale;
136
+ var altitude = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featurePositionY]) / config.config.scale;
137
+ var connectedTo = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featureConnectedTo]) || '';
138
+ var wallIndex = prepConnectionIncoming(connectedTo)[1];
139
+ var featureLine = (0, geometry_1.getLineAtOffsetOnLineSegment)(walls[wallIndex].line, offset, length);
140
+ var element = {
141
+ assetId: assetId,
142
+ offset: offset,
143
+ length: length,
144
+ height: height,
145
+ altitude: altitude,
146
+ connectedTo: [types_1.IElements.WALL, wallIndex],
147
+ path: (0, geometry_1.addThicknessToLine)(featureLine, config.config.styles.feature.thickness),
148
+ restConfiguration: JSON.stringify(filterRestConfiguration(configuration, config.attributes)),
149
+ };
150
+ if (type === types_1.IElements.DOOR) {
151
+ var doorShowSwing = (_d = (_c = (_b = configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.doorShowSwing]) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c[constants_1.SpacesMetadata.VALUE]) !== null && _d !== void 0 ? _d : attributeDefaults.doorShowSwing;
152
+ var doorOrientation = (_g = (_f = (_e = configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.doorOrientation]) === null || _e === void 0 ? void 0 : _e.metadata) === null || _f === void 0 ? void 0 : _f[constants_1.SpacesMetadata.VALUE]) !== null && _g !== void 0 ? _g : attributeDefaults.doorOrientation;
153
+ var doorOpeningDirection = (_k = (_j = (_h = configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.doorOpeningDirection]) === null || _h === void 0 ? void 0 : _h.metadata) === null || _j === void 0 ? void 0 : _j[constants_1.SpacesMetadata.VALUE]) !== null && _k !== void 0 ? _k : attributeDefaults.doorOpeningDirection;
154
+ Object.assign(element, {
155
+ showSwing: doorShowSwing,
156
+ orientation: doorOrientation,
157
+ openingDirection: doorOpeningDirection,
158
+ });
159
+ }
160
+ feature.push(element);
161
+ });
162
+ return feature;
163
+ }
164
+ function prepAttributesIncoming(attributes, config, attributeDefaults) {
165
+ var _a;
166
+ var wallsAttribute = attributes[config.attributes[types_1.IElements.WALL]];
167
+ var wallsAndVertices = prepWallsAndVerticesIncoming(wallsAttribute, config, attributeDefaults);
168
+ var wallsValidation = getWallsVaidationConfig(wallsAttribute, config);
169
+ var featuresList = [
170
+ types_1.IElements.WINDOW,
171
+ types_1.IElements.DOOR,
172
+ types_1.IElements.OPENING,
173
+ ];
174
+ var featuresData = featuresList.reduce(function (output, type) {
175
+ output[type] = prepFeatureIncoming(type, wallsAndVertices[types_1.IElements.WALL], attributes[config.attributes[type]], config, attributeDefaults);
176
+ return output;
177
+ }, {});
178
+ return __assign(__assign({}, wallsAndVertices), (_a = { validationConfig: wallsValidation }, _a[types_1.IElements.FEATURE] = featuresData, _a));
179
+ }
180
+ exports.prepAttributesIncoming = prepAttributesIncoming;
181
+ function prepFeaturesOutgoing(features, config) {
182
+ var attributeName = config.attributes;
183
+ return features.map(function (feature) {
184
+ var _a, _b;
185
+ var assetId = feature.assetId, offset = feature.offset, length = feature.length, height = feature.height, altitude = feature.altitude, restConfiguration = feature.restConfiguration;
186
+ var connectedTo = prepConnectionOutgoing([
187
+ config.attributes[feature.connectedTo[0]],
188
+ feature.connectedTo[1],
189
+ ]);
190
+ var configurationToScale = (_a = {},
191
+ _a[attributeName.featureLength] = length,
192
+ _a[attributeName.featurePositionX] = offset,
193
+ _a);
194
+ if (altitude)
195
+ configurationToScale[attributeName.featurePositionY] = altitude;
196
+ if (height)
197
+ configurationToScale[attributeName.featureHeight] = height;
198
+ var configuration = Object.entries(configurationToScale).reduce(function (output, _a) {
199
+ var _b;
200
+ var key = _a[0], value = _a[1];
201
+ return Object.assign(output, (_b = {},
202
+ _b[key] = value ? value * config.config.scale : value,
203
+ _b));
204
+ }, __assign((_b = {}, _b[attributeName.featureConnectedTo] = connectedTo, _b), JSON.parse(restConfiguration)));
205
+ return {
206
+ assetId: assetId,
207
+ configuration: configuration,
208
+ };
209
+ });
210
+ }
211
+ function prepWallsOutgoing(walls, config) {
212
+ var attributeName = config.attributes;
213
+ return walls.map(function (wall) {
214
+ var _a, _b;
215
+ var line = wall.line, restConfiguration = wall.restConfiguration;
216
+ var connections = wall.connections.map(function (connection) {
217
+ var attributeName = config.attributes[connection[0]];
218
+ if (!attributeName)
219
+ return;
220
+ return prepConnectionOutgoing([attributeName, connection[1]]);
221
+ });
222
+ var _c = line.flat(), x1 = _c[0], y1 = _c[1], x2 = _c[2], y2 = _c[3];
223
+ var configuration = Object.entries((_a = {},
224
+ _a[attributeName.wallStartX] = x1,
225
+ _a[attributeName.wallStartZ] = y1,
226
+ _a[attributeName.wallEndX] = x2,
227
+ _a[attributeName.wallEndZ] = y2,
228
+ _a)).reduce(function (output, _a) {
229
+ var _b;
230
+ var key = _a[0], value = _a[1];
231
+ return Object.assign(output, (_b = {},
232
+ _b[key] = value ? value * config.config.scale : value,
233
+ _b));
234
+ }, __assign((_b = {}, _b[attributeName.wallConnections] = JSON.stringify(connections), _b), JSON.parse(restConfiguration)));
235
+ return {
236
+ assetId: wall.assetId,
237
+ configuration: configuration,
238
+ };
239
+ });
240
+ }
241
+ function prepAttributesOutgoing(walls, features, config) {
242
+ var _a;
243
+ var wallsAttribute = prepWallsOutgoing(walls, config);
244
+ var featuresAttributes = Object.entries(features).reduce(function (output, _a) {
245
+ var type = _a[0], features = _a[1];
246
+ var attributeName = config.attributes[type];
247
+ if (!attributeName)
248
+ return output;
249
+ output[attributeName] = prepFeaturesOutgoing(features, config);
250
+ return output;
251
+ }, {});
252
+ return __assign(__assign({}, featuresAttributes), (_a = {}, _a[config.attributes[types_1.IElements.WALL]] = wallsAttribute, _a));
253
+ }
254
+ exports.prepAttributesOutgoing = prepAttributesOutgoing;
255
+ function convertLengthUnit(value, from, to) {
256
+ return (value / constants_1.UNIT_FACTORS[from]) * constants_1.UNIT_FACTORS[to];
257
+ }
258
+ exports.convertLengthUnit = convertLengthUnit;
259
+ function convertAreaUnit(value, from, to) {
260
+ return (value / constants_1.UNIT_FACTORS[from]) * Math.pow(constants_1.UNIT_FACTORS[to], 2);
261
+ }
262
+ exports.convertAreaUnit = convertAreaUnit;
263
+ function prepLengthForUser(value, unit) {
264
+ if (unit === types_1.IUnits.FEET) {
265
+ var feet = Math.floor(value);
266
+ var inches = 12 * (value % 1);
267
+ return "".concat(feet).concat(constants_1.UNIT_LABELS[types_1.IUnits.FEET], " ").concat(inches.toFixed(1)).concat(constants_1.UNIT_LABELS[types_1.IUnits.INCH]);
268
+ }
269
+ return "".concat(value.toFixed(2), " ").concat(constants_1.UNIT_LABELS[unit]);
270
+ }
271
+ exports.prepLengthForUser = prepLengthForUser;
272
+ function prepAreaForUser(value, unit) {
273
+ return "".concat(value.toFixed(2), " sq-").concat(constants_1.UNIT_LABELS[unit]);
274
+ }
275
+ exports.prepAreaForUser = prepAreaForUser;
276
+ function getAttributeData(configurator, attributeNames) {
277
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
278
+ return __awaiter(this, void 0, void 0, function () {
279
+ var attributes, wallAssetId, doorAssetId, windowAssetId, openingAssetId, i, attr, wallConfigurator, doorConfigurator, wallModeAttr, doorOrientationAttr, doorOpeningDirectionAttr, doorShowSwingAttr, doorAttributes, i, attr, options, optionsMap, wallModeOptions, wallModes, defaults;
280
+ var _p, _q, _r, _s, _t;
281
+ return __generator(this, function (_u) {
282
+ switch (_u.label) {
283
+ case 0:
284
+ attributes = configurator.getDisplayAttributes();
285
+ wallAssetId = undefined;
286
+ doorAssetId = undefined;
287
+ windowAssetId = undefined;
288
+ openingAssetId = undefined;
289
+ for (i = 0; i < attributes.length &&
290
+ (!wallAssetId || !doorAssetId || !windowAssetId || !openingAssetId); i++) {
291
+ attr = attributes[i];
292
+ switch (attr.name) {
293
+ case attributeNames[types_1.IElements.WALL]:
294
+ wallAssetId = attr.values[0].assetId;
295
+ break;
296
+ case attributeNames[types_1.IElements.DOOR]:
297
+ doorAssetId = attr.values[0].assetId;
298
+ break;
299
+ case attributeNames[types_1.IElements.WINDOW]:
300
+ windowAssetId = attr.values[0].assetId;
301
+ break;
302
+ case attributeNames[types_1.IElements.OPENING]:
303
+ openingAssetId = attr.values[0].assetId;
304
+ break;
305
+ }
306
+ }
307
+ if (!wallAssetId || !doorAssetId || !windowAssetId || !openingAssetId)
308
+ throw new Error('Missing assetId: ' +
309
+ JSON.stringify({
310
+ wallAssetId: wallAssetId,
311
+ doorAssetId: doorAssetId,
312
+ windowAssetId: windowAssetId,
313
+ openingAssetId: openingAssetId,
314
+ }));
315
+ return [4, configurator.setConfiguration((_p = {},
316
+ _p[attributeNames[types_1.IElements.WALL]] = { assetId: wallAssetId },
317
+ _p[attributeNames[types_1.IElements.DOOR]] = { assetId: doorAssetId },
318
+ _p))];
319
+ case 1:
320
+ _u.sent();
321
+ wallConfigurator = configurator.getNestedConfigurator(attributeNames[types_1.IElements.WALL], 0);
322
+ doorConfigurator = configurator.getNestedConfigurator(attributeNames[types_1.IElements.DOOR], 0);
323
+ wallModeAttr = wallConfigurator === null || wallConfigurator === void 0 ? void 0 : wallConfigurator.getDisplayAttributes().find(function (attr) { return attr.name === attributeNames.wallMode; });
324
+ doorOrientationAttr = undefined;
325
+ doorOpeningDirectionAttr = undefined;
326
+ doorShowSwingAttr = undefined;
327
+ doorAttributes = (_a = doorConfigurator === null || doorConfigurator === void 0 ? void 0 : doorConfigurator.getDisplayAttributes()) !== null && _a !== void 0 ? _a : [];
328
+ for (i = 0; i < doorAttributes.length &&
329
+ (!doorOrientationAttr || !doorOpeningDirectionAttr || !doorShowSwingAttr); i++) {
330
+ attr = doorAttributes[i];
331
+ switch (doorAttributes[i].name) {
332
+ case attributeNames.doorOrientation:
333
+ doorOrientationAttr = attr;
334
+ break;
335
+ case attributeNames.doorOpeningDirection:
336
+ doorOpeningDirectionAttr = attr;
337
+ break;
338
+ case attributeNames.doorShowSwing:
339
+ doorShowSwingAttr = attr;
340
+ break;
341
+ }
342
+ }
343
+ options = {
344
+ doorShowSwing: (_q = {},
345
+ _q[constants_1.DoorShowSwing.SHOW] = (_b = doorShowSwingAttr === null || doorShowSwingAttr === void 0 ? void 0 : doorShowSwingAttr.values.find(function (val) { return val.metadata[constants_1.SpacesMetadata.VALUE] === constants_1.DoorShowSwing.SHOW; })) === null || _b === void 0 ? void 0 : _b.assetId,
346
+ _q[constants_1.DoorShowSwing.HIDE] = (_c = doorShowSwingAttr === null || doorShowSwingAttr === void 0 ? void 0 : doorShowSwingAttr.values.find(function (val) { return val.metadata[constants_1.SpacesMetadata.VALUE] === constants_1.DoorShowSwing.HIDE; })) === null || _c === void 0 ? void 0 : _c.assetId,
347
+ _q),
348
+ doorOrientation: (_r = {},
349
+ _r[constants_1.DoorOrientations.LEFT] = (_d = doorOrientationAttr === null || doorOrientationAttr === void 0 ? void 0 : doorOrientationAttr.values.find(function (val) { return val.metadata[constants_1.SpacesMetadata.VALUE] === constants_1.DoorOrientations.LEFT; })) === null || _d === void 0 ? void 0 : _d.assetId,
350
+ _r[constants_1.DoorOrientations.RIGHT] = (_e = doorOrientationAttr === null || doorOrientationAttr === void 0 ? void 0 : doorOrientationAttr.values.find(function (val) { return val.metadata[constants_1.SpacesMetadata.VALUE] === constants_1.DoorOrientations.RIGHT; })) === null || _e === void 0 ? void 0 : _e.assetId,
351
+ _r),
352
+ doorOpeningDirection: (_s = {},
353
+ _s[constants_1.DoorOpeningDirections.INSIDE] = (_f = doorOpeningDirectionAttr === null || doorOpeningDirectionAttr === void 0 ? void 0 : doorOpeningDirectionAttr.values.find(function (val) {
354
+ return val.metadata[constants_1.SpacesMetadata.VALUE] === constants_1.DoorOpeningDirections.INSIDE;
355
+ })) === null || _f === void 0 ? void 0 : _f.assetId,
356
+ _s[constants_1.DoorOpeningDirections.OUTSIDE] = (_g = doorOpeningDirectionAttr === null || doorOpeningDirectionAttr === void 0 ? void 0 : doorOpeningDirectionAttr.values.find(function (val) {
357
+ return val.metadata[constants_1.SpacesMetadata.VALUE] === constants_1.DoorOpeningDirections.OUTSIDE;
358
+ })) === null || _g === void 0 ? void 0 : _g.assetId,
359
+ _s),
360
+ };
361
+ optionsMap = Object.entries(options).reduce(function (output, _a) {
362
+ var _b;
363
+ var attr = _a[0], valuesObj = _a[1];
364
+ return Object.assign(output, (_b = {},
365
+ _b[attr] = Object.entries(valuesObj).reduce(function (result, _a) {
366
+ var _b;
367
+ var val = _a[0], key = _a[1];
368
+ return Object.assign(result, (_b = {}, _b[key] = val, _b));
369
+ }, {}),
370
+ _b));
371
+ }, {});
372
+ wallModeOptions = [
373
+ {
374
+ value: constants_1.WallModes.WALL,
375
+ assetId: (_h = wallModeAttr === null || wallModeAttr === void 0 ? void 0 : wallModeAttr.values.find(function (val) { return val.metadata[constants_1.SpacesMetadata.VALUE] === constants_1.WallModes.WALL; })) === null || _h === void 0 ? void 0 : _h.assetId,
376
+ },
377
+ {
378
+ value: constants_1.WallModes.BOUNDARY,
379
+ assetId: (_j = wallModeAttr === null || wallModeAttr === void 0 ? void 0 : wallModeAttr.values.find(function (val) { return val.metadata[constants_1.SpacesMetadata.VALUE] === constants_1.WallModes.BOUNDARY; })) === null || _j === void 0 ? void 0 : _j.assetId,
380
+ },
381
+ ];
382
+ wallModes = {
383
+ options: wallModeOptions.map(function (_a) {
384
+ var value = _a.value;
385
+ return value;
386
+ }),
387
+ assetIds: wallModeOptions.reduce(function (output, mode) {
388
+ var _a;
389
+ return Object.assign(output, (_a = {}, _a[mode.value] = mode.assetId, _a));
390
+ }, {}),
391
+ value: (_k = wallModeOptions.find(function (mode) { return mode.assetId === (wallModeAttr === null || wallModeAttr === void 0 ? void 0 : wallModeAttr.defaultValue.assetId); })) === null || _k === void 0 ? void 0 : _k.value,
392
+ };
393
+ defaults = (_t = {},
394
+ _t[types_1.IElements.WALL] = wallAssetId,
395
+ _t[types_1.IElements.DOOR] = doorAssetId,
396
+ _t[types_1.IElements.WINDOW] = windowAssetId,
397
+ _t[types_1.IElements.OPENING] = openingAssetId,
398
+ _t.doorShowSwing = optionsMap.doorShowSwing[(_l = doorShowSwingAttr === null || doorShowSwingAttr === void 0 ? void 0 : doorShowSwingAttr.values.find(function (val) { return val.assetId === (doorShowSwingAttr === null || doorShowSwingAttr === void 0 ? void 0 : doorShowSwingAttr.defaultValue.assetId); })) === null || _l === void 0 ? void 0 : _l.assetId],
399
+ _t.doorOrientation = optionsMap.doorOrientation[(_m = doorOrientationAttr === null || doorOrientationAttr === void 0 ? void 0 : doorOrientationAttr.values.find(function (val) { return val.assetId === (doorOrientationAttr === null || doorOrientationAttr === void 0 ? void 0 : doorOrientationAttr.defaultValue.assetId); })) === null || _m === void 0 ? void 0 : _m.assetId],
400
+ _t.doorOpeningDirection = optionsMap.doorOpeningDirection[(_o = doorOpeningDirectionAttr === null || doorOpeningDirectionAttr === void 0 ? void 0 : doorOpeningDirectionAttr.values.find(function (val) { return val.assetId === (doorOpeningDirectionAttr === null || doorOpeningDirectionAttr === void 0 ? void 0 : doorOpeningDirectionAttr.defaultValue.assetId); })) === null || _o === void 0 ? void 0 : _o.assetId],
401
+ _t);
402
+ return [2, { defaults: defaults, wallModes: wallModes }];
403
+ }
404
+ });
405
+ });
406
+ }
407
+ exports.getAttributeData = getAttributeData;
@@ -0,0 +1,2 @@
1
+ declare function clearCanvas(canvas: HTMLCanvasElement): void;
2
+ export default clearCanvas;