venue-js 1.4.0-next.2 → 1.4.0-next.21

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/index.js CHANGED
@@ -37,6 +37,7 @@ __export(index_exports, {
37
37
  GEOJSON_FEATURE_TYPES: () => GEOJSON_FEATURE_TYPES,
38
38
  HIGHLIGHT_LAYER_NAME: () => HIGHLIGHT_LAYER_NAME,
39
39
  IMDF_FEATURE_TYPES: () => IMDF_FEATURE_TYPES,
40
+ IMDF_UNIT_CATEGORIES: () => IMDF_UNIT_CATEGORIES,
40
41
  IndoorMap: () => IndoorMap,
41
42
  LAST_USER_LOCATION_ELEMENT_ID_PREFIX: () => LAST_USER_LOCATION_ELEMENT_ID_PREFIX,
42
43
  LAYERS: () => LAYERS,
@@ -68,11 +69,13 @@ __export(index_exports, {
68
69
  getLocationByFeature: () => getLocationByFeature,
69
70
  getLocationByOccupant: () => getLocationByOccupant,
70
71
  getLocationIdByFeature: () => getLocationIdByFeature,
72
+ getNavigateClient: () => getNavigateClient,
71
73
  getOrdinalByLocationId: () => getOrdinalByLocationId,
72
74
  getRelatedLocationIdsByFeature: () => getRelatedLocationIdsByFeature,
73
75
  getRelatedLocationsByAmenity: () => getRelatedLocationsByAmenity,
74
76
  getRelatedLocationsByFeature: () => getRelatedLocationsByFeature,
75
77
  getRelatedLocationsByOccupant: () => getRelatedLocationsByOccupant,
78
+ getSearchClient: () => getSearchClient,
76
79
  getSuitablyValueBetweenBearings: () => getSuitablyValueBetweenBearings,
77
80
  isClickableFeature: () => isClickableFeature,
78
81
  isValidCoordinate: () => isValidCoordinate,
@@ -113,6 +116,71 @@ var IMDF_FEATURE_TYPES = [
113
116
  "unit",
114
117
  "venue"
115
118
  ];
119
+ var IMDF_UNIT_CATEGORIES = [
120
+ "auditorium",
121
+ "brick",
122
+ "classroom",
123
+ "column",
124
+ "concrete",
125
+ "conferenceroom",
126
+ "drywall",
127
+ "elevator",
128
+ "escalator",
129
+ "fieldofplay",
130
+ "firstaid",
131
+ "fitnessroom",
132
+ "foodservice",
133
+ "footbridge",
134
+ "glass",
135
+ "huddleroom",
136
+ "kitchen",
137
+ "laboratory",
138
+ "library",
139
+ "lobby",
140
+ "lounge",
141
+ "mailroom",
142
+ "mothersroom",
143
+ "movietheater",
144
+ "movingwalkway",
145
+ "nonpublic",
146
+ "office",
147
+ "opentobelow",
148
+ "parking",
149
+ "phoneroom",
150
+ "platform",
151
+ "privatelounge",
152
+ "ramp",
153
+ "recreation",
154
+ "restroom",
155
+ "restroom.family",
156
+ "restroom.female",
157
+ "restroom.female.wheelchair",
158
+ "restroom.male",
159
+ "restroom.male.wheelchair",
160
+ "restroom.transgender",
161
+ "restroom.transgender.wheelchair",
162
+ "restroom.unisex",
163
+ "restroom.unisex.wheelchair",
164
+ "restroom.wheelchair",
165
+ "road",
166
+ "room",
167
+ "serverroom",
168
+ "shower",
169
+ "smokingarea",
170
+ "stairs",
171
+ "steps",
172
+ "storage",
173
+ "structure",
174
+ "terrace",
175
+ "theater",
176
+ "unenclosedarea",
177
+ "unspecified",
178
+ "vegetation",
179
+ "waitingroom",
180
+ "walkway",
181
+ "walkway.island",
182
+ "wood"
183
+ ];
116
184
  var NONIMDF_FEATURE_TYPES = [
117
185
  "taxonomy",
118
186
  "event",
@@ -171,6 +239,119 @@ var defaultFeatureQueryOptionsMap = {
171
239
  model3d: {}
172
240
  };
173
241
 
242
+ // src/data/utils/geometry-validator.ts
243
+ var isValidCoordinate = (point2) => {
244
+ return point2.length === 2 && point2.every((coord) => typeof coord === "number");
245
+ };
246
+ function isValidLinearRingCoordinates(ring) {
247
+ if (ring.length < 4) {
248
+ return false;
249
+ }
250
+ return ring.every(isValidCoordinate) && ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][1];
251
+ }
252
+ var isValidPolygonCoordinates = (polygon2) => {
253
+ if (Array.isArray(polygon2[0]) && (polygon2[0].length === 0 || typeof polygon2[0][0] === "number")) {
254
+ return isValidLinearRingCoordinates(polygon2);
255
+ }
256
+ if (Array.isArray(polygon2) && polygon2.length > 0 && Array.isArray(polygon2[0])) {
257
+ if (!isValidLinearRingCoordinates(polygon2[0])) {
258
+ return false;
259
+ }
260
+ for (let i = 1; i < polygon2.length; i++) {
261
+ if (!isValidLinearRingCoordinates(polygon2[i])) {
262
+ return false;
263
+ }
264
+ }
265
+ return true;
266
+ }
267
+ return false;
268
+ };
269
+ var isValidMultiPolygonCoordinates = (multipolygon) => {
270
+ return multipolygon.every(isValidPolygonCoordinates);
271
+ };
272
+ var isValidLineStringCoordinates = (lineString2) => {
273
+ if (!Array.isArray(lineString2) || lineString2.length < 2) {
274
+ return false;
275
+ }
276
+ const firstPoint = lineString2[0];
277
+ const lastPoint = lineString2[lineString2.length - 1];
278
+ if (firstPoint[0] === lastPoint[0] && firstPoint[1] === lastPoint[1]) {
279
+ return false;
280
+ }
281
+ return lineString2.every(isValidCoordinate);
282
+ };
283
+ var isValidMultiPolygon = (geometry) => {
284
+ const { type, coordinates } = geometry;
285
+ return type === "MultiPolygon" && isValidMultiPolygonCoordinates(coordinates);
286
+ };
287
+ var isValidPolygon = (geometry) => {
288
+ const { type, coordinates } = geometry;
289
+ return type === "Polygon" && isValidPolygonCoordinates(coordinates);
290
+ };
291
+ var isValidLineString = (geometry) => {
292
+ const { type, coordinates } = geometry;
293
+ return type === "LineString" && isValidLineStringCoordinates(coordinates);
294
+ };
295
+ var isValidPoint = (geometry) => {
296
+ const { type, coordinates } = geometry;
297
+ return type === "Point" && isValidCoordinate(coordinates);
298
+ };
299
+
300
+ // src/data/utils/match-filters.ts
301
+ function isInFilter(filter) {
302
+ return typeof filter === "object" && filter !== null && "$in" in filter && Array.isArray(filter.$in);
303
+ }
304
+ var someIntersect = (a, b) => a.some((v) => b.includes(v));
305
+ function matchFilter(value, filter) {
306
+ if (Array.isArray(value)) {
307
+ if (isInFilter(filter)) return someIntersect(value, filter.$in);
308
+ return value.includes(filter);
309
+ } else {
310
+ if (isInFilter(filter)) return filter.$in.includes(value);
311
+ return value === filter;
312
+ }
313
+ }
314
+ function matchFilters(item, filters) {
315
+ return Object.entries(filters).every(([key, filter]) => {
316
+ return matchFilter(item.properties[key], filter);
317
+ });
318
+ }
319
+
320
+ // src/data/utils/occupant-helper.ts
321
+ var occupant_helper_exports = {};
322
+ __export(occupant_helper_exports, {
323
+ getOccupantCorrelatedLocations: () => getOccupantCorrelatedLocations,
324
+ getOccupantMainLocation: () => getOccupantMainLocation,
325
+ getOccupantMarkerLocations: () => getOccupantMarkerLocations
326
+ });
327
+
328
+ // src/data/utils/lodash/compact.ts
329
+ var compact = (arr) => arr.filter((item) => Boolean(item));
330
+
331
+ // src/data/utils/occupant-helper.ts
332
+ var getOccupantMainLocation = (occupant) => {
333
+ return occupant.properties.kiosk || occupant.properties.unit;
334
+ };
335
+ var getOccupantCorrelatedLocations = (occupant) => {
336
+ const allCorrelatedLocations = [
337
+ ...occupant.properties.units,
338
+ ...occupant.properties.kiosks
339
+ ];
340
+ return compact(allCorrelatedLocations);
341
+ };
342
+ var getOccupantMarkerLocations = (occupant, options) => {
343
+ const placementType = options?.type ? options.type : occupant.properties.show_name_on_all_units ? "ALL_LOCATIONS" : "ONCE_PER_LEVEL";
344
+ const mainLocation = getOccupantMainLocation(occupant);
345
+ const mainLocationLevel = mainLocation?.properties?.level_id;
346
+ const allCorrelatedLocations = getOccupantCorrelatedLocations(occupant);
347
+ if (placementType === "ALL_LOCATIONS") {
348
+ return compact([mainLocation, ...allCorrelatedLocations]);
349
+ }
350
+ const otherLevelLocations = allCorrelatedLocations.filter((f) => f.properties.level_id !== mainLocationLevel);
351
+ const onePerLevelLocations = [...new Map(otherLevelLocations.map((loc) => [loc.properties.level_id, loc])).values()];
352
+ return compact([mainLocation, ...onePerLevelLocations]);
353
+ };
354
+
174
355
  // src/data/api/delivery-project.ts
175
356
  async function fetchDeliveryApi(projectId, apiKey, featureType, baseUrl = DEFAULT_BASE_URL) {
176
357
  switch (featureType) {
@@ -292,121 +473,44 @@ var safeFetchFeature = async (featureType, params) => {
292
473
  }
293
474
  };
294
475
 
295
- // src/data/utils/geometry-validator.ts
296
- var isValidCoordinate = (point2) => {
297
- return point2.length === 2 && point2.every((coord) => typeof coord === "number");
298
- };
299
- function isValidLinearRingCoordinates(ring) {
300
- if (ring.length < 4) {
301
- return false;
302
- }
303
- return ring.every(isValidCoordinate) && ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][1];
304
- }
305
- var isValidPolygonCoordinates = (polygon2) => {
306
- if (Array.isArray(polygon2[0]) && (polygon2[0].length === 0 || typeof polygon2[0][0] === "number")) {
307
- return isValidLinearRingCoordinates(polygon2);
308
- }
309
- if (Array.isArray(polygon2) && polygon2.length > 0 && Array.isArray(polygon2[0])) {
310
- if (!isValidLinearRingCoordinates(polygon2[0])) {
311
- return false;
312
- }
313
- for (let i = 1; i < polygon2.length; i++) {
314
- if (!isValidLinearRingCoordinates(polygon2[i])) {
476
+ // src/data/getDataClient.ts
477
+ var import_query_core = require("@tanstack/query-core");
478
+
479
+ // src/data/populator/index.ts
480
+ var import_center2 = require("@turf/center");
481
+ var import_boolean_point_in_polygon2 = require("@turf/boolean-point-in-polygon");
482
+
483
+ // src/data/utils/findContaining.ts
484
+ var import_center = require("@turf/center");
485
+ var import_boolean_point_in_polygon = require("@turf/boolean-point-in-polygon");
486
+ var findContainingUnit = (poi, units) => {
487
+ const unit = units.find(
488
+ (unit2) => {
489
+ try {
490
+ return unit2.properties.level_id === poi.properties.level_id && (0, import_boolean_point_in_polygon.booleanPointInPolygon)((0, import_center.center)(poi), unit2);
491
+ } catch (e) {
492
+ console.log(`Cannot find containing unit of (${poi.id}):`, e.message);
315
493
  return false;
316
494
  }
317
495
  }
318
- return true;
319
- }
320
- return false;
321
- };
322
- var isValidMultiPolygonCoordinates = (multipolygon) => {
323
- return multipolygon.every(isValidPolygonCoordinates);
324
- };
325
- var isValidLineStringCoordinates = (lineString2) => {
326
- if (!Array.isArray(lineString2) || lineString2.length < 2) {
327
- return false;
328
- }
329
- const firstPoint = lineString2[0];
330
- const lastPoint = lineString2[lineString2.length - 1];
331
- if (firstPoint[0] === lastPoint[0] && firstPoint[1] === lastPoint[1]) {
332
- return false;
333
- }
334
- return lineString2.every(isValidCoordinate);
335
- };
336
- var isValidMultiPolygon = (geometry) => {
337
- const { type, coordinates } = geometry;
338
- return type === "MultiPolygon" && isValidMultiPolygonCoordinates(coordinates);
339
- };
340
- var isValidPolygon = (geometry) => {
341
- const { type, coordinates } = geometry;
342
- return type === "Polygon" && isValidPolygonCoordinates(coordinates);
343
- };
344
- var isValidLineString = (geometry) => {
345
- const { type, coordinates } = geometry;
346
- return type === "LineString" && isValidLineStringCoordinates(coordinates);
347
- };
348
- var isValidPoint = (geometry) => {
349
- const { type, coordinates } = geometry;
350
- return type === "Point" && isValidCoordinate(coordinates);
351
- };
352
-
353
- // src/data/utils/match-filters.ts
354
- function isInFilter(filter) {
355
- return typeof filter === "object" && filter !== null && "$in" in filter && Array.isArray(filter.$in);
356
- }
357
- var someIntersect = (a, b) => a.some((v2) => b.includes(v2));
358
- function matchFilter(value, filter) {
359
- if (Array.isArray(value)) {
360
- if (isInFilter(filter)) return someIntersect(value, filter.$in);
361
- return value.includes(filter);
362
- } else {
363
- if (isInFilter(filter)) return filter.$in.includes(value);
364
- return value === filter;
365
- }
366
- }
367
- function matchFilters(item, filters) {
368
- return Object.entries(filters).every(([key, filter]) => {
369
- return matchFilter(item.properties[key], filter);
370
- });
371
- }
372
-
373
- // src/data/utils/occupant-helper.ts
374
- var occupant_helper_exports = {};
375
- __export(occupant_helper_exports, {
376
- getOccupantCorrelatedLocations: () => getOccupantCorrelatedLocations,
377
- getOccupantMainLocation: () => getOccupantMainLocation,
378
- getOccupantMarkerLocations: () => getOccupantMarkerLocations
379
- });
380
- var import_lodash_es = require("lodash-es");
381
- var getOccupantMainLocation = (occupant) => {
382
- return occupant.properties.kiosk || occupant.properties.unit;
383
- };
384
- var getOccupantCorrelatedLocations = (occupant) => {
385
- const allCorrelatedLocations = [
386
- ...occupant.properties.units,
387
- ...occupant.properties.kiosks
388
- ];
389
- return (0, import_lodash_es.compact)(allCorrelatedLocations);
496
+ );
497
+ return unit;
390
498
  };
391
- var getOccupantMarkerLocations = (occupant, options) => {
392
- const placementType = options?.type ? options.type : occupant.properties.show_name_on_all_units ? "ALL_LOCATIONS" : "ONCE_PER_LEVEL";
393
- const mainLocation = getOccupantMainLocation(occupant);
394
- const mainLocationLevel = mainLocation?.properties?.level_id;
395
- const allCorrelatedLocations = getOccupantCorrelatedLocations(occupant);
396
- if (placementType === "ALL_LOCATIONS") {
397
- return (0, import_lodash_es.compact)([mainLocation, ...allCorrelatedLocations]);
398
- }
399
- const otherLevelLocations = allCorrelatedLocations.filter((f) => f.properties.level_id !== mainLocationLevel);
400
- const onePerLevelLocations = [...new Map(otherLevelLocations.map((loc) => [loc.properties.level_id, loc])).values()];
401
- return (0, import_lodash_es.compact)([mainLocation, ...onePerLevelLocations]);
499
+ var findContainingUnitAtPoint = (point2, levelId, units) => {
500
+ const unit = units.find(
501
+ (unit2) => {
502
+ try {
503
+ return unit2.properties.level_id === levelId && (0, import_boolean_point_in_polygon.booleanPointInPolygon)(point2, unit2);
504
+ } catch (e) {
505
+ console.log(`Cannot find containing unit of (point: ${point2}, levelId: ${levelId}):`, e.message);
506
+ return false;
507
+ }
508
+ }
509
+ );
510
+ return unit;
402
511
  };
403
512
 
404
- // src/data/getDataClient.ts
405
- var import_query_core = require("@tanstack/query-core");
406
-
407
513
  // src/data/populator/index.ts
408
- var import_lodash_es2 = require("lodash-es");
409
- var import_boolean_within = require("@turf/boolean-within");
410
514
  var createPopulator = ({
411
515
  internalFindById,
412
516
  internalFilterByType
@@ -416,7 +520,6 @@ var createPopulator = ({
416
520
  const populateDetail = (detail) => Promise.resolve(detail);
417
521
  const populateFootprint = (footprint) => Promise.resolve(footprint);
418
522
  const populateGeofence = (geofence) => Promise.resolve(geofence);
419
- const populateRelationship = (relationship) => Promise.resolve(relationship);
420
523
  const populatePrivilege = (privilege) => Promise.resolve(privilege);
421
524
  const populateEvent = (event) => Promise.resolve(event);
422
525
  const populatePromotion = async (promotion) => {
@@ -440,13 +543,14 @@ var createPopulator = ({
440
543
  const ordinalKiosks = kiosks.filter(
441
544
  (kiosk2) => kiosk2.properties.level_id === defaultLevel.id
442
545
  );
443
- const kiosk = ordinalKiosks.find((kiosk2) => (0, import_boolean_within.booleanWithin)(amenity, kiosk2));
546
+ const kiosk = ordinalKiosks.find((kiosk2) => (0, import_boolean_point_in_polygon2.booleanPointInPolygon)(amenity, kiosk2));
444
547
  return {
445
548
  ...amenity,
446
549
  properties: {
447
550
  ...amenity.properties,
448
551
  ordinal: defaultLevel.properties.ordinal,
449
552
  level_name: defaultLevel.properties.name.en,
553
+ level: defaultLevel,
450
554
  units: populatedUnits,
451
555
  venue,
452
556
  _experimental_kiosk: kiosk ? await populateKiosk(kiosk) : null
@@ -458,7 +562,7 @@ var createPopulator = ({
458
562
  const venue = await internalFindById(unit.properties.venue_id);
459
563
  const level = await internalFindById(unit.properties.level_id);
460
564
  const sections = await internalFilterByType("section");
461
- const section = sections.find((section2) => (0, import_boolean_within.booleanWithin)(anchor, section2));
565
+ const section = sections.find((section2) => (0, import_boolean_point_in_polygon2.booleanPointInPolygon)(anchor, section2));
462
566
  return {
463
567
  ...anchor,
464
568
  properties: {
@@ -491,20 +595,11 @@ var createPopulator = ({
491
595
  const venue = await internalFindById(kiosk.properties.venue_id);
492
596
  const anchor = await internalFindById(kiosk.properties.anchor_id);
493
597
  const units = await internalFilterByType("unit");
494
- const unit = units.find(
495
- (unit2) => {
496
- try {
497
- return unit2.properties.category === "walkway" && unit2.properties.level_id === kiosk.properties.level_id && (0, import_boolean_within.booleanWithin)(kiosk, unit2);
498
- } catch (e) {
499
- console.log(`Cannot find kiosk(${kiosk.id})'s units:`, e.message);
500
- return false;
501
- }
502
- }
503
- );
598
+ const unit = findContainingUnit(kiosk, units.filter((unit2) => unit2.properties.category === "walkway"));
504
599
  let section = null;
505
600
  if (anchor) {
506
601
  const sections = await internalFilterByType("section");
507
- section = sections.find((section2) => (0, import_boolean_within.booleanWithin)(anchor, section2));
602
+ section = sections.find((section2) => (0, import_boolean_point_in_polygon2.booleanPointInPolygon)(anchor, section2));
508
603
  }
509
604
  return {
510
605
  ...kiosk,
@@ -534,8 +629,8 @@ var createPopulator = ({
534
629
  anchor_id,
535
630
  venue_id,
536
631
  local_category_ids,
537
- promotion_ids,
538
- privilege_ids,
632
+ promotion_ids = [],
633
+ privilege_ids = [],
539
634
  kiosk_id,
540
635
  unit_id,
541
636
  kiosk_ids = [],
@@ -562,7 +657,7 @@ var createPopulator = ({
562
657
  ...occupant.properties,
563
658
  anchor: anchor ? await populateAnchor(anchor) : null,
564
659
  local_categories: await Promise.all(
565
- (0, import_lodash_es2.compact)(localCategories).map(populateTaxonomy)
660
+ compact(localCategories).map(populateTaxonomy)
566
661
  ),
567
662
  venue,
568
663
  promotions,
@@ -599,12 +694,29 @@ var createPopulator = ({
599
694
  }
600
695
  };
601
696
  };
697
+ const populateRelationship = async (relationship) => {
698
+ const originId = relationship.properties.origin?.id;
699
+ const destinationId = relationship.properties.destination?.id;
700
+ const origin = originId ? await internalFindById(originId) : null;
701
+ const destination = destinationId ? await internalFindById(destinationId) : null;
702
+ const intermediary_ids = (relationship.properties.intermediary || []).map(({ id }) => id);
703
+ const intermediary = await Promise.all(intermediary_ids.map(internalFindById));
704
+ return {
705
+ ...relationship,
706
+ properties: {
707
+ ...relationship.properties,
708
+ origin,
709
+ destination,
710
+ intermediary
711
+ }
712
+ };
713
+ };
602
714
  const populateUnit = async (unit) => {
603
715
  const venue = await internalFindById(unit.properties.venue_id);
604
716
  const level = await internalFindById(unit.properties.level_id);
605
717
  const sections = await internalFilterByType("section");
606
718
  try {
607
- const section = unit.geometry.type !== "MultiPolygon" ? sections.find((section2) => (0, import_boolean_within.booleanWithin)(unit, section2)) : null;
719
+ const section = unit.geometry.type !== "MultiPolygon" ? sections.find((section2) => (0, import_boolean_point_in_polygon2.booleanPointInPolygon)((0, import_center2.center)(unit), section2)) : null;
608
720
  return {
609
721
  ...unit,
610
722
  properties: {
@@ -632,6 +744,20 @@ var createPopulator = ({
632
744
  }
633
745
  };
634
746
  };
747
+ const populateModel3D = async (model3d) => {
748
+ const level = await internalFindById(model3d.properties.level_id);
749
+ try {
750
+ return {
751
+ ...model3d,
752
+ properties: {
753
+ ...model3d.properties,
754
+ level: await populateLevel(level)
755
+ }
756
+ };
757
+ } catch (err) {
758
+ console.log(`error finding level`, { model3d, level });
759
+ }
760
+ };
635
761
  const populateFeature = (feature2) => Promise.resolve(feature2);
636
762
  return {
637
763
  address: populateAddress,
@@ -656,23 +782,1666 @@ var createPopulator = ({
656
782
  section: populateSection,
657
783
  unit: populateUnit,
658
784
  venue: populateVenue,
659
- taxonomy: populateTaxonomy
785
+ taxonomy: populateTaxonomy,
786
+ model3d: populateModel3D
660
787
  };
661
788
  };
662
789
 
663
- // src/data/getDataClient.ts
664
- var getDataClient = (options) => {
665
- const observers = /* @__PURE__ */ new Map();
666
- const queryClient = options.queryClient ?? new import_query_core.QueryClient();
667
- const { mode = "delivery", projectId, apiKey, baseUrl, previewToken } = options;
668
- if (!projectId)
669
- throw new Error(
670
- "Cannot create VenueDataClient. Reason: `projectId` is missing"
671
- );
672
- if (mode === "delivery" && !apiKey)
673
- throw new Error(
674
- "Cannot create VenueDataClient. Reason: `apiKey` is missing"
675
- );
790
+ // src/data/search/getSearchClient.ts
791
+ var import_fuse = __toESM(require("fuse.js"));
792
+
793
+ // src/data/search/utils/sanitizeInput.ts
794
+ var sanitizeInput = (str) => str.replace(/[\u200E\u200F\u202A-\u202E\u2066-\u2069]/g, "").replace(/[\-–—_./()]+/g, "").normalize("NFC").trim();
795
+
796
+ // src/data/search/getSearchClient.ts
797
+ var getSearchClient = ({ occupants, amenities }) => {
798
+ const fuseAmenities = new import_fuse.default(amenities, {
799
+ threshold: 0.2,
800
+ keys: [
801
+ { name: "properties.name", "weight": 1, getFn: (obj) => Object.values(obj.properties.name || {}) },
802
+ { name: "properties.category", "weight": 1 }
803
+ ]
804
+ });
805
+ const fuseOccupants = new import_fuse.default(occupants, {
806
+ threshold: 0.25,
807
+ // 0.2 is too strict (can't find Mo-Mo Paradise with "momo" search string)
808
+ includeScore: true,
809
+ shouldSort: true,
810
+ keys: [
811
+ { name: "properties.name", "weight": 4, getFn: (obj) => Object.values(obj.properties.name || {}) },
812
+ { name: "properties.keywords", "weight": 0.5 },
813
+ { name: "properties.category", "weight": 0.25 },
814
+ { name: "properties.local_category_names", "weight": 0.25 },
815
+ { name: "properties.description", "weight": 0.25, getFn: (occ) => Object.values(occ.properties.description || {}) },
816
+ { name: "properties.unit_name", "weight": 0.25 },
817
+ { name: "properties.kiosk_name", "weight": 0.25 }
818
+ ]
819
+ });
820
+ const search = (value) => {
821
+ const sanitizedValue = sanitizeInput(value);
822
+ const matchedAmenities = fuseAmenities.search(sanitizedValue);
823
+ const matchedOccupants = fuseOccupants.search(sanitizedValue);
824
+ return [...matchedAmenities, ...matchedOccupants];
825
+ };
826
+ return {
827
+ search
828
+ };
829
+ };
830
+
831
+ // src/data/navigate/getNavigateClient.ts
832
+ var import_boolean_point_in_polygon4 = require("@turf/boolean-point-in-polygon");
833
+
834
+ // src/data/navigate/graph/prepare.ts
835
+ var import_lodash11 = __toESM(require("lodash"));
836
+ var import_node_dijkstra = __toESM(require("node-dijkstra"));
837
+ var import_distance3 = require("@turf/distance");
838
+ var import_center5 = require("@turf/center");
839
+
840
+ // src/data/navigate/graph/nodemap/createTraversalNodeMap.ts
841
+ var import_distance = require("@turf/distance");
842
+ var import_center3 = require("@turf/center");
843
+ var import_lodash3 = __toESM(require("lodash"));
844
+
845
+ // src/data/navigate/graph/constants.ts
846
+ var ROOM_BASEDISTANCE = 1e3;
847
+ var TERRACE_BASEDISTANCE = 1e3;
848
+ var ESCALATOR_BASEDISTANCE = 200;
849
+ var RAMP_BASEDISTANCE = 200;
850
+ var ELEVATOR_BASEDISTANCE = 500;
851
+ var STAIR_BASEDISTANCE = 1e5;
852
+ var BASE_POI_BASEDISTANCE = 9999999;
853
+ var DEFAULT_UNIT_BASEDISTANCE_OPTIONS = {
854
+ default: { baseDistance: 0 },
855
+ byCategory: {
856
+ room: { baseDistance: ROOM_BASEDISTANCE },
857
+ terrace: { baseDistance: TERRACE_BASEDISTANCE },
858
+ escalator: { baseDistance: ESCALATOR_BASEDISTANCE, scaleDistanceByLevel: false },
859
+ ramp: { baseDistance: RAMP_BASEDISTANCE, scaleDistanceByLevel: false },
860
+ elevator: { baseDistance: ELEVATOR_BASEDISTANCE, scaleDistanceByLevel: false },
861
+ stairs: {
862
+ baseDistance: STAIR_BASEDISTANCE,
863
+ scaleDistanceByLevel: true
864
+ },
865
+ "stairs.emergencyexit": {
866
+ baseDistance: STAIR_BASEDISTANCE,
867
+ scaleDistanceByLevel: true
868
+ }
869
+ }
870
+ };
871
+
872
+ // src/data/navigate/graph/utils/getDistanceOption.ts
873
+ var getDistanceOptions = (options, category) => {
874
+ if (!options) return DEFAULT_UNIT_BASEDISTANCE_OPTIONS.byCategory[category];
875
+ return (category && options.byCategory?.[category]) ?? DEFAULT_UNIT_BASEDISTANCE_OPTIONS.byCategory[category] ?? options?.default ?? DEFAULT_UNIT_BASEDISTANCE_OPTIONS.default;
876
+ };
877
+
878
+ // src/data/utils/trace.ts
879
+ var trace = (namespace, text, ms, color) => {
880
+ if (process.env.NODE_ENV !== "test") console.log(`[${namespace}] %c${text.padEnd(90)} ${ms !== void 0 ? `${ms.toFixed(1).padStart(6)} ms` : ``}`, color ? `color: ${color}` : void 0);
881
+ };
882
+
883
+ // src/data/navigate/graph/nodemap/createTraversalNodeMap.ts
884
+ var createTraversalNodeMap = (unitOpenings, options) => {
885
+ const { units } = options.data;
886
+ let counter = 0;
887
+ const calculateFeatureDistanceWithinUnit = (features, distanceOptions) => {
888
+ let relationshipGraph = {};
889
+ for (let currentIndex = 0; currentIndex < features.length; currentIndex++) {
890
+ const isLastItem = currentIndex + 1 === features.length;
891
+ if (isLastItem) break;
892
+ for (let j = currentIndex + 1; j < features.length; j++) {
893
+ const opening = features[currentIndex];
894
+ const feature2 = features[j];
895
+ try {
896
+ const distance5 = (0, import_distance.distance)(
897
+ (0, import_center3.center)(opening.geometry),
898
+ (0, import_center3.center)(feature2.geometry),
899
+ { units: "meters" }
900
+ ) + (distanceOptions?.baseDistance ?? 0);
901
+ if (opening.id === feature2.id) continue;
902
+ import_lodash3.default.set(relationshipGraph, `${opening.id}.${feature2.id}`, distance5);
903
+ import_lodash3.default.set(relationshipGraph, `${feature2.id}.${opening.id}`, distance5);
904
+ counter++;
905
+ } catch (error) {
906
+ continue;
907
+ }
908
+ }
909
+ }
910
+ return relationshipGraph;
911
+ };
912
+ const t0 = performance.now();
913
+ const nodeMap = import_lodash3.default.reduce(
914
+ unitOpenings,
915
+ (acc, openings, unitId) => {
916
+ const unit = units.find((unit2) => unit2.id === unitId);
917
+ const unitDistanceOption = getDistanceOptions(options.unitDistanceOptions, unit.properties.category);
918
+ return import_lodash3.default.merge(
919
+ acc,
920
+ calculateFeatureDistanceWithinUnit(openings, unitDistanceOption)
921
+ );
922
+ },
923
+ {}
924
+ );
925
+ const t1 = performance.now();
926
+ trace("nav", ` \u2502 \u251C\u2500 add ${counter} traversal relationships`, t1 - t0);
927
+ return nodeMap;
928
+ };
929
+
930
+ // src/data/navigate/graph/nodemap/createElevatorNodeMap.ts
931
+ var import_lodash4 = __toESM(require("lodash"));
932
+ var createElevatorNodeMap = (elevatorLikeRelationships, unitOpenings, options) => {
933
+ const t0 = performance.now();
934
+ const { levels, units } = options.data;
935
+ const distanceOptions = getDistanceOptions(options.unitDistanceOptions, "elevator");
936
+ const {
937
+ baseDistance = ELEVATOR_BASEDISTANCE,
938
+ scaleDistanceByLevel = false
939
+ } = distanceOptions;
940
+ let elevatorNodeMap = {};
941
+ let counter = 0;
942
+ for (const relationship of elevatorLikeRelationships) {
943
+ try {
944
+ const {
945
+ origin: originTypeAndId,
946
+ intermediary,
947
+ destination: destinationTypeAndId
948
+ } = relationship.properties;
949
+ const origin = units.find((unit) => unit.id === originTypeAndId.id);
950
+ if (!origin) return;
951
+ const originOpenings = compact(unitOpenings[origin.id]);
952
+ const originLevel = levels.find((level) => level.id === origin.properties.level_id);
953
+ const destination = units.find((unit) => unit.id === destinationTypeAndId.id);
954
+ const destinationOpenings = unitOpenings[destination.id];
955
+ const destinationOpeningAndLevels = destinationOpenings.map((opening) => {
956
+ const level = levels.find((level2) => level2.id === destination.properties.level_id);
957
+ return { opening, level };
958
+ });
959
+ const intermediaryOpeningAndLevels = intermediary.map((unitTypeAndId) => {
960
+ const openings = unitOpenings[unitTypeAndId.id];
961
+ const unit = units.find((unit2) => unit2.id === unitTypeAndId.id);
962
+ const level = levels.find((level2) => level2.id === unit.properties.level_id);
963
+ return openings.map((opening) => ({ opening, level }));
964
+ }).flat();
965
+ const connections = compact([...intermediaryOpeningAndLevels, ...destinationOpeningAndLevels]);
966
+ if (!originOpenings || originOpenings.length === 0) return;
967
+ for (const originOpening of originOpenings) {
968
+ for (const connection of connections) {
969
+ const { opening, level } = connection;
970
+ let distance5 = baseDistance;
971
+ if (scaleDistanceByLevel) {
972
+ const originOrdinal = originLevel.properties.ordinal;
973
+ const connectionOrdinal = level.properties.ordinal;
974
+ const levelDifference = Math.abs(originOrdinal - connectionOrdinal);
975
+ if (levelDifference > 0) distance5 *= levelDifference;
976
+ }
977
+ import_lodash4.default.set(elevatorNodeMap, `${originOpening.id}.${opening.id}`, distance5);
978
+ import_lodash4.default.set(elevatorNodeMap, `${opening.id}.${originOpening.id}`, distance5);
979
+ counter++;
980
+ }
981
+ }
982
+ } catch (err) {
983
+ console.log(err);
984
+ console.log("cannot create elevatorNodeMap for ", { relationship });
985
+ }
986
+ }
987
+ const t1 = performance.now();
988
+ trace("nav", ` \u2502 \u251C\u2500 add ${counter} escalator relationships`, t1 - t0);
989
+ return elevatorNodeMap;
990
+ };
991
+
992
+ // src/data/navigate/graph/nodemap/createEscalatorNodeMap.ts
993
+ var import_set = __toESM(require("lodash/set"));
994
+ var createEscalatorNodeMap = (relationships, options) => {
995
+ const t0 = performance.now();
996
+ const distanceOptions = getDistanceOptions(options.unitDistanceOptions, "escalator");
997
+ let counter = 0;
998
+ let nodeMap = {};
999
+ for (const relationship of relationships) {
1000
+ const {
1001
+ properties: { direction, origin, destination }
1002
+ } = relationship;
1003
+ (0, import_set.default)(nodeMap, `${origin.id}.${destination.id}`, distanceOptions.baseDistance);
1004
+ if (direction === "undirected") {
1005
+ (0, import_set.default)(nodeMap, `${destination.id}.${origin.id}`, distanceOptions.baseDistance);
1006
+ }
1007
+ counter++;
1008
+ }
1009
+ const t1 = performance.now();
1010
+ trace("nav", ` \u2502 \u251C\u2500 add ${counter} escalator relationships`, t1 - t0);
1011
+ return nodeMap;
1012
+ };
1013
+
1014
+ // src/data/navigate/graph/nodemap/createRampNodeMap.ts
1015
+ var import_set2 = __toESM(require("lodash/set"));
1016
+ var createRampNodeMap = (relationships, options) => {
1017
+ const t0 = performance.now();
1018
+ const distanceOptions = getDistanceOptions(options.unitDistanceOptions, "ramp");
1019
+ let counter = 0;
1020
+ let nodeMap = {};
1021
+ relationships.forEach((relationship) => {
1022
+ const {
1023
+ properties: { origin, destination }
1024
+ } = relationship;
1025
+ (0, import_set2.default)(nodeMap, `${origin.id}.${destination.id}`, distanceOptions.baseDistance);
1026
+ (0, import_set2.default)(nodeMap, `${destination.id}.${origin.id}`, distanceOptions.baseDistance);
1027
+ counter++;
1028
+ });
1029
+ const t1 = performance.now();
1030
+ trace("nav", ` \u2502 \u251C\u2500 add ${counter} ramp relationships`, t1 - t0);
1031
+ return nodeMap;
1032
+ };
1033
+
1034
+ // src/data/navigate/graph/nodemap/createStairNodeMap.ts
1035
+ var import_lodash6 = __toESM(require("lodash"));
1036
+ var createStairNodeMap = (elevatorLikeRelationships, unitOpenings, options) => {
1037
+ const t0 = performance.now();
1038
+ const { levels = [], openings = [], units = [] } = options.data;
1039
+ const { baseDistance, scaleDistanceByLevel } = getDistanceOptions(options.unitDistanceOptions, "stairs");
1040
+ let elevatorNodeMap = {};
1041
+ let counter = 0;
1042
+ for (const relationship of elevatorLikeRelationships) {
1043
+ try {
1044
+ const {
1045
+ origin: { id: originId },
1046
+ intermediary,
1047
+ destination: { id: destinationId }
1048
+ } = relationship.properties;
1049
+ const origin = openings.find((opening) => opening.id === originId);
1050
+ if (!origin) return;
1051
+ const originLevel = levels.find((level) => level.id === origin.properties.level_id);
1052
+ const destination = openings.find((opening) => opening.id === destinationId);
1053
+ const destinationOpeningAndLevel = {
1054
+ opening: destination,
1055
+ level: levels.find((level) => level.id === destination.properties.level_id)
1056
+ };
1057
+ const intermediaryOpeningAndLevels = intermediary.map((unitTypeAndId) => {
1058
+ const openings2 = unitOpenings[unitTypeAndId.id];
1059
+ const unit = units.find((unit2) => unit2.id === unitTypeAndId.id);
1060
+ const level = levels.find((level2) => level2.id === unit.properties.level_id);
1061
+ return openings2.map((opening) => ({ opening, level }));
1062
+ }).flat();
1063
+ const connections = [...intermediaryOpeningAndLevels, destinationOpeningAndLevel];
1064
+ if (!origin) return;
1065
+ for (const connection of connections) {
1066
+ const { opening, level } = connection;
1067
+ let distance5 = baseDistance;
1068
+ if (scaleDistanceByLevel) {
1069
+ const originOrdinal = originLevel.properties.ordinal;
1070
+ const connectionOrdinal = level.properties.ordinal;
1071
+ const levelDifference = Math.abs(originOrdinal - connectionOrdinal);
1072
+ if (levelDifference > 0) distance5 *= levelDifference;
1073
+ }
1074
+ import_lodash6.default.set(elevatorNodeMap, `${origin.id}.${opening.id}`, distance5);
1075
+ import_lodash6.default.set(elevatorNodeMap, `${opening.id}.${origin.id}`, distance5);
1076
+ counter++;
1077
+ }
1078
+ } catch (err) {
1079
+ console.warn(
1080
+ "Failed to create stairNodeMap",
1081
+ {
1082
+ relationshipId: relationship.id,
1083
+ featureType: relationship.feature_type,
1084
+ error: err instanceof Error ? err.message : err,
1085
+ stack: err instanceof Error ? err.stack : void 0
1086
+ }
1087
+ );
1088
+ }
1089
+ }
1090
+ const t1 = performance.now();
1091
+ trace("nav", ` \u2502 \u251C\u2500 add ${counter} stairs relationships`, t1 - t0);
1092
+ return elevatorNodeMap;
1093
+ };
1094
+
1095
+ // src/data/navigate/graph/nodemap/createOccupantNodeMap.ts
1096
+ var import_lodash7 = __toESM(require("lodash"));
1097
+ var createOccupantNodeMap = (occupants) => {
1098
+ const t0 = performance.now();
1099
+ let nodeMap = {};
1100
+ let counter = 0;
1101
+ occupants.forEach((occupant) => {
1102
+ const { unit_id, unit_ids = [], kiosk_id, kiosk_ids = [] } = occupant.properties;
1103
+ const occupantRoomIds = compact([unit_id, ...unit_ids]);
1104
+ const occupantKioskIds = compact([kiosk_id, ...kiosk_ids]);
1105
+ for (const roomId of occupantRoomIds) {
1106
+ import_lodash7.default.set(nodeMap, `${roomId}.${occupant.id}`, 1e-3);
1107
+ import_lodash7.default.set(nodeMap, `${occupant.id}.${roomId}`, 1e-3);
1108
+ counter++;
1109
+ }
1110
+ for (const kioskId of occupantKioskIds) {
1111
+ import_lodash7.default.set(nodeMap, `${kioskId}.${occupant.id}`, 1e-3);
1112
+ import_lodash7.default.set(nodeMap, `${occupant.id}.${kioskId}`, 1e-3);
1113
+ counter++;
1114
+ }
1115
+ });
1116
+ const t1 = performance.now();
1117
+ trace("nav", ` \u2502 \u251C\u2500 add ${counter} occupants relationships`, t1 - t0);
1118
+ return nodeMap;
1119
+ };
1120
+
1121
+ // src/data/navigate/graph/nodemap/createPOINodeMaps.ts
1122
+ var import_center4 = require("@turf/center");
1123
+ var import_distance2 = require("@turf/distance");
1124
+ var import_lodash9 = __toESM(require("lodash"));
1125
+ var createPOINodeMap = (features, getFeatureUnit, unitOpenings) => {
1126
+ const t0 = performance.now();
1127
+ let nodeMap = {};
1128
+ let counter = 0;
1129
+ features.forEach((feat) => {
1130
+ try {
1131
+ const locatedOnUnitId = getFeatureUnit(feat);
1132
+ const openings = unitOpenings[locatedOnUnitId];
1133
+ const center8 = (0, import_center4.center)(feat);
1134
+ for (const opening of openings) {
1135
+ try {
1136
+ const openingCenter = (0, import_center4.center)(opening);
1137
+ const dis = (0, import_distance2.distance)(center8, openingCenter, { units: "meters" }) + BASE_POI_BASEDISTANCE;
1138
+ import_lodash9.default.set(nodeMap, `${opening.id}.${feat.id}`, dis);
1139
+ import_lodash9.default.set(nodeMap, `${feat.id}.${opening.id}`, dis);
1140
+ counter++;
1141
+ } catch (err) {
1142
+ console.log(err, opening);
1143
+ }
1144
+ }
1145
+ } catch (err) {
1146
+ console.log(err);
1147
+ console.log(`cannot connect poi to openings`, err.message, { feat });
1148
+ }
1149
+ });
1150
+ const type = features.length > 0 ? features[0].feature_type : "-";
1151
+ const t1 = performance.now();
1152
+ trace("nav", ` \u2502 \u251C\u2500 add ${counter} ${type} relationships`, t1 - t0);
1153
+ return nodeMap;
1154
+ };
1155
+
1156
+ // src/data/navigate/graph/utils/mergeNodeMap.ts
1157
+ var mergeNodeMap = (nodeMaps) => {
1158
+ const out = {};
1159
+ for (const nodeMap of nodeMaps) {
1160
+ for (const from in nodeMap) {
1161
+ out[from] = {
1162
+ ...out[from] ?? {},
1163
+ ...nodeMap[from]
1164
+ };
1165
+ }
1166
+ }
1167
+ return out;
1168
+ };
1169
+
1170
+ // src/data/navigate/graph/utils/createUnitOpenings.ts
1171
+ var import_uniqBy = __toESM(require("lodash/uniqBy"));
1172
+ var createUnitOpenings = (relationships, units, openings) => {
1173
+ const openingConnections = {};
1174
+ const relationshipMap = /* @__PURE__ */ new Map();
1175
+ relationships.forEach((relationship) => {
1176
+ const originId = relationship.properties.origin?.id || null;
1177
+ const destinationId = relationship.properties.destination?.id || null;
1178
+ if (!relationshipMap.has(originId)) {
1179
+ relationshipMap.set(originId, []);
1180
+ }
1181
+ if (!relationshipMap.has(destinationId)) {
1182
+ relationshipMap.set(destinationId, []);
1183
+ }
1184
+ relationshipMap.get(originId).push(relationship);
1185
+ relationshipMap.get(destinationId).push(relationship);
1186
+ });
1187
+ units.forEach((unit) => {
1188
+ const unitId = unit.id;
1189
+ const connectedRelationship = relationshipMap.get(unitId) || [];
1190
+ const relationshipIntermediaryTypeAndId = compact(connectedRelationship.map(
1191
+ (relationship) => relationship.properties.intermediary?.[0]
1192
+ // Assuming intermediary is always an array
1193
+ ));
1194
+ const relationshipIntermediary = relationshipIntermediaryTypeAndId.map(({ id }) => {
1195
+ return openings.find((opening) => !!opening && opening.id === id);
1196
+ });
1197
+ openingConnections[unitId] = (0, import_uniqBy.default)(
1198
+ [...openingConnections[unitId] || [], ...relationshipIntermediary],
1199
+ "id"
1200
+ );
1201
+ });
1202
+ return openingConnections;
1203
+ };
1204
+
1205
+ // src/data/navigate/parsers.ts
1206
+ var parseOrdinalCoordinate = (id) => {
1207
+ return id.slice(0, -1).split(",").map(Number);
1208
+ };
1209
+
1210
+ // src/data/navigate/graph/prepare.ts
1211
+ var prepareGraph = (options) => {
1212
+ const {
1213
+ data: {
1214
+ amenities = [],
1215
+ anchors = [],
1216
+ occupants = [],
1217
+ relationships = [],
1218
+ openings = [],
1219
+ units = [],
1220
+ kiosks = []
1221
+ }
1222
+ } = options;
1223
+ const {
1224
+ traversal: traversalRelationships = [],
1225
+ escalator: escalatorRelationships = [],
1226
+ ramp: rampRelationships = [],
1227
+ elevator: elevatorRelationships = [],
1228
+ stairs: stairsRelationships = []
1229
+ } = import_lodash11.default.groupBy(relationships, "properties.category");
1230
+ const unitOpenings = createUnitOpenings(traversalRelationships, units, openings);
1231
+ const traversalNodeMap = createTraversalNodeMap(unitOpenings, options);
1232
+ const escalatorNodeMap = createEscalatorNodeMap(escalatorRelationships, options);
1233
+ const rampNodeMap = createRampNodeMap(rampRelationships, options);
1234
+ const elevatorNodeMap = createElevatorNodeMap(
1235
+ elevatorRelationships,
1236
+ unitOpenings,
1237
+ options
1238
+ );
1239
+ const stairNodeMap = createStairNodeMap(
1240
+ stairsRelationships,
1241
+ unitOpenings,
1242
+ options
1243
+ );
1244
+ const amenityNodeMap = createPOINodeMap(amenities, (amenity) => amenity.properties.unit_ids[0], unitOpenings);
1245
+ const anchorsNodeMap = createPOINodeMap(anchors, (anchor) => anchor.properties.unit_id, unitOpenings);
1246
+ const walkwayUnits = units.filter((unit) => unit.properties.category === "walkway");
1247
+ const kioskNodeMap = createPOINodeMap(kiosks, (kiosk) => findContainingUnit(kiosk, walkwayUnits)?.id, unitOpenings);
1248
+ const unitNodeMap = createPOINodeMap(units, (unit) => unit.id, unitOpenings);
1249
+ const occupantNodeMap = createOccupantNodeMap(occupants);
1250
+ const defaultGraph = new import_node_dijkstra.default(mergeNodeMap([
1251
+ traversalNodeMap,
1252
+ escalatorNodeMap,
1253
+ rampNodeMap,
1254
+ elevatorNodeMap,
1255
+ stairNodeMap,
1256
+ amenityNodeMap,
1257
+ anchorsNodeMap,
1258
+ kioskNodeMap,
1259
+ unitNodeMap,
1260
+ occupantNodeMap
1261
+ ]));
1262
+ const accessibleGraph = new import_node_dijkstra.default(mergeNodeMap([
1263
+ traversalNodeMap,
1264
+ rampNodeMap,
1265
+ elevatorNodeMap,
1266
+ amenityNodeMap,
1267
+ anchorsNodeMap,
1268
+ kioskNodeMap,
1269
+ unitNodeMap,
1270
+ occupantNodeMap
1271
+ ]));
1272
+ const addCoordinateOrdinalNode = (params, locatedOnUnit) => {
1273
+ const [lat, lng, ordinal] = parseOrdinalCoordinate(params);
1274
+ if (locatedOnUnit) {
1275
+ const openings2 = unitOpenings[locatedOnUnit.id];
1276
+ for (const opening of openings2) {
1277
+ const openingCenter = (0, import_center5.center)(opening);
1278
+ const dis = (0, import_distance3.distance)([lat, lng], openingCenter, { units: "meters" });
1279
+ defaultGraph.addNode(params, { [opening.id]: dis }).addNode(opening.id, { [params]: dis });
1280
+ accessibleGraph.addNode(params, { [opening.id]: dis }).addNode(opening.id, { [params]: dis });
1281
+ }
1282
+ }
1283
+ };
1284
+ return { defaultGraph, accessibleGraph, unitOpenings, addCoordinateOrdinalNode };
1285
+ };
1286
+
1287
+ // src/data/navigate/steps/createStepUtils.ts
1288
+ var import_lodash13 = require("lodash");
1289
+ var import_intersectionBy = __toESM(require("lodash/intersectionBy"));
1290
+
1291
+ // src/data/navigate/description/describe.ts
1292
+ var t = (template, locale, options) => {
1293
+ return template.replace(`{{intermediary}}`, options.intermediary ?? "").replace(`{{toward}}`, options.toward?.[locale] ?? "").replace(`{{landmark}}`, options.landmark?.[locale] ?? "");
1294
+ };
1295
+ var describeVerticalStep = (fromLevel, toLevel, intermediary) => {
1296
+ const dir = fromLevel.properties.ordinal < toLevel.properties.ordinal ? "up" : "down";
1297
+ const template = `Take the {{intermediary}} ${dir} to {{toward}}`;
1298
+ return {
1299
+ template,
1300
+ text: t(template, "en", { intermediary, toward: toLevel.properties.name })
1301
+ };
1302
+ };
1303
+ var describeHorizontalStep = (intermediary, toward, landmark) => {
1304
+ const template = `Follow the path ${intermediary === "walkway" ? `along the walkway` : `through {{intermediary}}`} ${toward ? `toward {{toward}}` : ``} ${landmark ? `near {{landmark}}` : ``}`.trim();
1305
+ return {
1306
+ text: t(template, "en", { intermediary, toward, landmark }),
1307
+ template
1308
+ };
1309
+ };
1310
+
1311
+ // src/data/navigate/steps/path/index.ts
1312
+ var import_lodash12 = __toESM(require("lodash"));
1313
+
1314
+ // src/data/navigate/constants.ts
1315
+ var OBSTACLE_FEATURE_TYPES = [
1316
+ "kiosk"
1317
+ /* , "fixture" */
1318
+ ];
1319
+ var OBSTACLE_CATEGORIES = [
1320
+ "fixture.water",
1321
+ "fixture.stage",
1322
+ "nonpublic",
1323
+ "opentobelow",
1324
+ "elevator",
1325
+ "escalator",
1326
+ "stairs",
1327
+ "stairs.emergencyexit",
1328
+ "room",
1329
+ "unspecified",
1330
+ "structure",
1331
+ "brick",
1332
+ "concrete",
1333
+ "drywall",
1334
+ "glass",
1335
+ "wood",
1336
+ "column"
1337
+ ];
1338
+ var WALKABLE_CATEGORY = [
1339
+ "walkway",
1340
+ "parking",
1341
+ "room",
1342
+ "terrace",
1343
+ "unenclosedarea",
1344
+ "vegetation",
1345
+ "unspecified"
1346
+ ];
1347
+
1348
+ // node_modules/@turf/helpers/dist/esm/index.js
1349
+ var earthRadius = 63710088e-1;
1350
+ var factors = {
1351
+ centimeters: earthRadius * 100,
1352
+ centimetres: earthRadius * 100,
1353
+ degrees: 360 / (2 * Math.PI),
1354
+ feet: earthRadius * 3.28084,
1355
+ inches: earthRadius * 39.37,
1356
+ kilometers: earthRadius / 1e3,
1357
+ kilometres: earthRadius / 1e3,
1358
+ meters: earthRadius,
1359
+ metres: earthRadius,
1360
+ miles: earthRadius / 1609.344,
1361
+ millimeters: earthRadius * 1e3,
1362
+ millimetres: earthRadius * 1e3,
1363
+ nauticalmiles: earthRadius / 1852,
1364
+ radians: 1,
1365
+ yards: earthRadius * 1.0936
1366
+ };
1367
+ function feature(geom, properties, options = {}) {
1368
+ const feat = { type: "Feature" };
1369
+ if (options.id === 0 || options.id) {
1370
+ feat.id = options.id;
1371
+ }
1372
+ if (options.bbox) {
1373
+ feat.bbox = options.bbox;
1374
+ }
1375
+ feat.properties = properties || {};
1376
+ feat.geometry = geom;
1377
+ return feat;
1378
+ }
1379
+ function point(coordinates, properties, options = {}) {
1380
+ if (!coordinates) {
1381
+ throw new Error("coordinates is required");
1382
+ }
1383
+ if (!Array.isArray(coordinates)) {
1384
+ throw new Error("coordinates must be an Array");
1385
+ }
1386
+ if (coordinates.length < 2) {
1387
+ throw new Error("coordinates must be at least 2 numbers long");
1388
+ }
1389
+ if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) {
1390
+ throw new Error("coordinates must contain numbers");
1391
+ }
1392
+ const geom = {
1393
+ type: "Point",
1394
+ coordinates
1395
+ };
1396
+ return feature(geom, properties, options);
1397
+ }
1398
+ function polygon(coordinates, properties, options = {}) {
1399
+ for (const ring of coordinates) {
1400
+ if (ring.length < 4) {
1401
+ throw new Error(
1402
+ "Each LinearRing of a Polygon must have 4 or more Positions."
1403
+ );
1404
+ }
1405
+ if (ring[ring.length - 1].length !== ring[0].length) {
1406
+ throw new Error("First and last Position are not equivalent.");
1407
+ }
1408
+ for (let j = 0; j < ring[ring.length - 1].length; j++) {
1409
+ if (ring[ring.length - 1][j] !== ring[0][j]) {
1410
+ throw new Error("First and last Position are not equivalent.");
1411
+ }
1412
+ }
1413
+ }
1414
+ const geom = {
1415
+ type: "Polygon",
1416
+ coordinates
1417
+ };
1418
+ return feature(geom, properties, options);
1419
+ }
1420
+ function lineString(coordinates, properties, options = {}) {
1421
+ if (coordinates.length < 2) {
1422
+ throw new Error("coordinates must be an array of two or more positions");
1423
+ }
1424
+ const geom = {
1425
+ type: "LineString",
1426
+ coordinates
1427
+ };
1428
+ return feature(geom, properties, options);
1429
+ }
1430
+ function featureCollection(features, options = {}) {
1431
+ const fc = { type: "FeatureCollection" };
1432
+ if (options.id) {
1433
+ fc.id = options.id;
1434
+ }
1435
+ if (options.bbox) {
1436
+ fc.bbox = options.bbox;
1437
+ }
1438
+ fc.features = features;
1439
+ return fc;
1440
+ }
1441
+ function multiPoint(coordinates, properties, options = {}) {
1442
+ const geom = {
1443
+ type: "MultiPoint",
1444
+ coordinates
1445
+ };
1446
+ return feature(geom, properties, options);
1447
+ }
1448
+ function isNumber(num) {
1449
+ return !isNaN(num) && num !== null && !Array.isArray(num);
1450
+ }
1451
+ function isObject(input) {
1452
+ return input !== null && typeof input === "object" && !Array.isArray(input);
1453
+ }
1454
+
1455
+ // node_modules/@turf/invariant/dist/esm/index.js
1456
+ function getCoord(coord) {
1457
+ if (!coord) {
1458
+ throw new Error("coord is required");
1459
+ }
1460
+ if (!Array.isArray(coord)) {
1461
+ if (coord.type === "Feature" && coord.geometry !== null && coord.geometry.type === "Point") {
1462
+ return [...coord.geometry.coordinates];
1463
+ }
1464
+ if (coord.type === "Point") {
1465
+ return [...coord.coordinates];
1466
+ }
1467
+ }
1468
+ if (Array.isArray(coord) && coord.length >= 2 && !Array.isArray(coord[0]) && !Array.isArray(coord[1])) {
1469
+ return [...coord];
1470
+ }
1471
+ throw new Error("coord must be GeoJSON Point or an Array of numbers");
1472
+ }
1473
+ function getGeom(geojson) {
1474
+ if (geojson.type === "Feature") {
1475
+ return geojson.geometry;
1476
+ }
1477
+ return geojson;
1478
+ }
1479
+ function getType(geojson, _name) {
1480
+ if (geojson.type === "FeatureCollection") {
1481
+ return "FeatureCollection";
1482
+ }
1483
+ if (geojson.type === "GeometryCollection") {
1484
+ return "GeometryCollection";
1485
+ }
1486
+ if (geojson.type === "Feature" && geojson.geometry !== null) {
1487
+ return geojson.geometry.type;
1488
+ }
1489
+ return geojson.type;
1490
+ }
1491
+
1492
+ // src/data/navigate/steps/path/index.ts
1493
+ var import_difference = __toESM(require("@turf/difference"));
1494
+ var import_envelope = __toESM(require("@turf/envelope"));
1495
+ var import_boolean_overlap = __toESM(require("@turf/boolean-overlap"));
1496
+ var import_boolean_intersects = __toESM(require("@turf/boolean-intersects"));
1497
+
1498
+ // ../../node_modules/@turf/meta/dist/esm/index.js
1499
+ function coordEach(geojson, callback, excludeWrapCoord) {
1500
+ if (geojson === null) return;
1501
+ var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
1502
+ for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
1503
+ geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
1504
+ isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
1505
+ stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
1506
+ for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
1507
+ var multiFeatureIndex = 0;
1508
+ var geometryIndex = 0;
1509
+ geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
1510
+ if (geometry === null) continue;
1511
+ coords = geometry.coordinates;
1512
+ var geomType = geometry.type;
1513
+ wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
1514
+ switch (geomType) {
1515
+ case null:
1516
+ break;
1517
+ case "Point":
1518
+ if (callback(
1519
+ coords,
1520
+ coordIndex,
1521
+ featureIndex,
1522
+ multiFeatureIndex,
1523
+ geometryIndex
1524
+ ) === false)
1525
+ return false;
1526
+ coordIndex++;
1527
+ multiFeatureIndex++;
1528
+ break;
1529
+ case "LineString":
1530
+ case "MultiPoint":
1531
+ for (j = 0; j < coords.length; j++) {
1532
+ if (callback(
1533
+ coords[j],
1534
+ coordIndex,
1535
+ featureIndex,
1536
+ multiFeatureIndex,
1537
+ geometryIndex
1538
+ ) === false)
1539
+ return false;
1540
+ coordIndex++;
1541
+ if (geomType === "MultiPoint") multiFeatureIndex++;
1542
+ }
1543
+ if (geomType === "LineString") multiFeatureIndex++;
1544
+ break;
1545
+ case "Polygon":
1546
+ case "MultiLineString":
1547
+ for (j = 0; j < coords.length; j++) {
1548
+ for (k = 0; k < coords[j].length - wrapShrink; k++) {
1549
+ if (callback(
1550
+ coords[j][k],
1551
+ coordIndex,
1552
+ featureIndex,
1553
+ multiFeatureIndex,
1554
+ geometryIndex
1555
+ ) === false)
1556
+ return false;
1557
+ coordIndex++;
1558
+ }
1559
+ if (geomType === "MultiLineString") multiFeatureIndex++;
1560
+ if (geomType === "Polygon") geometryIndex++;
1561
+ }
1562
+ if (geomType === "Polygon") multiFeatureIndex++;
1563
+ break;
1564
+ case "MultiPolygon":
1565
+ for (j = 0; j < coords.length; j++) {
1566
+ geometryIndex = 0;
1567
+ for (k = 0; k < coords[j].length; k++) {
1568
+ for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
1569
+ if (callback(
1570
+ coords[j][k][l],
1571
+ coordIndex,
1572
+ featureIndex,
1573
+ multiFeatureIndex,
1574
+ geometryIndex
1575
+ ) === false)
1576
+ return false;
1577
+ coordIndex++;
1578
+ }
1579
+ geometryIndex++;
1580
+ }
1581
+ multiFeatureIndex++;
1582
+ }
1583
+ break;
1584
+ case "GeometryCollection":
1585
+ for (j = 0; j < geometry.geometries.length; j++)
1586
+ if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
1587
+ return false;
1588
+ break;
1589
+ default:
1590
+ throw new Error("Unknown Geometry Type");
1591
+ }
1592
+ }
1593
+ }
1594
+ }
1595
+
1596
+ // ../../node_modules/@turf/bbox/dist/esm/index.js
1597
+ function bbox(geojson, options = {}) {
1598
+ if (geojson.bbox != null && true !== options.recompute) {
1599
+ return geojson.bbox;
1600
+ }
1601
+ const result = [Infinity, Infinity, -Infinity, -Infinity];
1602
+ coordEach(geojson, (coord) => {
1603
+ if (result[0] > coord[0]) {
1604
+ result[0] = coord[0];
1605
+ }
1606
+ if (result[1] > coord[1]) {
1607
+ result[1] = coord[1];
1608
+ }
1609
+ if (result[2] < coord[0]) {
1610
+ result[2] = coord[0];
1611
+ }
1612
+ if (result[3] < coord[1]) {
1613
+ result[3] = coord[1];
1614
+ }
1615
+ });
1616
+ return result;
1617
+ }
1618
+ var index_default = bbox;
1619
+
1620
+ // src/data/navigate/steps/path/turf/shortestPath.ts
1621
+ var import_boolean_point_in_polygon3 = __toESM(require("@turf/boolean-point-in-polygon"));
1622
+ var import_distance4 = __toESM(require("@turf/distance"));
1623
+ var import_transform_scale = __toESM(require("@turf/transform-scale"));
1624
+ var import_union = __toESM(require("@turf/union"));
1625
+ var import_bbox_polygon = __toESM(require("@turf/bbox-polygon"));
1626
+ var import_clean_coords = require("@turf/clean-coords");
1627
+ var import_pathfinding = __toESM(require("pathfinding"));
1628
+ var import_set3 = __toESM(require("lodash/set"));
1629
+
1630
+ // src/data/navigate/steps/path/turf/stringPull.ts
1631
+ function stringPull(grid, path) {
1632
+ const isWalkable = (x, y) => grid.isInside(x, y) && grid.isWalkableAt(x, y);
1633
+ function hasLOS(a, b) {
1634
+ let x0 = a[0], y0 = a[1];
1635
+ const x1 = b[0], y1 = b[1];
1636
+ if (!isWalkable(x0, y0) || !isWalkable(x1, y1)) return false;
1637
+ const dx = Math.abs(x1 - x0);
1638
+ const dy = Math.abs(y1 - y0);
1639
+ const sx = x0 < x1 ? 1 : -1;
1640
+ const sy = y0 < y1 ? 1 : -1;
1641
+ let err = dx - dy;
1642
+ while (true) {
1643
+ if (!isWalkable(x0, y0)) return false;
1644
+ if (x0 === x1 && y0 === y1) break;
1645
+ const e2 = err * 2;
1646
+ let nx = x0;
1647
+ let ny = y0;
1648
+ let movedX = false;
1649
+ let movedY = false;
1650
+ if (e2 > -dy) {
1651
+ err -= dy;
1652
+ nx += sx;
1653
+ movedX = true;
1654
+ }
1655
+ if (e2 < dx) {
1656
+ err += dx;
1657
+ ny += sy;
1658
+ movedY = true;
1659
+ }
1660
+ if (movedX && movedY) {
1661
+ if (!isWalkable(nx, y0) || !isWalkable(x0, ny)) return false;
1662
+ }
1663
+ x0 = nx;
1664
+ y0 = ny;
1665
+ }
1666
+ return true;
1667
+ }
1668
+ if (path.length <= 2) return path;
1669
+ const out = [path[0]];
1670
+ let i = 0;
1671
+ while (i < path.length - 1) {
1672
+ let best = i + 1;
1673
+ for (let j = i + 2; j < path.length; j++) {
1674
+ if (hasLOS(path[i], path[j])) best = j;
1675
+ else break;
1676
+ }
1677
+ out.push(path[best]);
1678
+ i = best;
1679
+ }
1680
+ return out;
1681
+ }
1682
+
1683
+ // src/data/navigate/steps/path/turf/pruneSmallAngle.ts
1684
+ function pruneSmallAngles(path, minDeg = 10) {
1685
+ if (path.length <= 2) return path;
1686
+ const out = [path[0]];
1687
+ for (let i = 1; i < path.length - 1; i++) {
1688
+ const a = out.at(-1);
1689
+ const b = path[i];
1690
+ const c = path[i + 1];
1691
+ const abx = b[0] - a[0], aby = b[1] - a[1];
1692
+ const bcx = c[0] - b[0], bcy = c[1] - b[1];
1693
+ const dot = abx * bcx + aby * bcy;
1694
+ const ab = Math.hypot(abx, aby);
1695
+ const bc = Math.hypot(bcx, bcy);
1696
+ const angle = Math.acos(dot / (ab * bc)) * 180 / Math.PI;
1697
+ if (angle > minDeg) out.push(b);
1698
+ }
1699
+ out.push(path.at(-1));
1700
+ return out;
1701
+ }
1702
+
1703
+ // src/data/navigate/steps/path/turf/pruneShortSegments.ts
1704
+ function pruneShortSegments(path, minLen = 5) {
1705
+ const out = [path[0]];
1706
+ for (let i = 1; i < path.length; i++) {
1707
+ const [x0, y0] = out.at(-1);
1708
+ const [x1, y1] = path[i];
1709
+ if (Math.hypot(x1 - x0, y1 - y0) >= minLen) {
1710
+ out.push(path[i]);
1711
+ }
1712
+ }
1713
+ return out;
1714
+ }
1715
+
1716
+ // src/data/navigate/steps/path/turf/clearance.ts
1717
+ function buildClearanceGrid(matrix) {
1718
+ const h = matrix.length;
1719
+ const w = matrix[0].length;
1720
+ const INF = 1e9;
1721
+ const dist = Array.from({ length: h }, () => Array(w).fill(INF));
1722
+ const q = [];
1723
+ for (let y = 0; y < h; y++) {
1724
+ for (let x = 0; x < w; x++) {
1725
+ if (matrix[y][x] === 1) {
1726
+ dist[y][x] = 0;
1727
+ q.push([x, y]);
1728
+ }
1729
+ }
1730
+ }
1731
+ const dirs = [
1732
+ [1, 0],
1733
+ [-1, 0],
1734
+ [0, 1],
1735
+ [0, -1],
1736
+ [1, 1],
1737
+ [1, -1],
1738
+ [-1, 1],
1739
+ [-1, -1]
1740
+ ];
1741
+ let qi = 0;
1742
+ while (qi < q.length) {
1743
+ const [x, y] = q[qi++];
1744
+ const d0 = dist[y][x];
1745
+ for (const [dx, dy] of dirs) {
1746
+ const nx = x + dx, ny = y + dy;
1747
+ if (nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
1748
+ const nd = d0 + 1;
1749
+ if (nd < dist[ny][nx]) {
1750
+ dist[ny][nx] = nd;
1751
+ q.push([nx, ny]);
1752
+ }
1753
+ }
1754
+ }
1755
+ return dist;
1756
+ }
1757
+ function snapPointToClearancePeak(p, clearance, isWalkableCell, radius = 4) {
1758
+ const [px, py] = p;
1759
+ let best = p;
1760
+ let bestScore = clearance[py]?.[px] ?? -Infinity;
1761
+ for (let dy = -radius; dy <= radius; dy++) {
1762
+ for (let dx = -radius; dx <= radius; dx++) {
1763
+ const x = px + dx;
1764
+ const y = py + dy;
1765
+ if (!isWalkableCell(x, y)) continue;
1766
+ const score = clearance[y][x];
1767
+ const penalty = Math.hypot(dx, dy) * 5e-3;
1768
+ const finalScore = score - penalty;
1769
+ if (finalScore > bestScore) {
1770
+ bestScore = finalScore;
1771
+ best = [x, y];
1772
+ }
1773
+ }
1774
+ }
1775
+ return best;
1776
+ }
1777
+ function centerlineSnapPath(path, clearance, isWalkableCell, radius = 4) {
1778
+ const snapped = path.map((p) => snapPointToClearancePeak(p, clearance, isWalkableCell, radius));
1779
+ return snapped;
1780
+ }
1781
+
1782
+ // src/data/navigate/steps/path/turf/shortestPath.ts
1783
+ function shortestPath(start, end, options) {
1784
+ options = options || {};
1785
+ if (!isObject(options)) throw new Error("options is invalid");
1786
+ let resolution = options.resolution;
1787
+ const smoothenPath = options.smoothenPath;
1788
+ let obstacles = options.obstacles || featureCollection([]);
1789
+ if (!start) throw new Error("start is required");
1790
+ if (!end) throw new Error("end is required");
1791
+ if (resolution && !isNumber(resolution) || resolution <= 0)
1792
+ throw new Error("options.resolution must be a number, greater than 0");
1793
+ const startCoord = getCoord(start);
1794
+ const endCoord = getCoord(end);
1795
+ start = point(startCoord);
1796
+ end = point(endCoord);
1797
+ switch (getType(obstacles)) {
1798
+ case "FeatureCollection":
1799
+ if (obstacles.features.length === 0)
1800
+ return lineString([startCoord, endCoord]);
1801
+ break;
1802
+ case "Polygon":
1803
+ obstacles = featureCollection([feature(getGeom(obstacles))]);
1804
+ break;
1805
+ default:
1806
+ throw new Error("invalid obstacles");
1807
+ }
1808
+ const collection = obstacles;
1809
+ collection.features.push(start, end);
1810
+ const box = index_default((0, import_transform_scale.default)((0, import_bbox_polygon.default)(index_default(collection)), 1.15));
1811
+ if (!resolution) {
1812
+ const width = (0, import_distance4.default)([box[0], box[1]], [box[2], box[1]], options);
1813
+ resolution = width / 100;
1814
+ }
1815
+ collection.features.pop();
1816
+ collection.features.pop();
1817
+ const [west, south, east, north] = box;
1818
+ const xFraction = resolution / (0, import_distance4.default)([west, south], [east, south], options);
1819
+ const cellWidth = xFraction * (east - west);
1820
+ const yFraction = resolution / (0, import_distance4.default)([west, south], [west, north], options);
1821
+ const cellHeight = yFraction * (north - south);
1822
+ const bboxHorizontalSide = east - west;
1823
+ const bboxVerticalSide = north - south;
1824
+ const columns = Math.floor(bboxHorizontalSide / cellWidth);
1825
+ const rows = Math.floor(bboxVerticalSide / cellHeight);
1826
+ const deltaX = (bboxHorizontalSide - columns * cellWidth) / 2;
1827
+ const deltaY = (bboxVerticalSide - rows * cellHeight) / 2;
1828
+ let closestToStart = null, closestToEnd = null, minDistStart = Infinity, minDistEnd = Infinity, currentY = north - deltaY, currentX = west + deltaX, row = 0, column = 0, distStart, distEnd, pt, isInsideObstacle;
1829
+ const roundLoopY = Math.ceil((currentY - south) / cellHeight);
1830
+ const roundLoopX = Math.ceil((east - currentX) / cellWidth);
1831
+ let totalRounds = roundLoopX * roundLoopY;
1832
+ const pointMatrix = [];
1833
+ const matrix = [];
1834
+ const obstacleTotal = collection.features.length;
1835
+ const obstacleFeatures = collection.features;
1836
+ let combinedObstacle = obstacleFeatures[0];
1837
+ let obstacleIndex = 0;
1838
+ for (obstacleIndex = 0; obstacleIndex < obstacleTotal; obstacleIndex++) {
1839
+ const nextObstacleFeature = obstacleFeatures[obstacleIndex + 1];
1840
+ if (!nextObstacleFeature) continue;
1841
+ try {
1842
+ combinedObstacle = (0, import_union.default)(
1843
+ featureCollection([combinedObstacle, nextObstacleFeature])
1844
+ );
1845
+ } catch (e) {
1846
+ console.log(e);
1847
+ }
1848
+ }
1849
+ while (totalRounds--) {
1850
+ pt = point([currentX, currentY]);
1851
+ isInsideObstacle = (0, import_boolean_point_in_polygon3.default)(pt, combinedObstacle);
1852
+ (0, import_set3.default)(matrix, `[${row}][${column}]`, isInsideObstacle ? 1 : 0);
1853
+ (0, import_set3.default)(pointMatrix, `[${row}][${column}]`, `${currentX}|${currentY}`);
1854
+ distStart = (0, import_distance4.default)(pt, start);
1855
+ if (!isInsideObstacle && distStart < minDistStart) {
1856
+ minDistStart = distStart;
1857
+ closestToStart = { x: column, y: row };
1858
+ }
1859
+ distEnd = (0, import_distance4.default)(pt, end);
1860
+ if (!isInsideObstacle && distEnd < minDistEnd) {
1861
+ minDistEnd = distEnd;
1862
+ closestToEnd = { x: column, y: row };
1863
+ }
1864
+ if (column < roundLoopX) {
1865
+ currentX += cellWidth;
1866
+ column++;
1867
+ continue;
1868
+ }
1869
+ if (row < roundLoopY) {
1870
+ currentY -= cellHeight;
1871
+ currentX = west + deltaX;
1872
+ column = 0;
1873
+ row++;
1874
+ }
1875
+ }
1876
+ const finder = new import_pathfinding.default.AStarFinder({
1877
+ allowDiagonal: true,
1878
+ dontCrossCorners: true,
1879
+ heuristic: import_pathfinding.default.Heuristic.euclidean
1880
+ });
1881
+ const grid = new import_pathfinding.default.Grid(matrix);
1882
+ const startOnMatrix = [closestToStart.x, closestToStart.y];
1883
+ const endOnMatrix = [closestToEnd.x, closestToEnd.y];
1884
+ let result = finder.findPath(...startOnMatrix, ...endOnMatrix, grid);
1885
+ if (result.length > 0) {
1886
+ result = stringPull(grid, result);
1887
+ const clearanceGrid = buildClearanceGrid(matrix);
1888
+ const isWalkable = (x, y) => grid.isInside(x, y) && grid.isWalkableAt(x, y);
1889
+ result = centerlineSnapPath(result, clearanceGrid, isWalkable);
1890
+ result = stringPull(grid, result);
1891
+ result = pruneSmallAngles(result);
1892
+ result = pruneShortSegments(result);
1893
+ }
1894
+ result.pop();
1895
+ result.shift();
1896
+ const path = [startCoord];
1897
+ result.forEach((coord) => {
1898
+ const coords = pointMatrix[coord[1]][coord[0]].split("|");
1899
+ path.push([+coords[0], +coords[1]]);
1900
+ });
1901
+ path.push(endCoord);
1902
+ return (0, import_clean_coords.cleanCoords)(lineString(path));
1903
+ }
1904
+ var shortestPath_default = shortestPath;
1905
+
1906
+ // src/data/navigate/steps/path/index.ts
1907
+ var createStepPathUtils = (options) => {
1908
+ const resolution = options.resolution ?? 88e-5;
1909
+ const { units = [], kiosks = [], fixtures = [] } = options.data;
1910
+ const possibleObstacleFeatures = [...units, ...kiosks, ...fixtures];
1911
+ const filterObstaclesByOrdinal = (levelId) => {
1912
+ return possibleObstacleFeatures.filter(({ feature_type, properties, geometry }) => {
1913
+ return properties.level_id === levelId && ["Polygon", "MultiPolygon"].includes(geometry.type) && (OBSTACLE_FEATURE_TYPES.includes(feature_type) || "category" in properties && OBSTACLE_CATEGORIES.includes(properties.category));
1914
+ });
1915
+ };
1916
+ const findObstaclesFromWalkway = (intermediaryUnit, exceptionIds = []) => {
1917
+ const result = featureCollection([]);
1918
+ if (!intermediaryUnit) return result;
1919
+ const walkwayLevelId = intermediaryUnit.properties.level_id;
1920
+ const obstacleOnLevel = filterObstaclesByOrdinal(walkwayLevelId).filter(
1921
+ (obstacle) => !exceptionIds.includes(obstacle.id)
1922
+ );
1923
+ const relatedObstacleWithIntermediary = obstacleOnLevel.reduce(
1924
+ (obstacles, feature2) => {
1925
+ if (
1926
+ // Prevent detecting itself as an obstacle
1927
+ // Ex. Unable to draw a line to amenity located with in a room as room is also consider as obstacle
1928
+ feature2.id !== intermediaryUnit.id && ((0, import_boolean_overlap.default)(intermediaryUnit, feature2) || (0, import_boolean_intersects.default)(intermediaryUnit, feature2))
1929
+ ) {
1930
+ const polygons = getType(feature2) === "Polygon" ? [polygon(feature2.geometry.coordinates, { id: feature2.id })] : feature2.geometry.coordinates.map((ring) => polygon(ring, { id: feature2.id }));
1931
+ obstacles.push(...polygons);
1932
+ }
1933
+ return obstacles;
1934
+ },
1935
+ []
1936
+ );
1937
+ const intermediaryExtends = (0, import_envelope.default)(intermediaryUnit);
1938
+ const walkwayPerimeter = (0, import_difference.default)(
1939
+ featureCollection([intermediaryExtends, intermediaryUnit])
1940
+ );
1941
+ result.features.push(...relatedObstacleWithIntermediary, walkwayPerimeter);
1942
+ return result;
1943
+ };
1944
+ const findPathOnArea = (originPoint, destinationPoint, options2) => {
1945
+ const { obstacles = featureCollection([]), resolution: resolution2, properties } = options2 || {};
1946
+ const stepPath = shortestPath_default(originPoint, destinationPoint, {
1947
+ obstacles,
1948
+ smoothenPath: false,
1949
+ resolution: resolution2
1950
+ });
1951
+ stepPath.properties = properties;
1952
+ return stepPath;
1953
+ };
1954
+ const findStepPath = (from, to, intermediaries) => {
1955
+ const t0 = performance.now();
1956
+ const relatedWalkablePlatform = intermediaries.find(
1957
+ (feature2) => WALKABLE_CATEGORY.includes(feature2.properties.category)
1958
+ );
1959
+ const exceptionFeatureIds = [];
1960
+ const obstacles = findObstaclesFromWalkway(
1961
+ relatedWalkablePlatform,
1962
+ import_lodash12.default.compact(exceptionFeatureIds)
1963
+ );
1964
+ const line = findPathOnArea(from, to, {
1965
+ resolution,
1966
+ obstacles
1967
+ });
1968
+ return line.geometry.coordinates;
1969
+ };
1970
+ return {
1971
+ findStepPath
1972
+ };
1973
+ };
1974
+
1975
+ // src/data/navigate/steps/utils/combineWalkwaySteps.ts
1976
+ var import_uniq = __toESM(require("lodash/uniq"));
1977
+ var combineWalkwaySteps = (steps) => {
1978
+ let result = [];
1979
+ for (let i = 0; i < steps.length; i++) {
1980
+ const thisStep = steps[i];
1981
+ if (i === steps.length - 1) {
1982
+ result.push(thisStep);
1983
+ continue;
1984
+ }
1985
+ const nextStep = steps[i + 1];
1986
+ if (thisStep.intermediaryCategory === "walkway" && nextStep.intermediaryCategory === "walkway" && thisStep.from.source.type === "opening" && nextStep.from.source.type === "opening") {
1987
+ result.push({
1988
+ from: thisStep.from,
1989
+ to: nextStep.to,
1990
+ levelIds: (0, import_uniq.default)([...thisStep.levelIds, ...nextStep.levelIds]),
1991
+ ordinals: (0, import_uniq.default)([...thisStep.ordinals, ...nextStep.ordinals]),
1992
+ intermediaryCategory: "walkway",
1993
+ description: nextStep.description,
1994
+ path: [
1995
+ ...thisStep.path,
1996
+ ...nextStep.path
1997
+ ]
1998
+ });
1999
+ i++;
2000
+ } else {
2001
+ result.push(thisStep);
2002
+ }
2003
+ }
2004
+ return result;
2005
+ };
2006
+
2007
+ // src/data/navigate/steps/createStepUtils.ts
2008
+ var createStepUtils = (options) => {
2009
+ const { data: { units, relationships }, findByIdSync } = options;
2010
+ const stepPathUtils = createStepPathUtils({ ...options, resolution: 88e-5 });
2011
+ const findUnitBetweenOpenings = (originId, destinationId) => {
2012
+ const origin = findByIdSync(originId);
2013
+ const destination = findByIdSync(destinationId);
2014
+ const matchedOne = relationships.find((rel) => rel.properties.intermediary.map((int) => int.id).includes(origin.id));
2015
+ const matchOneUnits = matchedOne ? [matchedOne.properties.origin, matchedOne.properties.destination] : [];
2016
+ const matchedTwo = relationships.find((rel) => rel.properties.intermediary.map((int) => int.id).includes(destination.id));
2017
+ const matchTwoUnits = matchedTwo ? [matchedTwo.properties.origin, matchedTwo.properties.destination] : [];
2018
+ const unitIds = (0, import_intersectionBy.default)(matchOneUnits, matchTwoUnits, "id");
2019
+ return unitIds.map(({ id }) => findByIdSync(id));
2020
+ };
2021
+ const findHorizontalIntermediary = (from, to) => {
2022
+ if (from.source.type !== "opening") {
2023
+ const unit = findContainingUnitAtPoint(from.point, from.levelId, units);
2024
+ return unit ? [unit] : [];
2025
+ }
2026
+ if (to.source.type !== "opening") {
2027
+ const unit = findContainingUnitAtPoint(to.point, to.levelId, units);
2028
+ return unit ? [unit] : [];
2029
+ }
2030
+ return findUnitBetweenOpenings(from.source.id, to.source.id);
2031
+ };
2032
+ const findVerticalIntermediary = (from, to) => {
2033
+ const firstOpeningId = from.source.id;
2034
+ const secondOpeningId = to.source.id;
2035
+ const relationship = relationships.find((rel) => {
2036
+ return rel.properties.origin?.id === firstOpeningId && rel.properties.destination?.id === secondOpeningId || rel.properties.origin?.id === secondOpeningId && rel.properties.destination?.id === firstOpeningId;
2037
+ });
2038
+ const intermediaryTypeAndId = relationship.properties.intermediary;
2039
+ return intermediaryTypeAndId.map(({ id }) => findByIdSync(id));
2040
+ };
2041
+ const formatCategoryLabel = (category) => {
2042
+ return (0, import_lodash13.capitalize)(category);
2043
+ };
2044
+ const getNextStepIntermediary = (from, to, intermediary) => {
2045
+ if (to.type === "end") return to.name;
2046
+ const intermediaryIds = intermediary.map((int) => int.id);
2047
+ const relationship = relationships.find((rel) => rel.properties.intermediary.map((int) => int.id).includes(to.source.id));
2048
+ if (!relationship) return to.name;
2049
+ const candidates = [relationship.properties.origin.id, relationship.properties.destination.id];
2050
+ const nextUnitId = candidates.filter((id) => !intermediaryIds.includes(id))[0];
2051
+ if (!nextUnitId) return to.name;
2052
+ const nextUnit = findByIdSync(nextUnitId);
2053
+ return { en: formatCategoryLabel(`${nextUnit.properties.category}`) };
2054
+ };
2055
+ const createHorizontalStep = (from, to) => {
2056
+ const intermediary = findHorizontalIntermediary(from, to);
2057
+ const intermediaryCategories = intermediary.map((unit) => unit.properties.category);
2058
+ const intermediaryCategory = intermediaryCategories.length > 0 ? intermediaryCategories[0] : "unspecified";
2059
+ const toward = getNextStepIntermediary(from, to, intermediary);
2060
+ const landmark = to.hint?.kind === "landmark" ? to.hint.name : null;
2061
+ const path = stepPathUtils.findStepPath(from.point, to.point, intermediary);
2062
+ const step = {
2063
+ from,
2064
+ to,
2065
+ levelIds: [from.levelId],
2066
+ ordinals: [from.ordinal],
2067
+ intermediaryCategory,
2068
+ description: describeHorizontalStep(intermediaryCategory, toward, landmark),
2069
+ path: path.map((coord) => [...coord, from.ordinal * 9])
2070
+ };
2071
+ return step;
2072
+ };
2073
+ const createVerticalStep = (from, to) => {
2074
+ const intermediary = findVerticalIntermediary(from, to);
2075
+ const intermediaryCategories = intermediary.map((unit) => unit.properties.category);
2076
+ const intermediaryCategory = intermediaryCategories.length > 0 ? intermediaryCategories[0] : "unspecified";
2077
+ const fromLevel = findByIdSync(from.levelId);
2078
+ const toLevel = findByIdSync(to.levelId);
2079
+ return {
2080
+ from,
2081
+ to,
2082
+ levelIds: [from.levelId, to.levelId],
2083
+ ordinals: [from.ordinal, to.ordinal],
2084
+ intermediaryCategory,
2085
+ description: describeVerticalStep(fromLevel, toLevel, intermediaryCategory),
2086
+ path: [
2087
+ [...from.point, from.ordinal * 9],
2088
+ [...to.point, to.ordinal * 9]
2089
+ ]
2090
+ };
2091
+ };
2092
+ const isVertical = (from, to) => {
2093
+ const fromLevel = findByIdSync(from.levelId);
2094
+ const toLevel = findByIdSync(to.levelId);
2095
+ return !!fromLevel && !!toLevel && fromLevel.properties.ordinal !== toLevel.properties.ordinal;
2096
+ };
2097
+ const toSteps = (waypoints) => {
2098
+ let steps = [];
2099
+ const t0_allSteps = performance.now();
2100
+ for (let i = 0; i < waypoints.length - 1; i++) {
2101
+ const from = waypoints[i];
2102
+ const to = waypoints[i + 1];
2103
+ const t0 = performance.now();
2104
+ const step = isVertical(from, to) ? createVerticalStep(from, to) : createHorizontalStep(from, to);
2105
+ steps.push(step);
2106
+ const t1 = performance.now();
2107
+ trace("nav", ` \u2502 \u251C\u2500 #${i} ${from.id.padEnd(25)} \u2192 ${`(${step.intermediaryCategory})`.padEnd(12)} \u2192 ${to.id}`, t1 - t0);
2108
+ trace("nav", ` \u2502 \u2502 ${step.description.text}`, void 0, "#bada55");
2109
+ }
2110
+ const simplifySteps = combineWalkwaySteps(steps);
2111
+ const t1_allSteps = performance.now();
2112
+ trace("nav", " \u2502 \u2514\u2500 Total ", t1_allSteps - t0_allSteps);
2113
+ return simplifySteps;
2114
+ };
2115
+ return {
2116
+ toSteps
2117
+ };
2118
+ };
2119
+
2120
+ // src/data/navigate/utils/timeDistance.ts
2121
+ var import_length = __toESM(require("@turf/length"));
2122
+ var WALKING_SPEED = 1.4;
2123
+ var calculatePathLength = (feature2) => (0, import_length.default)(feature2, { units: "kilometers" }) * 1e3;
2124
+ var calculateTravelingDuration = (distance5) => {
2125
+ const duration = distance5 / WALKING_SPEED;
2126
+ const minutes = Math.round(duration / 60);
2127
+ return minutes > 0 ? minutes : 1;
2128
+ };
2129
+ var calculateTotalDistance = (steps = []) => {
2130
+ return steps.reduce((acc, { path }) => acc + calculatePathLength(lineString(path)), 0);
2131
+ };
2132
+ var calculateRoundedDistance = (distance5) => {
2133
+ return Math.round(distance5 - distance5 % 25);
2134
+ };
2135
+
2136
+ // src/data/navigate/type-guard.ts
2137
+ function isCoordinateOrdinalString(id) {
2138
+ return /^-?\d+(\.\d+)?,-?\d+(\.\d+)?,-?\d+(\.\d+)?o$/.test(id);
2139
+ }
2140
+
2141
+ // src/data/navigate/utils/createFindByIdSync.ts
2142
+ var createFindByIdSync = (data) => {
2143
+ const { amenities = [], anchors = [], fixtures = [], levels = [], kiosks = [], relationships = [], occupants = [], openings = [], units } = data;
2144
+ const featureById = /* @__PURE__ */ new Map();
2145
+ const entries = [
2146
+ ...amenities,
2147
+ ...anchors,
2148
+ ...fixtures,
2149
+ ...levels,
2150
+ ...kiosks,
2151
+ ...relationships,
2152
+ ...occupants,
2153
+ ...openings,
2154
+ ...units
2155
+ ];
2156
+ for (const f of entries) featureById.set(f.id, f);
2157
+ const findByIdSync = (id) => {
2158
+ return featureById.get(id);
2159
+ };
2160
+ return { findByIdSync };
2161
+ };
2162
+
2163
+ // src/data/navigate/waypoint/createWaypointUtils.ts
2164
+ var import_center9 = require("@turf/center");
2165
+
2166
+ // src/data/navigate/waypoint/extractEndWaypoint.ts
2167
+ var import_center6 = require("@turf/center");
2168
+
2169
+ // src/data/navigate/waypoint/featureIdGuard.ts
2170
+ var isOccupant = (id) => !!id && id.startsWith("occupant-");
2171
+ var isUnit = (id) => !!id && id.startsWith("unit-");
2172
+ var isKiosk = (id) => !!id && id.startsWith("kiosk-");
2173
+ var isOpening = (id) => !!id && id.startsWith("opening-");
2174
+
2175
+ // src/data/navigate/waypoint/extractEndWaypoint.ts
2176
+ var extractEndPoint = (path, options) => {
2177
+ const { findByIdSync } = options;
2178
+ const [c, b, a] = path.slice(-3);
2179
+ if (isOccupant(a) && isUnit(b) && isOpening(c)) {
2180
+ const occ = findByIdSync(a);
2181
+ const opening = findByIdSync(c);
2182
+ const level = findByIdSync(opening.properties.level_id);
2183
+ return [
2184
+ {
2185
+ id: occ.id,
2186
+ type: "end",
2187
+ name: occ.properties.name,
2188
+ point: (0, import_center6.center)(opening).geometry.coordinates,
2189
+ levelId: opening.properties.level_id,
2190
+ ordinal: level.properties.ordinal,
2191
+ source: { type: "opening", id: opening.id }
2192
+ },
2193
+ path.slice(0, -3)
2194
+ ];
2195
+ }
2196
+ if (isOccupant(a) && isKiosk(b)) {
2197
+ const occ = findByIdSync(a);
2198
+ const kiosk = findByIdSync(b);
2199
+ const level = findByIdSync(kiosk.properties.level_id);
2200
+ return [
2201
+ {
2202
+ id: occ.id,
2203
+ type: "end",
2204
+ name: occ.properties.name,
2205
+ point: (0, import_center6.center)(kiosk).geometry.coordinates,
2206
+ levelId: kiosk.properties.level_id,
2207
+ ordinal: level.properties.ordinal,
2208
+ source: { type: "kiosk", id: kiosk.id }
2209
+ },
2210
+ path.slice(0, -2)
2211
+ ];
2212
+ }
2213
+ if (isCoordinateOrdinalString(a) && isOpening(b)) {
2214
+ const [lat, lng, ordinal] = parseOrdinalCoordinate(a);
2215
+ const opening = findByIdSync(b);
2216
+ return [
2217
+ {
2218
+ id: a,
2219
+ type: "end",
2220
+ name: { en: a },
2221
+ point: [lng, lat],
2222
+ levelId: opening.properties.level_id,
2223
+ ordinal,
2224
+ source: { type: "coordinate", raw: a }
2225
+ },
2226
+ path.slice(0, -1)
2227
+ ];
2228
+ }
2229
+ return [null, path];
2230
+ };
2231
+
2232
+ // src/data/navigate/waypoint/extractStartWaypoint.ts
2233
+ var import_center7 = require("@turf/center");
2234
+ var extractStartPoint = (path, options) => {
2235
+ const { findByIdSync } = options;
2236
+ const [a, b, c] = path;
2237
+ if (isOccupant(a) && isUnit(b) && isOpening(c)) {
2238
+ const occ = findByIdSync(a);
2239
+ const opening = findByIdSync(c);
2240
+ const level = findByIdSync(opening.properties.level_id);
2241
+ return [
2242
+ {
2243
+ id: occ.id,
2244
+ type: "start",
2245
+ name: occ.properties.name,
2246
+ point: (0, import_center7.center)(opening).geometry.coordinates,
2247
+ levelId: opening.properties.level_id,
2248
+ ordinal: level.properties.ordinal,
2249
+ source: { type: "opening", id: opening.id }
2250
+ },
2251
+ path.slice(3)
2252
+ ];
2253
+ }
2254
+ if (isOccupant(a) && isKiosk(b)) {
2255
+ const occ = findByIdSync(a);
2256
+ const kiosk = findByIdSync(b);
2257
+ const level = findByIdSync(kiosk.properties.level_id);
2258
+ return [
2259
+ {
2260
+ id: occ.id,
2261
+ type: "start",
2262
+ name: occ.properties.name,
2263
+ point: (0, import_center7.center)(kiosk).geometry.coordinates,
2264
+ levelId: kiosk.properties.level_id,
2265
+ ordinal: level.properties.ordinal,
2266
+ source: { type: "kiosk", id: kiosk.id }
2267
+ },
2268
+ path.slice(2)
2269
+ ];
2270
+ }
2271
+ if (isCoordinateOrdinalString(a) && isOpening(b)) {
2272
+ const [lat, lng, ordinal] = parseOrdinalCoordinate(a);
2273
+ const opening = findByIdSync(b);
2274
+ return [
2275
+ {
2276
+ id: a,
2277
+ type: "start",
2278
+ name: { en: a },
2279
+ point: [lng, lat],
2280
+ levelId: opening.properties.level_id,
2281
+ ordinal,
2282
+ source: { type: "coordinate", raw: a }
2283
+ },
2284
+ path.slice(1)
2285
+ ];
2286
+ }
2287
+ return [null, path];
2288
+ };
2289
+
2290
+ // src/data/navigate/landmark/createLandmarkUtils.ts
2291
+ var import_center8 = require("@turf/center");
2292
+ var import_distance5 = __toESM(require("@turf/distance"));
2293
+ var NEARBY_DISTANCE = 30;
2294
+ var createLandmarkUtils = (options) => {
2295
+ const { data, findByIdSync } = options;
2296
+ const { occupants = [] } = data;
2297
+ const occupantToLandmark = (occupant) => {
2298
+ const locationType = occupant.properties.unit_id ? "unit" : "kiosk";
2299
+ const locationId = locationType === "unit" ? occupant.properties.unit_id : occupant.properties.kiosk_id;
2300
+ const location = locationType === "unit" ? findByIdSync(locationId) : findByIdSync(locationId);
2301
+ const level = findByIdSync(location.properties.level_id);
2302
+ return {
2303
+ name: occupant.properties.name,
2304
+ point: (0, import_center8.center)(location.geometry).geometry.coordinates,
2305
+ level_id: location.properties.level_id,
2306
+ is_priority: occupant.properties.is_landmark,
2307
+ ordinal: level.properties.ordinal
2308
+ };
2309
+ };
2310
+ const landmarks = [
2311
+ ...occupants.map(occupantToLandmark)
2312
+ ];
2313
+ const findNearbyLandmarks = (point2, levelId) => {
2314
+ if (point2 === null || levelId === null) return [];
2315
+ return landmarks.map((landmark) => {
2316
+ const landmarkAndDistance = {
2317
+ landmark,
2318
+ d: (0, import_distance5.default)(point2, landmark.point, { units: "meters" })
2319
+ };
2320
+ return landmarkAndDistance;
2321
+ }).filter(({ landmark, d }) => d <= NEARBY_DISTANCE && landmark.level_id === levelId).sort((a, b) => {
2322
+ const aPriority = a.landmark.is_priority ? 0 : 1;
2323
+ const bPriority = b.landmark.is_priority ? 0 : 1;
2324
+ if (aPriority !== bPriority) return aPriority - bPriority;
2325
+ return a.d - b.d;
2326
+ }).map(({ landmark }) => landmark);
2327
+ };
2328
+ const findNearestLandmark = (point2, levelId) => {
2329
+ const nearbyLandmarks = findNearbyLandmarks(point2, levelId);
2330
+ const nearestLandmark = nearbyLandmarks.length > 0 ? nearbyLandmarks[0] : null;
2331
+ return nearestLandmark;
2332
+ };
2333
+ return { findNearbyLandmarks, findNearestLandmark };
2334
+ };
2335
+
2336
+ // src/data/navigate/waypoint/createWaypointUtils.ts
2337
+ var createWaypointUtils = (options) => {
2338
+ const { findByIdSync } = options;
2339
+ const landmarkUtils = createLandmarkUtils(options);
2340
+ const toWaypoints = (path) => {
2341
+ const [startPoint, middleAndEndPoints] = extractStartPoint(path, options);
2342
+ const [endPoint, middlePoints] = extractEndPoint(middleAndEndPoints, options);
2343
+ const waypoints = middlePoints.map((openingId) => {
2344
+ const opening = findByIdSync(openingId);
2345
+ const level = findByIdSync(opening.properties.level_id);
2346
+ const coordinates = (0, import_center9.center)(opening).geometry.coordinates;
2347
+ const landmark = landmarkUtils.findNearestLandmark(coordinates, opening.properties.level_id);
2348
+ return {
2349
+ id: `${opening.properties.level_id}:${openingId}`,
2350
+ type: "between",
2351
+ point: coordinates,
2352
+ name: null,
2353
+ levelId: opening.properties.level_id,
2354
+ ordinal: level.properties.ordinal,
2355
+ hint: landmark ? { kind: "landmark", name: landmark.name } : void 0,
2356
+ source: { type: "opening", id: opening.id }
2357
+ };
2358
+ });
2359
+ return [startPoint, ...waypoints, endPoint];
2360
+ };
2361
+ return { toWaypoints };
2362
+ };
2363
+
2364
+ // src/data/navigate/getNavigateClient.ts
2365
+ var getNavigateClient = (options) => {
2366
+ const { data } = options;
2367
+ const { levels, units } = data;
2368
+ trace("nav", "\u2713 prepare");
2369
+ const t0 = performance.now();
2370
+ trace("nav", " \u251C\u2500 createGraph (dijkstra)");
2371
+ const { defaultGraph, accessibleGraph, addCoordinateOrdinalNode } = prepareGraph({ data });
2372
+ const t1 = performance.now();
2373
+ trace("nav", " \u2502 \u2514\u2500 Total ", t1 - t0);
2374
+ const t2 = performance.now();
2375
+ const { findByIdSync } = createFindByIdSync(data);
2376
+ const t3 = performance.now();
2377
+ trace("nav", " \u2514\u2500 findByIdSync", t3 - t2);
2378
+ const findCoordinateOrdinalUnit = (params) => {
2379
+ const [lat, lng, ordinal] = parseOrdinalCoordinate(params);
2380
+ const levelIdsWithOrdinal = levels.filter((level) => level.properties.ordinal === ordinal).map((level) => level.id);
2381
+ const unit = units.find((unit2) => levelIdsWithOrdinal.includes(unit2.properties.level_id) && (0, import_boolean_point_in_polygon4.booleanPointInPolygon)([lat, lng], unit2));
2382
+ return unit;
2383
+ };
2384
+ const stepUtils = createStepUtils({ ...options, findByIdSync });
2385
+ const waypointUtils = createWaypointUtils({ ...options, findByIdSync });
2386
+ const findRoute = async (routeOriginParam, routeDestinationParam, options2) => {
2387
+ if (!routeOriginParam || !routeDestinationParam) return null;
2388
+ const graph = options2?.mode === "accessible" ? accessibleGraph : defaultGraph;
2389
+ if (isCoordinateOrdinalString(routeOriginParam)) {
2390
+ const walkwayUnit = findCoordinateOrdinalUnit(routeOriginParam);
2391
+ addCoordinateOrdinalNode(routeOriginParam, walkwayUnit);
2392
+ }
2393
+ if (isCoordinateOrdinalString(routeDestinationParam)) {
2394
+ const walkwayUnit = findCoordinateOrdinalUnit(routeDestinationParam);
2395
+ addCoordinateOrdinalNode(routeDestinationParam, walkwayUnit);
2396
+ }
2397
+ try {
2398
+ trace("nav", "\u2713 findRoute", 0);
2399
+ const t02 = performance.now();
2400
+ const path = graph.path(routeOriginParam, routeDestinationParam);
2401
+ const t12 = performance.now();
2402
+ trace("nav", " \u251C\u2500 path (dijkstra)", t12 - t02);
2403
+ const waypoints = waypointUtils.toWaypoints(path);
2404
+ const t22 = performance.now();
2405
+ trace("nav", " \u251C\u2500 toWaypoints", t22 - t12);
2406
+ trace("nav", " \u251C\u2500 toSteps", 0);
2407
+ const steps = stepUtils.toSteps(waypoints);
2408
+ const t32 = performance.now();
2409
+ const totalDistance = calculateTotalDistance(steps);
2410
+ const roundedDistance = calculateRoundedDistance(totalDistance);
2411
+ const duration = calculateTravelingDuration(totalDistance);
2412
+ const t4 = performance.now();
2413
+ trace("nav", " \u2514\u2500 postProcess", t4 - t32);
2414
+ return {
2415
+ distance: roundedDistance,
2416
+ duration,
2417
+ steps
2418
+ };
2419
+ } catch (error) {
2420
+ console.log(error);
2421
+ throw error;
2422
+ }
2423
+ };
2424
+ return {
2425
+ findRoute,
2426
+ findByIdSync
2427
+ };
2428
+ };
2429
+
2430
+ // src/data/getDataClient.ts
2431
+ var getDataClient = (options) => {
2432
+ let searchClient;
2433
+ let navigateClient;
2434
+ const observers = /* @__PURE__ */ new Map();
2435
+ const queryClient = options.queryClient ?? new import_query_core.QueryClient();
2436
+ const { mode = "delivery", projectId, apiKey, baseUrl, previewToken } = options;
2437
+ if (!projectId)
2438
+ throw new Error(
2439
+ "Cannot create VenueDataClient. Reason: `projectId` is missing"
2440
+ );
2441
+ if (mode === "delivery" && !apiKey)
2442
+ throw new Error(
2443
+ "Cannot create VenueDataClient. Reason: `apiKey` is missing"
2444
+ );
676
2445
  if (mode === "preview" && !previewToken)
677
2446
  throw new Error(
678
2447
  "Cannot create VenueDataClient. Reason: `previewToken` is missing"
@@ -690,7 +2459,7 @@ var getDataClient = (options) => {
690
2459
  }
691
2460
  };
692
2461
  const internalFindById = async (id) => {
693
- if (id === null) return null;
2462
+ if (id === null || id === void 0) return null;
694
2463
  const featureType = id.slice(0, id.lastIndexOf("-"));
695
2464
  const feature2 = await queryClient.ensureQueryData({
696
2465
  queryKey: ["_deliveryapi", featureType, id],
@@ -770,135 +2539,61 @@ var getDataClient = (options) => {
770
2539
  id,
771
2540
  params
772
2541
  );
773
- const feature2 = await queryClient.ensureQueryData(findQueryOptions);
774
- return feature2;
775
- }
776
- return {
777
- projectId,
778
- queryClient,
779
- registerObserver,
780
- destroyObserver,
781
- destroyObservers,
782
- createFilterByTypeQueryOptions,
783
- createFindByIdQueryOptions,
784
- filterByType,
785
- findById
786
- };
787
- };
788
-
789
- // src/IndoorMap/IndoorMap.ts
790
- var import_maptalks_gl = require("maptalks-gl");
791
- var import_transcoders = require("@maptalks/transcoders.draco");
792
- var import_tween = __toESM(require("@tweenjs/tween.js"));
793
- var import_lodash6 = __toESM(require("lodash"));
794
-
795
- // ../../node_modules/@turf/helpers/dist/esm/index.js
796
- var earthRadius = 63710088e-1;
797
- var factors = {
798
- centimeters: earthRadius * 100,
799
- centimetres: earthRadius * 100,
800
- degrees: 360 / (2 * Math.PI),
801
- feet: earthRadius * 3.28084,
802
- inches: earthRadius * 39.37,
803
- kilometers: earthRadius / 1e3,
804
- kilometres: earthRadius / 1e3,
805
- meters: earthRadius,
806
- metres: earthRadius,
807
- miles: earthRadius / 1609.344,
808
- millimeters: earthRadius * 1e3,
809
- millimetres: earthRadius * 1e3,
810
- nauticalmiles: earthRadius / 1852,
811
- radians: 1,
812
- yards: earthRadius * 1.0936
813
- };
814
- function feature(geom, properties, options = {}) {
815
- const feat = { type: "Feature" };
816
- if (options.id === 0 || options.id) {
817
- feat.id = options.id;
818
- }
819
- if (options.bbox) {
820
- feat.bbox = options.bbox;
821
- }
822
- feat.properties = properties || {};
823
- feat.geometry = geom;
824
- return feat;
825
- }
826
- function point(coordinates, properties, options = {}) {
827
- if (!coordinates) {
828
- throw new Error("coordinates is required");
829
- }
830
- if (!Array.isArray(coordinates)) {
831
- throw new Error("coordinates must be an Array");
832
- }
833
- if (coordinates.length < 2) {
834
- throw new Error("coordinates must be at least 2 numbers long");
835
- }
836
- if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) {
837
- throw new Error("coordinates must contain numbers");
838
- }
839
- const geom = {
840
- type: "Point",
841
- coordinates
842
- };
843
- return feature(geom, properties, options);
844
- }
845
- function polygon(coordinates, properties, options = {}) {
846
- for (const ring of coordinates) {
847
- if (ring.length < 4) {
848
- throw new Error(
849
- "Each LinearRing of a Polygon must have 4 or more Positions."
850
- );
851
- }
852
- if (ring[ring.length - 1].length !== ring[0].length) {
853
- throw new Error("First and last Position are not equivalent.");
854
- }
855
- for (let j = 0; j < ring[ring.length - 1].length; j++) {
856
- if (ring[ring.length - 1][j] !== ring[0][j]) {
857
- throw new Error("First and last Position are not equivalent.");
858
- }
859
- }
2542
+ const feature2 = await queryClient.ensureQueryData(findQueryOptions);
2543
+ return feature2;
860
2544
  }
861
- const geom = {
862
- type: "Polygon",
863
- coordinates
2545
+ const searchFn = async (txt) => {
2546
+ if (!searchClient) {
2547
+ const [occupants, amenities] = await Promise.all([
2548
+ filterByType("occupant"),
2549
+ filterByType("amenity")
2550
+ ]);
2551
+ const haystack = { occupants, amenities };
2552
+ searchClient = getSearchClient(haystack);
2553
+ }
2554
+ return searchClient.search(txt);
864
2555
  };
865
- return feature(geom, properties, options);
866
- }
867
- function lineString(coordinates, properties, options = {}) {
868
- if (coordinates.length < 2) {
869
- throw new Error("coordinates must be an array of two or more positions");
870
- }
871
- const geom = {
872
- type: "LineString",
873
- coordinates
2556
+ const navigateFn = async (origin, destination) => {
2557
+ if (!navigateClient) {
2558
+ const [levels, occupants, openings, relationships, units, fixtures, kiosks, amenities, anchors] = await Promise.all([
2559
+ filterByType("level"),
2560
+ filterByType("occupant"),
2561
+ filterByType("opening"),
2562
+ filterByType("relationship"),
2563
+ filterByType("unit"),
2564
+ filterByType("fixture"),
2565
+ filterByType("kiosk"),
2566
+ filterByType("amenity"),
2567
+ filterByType("anchor")
2568
+ ]);
2569
+ const haystack = { levels, occupants, openings, relationships, units, fixtures, kiosks, amenities, anchors };
2570
+ navigateClient = getNavigateClient({ data: haystack });
2571
+ }
2572
+ return navigateClient.findRoute(origin, destination);
874
2573
  };
875
- return feature(geom, properties, options);
876
- }
877
- function featureCollection(features, options = {}) {
878
- const fc = { type: "FeatureCollection" };
879
- if (options.id) {
880
- fc.id = options.id;
881
- }
882
- if (options.bbox) {
883
- fc.bbox = options.bbox;
884
- }
885
- fc.features = features;
886
- return fc;
887
- }
888
- function multiPoint(coordinates, properties, options = {}) {
889
- const geom = {
890
- type: "MultiPoint",
891
- coordinates
2574
+ return {
2575
+ projectId,
2576
+ queryClient,
2577
+ registerObserver,
2578
+ destroyObserver,
2579
+ destroyObservers,
2580
+ createFilterByTypeQueryOptions,
2581
+ createFindByIdQueryOptions,
2582
+ _internalFindById: internalFindById,
2583
+ filterByType,
2584
+ findById,
2585
+ search: searchFn,
2586
+ navigate: navigateFn
892
2587
  };
893
- return feature(geom, properties, options);
894
- }
895
- function isNumber(num) {
896
- return !isNaN(num) && num !== null && !Array.isArray(num);
897
- }
2588
+ };
898
2589
 
899
2590
  // src/IndoorMap/IndoorMap.ts
900
- var import_distance = __toESM(require("@turf/distance"));
901
- var import_center4 = __toESM(require("@turf/center"));
2591
+ var import_maptalks_gl = require("maptalks-gl");
2592
+ var import_transcoders = require("@maptalks/transcoders.draco");
2593
+ var import_tween = __toESM(require("@tweenjs/tween.js"));
2594
+ var import_lodash21 = __toESM(require("lodash"));
2595
+ var import_distance6 = __toESM(require("@turf/distance"));
2596
+ var import_center13 = __toESM(require("@turf/center"));
902
2597
  var import_three6 = require("three");
903
2598
  var import_maptalks10 = require("maptalks.three");
904
2599
 
@@ -977,9 +2672,9 @@ var VENUE_EVENTS = {
977
2672
  };
978
2673
 
979
2674
  // src/IndoorMap/utils/createElements.js
980
- var import_lodash4 = __toESM(require("lodash"));
2675
+ var import_lodash17 = __toESM(require("lodash"));
981
2676
  var import_maptalks4 = require("maptalks");
982
- var import_center2 = __toESM(require("@turf/center"));
2677
+ var import_center11 = __toESM(require("@turf/center"));
983
2678
  var import_buffer = __toESM(require("@turf/buffer"));
984
2679
  var import_three4 = require("three");
985
2680
 
@@ -987,7 +2682,7 @@ var import_three4 = require("three");
987
2682
  var maptalks = __toESM(require("maptalks"));
988
2683
  var import_maptalks = require("maptalks.three");
989
2684
  var import_three = require("three");
990
- var import_lodash = __toESM(require("lodash"));
2685
+ var import_lodash14 = __toESM(require("lodash"));
991
2686
  var OPTIONS = {
992
2687
  altitude: 25,
993
2688
  scale: 15e-5,
@@ -1020,7 +2715,7 @@ var Billboard = class extends import_maptalks.BaseObject {
1020
2715
  } = options;
1021
2716
  this.properties = { ...properties };
1022
2717
  this._createGroup();
1023
- const divider = import_lodash.default.clamp(window.innerWidth / 375 / 1.75, 1, 1.7);
2718
+ const divider = import_lodash14.default.clamp(window.innerWidth / 375 / 1.75, 1, 1.7);
1024
2719
  if (showLeg) {
1025
2720
  const lineMaterial = new import_three.LineBasicMaterial({
1026
2721
  color: legColor,
@@ -1055,9 +2750,9 @@ var Billboard = class extends import_maptalks.BaseObject {
1055
2750
  });
1056
2751
  const z = layer.altitudeToVector3(altitude, altitude).x;
1057
2752
  const position = layer.coordinateToVector3(coordinate, z);
1058
- import_lodash.default.set(this.properties, "default.position", position);
1059
- import_lodash.default.set(this.properties, "default.altitude", altitude);
1060
- import_lodash.default.set(this.properties, "default.scale", scale3);
2753
+ import_lodash14.default.set(this.properties, "default.position", position);
2754
+ import_lodash14.default.set(this.properties, "default.altitude", altitude);
2755
+ import_lodash14.default.set(this.properties, "default.scale", scale3);
1061
2756
  this.getObject3d().position.copy(position);
1062
2757
  }
1063
2758
  setLineHeight(altitude) {
@@ -1073,7 +2768,7 @@ var Billboard = class extends import_maptalks.BaseObject {
1073
2768
  // src/IndoorMap/object3d/SpriteMarker.ts
1074
2769
  var import_maptalks2 = require("maptalks.three");
1075
2770
  var import_three2 = require("three");
1076
- var import_lodash2 = __toESM(require("lodash"));
2771
+ var import_lodash15 = __toESM(require("lodash"));
1077
2772
  var DEFAULT_SCALE = 0.05;
1078
2773
  var DEFAULT_ALTITUDE = 0;
1079
2774
  var DEFAULT_ALPHATEST = 0.3;
@@ -1104,7 +2799,7 @@ var SpriteMarker = class extends import_maptalks2.BaseObject {
1104
2799
  this.properties = { ...properties };
1105
2800
  const modifiedAltitude = altitude + 2;
1106
2801
  this.#default = { options: { scale: scale3, altitude: modifiedAltitude }, material };
1107
- this.#highlight = import_lodash2.default.merge({}, DEFAULT_OPTIONS.highlight, highlight);
2802
+ this.#highlight = import_lodash15.default.merge({}, DEFAULT_OPTIONS.highlight, highlight);
1108
2803
  if (material && material instanceof import_three2.SpriteMaterial)
1109
2804
  material.alphaTest = alphaTest;
1110
2805
  const sprite = new import_three2.Sprite(material);
@@ -1113,7 +2808,7 @@ var SpriteMarker = class extends import_maptalks2.BaseObject {
1113
2808
  obj3d.add(sprite);
1114
2809
  const z = layer.altitudeToVector3(modifiedAltitude, modifiedAltitude).x;
1115
2810
  const position = layer.coordinateToVector3(coordinate, z);
1116
- import_lodash2.default.set(this.properties, "default.position", position);
2811
+ import_lodash15.default.set(this.properties, "default.position", position);
1117
2812
  this.getObject3d().position.copy(position);
1118
2813
  }
1119
2814
  // Different objects need to implement their own methods
@@ -1254,15 +2949,15 @@ var NavigationPath = class extends import_maptalks3.BaseObject {
1254
2949
  };
1255
2950
 
1256
2951
  // src/IndoorMap/utils/geometry.ts
1257
- var import_center = __toESM(require("@turf/center"));
1258
- var import_lodash3 = __toESM(require("lodash"));
2952
+ var import_center10 = __toESM(require("@turf/center"));
2953
+ var import_lodash16 = __toESM(require("lodash"));
1259
2954
  var import_line_offset = __toESM(require("@turf/line-offset"));
1260
2955
  var getCenterFromGeometry = (geometry) => {
1261
2956
  try {
1262
2957
  const { type = null, coordinates = null } = geometry;
1263
2958
  if (!type || !coordinates) return null;
1264
- const centerPoint = (0, import_center.default)(geometry);
1265
- return import_lodash3.default.get(centerPoint, "geometry.coordinates");
2959
+ const centerPoint = (0, import_center10.default)(geometry);
2960
+ return import_lodash16.default.get(centerPoint, "geometry.coordinates");
1266
2961
  } catch (error) {
1267
2962
  return null;
1268
2963
  }
@@ -1413,7 +3108,7 @@ var createWaterFixture = (feature2, style, options = {}) => {
1413
3108
  const { geometry, properties } = feature2;
1414
3109
  const { allowOverride, inheritFillColorToLine, zIndex } = options;
1415
3110
  const symbolStyle = { ...style };
1416
- if (allowOverride) import_lodash4.default.merge(symbolStyle, properties.style);
3111
+ if (allowOverride) import_lodash17.default.merge(symbolStyle, properties.style);
1417
3112
  if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill;
1418
3113
  return new GeometryType[geometry.type](geometry.coordinates, {
1419
3114
  properties: {
@@ -1429,7 +3124,7 @@ var createVegetationFixture = (feature2, style, options = {}) => {
1429
3124
  const { geometry, properties } = feature2;
1430
3125
  const { allowOverride, inheritFillColorToLine, zIndex } = options;
1431
3126
  const symbolStyle = { ...style };
1432
- if (allowOverride) import_lodash4.default.merge(symbolStyle, properties.style);
3127
+ if (allowOverride) import_lodash17.default.merge(symbolStyle, properties.style);
1433
3128
  if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill;
1434
3129
  return new GeometryType[geometry.type](geometry.coordinates, {
1435
3130
  properties: {
@@ -1446,8 +3141,8 @@ var createObstructionalFixture = (feature2, style = {}, options = {}) => {
1446
3141
  const { model3d } = properties;
1447
3142
  const { allowOverride, inheritFillColorToLine, zIndex } = options;
1448
3143
  const symbolStyle = { ...style };
1449
- if (!import_lodash4.default.isEmpty(model3d)) return;
1450
- if (allowOverride) import_lodash4.default.merge(symbolStyle, properties.style);
3144
+ if (!import_lodash17.default.isEmpty(model3d)) return;
3145
+ if (allowOverride) import_lodash17.default.merge(symbolStyle, properties.style);
1451
3146
  if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill;
1452
3147
  if (geometry.type === "LineString") {
1453
3148
  const polygon2 = createPolygonFromLineString(geometry);
@@ -1517,7 +3212,7 @@ var createPrincipalOpening = (feature2, style, options = {}) => {
1517
3212
  const { geometry, properties } = feature2;
1518
3213
  const { allowOverride, zIndex } = options;
1519
3214
  const symbolStyle = { ...style };
1520
- if (allowOverride) import_lodash4.default.merge(symbolStyle, properties.style);
3215
+ if (allowOverride) import_lodash17.default.merge(symbolStyle, properties.style);
1521
3216
  try {
1522
3217
  return new import_maptalks4.LineString(geometry.coordinates, {
1523
3218
  properties: {
@@ -1534,7 +3229,7 @@ var createEmergencyExitOpening = (feature2, style, options = {}) => {
1534
3229
  const { geometry, properties } = feature2;
1535
3230
  const { allowOverride, zIndex } = options;
1536
3231
  const symbolStyle = { ...style };
1537
- if (allowOverride) import_lodash4.default.merge(symbolStyle, properties.style);
3232
+ if (allowOverride) import_lodash17.default.merge(symbolStyle, properties.style);
1538
3233
  try {
1539
3234
  return new import_maptalks4.LineString(geometry.coordinates, {
1540
3235
  properties: {
@@ -1551,7 +3246,7 @@ var createPedestrianOpening = (feature2, style, options = {}) => {
1551
3246
  const { geometry, properties, id } = feature2;
1552
3247
  const { allowOverride, zIndex } = options;
1553
3248
  const symbolStyle = { ...style };
1554
- if (allowOverride) import_lodash4.default.merge(symbolStyle, properties.style);
3249
+ if (allowOverride) import_lodash17.default.merge(symbolStyle, properties.style);
1555
3250
  try {
1556
3251
  return new import_maptalks4.LineString(geometry.coordinates, {
1557
3252
  properties: {
@@ -1589,9 +3284,9 @@ var create3DMarker = (coordinates, options, material, threeLayer, markerProperti
1589
3284
  };
1590
3285
  var getExtrudeConfigByFeature = (baseExtrudeConfig, feature2 = {}) => {
1591
3286
  const { feature_type: featureType } = feature2;
1592
- const featureExtrudeConfig = import_lodash4.default.get(feature2, "properties.extrude");
1593
- const featureCategory = import_lodash4.default.get(feature2, "properties.category");
1594
- const baseFeatureExtrudeConfig = import_lodash4.default.get(
3287
+ const featureExtrudeConfig = import_lodash17.default.get(feature2, "properties.extrude");
3288
+ const featureCategory = import_lodash17.default.get(feature2, "properties.category");
3289
+ const baseFeatureExtrudeConfig = import_lodash17.default.get(
1595
3290
  baseExtrudeConfig,
1596
3291
  `${featureType}.${featureCategory || featureType}`
1597
3292
  );
@@ -1649,50 +3344,50 @@ var createStyledUIMarkerElement = ({
1649
3344
  var styledFeatureGenerator = (mapTheme) => {
1650
3345
  const getElementSymbol = (key) => {
1651
3346
  const [featureType] = key.split(".");
1652
- const featureTypeTheme = import_lodash4.default.get(mapTheme, `${featureType}.geometry.symbol`);
3347
+ const featureTypeTheme = import_lodash17.default.get(mapTheme, `${featureType}.geometry.symbol`);
1653
3348
  if (featureType === key) return featureTypeTheme;
1654
- const categoryTheme = import_lodash4.default.get(mapTheme, `${key}.geometry.symbol`);
1655
- return import_lodash4.default.merge({}, featureTypeTheme, categoryTheme);
3349
+ const categoryTheme = import_lodash17.default.get(mapTheme, `${key}.geometry.symbol`);
3350
+ return import_lodash17.default.merge({}, featureTypeTheme, categoryTheme);
1656
3351
  };
1657
3352
  const getLabelSymbol = (key) => {
1658
3353
  const [featureType] = key.split(".");
1659
- const featureTypeTheme = import_lodash4.default.get(mapTheme, `${featureType}.label`);
1660
- const categoryTheme = import_lodash4.default.get(mapTheme, `${key}.label`);
1661
- const mergedSymbol = import_lodash4.default.merge({}, featureTypeTheme, categoryTheme);
1662
- let symbols = import_lodash4.default.values(import_lodash4.default.map(mergedSymbol, "symbol"));
3354
+ const featureTypeTheme = import_lodash17.default.get(mapTheme, `${featureType}.label`);
3355
+ const categoryTheme = import_lodash17.default.get(mapTheme, `${key}.label`);
3356
+ const mergedSymbol = import_lodash17.default.merge({}, featureTypeTheme, categoryTheme);
3357
+ let symbols = import_lodash17.default.values(import_lodash17.default.map(mergedSymbol, "symbol"));
1663
3358
  const markerIndexToMove = symbols.findIndex(
1664
3359
  ({ elementType }) => elementType === "label.marker"
1665
3360
  );
1666
3361
  if (markerIndexToMove >= 0) {
1667
- const markerSymbolToMove = import_lodash4.default.pullAt(symbols, markerIndexToMove)[0];
3362
+ const markerSymbolToMove = import_lodash17.default.pullAt(symbols, markerIndexToMove)[0];
1668
3363
  symbols.push(markerSymbolToMove);
1669
3364
  }
1670
3365
  return symbols;
1671
3366
  };
1672
3367
  const getUIMarkerSymbol = (key) => {
1673
3368
  const [featureType] = key.split(".");
1674
- const featureTypeTheme = import_lodash4.default.get(mapTheme, `${featureType}.ui.marker`);
1675
- const categoryTheme = import_lodash4.default.get(mapTheme, `${key}.ui.marker`);
1676
- const mergedSymbol = import_lodash4.default.merge({}, featureTypeTheme, categoryTheme);
1677
- const symbol = import_lodash4.default.get(mergedSymbol, "symbol");
3369
+ const featureTypeTheme = import_lodash17.default.get(mapTheme, `${featureType}.ui.marker`);
3370
+ const categoryTheme = import_lodash17.default.get(mapTheme, `${key}.ui.marker`);
3371
+ const mergedSymbol = import_lodash17.default.merge({}, featureTypeTheme, categoryTheme);
3372
+ const symbol = import_lodash17.default.get(mergedSymbol, "symbol");
1678
3373
  return symbol;
1679
3374
  };
1680
3375
  const getUIMarkerOptions = (key) => {
1681
3376
  const [featureType] = key.split(".");
1682
- const featureTypeTheme = import_lodash4.default.get(mapTheme, `${featureType}.ui.marker`);
1683
- const categoryTheme = import_lodash4.default.get(mapTheme, `${key}.ui.marker`);
1684
- const mergedSymbol = import_lodash4.default.merge({}, featureTypeTheme, categoryTheme);
1685
- const options = import_lodash4.default.get(mergedSymbol, "options");
3377
+ const featureTypeTheme = import_lodash17.default.get(mapTheme, `${featureType}.ui.marker`);
3378
+ const categoryTheme = import_lodash17.default.get(mapTheme, `${key}.ui.marker`);
3379
+ const mergedSymbol = import_lodash17.default.merge({}, featureTypeTheme, categoryTheme);
3380
+ const options = import_lodash17.default.get(mergedSymbol, "options");
1686
3381
  return options;
1687
3382
  };
1688
3383
  const getLabelOptions = (key) => {
1689
3384
  const [featureType] = key.split(".");
1690
- const featureTypeSymbol = import_lodash4.default.get(mapTheme, `${featureType}.label`);
1691
- const categorySymbol = import_lodash4.default.get(mapTheme, `${key}.label`);
1692
- const mergedSymbol = import_lodash4.default.merge({}, featureTypeSymbol, categorySymbol);
1693
- return import_lodash4.default.reduce(
3385
+ const featureTypeSymbol = import_lodash17.default.get(mapTheme, `${featureType}.label`);
3386
+ const categorySymbol = import_lodash17.default.get(mapTheme, `${key}.label`);
3387
+ const mergedSymbol = import_lodash17.default.merge({}, featureTypeSymbol, categorySymbol);
3388
+ return import_lodash17.default.reduce(
1694
3389
  mergedSymbol,
1695
- (acc, symbol) => ({ ...acc, ...import_lodash4.default.get(symbol, "options", {}) }),
3390
+ (acc, symbol) => ({ ...acc, ...import_lodash17.default.get(symbol, "options", {}) }),
1696
3391
  {}
1697
3392
  );
1698
3393
  };
@@ -1707,13 +3402,13 @@ var styledFeatureGenerator = (mapTheme) => {
1707
3402
  };
1708
3403
  const generateSpriteHighlightMarkerOption = () => {
1709
3404
  return SPRITE_HIGHLIGHT_MARKER_FEATURE.reduce((acc, featCate) => {
1710
- const categoryKey = import_lodash4.default.last(featCate.split("-"));
3405
+ const categoryKey = import_lodash17.default.last(featCate.split("-"));
1711
3406
  const defaultLabelSymbol = getLabelSymbol(categoryKey);
1712
3407
  const highlightLabelSymbol = getLabelSymbol(featCate);
1713
3408
  const [defaultBase, defaultIcon] = defaultLabelSymbol;
1714
3409
  const [highlightBase, highlightIcon] = highlightLabelSymbol;
1715
- const base = import_lodash4.default.merge({}, defaultBase, highlightBase);
1716
- const icon = import_lodash4.default.merge({}, defaultIcon, highlightIcon);
3410
+ const base = import_lodash17.default.merge({}, defaultBase, highlightBase);
3411
+ const icon = import_lodash17.default.merge({}, defaultIcon, highlightIcon);
1717
3412
  const material = createSpriteMaterialByLabelSymbol([base, icon]);
1718
3413
  const options = getLabelOptions(featCate);
1719
3414
  return { ...acc, [featCate]: { material, options } };
@@ -1723,32 +3418,32 @@ var styledFeatureGenerator = (mapTheme) => {
1723
3418
  const spriteHighlightMarkerOptionObj = generateSpriteHighlightMarkerOption();
1724
3419
  const getElementOptions = (key) => {
1725
3420
  const [featureType] = key.split(".");
1726
- const featureTypeOptions = import_lodash4.default.get(
3421
+ const featureTypeOptions = import_lodash17.default.get(
1727
3422
  mapTheme,
1728
3423
  `${featureType}.geometry.options`
1729
3424
  );
1730
- const categoryOptions = import_lodash4.default.get(mapTheme, `${key}.geometry.options`);
1731
- return import_lodash4.default.merge({}, featureTypeOptions, categoryOptions);
3425
+ const categoryOptions = import_lodash17.default.get(mapTheme, `${key}.geometry.options`);
3426
+ return import_lodash17.default.merge({}, featureTypeOptions, categoryOptions);
1732
3427
  };
1733
3428
  const createOccupantMarker = (feature2, locatedFeature, mapConfig) => {
1734
3429
  const { textMarkerType, featureExtrudeConfig } = getFeatureMarkerConfig(
1735
3430
  feature2,
1736
3431
  mapConfig
1737
3432
  );
1738
- const markerHeight = import_lodash4.default.get(featureExtrudeConfig, "height", 0);
3433
+ const markerHeight = import_lodash17.default.get(featureExtrudeConfig, "height", 0);
1739
3434
  const { properties, id, feature_type } = feature2;
1740
3435
  if (!properties.anchor) return;
1741
- const mainLocationId = import_lodash4.default.get(properties, "unit.id") || import_lodash4.default.get(properties, "kiosk.id");
3436
+ const mainLocationId = import_lodash17.default.get(properties, "unit.id") || import_lodash17.default.get(properties, "kiosk.id");
1742
3437
  const isMainLocationFeature = mainLocationId === locatedFeature?.id;
1743
3438
  const { geometry: mainLocationGeometry } = properties?.anchor;
1744
- const geometry = isMainLocationFeature ? mainLocationGeometry : (0, import_center2.default)(locatedFeature)?.geometry;
3439
+ const geometry = isMainLocationFeature ? mainLocationGeometry : (0, import_center11.default)(locatedFeature)?.geometry;
1745
3440
  const baseProperties = {
1746
3441
  id,
1747
3442
  feature_type,
1748
3443
  category: properties.category,
1749
3444
  altitude: getAltitude(properties)
1750
3445
  };
1751
- const occupantName = import_lodash4.default.isEmpty(properties.short_name) ? properties.name : properties.short_name;
3446
+ const occupantName = import_lodash17.default.isEmpty(properties.short_name) ? properties.name : properties.short_name;
1752
3447
  if (locatedFeature) {
1753
3448
  const { feature_type: feature_type2, properties: properties2 } = locatedFeature;
1754
3449
  const { category } = properties2;
@@ -1762,21 +3457,21 @@ var styledFeatureGenerator = (mapTheme) => {
1762
3457
  }
1763
3458
  return requestedType;
1764
3459
  };
1765
- const logoUrl = import_lodash4.default.get(properties, "logo.url");
1766
- const requestedRenderType = import_lodash4.default.get(properties, "render_type", "Name");
3460
+ const logoUrl = import_lodash17.default.get(properties, "logo.url");
3461
+ const requestedRenderType = import_lodash17.default.get(properties, "render_type", "Name");
1767
3462
  const renderType = getValidatedRenderType(requestedRenderType, logoUrl);
1768
3463
  if (renderType === "Label") return null;
1769
3464
  const renderPriority = properties.render_priority || 3;
1770
- const labelSymbol = getLabelSymbol(`occupant-${import_lodash4.default.toLower(renderType)}`);
1771
- const markerSymbol = import_lodash4.default.last(labelSymbol);
1772
- const coordinates = import_lodash4.default.get(geometry, "coordinates");
3465
+ const labelSymbol = getLabelSymbol(`occupant-${import_lodash17.default.toLower(renderType)}`);
3466
+ const markerSymbol = import_lodash17.default.last(labelSymbol);
3467
+ const coordinates = import_lodash17.default.get(geometry, "coordinates");
1773
3468
  const priorityLabelSymbol = getLabelSymbol(
1774
- `occupant-${import_lodash4.default.toLower(renderType)}-${renderPriority}`
3469
+ `occupant-${import_lodash17.default.toLower(renderType)}-${renderPriority}`
1775
3470
  );
1776
- const priorityMarkerSymbol = import_lodash4.default.last(priorityLabelSymbol) || {};
3471
+ const priorityMarkerSymbol = import_lodash17.default.last(priorityLabelSymbol) || {};
1777
3472
  switch (renderType) {
1778
3473
  case "Logo":
1779
- import_lodash4.default.set(priorityMarkerSymbol, "markerFile", logoUrl);
3474
+ import_lodash17.default.set(priorityMarkerSymbol, "markerFile", logoUrl);
1780
3475
  return new import_maptalks4.Marker(coordinates, {
1781
3476
  properties: {
1782
3477
  altitude: getAltitude(properties) + markerHeight,
@@ -1837,13 +3532,13 @@ var styledFeatureGenerator = (mapTheme) => {
1837
3532
  });
1838
3533
  }
1839
3534
  const uiMarkerSymbol = getUIMarkerSymbol(
1840
- `occupant-${import_lodash4.default.toLower(renderType)}`
3535
+ `occupant-${import_lodash17.default.toLower(renderType)}`
1841
3536
  );
1842
3537
  const uiMarkerPrioritySymbol = getUIMarkerSymbol(
1843
- `occupant-${import_lodash4.default.toLower(renderType)}-${renderPriority}`
3538
+ `occupant-${import_lodash17.default.toLower(renderType)}-${renderPriority}`
1844
3539
  );
1845
3540
  const uiMarkerPriorityOptions = getUIMarkerOptions(
1846
- `occupant-${import_lodash4.default.toLower(renderType)}-${renderPriority}`
3541
+ `occupant-${import_lodash17.default.toLower(renderType)}-${renderPriority}`
1847
3542
  );
1848
3543
  const style = { ...uiMarkerSymbol, ...uiMarkerPrioritySymbol };
1849
3544
  return new import_maptalks4.ui.UIMarker(coordinates, {
@@ -1865,7 +3560,7 @@ var styledFeatureGenerator = (mapTheme) => {
1865
3560
  const { category, ordinal, style = {} } = properties;
1866
3561
  const elementStyle = getElementSymbol(`${feature_type}.${category}`);
1867
3562
  const { allowOverride } = getElementOptions(`${feature_type}.${category}`);
1868
- if (allowOverride) import_lodash4.default.merge(elementStyle, style);
3563
+ if (allowOverride) import_lodash17.default.merge(elementStyle, style);
1869
3564
  const { polygonFill: color } = elementStyle;
1870
3565
  const featureProperty = {
1871
3566
  id,
@@ -1954,9 +3649,9 @@ var styledFeatureGenerator = (mapTheme) => {
1954
3649
  feature2,
1955
3650
  mapConfig
1956
3651
  );
1957
- const markerHeight = import_lodash4.default.get(featureExtrudeConfig, "height");
3652
+ const markerHeight = import_lodash17.default.get(featureExtrudeConfig, "height");
1958
3653
  const { id, properties } = feature2;
1959
- const geometry = import_lodash4.default.get(feature2, "geometry") || import_lodash4.default.get(feature2, "properties.anchor.geometry");
3654
+ const geometry = import_lodash17.default.get(feature2, "geometry") || import_lodash17.default.get(feature2, "properties.anchor.geometry");
1960
3655
  const coordinates = getCenterFromGeometry(geometry);
1961
3656
  const symbol = getElementSymbol("pin-marker");
1962
3657
  try {
@@ -1976,10 +3671,10 @@ var styledFeatureGenerator = (mapTheme) => {
1976
3671
  feature2,
1977
3672
  mapConfig
1978
3673
  );
1979
- const markerHeight = import_lodash4.default.get(featureExtrudeConfig, "height", 0);
3674
+ const markerHeight = import_lodash17.default.get(featureExtrudeConfig, "height", 0);
1980
3675
  const { properties, id } = feature2;
1981
3676
  const { geometry } = properties.anchor;
1982
- const logoUrl = import_lodash4.default.get(properties, "logo.url");
3677
+ const logoUrl = import_lodash17.default.get(properties, "logo.url");
1983
3678
  const coordinates = getCenterFromGeometry(geometry);
1984
3679
  const [markerBase, markerLabel] = getLabelSymbol(
1985
3680
  "highlighted-logo-marker"
@@ -2049,7 +3744,7 @@ var styledFeatureGenerator = (mapTheme) => {
2049
3744
  feature2,
2050
3745
  mapConfig
2051
3746
  );
2052
- const markerHeight = import_lodash4.default.get(featureExtrudeConfig, "height");
3747
+ const markerHeight = import_lodash17.default.get(featureExtrudeConfig, "height");
2053
3748
  const { id, feature_type, properties } = feature2;
2054
3749
  if (!properties.anchor) return;
2055
3750
  const markerProperties = {
@@ -2059,8 +3754,8 @@ var styledFeatureGenerator = (mapTheme) => {
2059
3754
  altitude: getAltitude(properties) + markerHeight
2060
3755
  };
2061
3756
  const { geometry } = properties?.anchor;
2062
- const coordinates = import_lodash4.default.get(geometry, "coordinates");
2063
- const logoUrl = import_lodash4.default.get(properties, "logo.url");
3757
+ const coordinates = import_lodash17.default.get(geometry, "coordinates");
3758
+ const logoUrl = import_lodash17.default.get(properties, "logo.url");
2064
3759
  if (markerSymbol) {
2065
3760
  return new import_maptalks4.Marker(coordinates, {
2066
3761
  properties: markerProperties,
@@ -2075,8 +3770,8 @@ var styledFeatureGenerator = (mapTheme) => {
2075
3770
  });
2076
3771
  }
2077
3772
  const labelSymbol = getLabelSymbol("highlight-occupant-logo");
2078
- const priorityMarkerSymbol = import_lodash4.default.last(labelSymbol) || {};
2079
- import_lodash4.default.set(priorityMarkerSymbol, "markerFile", logoUrl);
3773
+ const priorityMarkerSymbol = import_lodash17.default.last(labelSymbol) || {};
3774
+ import_lodash17.default.set(priorityMarkerSymbol, "markerFile", logoUrl);
2080
3775
  return new import_maptalks4.Marker(coordinates, {
2081
3776
  properties: markerProperties,
2082
3777
  symbol: labelSymbol
@@ -2084,14 +3779,14 @@ var styledFeatureGenerator = (mapTheme) => {
2084
3779
  },
2085
3780
  createHighlight2DAmenityMarkerFrom3DMarker: (feature2, mapConfig) => {
2086
3781
  const { coordinates, units, kiosk } = feature2;
2087
- const amenityLocatedUnit = import_lodash4.default.first(units);
3782
+ const amenityLocatedUnit = import_lodash17.default.first(units);
2088
3783
  const unitConfig = getExtrudeConfigByFeature(
2089
3784
  mapConfig,
2090
3785
  amenityLocatedUnit
2091
3786
  );
2092
- const unitHeight = import_lodash4.default.get(unitConfig, "height", 0);
3787
+ const unitHeight = import_lodash17.default.get(unitConfig, "height", 0);
2093
3788
  const kioskConfig = getExtrudeConfigByFeature(mapConfig, kiosk);
2094
- const kioskHeight = import_lodash4.default.get(kioskConfig, "height", 0);
3789
+ const kioskHeight = import_lodash17.default.get(kioskConfig, "height", 0);
2095
3790
  const markerHeight = unitHeight + kioskHeight;
2096
3791
  const symbol = getElementSymbol("highlight-amenity-marker");
2097
3792
  return new import_maptalks4.Marker(coordinates, {
@@ -2167,7 +3862,7 @@ var styledFeatureGenerator = (mapTheme) => {
2167
3862
  }
2168
3863
  },
2169
3864
  createLineStringFromGeometries: (geometries) => {
2170
- const mergedCoordinates = (0, import_lodash4.default)(geometries).map((geometry) => {
3865
+ const mergedCoordinates = (0, import_lodash17.default)(geometries).map((geometry) => {
2171
3866
  switch (geometry.type) {
2172
3867
  case "Point":
2173
3868
  return [
@@ -2276,29 +3971,29 @@ var styledFeatureGenerator = (mapTheme) => {
2276
3971
  create3DAmenityMarker: (feature2, threeLayer, config) => {
2277
3972
  const { geometry, properties, feature_type, id } = feature2;
2278
3973
  const { category, units, kiosk, is_clickable } = properties;
2279
- const amenityLocatedUnit = import_lodash4.default.first(units);
2280
- const isLocatedUnitModel3dAvailable = !import_lodash4.default.isEmpty(
3974
+ const amenityLocatedUnit = import_lodash17.default.first(units);
3975
+ const isLocatedUnitModel3dAvailable = !import_lodash17.default.isEmpty(
2281
3976
  amenityLocatedUnit?.properties?.model3d
2282
3977
  );
2283
- const isLocatedKioskModel3dAvailable = !import_lodash4.default.isEmpty(
3978
+ const isLocatedKioskModel3dAvailable = !import_lodash17.default.isEmpty(
2284
3979
  kiosk?.properties?.model3d
2285
3980
  );
2286
3981
  const unitConfig = getExtrudeConfigByFeature(config, amenityLocatedUnit);
2287
- const unitHeight = isLocatedUnitModel3dAvailable ? 0 : import_lodash4.default.get(unitConfig, "height", 0);
3982
+ const unitHeight = isLocatedUnitModel3dAvailable ? 0 : import_lodash17.default.get(unitConfig, "height", 0);
2288
3983
  const kioskConfig = getExtrudeConfigByFeature(config, kiosk);
2289
- const kioskHeight = isLocatedKioskModel3dAvailable ? 0 : import_lodash4.default.get(kioskConfig, "height", 0);
2290
- const coordinates = import_lodash4.default.get(geometry, "coordinates");
3984
+ const kioskHeight = isLocatedKioskModel3dAvailable ? 0 : import_lodash17.default.get(kioskConfig, "height", 0);
3985
+ const coordinates = import_lodash17.default.get(geometry, "coordinates");
2291
3986
  const markerProperties = {
2292
3987
  ...properties,
2293
3988
  coordinates,
2294
3989
  id,
2295
3990
  feature_type
2296
3991
  };
2297
- const material = import_lodash4.default.get(
3992
+ const material = import_lodash17.default.get(
2298
3993
  spriteMarkerMaterialObj,
2299
3994
  `${feature_type}.${category}`
2300
3995
  );
2301
- const highlightOptions = import_lodash4.default.get(
3996
+ const highlightOptions = import_lodash17.default.get(
2302
3997
  spriteHighlightMarkerOptionObj,
2303
3998
  `${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${feature_type}.${category}`
2304
3999
  );
@@ -2321,24 +4016,24 @@ var styledFeatureGenerator = (mapTheme) => {
2321
4016
  const { category, unit, kiosk } = properties;
2322
4017
  const amenityLocation = kiosk || unit;
2323
4018
  const locationConfig = getExtrudeConfigByFeature(config, amenityLocation);
2324
- const coordinates = import_lodash4.default.get(geometry, "coordinates");
4019
+ const coordinates = import_lodash17.default.get(geometry, "coordinates");
2325
4020
  const markerProperties = {
2326
4021
  ...properties,
2327
4022
  coordinates,
2328
4023
  id,
2329
4024
  feature_type
2330
4025
  };
2331
- const material = import_lodash4.default.get(
4026
+ const material = import_lodash17.default.get(
2332
4027
  spriteMarkerMaterialObj,
2333
4028
  `${feature_type}.${category}`
2334
4029
  );
2335
- const highlightOptions = import_lodash4.default.get(
4030
+ const highlightOptions = import_lodash17.default.get(
2336
4031
  spriteHighlightMarkerOptionObj,
2337
4032
  `${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${feature_type}.${category}`
2338
4033
  );
2339
4034
  const options = {
2340
4035
  scale: 0.05,
2341
- altitude: import_lodash4.default.get(locationConfig, "height", 0),
4036
+ altitude: import_lodash17.default.get(locationConfig, "height", 0),
2342
4037
  highlight: highlightOptions
2343
4038
  };
2344
4039
  return create3DMarker(
@@ -2354,24 +4049,24 @@ var styledFeatureGenerator = (mapTheme) => {
2354
4049
  const { category, unit, kiosk } = properties;
2355
4050
  const amenityLocation = kiosk || unit;
2356
4051
  const locationConfig = getExtrudeConfigByFeature(config, amenityLocation);
2357
- const coordinates = import_lodash4.default.get(geometry, "coordinates");
4052
+ const coordinates = import_lodash17.default.get(geometry, "coordinates");
2358
4053
  const markerProperties = {
2359
4054
  ...properties,
2360
4055
  coordinates,
2361
4056
  id,
2362
4057
  feature_type
2363
4058
  };
2364
- const material = import_lodash4.default.get(
4059
+ const material = import_lodash17.default.get(
2365
4060
  spriteMarkerMaterialObj,
2366
4061
  `${feature_type}.${category}`
2367
4062
  );
2368
- const highlightOptions = import_lodash4.default.get(
4063
+ const highlightOptions = import_lodash17.default.get(
2369
4064
  spriteHighlightMarkerOptionObj,
2370
4065
  `${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${feature_type}.${category}`
2371
4066
  );
2372
4067
  const options = {
2373
4068
  scale: 0.05,
2374
- altitude: import_lodash4.default.get(locationConfig, "height", 0),
4069
+ altitude: import_lodash17.default.get(locationConfig, "height", 0),
2375
4070
  highlight: highlightOptions
2376
4071
  };
2377
4072
  return create3DMarker(
@@ -2383,13 +4078,13 @@ var styledFeatureGenerator = (mapTheme) => {
2383
4078
  );
2384
4079
  },
2385
4080
  createExtrudedUnit: (unit, threeLayer, options) => {
2386
- const extrudeHeight = import_lodash4.default.get(options, "height");
4081
+ const extrudeHeight = import_lodash17.default.get(options, "height");
2387
4082
  if (!extrudeHeight) return;
2388
4083
  const unitProperty = getFeatureProperties(unit);
2389
4084
  const options3d = {
2390
4085
  // TODO: Move to extrude config later
2391
4086
  offset: -0.1,
2392
- altitude: import_lodash4.default.get(options, "altitude", 0)
4087
+ altitude: import_lodash17.default.get(options, "altitude", 0)
2393
4088
  };
2394
4089
  const color = unitProperty.defaultColor;
2395
4090
  if (color === "transparent") return;
@@ -2432,14 +4127,14 @@ var EXCEPT_AMENITY_LOCATION_CATEGORIES = [
2432
4127
  "unspecified"
2433
4128
  ];
2434
4129
  var getLocationByAmenity = (feature2) => {
2435
- const unit = import_lodash4.default.get(feature2, "properties.units[0]", null);
2436
- const unitCategory = import_lodash4.default.get(unit, "properties.category");
4130
+ const unit = import_lodash17.default.get(feature2, "properties.units[0]", null);
4131
+ const unitCategory = import_lodash17.default.get(unit, "properties.category");
2437
4132
  if (!unit) return feature2.id;
2438
4133
  return EXCEPT_AMENITY_LOCATION_CATEGORIES.includes(unitCategory) ? feature2 : unit;
2439
4134
  };
2440
4135
  var getLocationByOccupant = (feature2) => {
2441
- const kiosk = import_lodash4.default.get(feature2, "properties.kiosk", null);
2442
- const unit = import_lodash4.default.get(feature2, "properties.anchor.properties.unit", null);
4136
+ const kiosk = import_lodash17.default.get(feature2, "properties.kiosk", null);
4137
+ const unit = import_lodash17.default.get(feature2, "properties.anchor.properties.unit", null);
2443
4138
  return kiosk || unit;
2444
4139
  };
2445
4140
  var getLocationIdByFeature = (feature2) => {
@@ -2467,10 +4162,10 @@ var getFeatureByLocationId = (id, features = []) => {
2467
4162
  });
2468
4163
  };
2469
4164
  var isClickableFeature = (feature2) => {
2470
- const isClickable = import_lodash4.default.get(feature2, "properties.is_clickable");
4165
+ const isClickable = import_lodash17.default.get(feature2, "properties.is_clickable");
2471
4166
  switch (feature2?.feature_type) {
2472
4167
  case "amenity":
2473
- return import_lodash4.default.isNull(isClickable) ? true : isClickable;
4168
+ return import_lodash17.default.isNull(isClickable) ? true : isClickable;
2474
4169
  case "occupant":
2475
4170
  return true;
2476
4171
  default:
@@ -2488,24 +4183,24 @@ var getLocationByFeature = (feature2) => {
2488
4183
  }
2489
4184
  };
2490
4185
  var getRelatedLocationsByOccupant = (feature2) => {
2491
- const kiosks = import_lodash4.default.get(feature2, "properties.kiosks", []);
2492
- const units = import_lodash4.default.get(feature2, "properties.units", []);
4186
+ const kiosks = import_lodash17.default.get(feature2, "properties.kiosks", []);
4187
+ const units = import_lodash17.default.get(feature2, "properties.units", []);
2493
4188
  return [...kiosks, ...units];
2494
4189
  };
2495
4190
  var getRelatedLocationsByAmenity = (feature2) => {
2496
- const units = import_lodash4.default.get(feature2, "properties.units", []);
4191
+ const units = import_lodash17.default.get(feature2, "properties.units", []);
2497
4192
  if (units.length === 0) return [feature2];
2498
4193
  return units.filter((unit) => {
2499
- const unitCategory = import_lodash4.default.get(unit, "properties.category");
4194
+ const unitCategory = import_lodash17.default.get(unit, "properties.category");
2500
4195
  return !EXCEPT_AMENITY_LOCATION_CATEGORIES.includes(unitCategory);
2501
4196
  });
2502
4197
  };
2503
4198
  var getRelatedLocationIdsByFeature = (feature2) => {
2504
4199
  switch (feature2?.feature_type) {
2505
4200
  case "amenity":
2506
- return getRelatedLocationsByAmenity(feature2).map((v2) => v2?.id);
4201
+ return getRelatedLocationsByAmenity(feature2).map((v) => v?.id);
2507
4202
  case "occupant":
2508
- return getRelatedLocationsByOccupant(feature2).map((v2) => v2?.id);
4203
+ return getRelatedLocationsByOccupant(feature2).map((v) => v?.id);
2509
4204
  default:
2510
4205
  return [];
2511
4206
  }
@@ -2522,8 +4217,8 @@ var getRelatedLocationsByFeature = (feature2) => {
2522
4217
  };
2523
4218
  var getOrdinalByLocationId = (locationId, feature2) => {
2524
4219
  if (!feature2) return null;
2525
- const mainUnit = import_lodash4.default.get(feature2, "properties.unit");
2526
- const mainKiosk = import_lodash4.default.get(feature2, "properties.kiosk");
4220
+ const mainUnit = import_lodash17.default.get(feature2, "properties.unit");
4221
+ const mainKiosk = import_lodash17.default.get(feature2, "properties.kiosk");
2527
4222
  const relatedLocations = getRelatedLocationsByFeature(feature2);
2528
4223
  const allLocations = [mainUnit, mainKiosk, ...relatedLocations].filter(
2529
4224
  Boolean
@@ -2531,7 +4226,7 @@ var getOrdinalByLocationId = (locationId, feature2) => {
2531
4226
  const targetLocation = allLocations.find(
2532
4227
  (location) => location.id === locationId
2533
4228
  );
2534
- return targetLocation ? import_lodash4.default.get(targetLocation, "properties.level.properties.ordinal") || import_lodash4.default.get(targetLocation, "properties.ordinal") : null;
4229
+ return targetLocation ? import_lodash17.default.get(targetLocation, "properties.level.properties.ordinal") || import_lodash17.default.get(targetLocation, "properties.ordinal") : null;
2535
4230
  };
2536
4231
 
2537
4232
  // src/IndoorMap/utils/math.ts
@@ -2544,140 +4239,16 @@ var getBearingBetweenPoints = (origin, destination) => {
2544
4239
  return Math.floor(radToDegree(theta));
2545
4240
  };
2546
4241
  var getSuitablyValueBetweenBearings = (newBearing, currentBearing) => {
2547
- const difference = Math.abs(newBearing - currentBearing);
2548
- if (difference > 180)
4242
+ const difference2 = Math.abs(newBearing - currentBearing);
4243
+ if (difference2 > 180)
2549
4244
  return newBearing > 0 ? newBearing - 360 : newBearing + 360;
2550
4245
  return newBearing;
2551
4246
  };
2552
4247
 
2553
4248
  // src/IndoorMap/camera/CameraManager.ts
2554
4249
  var import_maptalks5 = require("maptalks");
2555
-
2556
- // ../../node_modules/@turf/meta/dist/esm/index.js
2557
- function coordEach(geojson, callback, excludeWrapCoord) {
2558
- if (geojson === null) return;
2559
- var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
2560
- for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
2561
- geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
2562
- isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
2563
- stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
2564
- for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
2565
- var multiFeatureIndex = 0;
2566
- var geometryIndex = 0;
2567
- geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
2568
- if (geometry === null) continue;
2569
- coords = geometry.coordinates;
2570
- var geomType = geometry.type;
2571
- wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
2572
- switch (geomType) {
2573
- case null:
2574
- break;
2575
- case "Point":
2576
- if (callback(
2577
- coords,
2578
- coordIndex,
2579
- featureIndex,
2580
- multiFeatureIndex,
2581
- geometryIndex
2582
- ) === false)
2583
- return false;
2584
- coordIndex++;
2585
- multiFeatureIndex++;
2586
- break;
2587
- case "LineString":
2588
- case "MultiPoint":
2589
- for (j = 0; j < coords.length; j++) {
2590
- if (callback(
2591
- coords[j],
2592
- coordIndex,
2593
- featureIndex,
2594
- multiFeatureIndex,
2595
- geometryIndex
2596
- ) === false)
2597
- return false;
2598
- coordIndex++;
2599
- if (geomType === "MultiPoint") multiFeatureIndex++;
2600
- }
2601
- if (geomType === "LineString") multiFeatureIndex++;
2602
- break;
2603
- case "Polygon":
2604
- case "MultiLineString":
2605
- for (j = 0; j < coords.length; j++) {
2606
- for (k = 0; k < coords[j].length - wrapShrink; k++) {
2607
- if (callback(
2608
- coords[j][k],
2609
- coordIndex,
2610
- featureIndex,
2611
- multiFeatureIndex,
2612
- geometryIndex
2613
- ) === false)
2614
- return false;
2615
- coordIndex++;
2616
- }
2617
- if (geomType === "MultiLineString") multiFeatureIndex++;
2618
- if (geomType === "Polygon") geometryIndex++;
2619
- }
2620
- if (geomType === "Polygon") multiFeatureIndex++;
2621
- break;
2622
- case "MultiPolygon":
2623
- for (j = 0; j < coords.length; j++) {
2624
- geometryIndex = 0;
2625
- for (k = 0; k < coords[j].length; k++) {
2626
- for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
2627
- if (callback(
2628
- coords[j][k][l],
2629
- coordIndex,
2630
- featureIndex,
2631
- multiFeatureIndex,
2632
- geometryIndex
2633
- ) === false)
2634
- return false;
2635
- coordIndex++;
2636
- }
2637
- geometryIndex++;
2638
- }
2639
- multiFeatureIndex++;
2640
- }
2641
- break;
2642
- case "GeometryCollection":
2643
- for (j = 0; j < geometry.geometries.length; j++)
2644
- if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
2645
- return false;
2646
- break;
2647
- default:
2648
- throw new Error("Unknown Geometry Type");
2649
- }
2650
- }
2651
- }
2652
- }
2653
-
2654
- // ../../node_modules/@turf/bbox/dist/esm/index.js
2655
- function bbox(geojson, options = {}) {
2656
- if (geojson.bbox != null && true !== options.recompute) {
2657
- return geojson.bbox;
2658
- }
2659
- const result = [Infinity, Infinity, -Infinity, -Infinity];
2660
- coordEach(geojson, (coord) => {
2661
- if (result[0] > coord[0]) {
2662
- result[0] = coord[0];
2663
- }
2664
- if (result[1] > coord[1]) {
2665
- result[1] = coord[1];
2666
- }
2667
- if (result[2] < coord[0]) {
2668
- result[2] = coord[0];
2669
- }
2670
- if (result[3] < coord[1]) {
2671
- result[3] = coord[1];
2672
- }
2673
- });
2674
- return result;
2675
- }
2676
- var index_default = bbox;
2677
-
2678
- // src/IndoorMap/camera/CameraManager.ts
2679
- var import_transform_scale = __toESM(require("@turf/transform-scale"));
2680
- var import_bbox_polygon = __toESM(require("@turf/bbox-polygon"));
4250
+ var import_transform_scale2 = __toESM(require("@turf/transform-scale"));
4251
+ var import_bbox_polygon2 = __toESM(require("@turf/bbox-polygon"));
2681
4252
  var CameraManager = class {
2682
4253
  map;
2683
4254
  constructor(map, options) {
@@ -2703,7 +4274,7 @@ var CameraManager = class {
2703
4274
  }
2704
4275
  getFeatureExtent = (feature2, scaleFactor = 1) => {
2705
4276
  const [minX, minY, maxX, maxY] = index_default(
2706
- (0, import_transform_scale.default)((0, import_bbox_polygon.default)(index_default(feature2)), scaleFactor)
4277
+ (0, import_transform_scale2.default)((0, import_bbox_polygon2.default)(index_default(feature2)), scaleFactor)
2707
4278
  );
2708
4279
  return new import_maptalks5.Extent(minX, minY, maxX, maxY);
2709
4280
  };
@@ -2740,8 +4311,8 @@ var CameraManager = class {
2740
4311
  };
2741
4312
 
2742
4313
  // src/IndoorMap/renderer/RendererManager.ts
2743
- var import_lodash_es4 = require("lodash-es");
2744
- var import_center3 = require("@turf/center");
4314
+ var import_lodash20 = require("lodash");
4315
+ var import_center12 = require("@turf/center");
2745
4316
  var THREE4 = __toESM(require("three"));
2746
4317
 
2747
4318
  // src/IndoorMap/renderer/3d/Element3DRenderer.ts
@@ -2749,10 +4320,10 @@ var maptalks4 = __toESM(require("maptalks-gl"));
2749
4320
  var THREE = __toESM(require("three"));
2750
4321
  var import_maptalks7 = require("maptalks.three");
2751
4322
  var import_buffer2 = __toESM(require("@turf/buffer"));
2752
- var import_clean_coords = require("@turf/clean-coords");
4323
+ var import_clean_coords2 = require("@turf/clean-coords");
2753
4324
  var import_polygon_to_line = require("@turf/polygon-to-line");
2754
4325
  var import_nearest_point_on_line = require("@turf/nearest-point-on-line");
2755
- var import_length = require("@turf/length");
4326
+ var import_length2 = require("@turf/length");
2756
4327
  var import_along = require("@turf/along");
2757
4328
  var import_point_to_line_distance = require("@turf/point-to-line-distance");
2758
4329
 
@@ -2761,7 +4332,7 @@ var maptalks3 = __toESM(require("maptalks-gl"));
2761
4332
  var import_maptalks6 = require("maptalks.three");
2762
4333
  var import_three5 = require("three");
2763
4334
  var import_d3plus_shape = require("d3plus-shape");
2764
- var import_lodash_es3 = require("lodash-es");
4335
+ var import_lodash18 = require("lodash");
2765
4336
  var OPTIONS3 = {
2766
4337
  // Allowing click through and prevent interaction
2767
4338
  interactive: false,
@@ -2779,9 +4350,9 @@ var defaultFlatLabelOptions = {
2779
4350
  textBaseline: "middle",
2780
4351
  fillStyle: "#000"
2781
4352
  };
2782
- var defaultRectAngleToCalc = (0, import_lodash_es3.range)(-90, 92, 2);
4353
+ var defaultRectAngleToCalc = (0, import_lodash18.range)(-90, 92, 2);
2783
4354
  var getMaterial = (text, flatLabelOptions) => {
2784
- const options = (0, import_lodash_es3.merge)({}, defaultFlatLabelOptions, flatLabelOptions);
4355
+ const options = (0, import_lodash18.merge)({}, defaultFlatLabelOptions, flatLabelOptions);
2785
4356
  const {
2786
4357
  fontSize: initialFontSize,
2787
4358
  fontFamily,
@@ -2834,23 +4405,23 @@ var getMaterial = (text, flatLabelOptions) => {
2834
4405
  const maxWidth = SIZE - 2 * margin;
2835
4406
  texts = wrapText(ctx, text, maxWidth);
2836
4407
  }
2837
- let textWidth = (0, import_lodash_es3.max)(texts.map((text2) => ctx.measureText(text2).width));
4408
+ let textWidth = (0, import_lodash18.max)(texts.map((text2) => ctx.measureText(text2).width));
2838
4409
  let scale3 = 1;
2839
4410
  while (scale3 > 0 && textWidth + 2 * margin > SIZE) {
2840
4411
  scale3 -= scaleStep;
2841
4412
  ctx.font = `${fontWeight} ${scale3 * fontSize}px "${fontFamily}", Arial`;
2842
- textWidth = (0, import_lodash_es3.max)(texts.map((text2) => ctx.measureText(text2).width));
4413
+ textWidth = (0, import_lodash18.max)(texts.map((text2) => ctx.measureText(text2).width));
2843
4414
  }
2844
- const center2 = { x: 0.5 * SIZE, y: 0.5 * SIZE };
4415
+ const center8 = { x: 0.5 * SIZE, y: 0.5 * SIZE };
2845
4416
  if (scale3 > scaleMin) {
2846
4417
  const totalHeight = texts.length * (fontSize * scale3 * lineHeight);
2847
- const startY = center2.y - totalHeight / 2 + fontSize * scale3 * lineHeight * 0.5;
4418
+ const startY = center8.y - totalHeight / 2 + fontSize * scale3 * lineHeight * 0.5;
2848
4419
  texts.forEach((text2, index) => {
2849
4420
  const yOffset = startY + index * (fontSize * scale3 * lineHeight);
2850
4421
  if (strokeStyle && lineWidth) {
2851
- ctx.strokeText(text2, center2.x, yOffset);
4422
+ ctx.strokeText(text2, center8.x, yOffset);
2852
4423
  }
2853
- ctx.fillText(text2, center2.x, yOffset);
4424
+ ctx.fillText(text2, center8.x, yOffset);
2854
4425
  });
2855
4426
  }
2856
4427
  const texture = new import_three5.Texture(canvas);
@@ -2907,7 +4478,7 @@ var GroundLabel = class extends import_maptalks6.BaseObject {
2907
4478
  strokeStyle,
2908
4479
  lineWidth
2909
4480
  });
2910
- const rectAngles = (0, import_lodash_es3.isArray)(angle) ? angle : [angle];
4481
+ const rectAngles = (0, import_lodash18.isArray)(angle) ? angle : [angle];
2911
4482
  material.needsUpdate = true;
2912
4483
  const rect = (0, import_d3plus_shape.largestRect)(bound, {
2913
4484
  cache: true,
@@ -2980,32 +4551,32 @@ var GroundLabel = class extends import_maptalks6.BaseObject {
2980
4551
  return { x: this.#offsetX, y: this.#offsetY };
2981
4552
  }
2982
4553
  set offsetX(value) {
2983
- if ((0, import_lodash_es3.isNumber)(value)) {
4554
+ if ((0, import_lodash18.isNumber)(value)) {
2984
4555
  this.#offsetX = value;
2985
4556
  this.#updatePosition();
2986
4557
  }
2987
4558
  }
2988
4559
  set offsetY(value) {
2989
- if ((0, import_lodash_es3.isNumber)(value)) {
4560
+ if ((0, import_lodash18.isNumber)(value)) {
2990
4561
  this.#offsetY = value;
2991
4562
  this.#updatePosition();
2992
4563
  }
2993
4564
  }
2994
4565
  set angle(newAngle) {
2995
- if ((0, import_lodash_es3.isNumber)(newAngle)) {
4566
+ if ((0, import_lodash18.isNumber)(newAngle)) {
2996
4567
  this.#angle = newAngle;
2997
4568
  this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
2998
4569
  }
2999
4570
  }
3000
4571
  setOffset(offsetX, offsetY) {
3001
- if ((0, import_lodash_es3.isNumber)(offsetX) && (0, import_lodash_es3.isNumber)(offsetY)) {
4572
+ if ((0, import_lodash18.isNumber)(offsetX) && (0, import_lodash18.isNumber)(offsetY)) {
3002
4573
  this.#offsetX = offsetX;
3003
4574
  this.#offsetY = offsetY;
3004
4575
  this.#updatePosition();
3005
4576
  }
3006
4577
  }
3007
4578
  addOffset(deltaX, deltaY) {
3008
- if ((0, import_lodash_es3.isNumber)(deltaX) && (0, import_lodash_es3.isNumber)(deltaY)) {
4579
+ if ((0, import_lodash18.isNumber)(deltaX) && (0, import_lodash18.isNumber)(deltaY)) {
3009
4580
  this.#offsetX += deltaX;
3010
4581
  this.#offsetY += deltaY;
3011
4582
  this.#updatePosition();
@@ -3107,6 +4678,7 @@ var Element3DRenderer = class extends EventTarget {
3107
4678
  threeLayer;
3108
4679
  scene;
3109
4680
  lineMaterial;
4681
+ navigationLineMaterial;
3110
4682
  materialByColorMap;
3111
4683
  // Renderer is Ready
3112
4684
  isReady = false;
@@ -3118,6 +4690,7 @@ var Element3DRenderer = class extends EventTarget {
3118
4690
  this.threeLayer = groupLayer.getLayer("three");
3119
4691
  this.gltfLayer = groupLayer.getLayer("gltf");
3120
4692
  this.lineMaterial = new THREE.LineBasicMaterial({ color: "#000" });
4693
+ this.navigationLineMaterial = new THREE.LineBasicMaterial({ color: "#f00" });
3121
4694
  this.render();
3122
4695
  }
3123
4696
  animation() {
@@ -3233,7 +4806,7 @@ var Element3DRenderer = class extends EventTarget {
3233
4806
  const polygons = unit.geometry.type === "Polygon" ? [unit.geometry.coordinates] : unit.geometry.coordinates;
3234
4807
  return polygons.map((plg) => {
3235
4808
  return plg.map((ring) => {
3236
- const roomWall = (0, import_clean_coords.cleanCoords)((0, import_polygon_to_line.polygonToLine)(polygon([ring])));
4809
+ const roomWall = (0, import_clean_coords2.cleanCoords)((0, import_polygon_to_line.polygonToLine)(polygon([ring])));
3237
4810
  if (openings.length === 0) {
3238
4811
  const color = "#ababab";
3239
4812
  const material = this.getOrCreateMaterialByColor(color);
@@ -3261,7 +4834,7 @@ var Element3DRenderer = class extends EventTarget {
3261
4834
  try {
3262
4835
  const split = (0, import_line_split.default)(roomWall, multiPoint(openingPoints));
3263
4836
  const wallsOnly = split.features.filter((seg) => {
3264
- const mid = (0, import_along.along)(seg, (0, import_length.length)(seg, { units: "meters" }) / 2, { units: "meters" });
4837
+ const mid = (0, import_along.along)(seg, (0, import_length2.length)(seg, { units: "meters" }) / 2, { units: "meters" });
3265
4838
  for (const opening of openings) {
3266
4839
  const dist = (0, import_point_to_line_distance.pointToLineDistance)(mid, opening, { units: "meters" });
3267
4840
  if (dist < 0.05) return false;
@@ -3320,10 +4893,10 @@ var Element3DRenderer = class extends EventTarget {
3320
4893
  this.threeLayer.addMesh(groundLabel);
3321
4894
  return groundLabel;
3322
4895
  }
3323
- async createModel3d(f) {
3324
- const marker = new maptalks4.GLTFMarker(f.properties.center, {
4896
+ async createModel3d(center8, url) {
4897
+ const marker = new maptalks4.GLTFMarker(center8, {
3325
4898
  symbol: {
3326
- url: f.properties.model
4899
+ url
3327
4900
  }
3328
4901
  });
3329
4902
  marker.addTo(this.gltfLayer);
@@ -3382,11 +4955,23 @@ var Element3DRenderer = class extends EventTarget {
3382
4955
  }
3383
4956
  }
3384
4957
  }
4958
+ drawNavigation = (route) => {
4959
+ const lines = [];
4960
+ route.steps.map((step) => {
4961
+ const lineString2 = new maptalks4.LineString(step.path);
4962
+ const line = this.threeLayer.toPath(lineString2, { altitude: 0.2, cornerRadius: 1, width: 1, asynchronous: true }, this.navigationLineMaterial);
4963
+ lines.push(line);
4964
+ });
4965
+ this.threeLayer.addMesh(lines);
4966
+ };
3385
4967
  render() {
3386
4968
  this.threeLayer._needsUpdate = !this.threeLayer._needsUpdate;
3387
4969
  if (this.threeLayer._needsUpdate) {
3388
4970
  this.threeLayer.redraw();
3389
4971
  }
4972
+ if (this.navigationLineMaterial?.map?.offset) {
4973
+ this.navigationLineMaterial.map.offset.x -= 2e-3;
4974
+ }
3390
4975
  requestAnimationFrame(this.render.bind(this));
3391
4976
  }
3392
4977
  };
@@ -3526,6 +5111,8 @@ var Element2DRenderer = class extends EventTarget {
3526
5111
  }
3527
5112
  };
3528
5113
  }
5114
+ drawNavigation(route) {
5115
+ }
3529
5116
  };
3530
5117
 
3531
5118
  // src/IndoorMap/renderer/2d/Marker2DRenderer.ts
@@ -3571,7 +5158,7 @@ var THREE3 = __toESM(require("three"));
3571
5158
  var import_maptalks8 = require("maptalks");
3572
5159
  var THREE2 = __toESM(require("three"));
3573
5160
  var import_maptalks9 = require("maptalks.three");
3574
- var import_lodash5 = require("lodash");
5161
+ var import_lodash19 = require("lodash");
3575
5162
 
3576
5163
  // src/IndoorMap/renderer/utils/interpolateStops.ts
3577
5164
  var interpolateStops = ({ stops }, zoom) => {
@@ -3581,8 +5168,8 @@ var interpolateStops = ({ stops }, zoom) => {
3581
5168
  const [z1, v1] = stops[i];
3582
5169
  const [z2, v2] = stops[i + 1];
3583
5170
  if (zoom >= z1 && zoom <= z2) {
3584
- const t = (zoom - z1) / (z2 - z1);
3585
- return v1 + t * (v2 - v1);
5171
+ const t2 = (zoom - z1) / (z2 - z1);
5172
+ return v1 + t2 * (v2 - v1);
3586
5173
  }
3587
5174
  }
3588
5175
  };
@@ -3666,7 +5253,7 @@ var TextSpriteMarker = class extends import_maptalks9.BaseObject {
3666
5253
  const paragraphs = String(text).split("\n");
3667
5254
  const wrappedLines = [];
3668
5255
  paragraphs.forEach((paragraph) => {
3669
- if ((0, import_lodash5.isNil)(maxWidth) || isNaN(maxWidth)) {
5256
+ if ((0, import_lodash19.isNil)(maxWidth) || isNaN(maxWidth)) {
3670
5257
  wrappedLines.push(paragraph);
3671
5258
  return;
3672
5259
  }
@@ -3727,7 +5314,7 @@ var TextSpriteMarker = class extends import_maptalks9.BaseObject {
3727
5314
  const altitude = (options.altitude || 0) + this.#altitudeOffset;
3728
5315
  const z = layer.altitudeToVector3(altitude, altitude).x;
3729
5316
  const position = layer.coordinateToVector3(this._coordinate, z);
3730
- (0, import_lodash5.set)(this.properties, "default.position", position);
5317
+ (0, import_lodash19.set)(this.properties, "default.position", position);
3731
5318
  this.getObject3d().position.copy(position);
3732
5319
  }
3733
5320
  _animation() {
@@ -3901,478 +5488,11 @@ var angleBetweenLineStrings = (line1, line2) => {
3901
5488
  return Math.atan2(dy, dx);
3902
5489
  };
3903
5490
 
3904
- // ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/util.js
3905
- var epsilon = 11102230246251565e-32;
3906
- var splitter = 134217729;
3907
- var resulterrbound = (3 + 8 * epsilon) * epsilon;
3908
- function sum(elen, e, flen, f, h) {
3909
- let Q, Qnew, hh, bvirt;
3910
- let enow = e[0];
3911
- let fnow = f[0];
3912
- let eindex = 0;
3913
- let findex = 0;
3914
- if (fnow > enow === fnow > -enow) {
3915
- Q = enow;
3916
- enow = e[++eindex];
3917
- } else {
3918
- Q = fnow;
3919
- fnow = f[++findex];
3920
- }
3921
- let hindex = 0;
3922
- if (eindex < elen && findex < flen) {
3923
- if (fnow > enow === fnow > -enow) {
3924
- Qnew = enow + Q;
3925
- hh = Q - (Qnew - enow);
3926
- enow = e[++eindex];
3927
- } else {
3928
- Qnew = fnow + Q;
3929
- hh = Q - (Qnew - fnow);
3930
- fnow = f[++findex];
3931
- }
3932
- Q = Qnew;
3933
- if (hh !== 0) {
3934
- h[hindex++] = hh;
3935
- }
3936
- while (eindex < elen && findex < flen) {
3937
- if (fnow > enow === fnow > -enow) {
3938
- Qnew = Q + enow;
3939
- bvirt = Qnew - Q;
3940
- hh = Q - (Qnew - bvirt) + (enow - bvirt);
3941
- enow = e[++eindex];
3942
- } else {
3943
- Qnew = Q + fnow;
3944
- bvirt = Qnew - Q;
3945
- hh = Q - (Qnew - bvirt) + (fnow - bvirt);
3946
- fnow = f[++findex];
3947
- }
3948
- Q = Qnew;
3949
- if (hh !== 0) {
3950
- h[hindex++] = hh;
3951
- }
3952
- }
3953
- }
3954
- while (eindex < elen) {
3955
- Qnew = Q + enow;
3956
- bvirt = Qnew - Q;
3957
- hh = Q - (Qnew - bvirt) + (enow - bvirt);
3958
- enow = e[++eindex];
3959
- Q = Qnew;
3960
- if (hh !== 0) {
3961
- h[hindex++] = hh;
3962
- }
3963
- }
3964
- while (findex < flen) {
3965
- Qnew = Q + fnow;
3966
- bvirt = Qnew - Q;
3967
- hh = Q - (Qnew - bvirt) + (fnow - bvirt);
3968
- fnow = f[++findex];
3969
- Q = Qnew;
3970
- if (hh !== 0) {
3971
- h[hindex++] = hh;
3972
- }
3973
- }
3974
- if (Q !== 0 || hindex === 0) {
3975
- h[hindex++] = Q;
3976
- }
3977
- return hindex;
3978
- }
3979
- function estimate(elen, e) {
3980
- let Q = e[0];
3981
- for (let i = 1; i < elen; i++) Q += e[i];
3982
- return Q;
3983
- }
3984
- function vec(n) {
3985
- return new Float64Array(n);
3986
- }
3987
-
3988
- // ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/orient2d.js
3989
- var ccwerrboundA = (3 + 16 * epsilon) * epsilon;
3990
- var ccwerrboundB = (2 + 12 * epsilon) * epsilon;
3991
- var ccwerrboundC = (9 + 64 * epsilon) * epsilon * epsilon;
3992
- var B = vec(4);
3993
- var C1 = vec(8);
3994
- var C2 = vec(12);
3995
- var D = vec(16);
3996
- var u = vec(4);
3997
- function orient2dadapt(ax, ay, bx, by, cx, cy, detsum) {
3998
- let acxtail, acytail, bcxtail, bcytail;
3999
- let bvirt, c, ahi, alo, bhi, blo, _i, _j, _0, s1, s0, t1, t0, u32;
4000
- const acx = ax - cx;
4001
- const bcx = bx - cx;
4002
- const acy = ay - cy;
4003
- const bcy = by - cy;
4004
- s1 = acx * bcy;
4005
- c = splitter * acx;
4006
- ahi = c - (c - acx);
4007
- alo = acx - ahi;
4008
- c = splitter * bcy;
4009
- bhi = c - (c - bcy);
4010
- blo = bcy - bhi;
4011
- s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
4012
- t1 = acy * bcx;
4013
- c = splitter * acy;
4014
- ahi = c - (c - acy);
4015
- alo = acy - ahi;
4016
- c = splitter * bcx;
4017
- bhi = c - (c - bcx);
4018
- blo = bcx - bhi;
4019
- t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
4020
- _i = s0 - t0;
4021
- bvirt = s0 - _i;
4022
- B[0] = s0 - (_i + bvirt) + (bvirt - t0);
4023
- _j = s1 + _i;
4024
- bvirt = _j - s1;
4025
- _0 = s1 - (_j - bvirt) + (_i - bvirt);
4026
- _i = _0 - t1;
4027
- bvirt = _0 - _i;
4028
- B[1] = _0 - (_i + bvirt) + (bvirt - t1);
4029
- u32 = _j + _i;
4030
- bvirt = u32 - _j;
4031
- B[2] = _j - (u32 - bvirt) + (_i - bvirt);
4032
- B[3] = u32;
4033
- let det = estimate(4, B);
4034
- let errbound = ccwerrboundB * detsum;
4035
- if (det >= errbound || -det >= errbound) {
4036
- return det;
4037
- }
4038
- bvirt = ax - acx;
4039
- acxtail = ax - (acx + bvirt) + (bvirt - cx);
4040
- bvirt = bx - bcx;
4041
- bcxtail = bx - (bcx + bvirt) + (bvirt - cx);
4042
- bvirt = ay - acy;
4043
- acytail = ay - (acy + bvirt) + (bvirt - cy);
4044
- bvirt = by - bcy;
4045
- bcytail = by - (bcy + bvirt) + (bvirt - cy);
4046
- if (acxtail === 0 && acytail === 0 && bcxtail === 0 && bcytail === 0) {
4047
- return det;
4048
- }
4049
- errbound = ccwerrboundC * detsum + resulterrbound * Math.abs(det);
4050
- det += acx * bcytail + bcy * acxtail - (acy * bcxtail + bcx * acytail);
4051
- if (det >= errbound || -det >= errbound) return det;
4052
- s1 = acxtail * bcy;
4053
- c = splitter * acxtail;
4054
- ahi = c - (c - acxtail);
4055
- alo = acxtail - ahi;
4056
- c = splitter * bcy;
4057
- bhi = c - (c - bcy);
4058
- blo = bcy - bhi;
4059
- s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
4060
- t1 = acytail * bcx;
4061
- c = splitter * acytail;
4062
- ahi = c - (c - acytail);
4063
- alo = acytail - ahi;
4064
- c = splitter * bcx;
4065
- bhi = c - (c - bcx);
4066
- blo = bcx - bhi;
4067
- t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
4068
- _i = s0 - t0;
4069
- bvirt = s0 - _i;
4070
- u[0] = s0 - (_i + bvirt) + (bvirt - t0);
4071
- _j = s1 + _i;
4072
- bvirt = _j - s1;
4073
- _0 = s1 - (_j - bvirt) + (_i - bvirt);
4074
- _i = _0 - t1;
4075
- bvirt = _0 - _i;
4076
- u[1] = _0 - (_i + bvirt) + (bvirt - t1);
4077
- u32 = _j + _i;
4078
- bvirt = u32 - _j;
4079
- u[2] = _j - (u32 - bvirt) + (_i - bvirt);
4080
- u[3] = u32;
4081
- const C1len = sum(4, B, 4, u, C1);
4082
- s1 = acx * bcytail;
4083
- c = splitter * acx;
4084
- ahi = c - (c - acx);
4085
- alo = acx - ahi;
4086
- c = splitter * bcytail;
4087
- bhi = c - (c - bcytail);
4088
- blo = bcytail - bhi;
4089
- s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
4090
- t1 = acy * bcxtail;
4091
- c = splitter * acy;
4092
- ahi = c - (c - acy);
4093
- alo = acy - ahi;
4094
- c = splitter * bcxtail;
4095
- bhi = c - (c - bcxtail);
4096
- blo = bcxtail - bhi;
4097
- t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
4098
- _i = s0 - t0;
4099
- bvirt = s0 - _i;
4100
- u[0] = s0 - (_i + bvirt) + (bvirt - t0);
4101
- _j = s1 + _i;
4102
- bvirt = _j - s1;
4103
- _0 = s1 - (_j - bvirt) + (_i - bvirt);
4104
- _i = _0 - t1;
4105
- bvirt = _0 - _i;
4106
- u[1] = _0 - (_i + bvirt) + (bvirt - t1);
4107
- u32 = _j + _i;
4108
- bvirt = u32 - _j;
4109
- u[2] = _j - (u32 - bvirt) + (_i - bvirt);
4110
- u[3] = u32;
4111
- const C2len = sum(C1len, C1, 4, u, C2);
4112
- s1 = acxtail * bcytail;
4113
- c = splitter * acxtail;
4114
- ahi = c - (c - acxtail);
4115
- alo = acxtail - ahi;
4116
- c = splitter * bcytail;
4117
- bhi = c - (c - bcytail);
4118
- blo = bcytail - bhi;
4119
- s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
4120
- t1 = acytail * bcxtail;
4121
- c = splitter * acytail;
4122
- ahi = c - (c - acytail);
4123
- alo = acytail - ahi;
4124
- c = splitter * bcxtail;
4125
- bhi = c - (c - bcxtail);
4126
- blo = bcxtail - bhi;
4127
- t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
4128
- _i = s0 - t0;
4129
- bvirt = s0 - _i;
4130
- u[0] = s0 - (_i + bvirt) + (bvirt - t0);
4131
- _j = s1 + _i;
4132
- bvirt = _j - s1;
4133
- _0 = s1 - (_j - bvirt) + (_i - bvirt);
4134
- _i = _0 - t1;
4135
- bvirt = _0 - _i;
4136
- u[1] = _0 - (_i + bvirt) + (bvirt - t1);
4137
- u32 = _j + _i;
4138
- bvirt = u32 - _j;
4139
- u[2] = _j - (u32 - bvirt) + (_i - bvirt);
4140
- u[3] = u32;
4141
- const Dlen = sum(C2len, C2, 4, u, D);
4142
- return D[Dlen - 1];
4143
- }
4144
- function orient2d(ax, ay, bx, by, cx, cy) {
4145
- const detleft = (ay - cy) * (bx - cx);
4146
- const detright = (ax - cx) * (by - cy);
4147
- const det = detleft - detright;
4148
- const detsum = Math.abs(detleft + detright);
4149
- if (Math.abs(det) >= ccwerrboundA * detsum) return det;
4150
- return -orient2dadapt(ax, ay, bx, by, cx, cy, detsum);
4151
- }
4152
-
4153
- // ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/orient3d.js
4154
- var o3derrboundA = (7 + 56 * epsilon) * epsilon;
4155
- var o3derrboundB = (3 + 28 * epsilon) * epsilon;
4156
- var o3derrboundC = (26 + 288 * epsilon) * epsilon * epsilon;
4157
- var bc = vec(4);
4158
- var ca = vec(4);
4159
- var ab = vec(4);
4160
- var at_b = vec(4);
4161
- var at_c = vec(4);
4162
- var bt_c = vec(4);
4163
- var bt_a = vec(4);
4164
- var ct_a = vec(4);
4165
- var ct_b = vec(4);
4166
- var bct = vec(8);
4167
- var cat = vec(8);
4168
- var abt = vec(8);
4169
- var u2 = vec(4);
4170
- var _8 = vec(8);
4171
- var _8b = vec(8);
4172
- var _16 = vec(8);
4173
- var _12 = vec(12);
4174
- var fin = vec(192);
4175
- var fin2 = vec(192);
4176
-
4177
- // ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/incircle.js
4178
- var iccerrboundA = (10 + 96 * epsilon) * epsilon;
4179
- var iccerrboundB = (4 + 48 * epsilon) * epsilon;
4180
- var iccerrboundC = (44 + 576 * epsilon) * epsilon * epsilon;
4181
- var bc2 = vec(4);
4182
- var ca2 = vec(4);
4183
- var ab2 = vec(4);
4184
- var aa = vec(4);
4185
- var bb = vec(4);
4186
- var cc = vec(4);
4187
- var u3 = vec(4);
4188
- var v = vec(4);
4189
- var axtbc = vec(8);
4190
- var aytbc = vec(8);
4191
- var bxtca = vec(8);
4192
- var bytca = vec(8);
4193
- var cxtab = vec(8);
4194
- var cytab = vec(8);
4195
- var abt2 = vec(8);
4196
- var bct2 = vec(8);
4197
- var cat2 = vec(8);
4198
- var abtt = vec(4);
4199
- var bctt = vec(4);
4200
- var catt = vec(4);
4201
- var _82 = vec(8);
4202
- var _162 = vec(16);
4203
- var _16b = vec(16);
4204
- var _16c = vec(16);
4205
- var _32 = vec(32);
4206
- var _32b = vec(32);
4207
- var _48 = vec(48);
4208
- var _64 = vec(64);
4209
- var fin3 = vec(1152);
4210
- var fin22 = vec(1152);
4211
-
4212
- // ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/insphere.js
4213
- var isperrboundA = (16 + 224 * epsilon) * epsilon;
4214
- var isperrboundB = (5 + 72 * epsilon) * epsilon;
4215
- var isperrboundC = (71 + 1408 * epsilon) * epsilon * epsilon;
4216
- var ab3 = vec(4);
4217
- var bc3 = vec(4);
4218
- var cd = vec(4);
4219
- var de = vec(4);
4220
- var ea = vec(4);
4221
- var ac = vec(4);
4222
- var bd = vec(4);
4223
- var ce = vec(4);
4224
- var da = vec(4);
4225
- var eb = vec(4);
4226
- var abc = vec(24);
4227
- var bcd = vec(24);
4228
- var cde = vec(24);
4229
- var dea = vec(24);
4230
- var eab = vec(24);
4231
- var abd = vec(24);
4232
- var bce = vec(24);
4233
- var cda = vec(24);
4234
- var deb = vec(24);
4235
- var eac = vec(24);
4236
- var adet = vec(1152);
4237
- var bdet = vec(1152);
4238
- var cdet = vec(1152);
4239
- var ddet = vec(1152);
4240
- var edet = vec(1152);
4241
- var abdet = vec(2304);
4242
- var cddet = vec(2304);
4243
- var cdedet = vec(3456);
4244
- var deter = vec(5760);
4245
- var _83 = vec(8);
4246
- var _8b2 = vec(8);
4247
- var _8c = vec(8);
4248
- var _163 = vec(16);
4249
- var _24 = vec(24);
4250
- var _482 = vec(48);
4251
- var _48b = vec(48);
4252
- var _96 = vec(96);
4253
- var _192 = vec(192);
4254
- var _384x = vec(384);
4255
- var _384y = vec(384);
4256
- var _384z = vec(384);
4257
- var _768 = vec(768);
4258
- var xdet = vec(96);
4259
- var ydet = vec(96);
4260
- var zdet = vec(96);
4261
- var fin4 = vec(1152);
4262
-
4263
- // ../../node_modules/point-in-polygon-hao/dist/esm/index.js
4264
- function pointInPolygon(p, polygon2) {
4265
- var i;
4266
- var ii;
4267
- var k = 0;
4268
- var f;
4269
- var u1;
4270
- var v1;
4271
- var u22;
4272
- var v2;
4273
- var currentP;
4274
- var nextP;
4275
- var x = p[0];
4276
- var y = p[1];
4277
- var numContours = polygon2.length;
4278
- for (i = 0; i < numContours; i++) {
4279
- ii = 0;
4280
- var contour = polygon2[i];
4281
- var contourLen = contour.length - 1;
4282
- currentP = contour[0];
4283
- if (currentP[0] !== contour[contourLen][0] && currentP[1] !== contour[contourLen][1]) {
4284
- throw new Error("First and last coordinates in a ring must be the same");
4285
- }
4286
- u1 = currentP[0] - x;
4287
- v1 = currentP[1] - y;
4288
- for (ii; ii < contourLen; ii++) {
4289
- nextP = contour[ii + 1];
4290
- u22 = nextP[0] - x;
4291
- v2 = nextP[1] - y;
4292
- if (v1 === 0 && v2 === 0) {
4293
- if (u22 <= 0 && u1 >= 0 || u1 <= 0 && u22 >= 0) {
4294
- return 0;
4295
- }
4296
- } else if (v2 >= 0 && v1 <= 0 || v2 <= 0 && v1 >= 0) {
4297
- f = orient2d(u1, u22, v1, v2, 0, 0);
4298
- if (f === 0) {
4299
- return 0;
4300
- }
4301
- if (f > 0 && v2 > 0 && v1 <= 0 || f < 0 && v2 <= 0 && v1 > 0) {
4302
- k++;
4303
- }
4304
- }
4305
- currentP = nextP;
4306
- v1 = v2;
4307
- u1 = u22;
4308
- }
4309
- }
4310
- if (k % 2 === 0) {
4311
- return false;
4312
- }
4313
- return true;
4314
- }
4315
-
4316
- // ../../node_modules/@turf/invariant/dist/esm/index.js
4317
- function getCoord(coord) {
4318
- if (!coord) {
4319
- throw new Error("coord is required");
4320
- }
4321
- if (!Array.isArray(coord)) {
4322
- if (coord.type === "Feature" && coord.geometry !== null && coord.geometry.type === "Point") {
4323
- return [...coord.geometry.coordinates];
4324
- }
4325
- if (coord.type === "Point") {
4326
- return [...coord.coordinates];
4327
- }
4328
- }
4329
- if (Array.isArray(coord) && coord.length >= 2 && !Array.isArray(coord[0]) && !Array.isArray(coord[1])) {
4330
- return [...coord];
4331
- }
4332
- throw new Error("coord must be GeoJSON Point or an Array of numbers");
4333
- }
4334
- function getGeom(geojson) {
4335
- if (geojson.type === "Feature") {
4336
- return geojson.geometry;
4337
- }
4338
- return geojson;
4339
- }
4340
-
4341
- // ../../node_modules/@turf/boolean-point-in-polygon/dist/esm/index.js
4342
- function booleanPointInPolygon(point2, polygon2, options = {}) {
4343
- if (!point2) {
4344
- throw new Error("point is required");
4345
- }
4346
- if (!polygon2) {
4347
- throw new Error("polygon is required");
4348
- }
4349
- const pt = getCoord(point2);
4350
- const geom = getGeom(polygon2);
4351
- const type = geom.type;
4352
- const bbox2 = polygon2.bbox;
4353
- let polys = geom.coordinates;
4354
- if (bbox2 && inBBox(pt, bbox2) === false) {
4355
- return false;
4356
- }
4357
- if (type === "Polygon") {
4358
- polys = [polys];
4359
- }
4360
- let result = false;
4361
- for (var i = 0; i < polys.length; ++i) {
4362
- const polyResult = pointInPolygon(pt, polys[i]);
4363
- if (polyResult === 0) return options.ignoreBoundary ? false : true;
4364
- else if (polyResult) result = true;
4365
- }
4366
- return result;
4367
- }
4368
- function inBBox(pt, bbox2) {
4369
- return bbox2[0] <= pt[0] && bbox2[1] <= pt[1] && bbox2[2] >= pt[0] && bbox2[3] >= pt[1];
4370
- }
4371
-
4372
5491
  // src/IndoorMap/renderer/utils/findUnitOnPoint.ts
5492
+ var import_boolean_point_in_polygon5 = require("@turf/boolean-point-in-polygon");
4373
5493
  var findUnitOnPoint = (units, point2) => {
4374
5494
  try {
4375
- return units.find((unit) => booleanPointInPolygon(point2, polygon(unit.geometry.coordinates)));
5495
+ return units.find((unit) => (0, import_boolean_point_in_polygon5.booleanPointInPolygon)(point2, polygon(unit.geometry.coordinates)));
4376
5496
  } catch (err) {
4377
5497
  return null;
4378
5498
  }
@@ -4421,9 +5541,9 @@ var RendererManager = class extends EventTarget {
4421
5541
  const pos = geom?.attributes?.position?.array;
4422
5542
  if (!pos || pos.length === 0) return;
4423
5543
  for (let i = 0; i < pos.length; i++) {
4424
- const v2 = pos[i];
4425
- if (!Number.isFinite(v2)) {
4426
- bad.push({ mesh: obj, index: i, value: v2 });
5544
+ const v = pos[i];
5545
+ if (!Number.isFinite(v)) {
5546
+ bad.push({ mesh: obj, index: i, value: v });
4427
5547
  break;
4428
5548
  }
4429
5549
  }
@@ -4459,6 +5579,7 @@ var RendererManager = class extends EventTarget {
4459
5579
  options.onRendererReady();
4460
5580
  }
4461
5581
  _this.#createElements();
5582
+ _this.elementRenderer.createModel3d([100.54724407, 13.72699081], "https://s3.venue.in.th/all_park_f95ac5be3c.gltf");
4462
5583
  setTimeout(() => {
4463
5584
  findBadMeshes(scene);
4464
5585
  }, 3e3);
@@ -4476,7 +5597,7 @@ var RendererManager = class extends EventTarget {
4476
5597
  if (this.#isClicked) return;
4477
5598
  this.#isClicked = true;
4478
5599
  const onClickElement = this.#onClickElement;
4479
- if (!(0, import_lodash_es4.isFunction)(onClickElement)) return;
5600
+ if (!(0, import_lodash20.isFunction)(onClickElement)) return;
4480
5601
  this.#onClickElement(e);
4481
5602
  this.#isClicked = false;
4482
5603
  };
@@ -4519,7 +5640,7 @@ var RendererManager = class extends EventTarget {
4519
5640
  populate: true
4520
5641
  });
4521
5642
  units.filter(
4522
- (u4) => !["opentobelow", "escalator", "room"].includes(u4.properties.category)
5643
+ (u) => !["opentobelow", "escalator", "room"].includes(u.properties.category)
4523
5644
  ).forEach((unit) => {
4524
5645
  const element = this.elementRenderer.createGeometry(unit);
4525
5646
  if (element) {
@@ -4527,9 +5648,9 @@ var RendererManager = class extends EventTarget {
4527
5648
  this.addElementsToManager(unit.id, _elements, unit.properties.level.properties.ordinal);
4528
5649
  }
4529
5650
  });
4530
- units.filter((u4) => u4.properties.category === "room").forEach((unit) => {
5651
+ units.filter((u) => u.properties.category === "room").forEach((unit) => {
4531
5652
  const openingRelationships = relationships.filter((r) => r.properties.origin?.id === unit.id || r.properties.destination?.id === unit.id);
4532
- const roomOpenings = (0, import_lodash_es4.compact)(openingRelationships.map((rel) => {
5653
+ const roomOpenings = (0, import_lodash20.compact)(openingRelationships.map((rel) => {
4533
5654
  const openingId = rel?.properties.intermediary[0].id;
4534
5655
  return openings.find((o) => o.id === openingId);
4535
5656
  }));
@@ -4553,7 +5674,7 @@ var RendererManager = class extends EventTarget {
4553
5674
  this.addElementsToManager(kiosk.id, _elements, kiosk.properties.level.properties.ordinal);
4554
5675
  }
4555
5676
  });
4556
- const escalators = units.filter((u4) => u4.properties.category === "escalator");
5677
+ const escalators = units.filter((u) => u.properties.category === "escalator");
4557
5678
  for (const escalator of escalators) {
4558
5679
  try {
4559
5680
  const escalatorRelationships = relationships.filter((r) => (r.properties?.intermediary || []).some((inter) => inter.id === escalator.id));
@@ -4575,7 +5696,7 @@ var RendererManager = class extends EventTarget {
4575
5696
  const thatLevelOpening = bothOpenings.find((opening) => opening.properties.ordinal !== thisOrdinal);
4576
5697
  const angle = 180 * (1 / Math.PI) * angleBetweenLineStrings(thisLevelOpening.geometry.coordinates, thatLevelOpening.geometry.coordinates);
4577
5698
  const direction = thisOrdinal < thatLevelOpening.properties.ordinal ? "up" : "down";
4578
- const escalatorEntryPoint = (0, import_center3.center)(thisLevelOpening).geometry.coordinates;
5699
+ const escalatorEntryPoint = (0, import_center12.center)(thisLevelOpening).geometry.coordinates;
4579
5700
  const element = await this.elementRenderer.createEscalator(escalator, escalatorEntryPoint, { direction, angle });
4580
5701
  if (element) {
4581
5702
  const _elements = Array.isArray(element) ? element : [element];
@@ -4587,8 +5708,8 @@ var RendererManager = class extends EventTarget {
4587
5708
  }
4588
5709
  const groundLabels = await this.#dataClient.filterByType("label");
4589
5710
  for (const label of groundLabels) {
4590
- const center2 = (0, import_center3.center)(polygon(label.geometry.coordinates)).geometry.coordinates;
4591
- const unit = findUnitOnPoint(units, center2);
5711
+ const center8 = (0, import_center12.center)(polygon(label.geometry.coordinates)).geometry.coordinates;
5712
+ const unit = findUnitOnPoint(units, center8);
4592
5713
  if (unit) {
4593
5714
  const element = this.elementRenderer.createGroundLabel(label, unit);
4594
5715
  if (element) {
@@ -4597,12 +5718,6 @@ var RendererManager = class extends EventTarget {
4597
5718
  }
4598
5719
  }
4599
5720
  }
4600
- if (this.options.type === "3D") {
4601
- const model3ds = await this.#dataClient.filterByType("model3d");
4602
- for (const model3d of model3ds) {
4603
- this.elementRenderer.createModel3d(model3d);
4604
- }
4605
- }
4606
5721
  this.changeLevelByOrdinal(this.currentOrdinals);
4607
5722
  this.dispatchEvent(new CustomEvent("renderermanager:elements_created"));
4608
5723
  }
@@ -4617,7 +5732,7 @@ var RendererManager = class extends EventTarget {
4617
5732
  this.markerRenderer.showMarkers(markers, ordinal - baseOrdinal);
4618
5733
  }
4619
5734
  } else {
4620
- const baseOrdinal = Array.isArray(targetOrdinal) ? (0, import_lodash_es4.min)(targetOrdinal) : targetOrdinal;
5735
+ const baseOrdinal = Array.isArray(targetOrdinal) ? (0, import_lodash20.min)(targetOrdinal) : targetOrdinal;
4621
5736
  for (const [ordinal, elements] of this.elementsByOrdinal) {
4622
5737
  const inOrdinal = Array.isArray(targetOrdinal) ? targetOrdinal.includes(ordinal) : ordinal === targetOrdinal;
4623
5738
  if (inOrdinal) {
@@ -4644,7 +5759,7 @@ var RendererManager = class extends EventTarget {
4644
5759
  const elements = elemIds.map((id) => this.elementsMap.get(id)).flat();
4645
5760
  elements.forEach((element) => {
4646
5761
  const controller = this.elementRenderer.createHighlightController(element);
4647
- if (controller && (0, import_lodash_es4.isFunction)(controller.start)) {
5762
+ if (controller && (0, import_lodash20.isFunction)(controller.start)) {
4648
5763
  controller.start();
4649
5764
  this.highlightControllers.push(controller);
4650
5765
  }
@@ -4652,7 +5767,7 @@ var RendererManager = class extends EventTarget {
4652
5767
  };
4653
5768
  clearHighlightElements = () => {
4654
5769
  this.highlightControllers.forEach((controller) => {
4655
- if ((0, import_lodash_es4.isFunction)(controller?.clear)) controller.clear();
5770
+ if ((0, import_lodash20.isFunction)(controller?.clear)) controller.clear();
4656
5771
  });
4657
5772
  };
4658
5773
  /**
@@ -4687,6 +5802,9 @@ var RendererManager = class extends EventTarget {
4687
5802
  this.markerRenderer.removeMarker(marker);
4688
5803
  }
4689
5804
  }
5805
+ drawNavigation(route) {
5806
+ this.elementRenderer.drawNavigation(route);
5807
+ }
4690
5808
  };
4691
5809
 
4692
5810
  // src/IndoorMap/IndoorMap.ts
@@ -4764,7 +5882,7 @@ var IndoorMap = class extends EventTarget {
4764
5882
  };
4765
5883
  constructor(elementId, options) {
4766
5884
  super();
4767
- const combinedOptions = import_lodash6.default.merge({}, defaultOptions, options);
5885
+ const combinedOptions = import_lodash21.default.merge({}, defaultOptions, options);
4768
5886
  this.options = combinedOptions;
4769
5887
  const {
4770
5888
  onMapReady,
@@ -4811,7 +5929,7 @@ var IndoorMap = class extends EventTarget {
4811
5929
  this.dataClient = options.dataClient;
4812
5930
  }
4813
5931
  setOptions(options) {
4814
- const combinedOptions = import_lodash6.default.merge({}, defaultOptions, options);
5932
+ const combinedOptions = import_lodash21.default.merge({}, defaultOptions, options);
4815
5933
  this.options = combinedOptions;
4816
5934
  const maptalksOptions = parseMaptalksOptions(combinedOptions);
4817
5935
  this.map.setOptions(maptalksOptions);
@@ -4821,10 +5939,10 @@ var IndoorMap = class extends EventTarget {
4821
5939
  if (!this.options.camera?.defaultView?.center) {
4822
5940
  this.#dataClient.filterByType("venue").then((venues) => {
4823
5941
  this.#venues = venues;
4824
- const venueCenters = (0, import_center4.default)(featureCollection(venues));
5942
+ const venueCenters = (0, import_center13.default)(featureCollection(venues));
4825
5943
  const [x, y] = venueCenters.geometry.coordinates;
4826
- const center2 = new import_maptalks_gl.Coordinate(x, y);
4827
- this.camera.setView({ center: center2, pitch: 60, zoom: 19 });
5944
+ const center8 = new import_maptalks_gl.Coordinate(x, y);
5945
+ this.camera.setView({ center: center8, pitch: 60, zoom: 19 });
4828
5946
  });
4829
5947
  }
4830
5948
  }
@@ -4837,7 +5955,7 @@ var IndoorMap = class extends EventTarget {
4837
5955
  handleMapClick = ({ coordinate }) => {
4838
5956
  const { x, y } = coordinate;
4839
5957
  console.log(
4840
- `[Coordinates]: x: ${import_lodash6.default.round(x, 8)} y: ${import_lodash6.default.round(
5958
+ `[Coordinates]: x: ${import_lodash21.default.round(x, 8)} y: ${import_lodash21.default.round(
4841
5959
  y,
4842
5960
  8
4843
5961
  )}, [Bearing]: ${this.map.getBearing()}, [Pitch]: ${this.map.getPitch()}`
@@ -4923,7 +6041,7 @@ var IndoorMap = class extends EventTarget {
4923
6041
  if (this.#isClicked) return;
4924
6042
  this.#isClicked = true;
4925
6043
  const onClickElement = this.#onClickElement;
4926
- if (!import_lodash6.default.isFunction(onClickElement)) return;
6044
+ if (!import_lodash21.default.isFunction(onClickElement)) return;
4927
6045
  this.#onClickElement(e);
4928
6046
  this.#isClicked = false;
4929
6047
  };
@@ -4943,16 +6061,16 @@ var IndoorMap = class extends EventTarget {
4943
6061
  for (const feature2 of this.#features) {
4944
6062
  try {
4945
6063
  const { feature_type: featureType, properties, id } = feature2;
4946
- const layerName = import_lodash6.default.get(
6064
+ const layerName = import_lodash21.default.get(
4947
6065
  LAYER_FEATURE_TYPE_OBJ,
4948
6066
  featureType,
4949
6067
  featureType
4950
6068
  );
4951
6069
  const layer = this.map.getLayer(layerName);
4952
6070
  let geometry;
4953
- const category = import_lodash6.default.get(feature2, "properties.category");
4954
- const extrudeConfig = import_lodash6.default.get(this.#mapConfig, "extrude");
4955
- const textMarkerType = import_lodash6.default.get(
6071
+ const category = import_lodash21.default.get(feature2, "properties.category");
6072
+ const extrudeConfig = import_lodash21.default.get(this.#mapConfig, "extrude");
6073
+ const textMarkerType = import_lodash21.default.get(
4956
6074
  this.#mapConfig,
4957
6075
  "text_marker_type",
4958
6076
  "ui-marker"
@@ -4984,7 +6102,7 @@ var IndoorMap = class extends EventTarget {
4984
6102
  case "opening": {
4985
6103
  switch (category) {
4986
6104
  case "emergencyexit":
4987
- const { geometry: geometry2 } = (0, import_center4.default)(feature2);
6105
+ const { geometry: geometry2 } = (0, import_center13.default)(feature2);
4988
6106
  const markerFeature = {
4989
6107
  ...feature2,
4990
6108
  geometry: geometry2
@@ -5067,9 +6185,9 @@ var IndoorMap = class extends EventTarget {
5067
6185
  const mapCenter = this.map.getCenter();
5068
6186
  const result = this.#venues.reduce((closest, venue) => {
5069
6187
  const { display_point: displayPoint } = venue.properties;
5070
- const distance = (0, import_distance.default)(displayPoint, [mapCenter.x, mapCenter.y]);
5071
- if (!closest || distance < closest.distance) {
5072
- return { venueId: venue.id, distance };
6188
+ const distance5 = (0, import_distance6.default)(displayPoint, [mapCenter.x, mapCenter.y]);
6189
+ if (!closest || distance5 < closest.distance) {
6190
+ return { venueId: venue.id, distance: distance5 };
5073
6191
  }
5074
6192
  return closest;
5075
6193
  }, null);
@@ -5119,15 +6237,15 @@ var IndoorMap = class extends EventTarget {
5119
6237
  }
5120
6238
  }
5121
6239
  updateUserLocationSymbolByLocale(locale) {
5122
- const userLocationGeometry = import_lodash6.default.get(
6240
+ const userLocationGeometry = import_lodash21.default.get(
5123
6241
  this.#elements,
5124
6242
  `${USER_LOCATION_ELEMENT_ID}.geometry`
5125
6243
  );
5126
6244
  if (!userLocationGeometry) return;
5127
6245
  const currentSymbol = userLocationGeometry.getSymbol();
5128
6246
  const localeSymbolToUpdate = currentSymbol.map((symbol) => {
5129
- const localeSymbol = import_lodash6.default.get(symbol, `${LOCALE_SYMBOL_KEY}.${locale}`) || import_lodash6.default.get(symbol, `${LOCALE_SYMBOL_KEY}.default`);
5130
- if (!import_lodash6.default.isPlainObject(localeSymbol)) return symbol;
6247
+ const localeSymbol = import_lodash21.default.get(symbol, `${LOCALE_SYMBOL_KEY}.${locale}`) || import_lodash21.default.get(symbol, `${LOCALE_SYMBOL_KEY}.default`);
6248
+ if (!import_lodash21.default.isPlainObject(localeSymbol)) return symbol;
5131
6249
  return {
5132
6250
  ...symbol,
5133
6251
  ...localeSymbol
@@ -5201,14 +6319,14 @@ var IndoorMap = class extends EventTarget {
5201
6319
  * END of User Location
5202
6320
  ****************************/
5203
6321
  showGeometryByElementId = (elementId) => {
5204
- const geometry = import_lodash6.default.get(
6322
+ const geometry = import_lodash21.default.get(
5205
6323
  this.#elements,
5206
6324
  `${elementId}.geometry`
5207
6325
  );
5208
6326
  if (geometry) geometry.show();
5209
6327
  };
5210
6328
  hideGeometryByElementId = (elementId) => {
5211
- const geometry = import_lodash6.default.get(this.#elements, `${elementId}.geometry`);
6329
+ const geometry = import_lodash21.default.get(this.#elements, `${elementId}.geometry`);
5212
6330
  if (geometry) geometry.hide();
5213
6331
  };
5214
6332
  setSpriteMarkersOpacity = (opacity = 1) => {
@@ -5247,7 +6365,7 @@ var IndoorMap = class extends EventTarget {
5247
6365
  * Navigation
5248
6366
  ****************************/
5249
6367
  combineNearbyLineStrings(lineStrings, options = { properties: {}, distance: 3e-4 }) {
5250
- const { properties = {}, distance = 3e-4 } = options || {};
6368
+ const { properties = {}, distance: distance5 = 3e-4 } = options || {};
5251
6369
  const combinedLineStrings = [];
5252
6370
  const accLine = [];
5253
6371
  if (lineStrings.length === 1) return lineStrings;
@@ -5255,14 +6373,14 @@ var IndoorMap = class extends EventTarget {
5255
6373
  const line = lineStrings[i];
5256
6374
  const coords = line.geometry.coordinates;
5257
6375
  const prevLine = lineStrings[i - 1];
5258
- const firstCoord = import_lodash6.default.first(coords);
6376
+ const firstCoord = import_lodash21.default.first(coords);
5259
6377
  const isFirstLine = i === 0;
5260
6378
  if (isFirstLine) {
5261
6379
  accLine.push(...coords);
5262
6380
  continue;
5263
6381
  }
5264
- const prevLastCoord = import_lodash6.default.last(prevLine.geometry.coordinates);
5265
- const isNearby = (0, import_distance.default)(point(firstCoord), point(prevLastCoord)) < distance;
6382
+ const prevLastCoord = import_lodash21.default.last(prevLine.geometry.coordinates);
6383
+ const isNearby = (0, import_distance6.default)(point(firstCoord), point(prevLastCoord)) < distance5;
5266
6384
  if (!isNearby) {
5267
6385
  const remainingLines = lineStrings.slice(i);
5268
6386
  const res = this.combineNearbyLineStrings(remainingLines, properties);
@@ -5282,8 +6400,8 @@ var IndoorMap = class extends EventTarget {
5282
6400
  create3DStepPath
5283
6401
  } = this.#styler;
5284
6402
  const routeMarkerLayer = this.map.getLayer(HIGHLIGHT_LAYER_NAME);
5285
- const linesByOrdinal = (0, import_lodash6.default)(stepGeometries).filter(({ geometry }) => geometry.type === "LineString").groupBy("properties.ordinal").value();
5286
- const joinedLines = (0, import_lodash6.default)(linesByOrdinal).reduce((acc, lines, key) => {
6403
+ const linesByOrdinal = (0, import_lodash21.default)(stepGeometries).filter(({ geometry }) => geometry.type === "LineString").groupBy("properties.ordinal").value();
6404
+ const joinedLines = (0, import_lodash21.default)(linesByOrdinal).reduce((acc, lines, key) => {
5287
6405
  const joined = this.combineNearbyLineStrings(lines, {
5288
6406
  properties: { ordinal: +key }
5289
6407
  });
@@ -5311,14 +6429,14 @@ var IndoorMap = class extends EventTarget {
5311
6429
  stepElement = createOriginMarker(stepGeometry).addTo(routeMarkerLayer);
5312
6430
  break;
5313
6431
  case "destination-marker":
5314
- const extrudeConfig = import_lodash6.default.get(this.#mapConfig, "extrude");
6432
+ const extrudeConfig = import_lodash21.default.get(this.#mapConfig, "extrude");
5315
6433
  if (destinationFeature.feature_type === "occupant") {
5316
- const stepId = import_lodash6.default.get(stepGeometry, "id");
6434
+ const stepId = import_lodash21.default.get(stepGeometry, "id");
5317
6435
  const normalizedDestinationFeature = {
5318
6436
  ...destinationFeature,
5319
6437
  id: stepId
5320
6438
  };
5321
- const logoUrl = import_lodash6.default.get(
6439
+ const logoUrl = import_lodash21.default.get(
5322
6440
  normalizedDestinationFeature,
5323
6441
  "properties.logo.url"
5324
6442
  );
@@ -5363,15 +6481,15 @@ var IndoorMap = class extends EventTarget {
5363
6481
  const routeMarkerLayer = this.map.getLayer(
5364
6482
  HIGHLIGHT_LAYER_NAME
5365
6483
  );
5366
- const originMarkerGeometry = import_lodash6.default.get(
6484
+ const originMarkerGeometry = import_lodash21.default.get(
5367
6485
  this.#elements,
5368
6486
  `${ORIGIN_MARKER_ID}.geometry`
5369
6487
  );
5370
- const destinationMarkerGeometry = import_lodash6.default.get(
6488
+ const destinationMarkerGeometry = import_lodash21.default.get(
5371
6489
  this.#elements,
5372
6490
  `${DESTINATION_MARKER_ID}.geometry`
5373
6491
  );
5374
- const geometriesToRemove = import_lodash6.default.compact([
6492
+ const geometriesToRemove = import_lodash21.default.compact([
5375
6493
  originMarkerGeometry,
5376
6494
  destinationMarkerGeometry
5377
6495
  ]);
@@ -5382,7 +6500,7 @@ var IndoorMap = class extends EventTarget {
5382
6500
  (obj) => !(obj instanceof NavigationPath)
5383
6501
  );
5384
6502
  const objects = this.#navigationGeometries || {};
5385
- import_lodash6.default.forEach(objects, (obj) => {
6503
+ import_lodash21.default.forEach(objects, (obj) => {
5386
6504
  if (!obj) return;
5387
6505
  this.#navigationGeometries[obj.properties.id] = null;
5388
6506
  obj.remove();
@@ -5419,7 +6537,7 @@ var IndoorMap = class extends EventTarget {
5419
6537
  }
5420
6538
  if (this.threeLayer) {
5421
6539
  const currentView = this.camera.getView();
5422
- const objectOpacity = import_lodash6.default.clamp(38 - 2 * currentView.zoom, 0, 1);
6540
+ const objectOpacity = import_lodash21.default.clamp(38 - 2 * currentView.zoom, 0, 1);
5423
6541
  this.#objects.forEach((object) => {
5424
6542
  object.getObject3d().traverse((child) => {
5425
6543
  if (child.isMesh) child.material.opacity = objectOpacity;
@@ -5429,7 +6547,7 @@ var IndoorMap = class extends EventTarget {
5429
6547
  });
5430
6548
  if (this.#billboardObjects) {
5431
6549
  this.#billboardObjects.forEach((object) => {
5432
- const objectScale = import_lodash6.default.clamp(
6550
+ const objectScale = import_lodash21.default.clamp(
5433
6551
  20 - 1 * currentView.zoom,
5434
6552
  1,
5435
6553
  1.05
@@ -5438,7 +6556,7 @@ var IndoorMap = class extends EventTarget {
5438
6556
  });
5439
6557
  }
5440
6558
  if (this.#isLayersFadingOnZoom) {
5441
- const layerOpacity = import_lodash6.default.clamp(1 - objectOpacity, 0, 1);
6559
+ const layerOpacity = import_lodash21.default.clamp(1 - objectOpacity, 0, 1);
5442
6560
  LAYERS.forEach((layerKey) => {
5443
6561
  const layer = this.map.getLayer(layerKey);
5444
6562
  if (layer) layer.setOpacity(layerOpacity);
@@ -5468,6 +6586,7 @@ var IndoorMap = class extends EventTarget {
5468
6586
  GEOJSON_FEATURE_TYPES,
5469
6587
  HIGHLIGHT_LAYER_NAME,
5470
6588
  IMDF_FEATURE_TYPES,
6589
+ IMDF_UNIT_CATEGORIES,
5471
6590
  IndoorMap,
5472
6591
  LAST_USER_LOCATION_ELEMENT_ID_PREFIX,
5473
6592
  LAYERS,
@@ -5499,11 +6618,13 @@ var IndoorMap = class extends EventTarget {
5499
6618
  getLocationByFeature,
5500
6619
  getLocationByOccupant,
5501
6620
  getLocationIdByFeature,
6621
+ getNavigateClient,
5502
6622
  getOrdinalByLocationId,
5503
6623
  getRelatedLocationIdsByFeature,
5504
6624
  getRelatedLocationsByAmenity,
5505
6625
  getRelatedLocationsByFeature,
5506
6626
  getRelatedLocationsByOccupant,
6627
+ getSearchClient,
5507
6628
  getSuitablyValueBetweenBearings,
5508
6629
  isClickableFeature,
5509
6630
  isValidCoordinate,