kitchen-simulator 10.10.0 → 10.12.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.
@@ -97,9 +97,9 @@ function parseTempPlaceholdersFromCabinetPayload(_x2) {
97
97
  /***** Update cabinetPayloadData with updatedTempPlaceholders *****/
98
98
  function _parseTempPlaceholdersFromCabinetPayload() {
99
99
  _parseTempPlaceholdersFromCabinetPayload = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(cabinetPayload) {
100
- var link, keys, temp, i, _cabinetPayload$struc, _cabinetPayload$struc2, tempPlaceholdersData, _loop3, tempData, doorKey, drawerKey, fixedKey, doorPHs, drawerPHs, has_single_door, fixedPHs, k, _cabinetPayload$struc3, _t2, _t3, _t4;
101
- return _regenerator["default"].wrap(function (_context5) {
102
- while (1) switch (_context5.prev = _context5.next) {
100
+ 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;
101
+ return _regenerator["default"].wrap(function (_context4) {
102
+ while (1) switch (_context4.prev = _context4.next) {
103
103
  case 0:
104
104
  link = '';
105
105
  keys = Object.keys(cabinetPayload.structure_json);
@@ -107,356 +107,341 @@ function _parseTempPlaceholdersFromCabinetPayload() {
107
107
  i = 0;
108
108
  case 1:
109
109
  if (!(i < keys.length)) {
110
- _context5.next = 4;
110
+ _context4.next = 4;
111
111
  break;
112
112
  }
113
113
  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'))) {
114
- _context5.next = 3;
114
+ _context4.next = 3;
115
115
  break;
116
116
  }
117
117
  link = cabinetPayload.structure_json[keys[i]];
118
118
  _t2 = temp;
119
119
  _t3 = keys[i];
120
- _context5.next = 2;
120
+ _context4.next = 2;
121
121
  return loadJSON(link);
122
122
  case 2:
123
- _t4 = _context5.sent;
123
+ _t4 = _context4.sent;
124
124
  _t2.push.call(_t2, {
125
125
  name: _t3,
126
126
  data: _t4
127
127
  });
128
128
  case 3:
129
129
  i++;
130
- _context5.next = 1;
130
+ _context4.next = 1;
131
131
  break;
132
132
  case 4:
133
133
  tempPlaceholdersData = [];
134
- _loop3 = /*#__PURE__*/_regenerator["default"].mark(function _loop3(k) {
135
- var el;
136
- return _regenerator["default"].wrap(function (_context4) {
137
- while (1) switch (_context4.prev = _context4.next) {
138
- case 0:
139
- el = cabinetPayload.structure_json.tempPlaceholders[k].id;
140
- tempData = {};
141
- doorKey = 0;
142
- drawerKey = 0;
143
- fixedKey = 0;
144
- doorPHs = 0;
145
- drawerPHs = 0;
146
- has_single_door = false;
147
- fixedPHs = 0;
148
- temp.forEach(function (t, index) {
149
- var nodes = t.data.nodes;
150
- if (nodes === undefined) {
151
- nodes = [];
152
- }
153
- var tempPlaceholders = nodes.filter(function (element) {
154
- return element.name.startsWith('ph_');
155
- });
156
- tempPlaceholders.sort(function (a, b) {
157
- return a.name > b.name ? 1 : -1;
158
- });
159
- if (tempPlaceholders.length > 0) {
160
- if (t.name === 'base') {
161
- tempPlaceholders.map(function (element) {
162
- var sink_match = element.name.match(/\d_(sink_[^LR12]*)(_[LR12])?$/);
163
- if (sink_match && sink_match.length >= 2) {
164
- var _process$env$API_URL, _cabinetPayload$struc4;
165
- tempData['sink'] = tempData['sink'] || [];
166
- tempData['sink'].push(element.name);
167
- var sink_url = (_process$env$API_URL = process.env.API_URL) !== null && _process$env$API_URL !== void 0 ? _process$env$API_URL :
168
- // server url from 3DTool env
169
- import.meta.env.VITE_APP_API_URL + // server url from Host env
170
- "/uploads/assets/default/".concat(sink_match[1], ".gltf");
171
- if (cabinetPayload !== null && cabinetPayload !== void 0 && (_cabinetPayload$struc4 = cabinetPayload.structure_json) !== null && _cabinetPayload$struc4 !== void 0 && (_cabinetPayload$struc4 = _cabinetPayload$struc4.tempPlaceholders[k]) !== null && _cabinetPayload$struc4 !== void 0 && _cabinetPayload$struc4.structure) cabinetPayload.structure_json.tempPlaceholders[k].structure.sink = sink_url;
172
- } else if (temp.some(function (felement) {
173
- return felement.name.includes('base_drawer');
174
- }) && element.name.includes('interior_drawer')) {
175
- var objCnt = temp.filter(function (felement) {
176
- return felement.name.includes('base_drawer') && !felement.name.includes('_door');
177
- }).length;
178
- var phCnt = tempPlaceholders.filter(function (felement) {
179
- return felement.name.includes('interior');
180
- }).length;
181
- drawerPHs = phCnt;
182
- if (objCnt === 1 || phCnt % objCnt !== 0) {
183
- if (tempData['base_drawer_1'] === undefined) {
184
- tempData['base_drawer_1'] = [];
185
- }
186
- tempData['base_drawer_1'].push(element.name);
187
- drawerKey++;
188
- } else if (objCnt > 1 && phCnt % objCnt === 0) {
189
- if (tempData['base_drawer_' + (drawerKey % objCnt + 1)] === undefined) {
190
- tempData['base_drawer_' + (drawerKey % objCnt + 1)] = [];
191
- }
192
- tempData['base_drawer_' + (drawerKey % objCnt + 1)].push(element.name);
193
- drawerKey++;
194
- }
195
- } else if (temp.some(function (felement) {
196
- return felement.name.includes('base_door');
197
- }) && !element.name.includes('interior_drawer') && !element.name.includes('drawer') && element.name.includes('door')) {
198
- var _objCnt = temp.filter(function (felement) {
199
- return felement.name.includes('base_door');
200
- }).length;
201
- var _phCnt = tempPlaceholders.filter(function (felement) {
202
- return !felement.name.includes('interior') && !felement.name.includes('drawer') && felement.name.includes('door');
203
- }).length;
204
- doorPHs = _phCnt;
205
- if (_objCnt === 1 || _phCnt % _objCnt !== 0) {
206
- if (tempData['base_door_1'] === undefined) {
207
- tempData['base_door_1'] = [];
208
- }
209
- tempData['base_door_1'].push(element.name);
210
- doorKey++;
211
- } else if (_objCnt > 1) {
212
- if (tempData['base_door_' + (doorKey % _objCnt + 1)] === undefined) {
213
- tempData['base_door_' + (doorKey % _objCnt + 1)] = [];
214
- }
215
- tempData['base_door_' + (doorKey % _objCnt + 1)].push(element.name);
216
- doorKey++;
217
- }
218
- } else if (temp.some(function (felement) {
219
- return felement.name.includes('base_fixed_drawer_door');
220
- }) && element.name.includes('_drawer_door_fixed')) {
221
- var _objCnt2 = temp.filter(function (felement) {
222
- return felement.name.includes('base_fixed_drawer_door');
223
- }).length;
224
- var _phCnt2 = tempPlaceholders.filter(function (felement) {
225
- return felement.name.includes('_drawer_door_fixed');
226
- }).length;
227
- fixedPHs = _phCnt2;
228
- if (_objCnt2 === 1 || _phCnt2 % _objCnt2 !== 0) {
229
- if (tempData['base_fixed_drawer_door_1'] === undefined) {
230
- tempData['base_fixed_drawer_door_1'] = [];
231
- }
232
- tempData['base_fixed_drawer_door_1'].push(element.name);
233
- fixedKey++;
234
- } else if (_objCnt2 > 1) {
235
- if (tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] === undefined) {
236
- tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] = [];
237
- }
238
- tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)].push(element.name);
239
- fixedKey++;
240
- }
241
- }
242
- });
243
- } else if (t.name.includes('base_drawer') && !t.name.includes('_door')) {
134
+ 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++) {
135
+ el = cabinetPayload.structure_json.tempPlaceholders[k].id;
136
+ tempData = {};
137
+ doorKey = 0;
138
+ drawerKey = 0;
139
+ fixedKey = 0;
140
+ doorPHs = 0;
141
+ drawerPHs = 0;
142
+ has_single_door = false;
143
+ fixedPHs = 0;
144
+ temp.forEach(function (t, index) {
145
+ var nodes = t.data.nodes;
146
+ if (nodes === undefined) {
147
+ nodes = [];
148
+ }
149
+ var tempPlaceholders = nodes.filter(function (element) {
150
+ return element.name.startsWith('ph_');
151
+ });
152
+ tempPlaceholders.sort(function (a, b) {
153
+ return a.name > b.name ? 1 : -1;
154
+ });
155
+ if (tempPlaceholders.length > 0) {
156
+ if (t.name === 'base') {
157
+ tempPlaceholders.map(function (element) {
158
+ var sink_match = element.name.match(/\d_(sink_[^LR12]*)(_[LR12])?$/);
159
+ if (sink_match && sink_match.length >= 2) {
160
+ var _cabinetPayload$ccdf_;
161
+ tempData['sink'] = tempData['sink'] || [];
162
+ tempData['sink'].push(element.name);
163
+ // Resolve sink asset via ccdf.assets3d based on placeholder_name
164
+ var sinkPlaceholderName = sink_match[1]; // e.g. sink_farm_large
165
+ var assets3d = cabinetPayload === null || cabinetPayload === void 0 || (_cabinetPayload$ccdf_ = cabinetPayload.ccdf_list) === null || _cabinetPayload$ccdf_ === void 0 ? void 0 : _cabinetPayload$ccdf_.find(function (ccdf) {
166
+ return ccdf.cabinet_id === cabinetPayload.itemID;
167
+ }).assets3d;
168
+ var sinkAsset = Array.isArray(assets3d) && assets3d.find(function (a) {
169
+ return a && a.placeholder_name === sinkPlaceholderName && a.gltf;
170
+ });
171
+ if (sinkAsset !== null && sinkAsset !== void 0 && sinkAsset.gltf && cabinetPayload !== null && cabinetPayload !== void 0 && cabinetPayload.structure_json) {
172
+ cabinetPayload.structure_json.sink = sinkAsset.gltf;
173
+ } else if (temp.some(function (felement) {
174
+ return felement.name.includes('base_drawer');
175
+ }) && element.name.includes('interior_drawer')) {
244
176
  var objCnt = temp.filter(function (felement) {
245
177
  return felement.name.includes('base_drawer') && !felement.name.includes('_door');
246
178
  }).length;
247
- if (objCnt === 1 || drawerPHs % objCnt !== 0) {
248
- if (tempData['base_drawer_door_1'] === undefined) tempData['base_drawer_door_1'] = [];
249
- //get drawer door handle placeholders
250
- var ph_temp = temp.find(function (felement) {
251
- return felement.name === 'base_drawer_door_1';
252
- });
253
- if (ph_temp != undefined) {
254
- var ph_drawer_door_handle = ph_temp.data.nodes;
255
- ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) {
256
- return element.name.startsWith('ph_') && element.name.includes('handle');
257
- });
258
- for (var w = 0; w < drawerPHs; w++) {
259
- if (!tempData['base_drawer_door_1'].some(function (el) {
260
- return el === 'base_drawer_door_1/' + tempPlaceholders[0].name;
261
- })) {
262
- tempData['base_drawer_door_1'].push('base_drawer_1/' + tempPlaceholders[0].name);
263
- //add drawer door handle placeholders
264
- if (tempData['drawer_door_handle_1'] === undefined) tempData['drawer_door_handle_1'] = [];
265
- if (ph_drawer_door_handle.length > 0) tempData['drawer_door_handle_1'].push('base_drawer_door_1/' + ph_drawer_door_handle[0].name);
266
- }
267
- }
179
+ var phCnt = tempPlaceholders.filter(function (felement) {
180
+ return felement.name.includes('interior');
181
+ }).length;
182
+ drawerPHs = phCnt;
183
+ if (objCnt === 1 || phCnt % objCnt !== 0) {
184
+ if (tempData['base_drawer_1'] === undefined) {
185
+ tempData['base_drawer_1'] = [];
268
186
  }
269
- } else if (objCnt > 1 && drawerPHs > 0 && drawerPHs % objCnt === 0) {
270
- if (tempData['base_drawer_door' + t.name.slice(-2)] === undefined) tempData['base_drawer_door' + t.name.slice(-2)] = [];
271
- //get drawer door handle placeholders
272
- var ph_temp = temp.find(function (felement) {
273
- return felement.name === 'base_drawer_door' + t.name.slice(-2);
274
- });
275
- if (ph_temp != undefined) {
276
- var ph_drawer_door_handle = ph_temp.data.nodes;
277
- ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) {
278
- return element.name.startsWith('ph_') && element.name.includes('handle');
279
- });
280
- tempPlaceholders.forEach(function (element) {
281
- if (!tempData['base_drawer_door' + t.name.slice(-2)].some(function (el) {
282
- return el === t.name + '/' + element.name;
283
- })) {
284
- tempData['base_drawer_door' + t.name.slice(-2)].push(t.name + '/' + element.name);
285
- //add drawer door handle placeholders
286
- if (tempData['drawer_door_handle' + t.name.slice(-2)] === undefined) tempData['drawer_door_handle' + t.name.slice(-2)] = [];
287
- 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);
288
- }
289
- });
187
+ tempData['base_drawer_1'].push(element.name);
188
+ drawerKey++;
189
+ } else if (objCnt > 1 && phCnt % objCnt === 0) {
190
+ if (tempData['base_drawer_' + (drawerKey % objCnt + 1)] === undefined) {
191
+ tempData['base_drawer_' + (drawerKey % objCnt + 1)] = [];
290
192
  }
193
+ tempData['base_drawer_' + (drawerKey % objCnt + 1)].push(element.name);
194
+ drawerKey++;
291
195
  }
292
- } else if (t.name.includes('base_door')) {
293
- var _objCnt3 = temp.filter(function (felement) {
196
+ } else if (temp.some(function (felement) {
197
+ return felement.name.includes('base_door');
198
+ }) && !element.name.includes('interior_drawer') && !element.name.includes('drawer') && element.name.includes('door')) {
199
+ var _objCnt = temp.filter(function (felement) {
294
200
  return felement.name.includes('base_door');
295
201
  }).length;
296
- tempPlaceholders = tempPlaceholders.filter(function (el) {
297
- return el.name.includes('handle');
298
- });
299
- if (tempPlaceholders.length > 0) if (_objCnt3 === 1 || doorPHs % _objCnt3 !== 0) {
300
- if (tempData['door_handle_1'] === undefined) {
301
- tempData['door_handle_1'] = [];
302
- }
303
- var _loop4 = function _loop4() {
304
- var phname = tempPlaceholders[0].name;
305
- var newph = undefined;
306
- if (tempData['base_door_1'][_w].isLeftPlaceholder()) {
307
- newph = tempPlaceholders.find(function (el) {
308
- return el.name.isRightPlaceholder();
309
- });
310
- }
311
- if (tempData['base_door_1'][_w].isRightPlaceholder()) {
312
- newph = tempPlaceholders.find(function (el) {
313
- return el.name.isLeftPlaceholder();
314
- });
315
- }
316
- if (newph != undefined) {
317
- phname = newph.name;
318
- }
319
- if (doorPHs === 1 && tempPlaceholders.find(function (el) {
320
- return el.name.isLeftPlaceholder();
321
- }) != undefined && tempPlaceholders.find(function (el) {
322
- return el.name.isRightPlaceholder();
323
- }) != undefined) {
324
- has_single_door = true;
325
- }
326
- if (!tempData['door_handle_1'].some(function (el) {
327
- return el === 'door_handle_1/' + phname;
328
- })) {
329
- tempData['door_handle_1'].push('base_door_1/' + phname);
330
- }
331
- };
332
- for (var _w = 0; _w < doorPHs; _w++) {
333
- _loop4();
334
- }
335
- } else if (_objCnt3 > 1 && doorPHs > 0 && doorPHs % _objCnt3 === 0) {
336
- if (tempData['door_handle' + t.name.slice(-2)] === undefined) tempData['door_handle' + t.name.slice(-2)] = [];
337
- var phname = tempPlaceholders[0].name;
338
- var newph = undefined;
339
- var blAdd = true;
340
- if (cabinetPayload.is_corner) {
341
- if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
342
- newph = tempPlaceholders.find(function (el) {
343
- return el.name.isLeftPlaceholder();
344
- });
345
- } else {
346
- blAdd = false;
347
- }
348
- } else {
349
- if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
350
- newph = tempPlaceholders.find(function (el) {
351
- return el.name.isRightPlaceholder();
352
- });
353
- }
354
- if (tempData['base_door' + t.name.slice(-2)][0].isRightPlaceholder()) {
355
- newph = tempPlaceholders.find(function (el) {
356
- return el.name.isLeftPlaceholder();
357
- });
358
- }
202
+ var _phCnt = tempPlaceholders.filter(function (felement) {
203
+ return !felement.name.includes('interior') && !felement.name.includes('drawer') && felement.name.includes('door');
204
+ }).length;
205
+ doorPHs = _phCnt;
206
+ if (_objCnt === 1 || _phCnt % _objCnt !== 0) {
207
+ if (tempData['base_door_1'] === undefined) {
208
+ tempData['base_door_1'] = [];
359
209
  }
360
- if (blAdd) {
361
- if (newph != undefined) {
362
- phname = newph.name;
363
- }
364
- if (!tempData['door_handle' + t.name.slice(-2)].some(function (el) {
365
- return el === t.name + '/' + phname;
366
- })) {
367
- tempData['door_handle' + t.name.slice(-2)].push(t.name + '/' + phname);
368
- }
210
+ tempData['base_door_1'].push(element.name);
211
+ doorKey++;
212
+ } else if (_objCnt > 1) {
213
+ if (tempData['base_door_' + (doorKey % _objCnt + 1)] === undefined) {
214
+ tempData['base_door_' + (doorKey % _objCnt + 1)] = [];
369
215
  }
216
+ tempData['base_door_' + (doorKey % _objCnt + 1)].push(element.name);
217
+ doorKey++;
370
218
  }
371
- } else if (t.name.includes('base_fixed_drawer_door')) {
372
- var _objCnt4 = temp.filter(function (felement) {
219
+ } else if (temp.some(function (felement) {
220
+ return felement.name.includes('base_fixed_drawer_door');
221
+ }) && element.name.includes('_drawer_door_fixed')) {
222
+ var _objCnt2 = temp.filter(function (felement) {
373
223
  return felement.name.includes('base_fixed_drawer_door');
374
224
  }).length;
375
- tempPlaceholders = tempPlaceholders.filter(function (el) {
376
- return el.name.includes('handle');
377
- });
378
- if (tempPlaceholders.length > 0) if (_objCnt4 === 1 || fixedPHs % _objCnt4 !== 0) {
379
- if (tempData['fixed_drawer_door_handle_1'] === undefined) tempData['fixed_drawer_door_handle_1'] = [];
380
- var _loop5 = function _loop5() {
381
- var phname = tempPlaceholders[0].name;
382
- var newph = undefined;
383
- if (tempData['base_fixed_drawer_door_1'][_w2].isLeftPlaceholder()) {
384
- newph = tempPlaceholders.find(function (el) {
385
- return el.name.isRightPlaceholder();
386
- });
387
- }
388
- if (tempData['base_fixed_drawer_door_1'][_w2].isRightPlaceholder()) {
389
- newph = tempPlaceholders.find(function (el) {
390
- return el.name.isLeftPlaceholder();
391
- });
392
- }
393
- if (newph != undefined) {
394
- phname = newph.name;
395
- }
396
- if (!tempData['fixed_drawer_door_handle_1'].some(function (el) {
397
- return el === 'fixed_drawer_door_handle_1/' + phname;
398
- })) {
399
- tempData['fixed_drawer_door_handle_1'].push('base_fixed_drawer_door_1/' + phname);
400
- }
401
- };
402
- for (var _w2 = 0; _w2 < fixedPHs; _w2++) {
403
- _loop5();
404
- }
405
- } else if (_objCnt4 > 1 && fixedPHs > 0 && fixedPHs % _objCnt4 === 0) {
406
- if (tempData['fixed_drawer_door_handle' + t.name.slice(-2)] === undefined) {
407
- tempData['fixed_drawer_door_handle' + t.name.slice(-2)] = [];
408
- }
409
- var _phname = tempPlaceholders[0].name;
410
- var _newph = undefined;
411
- if (tempData['base_fixed_drawer_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
412
- _newph = tempPlaceholders.find(function (el) {
413
- return el.name.isRightPlaceholder();
414
- });
415
- }
416
- if (tempData['base_fixed_drawer_door' + t.name.slice(-2)][0].isRightPlaceholder()) {
417
- _newph = tempPlaceholders.find(function (el) {
418
- return el.name.isLeftPlaceholder();
419
- });
420
- }
421
- if (_newph != undefined) {
422
- _phname = _newph.name;
225
+ var _phCnt2 = tempPlaceholders.filter(function (felement) {
226
+ return felement.name.includes('_drawer_door_fixed');
227
+ }).length;
228
+ fixedPHs = _phCnt2;
229
+ if (_objCnt2 === 1 || _phCnt2 % _objCnt2 !== 0) {
230
+ if (tempData['base_fixed_drawer_door_1'] === undefined) {
231
+ tempData['base_fixed_drawer_door_1'] = [];
423
232
  }
424
- if (!tempData['fixed_drawer_door_handle' + t.name.slice(-2)].some(function (el) {
425
- return el === t.name + '/' + _phname;
426
- })) {
427
- tempData['fixed_drawer_door_handle' + t.name.slice(-2)].push(t.name + '/' + _phname);
233
+ tempData['base_fixed_drawer_door_1'].push(element.name);
234
+ fixedKey++;
235
+ } else if (_objCnt2 > 1) {
236
+ if (tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] === undefined) {
237
+ tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] = [];
428
238
  }
239
+ tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)].push(element.name);
240
+ fixedKey++;
429
241
  }
430
242
  }
431
243
  }
432
244
  });
433
- tempPlaceholdersData.push({
434
- id: parseInt(el, 10),
435
- placeholders: tempData,
436
- structure: cabinetPayload.structure_json.tempPlaceholders[k].structure
245
+ } else if (t.name.includes('base_drawer') && !t.name.includes('_door')) {
246
+ var objCnt = temp.filter(function (felement) {
247
+ return felement.name.includes('base_drawer') && !felement.name.includes('_door');
248
+ }).length;
249
+ if (objCnt === 1 || drawerPHs % objCnt !== 0) {
250
+ if (tempData['base_drawer_door_1'] === undefined) tempData['base_drawer_door_1'] = [];
251
+ //get drawer door handle placeholders
252
+ var ph_temp = temp.find(function (felement) {
253
+ return felement.name === 'base_drawer_door_1';
254
+ });
255
+ if (ph_temp != undefined) {
256
+ var ph_drawer_door_handle = ph_temp.data.nodes;
257
+ ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) {
258
+ return element.name.startsWith('ph_') && element.name.includes('handle');
259
+ });
260
+ for (var w = 0; w < drawerPHs; w++) {
261
+ if (!tempData['base_drawer_door_1'].some(function (el) {
262
+ return el === 'base_drawer_door_1/' + tempPlaceholders[0].name;
263
+ })) {
264
+ tempData['base_drawer_door_1'].push('base_drawer_1/' + tempPlaceholders[0].name);
265
+ //add drawer door handle placeholders
266
+ if (tempData['drawer_door_handle_1'] === undefined) tempData['drawer_door_handle_1'] = [];
267
+ if (ph_drawer_door_handle.length > 0) tempData['drawer_door_handle_1'].push('base_drawer_door_1/' + ph_drawer_door_handle[0].name);
268
+ }
269
+ }
270
+ }
271
+ } else if (objCnt > 1 && drawerPHs > 0 && drawerPHs % objCnt === 0) {
272
+ if (tempData['base_drawer_door' + t.name.slice(-2)] === undefined) tempData['base_drawer_door' + t.name.slice(-2)] = [];
273
+ //get drawer door handle placeholders
274
+ var ph_temp = temp.find(function (felement) {
275
+ return felement.name === 'base_drawer_door' + t.name.slice(-2);
276
+ });
277
+ if (ph_temp != undefined) {
278
+ var ph_drawer_door_handle = ph_temp.data.nodes;
279
+ ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) {
280
+ return element.name.startsWith('ph_') && element.name.includes('handle');
281
+ });
282
+ tempPlaceholders.forEach(function (element) {
283
+ if (!tempData['base_drawer_door' + t.name.slice(-2)].some(function (el) {
284
+ return el === t.name + '/' + element.name;
285
+ })) {
286
+ tempData['base_drawer_door' + t.name.slice(-2)].push(t.name + '/' + element.name);
287
+ //add drawer door handle placeholders
288
+ if (tempData['drawer_door_handle' + t.name.slice(-2)] === undefined) tempData['drawer_door_handle' + t.name.slice(-2)] = [];
289
+ 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);
290
+ }
291
+ });
292
+ }
293
+ }
294
+ } else if (t.name.includes('base_door')) {
295
+ var _objCnt3 = temp.filter(function (felement) {
296
+ return felement.name.includes('base_door');
297
+ }).length;
298
+ tempPlaceholders = tempPlaceholders.filter(function (el) {
299
+ return el.name.includes('handle');
437
300
  });
438
- case 1:
439
- case "end":
440
- return _context4.stop();
301
+ if (tempPlaceholders.length > 0) if (_objCnt3 === 1 || doorPHs % _objCnt3 !== 0) {
302
+ if (tempData['door_handle_1'] === undefined) {
303
+ tempData['door_handle_1'] = [];
304
+ }
305
+ var _loop3 = function _loop3() {
306
+ var phname = tempPlaceholders[0].name;
307
+ var newph = undefined;
308
+ if (tempData['base_door_1'][_w].isLeftPlaceholder()) {
309
+ newph = tempPlaceholders.find(function (el) {
310
+ return el.name.isRightPlaceholder();
311
+ });
312
+ }
313
+ if (tempData['base_door_1'][_w].isRightPlaceholder()) {
314
+ newph = tempPlaceholders.find(function (el) {
315
+ return el.name.isLeftPlaceholder();
316
+ });
317
+ }
318
+ if (newph != undefined) {
319
+ phname = newph.name;
320
+ }
321
+ if (doorPHs === 1 && tempPlaceholders.find(function (el) {
322
+ return el.name.isLeftPlaceholder();
323
+ }) != undefined && tempPlaceholders.find(function (el) {
324
+ return el.name.isRightPlaceholder();
325
+ }) != undefined) {
326
+ has_single_door = true;
327
+ }
328
+ if (!tempData['door_handle_1'].some(function (el) {
329
+ return el === 'door_handle_1/' + phname;
330
+ })) {
331
+ tempData['door_handle_1'].push('base_door_1/' + phname);
332
+ }
333
+ };
334
+ for (var _w = 0; _w < doorPHs; _w++) {
335
+ _loop3();
336
+ }
337
+ } else if (_objCnt3 > 1 && doorPHs > 0 && doorPHs % _objCnt3 === 0) {
338
+ if (tempData['door_handle' + t.name.slice(-2)] === undefined) tempData['door_handle' + t.name.slice(-2)] = [];
339
+ var phname = tempPlaceholders[0].name;
340
+ var newph = undefined;
341
+ var blAdd = true;
342
+ if (cabinetPayload.is_corner) {
343
+ if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
344
+ newph = tempPlaceholders.find(function (el) {
345
+ return el.name.isLeftPlaceholder();
346
+ });
347
+ } else {
348
+ blAdd = false;
349
+ }
350
+ } else {
351
+ if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
352
+ newph = tempPlaceholders.find(function (el) {
353
+ return el.name.isRightPlaceholder();
354
+ });
355
+ }
356
+ if (tempData['base_door' + t.name.slice(-2)][0].isRightPlaceholder()) {
357
+ newph = tempPlaceholders.find(function (el) {
358
+ return el.name.isLeftPlaceholder();
359
+ });
360
+ }
361
+ }
362
+ if (blAdd) {
363
+ if (newph != undefined) {
364
+ phname = newph.name;
365
+ }
366
+ if (!tempData['door_handle' + t.name.slice(-2)].some(function (el) {
367
+ return el === t.name + '/' + phname;
368
+ })) {
369
+ tempData['door_handle' + t.name.slice(-2)].push(t.name + '/' + phname);
370
+ }
371
+ }
372
+ }
373
+ } else if (t.name.includes('base_fixed_drawer_door')) {
374
+ var _objCnt4 = temp.filter(function (felement) {
375
+ return felement.name.includes('base_fixed_drawer_door');
376
+ }).length;
377
+ tempPlaceholders = tempPlaceholders.filter(function (el) {
378
+ return el.name.includes('handle');
379
+ });
380
+ if (tempPlaceholders.length > 0) if (_objCnt4 === 1 || fixedPHs % _objCnt4 !== 0) {
381
+ if (tempData['fixed_drawer_door_handle_1'] === undefined) tempData['fixed_drawer_door_handle_1'] = [];
382
+ var _loop4 = function _loop4() {
383
+ var phname = tempPlaceholders[0].name;
384
+ var newph = undefined;
385
+ if (tempData['base_fixed_drawer_door_1'][_w2].isLeftPlaceholder()) {
386
+ newph = tempPlaceholders.find(function (el) {
387
+ return el.name.isRightPlaceholder();
388
+ });
389
+ }
390
+ if (tempData['base_fixed_drawer_door_1'][_w2].isRightPlaceholder()) {
391
+ newph = tempPlaceholders.find(function (el) {
392
+ return el.name.isLeftPlaceholder();
393
+ });
394
+ }
395
+ if (newph != undefined) {
396
+ phname = newph.name;
397
+ }
398
+ if (!tempData['fixed_drawer_door_handle_1'].some(function (el) {
399
+ return el === 'fixed_drawer_door_handle_1/' + phname;
400
+ })) {
401
+ tempData['fixed_drawer_door_handle_1'].push('base_fixed_drawer_door_1/' + phname);
402
+ }
403
+ };
404
+ for (var _w2 = 0; _w2 < fixedPHs; _w2++) {
405
+ _loop4();
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
+ var _phname = tempPlaceholders[0].name;
412
+ var _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
+ }
441
433
  }
442
- }, _loop3);
443
- });
444
- k = 0;
445
- case 5:
446
- if (!(k < (cabinetPayload === null || cabinetPayload === void 0 || (_cabinetPayload$struc3 = cabinetPayload.structure_json) === null || _cabinetPayload$struc3 === void 0 || (_cabinetPayload$struc3 = _cabinetPayload$struc3.tempPlaceholders) === null || _cabinetPayload$struc3 === void 0 ? void 0 : _cabinetPayload$struc3.length))) {
447
- _context5.next = 7;
448
- break;
434
+ });
435
+ tempPlaceholdersData.push({
436
+ id: parseInt(el, 10),
437
+ placeholders: tempData,
438
+ structure: cabinetPayload.structure_json.tempPlaceholders[k].structure
439
+ });
449
440
  }
450
- return _context5.delegateYield(_loop3(k), "t0", 6);
451
- case 6:
452
- k++;
453
- _context5.next = 5;
454
- break;
455
- case 7:
456
- return _context5.abrupt("return", tempPlaceholdersData);
457
- case 8:
441
+ return _context4.abrupt("return", tempPlaceholdersData);
442
+ case 5:
458
443
  case "end":
459
- return _context5.stop();
444
+ return _context4.stop();
460
445
  }
461
446
  }, _callee4);
462
447
  }));
@@ -468,14 +453,14 @@ function updateCabinetPayload(_x3) {
468
453
  function _updateCabinetPayload() {
469
454
  _updateCabinetPayload = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(cabinetPayload) {
470
455
  var tempPlaceholders, cabinetPayloadKeys, i;
471
- return _regenerator["default"].wrap(function (_context6) {
472
- while (1) switch (_context6.prev = _context6.next) {
456
+ return _regenerator["default"].wrap(function (_context5) {
457
+ while (1) switch (_context5.prev = _context5.next) {
473
458
  case 0:
474
459
  tempPlaceholders = [];
475
- _context6.next = 1;
460
+ _context5.next = 1;
476
461
  return parseTempPlaceholdersFromCabinetPayload(cabinetPayload);
477
462
  case 1:
478
- tempPlaceholders = _context6.sent;
463
+ tempPlaceholders = _context5.sent;
479
464
  cabinetPayloadKeys = Object.keys(cabinetPayload);
480
465
  for (i = 0; i < cabinetPayloadKeys.length; i++) {
481
466
  if (cabinetPayloadKeys[i] === 'structure_json') {
@@ -487,10 +472,10 @@ function _updateCabinetPayload() {
487
472
  cabinetPayload[cabinetPayloadKeys[i]]['tempPlaceholders'] = tempPlaceholders;
488
473
  }
489
474
  }
490
- return _context6.abrupt("return", cabinetPayload);
475
+ return _context5.abrupt("return", cabinetPayload);
491
476
  case 2:
492
477
  case "end":
493
- return _context6.stop();
478
+ return _context5.stop();
494
479
  }
495
480
  }, _callee5);
496
481
  }));
@@ -594,22 +579,22 @@ function _addItemToCatalog() {
594
579
  _addItemToCatalog = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6(element, state, catalogInstance, projectActions) {
595
580
  var _elementJs, _elementJs3;
596
581
  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;
597
- return _regenerator["default"].wrap(function (_context7) {
598
- while (1) switch (_context7.prev = _context7.next) {
582
+ return _regenerator["default"].wrap(function (_context6) {
583
+ while (1) switch (_context6.prev = _context6.next) {
599
584
  case 0:
600
585
  if (!(0, _helper.isEmpty)(element === null || element === void 0 ? void 0 : element.name)) {
601
- _context7.next = 1;
586
+ _context6.next = 1;
602
587
  break;
603
588
  }
604
- return _context7.abrupt("return");
589
+ return _context6.abrupt("return");
605
590
  case 1:
606
591
  elementJs = populateCCDFList(element); // if (isEmpty(catalog?.elements[element.name])) {
607
- _context7.next = 2;
592
+ _context6.next = 2;
608
593
  return loadSVGsByItem(elementJs);
609
594
  case 2:
610
- outlineSVGData = _context7.sent;
595
+ outlineSVGData = _context6.sent;
611
596
  if (!(((_elementJs = elementJs) === null || _elementJs === void 0 ? void 0 : _elementJs.type) === 'cabinet')) {
612
- _context7.next = 4;
597
+ _context6.next = 4;
613
598
  break;
614
599
  }
615
600
  // move the tempPlaceholder of current door style to first of tempPlaceholders array
@@ -637,13 +622,13 @@ function _addItemToCatalog() {
637
622
  }
638
623
  });
639
624
  if ((0, _helper.isEmpty)((_elementJs$structure_3 = elementJs.structure_json) === null || _elementJs$structure_3 === void 0 ? void 0 : _elementJs$structure_3.tempPlaceholders)) {
640
- _context7.next = 4;
625
+ _context6.next = 4;
641
626
  break;
642
627
  }
643
- _context7.next = 3;
628
+ _context6.next = 3;
644
629
  return updateCabinetPayload(elementJs);
645
630
  case 3:
646
- elementJs = _context7.sent;
631
+ elementJs = _context6.sent;
647
632
  case 4:
648
633
  elementJs = _objectSpread(_objectSpread({}, elementJs), {}, {
649
634
  outlineSVGData: outlineSVGData,
@@ -660,18 +645,18 @@ function _addItemToCatalog() {
660
645
  k = 0;
661
646
  case 5:
662
647
  if (!(k < catalogElementKeys.length)) {
663
- _context7.next = 7;
648
+ _context6.next = 7;
664
649
  break;
665
650
  }
666
651
  if (!(((_catalogElements$cata = catalogElements[catalogElementKeys[k]]) === null || _catalogElements$cata === void 0 ? void 0 : _catalogElements$cata.itemID) === elementJs.itemID)) {
667
- _context7.next = 6;
652
+ _context6.next = 6;
668
653
  break;
669
654
  }
670
655
  catalogItem = catalogElements[catalogElementKeys[k]];
671
- return _context7.abrupt("continue", 7);
656
+ return _context6.abrupt("continue", 7);
672
657
  case 6:
673
658
  k++;
674
- _context7.next = 5;
659
+ _context6.next = 5;
675
660
  break;
676
661
  case 7:
677
662
  // get old tempPlaceholder array from catalog item
@@ -702,7 +687,7 @@ function _addItemToCatalog() {
702
687
  }
703
688
  case 8:
704
689
  case "end":
705
- return _context7.stop();
690
+ return _context6.stop();
706
691
  }
707
692
  }, _callee6);
708
693
  }));
@@ -1069,10 +1054,10 @@ function loadMoldingSvg(_x9) {
1069
1054
  }
1070
1055
  function _loadMoldingSvg() {
1071
1056
  _loadMoldingSvg = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7(molding) {
1072
- return _regenerator["default"].wrap(function (_context8) {
1073
- while (1) switch (_context8.prev = _context8.next) {
1057
+ return _regenerator["default"].wrap(function (_context7) {
1058
+ while (1) switch (_context7.prev = _context7.next) {
1074
1059
  case 0:
1075
- return _context8.abrupt("return", new Promise(function (resolve, reject) {
1060
+ return _context7.abrupt("return", new Promise(function (resolve, reject) {
1076
1061
  var url = molding === null || molding === void 0 ? void 0 : molding.shape_svg;
1077
1062
  if (!url) {
1078
1063
  // Skip if no SVG URL available
@@ -1094,7 +1079,7 @@ function _loadMoldingSvg() {
1094
1079
  }));
1095
1080
  case 1:
1096
1081
  case "end":
1097
- return _context8.stop();
1082
+ return _context7.stop();
1098
1083
  }
1099
1084
  }, _callee7);
1100
1085
  }));