kitchen-simulator 4.0.0-queuedEvents → 4.0.0

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 (111) hide show
  1. package/es/LiteKitchenConfigurator.js +141 -288
  2. package/es/LiteRenderer.js +159 -398
  3. package/es/actions/items-actions.js +10 -6
  4. package/es/actions/lines-actions.js +3 -1
  5. package/es/actions/project-actions.js +15 -5
  6. package/es/assets/img/svg/bottombar/elevation.svg +12 -5
  7. package/es/catalog/areas/area/planner-element.js +10 -5
  8. package/es/catalog/catalog.js +1 -4
  9. package/es/catalog/factories/area-factory-3d.js +2 -1
  10. package/es/catalog/factories/wall-factory-3d.js +2 -2
  11. package/es/catalog/factories/wall-factory.js +8 -8
  12. package/es/catalog/lines/wall/planner-element.js +18 -9
  13. package/es/catalog/utils/exporter.js +7 -3
  14. package/es/catalog/utils/item-loader.js +24 -14
  15. package/es/catalog/utils/mtl-loader.js +2 -2
  16. package/es/catalog/utils/obj-loader.js +2 -2
  17. package/es/class/hole.js +0 -2
  18. package/es/class/item.js +183 -184
  19. package/es/class/line.js +11 -3
  20. package/es/class/project.js +165 -48
  21. package/es/components/content.js +19 -6
  22. package/es/components/viewer2d/grids/grid-streak.js +1 -1
  23. package/es/components/viewer2d/item.js +84 -51
  24. package/es/components/viewer2d/line.js +315 -243
  25. package/es/components/viewer2d/ruler.js +20 -38
  26. package/es/components/viewer2d/rulerDist.js +48 -78
  27. package/es/components/viewer2d/utils.js +6 -0
  28. package/es/components/viewer2d/viewer2d.js +298 -220
  29. package/es/components/viewer3d/front3D.js +3 -2
  30. package/es/components/viewer3d/libs/mtl-loader.js +2 -2
  31. package/es/components/viewer3d/libs/obj-loader.js +2 -2
  32. package/es/components/viewer3d/libs/orbit-controls.js +3 -4
  33. package/es/components/viewer3d/libs/pointer-lock-controls.js +6 -7
  34. package/es/components/viewer3d/scene-creator.js +51 -15
  35. package/es/components/viewer3d/viewer3d.js +121 -82
  36. package/es/constants.js +111 -3
  37. package/es/devLiteRenderer.js +688 -31
  38. package/es/index.js +567 -87
  39. package/es/models.js +9 -5
  40. package/es/plugins/SVGLoader.js +7 -5
  41. package/es/plugins/console-debugger.js +0 -2
  42. package/es/plugins/keyboard.js +15 -6
  43. package/es/reducers/items-reducer.js +5 -5
  44. package/es/reducers/lines-reducer.js +1 -1
  45. package/es/reducers/project-reducer.js +5 -3
  46. package/es/shared-style.js +4 -4
  47. package/es/utils/geometry.js +163 -2
  48. package/es/utils/get-edges-of-subgraphs.js +1 -1
  49. package/es/utils/graph-cycles.js +1 -1
  50. package/es/utils/graph.js +1 -1
  51. package/es/utils/helper.js +105 -3
  52. package/es/utils/isolate-event-handler.js +1542 -164
  53. package/es/utils/molding.js +461 -11
  54. package/lib/LiteKitchenConfigurator.js +141 -289
  55. package/lib/LiteRenderer.js +159 -399
  56. package/lib/actions/items-actions.js +10 -6
  57. package/lib/actions/lines-actions.js +3 -1
  58. package/lib/actions/project-actions.js +15 -4
  59. package/lib/assets/img/svg/bottombar/elevation.svg +12 -5
  60. package/lib/catalog/areas/area/planner-element.js +11 -5
  61. package/lib/catalog/catalog.js +1 -4
  62. package/lib/catalog/factories/area-factory-3d.js +2 -1
  63. package/lib/catalog/factories/wall-factory-3d.js +2 -2
  64. package/lib/catalog/factories/wall-factory.js +8 -8
  65. package/lib/catalog/lines/wall/planner-element.js +19 -9
  66. package/lib/catalog/utils/exporter.js +7 -3
  67. package/lib/catalog/utils/item-loader.js +24 -14
  68. package/lib/catalog/utils/mtl-loader.js +9 -2
  69. package/lib/catalog/utils/obj-loader.js +10 -2
  70. package/lib/class/hole.js +0 -2
  71. package/lib/class/item.js +180 -181
  72. package/lib/class/line.js +9 -1
  73. package/lib/class/project.js +164 -47
  74. package/lib/components/content.js +19 -6
  75. package/lib/components/viewer2d/grids/grid-streak.js +1 -1
  76. package/lib/components/viewer2d/item.js +83 -50
  77. package/lib/components/viewer2d/line.js +315 -242
  78. package/lib/components/viewer2d/ruler.js +19 -37
  79. package/lib/components/viewer2d/rulerDist.js +48 -78
  80. package/lib/components/viewer2d/utils.js +7 -0
  81. package/lib/components/viewer2d/viewer2d.js +296 -219
  82. package/lib/components/viewer3d/front3D.js +3 -2
  83. package/lib/components/viewer3d/libs/mtl-loader.js +9 -2
  84. package/lib/components/viewer3d/libs/obj-loader.js +9 -2
  85. package/lib/components/viewer3d/libs/orbit-controls.js +11 -5
  86. package/lib/components/viewer3d/libs/pointer-lock-controls.js +13 -7
  87. package/lib/components/viewer3d/scene-creator.js +49 -13
  88. package/lib/components/viewer3d/viewer3d.js +119 -80
  89. package/lib/constants.js +116 -7
  90. package/lib/devLiteRenderer.js +687 -30
  91. package/lib/index.js +567 -87
  92. package/lib/models.js +9 -5
  93. package/lib/plugins/SVGLoader.js +7 -5
  94. package/lib/plugins/console-debugger.js +0 -2
  95. package/lib/plugins/keyboard.js +15 -6
  96. package/lib/reducers/items-reducer.js +5 -5
  97. package/lib/reducers/lines-reducer.js +1 -1
  98. package/lib/reducers/project-reducer.js +4 -2
  99. package/lib/shared-style.js +4 -4
  100. package/lib/utils/geometry.js +164 -2
  101. package/lib/utils/get-edges-of-subgraphs.js +6 -1
  102. package/lib/utils/graph-cycles.js +7 -8
  103. package/lib/utils/graph.js +6 -1
  104. package/lib/utils/helper.js +108 -2
  105. package/lib/utils/isolate-event-handler.js +1538 -159
  106. package/lib/utils/molding.js +463 -9
  107. package/package.json +1 -1
  108. package/es/assets/Window.hdr +0 -2100
  109. package/es/assets/img/1.jpg +0 -0
  110. package/lib/assets/Window.hdr +0 -2100
  111. package/lib/assets/img/1.jpg +0 -0
@@ -4,232 +4,1611 @@ 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"));
12
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
10
13
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
14
  var _immutable = require("immutable");
12
15
  var _constants = require("../constants");
13
16
  var _helper = require("./helper");
14
17
  var _exporter = _interopRequireDefault(require("../catalog/utils/exporter"));
15
18
  var _itemLoader = require("../catalog/utils/item-loader");
16
- var _catalog = _interopRequireDefault(require("../catalog/catalog"));
19
+ var _convertUnitsLite = require("./convert-units-lite");
20
+ var _export = require("./export");
21
+ var _utils = require("../components/viewer2d/utils");
22
+ var _SVGLoader = require("three/addons/loaders/SVGLoader");
23
+ var _molding = require("./molding");
17
24
  var _models = require("../models");
18
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; }
19
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; }
20
- var loadSVGsByItem = /*#__PURE__*/function () {
21
- var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(item) {
22
- var _parsed$xml$viewBox, _parsed$xml$viewBox2, response, svgText, loader, parsed, _t;
23
- return _regenerator["default"].wrap(function (_context) {
24
- while (1) switch (_context.prev = _context.next) {
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>
46
+ function loadJSON(_x) {
47
+ return _loadJSON.apply(this, arguments);
48
+ }
49
+ /********Parse TempPlaceholder from cabinetPayloadData **************/
50
+ function _loadJSON() {
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) {
25
55
  case 0:
26
- if (item.outline) {
27
- _context.next = 1;
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;
28
64
  break;
29
65
  }
30
- return _context.abrupt("return", null);
66
+ return _context3.abrupt("return", __jsonCache.get(path));
67
+ case 2:
68
+ p = new Promise(function (resolve, reject) {
69
+ var xhr = new XMLHttpRequest();
70
+ xhr.onreadystatechange = function () {
71
+ if (xhr.readyState === XMLHttpRequest.DONE) {
72
+ if (xhr.status === 200) resolve(JSON.parse(xhr.responseText));else reject(xhr);
73
+ }
74
+ };
75
+ xhr.open('GET', path, true);
76
+ xhr.send();
77
+ });
78
+ __jsonCache.set(path, p);
79
+ return _context3.abrupt("return", p);
80
+ case 3:
81
+ case "end":
82
+ return _context3.stop();
83
+ }
84
+ }, _callee3);
85
+ }));
86
+ return _loadJSON.apply(this, arguments);
87
+ }
88
+ function parseTempPlaceholdersFromCabinetPayload(_x2) {
89
+ return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments);
90
+ }
91
+ /***** Update cabinetPayloadData with updatedTempPlaceholders *****/
92
+ function _parseTempPlaceholdersFromCabinetPayload() {
93
+ _parseTempPlaceholdersFromCabinetPayload = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(cabinetPayload) {
94
+ var link, keys, temp, i, _cabinetPayload$struc, _cabinetPayload$struc2, tempPlaceholdersData, k, _cabinetPayload$struc3, el, tempData, doorKey, drawerKey, fixedKey, doorPHs, drawerPHs, has_single_door, fixedPHs, _t2, _t3, _t4;
95
+ return _regenerator["default"].wrap(function (_context4) {
96
+ while (1) switch (_context4.prev = _context4.next) {
97
+ case 0:
98
+ link = '';
99
+ keys = Object.keys(cabinetPayload.structure_json);
100
+ temp = [];
101
+ i = 0;
31
102
  case 1:
32
- _context.prev = 1;
33
- _context.next = 2;
34
- return fetch(item.outline, {
35
- cache: 'no-store'
103
+ if (!(i < keys.length)) {
104
+ _context4.next = 4;
105
+ break;
106
+ }
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'))) {
108
+ _context4.next = 3;
109
+ break;
110
+ }
111
+ link = cabinetPayload.structure_json[keys[i]];
112
+ _t2 = temp;
113
+ _t3 = keys[i];
114
+ _context4.next = 2;
115
+ return loadJSON(link);
116
+ case 2:
117
+ _t4 = _context4.sent;
118
+ _t2.push.call(_t2, {
119
+ name: _t3,
120
+ data: _t4
36
121
  });
122
+ case 3:
123
+ i++;
124
+ _context4.next = 1;
125
+ break;
126
+ case 4:
127
+ tempPlaceholdersData = [];
128
+ for (k = 0; 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); k++) {
129
+ el = cabinetPayload.structure_json.tempPlaceholders[k].id;
130
+ tempData = {};
131
+ doorKey = 0;
132
+ drawerKey = 0;
133
+ fixedKey = 0;
134
+ doorPHs = 0;
135
+ drawerPHs = 0;
136
+ has_single_door = false;
137
+ fixedPHs = 0;
138
+ temp.forEach(function (t, index) {
139
+ var nodes = t.data.nodes;
140
+ if (nodes === undefined) {
141
+ nodes = [];
142
+ }
143
+ var tempPlaceholders = nodes.filter(function (element) {
144
+ return element.name.startsWith('ph_');
145
+ });
146
+ tempPlaceholders.sort(function (a, b) {
147
+ return a.name > b.name ? 1 : -1;
148
+ });
149
+ if (tempPlaceholders.length > 0) {
150
+ if (t.name === 'base') {
151
+ tempPlaceholders.map(function (element) {
152
+ var sink_match = element.name.match(/\d_(sink_[^LR12]*)(_[LR12])?$/);
153
+ if (sink_match && sink_match.length >= 2) {
154
+ var _process$env$API_URL, _cabinetPayload$struc4;
155
+ tempData['sink'] = tempData['sink'] || [];
156
+ tempData['sink'].push(element.name);
157
+ var sink_url = (_process$env$API_URL = process.env.API_URL) !== null && _process$env$API_URL !== void 0 ? _process$env$API_URL :
158
+ // server url from 3DTool env
159
+ import.meta.env.VITE_APP_API_URL + // server url from Host env
160
+ "/uploads/assets/default/".concat(sink_match[1], ".gltf");
161
+ if (cabinetPayload !== null && cabinetPayload !== void 0 && (_cabinetPayload$struc4 = cabinetPayload.structure_json) !== null && _cabinetPayload$struc4 !== void 0 && (_cabinetPayload$struc4 = _cabinetPayload$struc4.tempPlaceholders[0]) !== null && _cabinetPayload$struc4 !== void 0 && _cabinetPayload$struc4.structure) cabinetPayload.structure_json.tempPlaceholders[0].structure.sink = sink_url;
162
+ } else if (temp.some(function (felement) {
163
+ return felement.name.includes('base_drawer');
164
+ }) && element.name.includes('interior_drawer')) {
165
+ var objCnt = temp.filter(function (felement) {
166
+ return felement.name.includes('base_drawer') && !felement.name.includes('_door');
167
+ }).length;
168
+ var phCnt = tempPlaceholders.filter(function (felement) {
169
+ return felement.name.includes('interior');
170
+ }).length;
171
+ drawerPHs = phCnt;
172
+ if (objCnt === 1 || phCnt % objCnt !== 0) {
173
+ if (tempData['base_drawer_1'] === undefined) {
174
+ tempData['base_drawer_1'] = [];
175
+ }
176
+ tempData['base_drawer_1'].push(element.name);
177
+ drawerKey++;
178
+ } else if (objCnt > 1 && phCnt % objCnt === 0) {
179
+ if (tempData['base_drawer_' + (drawerKey % objCnt + 1)] === undefined) {
180
+ tempData['base_drawer_' + (drawerKey % objCnt + 1)] = [];
181
+ }
182
+ tempData['base_drawer_' + (drawerKey % objCnt + 1)].push(element.name);
183
+ drawerKey++;
184
+ }
185
+ } else if (temp.some(function (felement) {
186
+ return felement.name.includes('base_door');
187
+ }) && !element.name.includes('interior_drawer') && !element.name.includes('drawer') && element.name.includes('door')) {
188
+ var _objCnt = temp.filter(function (felement) {
189
+ return felement.name.includes('base_door');
190
+ }).length;
191
+ var _phCnt = tempPlaceholders.filter(function (felement) {
192
+ return !felement.name.includes('interior') && !felement.name.includes('drawer') && felement.name.includes('door');
193
+ }).length;
194
+ doorPHs = _phCnt;
195
+ if (_objCnt === 1 || _phCnt % _objCnt !== 0) {
196
+ if (tempData['base_door_1'] === undefined) {
197
+ tempData['base_door_1'] = [];
198
+ }
199
+ tempData['base_door_1'].push(element.name);
200
+ doorKey++;
201
+ } else if (_objCnt > 1) {
202
+ if (tempData['base_door_' + (doorKey % _objCnt + 1)] === undefined) {
203
+ tempData['base_door_' + (doorKey % _objCnt + 1)] = [];
204
+ }
205
+ tempData['base_door_' + (doorKey % _objCnt + 1)].push(element.name);
206
+ doorKey++;
207
+ }
208
+ } else if (temp.some(function (felement) {
209
+ return felement.name.includes('base_fixed_drawer_door');
210
+ }) && element.name.includes('_drawer_door_fixed')) {
211
+ var _objCnt2 = temp.filter(function (felement) {
212
+ return felement.name.includes('base_fixed_drawer_door');
213
+ }).length;
214
+ var _phCnt2 = tempPlaceholders.filter(function (felement) {
215
+ return felement.name.includes('_drawer_door_fixed');
216
+ }).length;
217
+ fixedPHs = _phCnt2;
218
+ if (_objCnt2 === 1 || _phCnt2 % _objCnt2 !== 0) {
219
+ if (tempData['base_fixed_drawer_door_1'] === undefined) {
220
+ tempData['base_fixed_drawer_door_1'] = [];
221
+ }
222
+ tempData['base_fixed_drawer_door_1'].push(element.name);
223
+ fixedKey++;
224
+ } else if (_objCnt2 > 1) {
225
+ if (tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] === undefined) {
226
+ tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] = [];
227
+ }
228
+ tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)].push(element.name);
229
+ fixedKey++;
230
+ }
231
+ }
232
+ });
233
+ } else if (t.name.includes('base_drawer') && !t.name.includes('_door')) {
234
+ var objCnt = temp.filter(function (felement) {
235
+ return felement.name.includes('base_drawer') && !felement.name.includes('_door');
236
+ }).length;
237
+ if (objCnt === 1 || drawerPHs % objCnt !== 0) {
238
+ if (tempData['base_drawer_door_1'] === undefined) tempData['base_drawer_door_1'] = [];
239
+ //get drawer door handle placeholders
240
+ var ph_temp = temp.find(function (felement) {
241
+ return felement.name === 'base_drawer_door_1';
242
+ });
243
+ if (ph_temp != undefined) {
244
+ var ph_drawer_door_handle = ph_temp.data.nodes;
245
+ ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) {
246
+ return element.name.startsWith('ph_') && element.name.includes('handle');
247
+ });
248
+ for (var w = 0; w < drawerPHs; w++) {
249
+ if (!tempData['base_drawer_door_1'].some(function (el) {
250
+ return el === 'base_drawer_door_1/' + tempPlaceholders[0].name;
251
+ })) {
252
+ tempData['base_drawer_door_1'].push('base_drawer_1/' + tempPlaceholders[0].name);
253
+ //add drawer door handle placeholders
254
+ if (tempData['drawer_door_handle_1'] === undefined) tempData['drawer_door_handle_1'] = [];
255
+ if (ph_drawer_door_handle.length > 0) tempData['drawer_door_handle_1'].push('base_drawer_door_1/' + ph_drawer_door_handle[0].name);
256
+ }
257
+ }
258
+ }
259
+ } else if (objCnt > 1 && drawerPHs > 0 && drawerPHs % objCnt === 0) {
260
+ if (tempData['base_drawer_door' + t.name.slice(-2)] === undefined) tempData['base_drawer_door' + t.name.slice(-2)] = [];
261
+ //get drawer door handle placeholders
262
+ var ph_temp = temp.find(function (felement) {
263
+ return felement.name === 'base_drawer_door' + t.name.slice(-2);
264
+ });
265
+ if (ph_temp != undefined) {
266
+ var ph_drawer_door_handle = ph_temp.data.nodes;
267
+ ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) {
268
+ return element.name.startsWith('ph_') && element.name.includes('handle');
269
+ });
270
+ tempPlaceholders.forEach(function (element) {
271
+ if (!tempData['base_drawer_door' + t.name.slice(-2)].some(function (el) {
272
+ return el === t.name + '/' + element.name;
273
+ })) {
274
+ tempData['base_drawer_door' + t.name.slice(-2)].push(t.name + '/' + element.name);
275
+ //add drawer door handle placeholders
276
+ if (tempData['drawer_door_handle' + t.name.slice(-2)] === undefined) tempData['drawer_door_handle' + t.name.slice(-2)] = [];
277
+ 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);
278
+ }
279
+ });
280
+ }
281
+ }
282
+ } else if (t.name.includes('base_door')) {
283
+ var _objCnt3 = temp.filter(function (felement) {
284
+ return felement.name.includes('base_door');
285
+ }).length;
286
+ tempPlaceholders = tempPlaceholders.filter(function (el) {
287
+ return el.name.includes('handle');
288
+ });
289
+ if (tempPlaceholders.length > 0) if (_objCnt3 === 1 || doorPHs % _objCnt3 !== 0) {
290
+ if (tempData['door_handle_1'] === undefined) {
291
+ tempData['door_handle_1'] = [];
292
+ }
293
+ var _loop3 = function _loop3() {
294
+ var phname = tempPlaceholders[0].name;
295
+ var newph = undefined;
296
+ if (tempData['base_door_1'][_w].isLeftPlaceholder()) {
297
+ newph = tempPlaceholders.find(function (el) {
298
+ return el.name.isRightPlaceholder();
299
+ });
300
+ }
301
+ if (tempData['base_door_1'][_w].isRightPlaceholder()) {
302
+ newph = tempPlaceholders.find(function (el) {
303
+ return el.name.isLeftPlaceholder();
304
+ });
305
+ }
306
+ if (newph != undefined) {
307
+ phname = newph.name;
308
+ }
309
+ if (doorPHs === 1 && tempPlaceholders.find(function (el) {
310
+ return el.name.isLeftPlaceholder();
311
+ }) != undefined && tempPlaceholders.find(function (el) {
312
+ return el.name.isRightPlaceholder();
313
+ }) != undefined) {
314
+ has_single_door = true;
315
+ }
316
+ if (!tempData['door_handle_1'].some(function (el) {
317
+ return el === 'door_handle_1/' + phname;
318
+ })) {
319
+ tempData['door_handle_1'].push('base_door_1/' + phname);
320
+ }
321
+ };
322
+ for (var _w = 0; _w < doorPHs; _w++) {
323
+ _loop3();
324
+ }
325
+ } else if (_objCnt3 > 1 && doorPHs > 0 && doorPHs % _objCnt3 === 0) {
326
+ if (tempData['door_handle' + t.name.slice(-2)] === undefined) tempData['door_handle' + t.name.slice(-2)] = [];
327
+ var phname = tempPlaceholders[0].name;
328
+ var newph = undefined;
329
+ var blAdd = true;
330
+ if (cabinetPayload.is_corner) {
331
+ if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
332
+ newph = tempPlaceholders.find(function (el) {
333
+ return el.name.isLeftPlaceholder();
334
+ });
335
+ } else {
336
+ blAdd = false;
337
+ }
338
+ } else {
339
+ if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
340
+ newph = tempPlaceholders.find(function (el) {
341
+ return el.name.isRightPlaceholder();
342
+ });
343
+ }
344
+ if (tempData['base_door' + t.name.slice(-2)][0].isRightPlaceholder()) {
345
+ newph = tempPlaceholders.find(function (el) {
346
+ return el.name.isLeftPlaceholder();
347
+ });
348
+ }
349
+ }
350
+ if (blAdd) {
351
+ if (newph != undefined) {
352
+ phname = newph.name;
353
+ }
354
+ if (!tempData['door_handle' + t.name.slice(-2)].some(function (el) {
355
+ return el === t.name + '/' + phname;
356
+ })) {
357
+ tempData['door_handle' + t.name.slice(-2)].push(t.name + '/' + phname);
358
+ }
359
+ }
360
+ }
361
+ } else if (t.name.includes('base_fixed_drawer_door')) {
362
+ var _objCnt4 = temp.filter(function (felement) {
363
+ return felement.name.includes('base_fixed_drawer_door');
364
+ }).length;
365
+ tempPlaceholders = tempPlaceholders.filter(function (el) {
366
+ return el.name.includes('handle');
367
+ });
368
+ if (tempPlaceholders.length > 0) if (_objCnt4 === 1 || fixedPHs % _objCnt4 !== 0) {
369
+ if (tempData['fixed_drawer_door_handle_1'] === undefined) tempData['fixed_drawer_door_handle_1'] = [];
370
+ var _loop4 = function _loop4() {
371
+ var phname = tempPlaceholders[0].name;
372
+ var newph = undefined;
373
+ if (tempData['base_fixed_drawer_door_1'][_w2].isLeftPlaceholder()) {
374
+ newph = tempPlaceholders.find(function (el) {
375
+ return el.name.isRightPlaceholder();
376
+ });
377
+ }
378
+ if (tempData['base_fixed_drawer_door_1'][_w2].isRightPlaceholder()) {
379
+ newph = tempPlaceholders.find(function (el) {
380
+ return el.name.isLeftPlaceholder();
381
+ });
382
+ }
383
+ if (newph != undefined) {
384
+ phname = newph.name;
385
+ }
386
+ if (!tempData['fixed_drawer_door_handle_1'].some(function (el) {
387
+ return el === 'fixed_drawer_door_handle_1/' + phname;
388
+ })) {
389
+ tempData['fixed_drawer_door_handle_1'].push('base_fixed_drawer_door_1/' + phname);
390
+ }
391
+ };
392
+ for (var _w2 = 0; _w2 < fixedPHs; _w2++) {
393
+ _loop4();
394
+ }
395
+ } else if (_objCnt4 > 1 && fixedPHs > 0 && fixedPHs % _objCnt4 === 0) {
396
+ if (tempData['fixed_drawer_door_handle' + t.name.slice(-2)] === undefined) {
397
+ tempData['fixed_drawer_door_handle' + t.name.slice(-2)] = [];
398
+ }
399
+ var _phname = tempPlaceholders[0].name;
400
+ var _newph = undefined;
401
+ if (tempData['base_fixed_drawer_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
402
+ _newph = tempPlaceholders.find(function (el) {
403
+ return el.name.isRightPlaceholder();
404
+ });
405
+ }
406
+ if (tempData['base_fixed_drawer_door' + t.name.slice(-2)][0].isRightPlaceholder()) {
407
+ _newph = tempPlaceholders.find(function (el) {
408
+ return el.name.isLeftPlaceholder();
409
+ });
410
+ }
411
+ if (_newph != undefined) {
412
+ _phname = _newph.name;
413
+ }
414
+ if (!tempData['fixed_drawer_door_handle' + t.name.slice(-2)].some(function (el) {
415
+ return el === t.name + '/' + _phname;
416
+ })) {
417
+ tempData['fixed_drawer_door_handle' + t.name.slice(-2)].push(t.name + '/' + _phname);
418
+ }
419
+ }
420
+ }
421
+ }
422
+ });
423
+ tempPlaceholdersData.push({
424
+ id: parseInt(el, 10),
425
+ placeholders: tempData,
426
+ structure: cabinetPayload.structure_json.tempPlaceholders[0].structure
427
+ });
428
+ }
429
+ return _context4.abrupt("return", tempPlaceholdersData);
430
+ case 5:
431
+ case "end":
432
+ return _context4.stop();
433
+ }
434
+ }, _callee4);
435
+ }));
436
+ return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments);
437
+ }
438
+ function updateCabinetPayload(_x3) {
439
+ return _updateCabinetPayload.apply(this, arguments);
440
+ }
441
+ function _updateCabinetPayload() {
442
+ _updateCabinetPayload = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(cabinetPayload) {
443
+ var cabinetPayloadKeys, i, _cabinetPayload$cabin, _cabinetPayload$cabin2;
444
+ return _regenerator["default"].wrap(function (_context5) {
445
+ while (1) switch (_context5.prev = _context5.next) {
446
+ case 0:
447
+ // let tempPlaceholders = [];
448
+ // tempPlaceholders = await parseTempPlaceholdersFromCabinetPayload(
449
+ // cabinetPayload
450
+ // );
451
+ cabinetPayloadKeys = Object.keys(cabinetPayload);
452
+ for (i = 0; i < cabinetPayloadKeys.length; i++) {
453
+ if (cabinetPayloadKeys[i] === 'structure_json') {
454
+ 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 : [];
455
+
456
+ // cabinetPayload[cabinetPayloadKeys[i]]['placeholders'] =
457
+ // tempPlaceholders[0].placeholders;
458
+ // cabinetPayload[cabinetPayloadKeys[i]]['tempPlaceholders'] =
459
+ // tempPlaceholders;
460
+ }
461
+ }
462
+ return _context5.abrupt("return", cabinetPayload);
463
+ case 1:
464
+ case "end":
465
+ return _context5.stop();
466
+ }
467
+ }, _callee5);
468
+ }));
469
+ return _updateCabinetPayload.apply(this, arguments);
470
+ }
471
+ var loadSVGsByItem = /*#__PURE__*/function () {
472
+ var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(item) {
473
+ var url, p;
474
+ return _regenerator["default"].wrap(function (_context2) {
475
+ while (1) switch (_context2.prev = _context2.next) {
476
+ case 0:
477
+ if (item !== null && item !== void 0 && item.outline) {
478
+ _context2.next = 1;
479
+ break;
480
+ }
481
+ return _context2.abrupt("return", null);
482
+ case 1:
483
+ url = item.outline;
484
+ if (!__svgCache.has(url)) {
485
+ _context2.next = 2;
486
+ break;
487
+ }
488
+ return _context2.abrupt("return", __svgCache.get(url));
37
489
  case 2:
38
- response = _context.sent;
39
- _context.next = 3;
40
- return response.text();
490
+ p = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
491
+ var _parsed$xml$viewBox, _parsed$xml$viewBox2, response, svgText, loader, parsed, _t;
492
+ return _regenerator["default"].wrap(function (_context) {
493
+ while (1) switch (_context.prev = _context.next) {
494
+ case 0:
495
+ _context.prev = 0;
496
+ _context.next = 1;
497
+ return fetch(url, {
498
+ cache: 'force-cache'
499
+ });
500
+ case 1:
501
+ response = _context.sent;
502
+ _context.next = 2;
503
+ return response.text();
504
+ case 2:
505
+ svgText = _context.sent;
506
+ loader = new _SVGLoader.SVGLoader();
507
+ parsed = loader.parse(svgText);
508
+ if (!(0, _helper.isEmpty)(parsed.paths)) {
509
+ _context.next = 3;
510
+ break;
511
+ }
512
+ return _context.abrupt("return", null);
513
+ case 3:
514
+ return _context.abrupt("return", {
515
+ paths: parsed.paths,
516
+ 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,
517
+ 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,
518
+ reverse: !parseFloat(parsed.xml.getAttribute('height'))
519
+ });
520
+ case 4:
521
+ _context.prev = 4;
522
+ _t = _context["catch"](0);
523
+ console.error('Failed to load SVG:', url, _t);
524
+ return _context.abrupt("return", null);
525
+ case 5:
526
+ case "end":
527
+ return _context.stop();
528
+ }
529
+ }, _callee, null, [[0, 4]]);
530
+ }))();
531
+ __svgCache.set(url, p);
532
+ return _context2.abrupt("return", p);
41
533
  case 3:
42
- svgText = _context.sent;
43
- loader = new SVGLoader();
44
- parsed = loader.parse(svgText);
45
- if (!(0, _helper.isEmpty)(parsed.paths)) {
46
- _context.next = 4;
534
+ case "end":
535
+ return _context2.stop();
536
+ }
537
+ }, _callee2);
538
+ }));
539
+ return function loadSVGsByItem(_x4) {
540
+ return _ref.apply(this, arguments);
541
+ };
542
+ }();
543
+ function addItemToCatalog(_x5, _x6, _x7, _x8) {
544
+ return _addItemToCatalog.apply(this, arguments);
545
+ } // Get attributs of current selected element
546
+ function _addItemToCatalog() {
547
+ _addItemToCatalog = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6(element, state, catalogInstance, projectActions) {
548
+ var _elementJs, _elementJs3;
549
+ 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;
550
+ return _regenerator["default"].wrap(function (_context6) {
551
+ while (1) switch (_context6.prev = _context6.next) {
552
+ case 0:
553
+ if (!(0, _helper.isEmpty)(element === null || element === void 0 ? void 0 : element.name)) {
554
+ _context6.next = 1;
555
+ break;
556
+ }
557
+ return _context6.abrupt("return");
558
+ case 1:
559
+ // clone element
560
+ elementJs = Object.assign({}, element); // if (isEmpty(catalog?.elements[element.name])) {
561
+ _context6.next = 2;
562
+ return loadSVGsByItem(elementJs);
563
+ case 2:
564
+ outlineSVGData = _context6.sent;
565
+ if (!(((_elementJs = elementJs) === null || _elementJs === void 0 ? void 0 : _elementJs.type) === 'cabinet')) {
566
+ _context6.next = 4;
47
567
  break;
48
568
  }
49
- return _context.abrupt("return", null);
569
+ // move the tempPlaceholder of current door style to first of tempPlaceholders array
570
+ cds = (_state$getIn = state.getIn(['scene', 'layers', 'layer-1', 'doorStyle'])) === null || _state$getIn === void 0 ? void 0 : _state$getIn.cds;
571
+ if (cds) {
572
+ currentCdsId = (_cds$find = cds.find(function (c) {
573
+ return c.itemID === elementJs.itemID;
574
+ })) === null || _cds$find === void 0 ? void 0 : _cds$find.cabinet_door_style_id;
575
+ 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) {
576
+ return tph.id === currentCdsId;
577
+ }); // swap
578
+ if (currentCdsId && cdsIdx >= 0) {
579
+ ttph = elementJs.structure_json.tempPlaceholders[0];
580
+ elementJs.structure_json.tempPlaceholders[0] = elementJs.structure_json.tempPlaceholders[cdsIdx];
581
+ elementJs.structure_json.tempPlaceholders[cdsIdx] = ttph;
582
+ }
583
+ }
584
+ // make placeholders of element and tempPlaceholder
585
+ 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_ : {});
586
+ elementJs.structure_json = updatedStructureJson;
587
+ elementJs = _objectSpread(_objectSpread({}, elementJs), {}, {
588
+ cds: {
589
+ data: [_objectSpread({}, elementJs.customer_property)],
590
+ itemID: elementJs.itemID
591
+ }
592
+ });
593
+ if ((0, _helper.isEmpty)((_elementJs$structure_3 = elementJs.structure_json) === null || _elementJs$structure_3 === void 0 ? void 0 : _elementJs$structure_3.tempPlaceholders)) {
594
+ _context6.next = 4;
595
+ break;
596
+ }
597
+ _context6.next = 3;
598
+ return updateCabinetPayload(elementJs);
599
+ case 3:
600
+ elementJs = _context6.sent;
50
601
  case 4:
51
- return _context.abrupt("return", {
52
- paths: parsed.paths,
53
- 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,
54
- 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,
55
- reverse: !parseFloat(parsed.xml.getAttribute('height'))
602
+ elementJs = _objectSpread(_objectSpread({}, elementJs), {}, {
603
+ outlineSVGData: outlineSVGData,
604
+ type: elementJs.type,
605
+ render2DItem: _itemLoader.render2DItem
56
606
  });
607
+ 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;
608
+
609
+ /***** join new tempPlaceholder to the old element - start *****/
610
+ // get catalog item by itemID
611
+ catalogElements = state.getIn(['catalog', 'elements']).toJS();
612
+ catalogElementKeys = Object.keys(catalogElements);
613
+ catalogItem = null;
614
+ k = 0;
57
615
  case 5:
58
- _context.prev = 5;
59
- _t = _context["catch"](1);
60
- console.error('Failed to load SVG:', item.outline, _t);
61
- return _context.abrupt("return", null);
616
+ if (!(k < catalogElementKeys.length)) {
617
+ _context6.next = 7;
618
+ break;
619
+ }
620
+ if (!(((_catalogElements$cata = catalogElements[catalogElementKeys[k]]) === null || _catalogElements$cata === void 0 ? void 0 : _catalogElements$cata.itemID) === elementJs.itemID)) {
621
+ _context6.next = 6;
622
+ break;
623
+ }
624
+ catalogItem = catalogElements[catalogElementKeys[k]];
625
+ return _context6.abrupt("continue", 7);
62
626
  case 6:
627
+ k++;
628
+ _context6.next = 5;
629
+ break;
630
+ case 7:
631
+ // get old tempPlaceholder array from catalog item
632
+ tempPlaceholderArray = null;
633
+ if (!(0, _helper.isEmpty)(catalogItem)) {
634
+ tempPlaceholderArray = (_catalogItem$structur = catalogItem.structure_json) === null || _catalogItem$structur === void 0 ? void 0 : _catalogItem$structur.tempPlaceholders;
635
+ }
636
+
637
+ // join new tempPlaceholder array to old one
638
+ newTempPlaceholderArray = [];
639
+ (_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) {
640
+ var _tempPlaceholderArray;
641
+ if (!((_tempPlaceholderArray = tempPlaceholderArray) !== null && _tempPlaceholderArray !== void 0 && _tempPlaceholderArray.some(function (otph) {
642
+ return otph.id === tph.id;
643
+ }))) newTempPlaceholderArray.push(tph);
644
+ });
645
+ mergedTempPlaceholder = null;
646
+ if ((0, _helper.isEmpty)(tempPlaceholderArray)) mergedTempPlaceholder = newTempPlaceholderArray;else if ((0, _helper.isEmpty)(newTempPlaceholderArray)) mergedTempPlaceholder = tempPlaceholderArray;else mergedTempPlaceholder = [].concat((0, _toConsumableArray2["default"])(tempPlaceholderArray), newTempPlaceholderArray);
647
+
648
+ // rplace new array to the elementJS
649
+ if (!(0, _helper.isEmpty)(mergedTempPlaceholder)) elementJs.structure_json.tempPlaceholders = mergedTempPlaceholder;
650
+ /***** join new tempPlaceholder to the old element - end *****/
651
+
652
+ elementJs = (0, _exporter["default"])(elementJs);
653
+ if (catalogInstance !== null && catalogInstance !== void 0 && catalogInstance.validateElement(elementJs)) {
654
+ catalogInstance.registerElement(elementJs);
655
+ projectActions.addElementToCatalog(elementJs);
656
+ }
657
+ case 8:
63
658
  case "end":
64
- return _context.stop();
659
+ return _context6.stop();
65
660
  }
66
- }, _callee, null, [[1, 5]]);
661
+ }, _callee6);
67
662
  }));
68
- return function loadSVGsByItem(_x) {
69
- return _ref.apply(this, arguments);
663
+ return _addItemToCatalog.apply(this, arguments);
664
+ }
665
+ function initAttrData(element, layer, state) {
666
+ element = (0, _typeof2["default"])(element.misc) === 'object' ? element.set('misc', new _immutable.Map(element.misc)) : element;
667
+ switch (element.prototype) {
668
+ case 'items':
669
+ {
670
+ return new _immutable.Map(element);
671
+ }
672
+ case 'lines':
673
+ {
674
+ var v_a = layer.vertices.get(element.vertices.get(0));
675
+ var v_b = layer.vertices.get(element.vertices.get(1));
676
+ var distance = _export.GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
677
+ var _unit = element.misc.get('_unitLength') || _constants.UNIT_INCH;
678
+ var _length = (0, _convertUnitsLite.convert)(distance).from(_constants.UNIT_CENTIMETER).to(_unit);
679
+ if (state.mode == _constants.MODE_DRAWING_LINE) {
680
+ return new _immutable.Map({
681
+ vertexOne: v_a,
682
+ vertexTwo: v_b,
683
+ lineLength: new _immutable.Map({
684
+ length: distance,
685
+ _length: _length,
686
+ _unit: _unit
687
+ }),
688
+ focus: element.focus
689
+ });
690
+ } else {
691
+ var allLines = layer.lines.toArray();
692
+ var relatedLine = allLines.filter(function (line) {
693
+ return line.vertices.toArray().includes(v_b.id) && line.id != element.id;
694
+ })[0];
695
+ var relatedVertexID = relatedLine && (relatedLine.vertices.toArray()[0] == v_b.id ? relatedLine.vertices.toArray()[1] : relatedLine.vertices.toArray()[0]);
696
+ var v_d = relatedVertexID && layer.getIn(['vertices', relatedVertexID]);
697
+ var lineToExtend = relatedVertexID && allLines.filter(function (line) {
698
+ return line.vertices.toArray().includes(relatedVertexID) && line.id != relatedLine.id;
699
+ })[0];
700
+ var v_c = lineToExtend && layer.getIn(['vertices', lineToExtend.vertices.toArray()[0] == v_d.id ? lineToExtend.vertices.toArray()[1] : lineToExtend.vertices.toArray()[0]]);
701
+ return new _immutable.Map({
702
+ vertexOne: v_a,
703
+ vertexTwo: v_b,
704
+ vertexThree: v_c,
705
+ vertexFour: v_d,
706
+ lineToExtend: lineToExtend,
707
+ lineLength: new _immutable.Map({
708
+ length: distance,
709
+ _length: _length,
710
+ _unit: _unit
711
+ }),
712
+ focus: element.focus
713
+ });
714
+ }
715
+ }
716
+ case 'holes':
717
+ {
718
+ var line = layer.lines.get(element.line);
719
+ var _layer$vertices$get = layer.vertices.get(line.vertices.get(0)),
720
+ x0 = _layer$vertices$get.x,
721
+ y0 = _layer$vertices$get.y;
722
+ var _layer$vertices$get2 = layer.vertices.get(line.vertices.get(1)),
723
+ x1 = _layer$vertices$get2.x,
724
+ y1 = _layer$vertices$get2.y;
725
+ var lineLength = _export.GeometryUtils.pointsDistance(x0, y0, x1, y1);
726
+ var startAt = lineLength * element.offset - element.properties.get('width').get('length') / 2;
727
+ var endAt = lineLength - lineLength * element.offset - element.properties.get('width').get('length') / 2;
728
+ var _unitA = element.misc.get('_unitA') || _constants.UNIT_INCH;
729
+ var _lengthA = (0, _convertUnitsLite.convert)(x0 > x1 ? endAt : startAt).from(_constants.UNIT_CENTIMETER).to(_unitA);
730
+ var _unitB = element.misc.get('_unitB') || _constants.UNIT_INCH;
731
+ var _lengthB = (0, _convertUnitsLite.convert)(x0 > x1 ? startAt : endAt).from(_constants.UNIT_CENTIMETER).to(_unitB);
732
+ return new _immutable.Map({
733
+ offset: element.offset,
734
+ offsetA: new _immutable.Map({
735
+ length: _export.MathUtils.toFixedFloat(x0 > x1 ? endAt : startAt, PRECISION),
736
+ _length: _export.MathUtils.toFixedFloat(_lengthA, PRECISION),
737
+ _unit: _unitA
738
+ }),
739
+ offsetB: new _immutable.Map({
740
+ length: _export.MathUtils.toFixedFloat(x0 > x1 ? startAt : endAt, PRECISION),
741
+ _length: _export.MathUtils.toFixedFloat(_lengthB, PRECISION),
742
+ _unit: _unitB
743
+ })
744
+ });
745
+ }
746
+ case 'areas':
747
+ {
748
+ return new _immutable.Map({});
749
+ }
750
+ default:
751
+ return null;
752
+ }
753
+ }
754
+ // Get properties of current selected element
755
+ function initPropData(element, catalog) {
756
+ var mapped = {};
757
+ if (!catalog.elements.hasOwnProperty(element.type) && !(!catalog.elements[element.type] && !!catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(element.type)])) {
758
+ console.log("Last Selected ".concat(element.type, " Element does not exist in catalog."));
759
+ return new _immutable.Map(mapped);
760
+ }
761
+ var catalogElement = catalog.getElement(element.type);
762
+ var isFiller = catalogElement.long_name ? catalogElement.long_name.toUpperCase().includes('FILLER') : false;
763
+ if (isFiller) {
764
+ var height = {
765
+ defaultValue: element.properties.get('height').toJS(),
766
+ label: 'Height',
767
+ type: 'length-measure'
768
+ };
769
+ var depth = {
770
+ defaultValue: element.properties.get('depth').toJS(),
771
+ label: 'Depth',
772
+ type: 'length-measure'
773
+ };
774
+ catalogElement.properties = {
775
+ altitude: catalogElement.properties.altitude,
776
+ width: catalogElement.properties.width,
777
+ height: height,
778
+ depth: depth,
779
+ flip_doorhandle: catalogElement.properties.flip_doorhandle,
780
+ resize_and_scaling: catalogElement.properties.resize_and_scaling
781
+ };
782
+ }
783
+ for (var name in catalogElement.properties) {
784
+ mapped[name] = new _immutable.Map({
785
+ currentValue: element.properties.has(name) ? element.properties.get(name) : fromJS(catalogElement.properties[name].defaultValue),
786
+ configs: catalogElement.properties[name]
787
+ });
788
+ }
789
+ return new _immutable.Map(mapped);
790
+ }
791
+ function updateAttributeOfSelectedElement(element, attrPayload, state, layer, catalog, projectActions) {
792
+ var _attributesFormData;
793
+ var callback = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
794
+ var layerID = state.scene.selectedLayer;
795
+ var layerUnit = state.getIn(['scene', 'layers', layerID, 'unit']);
796
+ var attributesFormData = initAttrData(element, layer, state);
797
+ var value = attrPayload.value;
798
+ var attributeName = attrPayload.attributeName;
799
+ // pre process
800
+ if (attributeName === _constants.ATT_ITEM_POS) {
801
+ // calculate the new position of movement
802
+ var rotRad = (value.directionAng + element.rotation) / 180 * Math.PI;
803
+ var newX = element.x + (0, _convertUnitsLite.convert)((value.oldDistance - value.newDistance) * Math.cos(rotRad)).from(layerUnit).to('cm');
804
+ var newY = element.y + (0, _convertUnitsLite.convert)((value.oldDistance - value.newDistance) * Math.sin(rotRad)).from(layerUnit).to('cm');
805
+ value = {
806
+ x: newX,
807
+ y: newY
808
+ };
809
+ } else if (attributeName === _constants.ATT_LINE_LENGTH || attributeName === _constants.ATT_HOLE_OFFSET_A || attributeName === _constants.ATT_HOLE_OFFSET_B) {
810
+ var att = attributesFormData.has(attributeName) ? attributesFormData.get(attributeName) : element[attributeName];
811
+ if (att) value = att.merge({
812
+ _length: value,
813
+ _unit: layerUnit,
814
+ length: (0, _convertUnitsLite.convert)(value).from(layerUnit).to(_constants.UNIT_CENTIMETER)
815
+ });
816
+ }
817
+ // make the new attrivutes
818
+ switch (element.prototype) {
819
+ case 'items':
820
+ {
821
+ if (attributeName == _constants.ATT_ITEM_POS) {
822
+ var xVal = value.x;
823
+ var yVal = value.y;
824
+ attributesFormData = attributesFormData.set('x', xVal);
825
+ attributesFormData = attributesFormData.set('y', yVal);
826
+ } else {
827
+ attributesFormData = attributesFormData.set(attributeName, value);
828
+ }
829
+ // update the distances from wall
830
+ var _GeometryUtils$calcDi = _export.GeometryUtils.calcDistancesFromItemToWalls(attributesFormData, layer),
831
+ PointArray = _GeometryUtils$calcDi.PointArray;
832
+ attributesFormData = attributesFormData.set('distArray', PointArray);
833
+ break;
834
+ }
835
+ case 'lines':
836
+ {
837
+ switch (attributeName) {
838
+ case _constants.ATT_LINE_LENGTH:
839
+ {
840
+ var v_0 = attributesFormData.get('vertexOne');
841
+ var v_1 = attributesFormData.get('vertexTwo');
842
+ var v_b_new = _export.GeometryUtils.extendLine(v_0.x, v_0.y, v_1.x, v_1.y, value.get('length'), PRECISION);
843
+ attributesFormData = attributesFormData.withMutations(function (attr) {
844
+ attr.set('vertexTwo', v_1.merge(v_b_new));
845
+ attr.set('lineLength', value);
846
+ });
847
+ break;
848
+ }
849
+ case _constants.ATT_VERTEXT_ONE:
850
+ case _constants.ATT_VERTEXT_TWO:
851
+ {
852
+ attributesFormData = attributesFormData.withMutations(function (attr) {
853
+ attr.set(attributeName, attr.get(attributeName).merge(value));
854
+ var newDistance = _export.GeometryUtils.verticesDistance(attr.get('vertexOne'), attr.get('vertexTwo'));
855
+ attr.mergeIn(['lineLength'], attr.get('lineLength').merge({
856
+ length: newDistance,
857
+ _length: (0, _convertUnitsLite.convert)(newDistance).from(_constants.UNIT_CENTIMETER).to(attr.get('lineLength').get('_unit'))
858
+ }));
859
+ });
860
+ break;
861
+ }
862
+ default:
863
+ {
864
+ attributesFormData = attributesFormData.set(attributeName, value);
865
+ break;
866
+ }
867
+ }
868
+ break;
869
+ }
870
+ case 'holes':
871
+ {
872
+ switch (attributeName) {
873
+ case _constants.ATT_HOLE_OFFSET_A:
874
+ {
875
+ var line = layer.lines.get(element.line);
876
+ var _layer$vertices$get3 = layer.vertices.get(line.vertices.get(0)),
877
+ x0 = _layer$vertices$get3.x,
878
+ y0 = _layer$vertices$get3.y;
879
+ var _layer$vertices$get4 = layer.vertices.get(line.vertices.get(1)),
880
+ x1 = _layer$vertices$get4.x,
881
+ y1 = _layer$vertices$get4.y;
882
+ var alpha = _export.GeometryUtils.angleBetweenTwoPoints(x0, y0, x1, y1);
883
+ var lineLength = _export.GeometryUtils.pointsDistance(x0, y0, x1, y1);
884
+ var widthLength = element.properties.get('width').get('length');
885
+ var halfWidthLength = widthLength / 2;
886
+ var lengthValue = value.get('length');
887
+ lengthValue = Math.max(lengthValue, 0);
888
+ lengthValue = Math.min(lengthValue, lineLength - widthLength);
889
+ var xp = (lengthValue + halfWidthLength) * Math.cos(alpha) + x0;
890
+ var yp = (lengthValue + halfWidthLength) * Math.sin(alpha) + y0;
891
+ var offset = _export.GeometryUtils.pointPositionOnLineSegment(x0, y0, x1, y1, xp, yp);
892
+ /*
893
+ if (x0 > x1) offset = 1 - offset;
894
+ */
895
+ var endAt = _export.MathUtils.toFixedFloat(lineLength - lineLength * offset - halfWidthLength, PRECISION);
896
+ var offsetUnit = attributesFormData.getIn(['offsetB', '_unit']);
897
+ var offsetB = new _immutable.Map({
898
+ length: endAt,
899
+ _length: (0, _convertUnitsLite.convert)(endAt).from(_constants.UNIT_CENTIMETER).to(offsetUnit),
900
+ _unit: offsetUnit
901
+ });
902
+ attributesFormData = attributesFormData.set('offsetB', offsetB).set('offset', offset);
903
+ var offsetAttribute = new _immutable.Map({
904
+ length: _export.MathUtils.toFixedFloat(lengthValue, PRECISION),
905
+ _unit: value.get('_unit'),
906
+ _length: _export.MathUtils.toFixedFloat((0, _convertUnitsLite.convert)(lengthValue).from(_constants.UNIT_CENTIMETER).to(value.get('_unit')), PRECISION)
907
+ });
908
+ attributesFormData = attributesFormData.set(attributeName, offsetAttribute);
909
+ break;
910
+ }
911
+ case _constants.ATT_HOLE_OFFSET_B:
912
+ {
913
+ var _line = layer.lines.get(element.line);
914
+ var _layer$vertices$get5 = layer.vertices.get(_line.vertices.get(0)),
915
+ _x9 = _layer$vertices$get5.x,
916
+ _y = _layer$vertices$get5.y;
917
+ var _layer$vertices$get6 = layer.vertices.get(_line.vertices.get(1)),
918
+ _x0 = _layer$vertices$get6.x,
919
+ _y2 = _layer$vertices$get6.y;
920
+ var _alpha = _export.GeometryUtils.angleBetweenTwoPoints(_x9, _y, _x0, _y2);
921
+ var _lineLength = _export.GeometryUtils.pointsDistance(_x9, _y, _x0, _y2);
922
+ var _widthLength = element.properties.get('width').get('length');
923
+ var _halfWidthLength = _widthLength / 2;
924
+ var _lengthValue = value.get('length');
925
+ _lengthValue = Math.max(_lengthValue, 0);
926
+ _lengthValue = Math.min(_lengthValue, _lineLength - _widthLength);
927
+ var _xp = _x0 - (_lengthValue + _halfWidthLength) * Math.cos(_alpha);
928
+ var _yp = _y2 - (_lengthValue + _halfWidthLength) * Math.sin(_alpha);
929
+ var _offset = _export.GeometryUtils.pointPositionOnLineSegment(_x9, _y, _x0, _y2, _xp, _yp);
930
+ /*
931
+ if (x0 > x1) offset = 1 - offset;
932
+ */
933
+ var startAt = _export.MathUtils.toFixedFloat(_lineLength * _offset - _halfWidthLength, PRECISION);
934
+ var _offsetUnit = attributesFormData.getIn(['offsetA', '_unit']);
935
+ var offsetA = new _immutable.Map({
936
+ length: startAt,
937
+ _length: (0, _convertUnitsLite.convert)(startAt).from(_constants.UNIT_CENTIMETER).to(_offsetUnit),
938
+ _unit: _offsetUnit
939
+ });
940
+ attributesFormData = attributesFormData.set('offsetA', offsetA).set('offset', _offset);
941
+ var _offsetAttribute = new _immutable.Map({
942
+ length: _export.MathUtils.toFixedFloat(_lengthValue, PRECISION),
943
+ _unit: value.get('_unit'),
944
+ _length: _export.MathUtils.toFixedFloat((0, _convertUnitsLite.convert)(_lengthValue).from(_constants.UNIT_CENTIMETER).to(value.get('_unit')), PRECISION)
945
+ });
946
+ attributesFormData = attributesFormData.set(attributeName, _offsetAttribute);
947
+ break;
948
+ }
949
+ default:
950
+ {
951
+ attributesFormData = attributesFormData.set(attributeName, value);
952
+ break;
953
+ }
954
+ }
955
+ break;
956
+ }
957
+ default:
958
+ break;
959
+ }
960
+
961
+ // update attribute action
962
+ switch (element.prototype) {
963
+ case 'items':
964
+ {
965
+ projectActions.setItemsAttributes(attributesFormData);
966
+ break;
967
+ }
968
+ case 'lines':
969
+ {
970
+ projectActions.setLinesAttributes(attributesFormData);
971
+ break;
972
+ }
973
+ case 'holes':
974
+ {
975
+ projectActions.setHolesAttributes(attributesFormData);
976
+ break;
977
+ }
978
+ }
979
+
980
+ // invoke callback
981
+ if (callback) callback((_attributesFormData = attributesFormData) === null || _attributesFormData === void 0 ? void 0 : _attributesFormData.toJS());
982
+ }
983
+ function updatePropertyOfSelectedElement(element, propertyPayload, catalog,
984
+ // class instance of Catalog, get from props
985
+ projectActions) {
986
+ var _propertiesFormData;
987
+ var callback = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
988
+ var propertiesFormData = initPropData(element, catalog);
989
+ var value = propertyPayload.value;
990
+ var propertyName = propertyPayload.propertyName;
991
+ // make new properties
992
+ if (propertyName === _constants.PROP_FLIP_DOOR_HANDLE && element.properties.get(_constants.PROP_OPEN_DOORS)) {
993
+ alert('Doors are already open.');
994
+ return;
995
+ }
996
+ propertiesFormData = propertiesFormData.setIn([propertyName, 'currentValue'], value);
997
+
998
+ // update property action
999
+ if (propertiesFormData) {
1000
+ var properties = propertiesFormData.map(function (data) {
1001
+ return data.get('currentValue');
1002
+ });
1003
+ projectActions.setProperties(properties);
1004
+ }
1005
+
1006
+ // invoke callback
1007
+ if (callback) callback((_propertiesFormData = propertiesFormData) === null || _propertiesFormData === void 0 ? void 0 : _propertiesFormData.toJS());
1008
+ }
1009
+ function getElement(objProps, state) {
1010
+ var layerID = state.scene.selectedLayer;
1011
+ var curObject = null;
1012
+ if (!(0, _helper.isEmpty)(objProps === null || objProps === void 0 ? void 0 : objProps.elementPrototype) && !(0, _helper.isEmpty)(objProps === null || objProps === void 0 ? void 0 : objProps.elementId)) curObject = state.getIn(['scene', 'layers', layerID, objProps.elementPrototype, objProps.elementId]);else {
1013
+ // if no specified object property then get the first selected element
1014
+ var layer = state.scene.layers.get(state.scene.selectedLayer);
1015
+ var selected = [];
1016
+ layer.selected.forEach(function (data, prototype) {
1017
+ if (prototype == 'vertices') return;
1018
+ if (data.size > 0) {
1019
+ var values = data.toJS();
1020
+ for (var i = 0; i < values.length; i++) {
1021
+ selected.push({
1022
+ type: prototype,
1023
+ id: values[i]
1024
+ });
1025
+ }
1026
+ }
1027
+ });
1028
+ if (selected.length === 1) {
1029
+ var selData = selected[0];
1030
+ switch (selData.type) {
1031
+ case _constants.ELEMENT_HOLE:
1032
+ curObject = layer.holes.get(selData.id);
1033
+ break;
1034
+ case _constants.ELEMENT_ITEM:
1035
+ curObject = layer.items.get(selData.id);
1036
+ break;
1037
+ case _constants.ELEMENT_LINE:
1038
+ curObject = layer.lines.get(selData.id);
1039
+ break;
1040
+ }
1041
+ }
1042
+ }
1043
+ return curObject;
1044
+ }
1045
+ function loadMoldingSvg(_x1) {
1046
+ return _loadMoldingSvg.apply(this, arguments);
1047
+ }
1048
+ function _loadMoldingSvg() {
1049
+ _loadMoldingSvg = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7(molding) {
1050
+ return _regenerator["default"].wrap(function (_context7) {
1051
+ while (1) switch (_context7.prev = _context7.next) {
1052
+ case 0:
1053
+ return _context7.abrupt("return", new Promise(function (resolve, reject) {
1054
+ var url = molding === null || molding === void 0 ? void 0 : molding.shape_svg;
1055
+ if (!url) {
1056
+ // Skip if no SVG URL available
1057
+ return resolve();
1058
+ }
1059
+ var loader = new _SVGLoader.SVGLoader();
1060
+ loader.load(url, function (data) {
1061
+ var _data$xml$viewBox$ani, _data$xml, _data$xml$viewBox$ani2, _data$xml2;
1062
+ molding.data = {
1063
+ paths: data.paths,
1064
+ svg_width: (_data$xml$viewBox$ani = (_data$xml = data.xml) === null || _data$xml === void 0 || (_data$xml = _data$xml.viewBox) === null || _data$xml === void 0 || (_data$xml = _data$xml.animVal) === null || _data$xml === void 0 ? void 0 : _data$xml.width) !== null && _data$xml$viewBox$ani !== void 0 ? _data$xml$viewBox$ani : 0,
1065
+ svg_height: (_data$xml$viewBox$ani2 = (_data$xml2 = data.xml) === null || _data$xml2 === void 0 || (_data$xml2 = _data$xml2.viewBox) === null || _data$xml2 === void 0 || (_data$xml2 = _data$xml2.animVal) === null || _data$xml2 === void 0 ? void 0 : _data$xml2.height) !== null && _data$xml$viewBox$ani2 !== void 0 ? _data$xml$viewBox$ani2 : 0
1066
+ };
1067
+ resolve();
1068
+ }, null, function (error) {
1069
+ console.error(error);
1070
+ reject(error);
1071
+ });
1072
+ }));
1073
+ case 1:
1074
+ case "end":
1075
+ return _context7.stop();
1076
+ }
1077
+ }, _callee7);
1078
+ }));
1079
+ return _loadMoldingSvg.apply(this, arguments);
1080
+ }
1081
+ function setFinishing(props, state, payload) {
1082
+ switch (payload.category) {
1083
+ case _constants.FINISHING_TYPE.WALL_COLOR:
1084
+ if (state.mode !== _constants.MODE_ELEVATION_VIEW) props.itemsActions.setWallColor(payload.color);
1085
+ break;
1086
+ case _constants.FINISHING_TYPE.COUNTER_TOP:
1087
+ props.itemsActions.setCounterTop({
1088
+ uri: payload.texture
1089
+ });
1090
+ break;
1091
+ case _constants.FINISHING_TYPE.FLOOR_STYLE:
1092
+ if (state.mode !== _constants.MODE_ELEVATION_VIEW) props.areaActions.setFloorStyles({
1093
+ uri: payload.texture
1094
+ });
1095
+ break;
1096
+ case _constants.FINISHING_TYPE.BACKSPLASH:
1097
+ if (state.mode !== _constants.MODE_ELEVATION_VIEW) props.itemsActions.setBacksplash({
1098
+ uri: payload.texture
1099
+ });
1100
+ break;
1101
+ case _constants.FINISHING_TYPE.DOOR_HANDLE:
1102
+ props.itemsActions.setDoorHandle(payload.gltf);
1103
+ break;
1104
+ }
1105
+ }
1106
+ function moveAndRotatePan2D3D(eventType, props, payload, state) {
1107
+ if (eventType === _constants.EXTERNAL_EVENT_MOVE_PAN) {
1108
+ var moveType = payload.moveType,
1109
+ moveValue = payload.moveValue;
1110
+ var value = state.getIn(['viewer2D']).toJS();
1111
+ if (state.mode === _constants.MODE_IDLE) {
1112
+ switch (moveType) {
1113
+ case _constants.TOP:
1114
+ value.f -= moveValue;
1115
+ break;
1116
+ case _constants.BOTTOM:
1117
+ value.f += moveValue;
1118
+ break;
1119
+ case _constants.RIGHT:
1120
+ value.e += moveValue;
1121
+ break;
1122
+ case _constants.LEFT:
1123
+ value.e -= moveValue;
1124
+ break;
1125
+ }
1126
+ (0, _helper.updateViwer2D)(value, props.viewer2DActions);
1127
+ } else if (state.mode === _constants.MODE_IDLE_3D) {
1128
+ switch (moveType) {
1129
+ case _constants.TOP:
1130
+ window.interval = setTimeout(function () {
1131
+ window.tDKeyDown({
1132
+ keyCode: 38
1133
+ });
1134
+ }, 50);
1135
+ break;
1136
+ case _constants.BOTTOM:
1137
+ window.interval = setTimeout(function () {
1138
+ window.tDKeyDown({
1139
+ keyCode: 40
1140
+ });
1141
+ }, 50);
1142
+ break;
1143
+ case _constants.RIGHT:
1144
+ window.interval = setTimeout(function () {
1145
+ window.tDKeyDown({
1146
+ keyCode: 37
1147
+ });
1148
+ }, 50);
1149
+ break;
1150
+ case _constants.LEFT:
1151
+ window.interval = setTimeout(function () {
1152
+ window.tDKeyDown({
1153
+ keyCode: 39
1154
+ });
1155
+ }, 50);
1156
+ break;
1157
+ }
1158
+ }
1159
+ } else if (eventType === _constants.EXTERNAL_EVENT_ROTATE_PAN) {
1160
+ var rotateType = payload.rotateType;
1161
+ switch (rotateType) {
1162
+ case _constants.TOP:
1163
+ window.interval = setTimeout(function () {
1164
+ window.SPKeyDown({
1165
+ keyCode: 87
1166
+ });
1167
+ }, 50);
1168
+ break;
1169
+ case _constants.BOTTOM:
1170
+ window.interval = setTimeout(function () {
1171
+ window.SPKeyDown({
1172
+ keyCode: 83
1173
+ });
1174
+ }, 50);
1175
+ break;
1176
+ case _constants.RIGHT:
1177
+ window.interval = setTimeout(function () {
1178
+ window.SPKeyDown({
1179
+ keyCode: 68
1180
+ });
1181
+ }, 50);
1182
+ break;
1183
+ case _constants.LEFT:
1184
+ window.interval = setTimeout(function () {
1185
+ window.SPKeyDown({
1186
+ keyCode: 65
1187
+ });
1188
+ }, 50);
1189
+ break;
1190
+ }
1191
+ }
1192
+ }
1193
+ function mergeSameElements(projectItemsCatalog) {
1194
+ var result = [];
1195
+ var _loop = function _loop(i) {
1196
+ var idx = result.findIndex(function (v) {
1197
+ return v.itemID === projectItemsCatalog[i].itemID;
1198
+ });
1199
+ if (idx < 0) result.push(projectItemsCatalog[i]);else {
1200
+ var _loop2 = function _loop2(j) {
1201
+ var _result$idx$structure, _result$idx$structure2;
1202
+ 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) {
1203
+ return v.id === projectItemsCatalog[i].structure_json.tempPlaceholders[j].id;
1204
+ });
1205
+ 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];
1206
+ };
1207
+ 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++) {
1208
+ var _projectItemsCatalog$;
1209
+ _loop2(j);
1210
+ }
1211
+ }
70
1212
  };
71
- }();
72
- var compareSVGRect = function compareSVGRect(value) {
73
- return value.e <= 10 && value.e + value.a * value.SVGWidth + 10 >= value.viewerWidth && value.f <= 80 && value.f + value.d * value.SVGHeight + 10 >= value.viewerHeight ? true : false;
74
- };
75
- function handleExternalEvent(_x2) {
1213
+ for (var i = 0; i < (projectItemsCatalog === null || projectItemsCatalog === void 0 ? void 0 : projectItemsCatalog.length); i++) {
1214
+ _loop(i);
1215
+ }
1216
+ return result;
1217
+ }
1218
+ function handleExternalEvent(_x10) {
76
1219
  return _handleExternalEvent.apply(this, arguments);
77
1220
  }
78
1221
  function _handleExternalEvent() {
79
- _handleExternalEvent = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(props) {
80
- var evt, state, sLineCnt, element, catalog, outlineSVGData, catalogInstance, elementJs, _evt$payload, moveType, moveValue, value, defaulTitle, _evt$payload2, doorStyle, isAll, _doorStyle, _value, _zoomValue, _value2, _zoomValue2, _t2, _t3;
81
- return _regenerator["default"].wrap(function (_context2) {
82
- while (1) switch (_context2.prev = _context2.next) {
1222
+ _handleExternalEvent = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee0(props) {
1223
+ var _evt$payload3, _evt$payload4;
1224
+ var evt, state, layerId, layer, _evt$payload, cdsItems, itemKeys, _loop5, i, newScene, _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, _loop6, _i2, _props$onInternalEven2, _evt$payload6, roomShapeType, width, height, _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;
1225
+ return _regenerator["default"].wrap(function (_context10) {
1226
+ while (1) switch (_context10.prev = _context10.next) {
83
1227
  case 0:
1228
+ // console.log('***external event****', props);
84
1229
  evt = props.externalEvent;
85
- state = props.state.get('KitchenConfigurator');
86
- _t2 = evt === null || evt === void 0 ? void 0 : evt.type;
87
- _context2.next = _t2 === _constants.EXTERNAL_EVENT_TOGGLE_TO_3D ? 1 : _t2 === _constants.EXTERNAL_EVENT_TOGGLE_TO_2D ? 2 : _t2 === _constants.EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 3 : _t2 === _constants.EXTERNAL_EVENT_ADD_WALL ? 4 : _t2 === _constants.EXTERNAL_EVENT_ADD_ITEM ? 5 : _t2 === _constants.EXTERNAL_EVENT_MOVE_PAN ? 9 : _t2 === _constants.EXTERNAL_EVENT_NEW_PROJECT ? 15 : _t2 === _constants.EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 16 : _t2 === _constants.EXTERNAL_EVENT_SET_INITIAL_DATA ? 17 : _t2 === _constants.EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 18 : _t2 === _constants.EXTERNAL_EVENT_ZOOM_IN ? 19 : _t2 === _constants.EXTERNAL_EVENT_ZOOM_OUT ? 22 : 25;
88
- break;
1230
+ state = getPlannerStateFromProps(props);
1231
+ if (state) {
1232
+ _context10.next = 1;
1233
+ break;
1234
+ }
1235
+ return _context10.abrupt("return");
89
1236
  case 1:
90
- props.projectActions.setMode(_constants.MODE_IDLE_3D);
91
- return _context2.abrupt("continue", 25);
1237
+ layerId = state.getIn(['scene', 'selectedLayer']);
1238
+ layer = state.getIn(['scene', 'layers', layerId]);
1239
+ _t5 = evt === null || evt === void 0 ? void 0 : evt.type;
1240
+ _context10.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;
1241
+ break;
92
1242
  case 2:
93
- props.projectActions.setMode(_constants.MODE_IDLE);
94
- return _context2.abrupt("continue", 25);
1243
+ if (!(evt !== null && evt !== void 0 && evt.payload)) {
1244
+ _context10.next = 6;
1245
+ break;
1246
+ }
1247
+ // prepare item data request
1248
+ cdsItems = [];
1249
+ 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) || [];
1250
+ _loop5 = /*#__PURE__*/_regenerator["default"].mark(function _loop5() {
1251
+ var _evt$payload2, _it$doorStyle2;
1252
+ var it;
1253
+ return _regenerator["default"].wrap(function (_context9) {
1254
+ while (1) switch (_context9.prev = _context9.next) {
1255
+ case 0:
1256
+ 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')
1257
+ // if (
1258
+ // it.properties.altitude.length !==
1259
+ // convert(it.properties.altitude._length).from('in').to('cm')
1260
+ // ) {
1261
+ // it.properties.altitude.length = convert(
1262
+ // it.properties.altitude._length
1263
+ // )
1264
+ // .from('in')
1265
+ // .to('cm');
1266
+ // }
1267
+ /////////
1268
+ if (!cdsItems.some(function (v) {
1269
+ var _it$doorStyle;
1270
+ 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;
1271
+ })) cdsItems.push({
1272
+ itemID: it.itemID,
1273
+ prototype: it.prototype,
1274
+ category: it.category,
1275
+ name: it.name,
1276
+ type: it.type,
1277
+ sku_number: it.sku_number,
1278
+ cdsId: (_it$doorStyle2 = it.doorStyle) === null || _it$doorStyle2 === void 0 || (_it$doorStyle2 = _it$doorStyle2.doorStyles) === null || _it$doorStyle2 === void 0 ? void 0 : _it$doorStyle2.cabinet_door_style_id
1279
+ });
1280
+ case 1:
1281
+ case "end":
1282
+ return _context9.stop();
1283
+ }
1284
+ }, _loop5);
1285
+ });
1286
+ i = 0;
95
1287
  case 3:
96
- sLineCnt = state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size;
97
- if (sLineCnt > 0) props.projectActions.setMode(_constants.MODE_ELEVATION_VIEW);
98
- return _context2.abrupt("continue", 25);
1288
+ if (!(i < itemKeys.length)) {
1289
+ _context10.next = 5;
1290
+ break;
1291
+ }
1292
+ return _context10.delegateYield(_loop5(), "t0", 4);
99
1293
  case 4:
1294
+ i++;
1295
+ _context10.next = 3;
1296
+ break;
1297
+ case 5:
1298
+ newScene = new _models.Scene(evt === null || evt === void 0 ? void 0 : evt.payload);
1299
+ state = new _models.State({
1300
+ scene: newScene.toJS()
1301
+ });
1302
+ // request item catalog data to host app
1303
+ if (cdsItems.length > 0) {
1304
+ (_props$onInternalEven = props.onInternalEvent) === null || _props$onInternalEven === void 0 || _props$onInternalEven.call(props, {
1305
+ type: _constants.INTERNAL_EVENT_ITEMS_CATALOG,
1306
+ value: {
1307
+ cdsItems: cdsItems
1308
+ }
1309
+ }, /*#__PURE__*/function () {
1310
+ var _ref3 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee8(result) {
1311
+ var rt, _i;
1312
+ return _regenerator["default"].wrap(function (_context8) {
1313
+ while (1) switch (_context8.prev = _context8.next) {
1314
+ case 0:
1315
+ rt = mergeSameElements(result === null || result === void 0 ? void 0 : result.elements);
1316
+ _i = 0;
1317
+ case 1:
1318
+ if (!(_i < (rt === null || rt === void 0 ? void 0 : rt.length))) {
1319
+ _context8.next = 3;
1320
+ break;
1321
+ }
1322
+ _context8.next = 2;
1323
+ return addItemToCatalog(rt[_i], state, props.catalog, props.projectActions);
1324
+ case 2:
1325
+ _i++;
1326
+ _context8.next = 1;
1327
+ break;
1328
+ case 3:
1329
+ props.projectActions.loadProject(evt.payload);
1330
+ case 4:
1331
+ case "end":
1332
+ return _context8.stop();
1333
+ }
1334
+ }, _callee8);
1335
+ }));
1336
+ return function (_x11) {
1337
+ return _ref3.apply(this, arguments);
1338
+ };
1339
+ }());
1340
+ } else props.projectActions.loadProject(evt.payload);
1341
+ case 6:
1342
+ return _context10.abrupt("continue", 45);
1343
+ case 7:
1344
+ props.projectActions.setMode(_constants.MODE_IDLE_3D);
1345
+ return _context10.abrupt("continue", 45);
1346
+ case 8:
1347
+ props.projectActions.setMode(_constants.MODE_IDLE);
1348
+ return _context10.abrupt("continue", 45);
1349
+ case 9:
1350
+ sLineCnt = layer.selected.lines.size;
1351
+ if (sLineCnt > 0) props.projectActions.setMode(_constants.MODE_ELEVATION_VIEW);
1352
+ return _context10.abrupt("continue", 45);
1353
+ case 10:
100
1354
  if (state.mode === _constants.MODE_IDLE || state.mode === _constants.MODE_2D_PAN) props.linesActions.selectToolDrawingLine('wall');else {
101
1355
  props.projectActions.setMode(_constants.MODE_IDLE);
102
1356
  props.linesActions.selectToolDrawingLine('wall');
103
1357
  }
104
- return _context2.abrupt("continue", 25);
105
- case 5:
1358
+ return _context10.abrupt("continue", 45);
1359
+ case 11:
106
1360
  if ((0, _helper.isEmpty)(evt === null || evt === void 0 ? void 0 : evt.payload)) {
107
- _context2.next = 8;
1361
+ _context10.next = 13;
108
1362
  break;
109
1363
  }
110
1364
  element = evt.payload;
111
- catalog = state.getIn(['catalog']).toJS(); // add item to catalog of state
112
- if (!(0, _helper.isEmpty)(catalog === null || catalog === void 0 ? void 0 : catalog.elements[element.name])) {
113
- _context2.next = 7;
114
- break;
115
- }
116
- _context2.next = 6;
117
- return loadSVGsByItem(element);
118
- case 6:
119
- outlineSVGData = _context2.sent;
120
- catalogInstance = props.catalog;
121
- elementJs = (0, _exporter["default"])(_objectSpread(_objectSpread({}, element), {}, {
122
- outlineSVGData: outlineSVGData,
123
- type: 'cabinet',
124
- render2DItem: _itemLoader.render2DItem,
125
- render3DItem: _itemLoader.render3DItem
126
- }));
127
- if (catalogInstance !== null && catalogInstance !== void 0 && catalogInstance.validateElement(elementJs)) {
128
- props.projectActions.addElementToCatalog(elementJs);
129
- }
130
- case 7:
1365
+ _context10.next = 12;
1366
+ return addItemToCatalog(element, state, props.catalog, props.projectActions);
1367
+ case 12:
131
1368
  // start drawing item
132
- _constants.ARRAY_3D_MODES.includes(state.mode) ? props.itemsActions.selectToolDrawingItem3D(element.name) : props.itemsActions.selectToolDrawingItem(element.name);
1369
+ if (_constants.ARRAY_3D_MODES.includes(state.mode)) {
1370
+ // in 3d view
1371
+ props.itemsActions.selectToolDrawingItem3D(element.name);
1372
+ } else {
1373
+ // in 2d view
1374
+ // create cabinet
1375
+ props.itemsActions.selectToolDrawingItem(element.name);
1376
+ // mapping the initial position of client coord to viewer2D coord
1377
+ _evt$payload$initialP = evt.payload.initialPosition, mouseX = _evt$payload$initialP.mouseX, mouseY = _evt$payload$initialP.mouseY;
1378
+ v2d = (_state$viewer2D = state.viewer2D) === null || _state$viewer2D === void 0 ? void 0 : _state$viewer2D.toJS();
1379
+ if (mouseX && mouseY && v2d) {
1380
+ vPosX = (mouseX - v2d.e) / v2d.a;
1381
+ vPosY = (mouseY - v2d.f) / v2d.d;
1382
+ layerID = state.scene.selectedLayer; // move cabinet to initial position
1383
+ props.itemsActions.updateDrawingItem(layerID, vPosX, -vPosY + state.scene.height, true);
1384
+ }
1385
+ }
133
1386
  props.projectActions.pushLastSelectedCatalogElementToHistory(element);
134
1387
  props.projectActions.setIsCabinetDrawing(true);
135
- case 8:
136
- return _context2.abrupt("continue", 25);
137
- case 9:
138
- _evt$payload = evt.payload, moveType = _evt$payload.moveType, moveValue = _evt$payload.moveValue;
139
- value = state.getIn(['viewer2D']).toJS();
140
- _t3 = moveType;
141
- _context2.next = _t3 === _constants.TOP ? 10 : _t3 === _constants.BOTTOM ? 11 : _t3 === _constants.RIGHT ? 12 : _t3 === _constants.LEFT ? 13 : 14;
142
- break;
143
- case 10:
144
- value.f -= moveValue;
145
- return _context2.abrupt("continue", 14);
146
- case 11:
147
- value.f += moveValue;
148
- return _context2.abrupt("continue", 14);
149
- case 12:
150
- value.e += moveValue;
151
- return _context2.abrupt("continue", 14);
152
1388
  case 13:
153
- value.e -= moveValue;
154
- return _context2.abrupt("continue", 14);
1389
+ return _context10.abrupt("continue", 45);
155
1390
  case 14:
156
- if (compareSVGRect(value)) props.viewer2DActions.updateCameraView(value);
157
- return _context2.abrupt("continue", 25);
1391
+ _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);
1392
+ return _context10.abrupt("continue", 45);
158
1393
  case 15:
1394
+ moveAndRotatePan2D3D(evt.type, props, evt.payload, state);
1395
+ return _context10.abrupt("continue", 45);
1396
+ case 16:
159
1397
  defaulTitle = 'Untitle';
160
1398
  props.projectActions.newProject();
161
1399
  props.projectActions.rename(defaulTitle);
162
- return _context2.abrupt("continue", 25);
163
- case 16:
164
- _evt$payload2 = evt.payload, doorStyle = _evt$payload2.doorStyle, isAll = _evt$payload2.isAll;
165
- props.itemsActions.setDoorStyle(doorStyle, isAll);
166
- return _context2.abrupt("continue", 25);
1400
+ return _context10.abrupt("continue", 45);
167
1401
  case 17:
168
- _doorStyle = evt.payload.doorStyle;
169
- props.itemsActions.setInitialDoorStyle(_doorStyle.doorStyle, _doorStyle.oStyle);
170
- return _context2.abrupt("continue", 25);
1402
+ _evt$payload5 = evt.payload, doorStyle = _evt$payload5.doorStyle, itemCDS = _evt$payload5.itemCDS, isAll = _evt$payload5.isAll; // prepare item data request
1403
+ _layerId = state.getIn(['scene', 'selectedLayer']);
1404
+ _cdsItems = [];
1405
+ allItems = state.getIn(['scene', 'layers', _layerId, 'items']).toJS();
1406
+ selectedItemId = state.getIn(['scene', 'layers', _layerId]).selected.items.toJS()[0];
1407
+ _itemKeys = isAll ? (_Object$keys = Object.keys(allItems)) !== null && _Object$keys !== void 0 ? _Object$keys : [] : [selectedItemId];
1408
+ _loop6 = /*#__PURE__*/_regenerator["default"].mark(function _loop6() {
1409
+ var _itemCDS$find;
1410
+ var item, cdsId;
1411
+ return _regenerator["default"].wrap(function (_context1) {
1412
+ while (1) switch (_context1.prev = _context1.next) {
1413
+ case 0:
1414
+ item = allItems[_itemKeys[_i2]];
1415
+ cdsId = (_itemCDS$find = itemCDS.find(function (itCDS) {
1416
+ return itCDS.itemID === item.itemID;
1417
+ })) === null || _itemCDS$find === void 0 ? void 0 : _itemCDS$find.cabinet_door_style_id;
1418
+ if (cdsId && !_cdsItems.some(function (v) {
1419
+ return item.itemID === v.itemID && item.name === v.name && cdsId === v.cdsId;
1420
+ })) _cdsItems.push({
1421
+ itemID: item.itemID,
1422
+ prototype: item.prototype,
1423
+ category: item.category,
1424
+ name: item.name,
1425
+ type: item.type,
1426
+ sku_number: item.sku_number,
1427
+ cdsId: cdsId
1428
+ });
1429
+ case 1:
1430
+ case "end":
1431
+ return _context1.stop();
1432
+ }
1433
+ }, _loop6);
1434
+ });
1435
+ _i2 = 0;
171
1436
  case 18:
172
- props.projectActions.loadProject(evt.payload, props.categoryData);
173
- return _context2.abrupt("continue", 25);
174
- case 19:
175
- _value = state.getIn(['viewer2D']).toJS();
176
- _value.a -= 0.1;
177
- _value.d -= 0.1;
178
- _value.e += _value.SVGWidth * 0.1 / 2;
179
- _value.f += _value.SVGHeight * 0.1 / 2;
180
- _zoomValue = parseInt((_value.a - 0.5) / _constants.ZOOM_VARIABLE);
181
- if (!(_zoomValue > 404)) {
182
- _context2.next = 20;
1437
+ if (!(_i2 < _itemKeys.length)) {
1438
+ _context10.next = 20;
183
1439
  break;
184
1440
  }
185
- return _context2.abrupt("return");
1441
+ return _context10.delegateYield(_loop6(), "t1", 19);
1442
+ case 19:
1443
+ _i2++;
1444
+ _context10.next = 18;
1445
+ break;
186
1446
  case 20:
187
- if (!(_zoomValue < 35 || Number.isNaN(_zoomValue))) {
188
- _context2.next = 21;
189
- break;
190
- }
191
- return _context2.abrupt("return");
1447
+ // request item catalog data to host app
1448
+ if (_cdsItems.length > 0) {
1449
+ (_props$onInternalEven2 = props.onInternalEvent) === null || _props$onInternalEven2 === void 0 || _props$onInternalEven2.call(props, {
1450
+ type: _constants.INTERNAL_EVENT_ITEMS_CATALOG,
1451
+ value: {
1452
+ cdsItems: _cdsItems
1453
+ }
1454
+ }, /*#__PURE__*/function () {
1455
+ var _ref4 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee9(result) {
1456
+ var rt, _i3;
1457
+ return _regenerator["default"].wrap(function (_context0) {
1458
+ while (1) switch (_context0.prev = _context0.next) {
1459
+ case 0:
1460
+ rt = mergeSameElements(result === null || result === void 0 ? void 0 : result.elements);
1461
+ _i3 = 0;
1462
+ case 1:
1463
+ if (!(_i3 < (rt === null || rt === void 0 ? void 0 : rt.length))) {
1464
+ _context0.next = 3;
1465
+ break;
1466
+ }
1467
+ _context0.next = 2;
1468
+ return addItemToCatalog(rt[_i3], state, props.catalog, props.projectActions);
1469
+ case 2:
1470
+ _i3++;
1471
+ _context0.next = 1;
1472
+ break;
1473
+ case 3:
1474
+ props.itemsActions.setDoorStyle(doorStyle, itemCDS, isAll);
1475
+ case 4:
1476
+ case "end":
1477
+ return _context0.stop();
1478
+ }
1479
+ }, _callee9);
1480
+ }));
1481
+ return function (_x12) {
1482
+ return _ref4.apply(this, arguments);
1483
+ };
1484
+ }());
1485
+ } else props.itemsActions.setDoorStyle(doorStyle, itemCDS, isAll);
1486
+ return _context10.abrupt("continue", 45);
192
1487
  case 21:
193
- while (!(_value.e <= 10)) {
194
- _value.e -= 0.1;
195
- }
196
- while (!(_value.e + _value.a * _value.SVGWidth + 10 >= _value.viewerWidth)) {
197
- _value.e += 0.1;
198
- }
199
- while (!(_value.f <= 80)) {
200
- _value.f -= 0.1;
201
- }
202
- while (!(_value.f + _value.a * _value.SVGHeight + 10 >= _value.viewerHeight)) {
203
- _value.f += 0.1;
204
- }
205
- if (compareSVGRect(_value)) props.viewer2DActions.updateCameraView(_value);
206
- return _context2.abrupt("continue", 25);
1488
+ _evt$payload6 = evt.payload, roomShapeType = _evt$payload6.roomShapeType, width = _evt$payload6.width, height = _evt$payload6.height, _doorStyle = _evt$payload6.doorStyle;
1489
+ props.projectActions.createRoomWithShape(roomShapeType, width, height, _doorStyle);
1490
+ return _context10.abrupt("continue", 45);
207
1491
  case 22:
208
- _value2 = state.getIn(['viewer2D']).toJS();
209
- _value2.a += 0.1;
210
- _value2.d += 0.1;
211
- _value2.e -= _value2.SVGWidth * 0.1 / 2;
212
- _value2.f -= _value2.SVGHeight * 0.1 / 2;
213
- _zoomValue2 = parseInt((_value2.a - 0.5) / _constants.ZOOM_VARIABLE);
214
- if (!(_zoomValue2 > 404)) {
215
- _context2.next = 23;
216
- break;
217
- }
218
- return _context2.abrupt("return");
1492
+ value = state.getIn(['viewer2D']).toJS();
1493
+ value.a += 0.1;
1494
+ value.d += 0.1;
1495
+ value.e -= value.SVGWidth * 0.1 / 2;
1496
+ value.f -= value.SVGHeight * 0.1 / 2;
1497
+ (0, _helper.updateViwer2D)(value, props.viewer2DActions);
1498
+ return _context10.abrupt("continue", 45);
219
1499
  case 23:
220
- if (!(_zoomValue2 < 35 || Number.isNaN(_zoomValue2))) {
221
- _context2.next = 24;
222
- break;
223
- }
224
- return _context2.abrupt("return");
1500
+ _value = state.getIn(['viewer2D']).toJS();
1501
+ _value.a -= 0.1;
1502
+ _value.d -= 0.1;
1503
+ _value.e += _value.SVGWidth * 0.1 / 2;
1504
+ _value.f += _value.SVGHeight * 0.1 / 2;
1505
+ (0, _helper.updateViwer2D)(_value, props.viewer2DActions);
1506
+ return _context10.abrupt("continue", 45);
225
1507
  case 24:
226
- if (compareSVGRect(_value2)) props.viewer2DActions.updateCameraView(_value2);
227
- return _context2.abrupt("continue", 25);
1508
+ (0, _helper.centering2D)(state, props.viewer2DActions);
1509
+ return _context10.abrupt("continue", 45);
228
1510
  case 25:
1511
+ props.projectActions.undo();
1512
+ return _context10.abrupt("continue", 45);
1513
+ case 26:
1514
+ props.projectActions.redo();
1515
+ return _context10.abrupt("continue", 45);
1516
+ case 27:
1517
+ _evt$payload7 = evt.payload, moldingInfo = _evt$payload7.moldingInfo, isGlobal = _evt$payload7.isGlobal;
1518
+ _context10.next = 28;
1519
+ return loadMoldingSvg(moldingInfo);
1520
+ case 28:
1521
+ props.itemsActions.setMolding(moldingInfo, isGlobal);
1522
+ return _context10.abrupt("continue", 45);
1523
+ case 29:
1524
+ distElement = getElement(evt.payload, state);
1525
+ if (distElement) props.itemsActions.duplicateSelected(distElement, props.onInternalEvent);
1526
+ return _context10.abrupt("continue", 45);
1527
+ case 30:
1528
+ _distElement = getElement(evt.payload, state);
1529
+ if (_distElement) props.projectActions.remove(_distElement);
1530
+ return _context10.abrupt("continue", 45);
1531
+ case 31:
1532
+ _evt$payload8 = evt.payload, option = _evt$payload8.option, _value2 = _evt$payload8.value;
1533
+ _t6 = option;
1534
+ _context10.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;
1535
+ break;
1536
+ case 32:
1537
+ props.viewer2DActions.updateCeilHeight((0, _convertUnitsLite.convert)(layer.ceilHeight).from(layer.unit).to(_value2));
1538
+ props.viewer2DActions.updateCeilHeightUnit(_value2);
1539
+ props.viewer3DActions.update3DCeilHeightUnit(_value2);
1540
+ props.viewer3DActions.update3DCeilHeight((0, _convertUnitsLite.convert)(layer.ceilHeight).from(layer.unit).to(_value2));
1541
+ case 33:
1542
+ props.viewer2DActions.updateCeilHeight(_value2);
1543
+ props.viewer3DActions.update3DCeilHeight(_value2);
1544
+ return _context10.abrupt("continue", 39);
1545
+ case 34:
1546
+ props.viewer2DActions.changeWallLengthMeasure(_value2);
1547
+ return _context10.abrupt("continue", 39);
1548
+ case 35:
1549
+ props.viewer2DActions.changeBaseCabinetMeasure(_value2);
1550
+ return _context10.abrupt("continue", 39);
1551
+ case 36:
1552
+ props.viewer2DActions.changeWallCabinetMeasure(_value2);
1553
+ return _context10.abrupt("continue", 39);
1554
+ case 37:
1555
+ props.viewer2DActions.changeWindowDoorMeasure(_value2);
1556
+ return _context10.abrupt("continue", 39);
1557
+ case 38:
1558
+ return _context10.abrupt("continue", 39);
1559
+ case 39:
1560
+ return _context10.abrupt("continue", 45);
1561
+ case 40:
1562
+ _layerId2 = state.getIn(['scene', 'selectedLayer']);
1563
+ _layer = state.getIn(['scene', 'layers', _layerId2]);
1564
+ _layer$getIn = _layer.getIn(['selected']), selectedLines = _layer$getIn.lines, selectedHoles = _layer$getIn.holes, selectedItems = _layer$getIn.items;
1565
+ 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);
1566
+ 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);
1567
+ 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);
1568
+ return _context10.abrupt("continue", 45);
1569
+ case 41:
1570
+ _layerID = state.scene.selectedLayer;
1571
+ _layer2 = state.scene.getIn(['layers', _layerID]).toJS();
1572
+ orginalItemInfo = evt === null || evt === void 0 || (_evt$payload9 = evt.payload) === null || _evt$payload9 === void 0 ? void 0 : _evt$payload9.orginalItemInfo;
1573
+ originalItem = _layer2 === null || _layer2 === void 0 ? void 0 : _layer2.items[orginalItemInfo.id];
1574
+ _context10.next = 42;
1575
+ return addItemToCatalog(evt.payload.replaceItemInfo, state, props.catalog, props.projectActions);
1576
+ case 42:
1577
+ originalItemPos = {
1578
+ rotation: originalItem.rotation,
1579
+ selectedItemId: originalItem.id,
1580
+ x: originalItem.x,
1581
+ y: originalItem.y
1582
+ };
1583
+ replaceItem = {
1584
+ name: evt === null || evt === void 0 || (_evt$payload0 = evt.payload) === null || _evt$payload0 === void 0 || (_evt$payload0 = _evt$payload0.replaceItemInfo) === null || _evt$payload0 === void 0 ? void 0 : _evt$payload0.name,
1585
+ info: {
1586
+ width: evt === null || evt === void 0 || (_evt$payload1 = evt.payload) === null || _evt$payload1 === void 0 || (_evt$payload1 = _evt$payload1.replaceItemInfo) === null || _evt$payload1 === void 0 || (_evt$payload1 = _evt$payload1.sizeinfo) === null || _evt$payload1 === void 0 ? void 0 : _evt$payload1.width,
1587
+ height: evt === null || evt === void 0 || (_evt$payload10 = evt.payload) === null || _evt$payload10 === void 0 || (_evt$payload10 = _evt$payload10.replaceItemInfo) === null || _evt$payload10 === void 0 || (_evt$payload10 = _evt$payload10.sizeinfo) === null || _evt$payload10 === void 0 ? void 0 : _evt$payload10.height
1588
+ }
1589
+ };
1590
+ props.itemsActions.replaceItem(originalItemPos, originalItem, replaceItem);
1591
+ return _context10.abrupt("continue", 45);
1592
+ case 43:
1593
+ setFinishing(props, state, evt.payload);
1594
+ return _context10.abrupt("continue", 45);
1595
+ case 44:
1596
+ sceneData = state.scene.toJS(); // get molding data for "ReviewForQuote"
1597
+ currentTexture = layer.doorStyle !== null || layer.doorStyle !== undefined ? layer.doorStyle : props.state.doorStyle.toJS();
1598
+ sceneData.layers[layerId].moldingData = (0, _molding.getMoldingDataOfScene2)(layer, props.catalog, currentTexture);
1599
+ // send scene object from 3DTool to HostApp using internalEvent
1600
+ (_props$onInternalEven3 = props.onInternalEvent) === null || _props$onInternalEven3 === void 0 || _props$onInternalEven3.call(props, {
1601
+ type: _constants.INTERNAL_EVENT_SYNC_SCENE,
1602
+ value: {
1603
+ scene: sceneData
1604
+ }
1605
+ });
1606
+ return _context10.abrupt("continue", 45);
1607
+ case 45:
229
1608
  case "end":
230
- return _context2.stop();
1609
+ return _context10.stop();
231
1610
  }
232
- }, _callee2);
1611
+ }, _callee0);
233
1612
  }));
234
1613
  return _handleExternalEvent.apply(this, arguments);
235
1614
  }