kitchen-simulator 4.1.7-react-18 → 4.2.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 (206) hide show
  1. package/README.md +3 -0
  2. package/es/AppContext.js +1 -1
  3. package/es/LiteKitchenConfigurator.js +171 -111
  4. package/es/LiteRenderer.js +161 -129
  5. package/es/actions/export.js +25 -12
  6. package/es/actions/project-actions.js +2 -1
  7. package/es/assets/gltf/door_sliding.bin +0 -0
  8. package/es/assets/img/svg/bottombar/elevation.svg +12 -5
  9. package/es/catalog/catalog.js +21 -5
  10. package/es/catalog/factories/area-factory-3d.js +17 -17
  11. package/es/catalog/factories/wall-factory.js +1 -1
  12. package/es/catalog/holes/window-clear/planner-element.js +2 -2
  13. package/es/catalog/properties/export.js +21 -0
  14. package/es/catalog/properties/property-checkbox.js +68 -0
  15. package/es/catalog/properties/property-color.js +39 -0
  16. package/es/catalog/properties/property-enum.js +50 -0
  17. package/es/catalog/properties/property-hidden.js +19 -0
  18. package/es/catalog/properties/property-lenght-measure.js +100 -0
  19. package/es/catalog/properties/property-length-measure.js +84 -0
  20. package/es/catalog/properties/property-length-measure_hole.js +100 -0
  21. package/es/catalog/properties/property-number.js +48 -0
  22. package/es/catalog/properties/property-read-only.js +26 -0
  23. package/es/catalog/properties/property-string.js +48 -0
  24. package/es/catalog/properties/property-toggle.js +39 -0
  25. package/es/catalog/properties/shared-property-style.js +14 -0
  26. package/es/catalog/utils/exporter.js +24 -11
  27. package/es/catalog/utils/item-loader.js +224 -220
  28. package/es/class/hole.js +0 -2
  29. package/es/class/item.js +92 -70
  30. package/es/class/layer.js +1 -1
  31. package/es/class/line.js +4 -8
  32. package/es/class/project.js +96 -81
  33. package/es/components/content.js +10 -93
  34. package/es/components/export.js +4 -6
  35. package/es/components/style/button.js +106 -0
  36. package/es/components/style/cancel-button.js +21 -0
  37. package/es/components/style/content-container.js +30 -0
  38. package/es/components/style/content-title.js +25 -0
  39. package/es/components/style/delete-button.js +24 -0
  40. package/es/components/style/export.js +28 -2
  41. package/es/components/style/form-block.js +20 -0
  42. package/es/components/style/form-color-input.js +26 -0
  43. package/es/components/style/form-label.js +22 -0
  44. package/es/components/style/form-number-input.js +29 -29
  45. package/es/components/style/form-number-input_2.js +200 -0
  46. package/es/components/style/form-select.js +19 -0
  47. package/es/components/style/form-slider.js +60 -0
  48. package/es/components/style/form-submit-button.js +25 -0
  49. package/es/components/style/form-text-input.js +69 -0
  50. package/es/components/viewer2d/grids/grid-streak.js +1 -1
  51. package/es/components/viewer2d/group.js +5 -4
  52. package/es/components/viewer2d/item.js +155 -359
  53. package/es/components/viewer2d/layer.js +1 -1
  54. package/es/components/viewer2d/line.js +22 -54
  55. package/es/components/viewer2d/ruler.js +16 -11
  56. package/es/components/viewer2d/rulerDist.js +38 -51
  57. package/es/components/viewer2d/rulerX.js +4 -2
  58. package/es/components/viewer2d/rulerY.js +3 -0
  59. package/es/components/viewer2d/scene.js +17 -12
  60. package/es/components/viewer2d/state.js +1 -1
  61. package/es/components/viewer2d/utils.js +2 -2
  62. package/es/components/viewer2d/vertex.js +3 -2
  63. package/es/components/viewer2d/viewer2d.js +81 -118
  64. package/es/components/viewer3d/front3D.js +13 -1
  65. package/es/components/viewer3d/ruler-utils/scene3D.js +1 -1
  66. package/es/components/viewer3d/scene-creator.js +270 -69
  67. package/es/components/viewer3d/viewer3d-first-person.js +26 -32
  68. package/es/components/viewer3d/viewer3d.js +110 -130
  69. package/es/constants.js +7 -2
  70. package/es/devLiteRenderer.js +491 -150
  71. package/es/index.js +589 -62
  72. package/es/models.js +13 -8
  73. package/es/plugins/SVGLoader.js +1414 -0
  74. package/es/plugins/console-debugger.js +34 -0
  75. package/es/plugins/export.js +7 -0
  76. package/es/plugins/keyboard.js +110 -0
  77. package/es/reducers/project-reducer.js +4 -1
  78. package/es/reducers/viewer2d-reducer.js +3 -1
  79. package/es/reducers/viewer3d-reducer.js +3 -1
  80. package/es/styles/export.js +5 -0
  81. package/es/styles/tabs.css +40 -0
  82. package/es/utils/geometry.js +77 -119
  83. package/es/utils/helper.js +38 -1
  84. package/es/utils/isolate-event-handler.js +829 -609
  85. package/es/utils/molding.js +489 -11
  86. package/es/utils/ruler.js +58 -0
  87. package/lib/AppContext.js +1 -1
  88. package/lib/LiteKitchenConfigurator.js +170 -111
  89. package/lib/LiteRenderer.js +160 -129
  90. package/lib/actions/export.js +35 -39
  91. package/lib/actions/project-actions.js +2 -1
  92. package/lib/assets/gltf/door_sliding.bin +0 -0
  93. package/lib/assets/img/svg/bottombar/elevation.svg +12 -5
  94. package/lib/catalog/catalog.js +20 -4
  95. package/lib/catalog/factories/area-factory-3d.js +14 -14
  96. package/lib/catalog/factories/wall-factory.js +1 -1
  97. package/lib/catalog/holes/window-clear/planner-element.js +2 -2
  98. package/lib/catalog/properties/export.js +81 -0
  99. package/lib/catalog/properties/property-checkbox.js +76 -0
  100. package/lib/catalog/properties/property-color.js +47 -0
  101. package/lib/catalog/properties/property-enum.js +58 -0
  102. package/lib/catalog/properties/property-hidden.js +27 -0
  103. package/lib/catalog/properties/property-lenght-measure.js +108 -0
  104. package/lib/catalog/properties/property-length-measure.js +92 -0
  105. package/lib/catalog/properties/property-length-measure_hole.js +108 -0
  106. package/lib/catalog/properties/property-number.js +56 -0
  107. package/lib/catalog/properties/property-read-only.js +34 -0
  108. package/lib/catalog/properties/property-string.js +56 -0
  109. package/lib/catalog/properties/property-toggle.js +47 -0
  110. package/lib/catalog/properties/shared-property-style.js +21 -0
  111. package/lib/catalog/utils/exporter.js +24 -11
  112. package/lib/catalog/utils/item-loader.js +221 -217
  113. package/lib/class/hole.js +0 -2
  114. package/lib/class/item.js +90 -68
  115. package/lib/class/layer.js +1 -1
  116. package/lib/class/line.js +3 -7
  117. package/lib/class/project.js +96 -81
  118. package/lib/components/content.js +10 -93
  119. package/lib/components/export.js +6 -26
  120. package/lib/components/style/button.js +115 -0
  121. package/lib/components/style/cancel-button.js +29 -0
  122. package/lib/components/style/content-container.js +38 -0
  123. package/lib/components/style/content-title.js +35 -0
  124. package/lib/components/style/delete-button.js +34 -0
  125. package/lib/components/style/export.js +105 -1
  126. package/lib/components/style/form-block.js +28 -0
  127. package/lib/components/style/form-color-input.js +34 -0
  128. package/lib/components/style/form-label.js +30 -0
  129. package/lib/components/style/form-number-input.js +29 -29
  130. package/lib/components/style/form-number-input_2.js +209 -0
  131. package/lib/components/style/form-select.js +29 -0
  132. package/lib/components/style/form-slider.js +68 -0
  133. package/lib/components/style/form-submit-button.js +35 -0
  134. package/lib/components/style/form-text-input.js +78 -0
  135. package/lib/components/viewer2d/grids/grid-streak.js +1 -1
  136. package/lib/components/viewer2d/group.js +5 -4
  137. package/lib/components/viewer2d/item.js +152 -356
  138. package/lib/components/viewer2d/layer.js +1 -1
  139. package/lib/components/viewer2d/line.js +22 -54
  140. package/lib/components/viewer2d/ruler.js +15 -10
  141. package/lib/components/viewer2d/rulerDist.js +38 -51
  142. package/lib/components/viewer2d/rulerX.js +4 -2
  143. package/lib/components/viewer2d/rulerY.js +3 -0
  144. package/lib/components/viewer2d/scene.js +17 -12
  145. package/lib/components/viewer2d/state.js +1 -1
  146. package/lib/components/viewer2d/utils.js +2 -2
  147. package/lib/components/viewer2d/vertex.js +3 -2
  148. package/lib/components/viewer2d/viewer2d.js +79 -115
  149. package/lib/components/viewer3d/front3D.js +13 -1
  150. package/lib/components/viewer3d/ruler-utils/scene3D.js +1 -1
  151. package/lib/components/viewer3d/scene-creator.js +267 -66
  152. package/lib/components/viewer3d/viewer3d-first-person.js +26 -32
  153. package/lib/components/viewer3d/viewer3d.js +107 -126
  154. package/lib/constants.js +12 -7
  155. package/lib/devLiteRenderer.js +489 -148
  156. package/lib/index.js +591 -62
  157. package/lib/models.js +13 -8
  158. package/lib/plugins/SVGLoader.js +1419 -0
  159. package/lib/plugins/console-debugger.js +42 -0
  160. package/lib/plugins/export.js +25 -0
  161. package/lib/plugins/keyboard.js +117 -0
  162. package/lib/reducers/project-reducer.js +4 -1
  163. package/lib/reducers/viewer2d-reducer.js +3 -1
  164. package/lib/reducers/viewer3d-reducer.js +3 -1
  165. package/lib/styles/export.js +13 -0
  166. package/lib/styles/tabs.css +40 -0
  167. package/lib/utils/geometry.js +77 -119
  168. package/lib/utils/helper.js +40 -1
  169. package/lib/utils/isolate-event-handler.js +829 -608
  170. package/lib/utils/molding.js +490 -9
  171. package/lib/utils/ruler.js +63 -0
  172. package/package.json +21 -20
  173. package/es/mocks/appliancePayload.json +0 -27
  174. package/es/mocks/cabinetPayload.json +0 -1914
  175. package/es/mocks/cabinetPayload2.json +0 -76
  176. package/es/mocks/dataBundle2.json +0 -4
  177. package/es/mocks/distancePayload.json +0 -6
  178. package/es/mocks/doorStylePayload2.json +0 -84
  179. package/es/mocks/furnishingPayload.json +0 -23
  180. package/es/mocks/itemCDSPayload.json +0 -27
  181. package/es/mocks/lightingPayload.json +0 -23
  182. package/es/mocks/mockProps.json +0 -43
  183. package/es/mocks/mockProps2.json +0 -9
  184. package/es/mocks/moldingPayload.json +0 -19
  185. package/es/mocks/projectItemsCatalog.json +0 -133
  186. package/es/mocks/rectangleShape.json +0 -238
  187. package/es/mocks/replaceCabinetPayload.json +0 -81
  188. package/es/mocks/roomShapePayload.json +0 -5
  189. package/es/useAppContext.js +0 -8
  190. package/lib/mocks/appliancePayload.json +0 -27
  191. package/lib/mocks/cabinetPayload.json +0 -1914
  192. package/lib/mocks/cabinetPayload2.json +0 -76
  193. package/lib/mocks/dataBundle2.json +0 -4
  194. package/lib/mocks/distancePayload.json +0 -6
  195. package/lib/mocks/doorStylePayload2.json +0 -84
  196. package/lib/mocks/furnishingPayload.json +0 -23
  197. package/lib/mocks/itemCDSPayload.json +0 -27
  198. package/lib/mocks/lightingPayload.json +0 -23
  199. package/lib/mocks/mockProps.json +0 -43
  200. package/lib/mocks/mockProps2.json +0 -9
  201. package/lib/mocks/moldingPayload.json +0 -19
  202. package/lib/mocks/projectItemsCatalog.json +0 -133
  203. package/lib/mocks/rectangleShape.json +0 -238
  204. package/lib/mocks/replaceCabinetPayload.json +0 -81
  205. package/lib/mocks/roomShapePayload.json +0 -5
  206. package/lib/useAppContext.js +0 -16
@@ -4,8 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ exports.getPlannerStateFromProps = getPlannerStateFromProps;
7
8
  exports.handleExternalEvent = handleExternalEvent;
8
9
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
12
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
13
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
@@ -18,37 +20,68 @@ var _convertUnitsLite = require("./convert-units-lite");
18
20
  var _export = require("./export");
19
21
  var _utils = require("../components/viewer2d/utils");
20
22
  var _SVGLoader = require("three/addons/loaders/SVGLoader");
23
+ var _molding = require("./molding");
24
+ var _models = require("../models");
21
25
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
22
26
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
23
27
  var PRECISION = 2;
28
+
29
+ // ---- compatibility: supports old + optimized props shapes ----
30
+ function getPlannerStateFromProps(props) {
31
+ var _props$state;
32
+ // New optimized path
33
+ if (props !== null && props !== void 0 && props.extractedState) return props.extractedState;
34
+
35
+ // Old path
36
+ if (props !== null && props !== void 0 && (_props$state = props.state) !== null && _props$state !== void 0 && _props$state.get) {
37
+ var kc = props.state.get('KitchenConfigurator');
38
+ if (kc) return kc;
39
+ }
40
+ return null;
41
+ }
42
+
43
+ // ---- caches: avoid re-fetch/re-parse costs (no behavior change) ----
44
+ var __jsonCache = new _immutable.Map(); // url -> Promise<any>
45
+ var __svgCache = new _immutable.Map(); // url -> Promise<svgData|null>
24
46
  function loadJSON(_x) {
25
47
  return _loadJSON.apply(this, arguments);
26
48
  }
27
49
  /********Parse TempPlaceholder from cabinetPayloadData **************/
28
50
  function _loadJSON() {
29
- _loadJSON = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(path) {
30
- return _regenerator["default"].wrap(function (_context2) {
31
- while (1) switch (_context2.prev = _context2.next) {
51
+ _loadJSON = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(path) {
52
+ var p;
53
+ return _regenerator["default"].wrap(function (_context3) {
54
+ while (1) switch (_context3.prev = _context3.next) {
32
55
  case 0:
33
- return _context2.abrupt("return", new Promise(function (resolve, reject) {
56
+ if (path) {
57
+ _context3.next = 1;
58
+ break;
59
+ }
60
+ return _context3.abrupt("return", null);
61
+ case 1:
62
+ if (!__jsonCache.has(path)) {
63
+ _context3.next = 2;
64
+ break;
65
+ }
66
+ return _context3.abrupt("return", __jsonCache.get(path));
67
+ case 2:
68
+ p = new Promise(function (resolve, reject) {
34
69
  var xhr = new XMLHttpRequest();
35
70
  xhr.onreadystatechange = function () {
36
71
  if (xhr.readyState === XMLHttpRequest.DONE) {
37
- if (xhr.status === 200) {
38
- resolve(JSON.parse(xhr.responseText));
39
- } else {
40
- reject(xhr);
41
- }
72
+ if (xhr.status === 200) resolve(JSON.parse(xhr.responseText));else reject(xhr);
42
73
  }
43
74
  };
44
75
  xhr.open('GET', path, true);
45
76
  xhr.send();
46
- }));
47
- case 1:
77
+ });
78
+ __jsonCache.set(path, p);
79
+ return _context3.abrupt("return", p);
80
+ case 3:
48
81
  case "end":
49
- return _context2.stop();
82
+ return _context3.stop();
50
83
  }
51
- }, _callee2);
84
+ }, _callee3);
52
85
  }));
53
86
  return _loadJSON.apply(this, arguments);
54
87
  }
@@ -57,10 +90,10 @@ function parseTempPlaceholdersFromCabinetPayload(_x2) {
57
90
  }
58
91
  /***** Update cabinetPayloadData with updatedTempPlaceholders *****/
59
92
  function _parseTempPlaceholdersFromCabinetPayload() {
60
- _parseTempPlaceholdersFromCabinetPayload = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(cabinetPayload) {
61
- var link, keys, temp, i, _cabinetPayload$struc, _cabinetPayload$struc2, el, tempPlaceholdersData, tempData, doorKey, drawerKey, fixedKey, doorPHs, drawerPHs, has_single_door, fixedPHs, _t2, _t3, _t4;
62
- return _regenerator["default"].wrap(function (_context3) {
63
- while (1) switch (_context3.prev = _context3.next) {
93
+ _parseTempPlaceholdersFromCabinetPayload = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(cabinetPayload) {
94
+ var link, keys, temp, i, _cabinetPayload$struc, _cabinetPayload$struc2, tempPlaceholdersData, _loop3, tempData, doorKey, drawerKey, fixedKey, doorPHs, drawerPHs, has_single_door, fixedPHs, k, _cabinetPayload$struc3, _t2, _t3, _t4;
95
+ return _regenerator["default"].wrap(function (_context5) {
96
+ while (1) switch (_context5.prev = _context5.next) {
64
97
  case 0:
65
98
  link = '';
66
99
  keys = Object.keys(cabinetPayload.structure_json);
@@ -68,335 +101,358 @@ function _parseTempPlaceholdersFromCabinetPayload() {
68
101
  i = 0;
69
102
  case 1:
70
103
  if (!(i < keys.length)) {
71
- _context3.next = 4;
104
+ _context5.next = 4;
72
105
  break;
73
106
  }
74
107
  if (!((_cabinetPayload$struc = cabinetPayload.structure_json[keys[i]]) !== null && _cabinetPayload$struc !== void 0 && (_cabinetPayload$struc = _cabinetPayload$struc.toString()) !== null && _cabinetPayload$struc !== void 0 && _cabinetPayload$struc.includes('.gltf') && (_cabinetPayload$struc2 = cabinetPayload.structure_json[keys[i]]) !== null && _cabinetPayload$struc2 !== void 0 && (_cabinetPayload$struc2 = _cabinetPayload$struc2.toString()) !== null && _cabinetPayload$struc2 !== void 0 && _cabinetPayload$struc2.startsWith('http'))) {
75
- _context3.next = 3;
108
+ _context5.next = 3;
76
109
  break;
77
110
  }
78
111
  link = cabinetPayload.structure_json[keys[i]];
79
112
  _t2 = temp;
80
113
  _t3 = keys[i];
81
- _context3.next = 2;
114
+ _context5.next = 2;
82
115
  return loadJSON(link);
83
116
  case 2:
84
- _t4 = _context3.sent;
117
+ _t4 = _context5.sent;
85
118
  _t2.push.call(_t2, {
86
119
  name: _t3,
87
120
  data: _t4
88
121
  });
89
122
  case 3:
90
123
  i++;
91
- _context3.next = 1;
124
+ _context5.next = 1;
92
125
  break;
93
126
  case 4:
94
- el = cabinetPayload.structure_json.tempPlaceholders[0].id;
95
127
  tempPlaceholdersData = [];
96
- tempData = {};
97
- doorKey = 0;
98
- drawerKey = 0;
99
- fixedKey = 0;
100
- doorPHs = 0;
101
- drawerPHs = 0;
102
- has_single_door = false;
103
- fixedPHs = 0;
104
- temp.forEach(function (t, index) {
105
- var nodes = t.data.nodes;
106
- if (nodes === undefined) {
107
- nodes = [];
108
- }
109
- var tempPlaceholders = nodes.filter(function (element) {
110
- return element.name.startsWith('ph_');
111
- });
112
- tempPlaceholders.sort(function (a, b) {
113
- return a.name > b.name ? 1 : -1;
114
- });
115
- if (tempPlaceholders.length > 0) {
116
- if (t.name === 'base') {
117
- tempPlaceholders.map(function (element) {
118
- var sink_match = element.name.match(/\d_(sink_[^LR12]*)(_[LR12])?$/);
119
- if (sink_match && sink_match.length >= 2) {
120
- var _process$env$API_URL, _cabinetPayload$struc3;
121
- tempData['sink'] = tempData['sink'] || [];
122
- tempData['sink'].push(element.name);
123
- var sink_url = (_process$env$API_URL = process.env.API_URL) !== null && _process$env$API_URL !== void 0 ? _process$env$API_URL :
124
- // server url from 3DTool env
125
- import.meta.env.VITE_APP_API_URL + // server url from Host env
126
- "/uploads/assets/default/".concat(sink_match[1], ".gltf");
127
- if (cabinetPayload !== null && cabinetPayload !== void 0 && (_cabinetPayload$struc3 = cabinetPayload.structure_json) !== null && _cabinetPayload$struc3 !== void 0 && (_cabinetPayload$struc3 = _cabinetPayload$struc3.tempPlaceholders[0]) !== null && _cabinetPayload$struc3 !== void 0 && _cabinetPayload$struc3.structure) cabinetPayload.structure_json.tempPlaceholders[0].structure.sink = sink_url;
128
- } else if (temp.some(function (felement) {
129
- return felement.name.includes('base_drawer');
130
- }) && element.name.includes('interior_drawer')) {
131
- var objCnt = temp.filter(function (felement) {
132
- return felement.name.includes('base_drawer') && !felement.name.includes('_door');
133
- }).length;
134
- var phCnt = tempPlaceholders.filter(function (felement) {
135
- return felement.name.includes('interior');
136
- }).length;
137
- drawerPHs = phCnt;
138
- if (objCnt === 1 || phCnt % objCnt !== 0) {
139
- if (tempData['base_drawer_1'] === undefined) {
140
- tempData['base_drawer_1'] = [];
141
- }
142
- tempData['base_drawer_1'].push(element.name);
143
- drawerKey++;
144
- } else if (objCnt > 1 && phCnt % objCnt === 0) {
145
- if (tempData['base_drawer_' + (drawerKey % objCnt + 1)] === undefined) {
146
- tempData['base_drawer_' + (drawerKey % objCnt + 1)] = [];
147
- }
148
- tempData['base_drawer_' + (drawerKey % objCnt + 1)].push(element.name);
149
- drawerKey++;
150
- }
151
- } else if (temp.some(function (felement) {
152
- return felement.name.includes('base_door');
153
- }) && !element.name.includes('interior_drawer') && !element.name.includes('drawer') && element.name.includes('door')) {
154
- var _objCnt = temp.filter(function (felement) {
155
- return felement.name.includes('base_door');
156
- }).length;
157
- var _phCnt = tempPlaceholders.filter(function (felement) {
158
- return !felement.name.includes('interior') && !felement.name.includes('drawer') && felement.name.includes('door');
159
- }).length;
160
- doorPHs = _phCnt;
161
- if (_objCnt === 1 || _phCnt % _objCnt !== 0) {
162
- if (tempData['base_door_1'] === undefined) {
163
- tempData['base_door_1'] = [];
164
- }
165
- tempData['base_door_1'].push(element.name);
166
- doorKey++;
167
- } else if (_objCnt > 1) {
168
- if (tempData['base_door_' + (doorKey % _objCnt + 1)] === undefined) {
169
- tempData['base_door_' + (doorKey % _objCnt + 1)] = [];
170
- }
171
- tempData['base_door_' + (doorKey % _objCnt + 1)].push(element.name);
172
- doorKey++;
173
- }
174
- } else if (temp.some(function (felement) {
175
- return felement.name.includes('base_fixed_drawer_door');
176
- }) && element.name.includes('_drawer_door_fixed')) {
177
- var _objCnt2 = temp.filter(function (felement) {
178
- return felement.name.includes('base_fixed_drawer_door');
179
- }).length;
180
- var _phCnt2 = tempPlaceholders.filter(function (felement) {
181
- return felement.name.includes('_drawer_door_fixed');
182
- }).length;
183
- fixedPHs = _phCnt2;
184
- if (_objCnt2 === 1 || _phCnt2 % _objCnt2 !== 0) {
185
- if (tempData['base_fixed_drawer_door_1'] === undefined) {
186
- tempData['base_fixed_drawer_door_1'] = [];
187
- }
188
- tempData['base_fixed_drawer_door_1'].push(element.name);
189
- fixedKey++;
190
- } else if (_objCnt2 > 1) {
191
- if (tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] === undefined) {
192
- tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] = [];
193
- }
194
- tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)].push(element.name);
195
- fixedKey++;
128
+ _loop3 = /*#__PURE__*/_regenerator["default"].mark(function _loop3(k) {
129
+ var el;
130
+ return _regenerator["default"].wrap(function (_context4) {
131
+ while (1) switch (_context4.prev = _context4.next) {
132
+ case 0:
133
+ el = cabinetPayload.structure_json.tempPlaceholders[k].id;
134
+ tempData = {};
135
+ doorKey = 0;
136
+ drawerKey = 0;
137
+ fixedKey = 0;
138
+ doorPHs = 0;
139
+ drawerPHs = 0;
140
+ has_single_door = false;
141
+ fixedPHs = 0;
142
+ temp.forEach(function (t, index) {
143
+ var nodes = t.data.nodes;
144
+ if (nodes === undefined) {
145
+ nodes = [];
196
146
  }
197
- }
198
- });
199
- } else if (t.name.includes('base_drawer') && !t.name.includes('_door')) {
200
- var objCnt = temp.filter(function (felement) {
201
- return felement.name.includes('base_drawer') && !felement.name.includes('_door');
202
- }).length;
203
- if (objCnt === 1 || drawerPHs % objCnt !== 0) {
204
- if (tempData['base_drawer_door_1'] === undefined) tempData['base_drawer_door_1'] = [];
205
- //get drawer door handle placeholders
206
- var ph_temp = temp.find(function (felement) {
207
- return felement.name === 'base_drawer_door_1';
208
- });
209
- if (ph_temp != undefined) {
210
- var ph_drawer_door_handle = ph_temp.data.nodes;
211
- ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) {
212
- return element.name.startsWith('ph_') && element.name.includes('handle');
147
+ var tempPlaceholders = nodes.filter(function (element) {
148
+ return element.name.startsWith('ph_');
213
149
  });
214
- for (var w = 0; w < drawerPHs; w++) {
215
- if (!tempData['base_drawer_door_1'].some(function (el) {
216
- return el === 'base_drawer_door_1/' + tempPlaceholders[0].name;
217
- })) {
218
- tempData['base_drawer_door_1'].push('base_drawer_1/' + tempPlaceholders[0].name);
219
- //add drawer door handle placeholders
220
- if (tempData['drawer_door_handle_1'] === undefined) tempData['drawer_door_handle_1'] = [];
221
- if (ph_drawer_door_handle.length > 0) tempData['drawer_door_handle_1'].push('base_drawer_door_1/' + ph_drawer_door_handle[0].name);
222
- }
223
- }
224
- }
225
- } else if (objCnt > 1 && drawerPHs > 0 && drawerPHs % objCnt === 0) {
226
- if (tempData['base_drawer_door' + t.name.slice(-2)] === undefined) tempData['base_drawer_door' + t.name.slice(-2)] = [];
227
- //get drawer door handle placeholders
228
- var ph_temp = temp.find(function (felement) {
229
- return felement.name === 'base_drawer_door' + t.name.slice(-2);
230
- });
231
- if (ph_temp != undefined) {
232
- var ph_drawer_door_handle = ph_temp.data.nodes;
233
- ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) {
234
- return element.name.startsWith('ph_') && element.name.includes('handle');
150
+ tempPlaceholders.sort(function (a, b) {
151
+ return a.name > b.name ? 1 : -1;
235
152
  });
236
- tempPlaceholders.forEach(function (element) {
237
- if (!tempData['base_drawer_door' + t.name.slice(-2)].some(function (el) {
238
- return el === t.name + '/' + element.name;
239
- })) {
240
- tempData['base_drawer_door' + t.name.slice(-2)].push(t.name + '/' + element.name);
241
- //add drawer door handle placeholders
242
- if (tempData['drawer_door_handle' + t.name.slice(-2)] === undefined) tempData['drawer_door_handle' + t.name.slice(-2)] = [];
243
- if (ph_drawer_door_handle.length > 0) tempData['drawer_door_handle' + t.name.slice(-2)].push('base_drawer_door' + t.name.slice(-2) + '/' + ph_drawer_door_handle[0].name);
153
+ if (tempPlaceholders.length > 0) {
154
+ if (t.name === 'base') {
155
+ tempPlaceholders.map(function (element) {
156
+ var sink_match = element.name.match(/\d_(sink_[^LR12]*)(_[LR12])?$/);
157
+ if (sink_match && sink_match.length >= 2) {
158
+ var _process$env$API_URL, _cabinetPayload$struc4;
159
+ tempData['sink'] = tempData['sink'] || [];
160
+ tempData['sink'].push(element.name);
161
+ var sink_url = (_process$env$API_URL = process.env.API_URL) !== null && _process$env$API_URL !== void 0 ? _process$env$API_URL :
162
+ // server url from 3DTool env
163
+ import.meta.env.VITE_APP_API_URL + // server url from Host env
164
+ "/uploads/assets/default/".concat(sink_match[1], ".gltf");
165
+ if (cabinetPayload !== null && cabinetPayload !== void 0 && (_cabinetPayload$struc4 = cabinetPayload.structure_json) !== null && _cabinetPayload$struc4 !== void 0 && (_cabinetPayload$struc4 = _cabinetPayload$struc4.tempPlaceholders[k]) !== null && _cabinetPayload$struc4 !== void 0 && _cabinetPayload$struc4.structure) cabinetPayload.structure_json.tempPlaceholders[k].structure.sink = sink_url;
166
+ } else if (temp.some(function (felement) {
167
+ return felement.name.includes('base_drawer');
168
+ }) && element.name.includes('interior_drawer')) {
169
+ var objCnt = temp.filter(function (felement) {
170
+ return felement.name.includes('base_drawer') && !felement.name.includes('_door');
171
+ }).length;
172
+ var phCnt = tempPlaceholders.filter(function (felement) {
173
+ return felement.name.includes('interior');
174
+ }).length;
175
+ drawerPHs = phCnt;
176
+ if (objCnt === 1 || phCnt % objCnt !== 0) {
177
+ if (tempData['base_drawer_1'] === undefined) {
178
+ tempData['base_drawer_1'] = [];
179
+ }
180
+ tempData['base_drawer_1'].push(element.name);
181
+ drawerKey++;
182
+ } else if (objCnt > 1 && phCnt % objCnt === 0) {
183
+ if (tempData['base_drawer_' + (drawerKey % objCnt + 1)] === undefined) {
184
+ tempData['base_drawer_' + (drawerKey % objCnt + 1)] = [];
185
+ }
186
+ tempData['base_drawer_' + (drawerKey % objCnt + 1)].push(element.name);
187
+ drawerKey++;
188
+ }
189
+ } else if (temp.some(function (felement) {
190
+ return felement.name.includes('base_door');
191
+ }) && !element.name.includes('interior_drawer') && !element.name.includes('drawer') && element.name.includes('door')) {
192
+ var _objCnt = temp.filter(function (felement) {
193
+ return felement.name.includes('base_door');
194
+ }).length;
195
+ var _phCnt = tempPlaceholders.filter(function (felement) {
196
+ return !felement.name.includes('interior') && !felement.name.includes('drawer') && felement.name.includes('door');
197
+ }).length;
198
+ doorPHs = _phCnt;
199
+ if (_objCnt === 1 || _phCnt % _objCnt !== 0) {
200
+ if (tempData['base_door_1'] === undefined) {
201
+ tempData['base_door_1'] = [];
202
+ }
203
+ tempData['base_door_1'].push(element.name);
204
+ doorKey++;
205
+ } else if (_objCnt > 1) {
206
+ if (tempData['base_door_' + (doorKey % _objCnt + 1)] === undefined) {
207
+ tempData['base_door_' + (doorKey % _objCnt + 1)] = [];
208
+ }
209
+ tempData['base_door_' + (doorKey % _objCnt + 1)].push(element.name);
210
+ doorKey++;
211
+ }
212
+ } else if (temp.some(function (felement) {
213
+ return felement.name.includes('base_fixed_drawer_door');
214
+ }) && element.name.includes('_drawer_door_fixed')) {
215
+ var _objCnt2 = temp.filter(function (felement) {
216
+ return felement.name.includes('base_fixed_drawer_door');
217
+ }).length;
218
+ var _phCnt2 = tempPlaceholders.filter(function (felement) {
219
+ return felement.name.includes('_drawer_door_fixed');
220
+ }).length;
221
+ fixedPHs = _phCnt2;
222
+ if (_objCnt2 === 1 || _phCnt2 % _objCnt2 !== 0) {
223
+ if (tempData['base_fixed_drawer_door_1'] === undefined) {
224
+ tempData['base_fixed_drawer_door_1'] = [];
225
+ }
226
+ tempData['base_fixed_drawer_door_1'].push(element.name);
227
+ fixedKey++;
228
+ } else if (_objCnt2 > 1) {
229
+ if (tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] === undefined) {
230
+ tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] = [];
231
+ }
232
+ tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)].push(element.name);
233
+ fixedKey++;
234
+ }
235
+ }
236
+ });
237
+ } else if (t.name.includes('base_drawer') && !t.name.includes('_door')) {
238
+ var objCnt = temp.filter(function (felement) {
239
+ return felement.name.includes('base_drawer') && !felement.name.includes('_door');
240
+ }).length;
241
+ if (objCnt === 1 || drawerPHs % objCnt !== 0) {
242
+ if (tempData['base_drawer_door_1'] === undefined) tempData['base_drawer_door_1'] = [];
243
+ //get drawer door handle placeholders
244
+ var ph_temp = temp.find(function (felement) {
245
+ return felement.name === 'base_drawer_door_1';
246
+ });
247
+ if (ph_temp != undefined) {
248
+ var ph_drawer_door_handle = ph_temp.data.nodes;
249
+ ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) {
250
+ return element.name.startsWith('ph_') && element.name.includes('handle');
251
+ });
252
+ for (var w = 0; w < drawerPHs; w++) {
253
+ if (!tempData['base_drawer_door_1'].some(function (el) {
254
+ return el === 'base_drawer_door_1/' + tempPlaceholders[0].name;
255
+ })) {
256
+ tempData['base_drawer_door_1'].push('base_drawer_1/' + tempPlaceholders[0].name);
257
+ //add drawer door handle placeholders
258
+ if (tempData['drawer_door_handle_1'] === undefined) tempData['drawer_door_handle_1'] = [];
259
+ if (ph_drawer_door_handle.length > 0) tempData['drawer_door_handle_1'].push('base_drawer_door_1/' + ph_drawer_door_handle[0].name);
260
+ }
261
+ }
262
+ }
263
+ } else if (objCnt > 1 && drawerPHs > 0 && drawerPHs % objCnt === 0) {
264
+ if (tempData['base_drawer_door' + t.name.slice(-2)] === undefined) tempData['base_drawer_door' + t.name.slice(-2)] = [];
265
+ //get drawer door handle placeholders
266
+ var ph_temp = temp.find(function (felement) {
267
+ return felement.name === 'base_drawer_door' + t.name.slice(-2);
268
+ });
269
+ if (ph_temp != undefined) {
270
+ var ph_drawer_door_handle = ph_temp.data.nodes;
271
+ ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) {
272
+ return element.name.startsWith('ph_') && element.name.includes('handle');
273
+ });
274
+ tempPlaceholders.forEach(function (element) {
275
+ if (!tempData['base_drawer_door' + t.name.slice(-2)].some(function (el) {
276
+ return el === t.name + '/' + element.name;
277
+ })) {
278
+ tempData['base_drawer_door' + t.name.slice(-2)].push(t.name + '/' + element.name);
279
+ //add drawer door handle placeholders
280
+ if (tempData['drawer_door_handle' + t.name.slice(-2)] === undefined) tempData['drawer_door_handle' + t.name.slice(-2)] = [];
281
+ if (ph_drawer_door_handle.length > 0) tempData['drawer_door_handle' + t.name.slice(-2)].push('base_drawer_door' + t.name.slice(-2) + '/' + ph_drawer_door_handle[0].name);
282
+ }
283
+ });
284
+ }
285
+ }
286
+ } else if (t.name.includes('base_door')) {
287
+ var _objCnt3 = temp.filter(function (felement) {
288
+ return felement.name.includes('base_door');
289
+ }).length;
290
+ tempPlaceholders = tempPlaceholders.filter(function (el) {
291
+ return el.name.includes('handle');
292
+ });
293
+ if (tempPlaceholders.length > 0) if (_objCnt3 === 1 || doorPHs % _objCnt3 !== 0) {
294
+ if (tempData['door_handle_1'] === undefined) {
295
+ tempData['door_handle_1'] = [];
296
+ }
297
+ var _loop4 = function _loop4() {
298
+ var phname = tempPlaceholders[0].name;
299
+ var newph = undefined;
300
+ if (tempData['base_door_1'][_w].isLeftPlaceholder()) {
301
+ newph = tempPlaceholders.find(function (el) {
302
+ return el.name.isRightPlaceholder();
303
+ });
304
+ }
305
+ if (tempData['base_door_1'][_w].isRightPlaceholder()) {
306
+ newph = tempPlaceholders.find(function (el) {
307
+ return el.name.isLeftPlaceholder();
308
+ });
309
+ }
310
+ if (newph != undefined) {
311
+ phname = newph.name;
312
+ }
313
+ if (doorPHs === 1 && tempPlaceholders.find(function (el) {
314
+ return el.name.isLeftPlaceholder();
315
+ }) != undefined && tempPlaceholders.find(function (el) {
316
+ return el.name.isRightPlaceholder();
317
+ }) != undefined) {
318
+ has_single_door = true;
319
+ }
320
+ if (!tempData['door_handle_1'].some(function (el) {
321
+ return el === 'door_handle_1/' + phname;
322
+ })) {
323
+ tempData['door_handle_1'].push('base_door_1/' + phname);
324
+ }
325
+ };
326
+ for (var _w = 0; _w < doorPHs; _w++) {
327
+ _loop4();
328
+ }
329
+ } else if (_objCnt3 > 1 && doorPHs > 0 && doorPHs % _objCnt3 === 0) {
330
+ if (tempData['door_handle' + t.name.slice(-2)] === undefined) tempData['door_handle' + t.name.slice(-2)] = [];
331
+ var phname = tempPlaceholders[0].name;
332
+ var newph = undefined;
333
+ var blAdd = true;
334
+ if (cabinetPayload.is_corner) {
335
+ if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
336
+ newph = tempPlaceholders.find(function (el) {
337
+ return el.name.isLeftPlaceholder();
338
+ });
339
+ } else {
340
+ blAdd = false;
341
+ }
342
+ } else {
343
+ if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
344
+ newph = tempPlaceholders.find(function (el) {
345
+ return el.name.isRightPlaceholder();
346
+ });
347
+ }
348
+ if (tempData['base_door' + t.name.slice(-2)][0].isRightPlaceholder()) {
349
+ newph = tempPlaceholders.find(function (el) {
350
+ return el.name.isLeftPlaceholder();
351
+ });
352
+ }
353
+ }
354
+ if (blAdd) {
355
+ if (newph != undefined) {
356
+ phname = newph.name;
357
+ }
358
+ if (!tempData['door_handle' + t.name.slice(-2)].some(function (el) {
359
+ return el === t.name + '/' + phname;
360
+ })) {
361
+ tempData['door_handle' + t.name.slice(-2)].push(t.name + '/' + phname);
362
+ }
363
+ }
364
+ }
365
+ } else if (t.name.includes('base_fixed_drawer_door')) {
366
+ var _objCnt4 = temp.filter(function (felement) {
367
+ return felement.name.includes('base_fixed_drawer_door');
368
+ }).length;
369
+ tempPlaceholders = tempPlaceholders.filter(function (el) {
370
+ return el.name.includes('handle');
371
+ });
372
+ if (tempPlaceholders.length > 0) if (_objCnt4 === 1 || fixedPHs % _objCnt4 !== 0) {
373
+ if (tempData['fixed_drawer_door_handle_1'] === undefined) tempData['fixed_drawer_door_handle_1'] = [];
374
+ var _loop5 = function _loop5() {
375
+ var phname = tempPlaceholders[0].name;
376
+ var newph = undefined;
377
+ if (tempData['base_fixed_drawer_door_1'][_w2].isLeftPlaceholder()) {
378
+ newph = tempPlaceholders.find(function (el) {
379
+ return el.name.isRightPlaceholder();
380
+ });
381
+ }
382
+ if (tempData['base_fixed_drawer_door_1'][_w2].isRightPlaceholder()) {
383
+ newph = tempPlaceholders.find(function (el) {
384
+ return el.name.isLeftPlaceholder();
385
+ });
386
+ }
387
+ if (newph != undefined) {
388
+ phname = newph.name;
389
+ }
390
+ if (!tempData['fixed_drawer_door_handle_1'].some(function (el) {
391
+ return el === 'fixed_drawer_door_handle_1/' + phname;
392
+ })) {
393
+ tempData['fixed_drawer_door_handle_1'].push('base_fixed_drawer_door_1/' + phname);
394
+ }
395
+ };
396
+ for (var _w2 = 0; _w2 < fixedPHs; _w2++) {
397
+ _loop5();
398
+ }
399
+ } else if (_objCnt4 > 1 && fixedPHs > 0 && fixedPHs % _objCnt4 === 0) {
400
+ if (tempData['fixed_drawer_door_handle' + t.name.slice(-2)] === undefined) {
401
+ tempData['fixed_drawer_door_handle' + t.name.slice(-2)] = [];
402
+ }
403
+ var _phname = tempPlaceholders[0].name;
404
+ var _newph = undefined;
405
+ if (tempData['base_fixed_drawer_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
406
+ _newph = tempPlaceholders.find(function (el) {
407
+ return el.name.isRightPlaceholder();
408
+ });
409
+ }
410
+ if (tempData['base_fixed_drawer_door' + t.name.slice(-2)][0].isRightPlaceholder()) {
411
+ _newph = tempPlaceholders.find(function (el) {
412
+ return el.name.isLeftPlaceholder();
413
+ });
414
+ }
415
+ if (_newph != undefined) {
416
+ _phname = _newph.name;
417
+ }
418
+ if (!tempData['fixed_drawer_door_handle' + t.name.slice(-2)].some(function (el) {
419
+ return el === t.name + '/' + _phname;
420
+ })) {
421
+ tempData['fixed_drawer_door_handle' + t.name.slice(-2)].push(t.name + '/' + _phname);
422
+ }
423
+ }
244
424
  }
245
- });
246
- }
247
- }
248
- } else if (t.name.includes('base_door')) {
249
- var _objCnt3 = temp.filter(function (felement) {
250
- return felement.name.includes('base_door');
251
- }).length;
252
- tempPlaceholders = tempPlaceholders.filter(function (el) {
253
- return el.name.includes('handle');
254
- });
255
- if (tempPlaceholders.length > 0) if (_objCnt3 === 1 || doorPHs % _objCnt3 !== 0) {
256
- if (tempData['door_handle_1'] === undefined) {
257
- tempData['door_handle_1'] = [];
258
- }
259
- var _loop = function _loop() {
260
- var phname = tempPlaceholders[0].name;
261
- var newph = undefined;
262
- if (tempData['base_door_1'][_w].isLeftPlaceholder()) {
263
- newph = tempPlaceholders.find(function (el) {
264
- return el.name.isRightPlaceholder();
265
- });
266
- }
267
- if (tempData['base_door_1'][_w].isRightPlaceholder()) {
268
- newph = tempPlaceholders.find(function (el) {
269
- return el.name.isLeftPlaceholder();
270
- });
271
- }
272
- if (newph != undefined) {
273
- phname = newph.name;
274
- }
275
- if (doorPHs === 1 && tempPlaceholders.find(function (el) {
276
- return el.name.isLeftPlaceholder();
277
- }) != undefined && tempPlaceholders.find(function (el) {
278
- return el.name.isRightPlaceholder();
279
- }) != undefined) {
280
- has_single_door = true;
281
- }
282
- if (!tempData['door_handle_1'].some(function (el) {
283
- return el === 'door_handle_1/' + phname;
284
- })) {
285
- tempData['door_handle_1'].push('base_door_1/' + phname);
286
425
  }
287
- };
288
- for (var _w = 0; _w < doorPHs; _w++) {
289
- _loop();
290
- }
291
- } else if (_objCnt3 > 1 && doorPHs > 0 && doorPHs % _objCnt3 === 0) {
292
- if (tempData['door_handle' + t.name.slice(-2)] === undefined) tempData['door_handle' + t.name.slice(-2)] = [];
293
- var phname = tempPlaceholders[0].name;
294
- var newph = undefined;
295
- var blAdd = true;
296
- if (cabinetPayload.is_corner) {
297
- if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
298
- newph = tempPlaceholders.find(function (el) {
299
- return el.name.isLeftPlaceholder();
300
- });
301
- } else {
302
- blAdd = false;
303
- }
304
- } else {
305
- if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
306
- newph = tempPlaceholders.find(function (el) {
307
- return el.name.isRightPlaceholder();
308
- });
309
- }
310
- if (tempData['base_door' + t.name.slice(-2)][0].isRightPlaceholder()) {
311
- newph = tempPlaceholders.find(function (el) {
312
- return el.name.isLeftPlaceholder();
313
- });
314
- }
315
- }
316
- if (blAdd) {
317
- if (newph != undefined) {
318
- phname = newph.name;
319
- }
320
- if (!tempData['door_handle' + t.name.slice(-2)].some(function (el) {
321
- return el === t.name + '/' + phname;
322
- })) {
323
- tempData['door_handle' + t.name.slice(-2)].push(t.name + '/' + phname);
324
- }
325
- }
326
- }
327
- } else if (t.name.includes('base_fixed_drawer_door')) {
328
- var _objCnt4 = temp.filter(function (felement) {
329
- return felement.name.includes('base_fixed_drawer_door');
330
- }).length;
331
- tempPlaceholders = tempPlaceholders.filter(function (el) {
332
- return el.name.includes('handle');
333
- });
334
- if (tempPlaceholders.length > 0) if (_objCnt4 === 1 || fixedPHs % _objCnt4 !== 0) {
335
- if (tempData['fixed_drawer_door_handle_1'] === undefined) tempData['fixed_drawer_door_handle_1'] = [];
336
- var _loop2 = function _loop2() {
337
- var phname = tempPlaceholders[0].name;
338
- var newph = undefined;
339
- if (tempData['base_fixed_drawer_door_1'][_w2].isLeftPlaceholder()) {
340
- newph = tempPlaceholders.find(function (el) {
341
- return el.name.isRightPlaceholder();
342
- });
343
- }
344
- if (tempData['base_fixed_drawer_door_1'][_w2].isRightPlaceholder()) {
345
- newph = tempPlaceholders.find(function (el) {
346
- return el.name.isLeftPlaceholder();
347
- });
348
- }
349
- if (newph != undefined) {
350
- phname = newph.name;
351
- }
352
- if (!tempData['fixed_drawer_door_handle_1'].some(function (el) {
353
- return el === 'fixed_drawer_door_handle_1/' + phname;
354
- })) {
355
- tempData['fixed_drawer_door_handle_1'].push('base_fixed_drawer_door_1/' + phname);
356
- }
357
- };
358
- for (var _w2 = 0; _w2 < fixedPHs; _w2++) {
359
- _loop2();
360
- }
361
- } else if (_objCnt4 > 1 && fixedPHs > 0 && fixedPHs % _objCnt4 === 0) {
362
- if (tempData['fixed_drawer_door_handle' + t.name.slice(-2)] === undefined) {
363
- tempData['fixed_drawer_door_handle' + t.name.slice(-2)] = [];
364
- }
365
- var _phname = tempPlaceholders[0].name;
366
- var _newph = undefined;
367
- if (tempData['base_fixed_drawer_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
368
- _newph = tempPlaceholders.find(function (el) {
369
- return el.name.isRightPlaceholder();
370
- });
371
- }
372
- if (tempData['base_fixed_drawer_door' + t.name.slice(-2)][0].isRightPlaceholder()) {
373
- _newph = tempPlaceholders.find(function (el) {
374
- return el.name.isLeftPlaceholder();
375
- });
376
- }
377
- if (_newph != undefined) {
378
- _phname = _newph.name;
379
- }
380
- if (!tempData['fixed_drawer_door_handle' + t.name.slice(-2)].some(function (el) {
381
- return el === t.name + '/' + _phname;
382
- })) {
383
- tempData['fixed_drawer_door_handle' + t.name.slice(-2)].push(t.name + '/' + _phname);
384
- }
385
- }
426
+ });
427
+ tempPlaceholdersData.push({
428
+ id: parseInt(el, 10),
429
+ placeholders: tempData,
430
+ structure: cabinetPayload.structure_json.tempPlaceholders[k].structure
431
+ });
432
+ case 1:
433
+ case "end":
434
+ return _context4.stop();
386
435
  }
387
- }
388
- });
389
- tempPlaceholdersData.push({
390
- id: parseInt(el, 10),
391
- placeholders: tempData,
392
- structure: cabinetPayload.structure_json.tempPlaceholders[0].structure
436
+ }, _loop3);
393
437
  });
394
- return _context3.abrupt("return", tempPlaceholdersData);
438
+ k = 0;
395
439
  case 5:
440
+ if (!(k < (cabinetPayload === null || cabinetPayload === void 0 || (_cabinetPayload$struc3 = cabinetPayload.structure_json) === null || _cabinetPayload$struc3 === void 0 || (_cabinetPayload$struc3 = _cabinetPayload$struc3.tempPlaceholders) === null || _cabinetPayload$struc3 === void 0 ? void 0 : _cabinetPayload$struc3.length))) {
441
+ _context5.next = 7;
442
+ break;
443
+ }
444
+ return _context5.delegateYield(_loop3(k), "t0", 6);
445
+ case 6:
446
+ k++;
447
+ _context5.next = 5;
448
+ break;
449
+ case 7:
450
+ return _context5.abrupt("return", tempPlaceholdersData);
451
+ case 8:
396
452
  case "end":
397
- return _context3.stop();
453
+ return _context5.stop();
398
454
  }
399
- }, _callee3);
455
+ }, _callee4);
400
456
  }));
401
457
  return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments);
402
458
  }
@@ -404,79 +460,102 @@ function updateCabinetPayload(_x3) {
404
460
  return _updateCabinetPayload.apply(this, arguments);
405
461
  }
406
462
  function _updateCabinetPayload() {
407
- _updateCabinetPayload = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(cabinetPayload) {
408
- var tempPlaceholders, cabinetPayloadKeys, i;
409
- return _regenerator["default"].wrap(function (_context4) {
410
- while (1) switch (_context4.prev = _context4.next) {
463
+ _updateCabinetPayload = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(cabinetPayload) {
464
+ var cabinetPayloadKeys, i, _cabinetPayload$cabin, _cabinetPayload$cabin2;
465
+ return _regenerator["default"].wrap(function (_context6) {
466
+ while (1) switch (_context6.prev = _context6.next) {
411
467
  case 0:
412
- tempPlaceholders = [];
413
- _context4.next = 1;
414
- return parseTempPlaceholdersFromCabinetPayload(cabinetPayload);
415
- case 1:
416
- tempPlaceholders = _context4.sent;
468
+ // let tempPlaceholders = [];
469
+ // tempPlaceholders = await parseTempPlaceholdersFromCabinetPayload(
470
+ // cabinetPayload
471
+ // );
417
472
  cabinetPayloadKeys = Object.keys(cabinetPayload);
418
473
  for (i = 0; i < cabinetPayloadKeys.length; i++) {
419
474
  if (cabinetPayloadKeys[i] === 'structure_json') {
420
- cabinetPayload[cabinetPayloadKeys[i]]['placeholders'] = tempPlaceholders[0].placeholders;
421
- cabinetPayload[cabinetPayloadKeys[i]]['tempPlaceholders'] = tempPlaceholders;
475
+ cabinetPayload[cabinetPayloadKeys[i]]['placeholders'] = (_cabinetPayload$cabin = (_cabinetPayload$cabin2 = cabinetPayload[cabinetPayloadKeys[i]]['tempPlaceholders'][0]) === null || _cabinetPayload$cabin2 === void 0 ? void 0 : _cabinetPayload$cabin2.placeholders) !== null && _cabinetPayload$cabin !== void 0 ? _cabinetPayload$cabin : [];
476
+
477
+ // cabinetPayload[cabinetPayloadKeys[i]]['placeholders'] =
478
+ // tempPlaceholders[0].placeholders;
479
+ // cabinetPayload[cabinetPayloadKeys[i]]['tempPlaceholders'] =
480
+ // tempPlaceholders;
422
481
  }
423
482
  }
424
- return _context4.abrupt("return", cabinetPayload);
425
- case 2:
483
+ return _context6.abrupt("return", cabinetPayload);
484
+ case 1:
426
485
  case "end":
427
- return _context4.stop();
486
+ return _context6.stop();
428
487
  }
429
- }, _callee4);
488
+ }, _callee5);
430
489
  }));
431
490
  return _updateCabinetPayload.apply(this, arguments);
432
491
  }
433
492
  var loadSVGsByItem = /*#__PURE__*/function () {
434
- var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(item) {
435
- var _parsed$xml$viewBox, _parsed$xml$viewBox2, response, svgText, loader, parsed, _t;
436
- return _regenerator["default"].wrap(function (_context) {
437
- while (1) switch (_context.prev = _context.next) {
493
+ var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(item) {
494
+ var url, p;
495
+ return _regenerator["default"].wrap(function (_context2) {
496
+ while (1) switch (_context2.prev = _context2.next) {
438
497
  case 0:
439
- if (item.outline) {
440
- _context.next = 1;
498
+ if (item !== null && item !== void 0 && item.outline) {
499
+ _context2.next = 1;
441
500
  break;
442
501
  }
443
- return _context.abrupt("return", null);
502
+ return _context2.abrupt("return", null);
444
503
  case 1:
445
- _context.prev = 1;
446
- _context.next = 2;
447
- return fetch(item.outline, {
448
- cache: 'no-store'
449
- });
450
- case 2:
451
- response = _context.sent;
452
- _context.next = 3;
453
- return response.text();
454
- case 3:
455
- svgText = _context.sent;
456
- loader = new _SVGLoader.SVGLoader();
457
- parsed = loader.parse(svgText);
458
- if (!(0, _helper.isEmpty)(parsed.paths)) {
459
- _context.next = 4;
504
+ url = item.outline;
505
+ if (!__svgCache.has(url)) {
506
+ _context2.next = 2;
460
507
  break;
461
508
  }
462
- return _context.abrupt("return", null);
463
- case 4:
464
- return _context.abrupt("return", {
465
- paths: parsed.paths,
466
- svgWidth: parseFloat(parsed.xml.getAttribute('width')) || ((_parsed$xml$viewBox = parsed.xml.viewBox) === null || _parsed$xml$viewBox === void 0 || (_parsed$xml$viewBox = _parsed$xml$viewBox.animVal) === null || _parsed$xml$viewBox === void 0 ? void 0 : _parsed$xml$viewBox.width) || 0,
467
- svgHeight: parseFloat(parsed.xml.getAttribute('height')) || ((_parsed$xml$viewBox2 = parsed.xml.viewBox) === null || _parsed$xml$viewBox2 === void 0 || (_parsed$xml$viewBox2 = _parsed$xml$viewBox2.animVal) === null || _parsed$xml$viewBox2 === void 0 ? void 0 : _parsed$xml$viewBox2.height) || 0,
468
- reverse: !parseFloat(parsed.xml.getAttribute('height'))
469
- });
470
- case 5:
471
- _context.prev = 5;
472
- _t = _context["catch"](1);
473
- console.error('Failed to load SVG:', item.outline, _t);
474
- return _context.abrupt("return", null);
475
- case 6:
509
+ return _context2.abrupt("return", __svgCache.get(url));
510
+ case 2:
511
+ p = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
512
+ var _parsed$xml$viewBox, _parsed$xml$viewBox2, response, svgText, loader, parsed, _t;
513
+ return _regenerator["default"].wrap(function (_context) {
514
+ while (1) switch (_context.prev = _context.next) {
515
+ case 0:
516
+ _context.prev = 0;
517
+ _context.next = 1;
518
+ return fetch(url, {
519
+ cache: 'force-cache'
520
+ });
521
+ case 1:
522
+ response = _context.sent;
523
+ _context.next = 2;
524
+ return response.text();
525
+ case 2:
526
+ svgText = _context.sent;
527
+ loader = new _SVGLoader.SVGLoader();
528
+ parsed = loader.parse(svgText);
529
+ if (!(0, _helper.isEmpty)(parsed.paths)) {
530
+ _context.next = 3;
531
+ break;
532
+ }
533
+ return _context.abrupt("return", null);
534
+ case 3:
535
+ return _context.abrupt("return", {
536
+ paths: parsed.paths,
537
+ svgWidth: parseFloat(parsed.xml.getAttribute('width')) || ((_parsed$xml$viewBox = parsed.xml.viewBox) === null || _parsed$xml$viewBox === void 0 || (_parsed$xml$viewBox = _parsed$xml$viewBox.animVal) === null || _parsed$xml$viewBox === void 0 ? void 0 : _parsed$xml$viewBox.width) || 0,
538
+ svgHeight: parseFloat(parsed.xml.getAttribute('height')) || ((_parsed$xml$viewBox2 = parsed.xml.viewBox) === null || _parsed$xml$viewBox2 === void 0 || (_parsed$xml$viewBox2 = _parsed$xml$viewBox2.animVal) === null || _parsed$xml$viewBox2 === void 0 ? void 0 : _parsed$xml$viewBox2.height) || 0,
539
+ reverse: !parseFloat(parsed.xml.getAttribute('height'))
540
+ });
541
+ case 4:
542
+ _context.prev = 4;
543
+ _t = _context["catch"](0);
544
+ console.error('Failed to load SVG:', url, _t);
545
+ return _context.abrupt("return", null);
546
+ case 5:
547
+ case "end":
548
+ return _context.stop();
549
+ }
550
+ }, _callee, null, [[0, 4]]);
551
+ }))();
552
+ __svgCache.set(url, p);
553
+ return _context2.abrupt("return", p);
554
+ case 3:
476
555
  case "end":
477
- return _context.stop();
556
+ return _context2.stop();
478
557
  }
479
- }, _callee, null, [[1, 5]]);
558
+ }, _callee2);
480
559
  }));
481
560
  return function loadSVGsByItem(_x4) {
482
561
  return _ref.apply(this, arguments);
@@ -486,64 +565,121 @@ function addItemToCatalog(_x5, _x6, _x7, _x8) {
486
565
  return _addItemToCatalog.apply(this, arguments);
487
566
  } // Get attributs of current selected element
488
567
  function _addItemToCatalog() {
489
- _addItemToCatalog = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(element, state, catalogInstance, projectActions) {
490
- var _element, _element2;
491
- var elementJs, catalog, outlineSVGData, _element$structure_js, _element$structure_js2, _element$structure_js3, updatedStructureJson;
492
- return _regenerator["default"].wrap(function (_context5) {
493
- while (1) switch (_context5.prev = _context5.next) {
568
+ _addItemToCatalog = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6(element, state, catalogInstance, projectActions) {
569
+ var _elementJs, _elementJs3;
570
+ var elementJs, outlineSVGData, _state$getIn, _elementJs$structure_, _elementJs$structure_2, _elementJs$structure_3, cds, _cds$find, _elementJs2, currentCdsId, cdsIdx, ttph, updatedStructureJson, catalogElements, catalogElementKeys, catalogItem, k, _catalogElements$cata, tempPlaceholderArray, _catalogItem$structur, newTempPlaceholderArray, mergedTempPlaceholder;
571
+ return _regenerator["default"].wrap(function (_context7) {
572
+ while (1) switch (_context7.prev = _context7.next) {
494
573
  case 0:
495
- if (!(0, _helper.isEmpty)((_element = element) === null || _element === void 0 ? void 0 : _element.name)) {
496
- _context5.next = 1;
574
+ if (!(0, _helper.isEmpty)(element === null || element === void 0 ? void 0 : element.name)) {
575
+ _context7.next = 1;
497
576
  break;
498
577
  }
499
- return _context5.abrupt("return");
578
+ return _context7.abrupt("return");
500
579
  case 1:
501
- elementJs = element;
502
- catalog = state.getIn(['catalog']).toJS(); // add item to catalog of state
503
- // if (isEmpty(catalog?.elements[element.name])) {
504
- _context5.next = 2;
505
- return loadSVGsByItem(element);
580
+ // clone element
581
+ elementJs = Object.assign({}, element); // if (isEmpty(catalog?.elements[element.name])) {
582
+ _context7.next = 2;
583
+ return loadSVGsByItem(elementJs);
506
584
  case 2:
507
- outlineSVGData = _context5.sent;
508
- if (!(((_element2 = element) === null || _element2 === void 0 ? void 0 : _element2.type) === 'cabinet')) {
509
- _context5.next = 4;
585
+ outlineSVGData = _context7.sent;
586
+ if (!(((_elementJs = elementJs) === null || _elementJs === void 0 ? void 0 : _elementJs.type) === 'cabinet')) {
587
+ _context7.next = 4;
510
588
  break;
511
589
  }
590
+ // move the tempPlaceholder of current door style to first of tempPlaceholders array
591
+ cds = (_state$getIn = state.getIn(['scene', 'layers', 'layer-1', 'doorStyle'])) === null || _state$getIn === void 0 ? void 0 : _state$getIn.cds;
592
+ if (cds) {
593
+ currentCdsId = (_cds$find = cds.find(function (c) {
594
+ return c.itemID === elementJs.itemID;
595
+ })) === null || _cds$find === void 0 ? void 0 : _cds$find.cabinet_door_style_id;
596
+ cdsIdx = (_elementJs2 = elementJs) === null || _elementJs2 === void 0 || (_elementJs2 = _elementJs2.structure_json) === null || _elementJs2 === void 0 || (_elementJs2 = _elementJs2.tempPlaceholders) === null || _elementJs2 === void 0 ? void 0 : _elementJs2.findIndex(function (tph) {
597
+ return tph.id === currentCdsId;
598
+ }); // swap
599
+ if (currentCdsId && cdsIdx >= 0) {
600
+ ttph = elementJs.structure_json.tempPlaceholders[0];
601
+ elementJs.structure_json.tempPlaceholders[0] = elementJs.structure_json.tempPlaceholders[cdsIdx];
602
+ elementJs.structure_json.tempPlaceholders[cdsIdx] = ttph;
603
+ }
604
+ }
512
605
  // make placeholders of element and tempPlaceholder
513
- updatedStructureJson = _objectSpread(_objectSpread({}, element.structure_json), (_element$structure_js = (_element$structure_js2 = element.structure_json) === null || _element$structure_js2 === void 0 || (_element$structure_js2 = _element$structure_js2.tempPlaceholders[0]) === null || _element$structure_js2 === void 0 ? void 0 : _element$structure_js2.structure) !== null && _element$structure_js !== void 0 ? _element$structure_js : {});
514
- element.structure_json = updatedStructureJson;
515
- element = _objectSpread(_objectSpread({}, element), {}, {
606
+ updatedStructureJson = _objectSpread(_objectSpread({}, elementJs.structure_json), (_elementJs$structure_ = (_elementJs$structure_2 = elementJs.structure_json) === null || _elementJs$structure_2 === void 0 || (_elementJs$structure_2 = _elementJs$structure_2.tempPlaceholders[0]) === null || _elementJs$structure_2 === void 0 ? void 0 : _elementJs$structure_2.structure) !== null && _elementJs$structure_ !== void 0 ? _elementJs$structure_ : {});
607
+ elementJs.structure_json = updatedStructureJson;
608
+ elementJs = _objectSpread(_objectSpread({}, elementJs), {}, {
516
609
  cds: {
517
- data: [_objectSpread({}, element.customer_property)],
518
- itemID: element.itemID
610
+ data: [_objectSpread({}, elementJs.customer_property)],
611
+ itemID: elementJs.itemID
519
612
  }
520
613
  });
521
- if ((0, _helper.isEmpty)((_element$structure_js3 = element.structure_json) === null || _element$structure_js3 === void 0 ? void 0 : _element$structure_js3.tempPlaceholders)) {
522
- _context5.next = 4;
614
+ if ((0, _helper.isEmpty)((_elementJs$structure_3 = elementJs.structure_json) === null || _elementJs$structure_3 === void 0 ? void 0 : _elementJs$structure_3.tempPlaceholders)) {
615
+ _context7.next = 4;
523
616
  break;
524
617
  }
525
- _context5.next = 3;
526
- return updateCabinetPayload(element);
618
+ _context7.next = 3;
619
+ return updateCabinetPayload(elementJs);
527
620
  case 3:
528
- elementJs = _context5.sent;
621
+ elementJs = _context7.sent;
529
622
  case 4:
530
623
  elementJs = _objectSpread(_objectSpread({}, elementJs), {}, {
531
624
  outlineSVGData: outlineSVGData,
532
- type: element.type,
625
+ type: elementJs.type,
533
626
  render2DItem: _itemLoader.render2DItem
534
627
  });
535
- if (element.type === 'appliance' || element.type === 'furnishing') elementJs.render3DItem = _itemLoader.render3DApplianceItem;else if (element.type === 'lighting') elementJs.render3DItem = _itemLoader.render3DLightingItem;else elementJs.render3DItem = _itemLoader.render3DItem;
628
+ if (elementJs.type === 'appliance' || elementJs.type === 'furnishing') elementJs.render3DItem = _itemLoader.render3DApplianceItem;else if (elementJs.type === 'lighting') elementJs.render3DItem = _itemLoader.render3DLightingItem;else elementJs.render3DItem = _itemLoader.render3DItem;
629
+
630
+ /***** join new tempPlaceholder to the old element - start *****/
631
+ // get catalog item by itemID
632
+ catalogElements = state.getIn(['catalog', 'elements']).toJS();
633
+ catalogElementKeys = Object.keys(catalogElements);
634
+ catalogItem = null;
635
+ k = 0;
636
+ case 5:
637
+ if (!(k < catalogElementKeys.length)) {
638
+ _context7.next = 7;
639
+ break;
640
+ }
641
+ if (!(((_catalogElements$cata = catalogElements[catalogElementKeys[k]]) === null || _catalogElements$cata === void 0 ? void 0 : _catalogElements$cata.itemID) === elementJs.itemID)) {
642
+ _context7.next = 6;
643
+ break;
644
+ }
645
+ catalogItem = catalogElements[catalogElementKeys[k]];
646
+ return _context7.abrupt("continue", 7);
647
+ case 6:
648
+ k++;
649
+ _context7.next = 5;
650
+ break;
651
+ case 7:
652
+ // get old tempPlaceholder array from catalog item
653
+ tempPlaceholderArray = null;
654
+ if (!(0, _helper.isEmpty)(catalogItem)) {
655
+ tempPlaceholderArray = (_catalogItem$structur = catalogItem.structure_json) === null || _catalogItem$structur === void 0 ? void 0 : _catalogItem$structur.tempPlaceholders;
656
+ }
657
+
658
+ // join new tempPlaceholder array to old one
659
+ newTempPlaceholderArray = [];
660
+ (_elementJs3 = elementJs) === null || _elementJs3 === void 0 || (_elementJs3 = _elementJs3.structure_json) === null || _elementJs3 === void 0 || (_elementJs3 = _elementJs3.tempPlaceholders) === null || _elementJs3 === void 0 || _elementJs3.forEach(function (tph) {
661
+ var _tempPlaceholderArray;
662
+ if (!((_tempPlaceholderArray = tempPlaceholderArray) !== null && _tempPlaceholderArray !== void 0 && _tempPlaceholderArray.some(function (otph) {
663
+ return otph.id === tph.id;
664
+ }))) newTempPlaceholderArray.push(tph);
665
+ });
666
+ mergedTempPlaceholder = null;
667
+ if ((0, _helper.isEmpty)(tempPlaceholderArray)) mergedTempPlaceholder = newTempPlaceholderArray;else if ((0, _helper.isEmpty)(newTempPlaceholderArray)) mergedTempPlaceholder = tempPlaceholderArray;else mergedTempPlaceholder = [].concat((0, _toConsumableArray2["default"])(tempPlaceholderArray), newTempPlaceholderArray);
668
+
669
+ // rplace new array to the elementJS
670
+ if (!(0, _helper.isEmpty)(mergedTempPlaceholder)) elementJs.structure_json.tempPlaceholders = mergedTempPlaceholder;
671
+ /***** join new tempPlaceholder to the old element - end *****/
672
+
536
673
  elementJs = (0, _exporter["default"])(elementJs);
537
674
  if (catalogInstance !== null && catalogInstance !== void 0 && catalogInstance.validateElement(elementJs)) {
538
675
  catalogInstance.registerElement(elementJs);
539
676
  projectActions.addElementToCatalog(elementJs);
540
677
  }
541
- // }
542
- case 5:
678
+ case 8:
543
679
  case "end":
544
- return _context5.stop();
680
+ return _context7.stop();
545
681
  }
546
- }, _callee5);
682
+ }, _callee6);
547
683
  }));
548
684
  return _addItemToCatalog.apply(this, arguments);
549
685
  }
@@ -676,6 +812,8 @@ function initPropData(element, catalog) {
676
812
  function updateAttributeOfSelectedElement(element, attrPayload, state, layer, catalog, projectActions) {
677
813
  var _attributesFormData;
678
814
  var callback = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
815
+ var layerID = state.scene.selectedLayer;
816
+ var layerUnit = state.getIn(['scene', 'layers', layerID, 'unit']);
679
817
  var attributesFormData = initAttrData(element, layer, state);
680
818
  var value = attrPayload.value;
681
819
  var attributeName = attrPayload.attributeName;
@@ -683,28 +821,8 @@ function updateAttributeOfSelectedElement(element, attrPayload, state, layer, ca
683
821
  if (attributeName === _constants.ATT_ITEM_POS) {
684
822
  // calculate the new position of movement
685
823
  var rotRad = (value.directionAng + element.rotation) / 180 * Math.PI;
686
- var newX = element.x + (0, _convertUnitsLite.convert)((value.oldDistance - value.newDistance) * Math.cos(rotRad)).from('in').to('cm');
687
- var newY = element.y + (0, _convertUnitsLite.convert)((value.oldDistance - value.newDistance) * Math.sin(rotRad)).from('in').to('cm');
688
- // const reversedDirection =
689
- // value.directionAng === LEFT_DIST_ANG
690
- // ? RIGHT_DIST_ANG
691
- // : value.directionAng === RIGHT_DIST_ANG
692
- // ? LEFT_DIST_ANG
693
- // : value.directionAng === BACK_DIST_ANG
694
- // ? FRONT_DIST_ANG
695
- // : BACK_DIST_ANG;
696
- // let dist = convert(
697
- // element.distArray?.find(v => v[1] === reversedDirection)
698
- // ? element.distArray?.find(v => v[1] === reversedDirection)[0]
699
- // : 0
700
- // )
701
- // .from('cm')
702
- // .to('in');
703
- // if (dist + (value.oldDistance - value.newDistance) <= 0 || value.newDistance < 0) {
704
- // // confirm "The item will be placed outside the floor plan. Are you sure?"
705
- // setPopupOpen(true);
706
- // return;
707
- // }
824
+ var newX = element.x + (0, _convertUnitsLite.convert)((value.oldDistance - value.newDistance) * Math.cos(rotRad)).from(layerUnit).to('cm');
825
+ var newY = element.y + (0, _convertUnitsLite.convert)((value.oldDistance - value.newDistance) * Math.sin(rotRad)).from(layerUnit).to('cm');
708
826
  value = {
709
827
  x: newX,
710
828
  y: newY
@@ -713,8 +831,8 @@ function updateAttributeOfSelectedElement(element, attrPayload, state, layer, ca
713
831
  var att = attributesFormData.has(attributeName) ? attributesFormData.get(attributeName) : element[attributeName];
714
832
  if (att) value = att.merge({
715
833
  _length: value,
716
- _unit: _constants.UNIT_INCH,
717
- length: (0, _convertUnitsLite.convert)(value).from(_constants.UNIT_INCH).to(_constants.UNIT_CENTIMETER)
834
+ _unit: layerUnit,
835
+ length: (0, _convertUnitsLite.convert)(value).from(layerUnit).to(_constants.UNIT_CENTIMETER)
718
836
  });
719
837
  }
720
838
  // make the new attrivutes
@@ -728,11 +846,11 @@ function updateAttributeOfSelectedElement(element, attrPayload, state, layer, ca
728
846
  attributesFormData = attributesFormData.set('y', yVal);
729
847
  } else {
730
848
  attributesFormData = attributesFormData.set(attributeName, value);
731
- // update the distances from wall
732
- var _GeometryUtils$calcDi = _export.GeometryUtils.calcDistancesFromItemToWalls(attributesFormData, layer, catalog),
733
- PointArray = _GeometryUtils$calcDi.PointArray;
734
- attributesFormData = attributesFormData.set('distArray', PointArray);
735
849
  }
850
+ // update the distances from wall
851
+ var _GeometryUtils$calcDi = _export.GeometryUtils.calcDistancesFromItemToWalls(attributesFormData, layer),
852
+ PointArray = _GeometryUtils$calcDi.PointArray;
853
+ attributesFormData = attributesFormData.set('distArray', PointArray);
736
854
  break;
737
855
  }
738
856
  case 'lines':
@@ -949,11 +1067,11 @@ function loadMoldingSvg(_x1) {
949
1067
  return _loadMoldingSvg.apply(this, arguments);
950
1068
  }
951
1069
  function _loadMoldingSvg() {
952
- _loadMoldingSvg = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6(molding) {
953
- return _regenerator["default"].wrap(function (_context6) {
954
- while (1) switch (_context6.prev = _context6.next) {
1070
+ _loadMoldingSvg = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7(molding) {
1071
+ return _regenerator["default"].wrap(function (_context8) {
1072
+ while (1) switch (_context8.prev = _context8.next) {
955
1073
  case 0:
956
- return _context6.abrupt("return", new Promise(function (resolve, reject) {
1074
+ return _context8.abrupt("return", new Promise(function (resolve, reject) {
957
1075
  var url = molding === null || molding === void 0 ? void 0 : molding.shape_svg;
958
1076
  if (!url) {
959
1077
  // Skip if no SVG URL available
@@ -975,9 +1093,9 @@ function _loadMoldingSvg() {
975
1093
  }));
976
1094
  case 1:
977
1095
  case "end":
978
- return _context6.stop();
1096
+ return _context8.stop();
979
1097
  }
980
- }, _callee6);
1098
+ }, _callee7);
981
1099
  }));
982
1100
  return _loadMoldingSvg.apply(this, arguments);
983
1101
  }
@@ -1006,86 +1124,161 @@ function setFinishing(props, state, payload) {
1006
1124
  break;
1007
1125
  }
1008
1126
  }
1009
- function movePan2D3D(props, payload, state) {
1010
- var moveType = payload.moveType,
1011
- moveValue = payload.moveValue;
1012
- var value = state.getIn(['viewer2D']).toJS();
1013
- if (state.mode === _constants.MODE_IDLE) {
1014
- switch (moveType) {
1015
- case _constants.TOP:
1016
- value.f -= moveValue;
1017
- break;
1018
- case _constants.BOTTOM:
1019
- value.f += moveValue;
1020
- break;
1021
- case _constants.RIGHT:
1022
- value.e += moveValue;
1023
- break;
1024
- case _constants.LEFT:
1025
- value.e -= moveValue;
1026
- break;
1127
+ function moveAndRotatePan2D3D(eventType, props, payload, state) {
1128
+ if (eventType === _constants.EXTERNAL_EVENT_MOVE_PAN) {
1129
+ var moveType = payload.moveType,
1130
+ moveValue = payload.moveValue;
1131
+ var value = state.getIn(['viewer2D']).toJS();
1132
+ if (state.mode === _constants.MODE_IDLE) {
1133
+ switch (moveType) {
1134
+ case _constants.TOP:
1135
+ value.f -= moveValue;
1136
+ break;
1137
+ case _constants.BOTTOM:
1138
+ value.f += moveValue;
1139
+ break;
1140
+ case _constants.RIGHT:
1141
+ value.e += moveValue;
1142
+ break;
1143
+ case _constants.LEFT:
1144
+ value.e -= moveValue;
1145
+ break;
1146
+ }
1147
+ (0, _helper.updateViwer2D)(value, props.viewer2DActions);
1148
+ } else if (state.mode === _constants.MODE_IDLE_3D) {
1149
+ switch (moveType) {
1150
+ case _constants.TOP:
1151
+ window.interval = setTimeout(function () {
1152
+ window.tDKeyDown({
1153
+ keyCode: 38
1154
+ });
1155
+ }, 50);
1156
+ break;
1157
+ case _constants.BOTTOM:
1158
+ window.interval = setTimeout(function () {
1159
+ window.tDKeyDown({
1160
+ keyCode: 40
1161
+ });
1162
+ }, 50);
1163
+ break;
1164
+ case _constants.RIGHT:
1165
+ window.interval = setTimeout(function () {
1166
+ window.tDKeyDown({
1167
+ keyCode: 37
1168
+ });
1169
+ }, 50);
1170
+ break;
1171
+ case _constants.LEFT:
1172
+ window.interval = setTimeout(function () {
1173
+ window.tDKeyDown({
1174
+ keyCode: 39
1175
+ });
1176
+ }, 50);
1177
+ break;
1178
+ }
1027
1179
  }
1028
- (0, _helper.updateViwer2D)(value, props.viewer2DActions);
1029
- } else if (state.mode === _constants.MODE_IDLE_3D) {
1030
- switch (moveType) {
1180
+ } else if (eventType === _constants.EXTERNAL_EVENT_ROTATE_PAN) {
1181
+ var rotateType = payload.rotateType;
1182
+ switch (rotateType) {
1031
1183
  case _constants.TOP:
1032
1184
  window.interval = setTimeout(function () {
1033
- window.tDKeyDown({
1034
- keyCode: 38
1185
+ window.SPKeyDown({
1186
+ keyCode: 87
1035
1187
  });
1036
1188
  }, 50);
1037
1189
  break;
1038
1190
  case _constants.BOTTOM:
1039
1191
  window.interval = setTimeout(function () {
1040
- window.tDKeyDown({
1041
- keyCode: 40
1192
+ window.SPKeyDown({
1193
+ keyCode: 83
1042
1194
  });
1043
1195
  }, 50);
1044
1196
  break;
1045
1197
  case _constants.RIGHT:
1046
1198
  window.interval = setTimeout(function () {
1047
- window.tDKeyDown({
1048
- keyCode: 39
1199
+ window.SPKeyDown({
1200
+ keyCode: 68
1049
1201
  });
1050
1202
  }, 50);
1051
1203
  break;
1052
1204
  case _constants.LEFT:
1053
1205
  window.interval = setTimeout(function () {
1054
- window.tDKeyDown({
1055
- keyCode: 37
1206
+ window.SPKeyDown({
1207
+ keyCode: 65
1056
1208
  });
1057
1209
  }, 50);
1058
1210
  break;
1059
1211
  }
1060
1212
  }
1061
1213
  }
1214
+ function mergeSameElements(projectItemsCatalog) {
1215
+ var result = [];
1216
+ var _loop = function _loop(i) {
1217
+ var idx = result.findIndex(function (v) {
1218
+ return v.itemID === projectItemsCatalog[i].itemID;
1219
+ });
1220
+ if (idx < 0) result.push(projectItemsCatalog[i]);else {
1221
+ var _loop2 = function _loop2(j) {
1222
+ var _result$idx$structure, _result$idx$structure2;
1223
+ var idx2 = (_result$idx$structure = result[idx].structure_json) === null || _result$idx$structure === void 0 || (_result$idx$structure = _result$idx$structure.tempPlaceholders) === null || _result$idx$structure === void 0 ? void 0 : _result$idx$structure.findIndex(function (v) {
1224
+ return v.id === projectItemsCatalog[i].structure_json.tempPlaceholders[j].id;
1225
+ });
1226
+ if (idx2 < 0) (_result$idx$structure2 = result[idx].structure_json) === null || _result$idx$structure2 === void 0 || (_result$idx$structure2 = _result$idx$structure2.tempPlaceholders) === null || _result$idx$structure2 === void 0 || _result$idx$structure2.push(projectItemsCatalog[i].structure_json.tempPlaceholders[j]);else result[idx].structure_json.tempPlaceholders[idx2] = projectItemsCatalog[i].structure_json.tempPlaceholders[j];
1227
+ };
1228
+ for (var j = 0; j < ((_projectItemsCatalog$ = projectItemsCatalog[i].structure_json) === null || _projectItemsCatalog$ === void 0 || (_projectItemsCatalog$ = _projectItemsCatalog$.tempPlaceholders) === null || _projectItemsCatalog$ === void 0 ? void 0 : _projectItemsCatalog$.length); j++) {
1229
+ var _projectItemsCatalog$;
1230
+ _loop2(j);
1231
+ }
1232
+ }
1233
+ };
1234
+ for (var i = 0; i < (projectItemsCatalog === null || projectItemsCatalog === void 0 ? void 0 : projectItemsCatalog.length); i++) {
1235
+ _loop(i);
1236
+ }
1237
+ return result;
1238
+ }
1062
1239
  function handleExternalEvent(_x10) {
1063
1240
  return _handleExternalEvent.apply(this, arguments);
1064
1241
  }
1065
1242
  function _handleExternalEvent() {
1066
- _handleExternalEvent = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee9(props) {
1243
+ _handleExternalEvent = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee0(props) {
1067
1244
  var _evt$payload3, _evt$payload4;
1068
- var evt, state, _evt$payload, cdsItems, itemKeys, _loop3, i, _props$onInternalEven, sLineCnt, element, _state$viewer2D, _evt$payload$initialP, mouseX, mouseY, v2d, vPosX, vPosY, layerID, defaulTitle, _Object$keys, _evt$payload5, doorStyle, itemCDS, isAll, layerId, _cdsItems, allItems, selectedItemId, _itemKeys, _loop4, _i2, _props$onInternalEven2, _evt$payload6, roomShapeType, width, height, _doorStyle, value, _value, _evt$payload7, moldingInfo, isGlobal, distElement, _distElement, _evt$payload8, option, _value2, _layerId, layer, _layer$getIn, selectedLines, selectedHoles, selectedItems, _i4, _i5, _i6, _evt$payload9, _evt$payload0, _evt$payload1, _evt$payload10, _layerID, _layer, orginalItemInfo, originalItem, originalItemPos, replaceItem, _props$onInternalEven3, _t5;
1069
- return _regenerator["default"].wrap(function (_context1) {
1070
- while (1) switch (_context1.prev = _context1.next) {
1245
+ var evt, state, layerId, layer, _evt$payload, _state$catalog, cdsItems, itemKeys, _loop6, i, newScene, tempState, _props$onInternalEven, sLineCnt, element, _state$viewer2D, _evt$payload$initialP, mouseX, mouseY, v2d, vPosX, vPosY, layerID, defaulTitle, _Object$keys, _evt$payload5, doorStyle, itemCDS, isAll, _layerId, _cdsItems, allItems, selectedItemId, _itemKeys, _loop7, _i2, _props$onInternalEven2, _evt$payload6, roomShapeType, width, height, measurementUnit, _doorStyle, value, _value, _evt$payload7, moldingInfo, isGlobal, distElement, _distElement, _evt$payload8, option, _value2, _layerId2, _layer, _layer$getIn, selectedLines, selectedHoles, selectedItems, _i4, _i5, _i6, _evt$payload9, _evt$payload0, _evt$payload1, _evt$payload10, _layerID, _layer2, orginalItemInfo, originalItem, originalItemPos, replaceItem, _props$onInternalEven3, sceneData, currentTexture, _t5, _t6;
1246
+ return _regenerator["default"].wrap(function (_context11) {
1247
+ while (1) switch (_context11.prev = _context11.next) {
1071
1248
  case 0:
1072
- // console.log('***external event****', props);
1249
+ // console.log('***external event****', props.externalEvent);
1073
1250
  evt = props.externalEvent;
1074
- state = props.state.get('KitchenConfigurator');
1251
+ state = getPlannerStateFromProps(props);
1252
+ if (state) {
1253
+ _context11.next = 1;
1254
+ break;
1255
+ }
1256
+ return _context11.abrupt("return");
1257
+ case 1:
1258
+ layerId = state.getIn(['scene', 'selectedLayer']);
1259
+ layer = state.getIn(['scene', 'layers', layerId]);
1075
1260
  _t5 = evt === null || evt === void 0 ? void 0 : evt.type;
1076
- _context1.next = _t5 === _constants.EXTERNAL_EVENT_LOAD_PROJECT ? 1 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_3D ? 5 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_2D ? 6 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 7 : _t5 === _constants.EXTERNAL_EVENT_ADD_WALL ? 8 : _t5 === _constants.EXTERNAL_EVENT_ADD_ITEM ? 9 : _t5 === _constants.EXTERNAL_EVENT_ADD_HOLE ? 12 : _t5 === _constants.EXTERNAL_EVENT_MOVE_PAN ? 13 : _t5 === _constants.EXTERNAL_EVENT_NEW_PROJECT ? 14 : _t5 === _constants.EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 15 : _t5 === _constants.EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 19 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_IN ? 20 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_OUT ? 21 : _t5 === _constants.EXTERNAL_EVENT_CENTERING_2D ? 22 : _t5 === _constants.EXTERNAL_EVENT_UNDO ? 23 : _t5 === _constants.EXTERNAL_EVENT_REDO ? 24 : _t5 === _constants.EXTERNAL_EVENT_SET_MOLDING ? 25 : _t5 === _constants.EXTERNAL_EVENT_DUPLICATE_ELEMENT ? 27 : _t5 === _constants.EXTERNAL_EVENT_DELETE_ELEMENT ? 28 : _t5 === _constants.EXTERNAL_EVENT_PROJECT_SETTING ? 29 : _t5 === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? 30 : _t5 === _constants.EXTERNAL_EVENT_UPDATE_PROPERTY ? 30 : _t5 === _constants.EXTERNAL_EVENT_REPLACE_CABINET ? 31 : _t5 === _constants.EXTERNAL_EVENT_SET_FINISHING ? 33 : _t5 === _constants.EXTERNAL_EVENT_SYNC_SCENE ? 34 : 35;
1261
+ _context11.next = _t5 === _constants.EXTERNAL_EVENT_LOAD_PROJECT ? 2 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_3D ? 7 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_2D ? 8 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 9 : _t5 === _constants.EXTERNAL_EVENT_ADD_WALL ? 10 : _t5 === _constants.EXTERNAL_EVENT_ADD_ITEM ? 11 : _t5 === _constants.EXTERNAL_EVENT_ADD_HOLE ? 14 : _t5 === _constants.EXTERNAL_EVENT_ROTATE_PAN ? 15 : _t5 === _constants.EXTERNAL_EVENT_MOVE_PAN ? 15 : _t5 === _constants.EXTERNAL_EVENT_NEW_PROJECT ? 16 : _t5 === _constants.EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 17 : _t5 === _constants.EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 21 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_IN ? 22 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_OUT ? 23 : _t5 === _constants.EXTERNAL_EVENT_CENTERING_2D ? 24 : _t5 === _constants.EXTERNAL_EVENT_UNDO ? 25 : _t5 === _constants.EXTERNAL_EVENT_REDO ? 26 : _t5 === _constants.EXTERNAL_EVENT_SET_MOLDING ? 27 : _t5 === _constants.EXTERNAL_EVENT_DUPLICATE_ELEMENT ? 29 : _t5 === _constants.EXTERNAL_EVENT_DELETE_ELEMENT ? 30 : _t5 === _constants.EXTERNAL_EVENT_PROJECT_SETTING ? 31 : _t5 === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? 40 : _t5 === _constants.EXTERNAL_EVENT_UPDATE_PROPERTY ? 40 : _t5 === _constants.EXTERNAL_EVENT_REPLACE_CABINET ? 41 : _t5 === _constants.EXTERNAL_EVENT_SET_FINISHING ? 43 : _t5 === _constants.EXTERNAL_EVENT_SYNC_SCENE ? 44 : 45;
1077
1262
  break;
1078
- case 1:
1263
+ case 2:
1264
+ if (!(evt !== null && evt !== void 0 && evt.payload)) {
1265
+ _context11.next = 6;
1266
+ break;
1267
+ }
1079
1268
  // prepare item data request
1080
1269
  cdsItems = [];
1081
1270
  itemKeys = Object.keys(evt === null || evt === void 0 || (_evt$payload = evt.payload) === null || _evt$payload === void 0 || (_evt$payload = _evt$payload.layers['layer-1']) === null || _evt$payload === void 0 ? void 0 : _evt$payload.items) || [];
1082
- _loop3 = /*#__PURE__*/_regenerator["default"].mark(function _loop3() {
1083
- var _evt$payload2, _it$doorStyle2;
1271
+ _loop6 = /*#__PURE__*/_regenerator["default"].mark(function _loop6() {
1272
+ var _evt$payload2, _it$properties, _it$properties2, _it$properties3, _it$doorStyle2;
1084
1273
  var it;
1085
- return _regenerator["default"].wrap(function (_context8) {
1086
- while (1) switch (_context8.prev = _context8.next) {
1274
+ return _regenerator["default"].wrap(function (_context0) {
1275
+ while (1) switch (_context0.prev = _context0.next) {
1087
1276
  case 0:
1088
- it = evt === null || evt === void 0 || (_evt$payload2 = evt.payload) === null || _evt$payload2 === void 0 || (_evt$payload2 = _evt$payload2.layers['layer-1']) === null || _evt$payload2 === void 0 ? void 0 : _evt$payload2.items[itemKeys[i]];
1277
+ it = evt === null || evt === void 0 || (_evt$payload2 = evt.payload) === null || _evt$payload2 === void 0 || (_evt$payload2 = _evt$payload2.layers['layer-1']) === null || _evt$payload2 === void 0 ? void 0 : _evt$payload2.items[itemKeys[i]]; //////// check altitude of item property and change length from _length (convert length from 'in' fo 'cm')
1278
+ if (it !== null && it !== void 0 && (_it$properties = it.properties) !== null && _it$properties !== void 0 && (_it$properties = _it$properties.altitude) !== null && _it$properties !== void 0 && _it$properties.length && it !== null && it !== void 0 && (_it$properties2 = it.properties) !== null && _it$properties2 !== void 0 && (_it$properties2 = _it$properties2.altitude) !== null && _it$properties2 !== void 0 && _it$properties2._unit && it !== null && it !== void 0 && (_it$properties3 = it.properties) !== null && _it$properties3 !== void 0 && (_it$properties3 = _it$properties3.altitude) !== null && _it$properties3 !== void 0 && _it$properties3._length && it.properties.altitude.length !== (0, _convertUnitsLite.convert)(it.properties.altitude._length).from(it.properties.altitude._unit).to('cm')) {
1279
+ it.properties.altitude.length = (0, _convertUnitsLite.convert)(it.properties.altitude._length).from(it.properties.altitude._unit).to('cm');
1280
+ }
1281
+ /////////
1089
1282
  if (!cdsItems.some(function (v) {
1090
1283
  var _it$doorStyle;
1091
1284
  return it.itemID === v.itemID && it.name === v.name && ((_it$doorStyle = it.doorStyle) === null || _it$doorStyle === void 0 || (_it$doorStyle = _it$doorStyle.doorStyles) === null || _it$doorStyle === void 0 ? void 0 : _it$doorStyle.cabinet_door_style_id) === v.cdsId;
@@ -1100,23 +1293,27 @@ function _handleExternalEvent() {
1100
1293
  });
1101
1294
  case 1:
1102
1295
  case "end":
1103
- return _context8.stop();
1296
+ return _context0.stop();
1104
1297
  }
1105
- }, _loop3);
1298
+ }, _loop6);
1106
1299
  });
1107
1300
  i = 0;
1108
- case 2:
1301
+ case 3:
1109
1302
  if (!(i < itemKeys.length)) {
1110
- _context1.next = 4;
1303
+ _context11.next = 5;
1111
1304
  break;
1112
1305
  }
1113
- return _context1.delegateYield(_loop3(), "t0", 3);
1114
- case 3:
1306
+ return _context11.delegateYield(_loop6(), "t0", 4);
1307
+ case 4:
1115
1308
  i++;
1116
- _context1.next = 2;
1309
+ _context11.next = 3;
1117
1310
  break;
1118
- case 4:
1119
- // request item catalog data to host app
1311
+ case 5:
1312
+ newScene = new _models.Scene(evt === null || evt === void 0 ? void 0 : evt.payload);
1313
+ tempState = new _models.State({
1314
+ scene: newScene.toJS(),
1315
+ catalog: (_state$catalog = state.catalog) === null || _state$catalog === void 0 ? void 0 : _state$catalog.toJS()
1316
+ }); // request item catalog data to host app
1120
1317
  if (cdsItems.length > 0) {
1121
1318
  (_props$onInternalEven = props.onInternalEvent) === null || _props$onInternalEven === void 0 || _props$onInternalEven.call(props, {
1122
1319
  type: _constants.INTERNAL_EVENT_ITEMS_CATALOG,
@@ -1124,62 +1321,65 @@ function _handleExternalEvent() {
1124
1321
  cdsItems: cdsItems
1125
1322
  }
1126
1323
  }, /*#__PURE__*/function () {
1127
- var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7(result) {
1128
- var _i, _result$elements;
1129
- return _regenerator["default"].wrap(function (_context7) {
1130
- while (1) switch (_context7.prev = _context7.next) {
1324
+ var _ref3 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee8(result) {
1325
+ var rt, _i;
1326
+ return _regenerator["default"].wrap(function (_context9) {
1327
+ while (1) switch (_context9.prev = _context9.next) {
1131
1328
  case 0:
1329
+ rt = mergeSameElements(result === null || result === void 0 ? void 0 : result.elements);
1132
1330
  _i = 0;
1133
1331
  case 1:
1134
- if (!(_i < (result === null || result === void 0 || (_result$elements = result.elements) === null || _result$elements === void 0 ? void 0 : _result$elements.length))) {
1135
- _context7.next = 3;
1332
+ if (!(_i < (rt === null || rt === void 0 ? void 0 : rt.length))) {
1333
+ _context9.next = 3;
1136
1334
  break;
1137
1335
  }
1138
- _context7.next = 2;
1139
- return addItemToCatalog(result.elements[_i], state, props.catalog, props.projectActions);
1336
+ _context9.next = 2;
1337
+ return addItemToCatalog(rt[_i], tempState, props.catalog, props.projectActions);
1140
1338
  case 2:
1141
1339
  _i++;
1142
- _context7.next = 1;
1340
+ _context9.next = 1;
1143
1341
  break;
1144
1342
  case 3:
1145
1343
  props.projectActions.loadProject(evt.payload);
1146
1344
  case 4:
1147
1345
  case "end":
1148
- return _context7.stop();
1346
+ return _context9.stop();
1149
1347
  }
1150
- }, _callee7);
1348
+ }, _callee8);
1151
1349
  }));
1152
1350
  return function (_x11) {
1153
- return _ref2.apply(this, arguments);
1351
+ return _ref3.apply(this, arguments);
1154
1352
  };
1155
1353
  }());
1156
- }
1157
- return _context1.abrupt("continue", 35);
1158
- case 5:
1159
- props.projectActions.setMode(_constants.MODE_IDLE_3D);
1160
- return _context1.abrupt("continue", 35);
1354
+ } else props.projectActions.loadProject(evt.payload);
1161
1355
  case 6:
1162
- props.projectActions.setMode(_constants.MODE_IDLE);
1163
- return _context1.abrupt("continue", 35);
1356
+ return _context11.abrupt("continue", 45);
1164
1357
  case 7:
1165
- sLineCnt = state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size;
1166
- if (sLineCnt > 0) props.projectActions.setMode(_constants.MODE_ELEVATION_VIEW);
1167
- return _context1.abrupt("continue", 35);
1358
+ props.projectActions.unselectAll();
1359
+ props.projectActions.setMode(_constants.MODE_IDLE_3D);
1360
+ return _context11.abrupt("continue", 45);
1168
1361
  case 8:
1362
+ props.projectActions.setMode(_constants.MODE_IDLE);
1363
+ return _context11.abrupt("continue", 45);
1364
+ case 9:
1365
+ sLineCnt = layer.selected.lines.size;
1366
+ if (sLineCnt > 0) props.projectActions.setMode(_constants.MODE_ELEVATION_VIEW);
1367
+ return _context11.abrupt("continue", 45);
1368
+ case 10:
1169
1369
  if (state.mode === _constants.MODE_IDLE || state.mode === _constants.MODE_2D_PAN) props.linesActions.selectToolDrawingLine('wall');else {
1170
1370
  props.projectActions.setMode(_constants.MODE_IDLE);
1171
1371
  props.linesActions.selectToolDrawingLine('wall');
1172
1372
  }
1173
- return _context1.abrupt("continue", 35);
1174
- case 9:
1373
+ return _context11.abrupt("continue", 45);
1374
+ case 11:
1175
1375
  if ((0, _helper.isEmpty)(evt === null || evt === void 0 ? void 0 : evt.payload)) {
1176
- _context1.next = 11;
1376
+ _context11.next = 13;
1177
1377
  break;
1178
1378
  }
1179
1379
  element = evt.payload;
1180
- _context1.next = 10;
1380
+ _context11.next = 12;
1181
1381
  return addItemToCatalog(element, state, props.catalog, props.projectActions);
1182
- case 10:
1382
+ case 12:
1183
1383
  // start drawing item
1184
1384
  if (_constants.ARRAY_3D_MODES.includes(state.mode)) {
1185
1385
  // in 3d view
@@ -1200,38 +1400,38 @@ function _handleExternalEvent() {
1200
1400
  }
1201
1401
  props.projectActions.pushLastSelectedCatalogElementToHistory(element);
1202
1402
  props.projectActions.setIsCabinetDrawing(true);
1203
- case 11:
1204
- return _context1.abrupt("continue", 35);
1205
- case 12:
1206
- _constants.ARRAY_3D_MODES.includes(state.mode) ? props.holesActions.selectToolDrawingHole3D(evt === null || evt === void 0 || (_evt$payload3 = evt.payload) === null || _evt$payload3 === void 0 ? void 0 : _evt$payload3.holeName) : props.holesActions.selectToolDrawingHole(evt === null || evt === void 0 || (_evt$payload4 = evt.payload) === null || _evt$payload4 === void 0 ? void 0 : _evt$payload4.holeName);
1207
- return _context1.abrupt("continue", 35);
1208
1403
  case 13:
1209
- movePan2D3D(props, evt.payload, state);
1210
- return _context1.abrupt("continue", 35);
1404
+ return _context11.abrupt("continue", 45);
1211
1405
  case 14:
1406
+ _constants.ARRAY_3D_MODES.includes(state.mode) ? props.holesActions.selectToolDrawingHole3D(evt === null || evt === void 0 || (_evt$payload3 = evt.payload) === null || _evt$payload3 === void 0 ? void 0 : _evt$payload3.holeName) : props.holesActions.selectToolDrawingHole(evt === null || evt === void 0 || (_evt$payload4 = evt.payload) === null || _evt$payload4 === void 0 ? void 0 : _evt$payload4.holeName);
1407
+ return _context11.abrupt("continue", 45);
1408
+ case 15:
1409
+ moveAndRotatePan2D3D(evt.type, props, evt.payload, state);
1410
+ return _context11.abrupt("continue", 45);
1411
+ case 16:
1212
1412
  defaulTitle = 'Untitle';
1213
1413
  props.projectActions.newProject();
1214
1414
  props.projectActions.rename(defaulTitle);
1215
- return _context1.abrupt("continue", 35);
1216
- case 15:
1415
+ return _context11.abrupt("continue", 45);
1416
+ case 17:
1217
1417
  _evt$payload5 = evt.payload, doorStyle = _evt$payload5.doorStyle, itemCDS = _evt$payload5.itemCDS, isAll = _evt$payload5.isAll; // prepare item data request
1218
- layerId = state.getIn(['scene', 'selectedLayer']);
1418
+ _layerId = state.getIn(['scene', 'selectedLayer']);
1219
1419
  _cdsItems = [];
1220
- allItems = state.getIn(['scene', 'layers', layerId, 'items']).toJS();
1221
- selectedItemId = state.getIn(['scene', 'layers', layerId]).selected.items.toJS()[0];
1420
+ allItems = state.getIn(['scene', 'layers', _layerId, 'items']).toJS();
1421
+ selectedItemId = state.getIn(['scene', 'layers', _layerId]).selected.items.toJS()[0];
1222
1422
  _itemKeys = isAll ? (_Object$keys = Object.keys(allItems)) !== null && _Object$keys !== void 0 ? _Object$keys : [] : [selectedItemId];
1223
- _loop4 = /*#__PURE__*/_regenerator["default"].mark(function _loop4() {
1423
+ _loop7 = /*#__PURE__*/_regenerator["default"].mark(function _loop7() {
1224
1424
  var _itemCDS$find;
1225
1425
  var item, cdsId;
1226
- return _regenerator["default"].wrap(function (_context0) {
1227
- while (1) switch (_context0.prev = _context0.next) {
1426
+ return _regenerator["default"].wrap(function (_context10) {
1427
+ while (1) switch (_context10.prev = _context10.next) {
1228
1428
  case 0:
1229
1429
  item = allItems[_itemKeys[_i2]];
1230
1430
  cdsId = (_itemCDS$find = itemCDS.find(function (itCDS) {
1231
1431
  return itCDS.itemID === item.itemID;
1232
1432
  })) === null || _itemCDS$find === void 0 ? void 0 : _itemCDS$find.cabinet_door_style_id;
1233
1433
  if (cdsId && !_cdsItems.some(function (v) {
1234
- return it.itemID === v.itemID && it.name === v.name && cdsId === v.cdsId;
1434
+ return item.itemID === v.itemID && item.name === v.name && cdsId === v.cdsId;
1235
1435
  })) _cdsItems.push({
1236
1436
  itemID: item.itemID,
1237
1437
  prototype: item.prototype,
@@ -1243,22 +1443,22 @@ function _handleExternalEvent() {
1243
1443
  });
1244
1444
  case 1:
1245
1445
  case "end":
1246
- return _context0.stop();
1446
+ return _context10.stop();
1247
1447
  }
1248
- }, _loop4);
1448
+ }, _loop7);
1249
1449
  });
1250
1450
  _i2 = 0;
1251
- case 16:
1451
+ case 18:
1252
1452
  if (!(_i2 < _itemKeys.length)) {
1253
- _context1.next = 18;
1453
+ _context11.next = 20;
1254
1454
  break;
1255
1455
  }
1256
- return _context1.delegateYield(_loop4(), "t1", 17);
1257
- case 17:
1456
+ return _context11.delegateYield(_loop7(), "t1", 19);
1457
+ case 19:
1258
1458
  _i2++;
1259
- _context1.next = 16;
1459
+ _context11.next = 18;
1260
1460
  break;
1261
- case 18:
1461
+ case 20:
1262
1462
  // request item catalog data to host app
1263
1463
  if (_cdsItems.length > 0) {
1264
1464
  (_props$onInternalEven2 = props.onInternalEvent) === null || _props$onInternalEven2 === void 0 || _props$onInternalEven2.call(props, {
@@ -1267,112 +1467,129 @@ function _handleExternalEvent() {
1267
1467
  cdsItems: _cdsItems
1268
1468
  }
1269
1469
  }, /*#__PURE__*/function () {
1270
- var _ref3 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee8(result) {
1271
- var _i3, _result$elements2;
1272
- return _regenerator["default"].wrap(function (_context9) {
1273
- while (1) switch (_context9.prev = _context9.next) {
1470
+ var _ref4 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee9(result) {
1471
+ var rt, _i3;
1472
+ return _regenerator["default"].wrap(function (_context1) {
1473
+ while (1) switch (_context1.prev = _context1.next) {
1274
1474
  case 0:
1475
+ rt = mergeSameElements(result === null || result === void 0 ? void 0 : result.elements);
1275
1476
  _i3 = 0;
1276
1477
  case 1:
1277
- if (!(_i3 < (result === null || result === void 0 || (_result$elements2 = result.elements) === null || _result$elements2 === void 0 ? void 0 : _result$elements2.length))) {
1278
- _context9.next = 3;
1478
+ if (!(_i3 < (rt === null || rt === void 0 ? void 0 : rt.length))) {
1479
+ _context1.next = 3;
1279
1480
  break;
1280
1481
  }
1281
- _context9.next = 2;
1282
- return addItemToCatalog(result.elements[_i3], state, props.catalog, props.projectActions);
1482
+ _context1.next = 2;
1483
+ return addItemToCatalog(rt[_i3], state, props.catalog, props.projectActions);
1283
1484
  case 2:
1284
1485
  _i3++;
1285
- _context9.next = 1;
1486
+ _context1.next = 1;
1286
1487
  break;
1287
1488
  case 3:
1288
1489
  props.itemsActions.setDoorStyle(doorStyle, itemCDS, isAll);
1289
1490
  case 4:
1290
1491
  case "end":
1291
- return _context9.stop();
1492
+ return _context1.stop();
1292
1493
  }
1293
- }, _callee8);
1494
+ }, _callee9);
1294
1495
  }));
1295
1496
  return function (_x12) {
1296
- return _ref3.apply(this, arguments);
1497
+ return _ref4.apply(this, arguments);
1297
1498
  };
1298
1499
  }());
1299
1500
  } else props.itemsActions.setDoorStyle(doorStyle, itemCDS, isAll);
1300
- return _context1.abrupt("continue", 35);
1301
- case 19:
1302
- _evt$payload6 = evt.payload, roomShapeType = _evt$payload6.roomShapeType, width = _evt$payload6.width, height = _evt$payload6.height, _doorStyle = _evt$payload6.doorStyle;
1303
- props.projectActions.createRoomWithShape(roomShapeType, width, height, _doorStyle);
1304
- return _context1.abrupt("continue", 35);
1305
- case 20:
1501
+ return _context11.abrupt("continue", 45);
1502
+ case 21:
1503
+ _evt$payload6 = evt.payload, roomShapeType = _evt$payload6.roomShapeType, width = _evt$payload6.width, height = _evt$payload6.height, measurementUnit = _evt$payload6.measurementUnit, _doorStyle = _evt$payload6.doorStyle;
1504
+ props.projectActions.createRoomWithShape(roomShapeType, width, height, measurementUnit, _doorStyle);
1505
+ return _context11.abrupt("continue", 45);
1506
+ case 22:
1306
1507
  value = state.getIn(['viewer2D']).toJS();
1307
1508
  value.a += 0.1;
1308
1509
  value.d += 0.1;
1309
1510
  value.e -= value.SVGWidth * 0.1 / 2;
1310
1511
  value.f -= value.SVGHeight * 0.1 / 2;
1311
1512
  (0, _helper.updateViwer2D)(value, props.viewer2DActions);
1312
- return _context1.abrupt("continue", 35);
1313
- case 21:
1513
+ return _context11.abrupt("continue", 45);
1514
+ case 23:
1314
1515
  _value = state.getIn(['viewer2D']).toJS();
1315
1516
  _value.a -= 0.1;
1316
1517
  _value.d -= 0.1;
1317
1518
  _value.e += _value.SVGWidth * 0.1 / 2;
1318
1519
  _value.f += _value.SVGHeight * 0.1 / 2;
1319
1520
  (0, _helper.updateViwer2D)(_value, props.viewer2DActions);
1320
- return _context1.abrupt("continue", 35);
1321
- case 22:
1521
+ return _context11.abrupt("continue", 45);
1522
+ case 24:
1322
1523
  (0, _helper.centering2D)(state, props.viewer2DActions);
1323
- return _context1.abrupt("continue", 35);
1324
- case 23:
1524
+ return _context11.abrupt("continue", 45);
1525
+ case 25:
1325
1526
  props.projectActions.undo();
1326
- return _context1.abrupt("continue", 35);
1327
- case 24:
1527
+ return _context11.abrupt("continue", 45);
1528
+ case 26:
1328
1529
  props.projectActions.redo();
1329
- return _context1.abrupt("continue", 35);
1330
- case 25:
1530
+ return _context11.abrupt("continue", 45);
1531
+ case 27:
1331
1532
  _evt$payload7 = evt.payload, moldingInfo = _evt$payload7.moldingInfo, isGlobal = _evt$payload7.isGlobal;
1332
- _context1.next = 26;
1533
+ _context11.next = 28;
1333
1534
  return loadMoldingSvg(moldingInfo);
1334
- case 26:
1535
+ case 28:
1335
1536
  props.itemsActions.setMolding(moldingInfo, isGlobal);
1336
- return _context1.abrupt("continue", 35);
1337
- case 27:
1537
+ return _context11.abrupt("continue", 45);
1538
+ case 29:
1338
1539
  distElement = getElement(evt.payload, state);
1339
1540
  if (distElement) props.itemsActions.duplicateSelected(distElement, props.onInternalEvent);
1340
- return _context1.abrupt("continue", 35);
1341
- case 28:
1541
+ return _context11.abrupt("continue", 45);
1542
+ case 30:
1342
1543
  _distElement = getElement(evt.payload, state);
1343
1544
  if (_distElement) props.projectActions.remove(_distElement);
1344
- return _context1.abrupt("continue", 35);
1345
- case 29:
1346
- _evt$payload8 = evt.payload, option = _evt$payload8.option, _value2 = _evt$payload8.value;
1347
- if (option === _constants.PROJECT_SETTING_OPTION.UPDATE_CEIL_HEIGHT) {
1348
- props.viewer2DActions.updateCeilHeight(_value2);
1349
- props.viewer3DActions.update3DCeilHeight(_value2);
1350
- } else if (option === _constants.PROJECT_SETTING_OPTION.CHANGE_WALL_LENGTH_MEASURE) {
1351
- props.viewer2DActions.changeWallLengthMeasure(_value2);
1352
- } else if (option === _constants.PROJECT_SETTING_OPTION.CHANGE_BASE_CABINET_MEASURE) {
1353
- props.viewer2DActions.changeBaseCabinetMeasure(_value2);
1354
- } else if (option === _constants.PROJECT_SETTING_OPTION.CHANGE_WALL_CABINET_MEASURE) {
1355
- props.viewer2DActions.changeWallCabinetMeasure(_value2);
1356
- } else if (option === _constants.PROJECT_SETTING_OPTION.CHANGE_WINDOW_DOOR_MEASURE) {
1357
- props.viewer2DActions.changeWindowDoorMeasure(_value2);
1358
- }
1359
- return _context1.abrupt("continue", 35);
1360
- case 30:
1361
- _layerId = state.getIn(['scene', 'selectedLayer']);
1362
- layer = state.getIn(['scene', 'layers', _layerId]);
1363
- _layer$getIn = layer.getIn(['selected']), selectedLines = _layer$getIn.lines, selectedHoles = _layer$getIn.holes, selectedItems = _layer$getIn.items;
1364
- for (_i4 = 0; _i4 < selectedLines.size; _i4++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['lines', selectedLines.get(_i4)]), evt.payload, state, layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(layer.getIn(['lines', selectedLines.get(_i4)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1365
- for (_i5 = 0; _i5 < selectedHoles.size; _i5++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['holes', selectedHoles.get(_i5)]), evt.payload, state, layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(layer.getIn(['holes', selectedHoles.get(_i5)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1366
- for (_i6 = 0; _i6 < selectedItems.size; _i6++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['items', selectedItems.get(_i6)]), evt.payload, state, layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(layer.getIn(['items', selectedItems.get(_i6)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1367
- return _context1.abrupt("continue", 35);
1545
+ return _context11.abrupt("continue", 45);
1368
1546
  case 31:
1547
+ _evt$payload8 = evt.payload, option = _evt$payload8.option, _value2 = _evt$payload8.value;
1548
+ _t6 = option;
1549
+ _context11.next = _t6 === _constants.PROJECT_SETTING_OPTION.CHANGE_MEASUREMENT_UNIT ? 32 : _t6 === _constants.PROJECT_SETTING_OPTION.UPDATE_CEIL_HEIGHT ? 33 : _t6 === _constants.PROJECT_SETTING_OPTION.CHANGE_WALL_LENGTH_MEASURE ? 34 : _t6 === _constants.PROJECT_SETTING_OPTION.CHANGE_BASE_CABINET_MEASURE ? 35 : _t6 === _constants.PROJECT_SETTING_OPTION.CHANGE_WALL_CABINET_MEASURE ? 36 : _t6 === _constants.PROJECT_SETTING_OPTION.CHANGE_WINDOW_DOOR_MEASURE ? 37 : 38;
1550
+ break;
1551
+ case 32:
1552
+ props.viewer2DActions.updateCeilHeight((0, _convertUnitsLite.convert)(layer.ceilHeight).from(layer.unit).to(_value2));
1553
+ props.viewer2DActions.updateCeilHeightUnit(_value2);
1554
+ props.viewer3DActions.update3DCeilHeightUnit(_value2);
1555
+ props.viewer3DActions.update3DCeilHeight((0, _convertUnitsLite.convert)(layer.ceilHeight).from(layer.unit).to(_value2));
1556
+ return _context11.abrupt("continue", 39);
1557
+ case 33:
1558
+ props.viewer2DActions.updateCeilHeight(_value2);
1559
+ props.viewer3DActions.update3DCeilHeight(_value2);
1560
+ return _context11.abrupt("continue", 39);
1561
+ case 34:
1562
+ props.viewer2DActions.changeWallLengthMeasure(_value2);
1563
+ return _context11.abrupt("continue", 39);
1564
+ case 35:
1565
+ props.viewer2DActions.changeBaseCabinetMeasure(_value2);
1566
+ return _context11.abrupt("continue", 39);
1567
+ case 36:
1568
+ props.viewer2DActions.changeWallCabinetMeasure(_value2);
1569
+ return _context11.abrupt("continue", 39);
1570
+ case 37:
1571
+ props.viewer2DActions.changeWindowDoorMeasure(_value2);
1572
+ return _context11.abrupt("continue", 39);
1573
+ case 38:
1574
+ return _context11.abrupt("continue", 39);
1575
+ case 39:
1576
+ return _context11.abrupt("continue", 45);
1577
+ case 40:
1578
+ _layerId2 = state.getIn(['scene', 'selectedLayer']);
1579
+ _layer = state.getIn(['scene', 'layers', _layerId2]);
1580
+ _layer$getIn = _layer.getIn(['selected']), selectedLines = _layer$getIn.lines, selectedHoles = _layer$getIn.holes, selectedItems = _layer$getIn.items;
1581
+ for (_i4 = 0; _i4 < selectedLines.size; _i4++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(_layer.getIn(['lines', selectedLines.get(_i4)]), evt.payload, state, _layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(_layer.getIn(['lines', selectedLines.get(_i4)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1582
+ for (_i5 = 0; _i5 < selectedHoles.size; _i5++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(_layer.getIn(['holes', selectedHoles.get(_i5)]), evt.payload, state, _layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(_layer.getIn(['holes', selectedHoles.get(_i5)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1583
+ for (_i6 = 0; _i6 < selectedItems.size; _i6++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(_layer.getIn(['items', selectedItems.get(_i6)]), evt.payload, state, _layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(_layer.getIn(['items', selectedItems.get(_i6)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1584
+ return _context11.abrupt("continue", 45);
1585
+ case 41:
1369
1586
  _layerID = state.scene.selectedLayer;
1370
- _layer = state.scene.getIn(['layers', _layerID]).toJS();
1587
+ _layer2 = state.scene.getIn(['layers', _layerID]).toJS();
1371
1588
  orginalItemInfo = evt === null || evt === void 0 || (_evt$payload9 = evt.payload) === null || _evt$payload9 === void 0 ? void 0 : _evt$payload9.orginalItemInfo;
1372
- originalItem = _layer === null || _layer === void 0 ? void 0 : _layer.items[orginalItemInfo.id];
1373
- _context1.next = 32;
1589
+ originalItem = _layer2 === null || _layer2 === void 0 ? void 0 : _layer2.items[orginalItemInfo.id];
1590
+ _context11.next = 42;
1374
1591
  return addItemToCatalog(evt.payload.replaceItemInfo, state, props.catalog, props.projectActions);
1375
- case 32:
1592
+ case 42:
1376
1593
  originalItemPos = {
1377
1594
  rotation: originalItem.rotation,
1378
1595
  selectedItemId: originalItem.id,
@@ -1387,23 +1604,27 @@ function _handleExternalEvent() {
1387
1604
  }
1388
1605
  };
1389
1606
  props.itemsActions.replaceItem(originalItemPos, originalItem, replaceItem);
1390
- return _context1.abrupt("continue", 35);
1391
- case 33:
1607
+ return _context11.abrupt("continue", 45);
1608
+ case 43:
1392
1609
  setFinishing(props, state, evt.payload);
1393
- case 34:
1610
+ return _context11.abrupt("continue", 45);
1611
+ case 44:
1612
+ sceneData = state.scene.toJS(); // get molding data for "ReviewForQuote"
1613
+ currentTexture = layer.doorStyle !== null || layer.doorStyle !== undefined ? layer.doorStyle : props.state.doorStyle.toJS();
1614
+ sceneData.layers[layerId].moldingData = (0, _molding.getMoldingDataOfScene2)(layer, props.catalog, currentTexture);
1394
1615
  // send scene object from 3DTool to HostApp using internalEvent
1395
1616
  (_props$onInternalEven3 = props.onInternalEvent) === null || _props$onInternalEven3 === void 0 || _props$onInternalEven3.call(props, {
1396
1617
  type: _constants.INTERNAL_EVENT_SYNC_SCENE,
1397
1618
  value: {
1398
- scene: state.scene.toJS()
1619
+ scene: sceneData
1399
1620
  }
1400
1621
  });
1401
- return _context1.abrupt("continue", 35);
1402
- case 35:
1622
+ return _context11.abrupt("continue", 45);
1623
+ case 45:
1403
1624
  case "end":
1404
- return _context1.stop();
1625
+ return _context11.stop();
1405
1626
  }
1406
- }, _callee9);
1627
+ }, _callee0);
1407
1628
  }));
1408
1629
  return _handleExternalEvent.apply(this, arguments);
1409
1630
  }