kitchen-simulator 4.0.0-queuedEvents → 4.0.0

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