kitchen-simulator 1.0.0-clark.54 → 1.0.0-clark.56

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.
@@ -65,53 +65,459 @@ var loadSVGsByItem = /*#__PURE__*/function () {
65
65
  var compareSVGRect = function compareSVGRect(value) {
66
66
  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;
67
67
  };
68
- export function handleExternalEvent(_x2) {
69
- return _handleExternalEvent.apply(this, arguments);
68
+ function loadJSON(_x2, _x3, _x4) {
69
+ return _loadJSON.apply(this, arguments);
70
70
  }
71
- function _handleExternalEvent() {
72
- _handleExternalEvent = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(props) {
73
- var evt, state, sLineCnt, element, catalog, outlineSVGData, catalogInstance, elementJs, _evt$payload, moveType, moveValue, value, defaulTitle, _evt$payload2, doorStyle, itemCDS, isAll, _doorStyle, _value, _zoomValue, _value2, _zoomValue2, _evt$payload3, moldingInfo, isGlobal, _t2, _t3;
71
+ /********Parse TempPlaceholder from cabinetPayloadData **************/
72
+ function _loadJSON() {
73
+ _loadJSON = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(path, success, error) {
74
74
  return _regeneratorRuntime.wrap(function (_context2) {
75
75
  while (1) switch (_context2.prev = _context2.next) {
76
+ case 0:
77
+ return _context2.abrupt("return", new Promise(function (resolve, reject) {
78
+ var xhr = new XMLHttpRequest();
79
+ xhr.onreadystatechange = function () {
80
+ if (xhr.readyState === XMLHttpRequest.DONE) {
81
+ if (xhr.status === 200) {
82
+ resolve(JSON.parse(xhr.responseText));
83
+ } else {
84
+ reject(xhr);
85
+ }
86
+ }
87
+ };
88
+ xhr.open('GET', path, true);
89
+ xhr.send();
90
+ }));
91
+ case 1:
92
+ case "end":
93
+ return _context2.stop();
94
+ }
95
+ }, _callee2);
96
+ }));
97
+ return _loadJSON.apply(this, arguments);
98
+ }
99
+ export function parseTempPlaceholdersFromCabinetPayload(_x5) {
100
+ return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments);
101
+ }
102
+
103
+ /***** Update cabinetPayloadData with updatedTempPlaceholders *****/
104
+ function _parseTempPlaceholdersFromCabinetPayload() {
105
+ _parseTempPlaceholdersFromCabinetPayload = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(cabinetPayload) {
106
+ var link, keys, temp, i, _cabinetPayload$struc, el, tempPlaceholdersData, tempData, doorKey, drawerKey, fixedKey, doorPHs, drawerPHs, has_single_door, fixedPHs, _t2, _t3, _t4;
107
+ return _regeneratorRuntime.wrap(function (_context3) {
108
+ while (1) switch (_context3.prev = _context3.next) {
109
+ case 0:
110
+ link = '';
111
+ keys = Object.keys(cabinetPayload.structure_json);
112
+ temp = [];
113
+ i = 0;
114
+ case 1:
115
+ if (!(i < keys.length)) {
116
+ _context3.next = 4;
117
+ break;
118
+ }
119
+ 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'))) {
120
+ _context3.next = 3;
121
+ break;
122
+ }
123
+ link = cabinetPayload.structure_json[keys[i]];
124
+ _t2 = temp;
125
+ _t3 = keys[i];
126
+ _context3.next = 2;
127
+ return loadJSON(link);
128
+ case 2:
129
+ _t4 = _context3.sent;
130
+ _t2.push.call(_t2, {
131
+ name: _t3,
132
+ data: _t4
133
+ });
134
+ case 3:
135
+ i++;
136
+ _context3.next = 1;
137
+ break;
138
+ case 4:
139
+ el = cabinetPayload.structure_json.tempPlaceholders[0].id;
140
+ tempPlaceholdersData = [];
141
+ tempData = {};
142
+ doorKey = 0;
143
+ drawerKey = 0;
144
+ fixedKey = 0;
145
+ doorPHs = 0;
146
+ drawerPHs = 0;
147
+ has_single_door = false;
148
+ fixedPHs = 0;
149
+ temp.forEach(function (t, index) {
150
+ var nodes = t.data.nodes;
151
+ if (nodes === undefined) {
152
+ nodes = [];
153
+ }
154
+ var tempPlaceholders = nodes.filter(function (element) {
155
+ return element.name.startsWith('ph_');
156
+ });
157
+ tempPlaceholders.sort(function (a, b) {
158
+ return a.name > b.name ? 1 : -1;
159
+ });
160
+ if (tempPlaceholders.length > 0) {
161
+ if (t.name === 'base') {
162
+ tempPlaceholders.map(function (element) {
163
+ var sink_match = element.name.match(/\d_(sink_[^LR12]*)(_[LR12])?$/);
164
+ if (sink_match && sink_match.length >= 2) {
165
+ tempData['sink'] = tempData['sink'] || [];
166
+ tempData['sink'].push(element.name);
167
+ var sink_url = process.env.DEV_HTTP + process.env.DEV_PORT + "/uploads/assets/default/".concat(sink_match[1], ".gltf");
168
+ json_data.sink = sink_url;
169
+ } else if (temp.some(function (felement) {
170
+ return felement.name.includes('base_drawer');
171
+ }) && element.name.includes('interior_drawer')) {
172
+ var objCnt = temp.filter(function (felement) {
173
+ return felement.name.includes('base_drawer') && !felement.name.includes('_door');
174
+ }).length;
175
+ var phCnt = tempPlaceholders.filter(function (felement) {
176
+ return felement.name.includes('interior');
177
+ }).length;
178
+ drawerPHs = phCnt;
179
+ if (objCnt === 1 || phCnt % objCnt !== 0) {
180
+ if (tempData['base_drawer_1'] === undefined) {
181
+ tempData['base_drawer_1'] = [];
182
+ }
183
+ tempData['base_drawer_1'].push(element.name);
184
+ drawerKey++;
185
+ } else if (objCnt > 1 && phCnt % objCnt === 0) {
186
+ if (tempData['base_drawer_' + (drawerKey % objCnt + 1)] === undefined) {
187
+ tempData['base_drawer_' + (drawerKey % objCnt + 1)] = [];
188
+ }
189
+ tempData['base_drawer_' + (drawerKey % objCnt + 1)].push(element.name);
190
+ drawerKey++;
191
+ }
192
+ } else if (temp.some(function (felement) {
193
+ return felement.name.includes('base_door');
194
+ }) && !element.name.includes('interior_drawer') && !element.name.includes('drawer') && element.name.includes('door')) {
195
+ var _objCnt = temp.filter(function (felement) {
196
+ return felement.name.includes('base_door');
197
+ }).length;
198
+ var _phCnt = tempPlaceholders.filter(function (felement) {
199
+ return !felement.name.includes('interior') && !felement.name.includes('drawer') && felement.name.includes('door');
200
+ }).length;
201
+ doorPHs = _phCnt;
202
+ if (_objCnt === 1 || _phCnt % _objCnt !== 0) {
203
+ if (tempData['base_door_1'] === undefined) {
204
+ tempData['base_door_1'] = [];
205
+ }
206
+ tempData['base_door_1'].push(element.name);
207
+ doorKey++;
208
+ } else if (_objCnt > 1) {
209
+ if (tempData['base_door_' + (doorKey % _objCnt + 1)] === undefined) {
210
+ tempData['base_door_' + (doorKey % _objCnt + 1)] = [];
211
+ }
212
+ tempData['base_door_' + (doorKey % _objCnt + 1)].push(element.name);
213
+ doorKey++;
214
+ }
215
+ } else if (temp.some(function (felement) {
216
+ return felement.name.includes('base_fixed_drawer_door');
217
+ }) && element.name.includes('_drawer_door_fixed')) {
218
+ var _objCnt2 = temp.filter(function (felement) {
219
+ return felement.name.includes('base_fixed_drawer_door');
220
+ }).length;
221
+ var _phCnt2 = tempPlaceholders.filter(function (felement) {
222
+ return felement.name.includes('_drawer_door_fixed');
223
+ }).length;
224
+ fixedPHs = _phCnt2;
225
+ if (_objCnt2 === 1 || _phCnt2 % _objCnt2 !== 0) {
226
+ if (tempData['base_fixed_drawer_door_1'] === undefined) {
227
+ tempData['base_fixed_drawer_door_1'] = [];
228
+ }
229
+ tempData['base_fixed_drawer_door_1'].push(element.name);
230
+ fixedKey++;
231
+ } else if (_objCnt2 > 1) {
232
+ if (tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] === undefined) {
233
+ tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] = [];
234
+ }
235
+ tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)].push(element.name);
236
+ fixedKey++;
237
+ }
238
+ }
239
+ });
240
+ } else if (t.name.includes('base_drawer') && !t.name.includes('_door')) {
241
+ var objCnt = temp.filter(function (felement) {
242
+ return felement.name.includes('base_drawer') && !felement.name.includes('_door');
243
+ }).length;
244
+ if (objCnt === 1 || drawerPHs % objCnt !== 0) {
245
+ if (tempData['base_drawer_door_1'] === undefined) tempData['base_drawer_door_1'] = [];
246
+ //get drawer door handle placeholders
247
+ var ph_temp = temp.find(function (felement) {
248
+ return felement.name === 'base_drawer_door_1';
249
+ });
250
+ if (ph_temp != undefined) {
251
+ var ph_drawer_door_handle = ph_temp.data.nodes;
252
+ ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) {
253
+ return element.name.startsWith('ph_') && element.name.includes('handle');
254
+ });
255
+ for (var w = 0; w < drawerPHs; w++) {
256
+ if (!tempData['base_drawer_door_1'].some(function (el) {
257
+ return el === 'base_drawer_door_1/' + tempPlaceholders[0].name;
258
+ })) {
259
+ tempData['base_drawer_door_1'].push('base_drawer_1/' + tempPlaceholders[0].name);
260
+ //add drawer door handle placeholders
261
+ if (tempData['drawer_door_handle_1'] === undefined) tempData['drawer_door_handle_1'] = [];
262
+ if (ph_drawer_door_handle.length > 0) tempData['drawer_door_handle_1'].push('base_drawer_door_1/' + ph_drawer_door_handle[0].name);
263
+ }
264
+ }
265
+ }
266
+ } else if (objCnt > 1 && drawerPHs > 0 && drawerPHs % objCnt === 0) {
267
+ if (tempData['base_drawer_door' + t.name.slice(-2)] === undefined) tempData['base_drawer_door' + t.name.slice(-2)] = [];
268
+ //get drawer door handle placeholders
269
+ var ph_temp = temp.find(function (felement) {
270
+ return felement.name === 'base_drawer_door' + t.name.slice(-2);
271
+ });
272
+ if (ph_temp != undefined) {
273
+ var ph_drawer_door_handle = ph_temp.data.data.nodes;
274
+ ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) {
275
+ return element.name.startsWith('ph_') && element.name.includes('handle');
276
+ });
277
+ tempPlaceholders.forEach(function (element) {
278
+ if (!tempData['base_drawer_door' + t.name.slice(-2)].some(function (el) {
279
+ return el === t.name + '/' + element.name;
280
+ })) {
281
+ tempData['base_drawer_door' + t.name.slice(-2)].push(t.name + '/' + element.name);
282
+ //add drawer door handle placeholders
283
+ if (tempData['drawer_door_handle' + t.name.slice(-2)] === undefined) tempData['drawer_door_handle' + t.name.slice(-2)] = [];
284
+ 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);
285
+ }
286
+ });
287
+ }
288
+ }
289
+ } else if (t.name.includes('base_door')) {
290
+ var _objCnt3 = temp.filter(function (felement) {
291
+ return felement.name.includes('base_door');
292
+ }).length;
293
+ tempPlaceholders = tempPlaceholders.filter(function (el) {
294
+ return el.name.includes('handle');
295
+ });
296
+ if (tempPlaceholders.length > 0) if (_objCnt3 === 1 || doorPHs % _objCnt3 !== 0) {
297
+ if (tempData['door_handle_1'] === undefined) {
298
+ tempData['door_handle_1'] = [];
299
+ }
300
+ var _loop = function _loop() {
301
+ var phname = tempPlaceholders[0].name;
302
+ var newph = undefined;
303
+ if (tempData['base_door_1'][_w].isLeftPlaceholder()) {
304
+ newph = tempPlaceholders.find(function (el) {
305
+ return el.name.isRightPlaceholder();
306
+ });
307
+ }
308
+ if (tempData['base_door_1'][_w].isRightPlaceholder()) {
309
+ newph = tempPlaceholders.find(function (el) {
310
+ return el.name.isLeftPlaceholder();
311
+ });
312
+ }
313
+ if (newph != undefined) {
314
+ phname = newph.name;
315
+ }
316
+ if (doorPHs === 1 && tempPlaceholders.find(function (el) {
317
+ return el.name.isLeftPlaceholder();
318
+ }) != undefined && tempPlaceholders.find(function (el) {
319
+ return el.name.isRightPlaceholder();
320
+ }) != undefined) {
321
+ has_single_door = true;
322
+ }
323
+ if (!tempData['door_handle_1'].some(function (el) {
324
+ return el === 'door_handle_1/' + phname;
325
+ })) {
326
+ tempData['door_handle_1'].push('base_door_1/' + phname);
327
+ }
328
+ };
329
+ for (var _w = 0; _w < doorPHs; _w++) {
330
+ _loop();
331
+ }
332
+ } else if (_objCnt3 > 1 && doorPHs > 0 && doorPHs % _objCnt3 === 0) {
333
+ if (tempData['door_handle' + t.name.slice(-2)] === undefined) tempData['door_handle' + t.name.slice(-2)] = [];
334
+ phname = tempPlaceholders[0].name;
335
+ newph = undefined;
336
+ var blAdd = true;
337
+ if (element.is_corner) {
338
+ if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
339
+ newph = tempPlaceholders.find(function (el) {
340
+ return el.name.isLeftPlaceholder();
341
+ });
342
+ } else {
343
+ blAdd = false;
344
+ }
345
+ } else {
346
+ if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
347
+ newph = tempPlaceholders.find(function (el) {
348
+ return el.name.isRightPlaceholder();
349
+ });
350
+ }
351
+ if (tempData['base_door' + t.name.slice(-2)][0].isRightPlaceholder()) {
352
+ newph = tempPlaceholders.find(function (el) {
353
+ return el.name.isLeftPlaceholder();
354
+ });
355
+ }
356
+ }
357
+ if (blAdd) {
358
+ if (newph != undefined) {
359
+ phname = newph.name;
360
+ }
361
+ if (!tempData['door_handle' + t.name.slice(-2)].some(function (el) {
362
+ return el === t.name + '/' + phname;
363
+ })) {
364
+ tempData['door_handle' + t.name.slice(-2)].push(t.name + '/' + phname);
365
+ }
366
+ }
367
+ }
368
+ } else if (t.name.includes('base_fixed_drawer_door')) {
369
+ var _objCnt4 = temp.filter(function (felement) {
370
+ return felement.name.includes('base_fixed_drawer_door');
371
+ }).length;
372
+ tempPlaceholders = tempPlaceholders.filter(function (el) {
373
+ return el.name.includes('handle');
374
+ });
375
+ if (tempPlaceholders.length > 0) if (_objCnt4 === 1 || fixedPHs % _objCnt4 !== 0) {
376
+ if (tempData['fixed_drawer_door_handle_1'] === undefined) tempData['fixed_drawer_door_handle_1'] = [];
377
+ for (var _w2 = 0; _w2 < fixedPHs; _w2++) {
378
+ phname = tempPlaceholders[0].name;
379
+ newph = undefined;
380
+ if (tempData['base_fixed_drawer_door_1'][_w2].isLeftPlaceholder()) {
381
+ newph = tempPlaceholders.find(function (el) {
382
+ return el.name.isRightPlaceholder();
383
+ });
384
+ }
385
+ if (tempData['base_fixed_drawer_door_1'][_w2].isRightPlaceholder()) {
386
+ newph = tempPlaceholders.find(function (el) {
387
+ return el.name.isLeftPlaceholder();
388
+ });
389
+ }
390
+ if (newph != undefined) {
391
+ phname = newph.name;
392
+ }
393
+ if (!tempData['fixed_drawer_door_handle_1'].some(function (el) {
394
+ return el === 'fixed_drawer_door_handle_1/' + phname;
395
+ })) {
396
+ tempData['fixed_drawer_door_handle_1'].push('base_fixed_drawer_door_1/' + phname);
397
+ }
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
+ phname = tempPlaceholders[0].name;
404
+ 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
+ }
424
+ }
425
+ }
426
+ });
427
+ tempPlaceholdersData.push({
428
+ id: parseInt(el, 10),
429
+ placeholders: tempData
430
+ });
431
+ return _context3.abrupt("return", tempPlaceholdersData);
432
+ case 5:
433
+ case "end":
434
+ return _context3.stop();
435
+ }
436
+ }, _callee3);
437
+ }));
438
+ return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments);
439
+ }
440
+ export function updateCabinetPayload(_x6) {
441
+ return _updateCabinetPayload.apply(this, arguments);
442
+ }
443
+ function _updateCabinetPayload() {
444
+ _updateCabinetPayload = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(cabinetPayload) {
445
+ var tempPlaceholders, cabinetPayloadKeys, i;
446
+ return _regeneratorRuntime.wrap(function (_context4) {
447
+ while (1) switch (_context4.prev = _context4.next) {
448
+ case 0:
449
+ tempPlaceholders = [];
450
+ _context4.next = 1;
451
+ return parseTempPlaceholdersFromCabinetPayload(cabinetPayload);
452
+ case 1:
453
+ tempPlaceholders = _context4.sent;
454
+ cabinetPayloadKeys = Object.keys(cabinetPayload);
455
+ for (i = 0; i < cabinetPayloadKeys.length; i++) {
456
+ if (cabinetPayloadKeys[i] === 'structure_json') {
457
+ cabinetPayload[cabinetPayloadKeys[i]]['placeholders'] = tempPlaceholders[0].placeholders;
458
+ cabinetPayload[cabinetPayloadKeys[i]]['tempPlaceholders'] = tempPlaceholders;
459
+ }
460
+ }
461
+ return _context4.abrupt("return", cabinetPayload);
462
+ case 2:
463
+ case "end":
464
+ return _context4.stop();
465
+ }
466
+ }, _callee4);
467
+ }));
468
+ return _updateCabinetPayload.apply(this, arguments);
469
+ }
470
+ export function handleExternalEvent(_x7) {
471
+ return _handleExternalEvent.apply(this, arguments);
472
+ }
473
+ function _handleExternalEvent() {
474
+ _handleExternalEvent = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(props) {
475
+ var evt, state, sLineCnt, elementJs, _element, catalog, outlineSVGData, catalogInstance, _evt$payload, moveType, moveValue, value, defaulTitle, _evt$payload2, doorStyle, itemCDS, isAll, _doorStyle, _value, _zoomValue, _value2, _zoomValue2, _evt$payload3, moldingInfo, isGlobal, _t5, _t6;
476
+ return _regeneratorRuntime.wrap(function (_context5) {
477
+ while (1) switch (_context5.prev = _context5.next) {
76
478
  case 0:
77
479
  evt = props.externalEvent;
78
480
  state = props.state.get('KitchenConfigurator');
79
- _t2 = evt === null || evt === void 0 ? void 0 : evt.type;
80
- _context2.next = _t2 === EXTERNAL_EVENT_TOGGLE_TO_3D ? 1 : _t2 === EXTERNAL_EVENT_TOGGLE_TO_2D ? 2 : _t2 === EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 3 : _t2 === EXTERNAL_EVENT_ADD_WALL ? 4 : _t2 === EXTERNAL_EVENT_ADD_ITEM ? 5 : _t2 === EXTERNAL_EVENT_MOVE_PAN ? 9 : _t2 === EXTERNAL_EVENT_NEW_PROJECT ? 15 : _t2 === EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 16 : _t2 === EXTERNAL_EVENT_SET_INITIAL_DATA ? 17 : _t2 === EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 18 : _t2 === EXTERNAL_EVENT_ZOOM_IN ? 19 : _t2 === EXTERNAL_EVENT_ZOOM_OUT ? 22 : _t2 === EXTERNAL_EVENT_UNDO ? 25 : _t2 === EXTERNAL_EVENT_REDO ? 26 : _t2 === EXTERNAL_EVENT_SET_MOLDING ? 27 : 28;
481
+ _t5 = evt === null || evt === void 0 ? void 0 : evt.type;
482
+ _context5.next = _t5 === EXTERNAL_EVENT_TOGGLE_TO_3D ? 1 : _t5 === EXTERNAL_EVENT_TOGGLE_TO_2D ? 2 : _t5 === EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 3 : _t5 === EXTERNAL_EVENT_ADD_WALL ? 4 : _t5 === EXTERNAL_EVENT_ADD_ITEM ? 5 : _t5 === EXTERNAL_EVENT_MOVE_PAN ? 10 : _t5 === EXTERNAL_EVENT_NEW_PROJECT ? 16 : _t5 === EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 17 : _t5 === EXTERNAL_EVENT_SET_INITIAL_DATA ? 18 : _t5 === EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 19 : _t5 === EXTERNAL_EVENT_ZOOM_IN ? 20 : _t5 === EXTERNAL_EVENT_ZOOM_OUT ? 23 : _t5 === EXTERNAL_EVENT_UNDO ? 26 : _t5 === EXTERNAL_EVENT_REDO ? 27 : _t5 === EXTERNAL_EVENT_SET_MOLDING ? 28 : 29;
81
483
  break;
82
484
  case 1:
83
485
  props.projectActions.setMode(MODE_IDLE_3D);
84
- return _context2.abrupt("continue", 28);
486
+ return _context5.abrupt("continue", 29);
85
487
  case 2:
86
488
  props.projectActions.setMode(MODE_IDLE);
87
- return _context2.abrupt("continue", 28);
489
+ return _context5.abrupt("continue", 29);
88
490
  case 3:
89
491
  sLineCnt = state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size;
90
492
  if (sLineCnt > 0) props.projectActions.setMode(MODE_ELEVATION_VIEW);
91
- return _context2.abrupt("continue", 28);
493
+ return _context5.abrupt("continue", 29);
92
494
  case 4:
93
495
  if (state.mode === MODE_IDLE || state.mode === MODE_2D_PAN) props.linesActions.selectToolDrawingLine('wall');else {
94
496
  props.projectActions.setMode(MODE_IDLE);
95
497
  props.linesActions.selectToolDrawingLine('wall');
96
498
  }
97
- return _context2.abrupt("continue", 28);
499
+ return _context5.abrupt("continue", 29);
98
500
  case 5:
99
501
  if (isEmpty(evt === null || evt === void 0 ? void 0 : evt.payload)) {
100
- _context2.next = 8;
502
+ _context5.next = 9;
101
503
  break;
102
504
  }
103
- element = evt.payload;
505
+ _element = evt.payload;
104
506
  catalog = state.getIn(['catalog']).toJS(); // add item to catalog of state
105
- if (!isEmpty(catalog === null || catalog === void 0 ? void 0 : catalog.elements[element.name])) {
106
- _context2.next = 7;
507
+ if (!isEmpty(catalog === null || catalog === void 0 ? void 0 : catalog.elements[_element.name])) {
508
+ _context5.next = 8;
107
509
  break;
108
510
  }
109
- _context2.next = 6;
110
- return loadSVGsByItem(element);
511
+ _context5.next = 6;
512
+ return loadSVGsByItem(_element);
111
513
  case 6:
112
- outlineSVGData = _context2.sent;
514
+ outlineSVGData = _context5.sent;
113
515
  catalogInstance = props.catalog;
114
- elementJs = exporter(_objectSpread(_objectSpread({}, element), {}, {
516
+ _context5.next = 7;
517
+ return updateCabinetPayload(_element);
518
+ case 7:
519
+ elementJs = _context5.sent;
520
+ elementJs = exporter(_objectSpread(_objectSpread({}, elementJs), {}, {
115
521
  outlineSVGData: outlineSVGData,
116
522
  type: 'cabinet',
117
523
  render2DItem: render2DItem,
@@ -121,51 +527,51 @@ function _handleExternalEvent() {
121
527
  catalogInstance.registerElement(elementJs);
122
528
  props.projectActions.addElementToCatalog(elementJs);
123
529
  }
124
- case 7:
530
+ case 8:
125
531
  // start drawing item
126
- ARRAY_3D_MODES.includes(state.mode) ? props.itemsActions.selectToolDrawingItem3D(element.name) : props.itemsActions.selectToolDrawingItem(element.name);
127
- props.projectActions.pushLastSelectedCatalogElementToHistory(element);
532
+ ARRAY_3D_MODES.includes(state.mode) ? props.itemsActions.selectToolDrawingItem3D(_element.name) : props.itemsActions.selectToolDrawingItem(_element.name);
533
+ props.projectActions.pushLastSelectedCatalogElementToHistory(_element);
128
534
  props.projectActions.setIsCabinetDrawing(true);
129
- case 8:
130
- return _context2.abrupt("continue", 28);
131
535
  case 9:
536
+ return _context5.abrupt("continue", 29);
537
+ case 10:
132
538
  _evt$payload = evt.payload, moveType = _evt$payload.moveType, moveValue = _evt$payload.moveValue;
133
539
  value = state.getIn(['viewer2D']).toJS();
134
- _t3 = moveType;
135
- _context2.next = _t3 === TOP ? 10 : _t3 === BOTTOM ? 11 : _t3 === RIGHT ? 12 : _t3 === LEFT ? 13 : 14;
540
+ _t6 = moveType;
541
+ _context5.next = _t6 === TOP ? 11 : _t6 === BOTTOM ? 12 : _t6 === RIGHT ? 13 : _t6 === LEFT ? 14 : 15;
136
542
  break;
137
- case 10:
138
- value.f -= moveValue;
139
- return _context2.abrupt("continue", 14);
140
543
  case 11:
141
- value.f += moveValue;
142
- return _context2.abrupt("continue", 14);
544
+ value.f -= moveValue;
545
+ return _context5.abrupt("continue", 15);
143
546
  case 12:
144
- value.e += moveValue;
145
- return _context2.abrupt("continue", 14);
547
+ value.f += moveValue;
548
+ return _context5.abrupt("continue", 15);
146
549
  case 13:
147
- value.e -= moveValue;
148
- return _context2.abrupt("continue", 14);
550
+ value.e += moveValue;
551
+ return _context5.abrupt("continue", 15);
149
552
  case 14:
150
- if (compareSVGRect(value)) props.viewer2DActions.updateCameraView(value);
151
- return _context2.abrupt("continue", 28);
553
+ value.e -= moveValue;
554
+ return _context5.abrupt("continue", 15);
152
555
  case 15:
556
+ if (compareSVGRect(value)) props.viewer2DActions.updateCameraView(value);
557
+ return _context5.abrupt("continue", 29);
558
+ case 16:
153
559
  defaulTitle = 'Untitle';
154
560
  props.projectActions.newProject();
155
561
  props.projectActions.rename(defaulTitle);
156
- return _context2.abrupt("continue", 28);
157
- case 16:
562
+ return _context5.abrupt("continue", 29);
563
+ case 17:
158
564
  _evt$payload2 = evt.payload, doorStyle = _evt$payload2.doorStyle, itemCDS = _evt$payload2.itemCDS, isAll = _evt$payload2.isAll;
159
565
  props.itemsActions.setDoorStyle(doorStyle, itemCDS, isAll);
160
- return _context2.abrupt("continue", 28);
161
- case 17:
566
+ return _context5.abrupt("continue", 29);
567
+ case 18:
162
568
  _doorStyle = evt.payload.doorStyle;
163
569
  props.itemsActions.setInitialDoorStyle(_doorStyle.doorStyle);
164
- return _context2.abrupt("continue", 28);
165
- case 18:
166
- props.projectActions.loadProject(evt.payload);
167
- return _context2.abrupt("continue", 28);
570
+ return _context5.abrupt("continue", 29);
168
571
  case 19:
572
+ props.projectActions.loadProject(evt.payload);
573
+ return _context5.abrupt("continue", 29);
574
+ case 20:
169
575
  _value = state.getIn(['viewer2D']).toJS();
170
576
  _value.a -= 0.1;
171
577
  _value.d -= 0.1;
@@ -173,17 +579,17 @@ function _handleExternalEvent() {
173
579
  _value.f += _value.SVGHeight * 0.1 / 2;
174
580
  _zoomValue = parseInt((_value.a - 0.5) / ZOOM_VARIABLE);
175
581
  if (!(_zoomValue > 404)) {
176
- _context2.next = 20;
582
+ _context5.next = 21;
177
583
  break;
178
584
  }
179
- return _context2.abrupt("return");
180
- case 20:
585
+ return _context5.abrupt("return");
586
+ case 21:
181
587
  if (!(_zoomValue < 35 || Number.isNaN(_zoomValue))) {
182
- _context2.next = 21;
588
+ _context5.next = 22;
183
589
  break;
184
590
  }
185
- return _context2.abrupt("return");
186
- case 21:
591
+ return _context5.abrupt("return");
592
+ case 22:
187
593
  while (!(_value.e <= 10)) {
188
594
  _value.e -= 0.1;
189
595
  }
@@ -197,8 +603,8 @@ function _handleExternalEvent() {
197
603
  _value.f += 0.1;
198
604
  }
199
605
  if (compareSVGRect(_value)) props.viewer2DActions.updateCameraView(_value);
200
- return _context2.abrupt("continue", 28);
201
- case 22:
606
+ return _context5.abrupt("continue", 29);
607
+ case 23:
202
608
  _value2 = state.getIn(['viewer2D']).toJS();
203
609
  _value2.a += 0.1;
204
610
  _value2.d += 0.1;
@@ -206,34 +612,34 @@ function _handleExternalEvent() {
206
612
  _value2.f -= _value2.SVGHeight * 0.1 / 2;
207
613
  _zoomValue2 = parseInt((_value2.a - 0.5) / ZOOM_VARIABLE);
208
614
  if (!(_zoomValue2 > 404)) {
209
- _context2.next = 23;
615
+ _context5.next = 24;
210
616
  break;
211
617
  }
212
- return _context2.abrupt("return");
213
- case 23:
618
+ return _context5.abrupt("return");
619
+ case 24:
214
620
  if (!(_zoomValue2 < 35 || Number.isNaN(_zoomValue2))) {
215
- _context2.next = 24;
621
+ _context5.next = 25;
216
622
  break;
217
623
  }
218
- return _context2.abrupt("return");
219
- case 24:
220
- if (compareSVGRect(_value2)) props.viewer2DActions.updateCameraView(_value2);
221
- return _context2.abrupt("continue", 28);
624
+ return _context5.abrupt("return");
222
625
  case 25:
223
- props.projectActions.undo();
224
- return _context2.abrupt("continue", 28);
626
+ if (compareSVGRect(_value2)) props.viewer2DActions.updateCameraView(_value2);
627
+ return _context5.abrupt("continue", 29);
225
628
  case 26:
226
- props.projectActions.redo();
227
- return _context2.abrupt("continue", 28);
629
+ props.projectActions.undo();
630
+ return _context5.abrupt("continue", 29);
228
631
  case 27:
632
+ props.projectActions.redo();
633
+ return _context5.abrupt("continue", 29);
634
+ case 28:
229
635
  _evt$payload3 = evt.payload, moldingInfo = _evt$payload3.moldingInfo, isGlobal = _evt$payload3.isGlobal;
230
636
  props.itemsActions.setMolding(moldingInfo, isGlobal);
231
- return _context2.abrupt("continue", 28);
232
- case 28:
637
+ return _context5.abrupt("continue", 29);
638
+ case 29:
233
639
  case "end":
234
- return _context2.stop();
640
+ return _context5.stop();
235
641
  }
236
- }, _callee2);
642
+ }, _callee5);
237
643
  }));
238
644
  return _handleExternalEvent.apply(this, arguments);
239
645
  }
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.handleExternalEvent = handleExternalEvent;
8
+ exports.parseTempPlaceholdersFromCabinetPayload = parseTempPlaceholdersFromCabinetPayload;
9
+ exports.updateCabinetPayload = updateCabinetPayload;
8
10
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
12
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
@@ -72,53 +74,458 @@ var loadSVGsByItem = /*#__PURE__*/function () {
72
74
  var compareSVGRect = function compareSVGRect(value) {
73
75
  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
76
  };
75
- function handleExternalEvent(_x2) {
76
- return _handleExternalEvent.apply(this, arguments);
77
+ function loadJSON(_x2, _x3, _x4) {
78
+ return _loadJSON.apply(this, arguments);
77
79
  }
78
- 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, itemCDS, isAll, _doorStyle, _value, _zoomValue, _value2, _zoomValue2, _evt$payload3, moldingInfo, isGlobal, _t2, _t3;
80
+ /********Parse TempPlaceholder from cabinetPayloadData **************/
81
+ function _loadJSON() {
82
+ _loadJSON = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(path, success, error) {
81
83
  return _regenerator["default"].wrap(function (_context2) {
82
84
  while (1) switch (_context2.prev = _context2.next) {
85
+ case 0:
86
+ return _context2.abrupt("return", new Promise(function (resolve, reject) {
87
+ var xhr = new XMLHttpRequest();
88
+ xhr.onreadystatechange = function () {
89
+ if (xhr.readyState === XMLHttpRequest.DONE) {
90
+ if (xhr.status === 200) {
91
+ resolve(JSON.parse(xhr.responseText));
92
+ } else {
93
+ reject(xhr);
94
+ }
95
+ }
96
+ };
97
+ xhr.open('GET', path, true);
98
+ xhr.send();
99
+ }));
100
+ case 1:
101
+ case "end":
102
+ return _context2.stop();
103
+ }
104
+ }, _callee2);
105
+ }));
106
+ return _loadJSON.apply(this, arguments);
107
+ }
108
+ function parseTempPlaceholdersFromCabinetPayload(_x5) {
109
+ return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments);
110
+ }
111
+ /***** Update cabinetPayloadData with updatedTempPlaceholders *****/
112
+ function _parseTempPlaceholdersFromCabinetPayload() {
113
+ _parseTempPlaceholdersFromCabinetPayload = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(cabinetPayload) {
114
+ var link, keys, temp, i, _cabinetPayload$struc, el, tempPlaceholdersData, tempData, doorKey, drawerKey, fixedKey, doorPHs, drawerPHs, has_single_door, fixedPHs, _t2, _t3, _t4;
115
+ return _regenerator["default"].wrap(function (_context3) {
116
+ while (1) switch (_context3.prev = _context3.next) {
117
+ case 0:
118
+ link = '';
119
+ keys = Object.keys(cabinetPayload.structure_json);
120
+ temp = [];
121
+ i = 0;
122
+ case 1:
123
+ if (!(i < keys.length)) {
124
+ _context3.next = 4;
125
+ break;
126
+ }
127
+ 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'))) {
128
+ _context3.next = 3;
129
+ break;
130
+ }
131
+ link = cabinetPayload.structure_json[keys[i]];
132
+ _t2 = temp;
133
+ _t3 = keys[i];
134
+ _context3.next = 2;
135
+ return loadJSON(link);
136
+ case 2:
137
+ _t4 = _context3.sent;
138
+ _t2.push.call(_t2, {
139
+ name: _t3,
140
+ data: _t4
141
+ });
142
+ case 3:
143
+ i++;
144
+ _context3.next = 1;
145
+ break;
146
+ case 4:
147
+ el = cabinetPayload.structure_json.tempPlaceholders[0].id;
148
+ tempPlaceholdersData = [];
149
+ tempData = {};
150
+ doorKey = 0;
151
+ drawerKey = 0;
152
+ fixedKey = 0;
153
+ doorPHs = 0;
154
+ drawerPHs = 0;
155
+ has_single_door = false;
156
+ fixedPHs = 0;
157
+ temp.forEach(function (t, index) {
158
+ var nodes = t.data.nodes;
159
+ if (nodes === undefined) {
160
+ nodes = [];
161
+ }
162
+ var tempPlaceholders = nodes.filter(function (element) {
163
+ return element.name.startsWith('ph_');
164
+ });
165
+ tempPlaceholders.sort(function (a, b) {
166
+ return a.name > b.name ? 1 : -1;
167
+ });
168
+ if (tempPlaceholders.length > 0) {
169
+ if (t.name === 'base') {
170
+ tempPlaceholders.map(function (element) {
171
+ var sink_match = element.name.match(/\d_(sink_[^LR12]*)(_[LR12])?$/);
172
+ if (sink_match && sink_match.length >= 2) {
173
+ tempData['sink'] = tempData['sink'] || [];
174
+ tempData['sink'].push(element.name);
175
+ var sink_url = process.env.DEV_HTTP + process.env.DEV_PORT + "/uploads/assets/default/".concat(sink_match[1], ".gltf");
176
+ json_data.sink = sink_url;
177
+ } else if (temp.some(function (felement) {
178
+ return felement.name.includes('base_drawer');
179
+ }) && element.name.includes('interior_drawer')) {
180
+ var objCnt = temp.filter(function (felement) {
181
+ return felement.name.includes('base_drawer') && !felement.name.includes('_door');
182
+ }).length;
183
+ var phCnt = tempPlaceholders.filter(function (felement) {
184
+ return felement.name.includes('interior');
185
+ }).length;
186
+ drawerPHs = phCnt;
187
+ if (objCnt === 1 || phCnt % objCnt !== 0) {
188
+ if (tempData['base_drawer_1'] === undefined) {
189
+ tempData['base_drawer_1'] = [];
190
+ }
191
+ tempData['base_drawer_1'].push(element.name);
192
+ drawerKey++;
193
+ } else if (objCnt > 1 && phCnt % objCnt === 0) {
194
+ if (tempData['base_drawer_' + (drawerKey % objCnt + 1)] === undefined) {
195
+ tempData['base_drawer_' + (drawerKey % objCnt + 1)] = [];
196
+ }
197
+ tempData['base_drawer_' + (drawerKey % objCnt + 1)].push(element.name);
198
+ drawerKey++;
199
+ }
200
+ } else if (temp.some(function (felement) {
201
+ return felement.name.includes('base_door');
202
+ }) && !element.name.includes('interior_drawer') && !element.name.includes('drawer') && element.name.includes('door')) {
203
+ var _objCnt = temp.filter(function (felement) {
204
+ return felement.name.includes('base_door');
205
+ }).length;
206
+ var _phCnt = tempPlaceholders.filter(function (felement) {
207
+ return !felement.name.includes('interior') && !felement.name.includes('drawer') && felement.name.includes('door');
208
+ }).length;
209
+ doorPHs = _phCnt;
210
+ if (_objCnt === 1 || _phCnt % _objCnt !== 0) {
211
+ if (tempData['base_door_1'] === undefined) {
212
+ tempData['base_door_1'] = [];
213
+ }
214
+ tempData['base_door_1'].push(element.name);
215
+ doorKey++;
216
+ } else if (_objCnt > 1) {
217
+ if (tempData['base_door_' + (doorKey % _objCnt + 1)] === undefined) {
218
+ tempData['base_door_' + (doorKey % _objCnt + 1)] = [];
219
+ }
220
+ tempData['base_door_' + (doorKey % _objCnt + 1)].push(element.name);
221
+ doorKey++;
222
+ }
223
+ } else if (temp.some(function (felement) {
224
+ return felement.name.includes('base_fixed_drawer_door');
225
+ }) && element.name.includes('_drawer_door_fixed')) {
226
+ var _objCnt2 = temp.filter(function (felement) {
227
+ return felement.name.includes('base_fixed_drawer_door');
228
+ }).length;
229
+ var _phCnt2 = tempPlaceholders.filter(function (felement) {
230
+ return felement.name.includes('_drawer_door_fixed');
231
+ }).length;
232
+ fixedPHs = _phCnt2;
233
+ if (_objCnt2 === 1 || _phCnt2 % _objCnt2 !== 0) {
234
+ if (tempData['base_fixed_drawer_door_1'] === undefined) {
235
+ tempData['base_fixed_drawer_door_1'] = [];
236
+ }
237
+ tempData['base_fixed_drawer_door_1'].push(element.name);
238
+ fixedKey++;
239
+ } else if (_objCnt2 > 1) {
240
+ if (tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] === undefined) {
241
+ tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] = [];
242
+ }
243
+ tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)].push(element.name);
244
+ fixedKey++;
245
+ }
246
+ }
247
+ });
248
+ } else if (t.name.includes('base_drawer') && !t.name.includes('_door')) {
249
+ var objCnt = temp.filter(function (felement) {
250
+ return felement.name.includes('base_drawer') && !felement.name.includes('_door');
251
+ }).length;
252
+ if (objCnt === 1 || drawerPHs % objCnt !== 0) {
253
+ if (tempData['base_drawer_door_1'] === undefined) tempData['base_drawer_door_1'] = [];
254
+ //get drawer door handle placeholders
255
+ var ph_temp = temp.find(function (felement) {
256
+ return felement.name === 'base_drawer_door_1';
257
+ });
258
+ if (ph_temp != undefined) {
259
+ var ph_drawer_door_handle = ph_temp.data.nodes;
260
+ ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) {
261
+ return element.name.startsWith('ph_') && element.name.includes('handle');
262
+ });
263
+ for (var w = 0; w < drawerPHs; w++) {
264
+ if (!tempData['base_drawer_door_1'].some(function (el) {
265
+ return el === 'base_drawer_door_1/' + tempPlaceholders[0].name;
266
+ })) {
267
+ tempData['base_drawer_door_1'].push('base_drawer_1/' + tempPlaceholders[0].name);
268
+ //add drawer door handle placeholders
269
+ if (tempData['drawer_door_handle_1'] === undefined) tempData['drawer_door_handle_1'] = [];
270
+ if (ph_drawer_door_handle.length > 0) tempData['drawer_door_handle_1'].push('base_drawer_door_1/' + ph_drawer_door_handle[0].name);
271
+ }
272
+ }
273
+ }
274
+ } else if (objCnt > 1 && drawerPHs > 0 && drawerPHs % objCnt === 0) {
275
+ if (tempData['base_drawer_door' + t.name.slice(-2)] === undefined) tempData['base_drawer_door' + t.name.slice(-2)] = [];
276
+ //get drawer door handle placeholders
277
+ var ph_temp = temp.find(function (felement) {
278
+ return felement.name === 'base_drawer_door' + t.name.slice(-2);
279
+ });
280
+ if (ph_temp != undefined) {
281
+ var ph_drawer_door_handle = ph_temp.data.data.nodes;
282
+ ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) {
283
+ return element.name.startsWith('ph_') && element.name.includes('handle');
284
+ });
285
+ tempPlaceholders.forEach(function (element) {
286
+ if (!tempData['base_drawer_door' + t.name.slice(-2)].some(function (el) {
287
+ return el === t.name + '/' + element.name;
288
+ })) {
289
+ tempData['base_drawer_door' + t.name.slice(-2)].push(t.name + '/' + element.name);
290
+ //add drawer door handle placeholders
291
+ if (tempData['drawer_door_handle' + t.name.slice(-2)] === undefined) tempData['drawer_door_handle' + t.name.slice(-2)] = [];
292
+ 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);
293
+ }
294
+ });
295
+ }
296
+ }
297
+ } else if (t.name.includes('base_door')) {
298
+ var _objCnt3 = temp.filter(function (felement) {
299
+ return felement.name.includes('base_door');
300
+ }).length;
301
+ tempPlaceholders = tempPlaceholders.filter(function (el) {
302
+ return el.name.includes('handle');
303
+ });
304
+ if (tempPlaceholders.length > 0) if (_objCnt3 === 1 || doorPHs % _objCnt3 !== 0) {
305
+ if (tempData['door_handle_1'] === undefined) {
306
+ tempData['door_handle_1'] = [];
307
+ }
308
+ var _loop = function _loop() {
309
+ var phname = tempPlaceholders[0].name;
310
+ var newph = undefined;
311
+ if (tempData['base_door_1'][_w].isLeftPlaceholder()) {
312
+ newph = tempPlaceholders.find(function (el) {
313
+ return el.name.isRightPlaceholder();
314
+ });
315
+ }
316
+ if (tempData['base_door_1'][_w].isRightPlaceholder()) {
317
+ newph = tempPlaceholders.find(function (el) {
318
+ return el.name.isLeftPlaceholder();
319
+ });
320
+ }
321
+ if (newph != undefined) {
322
+ phname = newph.name;
323
+ }
324
+ if (doorPHs === 1 && tempPlaceholders.find(function (el) {
325
+ return el.name.isLeftPlaceholder();
326
+ }) != undefined && tempPlaceholders.find(function (el) {
327
+ return el.name.isRightPlaceholder();
328
+ }) != undefined) {
329
+ has_single_door = true;
330
+ }
331
+ if (!tempData['door_handle_1'].some(function (el) {
332
+ return el === 'door_handle_1/' + phname;
333
+ })) {
334
+ tempData['door_handle_1'].push('base_door_1/' + phname);
335
+ }
336
+ };
337
+ for (var _w = 0; _w < doorPHs; _w++) {
338
+ _loop();
339
+ }
340
+ } else if (_objCnt3 > 1 && doorPHs > 0 && doorPHs % _objCnt3 === 0) {
341
+ if (tempData['door_handle' + t.name.slice(-2)] === undefined) tempData['door_handle' + t.name.slice(-2)] = [];
342
+ phname = tempPlaceholders[0].name;
343
+ newph = undefined;
344
+ var blAdd = true;
345
+ if (element.is_corner) {
346
+ if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
347
+ newph = tempPlaceholders.find(function (el) {
348
+ return el.name.isLeftPlaceholder();
349
+ });
350
+ } else {
351
+ blAdd = false;
352
+ }
353
+ } else {
354
+ if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
355
+ newph = tempPlaceholders.find(function (el) {
356
+ return el.name.isRightPlaceholder();
357
+ });
358
+ }
359
+ if (tempData['base_door' + t.name.slice(-2)][0].isRightPlaceholder()) {
360
+ newph = tempPlaceholders.find(function (el) {
361
+ return el.name.isLeftPlaceholder();
362
+ });
363
+ }
364
+ }
365
+ if (blAdd) {
366
+ if (newph != undefined) {
367
+ phname = newph.name;
368
+ }
369
+ if (!tempData['door_handle' + t.name.slice(-2)].some(function (el) {
370
+ return el === t.name + '/' + phname;
371
+ })) {
372
+ tempData['door_handle' + t.name.slice(-2)].push(t.name + '/' + phname);
373
+ }
374
+ }
375
+ }
376
+ } else if (t.name.includes('base_fixed_drawer_door')) {
377
+ var _objCnt4 = temp.filter(function (felement) {
378
+ return felement.name.includes('base_fixed_drawer_door');
379
+ }).length;
380
+ tempPlaceholders = tempPlaceholders.filter(function (el) {
381
+ return el.name.includes('handle');
382
+ });
383
+ if (tempPlaceholders.length > 0) if (_objCnt4 === 1 || fixedPHs % _objCnt4 !== 0) {
384
+ if (tempData['fixed_drawer_door_handle_1'] === undefined) tempData['fixed_drawer_door_handle_1'] = [];
385
+ for (var _w2 = 0; _w2 < fixedPHs; _w2++) {
386
+ phname = tempPlaceholders[0].name;
387
+ newph = undefined;
388
+ if (tempData['base_fixed_drawer_door_1'][_w2].isLeftPlaceholder()) {
389
+ newph = tempPlaceholders.find(function (el) {
390
+ return el.name.isRightPlaceholder();
391
+ });
392
+ }
393
+ if (tempData['base_fixed_drawer_door_1'][_w2].isRightPlaceholder()) {
394
+ newph = tempPlaceholders.find(function (el) {
395
+ return el.name.isLeftPlaceholder();
396
+ });
397
+ }
398
+ if (newph != undefined) {
399
+ phname = newph.name;
400
+ }
401
+ if (!tempData['fixed_drawer_door_handle_1'].some(function (el) {
402
+ return el === 'fixed_drawer_door_handle_1/' + phname;
403
+ })) {
404
+ tempData['fixed_drawer_door_handle_1'].push('base_fixed_drawer_door_1/' + phname);
405
+ }
406
+ }
407
+ } else if (_objCnt4 > 1 && fixedPHs > 0 && fixedPHs % _objCnt4 === 0) {
408
+ if (tempData['fixed_drawer_door_handle' + t.name.slice(-2)] === undefined) {
409
+ tempData['fixed_drawer_door_handle' + t.name.slice(-2)] = [];
410
+ }
411
+ phname = tempPlaceholders[0].name;
412
+ newph = undefined;
413
+ if (tempData['base_fixed_drawer_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
414
+ newph = tempPlaceholders.find(function (el) {
415
+ return el.name.isRightPlaceholder();
416
+ });
417
+ }
418
+ if (tempData['base_fixed_drawer_door' + t.name.slice(-2)][0].isRightPlaceholder()) {
419
+ newph = tempPlaceholders.find(function (el) {
420
+ return el.name.isLeftPlaceholder();
421
+ });
422
+ }
423
+ if (newph != undefined) {
424
+ phname = newph.name;
425
+ }
426
+ if (!tempData['fixed_drawer_door_handle' + t.name.slice(-2)].some(function (el) {
427
+ return el === t.name + '/' + phname;
428
+ })) {
429
+ tempData['fixed_drawer_door_handle' + t.name.slice(-2)].push(t.name + '/' + phname);
430
+ }
431
+ }
432
+ }
433
+ }
434
+ });
435
+ tempPlaceholdersData.push({
436
+ id: parseInt(el, 10),
437
+ placeholders: tempData
438
+ });
439
+ return _context3.abrupt("return", tempPlaceholdersData);
440
+ case 5:
441
+ case "end":
442
+ return _context3.stop();
443
+ }
444
+ }, _callee3);
445
+ }));
446
+ return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments);
447
+ }
448
+ function updateCabinetPayload(_x6) {
449
+ return _updateCabinetPayload.apply(this, arguments);
450
+ }
451
+ function _updateCabinetPayload() {
452
+ _updateCabinetPayload = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(cabinetPayload) {
453
+ var tempPlaceholders, cabinetPayloadKeys, i;
454
+ return _regenerator["default"].wrap(function (_context4) {
455
+ while (1) switch (_context4.prev = _context4.next) {
456
+ case 0:
457
+ tempPlaceholders = [];
458
+ _context4.next = 1;
459
+ return parseTempPlaceholdersFromCabinetPayload(cabinetPayload);
460
+ case 1:
461
+ tempPlaceholders = _context4.sent;
462
+ cabinetPayloadKeys = Object.keys(cabinetPayload);
463
+ for (i = 0; i < cabinetPayloadKeys.length; i++) {
464
+ if (cabinetPayloadKeys[i] === 'structure_json') {
465
+ cabinetPayload[cabinetPayloadKeys[i]]['placeholders'] = tempPlaceholders[0].placeholders;
466
+ cabinetPayload[cabinetPayloadKeys[i]]['tempPlaceholders'] = tempPlaceholders;
467
+ }
468
+ }
469
+ return _context4.abrupt("return", cabinetPayload);
470
+ case 2:
471
+ case "end":
472
+ return _context4.stop();
473
+ }
474
+ }, _callee4);
475
+ }));
476
+ return _updateCabinetPayload.apply(this, arguments);
477
+ }
478
+ function handleExternalEvent(_x7) {
479
+ return _handleExternalEvent.apply(this, arguments);
480
+ }
481
+ function _handleExternalEvent() {
482
+ _handleExternalEvent = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(props) {
483
+ var evt, state, sLineCnt, elementJs, _element, catalog, outlineSVGData, catalogInstance, _evt$payload, moveType, moveValue, value, defaulTitle, _evt$payload2, doorStyle, itemCDS, isAll, _doorStyle, _value, _zoomValue, _value2, _zoomValue2, _evt$payload3, moldingInfo, isGlobal, _t5, _t6;
484
+ return _regenerator["default"].wrap(function (_context5) {
485
+ while (1) switch (_context5.prev = _context5.next) {
83
486
  case 0:
84
487
  evt = props.externalEvent;
85
488
  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 : _t2 === _constants.EXTERNAL_EVENT_UNDO ? 25 : _t2 === _constants.EXTERNAL_EVENT_REDO ? 26 : _t2 === _constants.EXTERNAL_EVENT_SET_MOLDING ? 27 : 28;
489
+ _t5 = evt === null || evt === void 0 ? void 0 : evt.type;
490
+ _context5.next = _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_3D ? 1 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_2D ? 2 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 3 : _t5 === _constants.EXTERNAL_EVENT_ADD_WALL ? 4 : _t5 === _constants.EXTERNAL_EVENT_ADD_ITEM ? 5 : _t5 === _constants.EXTERNAL_EVENT_MOVE_PAN ? 10 : _t5 === _constants.EXTERNAL_EVENT_NEW_PROJECT ? 16 : _t5 === _constants.EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 17 : _t5 === _constants.EXTERNAL_EVENT_SET_INITIAL_DATA ? 18 : _t5 === _constants.EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 19 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_IN ? 20 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_OUT ? 23 : _t5 === _constants.EXTERNAL_EVENT_UNDO ? 26 : _t5 === _constants.EXTERNAL_EVENT_REDO ? 27 : _t5 === _constants.EXTERNAL_EVENT_SET_MOLDING ? 28 : 29;
88
491
  break;
89
492
  case 1:
90
493
  props.projectActions.setMode(_constants.MODE_IDLE_3D);
91
- return _context2.abrupt("continue", 28);
494
+ return _context5.abrupt("continue", 29);
92
495
  case 2:
93
496
  props.projectActions.setMode(_constants.MODE_IDLE);
94
- return _context2.abrupt("continue", 28);
497
+ return _context5.abrupt("continue", 29);
95
498
  case 3:
96
499
  sLineCnt = state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size;
97
500
  if (sLineCnt > 0) props.projectActions.setMode(_constants.MODE_ELEVATION_VIEW);
98
- return _context2.abrupt("continue", 28);
501
+ return _context5.abrupt("continue", 29);
99
502
  case 4:
100
503
  if (state.mode === _constants.MODE_IDLE || state.mode === _constants.MODE_2D_PAN) props.linesActions.selectToolDrawingLine('wall');else {
101
504
  props.projectActions.setMode(_constants.MODE_IDLE);
102
505
  props.linesActions.selectToolDrawingLine('wall');
103
506
  }
104
- return _context2.abrupt("continue", 28);
507
+ return _context5.abrupt("continue", 29);
105
508
  case 5:
106
509
  if ((0, _helper.isEmpty)(evt === null || evt === void 0 ? void 0 : evt.payload)) {
107
- _context2.next = 8;
510
+ _context5.next = 9;
108
511
  break;
109
512
  }
110
- element = evt.payload;
513
+ _element = evt.payload;
111
514
  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;
515
+ if (!(0, _helper.isEmpty)(catalog === null || catalog === void 0 ? void 0 : catalog.elements[_element.name])) {
516
+ _context5.next = 8;
114
517
  break;
115
518
  }
116
- _context2.next = 6;
117
- return loadSVGsByItem(element);
519
+ _context5.next = 6;
520
+ return loadSVGsByItem(_element);
118
521
  case 6:
119
- outlineSVGData = _context2.sent;
522
+ outlineSVGData = _context5.sent;
120
523
  catalogInstance = props.catalog;
121
- elementJs = (0, _exporter["default"])(_objectSpread(_objectSpread({}, element), {}, {
524
+ _context5.next = 7;
525
+ return updateCabinetPayload(_element);
526
+ case 7:
527
+ elementJs = _context5.sent;
528
+ elementJs = (0, _exporter["default"])(_objectSpread(_objectSpread({}, elementJs), {}, {
122
529
  outlineSVGData: outlineSVGData,
123
530
  type: 'cabinet',
124
531
  render2DItem: _itemLoader.render2DItem,
@@ -128,51 +535,51 @@ function _handleExternalEvent() {
128
535
  catalogInstance.registerElement(elementJs);
129
536
  props.projectActions.addElementToCatalog(elementJs);
130
537
  }
131
- case 7:
538
+ case 8:
132
539
  // start drawing item
133
- _constants.ARRAY_3D_MODES.includes(state.mode) ? props.itemsActions.selectToolDrawingItem3D(element.name) : props.itemsActions.selectToolDrawingItem(element.name);
134
- props.projectActions.pushLastSelectedCatalogElementToHistory(element);
540
+ _constants.ARRAY_3D_MODES.includes(state.mode) ? props.itemsActions.selectToolDrawingItem3D(_element.name) : props.itemsActions.selectToolDrawingItem(_element.name);
541
+ props.projectActions.pushLastSelectedCatalogElementToHistory(_element);
135
542
  props.projectActions.setIsCabinetDrawing(true);
136
- case 8:
137
- return _context2.abrupt("continue", 28);
138
543
  case 9:
544
+ return _context5.abrupt("continue", 29);
545
+ case 10:
139
546
  _evt$payload = evt.payload, moveType = _evt$payload.moveType, moveValue = _evt$payload.moveValue;
140
547
  value = state.getIn(['viewer2D']).toJS();
141
- _t3 = moveType;
142
- _context2.next = _t3 === _constants.TOP ? 10 : _t3 === _constants.BOTTOM ? 11 : _t3 === _constants.RIGHT ? 12 : _t3 === _constants.LEFT ? 13 : 14;
548
+ _t6 = moveType;
549
+ _context5.next = _t6 === _constants.TOP ? 11 : _t6 === _constants.BOTTOM ? 12 : _t6 === _constants.RIGHT ? 13 : _t6 === _constants.LEFT ? 14 : 15;
143
550
  break;
144
- case 10:
145
- value.f -= moveValue;
146
- return _context2.abrupt("continue", 14);
147
551
  case 11:
148
- value.f += moveValue;
149
- return _context2.abrupt("continue", 14);
552
+ value.f -= moveValue;
553
+ return _context5.abrupt("continue", 15);
150
554
  case 12:
151
- value.e += moveValue;
152
- return _context2.abrupt("continue", 14);
555
+ value.f += moveValue;
556
+ return _context5.abrupt("continue", 15);
153
557
  case 13:
154
- value.e -= moveValue;
155
- return _context2.abrupt("continue", 14);
558
+ value.e += moveValue;
559
+ return _context5.abrupt("continue", 15);
156
560
  case 14:
157
- if (compareSVGRect(value)) props.viewer2DActions.updateCameraView(value);
158
- return _context2.abrupt("continue", 28);
561
+ value.e -= moveValue;
562
+ return _context5.abrupt("continue", 15);
159
563
  case 15:
564
+ if (compareSVGRect(value)) props.viewer2DActions.updateCameraView(value);
565
+ return _context5.abrupt("continue", 29);
566
+ case 16:
160
567
  defaulTitle = 'Untitle';
161
568
  props.projectActions.newProject();
162
569
  props.projectActions.rename(defaulTitle);
163
- return _context2.abrupt("continue", 28);
164
- case 16:
570
+ return _context5.abrupt("continue", 29);
571
+ case 17:
165
572
  _evt$payload2 = evt.payload, doorStyle = _evt$payload2.doorStyle, itemCDS = _evt$payload2.itemCDS, isAll = _evt$payload2.isAll;
166
573
  props.itemsActions.setDoorStyle(doorStyle, itemCDS, isAll);
167
- return _context2.abrupt("continue", 28);
168
- case 17:
574
+ return _context5.abrupt("continue", 29);
575
+ case 18:
169
576
  _doorStyle = evt.payload.doorStyle;
170
577
  props.itemsActions.setInitialDoorStyle(_doorStyle.doorStyle);
171
- return _context2.abrupt("continue", 28);
172
- case 18:
173
- props.projectActions.loadProject(evt.payload);
174
- return _context2.abrupt("continue", 28);
578
+ return _context5.abrupt("continue", 29);
175
579
  case 19:
580
+ props.projectActions.loadProject(evt.payload);
581
+ return _context5.abrupt("continue", 29);
582
+ case 20:
176
583
  _value = state.getIn(['viewer2D']).toJS();
177
584
  _value.a -= 0.1;
178
585
  _value.d -= 0.1;
@@ -180,17 +587,17 @@ function _handleExternalEvent() {
180
587
  _value.f += _value.SVGHeight * 0.1 / 2;
181
588
  _zoomValue = parseInt((_value.a - 0.5) / _constants.ZOOM_VARIABLE);
182
589
  if (!(_zoomValue > 404)) {
183
- _context2.next = 20;
590
+ _context5.next = 21;
184
591
  break;
185
592
  }
186
- return _context2.abrupt("return");
187
- case 20:
593
+ return _context5.abrupt("return");
594
+ case 21:
188
595
  if (!(_zoomValue < 35 || Number.isNaN(_zoomValue))) {
189
- _context2.next = 21;
596
+ _context5.next = 22;
190
597
  break;
191
598
  }
192
- return _context2.abrupt("return");
193
- case 21:
599
+ return _context5.abrupt("return");
600
+ case 22:
194
601
  while (!(_value.e <= 10)) {
195
602
  _value.e -= 0.1;
196
603
  }
@@ -204,8 +611,8 @@ function _handleExternalEvent() {
204
611
  _value.f += 0.1;
205
612
  }
206
613
  if (compareSVGRect(_value)) props.viewer2DActions.updateCameraView(_value);
207
- return _context2.abrupt("continue", 28);
208
- case 22:
614
+ return _context5.abrupt("continue", 29);
615
+ case 23:
209
616
  _value2 = state.getIn(['viewer2D']).toJS();
210
617
  _value2.a += 0.1;
211
618
  _value2.d += 0.1;
@@ -213,34 +620,34 @@ function _handleExternalEvent() {
213
620
  _value2.f -= _value2.SVGHeight * 0.1 / 2;
214
621
  _zoomValue2 = parseInt((_value2.a - 0.5) / _constants.ZOOM_VARIABLE);
215
622
  if (!(_zoomValue2 > 404)) {
216
- _context2.next = 23;
623
+ _context5.next = 24;
217
624
  break;
218
625
  }
219
- return _context2.abrupt("return");
220
- case 23:
626
+ return _context5.abrupt("return");
627
+ case 24:
221
628
  if (!(_zoomValue2 < 35 || Number.isNaN(_zoomValue2))) {
222
- _context2.next = 24;
629
+ _context5.next = 25;
223
630
  break;
224
631
  }
225
- return _context2.abrupt("return");
226
- case 24:
227
- if (compareSVGRect(_value2)) props.viewer2DActions.updateCameraView(_value2);
228
- return _context2.abrupt("continue", 28);
632
+ return _context5.abrupt("return");
229
633
  case 25:
230
- props.projectActions.undo();
231
- return _context2.abrupt("continue", 28);
634
+ if (compareSVGRect(_value2)) props.viewer2DActions.updateCameraView(_value2);
635
+ return _context5.abrupt("continue", 29);
232
636
  case 26:
233
- props.projectActions.redo();
234
- return _context2.abrupt("continue", 28);
637
+ props.projectActions.undo();
638
+ return _context5.abrupt("continue", 29);
235
639
  case 27:
640
+ props.projectActions.redo();
641
+ return _context5.abrupt("continue", 29);
642
+ case 28:
236
643
  _evt$payload3 = evt.payload, moldingInfo = _evt$payload3.moldingInfo, isGlobal = _evt$payload3.isGlobal;
237
644
  props.itemsActions.setMolding(moldingInfo, isGlobal);
238
- return _context2.abrupt("continue", 28);
239
- case 28:
645
+ return _context5.abrupt("continue", 29);
646
+ case 29:
240
647
  case "end":
241
- return _context2.stop();
648
+ return _context5.stop();
242
649
  }
243
- }, _callee2);
650
+ }, _callee5);
244
651
  }));
245
652
  return _handleExternalEvent.apply(this, arguments);
246
653
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "1.0.0-clark.54",
3
+ "version": "1.0.0-clark.56",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",