@archilogic/floor-plan-sdk 5.1.8 → 5.1.10

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.
package/dist/fpe.js CHANGED
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  /*!
5
- Archilogic Floor Plan Engine SDK v5.1.8 webgl build 250429-111617-277c93
5
+ Archilogic Floor Plan Engine SDK v5.1.10 webgl build 250709-150249-53c0fd
6
6
 
7
7
  Copyright (c) 2025 Archilogic AG. All rights reserved.
8
8
 
@@ -390,41 +390,6 @@ class Connection {
390
390
  __publicField(this, "temporaryAccessToken");
391
391
  __publicField(this, "temporaryAccessTokenPromise");
392
392
  __publicField(this, "durationSeconds", 3600);
393
- __publicField(this, "getTemporaryAccessToken", async () => {
394
- if (this.isAccessTokenActive && this.temporaryAccessToken) {
395
- return this.temporaryAccessToken;
396
- }
397
- if (!this.temporaryAccessTokenPromise) {
398
- this.temporaryAccessTokenPromise = new Promise(async (resolve2, reject) => {
399
- if (this.temporaryAccessTokenFunction) {
400
- this.temporaryAccessToken = await this.temporaryAccessTokenFunction({
401
- scopes: this.tempScopes,
402
- durationSeconds: this.durationSeconds
403
- });
404
- if (this.isAccessTokenActive) {
405
- resolve2(this.temporaryAccessToken);
406
- }
407
- }
408
- if (this.temporaryAccessToken) {
409
- const expired = /* @__PURE__ */ new Date();
410
- expired.setTime(this.temporaryAccessToken.expiresAt * 1e3);
411
- reject(new SpaceApiError(`Temporary access token expired at ${expired.toString()}`, void 0, void 0));
412
- } else {
413
- reject(new SpaceApiError("Temporary access token not defined", void 0, void 0));
414
- }
415
- });
416
- }
417
- try {
418
- return await this.temporaryAccessTokenPromise;
419
- } catch (rejectedTokenError) {
420
- this.temporaryAccessTokenPromise = void 0;
421
- throw rejectedTokenError;
422
- } finally {
423
- if (this.isAccessTokenActive) {
424
- this.temporaryAccessTokenPromise = void 0;
425
- }
426
- }
427
- });
428
393
  this.config = getTokenConfig(options);
429
394
  if (options.temporaryAccessToken || options.temporaryAccessTokenFunction) {
430
395
  this.temporaryAccessTokenFunction = options.temporaryAccessTokenFunction;
@@ -438,6 +403,41 @@ class Connection {
438
403
  const currentTime = (/* @__PURE__ */ new Date()).getTime() / 1e3;
439
404
  return !!this.temporaryAccessToken && this.temporaryAccessToken.expiresAt > currentTime;
440
405
  }
406
+ async getTemporaryAccessToken() {
407
+ if (this.isAccessTokenActive && this.temporaryAccessToken) {
408
+ return this.temporaryAccessToken;
409
+ }
410
+ if (!this.temporaryAccessTokenPromise) {
411
+ this.temporaryAccessTokenPromise = new Promise(async (resolve2, reject) => {
412
+ if (this.temporaryAccessTokenFunction) {
413
+ this.temporaryAccessToken = await this.temporaryAccessTokenFunction({
414
+ scopes: this.tempScopes,
415
+ durationSeconds: this.durationSeconds
416
+ });
417
+ if (this.isAccessTokenActive) {
418
+ resolve2(this.temporaryAccessToken);
419
+ }
420
+ }
421
+ if (this.temporaryAccessToken) {
422
+ const expired = /* @__PURE__ */ new Date();
423
+ expired.setTime(this.temporaryAccessToken.expiresAt * 1e3);
424
+ reject(new SpaceApiError(`Temporary access token expired at ${expired.toString()}`, void 0, void 0));
425
+ } else {
426
+ reject(new SpaceApiError("Temporary access token not defined", void 0, void 0));
427
+ }
428
+ });
429
+ }
430
+ try {
431
+ return await this.temporaryAccessTokenPromise;
432
+ } catch (rejectedTokenError) {
433
+ this.temporaryAccessTokenPromise = void 0;
434
+ throw rejectedTokenError;
435
+ } finally {
436
+ if (this.isAccessTokenActive) {
437
+ this.temporaryAccessTokenPromise = void 0;
438
+ }
439
+ }
440
+ }
441
441
  async callSpaceAPI(method, path2, params = {}, config = this.config) {
442
442
  switch (config.type) {
443
443
  case "secret":
@@ -485,6 +485,9 @@ class SpaceAPI {
485
485
  this[key] = fn;
486
486
  }
487
487
  }
488
+ async getTemporaryAccessToken() {
489
+ return this.connection.getTemporaryAccessToken();
490
+ }
488
491
  async createFloor(floor) {
489
492
  return this.connection.callSpaceAPI("POST", `/v2/floor`, floor);
490
493
  }
@@ -553,14 +556,19 @@ class SpaceAPI {
553
556
  return this.connection.callSpaceAPI("GET", "/v2/floor", query);
554
557
  }
555
558
  async getAllFloors(geometry = false, includeArchived = false, includeRelations = false, teamId, includeCustomAttributes) {
559
+ const limit2 = geometry || includeRelations ? 1e3 : 1e4;
556
560
  const allFloors = await this.queryFloors({
557
561
  geometry,
558
562
  includeArchived,
559
563
  includeRelations,
560
564
  includeCustomAttributes,
561
- teamId
565
+ teamId,
566
+ limit: limit2
562
567
  });
563
- let floors = allFloors.features;
568
+ let floors = allFloors.features || [];
569
+ if (floors.length < limit2) {
570
+ return allFloors;
571
+ }
564
572
  while (floors == null ? void 0 : floors.length) {
565
573
  floors = (await this.queryFloors({
566
574
  geometry,
@@ -568,8 +576,9 @@ class SpaceAPI {
568
576
  includeRelations,
569
577
  includeCustomAttributes,
570
578
  teamId,
571
- offset: allFloors.features.length
572
- })).features;
579
+ offset: allFloors.features.length,
580
+ limit: limit2
581
+ })).features || [];
573
582
  allFloors.features.push(...floors);
574
583
  }
575
584
  return allFloors;
@@ -608,21 +617,27 @@ class SpaceAPI {
608
617
  return this.connection.callSpaceAPI("GET", "/v2/space", query);
609
618
  }
610
619
  async getAllSpacesByFloorId(floorId, geometry = false, includeRelations, includeCustomAttributes) {
620
+ const limit2 = 1e3;
611
621
  const allSpaces = await this.querySpaces({
612
622
  floorId,
613
623
  geometry,
614
624
  includeRelations,
615
- includeCustomAttributes
625
+ includeCustomAttributes,
626
+ limit: limit2
616
627
  });
617
- let spaces = allSpaces.features;
628
+ let spaces = allSpaces.features || [];
629
+ if (spaces.length < limit2) {
630
+ return allSpaces;
631
+ }
618
632
  while (spaces == null ? void 0 : spaces.length) {
619
633
  spaces = (await this.querySpaces({
620
634
  floorId,
621
635
  geometry,
622
636
  includeRelations,
623
637
  includeCustomAttributes,
624
- offset: allSpaces.features.length
625
- })).features;
638
+ offset: allSpaces.features.length,
639
+ limit: limit2
640
+ })).features || [];
626
641
  allSpaces.features.push(...spaces);
627
642
  }
628
643
  return allSpaces;
@@ -635,13 +650,18 @@ class SpaceAPI {
635
650
  return this.connection.callSpaceAPI("GET", "/v2/asset", query);
636
651
  }
637
652
  async getAllAssets(query) {
638
- const allAssets = await this.queryAssets(query);
639
- let assets = allAssets.features;
653
+ const { limit: limit2 = 1e4, ...rest } = query;
654
+ const allAssets = await this.queryAssets({ ...rest, limit: limit2 });
655
+ let assets = allAssets.features || [];
656
+ if (assets.length < limit2) {
657
+ return allAssets;
658
+ }
640
659
  while (assets == null ? void 0 : assets.length) {
641
660
  assets = (await this.queryAssets({
642
661
  ...query,
643
- offset: (query.offset || 0) + allAssets.features.length
644
- })).features;
662
+ offset: (query.offset || 0) + allAssets.features.length,
663
+ limit: limit2
664
+ })).features || [];
645
665
  allAssets.features.push(...assets);
646
666
  }
647
667
  return allAssets;
@@ -799,7 +819,7 @@ class SpaceAPI {
799
819
  return this.connection.callSpaceAPI("PATCH", `/v2/layout/${layoutId}/revisions/${revisionId}`, params);
800
820
  }
801
821
  getLayoutRevisions(layoutId, revisionFilter) {
802
- const queryString = generateQueryString({ filter: revisionFilter });
822
+ const queryString = generateQueryString(revisionFilter ? { filter: revisionFilter } : {});
803
823
  return this.connection.callSpaceAPI("GET", `/v2/layout/${layoutId}/revisions${queryString}`);
804
824
  }
805
825
  getLayoutRevision(layoutId, revisionId) {
@@ -823,6 +843,33 @@ class SpaceAPI {
823
843
  getImdfs(params) {
824
844
  return this.connection.callSpaceAPI("POST", `/v2/floor/imdf`, params);
825
845
  }
846
+ listExtensions() {
847
+ return this.connection.callSpaceAPI("GET", "/v2/extensions");
848
+ }
849
+ createExtension(extension) {
850
+ return this.connection.callSpaceAPI("POST", "/v2/extensions", extension);
851
+ }
852
+ updateExtension(extensionId, extension) {
853
+ return this.connection.callSpaceAPI("PATCH", `/v2/extensions/${extensionId}`, extension);
854
+ }
855
+ deleteExtension(extensionId) {
856
+ return this.connection.callSpaceAPI("DELETE", `/v2/extensions/${extensionId}`);
857
+ }
858
+ listBuildings() {
859
+ return this.connection.callSpaceAPI("GET", "/v2/buildings");
860
+ }
861
+ createBuilding(params) {
862
+ return this.connection.callSpaceAPI("POST", "/v2/buildings", params);
863
+ }
864
+ getBuildingById(id) {
865
+ return this.connection.callSpaceAPI("GET", `/v2/buildings/${id}`);
866
+ }
867
+ updateBuilding(id, params) {
868
+ return this.connection.callSpaceAPI("PATCH", `/v2/buildings/${id}`, params);
869
+ }
870
+ deleteBuilding(id) {
871
+ return this.connection.callSpaceAPI("DELETE", `/v2/buildings/${id}`);
872
+ }
826
873
  }
827
874
  var __defProp2 = Object.defineProperty;
828
875
  var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -5881,6 +5928,13 @@ E$2.prototype = {
5881
5928
  };
5882
5929
  tinyEmitter$1.exports = E$2;
5883
5930
  var TinyEmitter$1 = tinyEmitter$1.exports.TinyEmitter = E$2;
5931
+ var __typeError$1 = (msg) => {
5932
+ throw TypeError(msg);
5933
+ };
5934
+ var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
5935
+ var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
5936
+ var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
5937
+ var _SpaceGraphProductBase_instances, getAttributesJson_fn;
5884
5938
  const defaultLevels$1 = ["info", "warnings", "errors"];
5885
5939
  class SpaceGraphLogger extends at {
5886
5940
  error(...args) {
@@ -5889,6 +5943,7 @@ class SpaceGraphLogger extends at {
5889
5943
  args[0] = "Internal error: " + args[0];
5890
5944
  }
5891
5945
  console.error(...args);
5946
+ this.emit("error", ...args);
5892
5947
  }
5893
5948
  }
5894
5949
  }
@@ -6811,13 +6866,13 @@ function getPolygonCenter(polygon) {
6811
6866
  const { min, max: max2 } = polygonBounds([polygon]);
6812
6867
  return [min[0] + (max2[0] - min[0]) / 2, min[1] + (max2[1] - min[1]) / 2];
6813
6868
  }
6814
- function getPolygonLabelPoint(polygonWithHoles) {
6869
+ function getPolygonLabelPoint(polygonWithHoles, precision = 0.1) {
6815
6870
  let labelPoint;
6816
6871
  const area2 = getPolygonWithHolesArea(polygonWithHoles);
6817
6872
  if (area2 < 0.1) {
6818
6873
  labelPoint = getPolygonCenter(polygonWithHoles[0]);
6819
6874
  } else {
6820
- const point = polylabel$2(polygonWithHoles, 0.1);
6875
+ const point = polylabel$2(polygonWithHoles, precision);
6821
6876
  labelPoint = [point[0], point[1]];
6822
6877
  }
6823
6878
  return labelPoint;
@@ -8445,6 +8500,7 @@ const layoutToCustomAttributeResourceTypeMap = {
8445
8500
  "spatialStructure:layout": "layout",
8446
8501
  "layout:space": "space",
8447
8502
  "product:static": "product",
8503
+ "product:component": "product",
8448
8504
  "spatialStructure:building": "building",
8449
8505
  "spatialStructure:floor": "floor",
8450
8506
  "element:asset": "element",
@@ -10467,6 +10523,7 @@ function doRemoveBoundaryElement(boundaryElement) {
10467
10523
  }
10468
10524
  }
10469
10525
  function doRemoveElement(element) {
10526
+ var _a;
10470
10527
  switch (element.type) {
10471
10528
  case "element:boundaryWall":
10472
10529
  case "element:ceiling":
@@ -10478,6 +10535,9 @@ function doRemoveElement(element) {
10478
10535
  case "element:wall":
10479
10536
  doRemoveEdgeElement(element);
10480
10537
  break;
10538
+ case "element:asset":
10539
+ (_a = element.product) == null ? void 0 : _a.instances.delete(element);
10540
+ break;
10481
10541
  }
10482
10542
  }
10483
10543
  function getSpaceBoundaryPolygons(space) {
@@ -12345,11 +12405,20 @@ class LayoutAsset extends LayoutTransformElementBase {
12345
12405
  this.product = null;
12346
12406
  this.parameters = JSON.parse(JSON.stringify(defaultAssetParameters));
12347
12407
  }
12408
+ get isComponentInstance() {
12409
+ var _a;
12410
+ return ((_a = this.product) == null ? void 0 : _a.type) === "product:component";
12411
+ }
12412
+ get isComponentInstanceChild() {
12413
+ var _a;
12414
+ return ((_a = this.parent) == null ? void 0 : _a.type) === "element:asset" && this.parent.isComponentInstance;
12415
+ }
12348
12416
  setParameters(parameters) {
12349
12417
  super.setParameters(parameters);
12350
12418
  }
12351
12419
  setProduct(product) {
12352
12420
  this.product = product;
12421
+ this.product.instances.add(this);
12353
12422
  this.emit("node-property-change", this, "product");
12354
12423
  this.emit("geometry-update", this);
12355
12424
  }
@@ -12573,28 +12642,29 @@ class LayoutGeneric extends LayoutTransformElementBase {
12573
12642
  super.setParameters(parameters);
12574
12643
  }
12575
12644
  }
12576
- const SpaceGraphProductTypeValue = "product:static";
12577
- class SpaceGraphProduct extends SpaceGraphNodeWithCustomAttributesBase {
12578
- constructor(id) {
12579
- super(id, SpaceGraphProductTypeValue);
12580
- this.geometries = [];
12581
- this.attributes = {
12582
- manufacturer: "",
12583
- categories: [],
12584
- subCategories: [],
12585
- thumbnail: "",
12586
- boundingBox: {
12587
- min: [1, 0, 0],
12588
- max: [-1, 0, 0]
12589
- },
12590
- seatCapacity: 0,
12591
- updatedAt: ""
12592
- };
12645
+ const SpaceGraphProductStaticTypeValue = "product:static";
12646
+ const defaultAttributes = {
12647
+ manufacturer: "",
12648
+ categories: [],
12649
+ subCategories: [],
12650
+ thumbnail: "",
12651
+ boundingBox: {
12652
+ min: [0, 0, 0],
12653
+ max: [0, 0, 0]
12654
+ },
12655
+ seatCapacity: 0,
12656
+ updatedAt: ""
12657
+ };
12658
+ class SpaceGraphProductBase extends SpaceGraphNodeWithCustomAttributesBase {
12659
+ constructor(id, type2) {
12660
+ super(id, type2);
12661
+ __privateAdd$1(this, _SpaceGraphProductBase_instances);
12662
+ this.instances = /* @__PURE__ */ new Set();
12663
+ this.attributes = JSON.parse(JSON.stringify(defaultAttributes));
12593
12664
  }
12594
12665
  copyForClone(product) {
12595
12666
  super.copyForClone(product);
12596
12667
  this.attributes = JSON.parse(JSON.stringify(product.attributes));
12597
- this.geometries = JSON.parse(JSON.stringify(product.geometries));
12598
12668
  }
12599
12669
  setAttributes(attributesJson) {
12600
12670
  var _a, _b;
@@ -12612,38 +12682,106 @@ class SpaceGraphProduct extends SpaceGraphNodeWithCustomAttributesBase {
12612
12682
  }
12613
12683
  toJSON() {
12614
12684
  const productJson = super.toJSON();
12615
- let attributes = this.attributes;
12616
- let attributesJson = {};
12617
- if (attributes.manufacturer !== "") {
12618
- attributesJson.manufacturer = attributes.manufacturer;
12619
- }
12620
- if (attributes.categories.length > 0) {
12621
- attributesJson.categories = [...attributes.categories];
12622
- }
12623
- if (attributes.subCategories.length > 0) {
12624
- attributesJson.subCategories = [...attributes.subCategories];
12625
- }
12626
- if (attributes.thumbnail !== "") {
12627
- attributesJson.thumbnail = attributes.thumbnail;
12628
- }
12629
- let { min, max: max2 } = attributes.boundingBox;
12630
- if (min[0] !== 1 && max2[0] !== -1) {
12631
- attributesJson.boundingBox = {
12632
- min: [...attributes.boundingBox.min],
12633
- max: [...attributes.boundingBox.max]
12634
- };
12635
- }
12636
- if (attributes.seatCapacity > 0) {
12637
- attributesJson.seatCapacity = attributes.seatCapacity;
12638
- }
12639
- if (attributes.updatedAt !== void 0) {
12640
- attributesJson.updatedAt = attributes.updatedAt;
12641
- }
12642
- productJson.attributes = attributesJson;
12643
- productJson.geometries = JSON.parse(JSON.stringify(this.geometries));
12685
+ productJson.attributes = __privateMethod$1(this, _SpaceGraphProductBase_instances, getAttributesJson_fn).call(this);
12644
12686
  return productJson;
12645
12687
  }
12646
12688
  }
12689
+ _SpaceGraphProductBase_instances = /* @__PURE__ */ new WeakSet();
12690
+ getAttributesJson_fn = function() {
12691
+ const attributesJson = {};
12692
+ const attributes = this.attributes;
12693
+ if (attributes.manufacturer !== "") {
12694
+ attributesJson.manufacturer = attributes.manufacturer;
12695
+ }
12696
+ if (attributes.categories.length > 0) {
12697
+ attributesJson.categories = [...attributes.categories];
12698
+ }
12699
+ if (attributes.subCategories.length > 0) {
12700
+ attributesJson.subCategories = [...attributes.subCategories];
12701
+ }
12702
+ if (attributes.thumbnail !== "") {
12703
+ attributesJson.thumbnail = attributes.thumbnail;
12704
+ }
12705
+ let { min, max: max2 } = attributes.boundingBox;
12706
+ if (min[0] !== 1 && max2[0] !== -1) {
12707
+ attributesJson.boundingBox = {
12708
+ min: [...attributes.boundingBox.min],
12709
+ max: [...attributes.boundingBox.max]
12710
+ };
12711
+ }
12712
+ if (attributes.seatCapacity > 0) {
12713
+ attributesJson.seatCapacity = attributes.seatCapacity;
12714
+ }
12715
+ if (attributes.updatedAt !== void 0) {
12716
+ attributesJson.updatedAt = attributes.updatedAt;
12717
+ }
12718
+ return attributesJson;
12719
+ };
12720
+ class SpaceGraphProductStatic extends SpaceGraphProductBase {
12721
+ constructor(id) {
12722
+ super(id, SpaceGraphProductStaticTypeValue);
12723
+ this.geometries = [];
12724
+ }
12725
+ copyForClone(product) {
12726
+ super.copyForClone(product);
12727
+ this.geometries = JSON.parse(JSON.stringify(product.geometries));
12728
+ }
12729
+ toJSON() {
12730
+ const productJson = super.toJSON();
12731
+ return {
12732
+ ...productJson,
12733
+ type: SpaceGraphProductStaticTypeValue,
12734
+ geometries: JSON.parse(JSON.stringify(this.geometries))
12735
+ };
12736
+ }
12737
+ }
12738
+ const SpaceGraphProductComponentTypeValue = "product:component";
12739
+ class SpaceGraphProductComponent extends SpaceGraphProductBase {
12740
+ constructor(id) {
12741
+ super(id, SpaceGraphProductComponentTypeValue);
12742
+ this.products = [];
12743
+ this.geometries = [];
12744
+ this.attributes = JSON.parse(JSON.stringify(defaultAttributes));
12745
+ }
12746
+ copyForClone(product) {
12747
+ super.copyForClone(product);
12748
+ this.products = JSON.parse(JSON.stringify(product.products));
12749
+ }
12750
+ toJSON() {
12751
+ const productJson = super.toJSON();
12752
+ return {
12753
+ ...productJson,
12754
+ type: SpaceGraphProductComponentTypeValue,
12755
+ products: JSON.parse(JSON.stringify(this.products)),
12756
+ // for compatibility
12757
+ geometries: []
12758
+ };
12759
+ }
12760
+ setProducts(products) {
12761
+ this.products = JSON.parse(JSON.stringify(products));
12762
+ }
12763
+ setInstances() {
12764
+ var _a;
12765
+ for (const instance of this.instances) {
12766
+ if (this.products.length !== instance.elements.length) {
12767
+ continue;
12768
+ }
12769
+ for (let i2 = 0; i2 < this.products.length; i2++) {
12770
+ const productEntry = this.products[i2];
12771
+ if ("type" in productEntry.position) {
12772
+ continue;
12773
+ }
12774
+ if (typeof productEntry.rotation !== "number") {
12775
+ continue;
12776
+ }
12777
+ const asset = instance.elements[i2];
12778
+ if (asset.type === "element:asset" && ((_a = asset.product) == null ? void 0 : _a.id) === productEntry.product) {
12779
+ asset.setTransform(productEntry.position, productEntry.rotation);
12780
+ }
12781
+ }
12782
+ }
12783
+ }
12784
+ }
12647
12785
  function clearNestedElements(element) {
12648
12786
  for (let i2 = element.elements.length - 1; i2 >= 0; i2--) {
12649
12787
  element.removeElement(element.elements[i2]);
@@ -12668,7 +12806,7 @@ function getSinkProduct(spaceGraph) {
12668
12806
  if (spaceGraph == null ? void 0 : spaceGraph.productsById[sinkProductId]) {
12669
12807
  return spaceGraph == null ? void 0 : spaceGraph.productsById[sinkProductId];
12670
12808
  }
12671
- let sink = new SpaceGraphProduct(sinkProductId);
12809
+ let sink = new SpaceGraphProductStatic(sinkProductId);
12672
12810
  sink.setAttributes({
12673
12811
  categories: ["appliances"],
12674
12812
  subCategories: ["kitchen"],
@@ -13776,6 +13914,24 @@ class Graph {
13776
13914
  }
13777
13915
  return null;
13778
13916
  }
13917
+ toJSON() {
13918
+ const nodes = [];
13919
+ const edges = [];
13920
+ for (const [node, edgeMap] of this.nodeMap.entries()) {
13921
+ nodes.push({ id: node.id, type: node.type });
13922
+ for (const [edgeType, destinations] of edgeMap.entries()) {
13923
+ for (const destination of destinations) {
13924
+ if (node.id < destination.id) {
13925
+ edges.push({
13926
+ type: String(edgeType),
13927
+ nodes: [node.id, destination.id]
13928
+ });
13929
+ }
13930
+ }
13931
+ }
13932
+ }
13933
+ return { nodes, edges };
13934
+ }
13779
13935
  }
13780
13936
  const createByType = (map2) => {
13781
13937
  const byType = {};
@@ -14376,7 +14532,8 @@ const spaceGraphMaterialTypeValues = {
14376
14532
  "material:standard": SpaceGraphStandardMaterial
14377
14533
  };
14378
14534
  const spaceGraphProductTypeValues = {
14379
- "product:static": SpaceGraphProduct
14535
+ "product:static": SpaceGraphProductStatic,
14536
+ "product:component": SpaceGraphProductComponent
14380
14537
  };
14381
14538
  const spaceGraphRelationTypeValues = {
14382
14539
  "relation:group": GroupRelation
@@ -14431,7 +14588,7 @@ function getCustomAttributesJson(customAttributes) {
14431
14588
  }
14432
14589
  return customAttributesJson;
14433
14590
  }
14434
- const version = "0.21.2";
14591
+ const version = "0.22.1";
14435
14592
  const schemaVersion = version;
14436
14593
  class SpaceGraph {
14437
14594
  constructor(sourceSchemaVersion) {
@@ -14602,8 +14759,13 @@ class SpaceGraph {
14602
14759
  this.unregisterNode(product);
14603
14760
  this.emit("product-delete", product);
14604
14761
  }
14605
- createProduct(id) {
14606
- let product = new SpaceGraphProduct(id);
14762
+ createProduct(id, type2) {
14763
+ let product;
14764
+ if (type2 === SpaceGraphProductComponentTypeValue) {
14765
+ product = new SpaceGraphProductComponent(id);
14766
+ } else {
14767
+ product = new SpaceGraphProductStatic(id);
14768
+ }
14607
14769
  this.insertProduct(product);
14608
14770
  return product;
14609
14771
  }
@@ -15256,7 +15418,14 @@ function loadJsonNameAndCustomId(node, nodeJson) {
15256
15418
  node.customId = nodeJson.customId ?? node.customId;
15257
15419
  }
15258
15420
  function getProductFromProductJson(productJson, customAttributesById) {
15259
- let product = new SpaceGraphProduct(productJson.id);
15421
+ let product;
15422
+ if (productJson.type === SpaceGraphProductComponentTypeValue) {
15423
+ product = new SpaceGraphProductComponent(productJson.id);
15424
+ product.products = JSON.parse(JSON.stringify(productJson.products));
15425
+ } else {
15426
+ product = new SpaceGraphProductStatic(productJson.id);
15427
+ product.geometries = JSON.parse(JSON.stringify(productJson.geometries));
15428
+ }
15260
15429
  if (productJson.attributes) {
15261
15430
  product.setAttributes(productJson.attributes);
15262
15431
  }
@@ -15264,7 +15433,6 @@ function getProductFromProductJson(productJson, customAttributesById) {
15264
15433
  product.setCustomAttributes(productJson.customAttributes, customAttributesById);
15265
15434
  }
15266
15435
  loadJsonNameAndCustomId(product, productJson);
15267
- product.geometries = JSON.parse(JSON.stringify(productJson.geometries));
15268
15436
  return product;
15269
15437
  }
15270
15438
  function getGeometryFromGeometryJson(geometryJson) {
@@ -17827,8 +17995,10 @@ const setApiUrls = ({
17827
17995
  const defaultLevels = ["info", "warnings", "errors"];
17828
17996
  let logger = new at(defaultLevels);
17829
17997
  function loadAssetResources(loader, node) {
17998
+ var _a;
17830
17999
  let uriGeometry;
17831
18000
  let productGeometryEntry = node.product.geometries[0];
18001
+ const isComponent = ((_a = node.product) == null ? void 0 : _a.type) === "product:component";
17832
18002
  if (typeof productGeometryEntry === "string") {
17833
18003
  let geometryRef = productGeometryEntry;
17834
18004
  uriGeometry = node.spaceGraph.geometriesById[geometryRef];
@@ -17836,15 +18006,17 @@ function loadAssetResources(loader, node) {
17836
18006
  uriGeometry = productGeometryEntry.geometry;
17837
18007
  }
17838
18008
  let isUriGeometry = (uriGeometry == null ? void 0 : uriGeometry.type) === "geometry:uri";
17839
- if (!isUriGeometry) {
18009
+ if (!isComponent && !isUriGeometry) {
17840
18010
  return Promise.reject("Unsupported product geometry: " + node.product.id);
17841
18011
  }
17842
- return loader.loadResources(node.product.id, node, ["productJson", "productContour"]).catch((e2) => logger.error(e2));
18012
+ const resources = isComponent ? ["productJson"] : ["productJson", "productContour"];
18013
+ return loader.loadResources(node.product.id, node, resources).catch((e2) => logger.error(e2));
17843
18014
  }
17844
18015
  const loadAllAssetResources = (floorPlan) => {
17845
18016
  const assets = [];
17846
18017
  floorPlan.layout.elementsByType["element:asset"].forEach((element) => {
17847
- if ("product" in element && element.product) {
18018
+ var _a;
18019
+ if ("product" in element && ((_a = element.product) == null ? void 0 : _a.type) === "product:static") {
17848
18020
  assets.push(element);
17849
18021
  }
17850
18022
  });
@@ -42872,7 +43044,7 @@ function checkProductQueueStatus(element, floorPlan) {
42872
43044
  }
42873
43045
  }
42874
43046
  function getProductGraphics(element, nodeContainer, floorPlan, style) {
42875
- var _a;
43047
+ var _a, _b, _c, _d;
42876
43048
  checkProductQueueStatus(element, floorPlan);
42877
43049
  const { view, settings: settings2, loader } = floorPlan;
42878
43050
  const { theme, showCeilingLamps } = settings2;
@@ -42882,7 +43054,10 @@ function getProductGraphics(element, nodeContainer, floorPlan, style) {
42882
43054
  const productId = (_a = element.product) == null ? void 0 : _a.id;
42883
43055
  const productData = loader.resources.productJson.get(
42884
43056
  productId
42885
- ) || { subCategories: [] };
43057
+ ) || {
43058
+ subCategories: []
43059
+ };
43060
+ const isComponent = ((_b = element.product) == null ? void 0 : _b.type) === "product:component";
42886
43061
  const productContours = loader.resources.productContour.get(productId);
42887
43062
  const textureData = loader.resources.texture.get(productId);
42888
43063
  const contourShapes = getPolygonShapes(productContours);
@@ -42890,10 +43065,24 @@ function getProductGraphics(element, nodeContainer, floorPlan, style) {
42890
43065
  if (hideCeilingLamps) {
42891
43066
  return [];
42892
43067
  }
42893
- const zValue = getIndex(element.type, getOrder(productData));
43068
+ let order = 0;
43069
+ if (isComponent) {
43070
+ for (const child of element.elements) {
43071
+ if (child.type !== "element:asset" || !child.product) {
43072
+ continue;
43073
+ }
43074
+ const childOrder = getOrder(child.product.attributes);
43075
+ if (childOrder > order) {
43076
+ order = childOrder;
43077
+ }
43078
+ }
43079
+ } else {
43080
+ order = getOrder(productData);
43081
+ }
43082
+ const zValue = getIndex(element.type, order);
42894
43083
  nodeContainer.zIndex = zValue || 0;
42895
43084
  let resolvedStyle = getNodeStyle({ element, settings: settings2, style });
42896
- if (!productContours && productData.boundingBox) {
43085
+ if (!productContours && !isComponent && productData.boundingBox) {
42897
43086
  const boxContours = getBoundingBoxContour(productData.boundingBox);
42898
43087
  shapes = getPolygonShapes(boxContours);
42899
43088
  gfx = new Graphics();
@@ -42912,6 +43101,16 @@ function getProductGraphics(element, nodeContainer, floorPlan, style) {
42912
43101
  gfx.anchor.x = textureData.anchor.x;
42913
43102
  gfx.anchor.y = textureData.anchor.y;
42914
43103
  gfx.zIndex = 1;
43104
+ if (((_c = productData.categories) == null ? void 0 : _c.includes("tables")) || ((_d = productData.categories) == null ? void 0 : _d.includes("seating"))) {
43105
+ const hitArea = new Polygon(
43106
+ contourShapes[0].polygons[0].flatMap((p2) => [
43107
+ p2[0] * scale / gfx.scale.x,
43108
+ p2[1] * scale / gfx.scale.y
43109
+ ])
43110
+ );
43111
+ gfx.hitArea = hitArea;
43112
+ gfx.interactive = true;
43113
+ }
42915
43114
  if (style === "selected") {
42916
43115
  if (!textureData.contourTexture) {
42917
43116
  textureData.contourTexture = textureFromShapes(contourShapes, {
@@ -43035,6 +43234,9 @@ function drawNode(node, floorPlan, { ctx, style, container, preview }) {
43035
43234
  createNodeGraphics(node, nodeContainer, floorPlan, style, preview, ctx);
43036
43235
  }
43037
43236
  if (node && "elements" in node) {
43237
+ if (node.elements.length) {
43238
+ nodeContainer.sortableChildren = true;
43239
+ }
43038
43240
  for (const child of node.elements) {
43039
43241
  drawNode(child, floorPlan, { ctx: nodeContainer, style, preview });
43040
43242
  }