kitchen-simulator 3.1.10 → 3.1.11

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.
@@ -13,6 +13,7 @@ import { convert } from "./convert-units-lite";
13
13
  import { GeometryUtils, MathUtils } from "./export";
14
14
  import { returnReplaceableDeepSearchType } from "../components/viewer2d/utils";
15
15
  import { SVGLoader } from 'three/addons/loaders/SVGLoader';
16
+ import { getMoldingDataOfScene } from "./molding";
16
17
  var PRECISION = 2;
17
18
  function loadJSON(_x) {
18
19
  return _loadJSON.apply(this, arguments);
@@ -1058,13 +1059,15 @@ export function handleExternalEvent(_x10) {
1058
1059
  function _handleExternalEvent() {
1059
1060
  _handleExternalEvent = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(props) {
1060
1061
  var _evt$payload3, _evt$payload4;
1061
- var evt, state, _evt$payload, cdsItems, itemKeys, _loop3, i, _props$onInternalEven, sLineCnt, element, _state$viewer2D, _evt$payload$initialP, mouseX, mouseY, v2d, vPosX, vPosY, layerID, defaulTitle, _Object$keys, _evt$payload5, doorStyle, itemCDS, isAll, layerId, _cdsItems, allItems, selectedItemId, _itemKeys, _loop4, _i2, _props$onInternalEven2, _evt$payload6, roomShapeType, width, height, _doorStyle, value, _value, _evt$payload7, moldingInfo, isGlobal, distElement, _distElement, _evt$payload8, option, _value2, _layerId, layer, _layer$getIn, selectedLines, selectedHoles, selectedItems, _i4, _i5, _i6, _evt$payload9, _evt$payload0, _evt$payload1, _evt$payload10, _layerID, _layer, orginalItemInfo, originalItem, originalItemPos, replaceItem, _props$onInternalEven3, _t5;
1062
+ var evt, state, layerId, layer, _evt$payload, cdsItems, itemKeys, _loop3, i, _props$onInternalEven, sLineCnt, element, _state$viewer2D, _evt$payload$initialP, mouseX, mouseY, v2d, vPosX, vPosY, layerID, defaulTitle, _Object$keys, _evt$payload5, doorStyle, itemCDS, isAll, _layerId, _cdsItems, allItems, selectedItemId, _itemKeys, _loop4, _i2, _props$onInternalEven2, _evt$payload6, roomShapeType, width, height, _doorStyle, value, _value, _evt$payload7, moldingInfo, isGlobal, distElement, _distElement, _evt$payload8, option, _value2, _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;
1062
1063
  return _regeneratorRuntime.wrap(function (_context1) {
1063
1064
  while (1) switch (_context1.prev = _context1.next) {
1064
1065
  case 0:
1065
1066
  // console.log('***external event****', props);
1066
1067
  evt = props.externalEvent;
1067
1068
  state = props.state.get('KitchenConfigurator');
1069
+ layerId = state.getIn(['scene', 'selectedLayer']);
1070
+ layer = state.getIn(['scene', 'layers', layerId]);
1068
1071
  _t5 = evt === null || evt === void 0 ? void 0 : evt.type;
1069
1072
  _context1.next = _t5 === EXTERNAL_EVENT_LOAD_PROJECT ? 1 : _t5 === EXTERNAL_EVENT_TOGGLE_TO_3D ? 5 : _t5 === EXTERNAL_EVENT_TOGGLE_TO_2D ? 6 : _t5 === EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 7 : _t5 === EXTERNAL_EVENT_ADD_WALL ? 8 : _t5 === EXTERNAL_EVENT_ADD_ITEM ? 9 : _t5 === EXTERNAL_EVENT_ADD_HOLE ? 12 : _t5 === EXTERNAL_EVENT_MOVE_PAN ? 13 : _t5 === EXTERNAL_EVENT_NEW_PROJECT ? 14 : _t5 === EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 15 : _t5 === EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 19 : _t5 === EXTERNAL_EVENT_ZOOM_IN ? 20 : _t5 === EXTERNAL_EVENT_ZOOM_OUT ? 21 : _t5 === EXTERNAL_EVENT_CENTERING_2D ? 22 : _t5 === EXTERNAL_EVENT_UNDO ? 23 : _t5 === EXTERNAL_EVENT_REDO ? 24 : _t5 === EXTERNAL_EVENT_SET_MOLDING ? 25 : _t5 === EXTERNAL_EVENT_DUPLICATE_ELEMENT ? 27 : _t5 === EXTERNAL_EVENT_DELETE_ELEMENT ? 28 : _t5 === EXTERNAL_EVENT_PROJECT_SETTING ? 29 : _t5 === EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? 30 : _t5 === EXTERNAL_EVENT_UPDATE_PROPERTY ? 30 : _t5 === EXTERNAL_EVENT_REPLACE_CABINET ? 31 : _t5 === EXTERNAL_EVENT_SET_FINISHING ? 33 : _t5 === EXTERNAL_EVENT_SYNC_SCENE ? 34 : 35;
1070
1073
  break;
@@ -1155,7 +1158,7 @@ function _handleExternalEvent() {
1155
1158
  props.projectActions.setMode(MODE_IDLE);
1156
1159
  return _context1.abrupt("continue", 35);
1157
1160
  case 7:
1158
- sLineCnt = state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size;
1161
+ sLineCnt = layer.selected.lines.size;
1159
1162
  if (sLineCnt > 0) props.projectActions.setMode(MODE_ELEVATION_VIEW);
1160
1163
  return _context1.abrupt("continue", 35);
1161
1164
  case 8:
@@ -1208,10 +1211,10 @@ function _handleExternalEvent() {
1208
1211
  return _context1.abrupt("continue", 35);
1209
1212
  case 15:
1210
1213
  _evt$payload5 = evt.payload, doorStyle = _evt$payload5.doorStyle, itemCDS = _evt$payload5.itemCDS, isAll = _evt$payload5.isAll; // prepare item data request
1211
- layerId = state.getIn(['scene', 'selectedLayer']);
1214
+ _layerId = state.getIn(['scene', 'selectedLayer']);
1212
1215
  _cdsItems = [];
1213
- allItems = state.getIn(['scene', 'layers', layerId, 'items']).toJS();
1214
- selectedItemId = state.getIn(['scene', 'layers', layerId]).selected.items.toJS()[0];
1216
+ allItems = state.getIn(['scene', 'layers', _layerId, 'items']).toJS();
1217
+ selectedItemId = state.getIn(['scene', 'layers', _layerId]).selected.items.toJS()[0];
1215
1218
  _itemKeys = isAll ? (_Object$keys = Object.keys(allItems)) !== null && _Object$keys !== void 0 ? _Object$keys : [] : [selectedItemId];
1216
1219
  _loop4 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop4() {
1217
1220
  var _itemCDS$find;
@@ -1351,18 +1354,18 @@ function _handleExternalEvent() {
1351
1354
  }
1352
1355
  return _context1.abrupt("continue", 35);
1353
1356
  case 30:
1354
- _layerId = state.getIn(['scene', 'selectedLayer']);
1355
- layer = state.getIn(['scene', 'layers', _layerId]);
1356
- _layer$getIn = layer.getIn(['selected']), selectedLines = _layer$getIn.lines, selectedHoles = _layer$getIn.holes, selectedItems = _layer$getIn.items;
1357
- 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);
1358
- 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);
1359
- 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);
1357
+ _layerId2 = state.getIn(['scene', 'selectedLayer']);
1358
+ _layer = state.getIn(['scene', 'layers', _layerId2]);
1359
+ _layer$getIn = _layer.getIn(['selected']), selectedLines = _layer$getIn.lines, selectedHoles = _layer$getIn.holes, selectedItems = _layer$getIn.items;
1360
+ 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);
1361
+ 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);
1362
+ 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);
1360
1363
  return _context1.abrupt("continue", 35);
1361
1364
  case 31:
1362
1365
  _layerID = state.scene.selectedLayer;
1363
- _layer = state.scene.getIn(['layers', _layerID]).toJS();
1366
+ _layer2 = state.scene.getIn(['layers', _layerID]).toJS();
1364
1367
  orginalItemInfo = evt === null || evt === void 0 || (_evt$payload9 = evt.payload) === null || _evt$payload9 === void 0 ? void 0 : _evt$payload9.orginalItemInfo;
1365
- originalItem = _layer === null || _layer === void 0 ? void 0 : _layer.items[orginalItemInfo.id];
1368
+ originalItem = _layer2 === null || _layer2 === void 0 ? void 0 : _layer2.items[orginalItemInfo.id];
1366
1369
  _context1.next = 32;
1367
1370
  return addItemToCatalog(evt.payload.replaceItemInfo, state, props.catalog, props.projectActions);
1368
1371
  case 32:
@@ -1384,11 +1387,14 @@ function _handleExternalEvent() {
1384
1387
  case 33:
1385
1388
  setFinishing(props, state, evt.payload);
1386
1389
  case 34:
1390
+ sceneData = state.scene.toJS(); // get molding data for "ReviewForQuote"
1391
+ currentTexture = layer.doorStyle !== null || layer.doorStyle !== undefined ? layer.doorStyle : props.state.doorStyle.toJS();
1392
+ sceneData.layers[layerId].moldingData = getMoldingDataOfScene(layer, props.catalog, currentTexture);
1387
1393
  // send scene object from 3DTool to HostApp using internalEvent
1388
1394
  (_props$onInternalEven3 = props.onInternalEvent) === null || _props$onInternalEven3 === void 0 || _props$onInternalEven3.call(props, {
1389
1395
  type: INTERNAL_EVENT_SYNC_SCENE,
1390
1396
  value: {
1391
- scene: state.scene.toJS()
1397
+ scene: sceneData
1392
1398
  }
1393
1399
  });
1394
1400
  return _context1.abrupt("continue", 35);
@@ -5,11 +5,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
5
5
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
6
6
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
7
7
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
8
- import { BASE_CABINET_LAYOUTPOS, BOTTOM_MOLDING_LOCATION, EPSILON, MIDDLE_MOLDING_LOCATION, MOLDING_LOCATIONS, OVERLAP_INCLUDED, OVERLAP_LINK, OVERLAP_SAME, OVERLAP_SOME, TALL_CABINET_LAYOUTPOS, TOP_MOLDING_LOCATION, WALL_CABINET_LAYOUTPOS } from "../constants";
8
+ import { BASE_CABINET_LAYOUTPOS, BOTTOM_MOLDING_LOCATION, EPSILON, MIDDLE_MOLDING_LOCATION, MOLDING_LOCATIONS, OVERLAP_INCLUDED, OVERLAP_LINK, OVERLAP_SAME, OVERLAP_SOME, TALL_CABINET_LAYOUTPOS, TOE_KICK_MOLDING, TOP_MOLDING_LOCATION, WALL_CABINET_LAYOUTPOS } from "../constants";
9
9
  import * as Three from 'three';
10
10
  import { convert } from "./convert-units-lite";
11
11
  import IDBroker from "./id-broker";
12
- import { returnReplaceableDeepSearchType } from "../components/viewer2d/utils";
12
+ import { getToeKickSKU, isEqualInstallationType, returnReplaceableDeepSearchType } from "../components/viewer2d/utils";
13
13
  import { GeometryUtils } from "./export";
14
14
  import { isEmpty } from "./helper";
15
15
  export function getItemRect(item) {
@@ -866,4 +866,236 @@ export function createMonldingGroup(oldMG, layer, molding, catalog) {
866
866
  newMG.lines.reverse();
867
867
  newMG = getMDPoints(newMG);
868
868
  return newMG;
869
+ }
870
+ export function getMoldingDataOfScene(layer, catalog, doorStyle) {
871
+ var moldingData = [];
872
+ var items = layer.items.toArray();
873
+ var moldings = [];
874
+ // get all moldings info
875
+ items.forEach(function (itemCat) {
876
+ var _itemCat$molding;
877
+ itemCat === null || itemCat === void 0 || (_itemCat$molding = itemCat.molding) === null || _itemCat$molding === void 0 || _itemCat$molding.forEach(function (molding) {
878
+ if (!moldings.some(function (m) {
879
+ return m.name === molding.name;
880
+ })) moldings.push(molding);
881
+ });
882
+ });
883
+
884
+ // calc normal molding
885
+ moldings.forEach(function (molding) {
886
+ var itemGroups = [];
887
+ var temp_items = [];
888
+ items.forEach(function (item) {
889
+ if (item.molding.some(function (mol) {
890
+ return mol.itemID === molding.itemID;
891
+ }) && isEnableItemForMolding(layer, item)) {
892
+ temp_items.push(item);
893
+ }
894
+ });
895
+ if (temp_items.length) {
896
+ while (temp_items.length > 0) {
897
+ var itemGroup = [temp_items[0]];
898
+ var _loop9 = function _loop9(_idx) {
899
+ if (!itemGroup.some(function (it) {
900
+ return it.id === temp_items[_idx].id;
901
+ }) && isItemSnappedGroup(temp_items[_idx], itemGroup)) {
902
+ itemGroup.push(temp_items[_idx]);
903
+ _idx = 0;
904
+ }
905
+ idx = _idx;
906
+ };
907
+ for (var idx = 0; idx < temp_items.length; idx++) {
908
+ _loop9(idx);
909
+ }
910
+ itemGroup.forEach(function (item) {
911
+ var index = temp_items.findIndex(function (it) {
912
+ return it.id === item.id;
913
+ });
914
+ if (index > -1) {
915
+ temp_items.splice(index, 1);
916
+ }
917
+ });
918
+ itemGroups.push(itemGroup);
919
+ }
920
+ var molding_totalLength = 0;
921
+ itemGroups.forEach(function (itemgroup) {
922
+ var allLineRects = GeometryUtils.buildRectFromLines(layer, GeometryUtils.getAllLines(layer));
923
+ var items = _toConsumableArray(itemgroup);
924
+ var MGlines = getLinesOfItem(items[0], allLineRects, catalog);
925
+ items = sortItemsByDistance(items, items[0]);
926
+ var _loop0 = function _loop0() {
927
+ var itemLines = getLinesOfItem(items[i], allLineRects, catalog);
928
+ var temp_MGLines = [];
929
+ MGlines.forEach(function (line) {
930
+ var idx = itemLines.findIndex(function (itemLine) {
931
+ return isLinesOverlapped(line, itemLine);
932
+ });
933
+ var curItemLine = itemLines[idx];
934
+ if (idx > -1) {
935
+ if (!(GeometryUtils.samePoints(line[0], curItemLine[0]) && GeometryUtils.samePoints(line[1], curItemLine[1]) || GeometryUtils.samePoints(line[0], curItemLine[1]) && GeometryUtils.samePoints(line[1], curItemLine[0]))) {
936
+ var MGLine = mergeOverlappedLines(line, curItemLine);
937
+ temp_MGLines.push(MGLine);
938
+ }
939
+ itemLines.splice(idx, 1);
940
+ } else {
941
+ temp_MGLines.push(line);
942
+ }
943
+ });
944
+ itemLines.forEach(function (itemLine) {
945
+ return temp_MGLines.push(itemLine);
946
+ });
947
+ MGlines = [].concat(temp_MGLines);
948
+ };
949
+ for (var i = 1; i < items.length; i++) {
950
+ _loop0();
951
+ }
952
+ MGlines.forEach(function (line) {
953
+ molding_totalLength += GeometryUtils.verticesDistance(line[0], line[1]);
954
+ });
955
+ });
956
+ molding_totalLength = convert(molding_totalLength).from('cm').to('in');
957
+ moldingData.push(_objectSpread(_objectSpread({}, molding), {}, {
958
+ doorStyle: doorStyle,
959
+ count: Math.ceil(molding_totalLength * 1.1 / 96)
960
+ }));
961
+ }
962
+ });
963
+
964
+ // calc toe kick molding
965
+ var tmp = [];
966
+ items.forEach(function (item) {
967
+ if (item.category === 'cabinet' && !item.cabinet_category.toLowerCase().includes('microwave')) {
968
+ tmp.push(item);
969
+ }
970
+ });
971
+ var tmpMoldingData = [];
972
+ var toedoorStyles = [];
973
+ tmp.map(function (item) {
974
+ var _item$molding;
975
+ if (item.layoutpos === BASE_CABINET_LAYOUTPOS && (isEmpty(item.molding) || ((_item$molding = item.molding) === null || _item$molding === void 0 ? void 0 : _item$molding.length) < 1 || !isEnableItemForMolding(layer, item))) {
976
+ var w = item.properties.get('width').get('_length');
977
+ var wUnit = item.properties.get('width').get('_unit') || 'cm';
978
+ w = convert(w / 2).from(wUnit).to('cm');
979
+ var h = item.properties.get('depth').get('_length');
980
+ var hUnit = item.properties.get('depth').get('_unit') || 'cm';
981
+ h = convert(h / 2).from(hUnit).to('cm');
982
+ var outline = null;
983
+ var element = catalog.elements[item.get('type')];
984
+ if (!element) element = catalog.elements[returnReplaceableDeepSearchType(item.get('type'))];
985
+ outline = element.info.outline;
986
+ var len = 0;
987
+ if (outline) {
988
+ // Extract Points from `outline`
989
+ var outlinePaths = outline.paths;
990
+ var outlineWidth = outline.svgWidth;
991
+ var outlineHeight = outline.svgHeight;
992
+ var outlinePoints = []; // Hold Points Of SVG
993
+ var _iterator3 = _createForOfIteratorHelper(outlinePaths),
994
+ _step3;
995
+ try {
996
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
997
+ var path = _step3.value;
998
+ var _iterator4 = _createForOfIteratorHelper(path.subPaths),
999
+ _step4;
1000
+ try {
1001
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1002
+ var subPath = _step4.value;
1003
+ outlinePoints = outlinePoints.concat(subPath.getPoints());
1004
+ }
1005
+ } catch (err) {
1006
+ _iterator4.e(err);
1007
+ } finally {
1008
+ _iterator4.f();
1009
+ }
1010
+ }
1011
+ } catch (err) {
1012
+ _iterator3.e(err);
1013
+ } finally {
1014
+ _iterator3.f();
1015
+ }
1016
+ var maxX = outlinePoints[0].x,
1017
+ minX = outlinePoints[0].x;
1018
+ var maxY = outlinePoints[0].y,
1019
+ minY = outlinePoints[0].y;
1020
+ outlinePoints.forEach(function (point) {
1021
+ if (point.x > maxX) {
1022
+ maxX = point.x;
1023
+ }
1024
+ if (point.x < minX) {
1025
+ minX = point.x;
1026
+ }
1027
+ if (point.y > maxY) {
1028
+ maxY = point.y;
1029
+ }
1030
+ if (point.y < minY) {
1031
+ minY = point.y;
1032
+ }
1033
+ });
1034
+ outlinePoints.forEach(function (point) {
1035
+ if (GeometryUtils.isPointInRect([{
1036
+ x: minX,
1037
+ y: minY
1038
+ }, {
1039
+ x: minX,
1040
+ y: maxY
1041
+ }, {
1042
+ x: maxX,
1043
+ y: maxY
1044
+ }, {
1045
+ x: maxX,
1046
+ y: minY
1047
+ }], point)) {
1048
+ if (point.x > 10) len += (point.x / outlineWidth - 0.5) * w * 2 + h * 2 - (point.y / outlineHeight - 0.5) * h * 2;
1049
+ }
1050
+ });
1051
+ len = convert(len).from('cm').to('in');
1052
+ } else {
1053
+ w = convert(w * 2).from('cm').to('in');
1054
+ len += w;
1055
+ }
1056
+ var doorIndex = toedoorStyles.findIndex(function (a) {
1057
+ var iDS = item === null || item === void 0 ? void 0 : item.doorStyle;
1058
+ if (!iDS) return false;
1059
+ if (!iDS.hasOwnProperty('id')) {
1060
+ iDS = iDS.toJS();
1061
+ }
1062
+ return a.doorStyle.id === iDS.id && isEqualInstallationType(a.doorStyle, iDS);
1063
+ });
1064
+ if (doorIndex > -1) {
1065
+ toedoorStyles[doorIndex].totalLength += len;
1066
+ } else {
1067
+ toedoorStyles.push({
1068
+ doorStyle: item.doorStyle.hasOwnProperty('id') ? item.doorStyle : item.doorStyle && item.doorStyle.toJS(),
1069
+ totalLength: len
1070
+ });
1071
+ }
1072
+ }
1073
+ });
1074
+ toedoorStyles.forEach(function (doorStyle) {
1075
+ var skuName = getToeKickSKU(doorStyle.doorStyle, catalog);
1076
+ var thumbnail = skuName ? skuName : '';
1077
+ // moldings.forEach(molding => {
1078
+ // if (
1079
+ // molding.name ===
1080
+ // getToeKickSKU(
1081
+ // doorStyle.doorStyle,
1082
+ // catalog,
1083
+ // true
1084
+ // )
1085
+ // )
1086
+ // thumbnail = molding.thumbnail;
1087
+ // });
1088
+
1089
+ doorStyle.totalLength && tmpMoldingData.push({
1090
+ name: TOE_KICK_MOLDING,
1091
+ sku: getToeKickSKU(doorStyle.doorStyle, catalog),
1092
+ thumbnail: thumbnail,
1093
+ category: 'molding',
1094
+ type: 'cabinet',
1095
+ doorStyle: doorStyle.doorStyle,
1096
+ count: Math.ceil(doorStyle.totalLength * 1.1 / 96)
1097
+ });
1098
+ });
1099
+ if (tmpMoldingData.length > 0) moldingData = [].concat(_toConsumableArray(moldingData), tmpMoldingData);
1100
+ return moldingData;
869
1101
  }
@@ -18,6 +18,7 @@ var _convertUnitsLite = require("./convert-units-lite");
18
18
  var _export = require("./export");
19
19
  var _utils = require("../components/viewer2d/utils");
20
20
  var _SVGLoader = require("three/addons/loaders/SVGLoader");
21
+ var _molding = require("./molding");
21
22
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
22
23
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
23
24
  var PRECISION = 2;
@@ -1065,13 +1066,15 @@ function handleExternalEvent(_x10) {
1065
1066
  function _handleExternalEvent() {
1066
1067
  _handleExternalEvent = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee9(props) {
1067
1068
  var _evt$payload3, _evt$payload4;
1068
- var evt, state, _evt$payload, cdsItems, itemKeys, _loop3, i, _props$onInternalEven, sLineCnt, element, _state$viewer2D, _evt$payload$initialP, mouseX, mouseY, v2d, vPosX, vPosY, layerID, defaulTitle, _Object$keys, _evt$payload5, doorStyle, itemCDS, isAll, layerId, _cdsItems, allItems, selectedItemId, _itemKeys, _loop4, _i2, _props$onInternalEven2, _evt$payload6, roomShapeType, width, height, _doorStyle, value, _value, _evt$payload7, moldingInfo, isGlobal, distElement, _distElement, _evt$payload8, option, _value2, _layerId, layer, _layer$getIn, selectedLines, selectedHoles, selectedItems, _i4, _i5, _i6, _evt$payload9, _evt$payload0, _evt$payload1, _evt$payload10, _layerID, _layer, orginalItemInfo, originalItem, originalItemPos, replaceItem, _props$onInternalEven3, _t5;
1069
+ var evt, state, layerId, layer, _evt$payload, cdsItems, itemKeys, _loop3, i, _props$onInternalEven, sLineCnt, element, _state$viewer2D, _evt$payload$initialP, mouseX, mouseY, v2d, vPosX, vPosY, layerID, defaulTitle, _Object$keys, _evt$payload5, doorStyle, itemCDS, isAll, _layerId, _cdsItems, allItems, selectedItemId, _itemKeys, _loop4, _i2, _props$onInternalEven2, _evt$payload6, roomShapeType, width, height, _doorStyle, value, _value, _evt$payload7, moldingInfo, isGlobal, distElement, _distElement, _evt$payload8, option, _value2, _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;
1069
1070
  return _regenerator["default"].wrap(function (_context1) {
1070
1071
  while (1) switch (_context1.prev = _context1.next) {
1071
1072
  case 0:
1072
1073
  // console.log('***external event****', props);
1073
1074
  evt = props.externalEvent;
1074
1075
  state = props.state.get('KitchenConfigurator');
1076
+ layerId = state.getIn(['scene', 'selectedLayer']);
1077
+ layer = state.getIn(['scene', 'layers', layerId]);
1075
1078
  _t5 = evt === null || evt === void 0 ? void 0 : evt.type;
1076
1079
  _context1.next = _t5 === _constants.EXTERNAL_EVENT_LOAD_PROJECT ? 1 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_3D ? 5 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_2D ? 6 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 7 : _t5 === _constants.EXTERNAL_EVENT_ADD_WALL ? 8 : _t5 === _constants.EXTERNAL_EVENT_ADD_ITEM ? 9 : _t5 === _constants.EXTERNAL_EVENT_ADD_HOLE ? 12 : _t5 === _constants.EXTERNAL_EVENT_MOVE_PAN ? 13 : _t5 === _constants.EXTERNAL_EVENT_NEW_PROJECT ? 14 : _t5 === _constants.EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 15 : _t5 === _constants.EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 19 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_IN ? 20 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_OUT ? 21 : _t5 === _constants.EXTERNAL_EVENT_CENTERING_2D ? 22 : _t5 === _constants.EXTERNAL_EVENT_UNDO ? 23 : _t5 === _constants.EXTERNAL_EVENT_REDO ? 24 : _t5 === _constants.EXTERNAL_EVENT_SET_MOLDING ? 25 : _t5 === _constants.EXTERNAL_EVENT_DUPLICATE_ELEMENT ? 27 : _t5 === _constants.EXTERNAL_EVENT_DELETE_ELEMENT ? 28 : _t5 === _constants.EXTERNAL_EVENT_PROJECT_SETTING ? 29 : _t5 === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? 30 : _t5 === _constants.EXTERNAL_EVENT_UPDATE_PROPERTY ? 30 : _t5 === _constants.EXTERNAL_EVENT_REPLACE_CABINET ? 31 : _t5 === _constants.EXTERNAL_EVENT_SET_FINISHING ? 33 : _t5 === _constants.EXTERNAL_EVENT_SYNC_SCENE ? 34 : 35;
1077
1080
  break;
@@ -1162,7 +1165,7 @@ function _handleExternalEvent() {
1162
1165
  props.projectActions.setMode(_constants.MODE_IDLE);
1163
1166
  return _context1.abrupt("continue", 35);
1164
1167
  case 7:
1165
- sLineCnt = state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size;
1168
+ sLineCnt = layer.selected.lines.size;
1166
1169
  if (sLineCnt > 0) props.projectActions.setMode(_constants.MODE_ELEVATION_VIEW);
1167
1170
  return _context1.abrupt("continue", 35);
1168
1171
  case 8:
@@ -1215,10 +1218,10 @@ function _handleExternalEvent() {
1215
1218
  return _context1.abrupt("continue", 35);
1216
1219
  case 15:
1217
1220
  _evt$payload5 = evt.payload, doorStyle = _evt$payload5.doorStyle, itemCDS = _evt$payload5.itemCDS, isAll = _evt$payload5.isAll; // prepare item data request
1218
- layerId = state.getIn(['scene', 'selectedLayer']);
1221
+ _layerId = state.getIn(['scene', 'selectedLayer']);
1219
1222
  _cdsItems = [];
1220
- allItems = state.getIn(['scene', 'layers', layerId, 'items']).toJS();
1221
- selectedItemId = state.getIn(['scene', 'layers', layerId]).selected.items.toJS()[0];
1223
+ allItems = state.getIn(['scene', 'layers', _layerId, 'items']).toJS();
1224
+ selectedItemId = state.getIn(['scene', 'layers', _layerId]).selected.items.toJS()[0];
1222
1225
  _itemKeys = isAll ? (_Object$keys = Object.keys(allItems)) !== null && _Object$keys !== void 0 ? _Object$keys : [] : [selectedItemId];
1223
1226
  _loop4 = /*#__PURE__*/_regenerator["default"].mark(function _loop4() {
1224
1227
  var _itemCDS$find;
@@ -1358,18 +1361,18 @@ function _handleExternalEvent() {
1358
1361
  }
1359
1362
  return _context1.abrupt("continue", 35);
1360
1363
  case 30:
1361
- _layerId = state.getIn(['scene', 'selectedLayer']);
1362
- layer = state.getIn(['scene', 'layers', _layerId]);
1363
- _layer$getIn = layer.getIn(['selected']), selectedLines = _layer$getIn.lines, selectedHoles = _layer$getIn.holes, selectedItems = _layer$getIn.items;
1364
- for (_i4 = 0; _i4 < selectedLines.size; _i4++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['lines', selectedLines.get(_i4)]), evt.payload, state, layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(layer.getIn(['lines', selectedLines.get(_i4)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1365
- for (_i5 = 0; _i5 < selectedHoles.size; _i5++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['holes', selectedHoles.get(_i5)]), evt.payload, state, layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(layer.getIn(['holes', selectedHoles.get(_i5)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1366
- for (_i6 = 0; _i6 < selectedItems.size; _i6++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['items', selectedItems.get(_i6)]), evt.payload, state, layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(layer.getIn(['items', selectedItems.get(_i6)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1364
+ _layerId2 = state.getIn(['scene', 'selectedLayer']);
1365
+ _layer = state.getIn(['scene', 'layers', _layerId2]);
1366
+ _layer$getIn = _layer.getIn(['selected']), selectedLines = _layer$getIn.lines, selectedHoles = _layer$getIn.holes, selectedItems = _layer$getIn.items;
1367
+ for (_i4 = 0; _i4 < selectedLines.size; _i4++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(_layer.getIn(['lines', selectedLines.get(_i4)]), evt.payload, state, _layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(_layer.getIn(['lines', selectedLines.get(_i4)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1368
+ for (_i5 = 0; _i5 < selectedHoles.size; _i5++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(_layer.getIn(['holes', selectedHoles.get(_i5)]), evt.payload, state, _layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(_layer.getIn(['holes', selectedHoles.get(_i5)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1369
+ for (_i6 = 0; _i6 < selectedItems.size; _i6++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(_layer.getIn(['items', selectedItems.get(_i6)]), evt.payload, state, _layer, props.catalog, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(_layer.getIn(['items', selectedItems.get(_i6)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1367
1370
  return _context1.abrupt("continue", 35);
1368
1371
  case 31:
1369
1372
  _layerID = state.scene.selectedLayer;
1370
- _layer = state.scene.getIn(['layers', _layerID]).toJS();
1373
+ _layer2 = state.scene.getIn(['layers', _layerID]).toJS();
1371
1374
  orginalItemInfo = evt === null || evt === void 0 || (_evt$payload9 = evt.payload) === null || _evt$payload9 === void 0 ? void 0 : _evt$payload9.orginalItemInfo;
1372
- originalItem = _layer === null || _layer === void 0 ? void 0 : _layer.items[orginalItemInfo.id];
1375
+ originalItem = _layer2 === null || _layer2 === void 0 ? void 0 : _layer2.items[orginalItemInfo.id];
1373
1376
  _context1.next = 32;
1374
1377
  return addItemToCatalog(evt.payload.replaceItemInfo, state, props.catalog, props.projectActions);
1375
1378
  case 32:
@@ -1391,11 +1394,14 @@ function _handleExternalEvent() {
1391
1394
  case 33:
1392
1395
  setFinishing(props, state, evt.payload);
1393
1396
  case 34:
1397
+ sceneData = state.scene.toJS(); // get molding data for "ReviewForQuote"
1398
+ currentTexture = layer.doorStyle !== null || layer.doorStyle !== undefined ? layer.doorStyle : props.state.doorStyle.toJS();
1399
+ sceneData.layers[layerId].moldingData = (0, _molding.getMoldingDataOfScene)(layer, props.catalog, currentTexture);
1394
1400
  // send scene object from 3DTool to HostApp using internalEvent
1395
1401
  (_props$onInternalEven3 = props.onInternalEvent) === null || _props$onInternalEven3 === void 0 || _props$onInternalEven3.call(props, {
1396
1402
  type: _constants.INTERNAL_EVENT_SYNC_SCENE,
1397
1403
  value: {
1398
- scene: state.scene.toJS()
1404
+ scene: sceneData
1399
1405
  }
1400
1406
  });
1401
1407
  return _context1.abrupt("continue", 35);
@@ -12,6 +12,7 @@ exports.getItemRect = getItemRect;
12
12
  exports.getLinesFromItems = getLinesFromItems;
13
13
  exports.getLinesFromItems2 = getLinesFromItems2;
14
14
  exports.getLinesOfItem = getLinesOfItem;
15
+ exports.getMoldingDataOfScene = getMoldingDataOfScene;
15
16
  exports.hasMoldingLayout = hasMoldingLayout;
16
17
  exports.isAttachedWall = isAttachedWall;
17
18
  exports.isEnableItemForMolding = isEnableItemForMolding;
@@ -892,4 +893,236 @@ function createMonldingGroup(oldMG, layer, molding, catalog) {
892
893
  newMG.lines.reverse();
893
894
  newMG = getMDPoints(newMG);
894
895
  return newMG;
896
+ }
897
+ function getMoldingDataOfScene(layer, catalog, doorStyle) {
898
+ var moldingData = [];
899
+ var items = layer.items.toArray();
900
+ var moldings = [];
901
+ // get all moldings info
902
+ items.forEach(function (itemCat) {
903
+ var _itemCat$molding;
904
+ itemCat === null || itemCat === void 0 || (_itemCat$molding = itemCat.molding) === null || _itemCat$molding === void 0 || _itemCat$molding.forEach(function (molding) {
905
+ if (!moldings.some(function (m) {
906
+ return m.name === molding.name;
907
+ })) moldings.push(molding);
908
+ });
909
+ });
910
+
911
+ // calc normal molding
912
+ moldings.forEach(function (molding) {
913
+ var itemGroups = [];
914
+ var temp_items = [];
915
+ items.forEach(function (item) {
916
+ if (item.molding.some(function (mol) {
917
+ return mol.itemID === molding.itemID;
918
+ }) && isEnableItemForMolding(layer, item)) {
919
+ temp_items.push(item);
920
+ }
921
+ });
922
+ if (temp_items.length) {
923
+ while (temp_items.length > 0) {
924
+ var itemGroup = [temp_items[0]];
925
+ var _loop9 = function _loop9(_idx) {
926
+ if (!itemGroup.some(function (it) {
927
+ return it.id === temp_items[_idx].id;
928
+ }) && isItemSnappedGroup(temp_items[_idx], itemGroup)) {
929
+ itemGroup.push(temp_items[_idx]);
930
+ _idx = 0;
931
+ }
932
+ idx = _idx;
933
+ };
934
+ for (var idx = 0; idx < temp_items.length; idx++) {
935
+ _loop9(idx);
936
+ }
937
+ itemGroup.forEach(function (item) {
938
+ var index = temp_items.findIndex(function (it) {
939
+ return it.id === item.id;
940
+ });
941
+ if (index > -1) {
942
+ temp_items.splice(index, 1);
943
+ }
944
+ });
945
+ itemGroups.push(itemGroup);
946
+ }
947
+ var molding_totalLength = 0;
948
+ itemGroups.forEach(function (itemgroup) {
949
+ var allLineRects = _export.GeometryUtils.buildRectFromLines(layer, _export.GeometryUtils.getAllLines(layer));
950
+ var items = (0, _toConsumableArray2["default"])(itemgroup);
951
+ var MGlines = getLinesOfItem(items[0], allLineRects, catalog);
952
+ items = sortItemsByDistance(items, items[0]);
953
+ var _loop0 = function _loop0() {
954
+ var itemLines = getLinesOfItem(items[i], allLineRects, catalog);
955
+ var temp_MGLines = [];
956
+ MGlines.forEach(function (line) {
957
+ var idx = itemLines.findIndex(function (itemLine) {
958
+ return isLinesOverlapped(line, itemLine);
959
+ });
960
+ var curItemLine = itemLines[idx];
961
+ if (idx > -1) {
962
+ if (!(_export.GeometryUtils.samePoints(line[0], curItemLine[0]) && _export.GeometryUtils.samePoints(line[1], curItemLine[1]) || _export.GeometryUtils.samePoints(line[0], curItemLine[1]) && _export.GeometryUtils.samePoints(line[1], curItemLine[0]))) {
963
+ var MGLine = mergeOverlappedLines(line, curItemLine);
964
+ temp_MGLines.push(MGLine);
965
+ }
966
+ itemLines.splice(idx, 1);
967
+ } else {
968
+ temp_MGLines.push(line);
969
+ }
970
+ });
971
+ itemLines.forEach(function (itemLine) {
972
+ return temp_MGLines.push(itemLine);
973
+ });
974
+ MGlines = [].concat(temp_MGLines);
975
+ };
976
+ for (var i = 1; i < items.length; i++) {
977
+ _loop0();
978
+ }
979
+ MGlines.forEach(function (line) {
980
+ molding_totalLength += _export.GeometryUtils.verticesDistance(line[0], line[1]);
981
+ });
982
+ });
983
+ molding_totalLength = (0, _convertUnitsLite.convert)(molding_totalLength).from('cm').to('in');
984
+ moldingData.push(_objectSpread(_objectSpread({}, molding), {}, {
985
+ doorStyle: doorStyle,
986
+ count: Math.ceil(molding_totalLength * 1.1 / 96)
987
+ }));
988
+ }
989
+ });
990
+
991
+ // calc toe kick molding
992
+ var tmp = [];
993
+ items.forEach(function (item) {
994
+ if (item.category === 'cabinet' && !item.cabinet_category.toLowerCase().includes('microwave')) {
995
+ tmp.push(item);
996
+ }
997
+ });
998
+ var tmpMoldingData = [];
999
+ var toedoorStyles = [];
1000
+ tmp.map(function (item) {
1001
+ var _item$molding;
1002
+ if (item.layoutpos === _constants.BASE_CABINET_LAYOUTPOS && ((0, _helper.isEmpty)(item.molding) || ((_item$molding = item.molding) === null || _item$molding === void 0 ? void 0 : _item$molding.length) < 1 || !isEnableItemForMolding(layer, item))) {
1003
+ var w = item.properties.get('width').get('_length');
1004
+ var wUnit = item.properties.get('width').get('_unit') || 'cm';
1005
+ w = (0, _convertUnitsLite.convert)(w / 2).from(wUnit).to('cm');
1006
+ var h = item.properties.get('depth').get('_length');
1007
+ var hUnit = item.properties.get('depth').get('_unit') || 'cm';
1008
+ h = (0, _convertUnitsLite.convert)(h / 2).from(hUnit).to('cm');
1009
+ var outline = null;
1010
+ var element = catalog.elements[item.get('type')];
1011
+ if (!element) element = catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(item.get('type'))];
1012
+ outline = element.info.outline;
1013
+ var len = 0;
1014
+ if (outline) {
1015
+ // Extract Points from `outline`
1016
+ var outlinePaths = outline.paths;
1017
+ var outlineWidth = outline.svgWidth;
1018
+ var outlineHeight = outline.svgHeight;
1019
+ var outlinePoints = []; // Hold Points Of SVG
1020
+ var _iterator3 = _createForOfIteratorHelper(outlinePaths),
1021
+ _step3;
1022
+ try {
1023
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1024
+ var path = _step3.value;
1025
+ var _iterator4 = _createForOfIteratorHelper(path.subPaths),
1026
+ _step4;
1027
+ try {
1028
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1029
+ var subPath = _step4.value;
1030
+ outlinePoints = outlinePoints.concat(subPath.getPoints());
1031
+ }
1032
+ } catch (err) {
1033
+ _iterator4.e(err);
1034
+ } finally {
1035
+ _iterator4.f();
1036
+ }
1037
+ }
1038
+ } catch (err) {
1039
+ _iterator3.e(err);
1040
+ } finally {
1041
+ _iterator3.f();
1042
+ }
1043
+ var maxX = outlinePoints[0].x,
1044
+ minX = outlinePoints[0].x;
1045
+ var maxY = outlinePoints[0].y,
1046
+ minY = outlinePoints[0].y;
1047
+ outlinePoints.forEach(function (point) {
1048
+ if (point.x > maxX) {
1049
+ maxX = point.x;
1050
+ }
1051
+ if (point.x < minX) {
1052
+ minX = point.x;
1053
+ }
1054
+ if (point.y > maxY) {
1055
+ maxY = point.y;
1056
+ }
1057
+ if (point.y < minY) {
1058
+ minY = point.y;
1059
+ }
1060
+ });
1061
+ outlinePoints.forEach(function (point) {
1062
+ if (_export.GeometryUtils.isPointInRect([{
1063
+ x: minX,
1064
+ y: minY
1065
+ }, {
1066
+ x: minX,
1067
+ y: maxY
1068
+ }, {
1069
+ x: maxX,
1070
+ y: maxY
1071
+ }, {
1072
+ x: maxX,
1073
+ y: minY
1074
+ }], point)) {
1075
+ if (point.x > 10) len += (point.x / outlineWidth - 0.5) * w * 2 + h * 2 - (point.y / outlineHeight - 0.5) * h * 2;
1076
+ }
1077
+ });
1078
+ len = (0, _convertUnitsLite.convert)(len).from('cm').to('in');
1079
+ } else {
1080
+ w = (0, _convertUnitsLite.convert)(w * 2).from('cm').to('in');
1081
+ len += w;
1082
+ }
1083
+ var doorIndex = toedoorStyles.findIndex(function (a) {
1084
+ var iDS = item === null || item === void 0 ? void 0 : item.doorStyle;
1085
+ if (!iDS) return false;
1086
+ if (!iDS.hasOwnProperty('id')) {
1087
+ iDS = iDS.toJS();
1088
+ }
1089
+ return a.doorStyle.id === iDS.id && (0, _utils.isEqualInstallationType)(a.doorStyle, iDS);
1090
+ });
1091
+ if (doorIndex > -1) {
1092
+ toedoorStyles[doorIndex].totalLength += len;
1093
+ } else {
1094
+ toedoorStyles.push({
1095
+ doorStyle: item.doorStyle.hasOwnProperty('id') ? item.doorStyle : item.doorStyle && item.doorStyle.toJS(),
1096
+ totalLength: len
1097
+ });
1098
+ }
1099
+ }
1100
+ });
1101
+ toedoorStyles.forEach(function (doorStyle) {
1102
+ var skuName = (0, _utils.getToeKickSKU)(doorStyle.doorStyle, catalog);
1103
+ var thumbnail = skuName ? skuName : '';
1104
+ // moldings.forEach(molding => {
1105
+ // if (
1106
+ // molding.name ===
1107
+ // getToeKickSKU(
1108
+ // doorStyle.doorStyle,
1109
+ // catalog,
1110
+ // true
1111
+ // )
1112
+ // )
1113
+ // thumbnail = molding.thumbnail;
1114
+ // });
1115
+
1116
+ doorStyle.totalLength && tmpMoldingData.push({
1117
+ name: _constants.TOE_KICK_MOLDING,
1118
+ sku: (0, _utils.getToeKickSKU)(doorStyle.doorStyle, catalog),
1119
+ thumbnail: thumbnail,
1120
+ category: 'molding',
1121
+ type: 'cabinet',
1122
+ doorStyle: doorStyle.doorStyle,
1123
+ count: Math.ceil(doorStyle.totalLength * 1.1 / 96)
1124
+ });
1125
+ });
1126
+ if (tmpMoldingData.length > 0) moldingData = [].concat((0, _toConsumableArray2["default"])(moldingData), tmpMoldingData);
1127
+ return moldingData;
895
1128
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "3.1.10",
3
+ "version": "3.1.11",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",