bruce-cesium 4.5.6 → 4.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/bruce-cesium.es5.js +1396 -1089
  2. package/dist/bruce-cesium.es5.js.map +1 -1
  3. package/dist/bruce-cesium.umd.js +1402 -1097
  4. package/dist/bruce-cesium.umd.js.map +1 -1
  5. package/dist/lib/bruce-cesium.js +6 -5
  6. package/dist/lib/bruce-cesium.js.map +1 -1
  7. package/dist/lib/viewer/viewer-utils.js +10 -4
  8. package/dist/lib/viewer/viewer-utils.js.map +1 -1
  9. package/dist/lib/widgets/controls-view-bar/widget-control-view-bar-fullscreen.js +53 -0
  10. package/dist/lib/widgets/controls-view-bar/widget-control-view-bar-fullscreen.js.map +1 -0
  11. package/dist/lib/widgets/{widget-searchbar.js → controls-view-bar/widget-control-view-bar-search.js} +71 -67
  12. package/dist/lib/widgets/controls-view-bar/widget-control-view-bar-search.js.map +1 -0
  13. package/dist/lib/widgets/controls-view-bar/widget-control-view-bar.js +59 -0
  14. package/dist/lib/widgets/controls-view-bar/widget-control-view-bar.js.map +1 -0
  15. package/dist/lib/widgets/{left-panel-tabs → tabs-left-panel}/widget-left-panel-tab-bookmarks.js.map +1 -1
  16. package/dist/lib/widgets/{left-panel-tabs → tabs-left-panel}/widget-left-panel-tab.js.map +1 -1
  17. package/dist/lib/widgets/widget-left-panel.js +1 -1
  18. package/dist/lib/widgets/widget-view-bar.js +231 -0
  19. package/dist/lib/widgets/widget-view-bar.js.map +1 -0
  20. package/dist/types/bruce-cesium.d.ts +6 -5
  21. package/dist/types/viewer/viewer-utils.d.ts +1 -0
  22. package/dist/types/widgets/controls-view-bar/widget-control-view-bar-fullscreen.d.ts +10 -0
  23. package/dist/types/widgets/{widget-searchbar.d.ts → controls-view-bar/widget-control-view-bar-search.d.ts} +6 -5
  24. package/dist/types/widgets/controls-view-bar/widget-control-view-bar.d.ts +23 -0
  25. package/dist/types/widgets/widget-view-bar.d.ts +37 -0
  26. package/package.json +1 -1
  27. package/dist/lib/widgets/widget-searchbar.js.map +0 -1
  28. /package/dist/lib/widgets/{left-panel-tabs → tabs-left-panel}/widget-left-panel-tab-bookmarks.js +0 -0
  29. /package/dist/lib/widgets/{left-panel-tabs → tabs-left-panel}/widget-left-panel-tab.js +0 -0
  30. /package/dist/types/widgets/{left-panel-tabs → tabs-left-panel}/widget-left-panel-tab-bookmarks.d.ts +0 -0
  31. /package/dist/types/widgets/{left-panel-tabs → tabs-left-panel}/widget-left-panel-tab.d.ts +0 -0
@@ -1,6 +1,6 @@
1
- import { BruceEvent, Cartes, Entity as Entity$1, Carto, Geometry, MathUtils, LRUCache, Api, Calculator, ClientFile, EntityTag, EntityType, ObjectUtils, Style, ProjectViewTile, DelayQueue, EntityLod, Bounds, ZoomControl, EntityRelationType, ENVIRONMENT, EntityHistoricData, Tileset, EntityCoords, EntitySource, MenuItem, EntityRelation, ProgramKey, ProjectView, ProjectViewBookmark, Camera, ProjectViewLegacyTile, Session, EntityAttribute, EntityAttachment, EntityAttachmentType, AbstractApi } from 'bruce-models';
1
+ import { BruceEvent, Cartes, Entity as Entity$1, Carto, Geometry, MathUtils, LRUCache, Api, Calculator, ClientFile, EntityTag, EntityType, ObjectUtils, Style, ProjectViewTile, DelayQueue, EntityLod, Bounds, ZoomControl, EntityRelationType, ENVIRONMENT, EntityHistoricData, Tileset, EntityCoords, EntitySource, MenuItem, EntityRelation, ProgramKey, ProjectView, ProjectViewBookmark, Camera, ProjectViewLegacyTile, AbstractApi, EntityAttribute, EntityAttachment, EntityAttachmentType, Session } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, JulianDate, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, Entity, DistanceDisplayCondition, HorizontalOrigin, VerticalOrigin, ConstantProperty, ConstantPositionProperty, ClassificationType, ArcType, CornerType, ShadowMode, Primitive, Cesium3DTileFeature, ColorBlendMode, HeadingPitchRoll, Transforms, Model, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, SceneMode, GeoJsonDataSource, Cesium3DTileColorBlendMode, HeadingPitchRange, Cesium3DTileStyle, Ion, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, NearFarScalar, EllipsoidTerrainProvider, CesiumInspector, defined, ClockRange, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, PolygonPipeline, Cesium3DTileset, Matrix4, Matrix3, IonResource, EllipsoidGeodesic, sampleTerrainMostDetailed, BoundingSphere, GeometryInstance, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, Quaternion, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Intersect } from 'cesium';
3
+ import { Cartographic, JulianDate, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, ClassificationType, Entity, ArcType, CornerType, ShadowMode, ConstantProperty, ConstantPositionProperty, HorizontalOrigin, VerticalOrigin, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, ColorBlendMode, HeadingPitchRoll, Transforms, Model, DistanceDisplayCondition, SceneMode, Primitive, Cesium3DTileFeature, GeoJsonDataSource, Cesium3DTileColorBlendMode, HeadingPitchRange, Cesium3DTileStyle, Ion, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, NearFarScalar, EllipsoidTerrainProvider, CesiumInspector, defined, ClockRange, PolygonPipeline, Cesium3DTileset, Matrix4, Matrix3, IonResource, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, BoundingSphere, GeometryInstance, EllipsoidGeodesic, sampleTerrainMostDetailed, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, Quaternion, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Intersect, Fullscreen } from 'cesium';
4
4
 
5
5
  /*! *****************************************************************************
6
6
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -26228,483 +26228,427 @@ var WidgetCursorBar = /** @class */ (function (_super) {
26228
26228
  return WidgetCursorBar;
26229
26229
  }(Widget.AWidget));
26230
26230
 
26231
- var ESearchType;
26232
- (function (ESearchType) {
26233
- ESearchType["CesiumAddress"] = "CESIUM_ADDRESS";
26234
- ESearchType["LatLon"] = "LATLON";
26235
- })(ESearchType || (ESearchType = {}));
26236
- function isLatLon(text) {
26237
- var parts = text.split(",");
26238
- if (parts.length !== 2 && parts.length !== 3) {
26231
+ var EMode;
26232
+ (function (EMode) {
26233
+ EMode["ShowImportant"] = "IMP";
26234
+ EMode["ShowAll"] = "ALL";
26235
+ EMode["ShowAvailable"] = "AV";
26236
+ EMode["ShowImportantAndAvailable"] = "IMP_AV";
26237
+ })(EMode || (EMode = {}));
26238
+ var OPEN_STORAGE_KEY = "EntityViewSummary_open_";
26239
+ var EXCLUDED_PROPERTIES = ["Bruce", "geometry", "position", "boundaries"];
26240
+ function isAttributeImportant(mode, entity, path, field) {
26241
+ if (path.length && EXCLUDED_PROPERTIES.includes(path[0])) {
26239
26242
  return false;
26240
26243
  }
26241
- var lat = parseFloat(parts[0]);
26242
- var lon = parseFloat(parts[1]);
26243
- if (isNaN(lat) || isNaN(lon)) {
26244
- return false;
26244
+ if (mode === EMode.ShowAvailable || mode === EMode.ShowImportantAndAvailable) {
26245
+ var value = Entity$1.GetValue({
26246
+ entity: entity,
26247
+ path: path
26248
+ });
26249
+ var hasValue = value || value == 0;
26250
+ if (mode === EMode.ShowAvailable) {
26251
+ return hasValue;
26252
+ }
26253
+ if (!hasValue) {
26254
+ return false;
26255
+ }
26245
26256
  }
26246
- return true;
26257
+ if (field.IsImportant || mode === EMode.ShowAll) {
26258
+ return true;
26259
+ }
26260
+ if (field.Type === EntityAttribute.EType.Structure) {
26261
+ return field.Structure.some(function (field) { return isAttributeImportant(mode, entity, path, field); });
26262
+ }
26263
+ return false;
26264
+ }
26265
+ function digAttributes(mode, entity, structure, path) {
26266
+ var attributes = [];
26267
+ for (var i = 0; i < structure.length; i++) {
26268
+ var field = structure[i];
26269
+ var fieldPath = [].concat(path);
26270
+ fieldPath.push(field.Key);
26271
+ if (!isAttributeImportant(mode, entity, fieldPath, field)) {
26272
+ continue;
26273
+ }
26274
+ if (field.Type === EntityAttribute.EType.Structure) {
26275
+ var dug = digAttributes(mode, entity, field.Structure, fieldPath);
26276
+ attributes = attributes.concat(dug);
26277
+ }
26278
+ else {
26279
+ attributes.push(fieldPath);
26280
+ }
26281
+ }
26282
+ return attributes;
26283
+ }
26284
+ function gatherAttributes(mode, entity, type) {
26285
+ var _a, _b;
26286
+ var schema = (_b = (_a = type.DataSchema) === null || _a === void 0 ? void 0 : _a.Structure) !== null && _b !== void 0 ? _b : [];
26287
+ schema = [].concat(schema);
26288
+ Object.keys(entity).forEach(function (key) {
26289
+ if (!schema.find(function (field) { return (field === null || field === void 0 ? void 0 : field.Key) == key; })) {
26290
+ schema.push({
26291
+ Key: key,
26292
+ Name: key,
26293
+ Type: EntityAttribute.EType.String,
26294
+ IsImportant: false,
26295
+ IsIndexed: false,
26296
+ Structure: []
26297
+ });
26298
+ }
26299
+ });
26300
+ return digAttributes(mode, entity, schema, []);
26301
+ }
26302
+ function digTypeItem(path, structure) {
26303
+ var key = path[0];
26304
+ var field = structure.find(function (field) { return field.Key === key; });
26305
+ if (!field) {
26306
+ return null;
26307
+ }
26308
+ if (path.length === 1) {
26309
+ return field;
26310
+ }
26311
+ if (field.Type === EntityAttribute.EType.Structure) {
26312
+ return digTypeItem(path.slice(1), field.Structure);
26313
+ }
26314
+ return null;
26315
+ }
26316
+ function groupAttributes(paths, attributes) {
26317
+ var groups = [];
26318
+ var _loop_1 = function (i) {
26319
+ var path = paths[i];
26320
+ var groupPath = path.slice(0, path.length - 1);
26321
+ var groupAttr = digTypeItem(groupPath, attributes);
26322
+ if (!groupAttr) {
26323
+ groupAttr = {
26324
+ Key: "ROOT"
26325
+ };
26326
+ }
26327
+ var group = groups.find(function (group) { return group.group.Key === groupAttr.Key; });
26328
+ if (group) {
26329
+ group.attributes.push(path);
26330
+ }
26331
+ else {
26332
+ var isOpen = localStorage.getItem(OPEN_STORAGE_KEY + groupAttr.Key);
26333
+ if (isOpen == null) {
26334
+ var DEFAULT_CLOSED = [
26335
+ "Bruce",
26336
+ "location",
26337
+ "boundaries",
26338
+ "transform"
26339
+ ];
26340
+ isOpen = path.length ? DEFAULT_CLOSED.includes(path[0]) ? "false" : "true" : "true";
26341
+ }
26342
+ groups.push({
26343
+ group: groupAttr,
26344
+ attributes: [path],
26345
+ open: isOpen != "false"
26346
+ });
26347
+ }
26348
+ };
26349
+ for (var i = 0; i < paths.length; i++) {
26350
+ _loop_1(i);
26351
+ }
26352
+ return groups;
26247
26353
  }
26248
- var WidgetSearchBar = /** @class */ (function (_super) {
26249
- __extends(WidgetSearchBar, _super);
26250
- function WidgetSearchBar(params) {
26354
+ var WidgetInfoView = /** @class */ (function (_super) {
26355
+ __extends(WidgetInfoView, _super);
26356
+ function WidgetInfoView(params) {
26251
26357
  var _this = _super.call(this, params) || this;
26252
- _this.STYLESHEET_ID = "nextspace-searchbar-stylesheet";
26253
- _this._cApi = new AbstractApi({});
26358
+ _this.STYLESHEET_ID = "nextspace-info-view-stylesheet";
26254
26359
  _this._generateStyles();
26255
26360
  _this._generateElement();
26361
+ _this._updateRemoval = _this._manager.VisualsRegister.OnUpdate.Subscribe(function (data) {
26362
+ if (data.type == "UPDATE" || data.type == "DESELECT_ALL") {
26363
+ _this._updateInfoView();
26364
+ }
26365
+ });
26256
26366
  return _this;
26257
26367
  }
26258
- WidgetSearchBar.prototype.Dispose = function () {
26368
+ WidgetInfoView.prototype.Dispose = function () {
26259
26369
  _super.prototype.Dispose.call(this);
26370
+ this._updateRemoval();
26260
26371
  };
26261
- WidgetSearchBar.prototype._generateStyles = function () {
26372
+ WidgetInfoView.prototype._generateStyles = function () {
26262
26373
  if (document.getElementById(this.STYLESHEET_ID)) {
26263
26374
  return;
26264
26375
  }
26265
26376
  var style = document.createElement("style");
26266
26377
  style.id = this.STYLESHEET_ID;
26267
- style.innerHTML = "\n .NextspaceSearchBar {\n position: absolute;\n z-index: 1;\n top: 10px;\n right: 10px;\n display: flex;\n box-sizing: border-box;\n box-shadow: 0 0 1px rgba(18,22,25,.24),0 18px 36px -4px rgba(18,22,25,.6);\n background: #21272a;\n border-radius: 9px;\n height: 48px;\n padding-left: 2px;\n padding-right: 2px;\n font-family: sans-serif;\n }\n\n .NextspaceSearchBar * {\n box-sizing: border-box;\n }\n\n .NextspaceSearchBar[is-opened=\"true\"] .NextspaceSearchBarContent {\n display: flex;\n width: 260px;\n }\n\n .NextspaceSearchBarToggle {\n align-items: center;\n border-radius: 0;\n border-radius: 9px 0 0 9px;\n color: #fff;\n cursor: pointer;\n display: flex;\n flex-shrink: 0;\n font-size: 18px;\n height: 100%;\n justify-content: center;\n transition: .3s ease;\n width: 46px;\n }\n\n .NextspaceSearchBarToggle >svg {\n transition: .3s ease;\n }\n\n .NextspaceSearchBarToggle >svg:hover {\n -webkit-transform: scale(1.2);\n transform: scale(1.2);\n }\n\n .NextspaceSearchBarContent {\n flex-grow: 0;\n flex-shrink: 0;\n overflow: hidden;\n transition: .3s ease;\n width: 0;\n }\n\n .NextspaceSearchBarContent >input {\n background: transparent;\n border: none;\n color: #fff;\n font-size: 15px;\n height: 100%;\n outline: none;\n padding: 0 8px;\n width: 100%;\n }\n\n .NextspaceSearchBarResults {\n background-color: #21272a;\n border-radius: 0 0 6px 6px;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n padding: 12px 8px 8px;\n position: absolute;\n top: calc(100% - 4px);\n width: 100%;\n left: 0;\n z-index: 1;\n }\n\n .NextspaceSearchBarResultsItem {\n align-items: center;\n color: #fff;\n cursor: pointer;\n display: flex;\n height: 30px;\n transition: .3s ease;\n font-size: 13px;\n }\n\n .NextspaceSearchBarResultsItem:hover .NextspaceSearchBarResultsItemIcon {\n -webkit-transform: scale(1.05);\n transform: scale(1.05);\n }\n\n .NextspaceSearchBarResultsItemIcon {\n align-items: center;\n display: flex;\n flex-grow: 0;\n flex-shrink: 0;\n justify-content: center;\n margin-right: 5px;\n width: 25px;\n }\n\n .NextspaceSearchBarResultsItemTip {\n flex-grow: 1;\n flex-shrink: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: 50px;\n font-size: 15px;\n }\n\n .NextspaceSearchBarResultsWarning {\n height: 30px;\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n font-size: 15px;\n }\n ";
26378
+ style.innerHTML = "\n .NextspaceInfoView {\n width: 430px;\n right: 10px;\n top: 66px;\n height: max-content;\n max-height: calc(100% - 320px);\n min-height: 50px;\n align-items: center;\n -webkit-backdrop-filter: blur(20px);\n backdrop-filter: blur(20px);\n background: rgba(33,39,42,.8);\n border-radius: 9px;\n box-shadow: 0 0 1px rgba(18,22,25,.36),0 18px 36px -4px rgba(18,22,25,.36);\n display: flex;\n flex-direction: column;\n flex-shrink: 1;\n opacity: 0;\n position: absolute;\n z-index: 1;\n transition: opacity .3s ease,-webkit-transform .1s;\n transition: opacity .3s ease,transform .1s;\n transition: opacity .3s ease,transform .1s,-webkit-transform .1s;\n font-family: Arial;\n }\n\n .NextspaceInfoView * {\n box-sizing: border-box;\n }\n\n .NextspaceInfoViewTopLeftButtons {\n left: 12px;\n top: 5px;\n align-items: center;\n display: flex;\n position: absolute;\n z-index: 1;\n }\n\n .NextspaceInfoViewTopRightButtons {\n right: 12px;\n top: 5px;\n align-items: center;\n display: flex;\n position: absolute;\n z-index: 1;\n }\n\n .NextspaceInfoViewIconButton {\n align-items: center;\n display: flex;\n flex-grow: 0;\n flex-shrink: 0;\n height: 30px;\n justify-content: center;\n margin-right: 8px;\n min-height: 0;\n min-width: 0;\n position: relative;\n width: 30px;\n font-size: 1.5rem;\n padding: 8px;\n border-radius: 50%;\n overflow: visible;\n color: rgba(0, 0, 0, 0.54);\n transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\n appearance: none;\n text-decoration: none;\n text-align: center;\n background-color: transparent;\n outline: 0px;\n border: 0px none;\n margin: 0px;\n margin-right: 0px;\n cursor: pointer;\n user-select: none;\n -moz-box-pack: center;\n -moz-box-align: center;\n }\n\n .NextspaceInfoViewIconButton:hover {\n opacity: .9;\n transition: opacity .3s ease;\n background-color: rgba(0, 0, 0, 0.04);\n }\n\n .NextspaceInfoViewIconButton svg {\n max-height: 24px;\n max-width: 24px;\n flex-shrink: 0;\n }\n\n .NextspaceInfoViewContent {\n align-items: flex-start;\n color: #fff;\n display: flex;\n flex-direction: column;\n flex-grow: 1;\n flex-shrink: 1;\n margin-top: 12px;\n overflow: auto;\n padding: 25px;\n width: 100%;\n }\n\n .NextspaceInfoViewScrollBox {\n flex-grow: 1;\n flex-shrink: 1;\n overflow-y: auto;\n width: 100%;\n }\n\n .NextspaceInfoViewName {\n font-family: Arial;\n font-style: normal;\n font-weight: 400;\n text-align: center;\n width: 100%;\n color: #40c4ff;\n font-size: 13px;\n letter-spacing: .01em;\n line-height: 16px;\n margin-bottom: 5px;\n }\n\n .NextspaceInfoViewType {\n font-family: Arial;\n font-style: normal;\n font-weight: 400;\n text-align: center;\n width: 100%;\n color: #c1c7cd;\n font-size: 10px;\n letter-spacing: .05em;\n line-height: 10px;\n margin-bottom: 12px;\n -webkit-user-select: none;\n user-select: none;\n }\n\n .NextspaceInfoViewTitle {\n color: #f2f4f8;\n font-family: Arial;\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n margin-right: auto;\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n user-select: none;\n margin-top: 20px;\n margin-bottom: 10px;\n }\n\n .NextspaceInfoViewSummary {\n display: flex;\n flex-direction: column;\n flex-grow: 1;\n flex-shrink: 1;\n }\n\n .NextspaceAttributesGroup {\n display: flex;\n flex-direction: column;\n }\n\n .NextspaceAttributesGroup[is-opened=\"false\"] .NextspaceAttribute {\n display: none;\n }\n\n .NextspaceAttributesGroupToggle {\n align-items: center;\n background-color: #343a3f;\n border: 1px solid #343a3f;\n border-radius: 5px;\n cursor: pointer;\n display: flex;\n height: 35px;\n margin-bottom: 3px;\n overflow: hidden;\n padding-left: 12px;\n text-overflow: ellipsis;\n white-space: nowrap;\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n user-select: none;\n font-size: 12px;\n }\n\n .NextspaceAttributesGroupToggleIcon {\n align-items: center;\n display: flex;\n height: 20px;\n justify-content: center;\n margin-left: auto;\n margin-right: 8px;\n width: 20px;\n cursor: pointer;\n white-space: nowrap;\n }\n\n .NextspaceAttributesGroup[is-opened=\"false\"] .NextspaceAttributesGroupToggleIconOpened {\n display: none;\n }\n\n .NextspaceAttributesGroup[is-opened=\"true\"] .NextspaceAttributesGroupToggleIconOpened {\n display: block;\n }\n\n .NextspaceAttributesGroup[is-opened=\"false\"] .NextspaceAttributesGroupToggleIconClosed {\n display: block;\n }\n\n .NextspaceAttributesGroup[is-opened=\"true\"] .NextspaceAttributesGroupToggleIconClosed {\n display: none;\n }\n\n .NextspaceAttribute {\n align-items: center;\n display: flex;\n flex-direction: row;\n flex-grow: 1;\n }\n\n .NextspaceAttributeInput {\n align-items: center;\n background-color: #121619;\n border: 1px solid #434343;\n border-radius: 5px;\n display: flex;\n height: 35px;\n margin-bottom: 3px;\n width: 100%;\n }\n\n .NextspaceAttributeInputLabel {\n border-right: 1px solid #434343;\n flex-grow: .8;\n flex-shrink: 1;\n margin-right: 8px;\n overflow: hidden;\n padding-left: 8px;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: 90px;\n font-size: 12px;\n }\n\n .NextspaceAttributeInputValue {\n background-color: transparent;\n border: 1px solid transparent;\n color: #fff;\n flex-grow: 1;\n flex-shrink: 1;\n height: 100%;\n padding-left: 2px;\n text-align: left;\n width: 120px;\n cursor: default;\n opacity: .6;\n outline: none;\n padding: .5rem .75rem;\n border-radius: .375rem;\n font-size: 12px;\n }\n\n .NextspaceDefaultImageContainer {\n align-items: center;\n border-radius: 5px;\n display: flex;\n flex-direction: column;\n flex-grow: 0;\n flex-shrink: 1;\n height: 170px;\n overflow: hidden;\n position: relative;\n width: 100%;\n background-color: rgba(33, 39, 42, 0.8);\n margin-bottom: 20px;\n }\n\n .NextspaceDefaultImage {\n background-position: 50%;\n background-repeat: no-repeat;\n background-size: cover;\n height: 100%;\n width: 100%;\n user-select: none;\n }\n ";
26268
26379
  document.head.appendChild(style);
26269
26380
  };
26270
- WidgetSearchBar.prototype._generateElement = function () {
26381
+ WidgetInfoView.prototype._generateElement = function () {
26271
26382
  var _this = this;
26272
26383
  var element = document.createElement("div");
26273
- element.className = "NextspaceSearchBar";
26274
- element.setAttribute("is-opened", "false");
26275
- var toggle = document.createElement("div");
26276
- toggle.className = "NextspaceSearchBarToggle";
26277
- toggle.innerHTML = "\n <svg class=\"\" width=\"32\" height=\"32\" viewBox=\"0 0 32 32\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M14.3283 6C9.73857 6 6 9.73857 6 14.3283C6 18.918 9.73857 22.6566 14.3283 22.6566C16.3242 22.6566 18.1571 21.9479 19.5937 20.7714L24.5663 25.7439C24.643 25.8239 24.7349 25.8877 24.8366 25.9316C24.9383 25.9756 25.0478 25.9988 25.1586 26C25.2694 26.0011 25.3793 25.9801 25.4819 25.9382C25.5845 25.8963 25.6777 25.8344 25.756 25.756C25.8344 25.6777 25.8963 25.5845 25.9382 25.4819C25.9801 25.3793 26.0011 25.2694 26 25.1586C25.9988 25.0478 25.9756 24.9383 25.9316 24.8366C25.8877 24.7349 25.8239 24.643 25.7439 24.5663L20.7714 19.5937C21.9479 18.1571 22.6566 16.3242 22.6566 14.3283C22.6566 9.73857 18.918 6 14.3283 6ZM14.3283 7.66566C18.0178 7.66566 20.9909 10.6388 20.9909 14.3283C20.9909 18.0178 18.0178 20.9909 14.3283 20.9909C10.6388 20.9909 7.66566 18.0178 7.66566 14.3283C7.66566 10.6388 10.6388 7.66566 14.3283 7.66566Z\" fill=\"white\"></path></svg>\n ";
26278
- toggle.onclick = function () {
26279
- var _a, _b;
26280
- if (element.getAttribute("is-opened") === "true") {
26281
- element.setAttribute("is-opened", "false");
26282
- _this._hideResults();
26283
- }
26284
- else {
26285
- element.setAttribute("is-opened", "true");
26286
- // Show prior results.
26287
- if (_this._results.innerHTML) {
26288
- element.style.borderRadius = "9px 9px 0 0";
26289
- _this._results.style.display = "flex";
26290
- }
26291
- // Focus input.
26292
- (_b = (_a = content.querySelector("input")) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
26293
- }
26294
- };
26295
- element.appendChild(toggle);
26384
+ element.className = "NextspaceInfoView";
26385
+ element.style.display = "none";
26386
+ var topLeftButtons = document.createElement("div");
26387
+ topLeftButtons.className = "NextspaceInfoViewTopLeftButtons";
26388
+ topLeftButtons.innerHTML = "\n <button title=\"Fly to entity\" class=\"NextspaceInfoViewIconButton\">\n <svg width=\"22\" height=\"22\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M20.5926 2.12617L2.49072 12.5694C1.78383 12.9756 1.87366 13.9597 2.57664 14.2566L6.72815 15.9984L17.9486 6.10975C18.1634 5.91838 18.468 6.21129 18.2844 6.4339L8.87616 17.8964V21.0403C8.87616 21.962 9.98921 22.3252 10.536 21.6574L13.016 18.6385L17.8822 20.6771C18.4367 20.9115 19.0694 20.5639 19.171 19.9663L21.9829 3.09473C22.1157 2.30583 21.2682 1.73563 20.5926 2.12617Z\" fill=\"white\"></path></svg>\n </button>\n ";
26389
+ element.appendChild(topLeftButtons);
26390
+ var topRightButtons = document.createElement("div");
26391
+ topRightButtons.className = "NextspaceInfoViewTopRightButtons";
26392
+ topRightButtons.innerHTML = "\n <button title=\"Close\" class=\"NextspaceInfoViewIconButton\">\n <svg class=\"\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M18.3002 5.70973C17.9102 5.31973 17.2802 5.31973 16.8902 5.70973L12.0002 10.5897L7.11022 5.69973C6.72022 5.30973 6.09021 5.30973 5.70021 5.69973C5.31021 6.08973 5.31021 6.71973 5.70021 7.10973L10.5902 11.9997L5.70021 16.8897C5.31021 17.2797 5.31021 17.9097 5.70021 18.2997C6.09021 18.6897 6.72022 18.6897 7.11022 18.2997L12.0002 13.4097L16.8902 18.2997C17.2802 18.6897 17.9102 18.6897 18.3002 18.2997C18.6902 17.9097 18.6902 17.2797 18.3002 16.8897L13.4102 11.9997L18.3002 7.10973C18.6802 6.72973 18.6802 6.08973 18.3002 5.70973Z\" fill=\"white\"></path></svg>\n </button>\n ";
26393
+ element.appendChild(topRightButtons);
26394
+ var flyToButt = topLeftButtons.querySelector("button");
26395
+ flyToButt.addEventListener("click", function () {
26396
+ _this._clickFlyTo();
26397
+ });
26398
+ this._flyTo = flyToButt;
26399
+ var closeButt = topRightButtons.querySelector("button");
26400
+ closeButt.addEventListener("click", function () {
26401
+ _this._manager.VisualsRegister.ClearSelected();
26402
+ });
26296
26403
  var content = document.createElement("div");
26297
- content.className = "NextspaceSearchBarContent";
26298
- content.innerHTML = "\n <input placeholder=\"address\"/>\n ";
26404
+ content.className = "NextspaceInfoViewContent";
26299
26405
  element.appendChild(content);
26300
- var input = content.querySelector("input");
26301
- var searchTimeout = null;
26302
- var counter = 0;
26303
- input.onkeyup = function (e) {
26304
- var _a;
26305
- var value = (_a = e.currentTarget) === null || _a === void 0 ? void 0 : _a.value;
26306
- if (!value || value.length < 3) {
26307
- return;
26308
- }
26309
- counter += 1;
26310
- var curCounter = counter;
26311
- _this._displayLoading();
26312
- clearTimeout(searchTimeout);
26313
- searchTimeout = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
26314
- var searchData, e_1;
26315
- return __generator(this, function (_a) {
26316
- switch (_a.label) {
26317
- case 0:
26318
- _a.trys.push([0, 2, , 3]);
26319
- return [4 /*yield*/, this._doSearch(value)];
26320
- case 1:
26321
- searchData = _a.sent();
26322
- if (curCounter !== counter) {
26323
- return [2 /*return*/];
26324
- }
26325
- this._displayResults(searchData);
26326
- return [3 /*break*/, 3];
26327
- case 2:
26328
- e_1 = _a.sent();
26329
- console.error(e_1);
26330
- return [3 /*break*/, 3];
26331
- case 3: return [2 /*return*/];
26332
- }
26333
- });
26334
- }); }, 200);
26335
- };
26336
- var results = document.createElement("div");
26337
- results.className = "NextspaceSearchBarResults";
26338
- element.appendChild(results);
26339
- results.style.display = "none";
26340
- this._results = results;
26406
+ var scrollBox = document.createElement("div");
26407
+ scrollBox.className = "NextspaceInfoViewScrollBox";
26408
+ content.appendChild(scrollBox);
26409
+ var name = document.createElement("div");
26410
+ name.className = "NextspaceInfoViewName";
26411
+ scrollBox.appendChild(name);
26412
+ this._name = name;
26413
+ var type = document.createElement("div");
26414
+ type.className = "NextspaceInfoViewType";
26415
+ scrollBox.appendChild(type);
26416
+ this._type = type;
26417
+ var imageContainer = document.createElement("div");
26418
+ imageContainer.className = "NextspaceDefaultImageContainer";
26419
+ var image = document.createElement("div");
26420
+ image.classList.add("NextspaceDefaultImage");
26421
+ imageContainer.appendChild(image);
26422
+ scrollBox.appendChild(imageContainer);
26423
+ this._imageContainer = imageContainer;
26424
+ this._image = image;
26425
+ var title = document.createElement("div");
26426
+ title.className = "NextspaceInfoViewTitle";
26427
+ title.innerText = "Details";
26428
+ scrollBox.appendChild(title);
26429
+ this._title = title;
26430
+ var summary = document.createElement("div");
26431
+ summary.className = "NextspaceInfoViewSummary";
26432
+ scrollBox.appendChild(summary);
26433
+ this._summary = summary;
26341
26434
  this.Container.appendChild(element);
26342
26435
  this._element = element;
26436
+ this._updateInfoView();
26343
26437
  };
26344
- WidgetSearchBar.prototype._displayResults = function (results) {
26345
- var _this = this;
26346
- this._element.style.borderRadius = "9px 9px 0 0";
26347
- this._results.style.display = "flex";
26348
- if (results === null || results === void 0 ? void 0 : results.length) {
26349
- this._results.innerHTML = "";
26350
- var getIcon_1 = function (result) {
26351
- if (result.type == ESearchType.CesiumAddress) {
26352
- return "\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12 24C18.6274 24 24 18.6274 24 12C24 5.37259 18.6274 0 12 0C5.37258 0 0 5.37259 0 12C0 18.6274 5.37258 24 12 24Z\" fill=\"white\"/>\n <path d=\"M21.6985 10.4272C21.3489 10.4272 20.9994 10.631 20.7373 10.9806L17.4169 15.3786C16.8635 16.1068 16.0771 16.5145 15.2616 16.5145C14.446 16.5145 13.6596 16.1068 13.1062 15.3786L9.78584 10.9806C9.5237 10.631 9.17419 10.4272 8.82467 10.4272C8.47516 10.4272 8.12564 10.631 7.86351 10.9806L4.54312 15.3786C3.98972 16.1068 3.23244 16.5145 2.4169 16.5145C4.10623 20.0971 7.747 22.5728 11.9703 22.5728C17.7955 22.5728 22.5431 17.8543 22.5431 12C22.5431 11.5922 22.514 11.1844 22.4557 10.7767C22.2519 10.5437 21.9897 10.4272 21.6985 10.4272Z\" fill=\"#7A9C49\"/>\n <path d=\"M11.9996 1.42718C6.1744 1.42718 1.42683 6.14562 1.42683 12C1.42683 12.932 1.57246 13.8349 1.77634 14.6796C1.98022 14.8252 2.18411 14.9126 2.41712 14.9126C2.76663 14.9126 3.11615 14.7087 3.37828 14.3592L6.69867 9.96116C7.25207 9.233 8.03848 8.82523 8.85401 8.82523C9.66955 8.82523 10.456 9.233 11.0094 9.96116L14.2132 14.1845L14.3589 14.3592C14.621 14.7087 14.9705 14.8835 15.2909 14.9126C15.6404 14.9126 15.9608 14.7087 16.2229 14.3592L16.3686 14.1845L19.5725 9.96116C20.1259 9.233 20.9123 8.82523 21.7278 8.82523C21.8443 8.82523 21.9899 8.82524 22.1064 8.85436C20.7666 4.54368 16.7472 1.42718 11.9996 1.42718V1.42718ZM15.5239 8.12621C14.9123 8.12621 14.4171 7.63105 14.4171 7.0194C14.4171 6.40775 14.9123 5.91261 15.5239 5.91261C16.1356 5.91261 16.6307 6.40775 16.6307 7.0194C16.6307 7.63105 16.1356 8.12621 15.5239 8.12621Z\" fill=\"#6DABE4\"/>\n </svg>\n ";
26353
- }
26354
- return "\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M6 20H18C18.55 20 19 20.45 19 21C19 21.55 18.55 22 18 22H6C5.45 22 5 21.55 5 21C5 20.45 5.45 20 6 20ZM12 7C10.9 7 10 7.9 10 9C10 10.1 10.9 11 12 11C13.1 11 14 10.1 14 9C14 7.9 13.1 7 12 7ZM12 2C15.27 2 19 4.46 19 9.15C19 12.13 16.87 15.27 12.61 18.54C12.25 18.82 11.75 18.82 11.39 18.54C7.13 15.26 5 12.13 5 9.15C5 4.46 8.73 2 12 2Z\" fill=\"white\"/>\n </svg>\n ";
26355
- };
26356
- results.forEach(function (result) {
26357
- var resultElement = document.createElement("div");
26358
- resultElement.className = "NextspaceSearchBarResultsItem";
26359
- resultElement.innerHTML = "\n <div class=\"NextspaceSearchBarResultsItemIcon\">\n ".concat(getIcon_1(result), "\n </div>\n <div class=\"NextspaceSearchBarResultsItemTip\">\n ").concat(result.tip, "\n </div>\n ");
26360
- resultElement.onclick = function () {
26361
- _this._clickResult(result);
26362
- };
26363
- _this._results.appendChild(resultElement);
26364
- });
26365
- }
26366
- else {
26367
- this._results.innerHTML = "\n <div class=\"NextspaceSearchBarResultsWarning\">No results found...</div>\n ";
26368
- }
26369
- };
26370
- WidgetSearchBar.prototype._displayLoading = function () {
26371
- this._element.style.borderRadius = "9px 9px 0 0";
26372
- this._results.style.display = "flex";
26373
- this._results.innerHTML = "\n <div class=\"NextspaceSearchBarResultsWarning\">Loading...</div>\n ";
26374
- };
26375
- WidgetSearchBar.prototype._hideResults = function () {
26376
- this._element.style.borderRadius = "9px";
26377
- this._results.style.display = "none";
26378
- };
26379
- WidgetSearchBar.prototype._cesiumAutoComplete = function (text) {
26438
+ WidgetInfoView.prototype._clickFlyTo = function () {
26380
26439
  return __awaiter(this, void 0, void 0, function () {
26381
- var token;
26440
+ var entityId, pos3d;
26382
26441
  return __generator(this, function (_a) {
26383
- token = Ion.defaultAccessToken;
26384
- return [2 /*return*/, this._cApi.get("https://api.cesium.com/v1/geocode/autocomplete?text=".concat(encodeURI(text), "&access_token=").concat(token))];
26442
+ switch (_a.label) {
26443
+ case 0:
26444
+ entityId = this._lastSelectedId;
26445
+ if (!entityId) {
26446
+ return [2 /*return*/];
26447
+ }
26448
+ return [4 /*yield*/, EntityUtils.GetPosAsync({
26449
+ api: this._apiGetters.GetBruceApi(),
26450
+ entityId: entityId,
26451
+ viewer: this._viewer,
26452
+ returnHeightRef: HeightReference.NONE,
26453
+ recordHeightRef: HeightReference.NONE,
26454
+ visualRegister: this._manager.VisualsRegister
26455
+ })];
26456
+ case 1:
26457
+ pos3d = _a.sent();
26458
+ if (!(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) return [3 /*break*/, 3];
26459
+ return [4 /*yield*/, DrawingUtils.RaisePos3d(this._viewer, pos3d, 15)];
26460
+ case 2:
26461
+ pos3d = _a.sent();
26462
+ this._viewer.camera.flyTo({
26463
+ destination: pos3d,
26464
+ duration: 1,
26465
+ orientation: {
26466
+ heading: 0,
26467
+ pitch: -Math$1.PI_OVER_TWO,
26468
+ roll: 0
26469
+ }
26470
+ });
26471
+ return [3 /*break*/, 4];
26472
+ case 3:
26473
+ alert("Could not get position of entity.");
26474
+ _a.label = 4;
26475
+ case 4: return [2 /*return*/];
26476
+ }
26385
26477
  });
26386
26478
  });
26387
26479
  };
26388
- WidgetSearchBar.prototype._doSearch = function (text) {
26389
- var _a;
26480
+ WidgetInfoView.prototype._updateInfoView = function () {
26481
+ var _a, _b, _c;
26390
26482
  return __awaiter(this, void 0, void 0, function () {
26391
- var result, parts, lat, lon, alt, res, MAX_ITEMS, added, _loop_1, i, state_1, e_2;
26392
- return __generator(this, function (_b) {
26393
- switch (_b.label) {
26483
+ var selectedIds, firstId, api, entity, entityType, name_1, data, items, images, defaultImage, url, attributes, groups, _i, groups_1, group, e_1;
26484
+ return __generator(this, function (_d) {
26485
+ switch (_d.label) {
26394
26486
  case 0:
26395
- if (!text || text.length < 3) {
26396
- return [2 /*return*/, []];
26487
+ selectedIds = this._manager.VisualsRegister.GetSelected();
26488
+ if (selectedIds.length <= 0) {
26489
+ this._element.style.display = "none";
26490
+ this._element.style.opacity = "0";
26491
+ return [2 /*return*/];
26397
26492
  }
26398
- result = [];
26399
- if (isLatLon(text)) {
26400
- parts = text.split(",");
26401
- lat = parseFloat(parts[0]);
26402
- lon = parseFloat(parts[1]);
26403
- alt = parts.length > 2 ? parseFloat(parts[2]) : null;
26404
- result.push({
26405
- type: ESearchType.LatLon,
26406
- tip: "Lat Lon Location",
26407
- data: {
26408
- altitude: alt,
26409
- latitude: lat,
26410
- longitude: lon
26411
- }
26412
- });
26413
- return [2 /*return*/, result];
26493
+ this._element.style.display = "flex";
26494
+ this._element.style.opacity = "1";
26495
+ firstId = selectedIds[0];
26496
+ if (this._lastSelectedId == firstId) {
26497
+ return [2 /*return*/];
26414
26498
  }
26415
- if (!Ion.defaultAccessToken) return [3 /*break*/, 5];
26416
- _b.label = 1;
26499
+ this._lastSelectedId = firstId;
26500
+ _d.label = 1;
26417
26501
  case 1:
26418
- _b.trys.push([1, 3, , 4]);
26419
- return [4 /*yield*/, this._cesiumAutoComplete(text)];
26502
+ _d.trys.push([1, 5, , 6]);
26503
+ this._title.style.display = "none";
26504
+ this._flyTo.style.display = "none";
26505
+ this._name.innerText = "Loading...";
26506
+ this._type.innerText = "";
26507
+ this._summary.innerHTML = "";
26508
+ this._imageContainer.style.display = "none";
26509
+ api = this._apiGetters.GetBruceApi();
26510
+ return [4 /*yield*/, Entity$1.Get({
26511
+ entityId: firstId,
26512
+ api: api,
26513
+ migrated: true
26514
+ })];
26420
26515
  case 2:
26421
- res = _b.sent();
26422
- console.log("Cesium search result", res);
26423
- MAX_ITEMS = 5;
26424
- added = 0;
26425
- if (res && res.features) {
26426
- _loop_1 = function (i) {
26427
- var feature = res.features[i];
26428
- if (feature.bbox || feature.geometry) {
26429
- var name_1 = feature.properties.name;
26430
- if (!name_1) {
26431
- name_1 = feature.properties.label;
26432
- }
26433
- if (!name_1) {
26434
- return "continue";
26435
- }
26436
- // We don't want results with the same visual name, even if they have different coordinate data.
26437
- if (result.find(function (x) { return x.type == ESearchType.CesiumAddress && x.tip == name_1; })) {
26438
- return "continue";
26439
- }
26440
- var coords = (_a = feature.geometry) === null || _a === void 0 ? void 0 : _a.coordinates;
26441
- var bbox = feature.bbox;
26442
- if (!coords && !bbox) {
26443
- return "continue";
26444
- }
26445
- result.push({
26446
- type: ESearchType.CesiumAddress,
26447
- tip: name_1,
26448
- data: {
26449
- bbox: bbox,
26450
- location: coords ? {
26451
- altitude: coords[2],
26452
- latitude: coords[1],
26453
- longitude: coords[0]
26454
- } : null
26455
- }
26456
- });
26457
- added += 1;
26458
- if (added >= MAX_ITEMS) {
26459
- return "break";
26460
- }
26461
- }
26462
- };
26463
- for (i = 0; i < res.features.length; i++) {
26464
- state_1 = _loop_1(i);
26465
- if (state_1 === "break")
26466
- break;
26467
- }
26516
+ entity = (_d.sent()).entity;
26517
+ if (!entity) {
26518
+ throw (new Error("Could not get entity."));
26468
26519
  }
26469
- return [3 /*break*/, 4];
26520
+ return [4 /*yield*/, EntityType.Get({
26521
+ entityTypeId: (_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a["EntityType.ID"],
26522
+ api: api
26523
+ })];
26470
26524
  case 3:
26471
- e_2 = _b.sent();
26472
- console.error(e_2);
26473
- return [3 /*break*/, 4];
26474
- case 4: return [3 /*break*/, 6];
26525
+ entityType = (_d.sent()).entityType;
26526
+ name_1 = Entity$1.CalculateName({
26527
+ entity: entity,
26528
+ type: entityType,
26529
+ defaultToId: false
26530
+ });
26531
+ if (!name_1) {
26532
+ name_1 = "Unnamed Entity";
26533
+ }
26534
+ this._title.style.display = "block";
26535
+ this._flyTo.style.display = "flex";
26536
+ this._name.innerText = name_1;
26537
+ this._type.innerText = (entityType === null || entityType === void 0 ? void 0 : entityType.Name) ? entityType.Name : "Unknown type";
26538
+ return [4 /*yield*/, EntityAttachment.GetListByEntityId({
26539
+ entityId: firstId,
26540
+ api: api
26541
+ })];
26542
+ case 4:
26543
+ data = _d.sent();
26544
+ items = data.attachments;
26545
+ images = [].concat(items).sort(function (a, b) { return b.DisplayOrder - a.DisplayOrder; }).filter(function (x) { return x["EntityAttachmentType.ID"] == EntityAttachmentType.EType.Photo; }).reverse();
26546
+ defaultImage = images.length ? images[0] : null;
26547
+ if (defaultImage) {
26548
+ this._imageContainer.style.display = "flex";
26549
+ url = ClientFile.GetUrl({
26550
+ fileId: defaultImage["ClientFile.ID"],
26551
+ api: api,
26552
+ viaCdn: true
26553
+ });
26554
+ this._image.style.backgroundImage = "url(".concat(url, ")");
26555
+ }
26556
+ attributes = gatherAttributes(EMode.ShowAll, entity, entityType);
26557
+ groups = groupAttributes(attributes, (_c = (_b = entityType.DataSchema) === null || _b === void 0 ? void 0 : _b.Structure) !== null && _c !== void 0 ? _c : []);
26558
+ for (_i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
26559
+ group = groups_1[_i];
26560
+ this._generateAttrGroup(entityType, entity, group);
26561
+ }
26562
+ return [3 /*break*/, 6];
26475
26563
  case 5:
26476
- console.warn("No Cesium token set, skipping Cesium address search.");
26477
- _b.label = 6;
26478
- case 6: return [2 /*return*/, result];
26564
+ e_1 = _d.sent();
26565
+ console.error(e_1);
26566
+ this._name.innerText = "";
26567
+ this._summary.innerHTML = "<p>Could not read entity information</p>";
26568
+ return [3 /*break*/, 6];
26569
+ case 6: return [2 /*return*/];
26479
26570
  }
26480
26571
  });
26481
26572
  });
26482
26573
  };
26483
- WidgetSearchBar.prototype._clickResult = function (item) {
26484
- return __awaiter(this, void 0, void 0, function () {
26485
- function zoomToCarto(points) {
26486
- var cartes = points.map(function (x) { var _a; return Cartesian3.fromDegrees(x.longitude, x.latitude, (_a = x.altitude) !== null && _a !== void 0 ? _a : 0); });
26487
- zoomToCartes(cartes);
26574
+ WidgetInfoView.prototype._generateAttrGroup = function (type, entity, group) {
26575
+ var groupDiv = document.createElement("div");
26576
+ groupDiv.className = "NextspaceAttributesGroup";
26577
+ groupDiv.setAttribute("is-opened", group.open ? "true" : "false");
26578
+ if (group.group.Key != "ROOT") {
26579
+ var toggle = document.createElement("div");
26580
+ toggle.className = "NextspaceAttributesGroupToggle";
26581
+ toggle.innerHTML = "\n ".concat(group.group.Key, "\n <div class=\"NextspaceAttributesGroupToggleIcon\">\n <svg class=\"NextspaceAttributesGroupToggleIconOpened\" width=\"16\" height=\"9\" viewBox=\"0 0 16 9\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M15 1L8 8L1 1\" stroke=\"white\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path></svg>\n <svg class=\"NextspaceAttributesGroupToggleIconClosed\" width=\"10\" height=\"17\" viewBox=\"0 0 10 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M8.5 15.5L1.5 8.5L8.5 1.5\" stroke=\"white\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path></svg>\n </div>\n ");
26582
+ toggle.addEventListener("click", function () {
26583
+ var isOpened = groupDiv.getAttribute("is-opened") == "true";
26584
+ groupDiv.setAttribute("is-opened", isOpened ? "false" : "true");
26585
+ localStorage.setItem("".concat(OPEN_STORAGE_KEY).concat(group.group.Key), isOpened ? "false" : "true");
26586
+ });
26587
+ groupDiv.appendChild(toggle);
26588
+ }
26589
+ for (var _i = 0, _a = group.attributes; _i < _a.length; _i++) {
26590
+ var attr = _a[_i];
26591
+ var attrDiv = this._generateAttr(groupDiv, type, entity, attr);
26592
+ if (group.group.Key != "ROOT") {
26593
+ attrDiv.style.marginLeft = "12px";
26488
26594
  }
26489
- var deduplicatePoints, raiseCartesToHeight, zoomToCartes, bbox, point;
26490
- var _this = this;
26491
- return __generator(this, function (_a) {
26492
- deduplicatePoints = function (points) {
26493
- var DIS_TOLERANCE = 0.001;
26494
- var result = [];
26495
- var _loop_2 = function (i) {
26496
- var point_1 = points[i];
26497
- if (result.find(function (x) { return Cartesian3.distance(x, point_1) < DIS_TOLERANCE; })) {
26498
- return "continue";
26499
- }
26500
- result.push(point_1);
26501
- };
26502
- for (var i = 0; i < points.length; i++) {
26503
- _loop_2(i);
26504
- }
26505
- return result;
26506
- };
26507
- raiseCartesToHeight = function (points, minHeight) {
26508
- for (var i = 0; i < points.length; i++) {
26509
- var carto = Cartographic.fromCartesian(points[i]);
26510
- carto.height = Math.max(carto.height, minHeight);
26511
- points[i] = Cartesian3.fromRadians(carto.longitude, carto.latitude, carto.height);
26512
- }
26513
- };
26514
- zoomToCartes = function (points) {
26515
- points = deduplicatePoints(points);
26516
- raiseCartesToHeight(points, 2500);
26517
- var viewer = _this._viewer;
26518
- var orient = {
26519
- heading: Math$1.toRadians(0),
26520
- pitch: Math$1.toRadians(-90),
26521
- roll: 0
26522
- };
26523
- var onComplete = function () {
26524
- viewer.camera.lookAtTransform(Matrix4.IDENTITY);
26525
- };
26526
- if (points.length > 1) {
26527
- var rectangle = Rectangle.fromCartesianArray(points);
26528
- viewer.camera.flyTo({
26529
- destination: rectangle,
26530
- orientation: orient,
26531
- duration: 1,
26532
- complete: onComplete
26533
- });
26534
- }
26535
- else {
26536
- var carto = BoundingSphere.fromPoints(points).center;
26537
- viewer.camera.flyTo({
26538
- destination: carto,
26539
- orientation: orient,
26540
- duration: 1,
26541
- complete: onComplete
26542
- });
26543
- }
26544
- };
26545
- switch (item.type) {
26546
- case ESearchType.CesiumAddress:
26547
- bbox = item.data.bbox;
26548
- if (bbox) {
26549
- zoomToCarto([
26550
- {
26551
- altitude: null,
26552
- latitude: bbox[1],
26553
- longitude: bbox[0]
26554
- },
26555
- {
26556
- altitude: null,
26557
- latitude: bbox[3],
26558
- longitude: bbox[2]
26559
- }
26560
- ]);
26561
- break;
26562
- }
26563
- point = item.data.location;
26564
- if (point) {
26565
- zoomToCarto([point]);
26566
- break;
26567
- }
26568
- break;
26569
- case ESearchType.LatLon:
26570
- zoomToCarto([item.data]);
26571
- break;
26572
- }
26573
- this._element.setAttribute("is-opened", "false");
26574
- this._hideResults();
26575
- return [2 /*return*/];
26576
- });
26577
- });
26595
+ }
26596
+ this._summary.appendChild(groupDiv);
26578
26597
  };
26579
- return WidgetSearchBar;
26580
- }(Widget.AWidget));
26581
-
26582
- var EMode;
26583
- (function (EMode) {
26584
- EMode["ShowImportant"] = "IMP";
26585
- EMode["ShowAll"] = "ALL";
26586
- EMode["ShowAvailable"] = "AV";
26587
- EMode["ShowImportantAndAvailable"] = "IMP_AV";
26588
- })(EMode || (EMode = {}));
26589
- var OPEN_STORAGE_KEY = "EntityViewSummary_open_";
26590
- var EXCLUDED_PROPERTIES = ["Bruce", "geometry", "position", "boundaries"];
26591
- function isAttributeImportant(mode, entity, path, field) {
26592
- if (path.length && EXCLUDED_PROPERTIES.includes(path[0])) {
26593
- return false;
26594
- }
26595
- if (mode === EMode.ShowAvailable || mode === EMode.ShowImportantAndAvailable) {
26598
+ WidgetInfoView.prototype._generateAttr = function (container, type, entity, path) {
26599
+ var _a, _b, _c;
26600
+ var attrDiv = document.createElement("div");
26601
+ attrDiv.className = "NextspaceAttribute";
26602
+ var typeItem = digTypeItem(path, (_b = (_a = type.DataSchema) === null || _a === void 0 ? void 0 : _a.Structure) !== null && _b !== void 0 ? _b : []);
26603
+ var attrType = (_c = typeItem === null || typeItem === void 0 ? void 0 : typeItem.Type) !== null && _c !== void 0 ? _c : EntityAttribute.EType.String;
26604
+ var input = document.createElement("div");
26605
+ input.className = "NextspaceAttributeInput";
26606
+ attrDiv.appendChild(input);
26607
+ var attrName = document.createElement("div");
26608
+ attrName.className = "NextspaceAttributeInputLabel";
26609
+ attrName.innerText = typeItem ? typeItem.Name ? typeItem.Name : typeItem.Key : path[path.length - 1];
26610
+ input.appendChild(attrName);
26596
26611
  var value = Entity$1.GetValue({
26597
26612
  entity: entity,
26598
26613
  path: path
26599
26614
  });
26600
- var hasValue = value || value == 0;
26601
- if (mode === EMode.ShowAvailable) {
26602
- return hasValue;
26603
- }
26604
- if (!hasValue) {
26605
- return false;
26606
- }
26607
- }
26608
- if (field.IsImportant || mode === EMode.ShowAll) {
26609
- return true;
26610
- }
26611
- if (field.Type === EntityAttribute.EType.Structure) {
26612
- return field.Structure.some(function (field) { return isAttributeImportant(mode, entity, path, field); });
26613
- }
26614
- return false;
26615
- }
26616
- function digAttributes(mode, entity, structure, path) {
26617
- var attributes = [];
26618
- for (var i = 0; i < structure.length; i++) {
26619
- var field = structure[i];
26620
- var fieldPath = [].concat(path);
26621
- fieldPath.push(field.Key);
26622
- if (!isAttributeImportant(mode, entity, fieldPath, field)) {
26623
- continue;
26624
- }
26625
- if (field.Type === EntityAttribute.EType.Structure) {
26626
- var dug = digAttributes(mode, entity, field.Structure, fieldPath);
26627
- attributes = attributes.concat(dug);
26628
- }
26629
- else {
26630
- attributes.push(fieldPath);
26615
+ var valueStr = "";
26616
+ if (attrType == EntityAttribute.EType.Boolean) {
26617
+ valueStr = value ? "Yes" : "No";
26631
26618
  }
26632
- }
26633
- return attributes;
26634
- }
26635
- function gatherAttributes(mode, entity, type) {
26636
- var _a, _b;
26637
- var schema = (_b = (_a = type.DataSchema) === null || _a === void 0 ? void 0 : _a.Structure) !== null && _b !== void 0 ? _b : [];
26638
- schema = [].concat(schema);
26639
- Object.keys(entity).forEach(function (key) {
26640
- if (!schema.find(function (field) { return (field === null || field === void 0 ? void 0 : field.Key) == key; })) {
26641
- schema.push({
26642
- Key: key,
26643
- Name: key,
26644
- Type: EntityAttribute.EType.String,
26645
- IsImportant: false,
26646
- IsIndexed: false,
26647
- Structure: []
26648
- });
26619
+ else if (attrType == EntityAttribute.EType.Integer || attrType == EntityAttribute.EType.Double) {
26620
+ valueStr = +value;
26621
+ if (isNaN(valueStr)) {
26622
+ valueStr = 0;
26623
+ }
26649
26624
  }
26650
- });
26651
- return digAttributes(mode, entity, schema, []);
26652
- }
26653
- function digTypeItem(path, structure) {
26654
- var key = path[0];
26655
- var field = structure.find(function (field) { return field.Key === key; });
26656
- if (!field) {
26657
- return null;
26658
- }
26659
- if (path.length === 1) {
26660
- return field;
26661
- }
26662
- if (field.Type === EntityAttribute.EType.Structure) {
26663
- return digTypeItem(path.slice(1), field.Structure);
26664
- }
26665
- return null;
26666
- }
26667
- function groupAttributes(paths, attributes) {
26668
- var groups = [];
26669
- var _loop_1 = function (i) {
26670
- var path = paths[i];
26671
- var groupPath = path.slice(0, path.length - 1);
26672
- var groupAttr = digTypeItem(groupPath, attributes);
26673
- if (!groupAttr) {
26674
- groupAttr = {
26675
- Key: "ROOT"
26676
- };
26625
+ else if (attrType == EntityAttribute.EType.Structure) {
26626
+ valueStr = "<Multiple values>";
26677
26627
  }
26678
- var group = groups.find(function (group) { return group.group.Key === groupAttr.Key; });
26679
- if (group) {
26680
- group.attributes.push(path);
26628
+ else if (attrType == EntityAttribute.EType.Geometry) {
26629
+ valueStr = "<Multiple values>";
26681
26630
  }
26682
26631
  else {
26683
- var isOpen = localStorage.getItem(OPEN_STORAGE_KEY + groupAttr.Key);
26684
- if (isOpen == null) {
26685
- var DEFAULT_CLOSED = [
26686
- "Bruce",
26687
- "location",
26688
- "boundaries",
26689
- "transform"
26690
- ];
26691
- isOpen = path.length ? DEFAULT_CLOSED.includes(path[0]) ? "false" : "true" : "true";
26632
+ if (value && typeof value == "object") {
26633
+ valueStr = "<Multiple values>";
26634
+ }
26635
+ else {
26636
+ valueStr = value ? String(value) : "<No value>";
26692
26637
  }
26693
- groups.push({
26694
- group: groupAttr,
26695
- attributes: [path],
26696
- open: isOpen != "false"
26697
- });
26698
26638
  }
26639
+ var attrValue = document.createElement("input");
26640
+ attrValue.className = "NextspaceAttributeInputValue";
26641
+ attrValue.value = String(valueStr);
26642
+ input.appendChild(attrValue);
26643
+ container.appendChild(attrDiv);
26644
+ return attrDiv;
26699
26645
  };
26700
- for (var i = 0; i < paths.length; i++) {
26701
- _loop_1(i);
26702
- }
26703
- return groups;
26704
- }
26705
- var WidgetInfoView = /** @class */ (function (_super) {
26706
- __extends(WidgetInfoView, _super);
26707
- function WidgetInfoView(params) {
26646
+ return WidgetInfoView;
26647
+ }(Widget.AWidget));
26648
+
26649
+ var WidgetEmbeddedInfoView = /** @class */ (function (_super) {
26650
+ __extends(WidgetEmbeddedInfoView, _super);
26651
+ function WidgetEmbeddedInfoView(params) {
26708
26652
  var _this = _super.call(this, params) || this;
26709
26653
  _this.STYLESHEET_ID = "nextspace-info-view-stylesheet";
26710
26654
  _this._generateStyles();
@@ -26714,766 +26658,1129 @@ var WidgetInfoView = /** @class */ (function (_super) {
26714
26658
  _this._updateInfoView();
26715
26659
  }
26716
26660
  });
26717
- return _this;
26718
- }
26719
- WidgetInfoView.prototype.Dispose = function () {
26720
- _super.prototype.Dispose.call(this);
26721
- this._updateRemoval();
26722
- };
26723
- WidgetInfoView.prototype._generateStyles = function () {
26724
- if (document.getElementById(this.STYLESHEET_ID)) {
26725
- return;
26726
- }
26727
- var style = document.createElement("style");
26728
- style.id = this.STYLESHEET_ID;
26729
- style.innerHTML = "\n .NextspaceInfoView {\n width: 430px;\n right: 10px;\n top: 66px;\n height: max-content;\n max-height: calc(100% - 320px);\n min-height: 50px;\n align-items: center;\n -webkit-backdrop-filter: blur(20px);\n backdrop-filter: blur(20px);\n background: rgba(33,39,42,.8);\n border-radius: 9px;\n box-shadow: 0 0 1px rgba(18,22,25,.36),0 18px 36px -4px rgba(18,22,25,.36);\n display: flex;\n flex-direction: column;\n flex-shrink: 1;\n opacity: 0;\n position: absolute;\n z-index: 1;\n transition: opacity .3s ease,-webkit-transform .1s;\n transition: opacity .3s ease,transform .1s;\n transition: opacity .3s ease,transform .1s,-webkit-transform .1s;\n font-family: Arial;\n }\n\n .NextspaceInfoView * {\n box-sizing: border-box;\n }\n\n .NextspaceInfoViewTopLeftButtons {\n left: 12px;\n top: 5px;\n align-items: center;\n display: flex;\n position: absolute;\n z-index: 1;\n }\n\n .NextspaceInfoViewTopRightButtons {\n right: 12px;\n top: 5px;\n align-items: center;\n display: flex;\n position: absolute;\n z-index: 1;\n }\n\n .NextspaceInfoViewIconButton {\n align-items: center;\n display: flex;\n flex-grow: 0;\n flex-shrink: 0;\n height: 30px;\n justify-content: center;\n margin-right: 8px;\n min-height: 0;\n min-width: 0;\n position: relative;\n width: 30px;\n font-size: 1.5rem;\n padding: 8px;\n border-radius: 50%;\n overflow: visible;\n color: rgba(0, 0, 0, 0.54);\n transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\n appearance: none;\n text-decoration: none;\n text-align: center;\n background-color: transparent;\n outline: 0px;\n border: 0px none;\n margin: 0px;\n margin-right: 0px;\n cursor: pointer;\n user-select: none;\n -moz-box-pack: center;\n -moz-box-align: center;\n }\n\n .NextspaceInfoViewIconButton:hover {\n opacity: .9;\n transition: opacity .3s ease;\n background-color: rgba(0, 0, 0, 0.04);\n }\n\n .NextspaceInfoViewIconButton svg {\n max-height: 24px;\n max-width: 24px;\n flex-shrink: 0;\n }\n\n .NextspaceInfoViewContent {\n align-items: flex-start;\n color: #fff;\n display: flex;\n flex-direction: column;\n flex-grow: 1;\n flex-shrink: 1;\n margin-top: 12px;\n overflow: auto;\n padding: 25px;\n width: 100%;\n }\n\n .NextspaceInfoViewScrollBox {\n flex-grow: 1;\n flex-shrink: 1;\n overflow-y: auto;\n width: 100%;\n }\n\n .NextspaceInfoViewName {\n font-family: Arial;\n font-style: normal;\n font-weight: 400;\n text-align: center;\n width: 100%;\n color: #40c4ff;\n font-size: 13px;\n letter-spacing: .01em;\n line-height: 16px;\n margin-bottom: 5px;\n }\n\n .NextspaceInfoViewType {\n font-family: Arial;\n font-style: normal;\n font-weight: 400;\n text-align: center;\n width: 100%;\n color: #c1c7cd;\n font-size: 10px;\n letter-spacing: .05em;\n line-height: 10px;\n margin-bottom: 12px;\n -webkit-user-select: none;\n user-select: none;\n }\n\n .NextspaceInfoViewTitle {\n color: #f2f4f8;\n font-family: Arial;\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px;\n margin-right: auto;\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n user-select: none;\n margin-top: 20px;\n margin-bottom: 10px;\n }\n\n .NextspaceInfoViewSummary {\n display: flex;\n flex-direction: column;\n flex-grow: 1;\n flex-shrink: 1;\n }\n\n .NextspaceAttributesGroup {\n display: flex;\n flex-direction: column;\n }\n\n .NextspaceAttributesGroup[is-opened=\"false\"] .NextspaceAttribute {\n display: none;\n }\n\n .NextspaceAttributesGroupToggle {\n align-items: center;\n background-color: #343a3f;\n border: 1px solid #343a3f;\n border-radius: 5px;\n cursor: pointer;\n display: flex;\n height: 35px;\n margin-bottom: 3px;\n overflow: hidden;\n padding-left: 12px;\n text-overflow: ellipsis;\n white-space: nowrap;\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n user-select: none;\n font-size: 12px;\n }\n\n .NextspaceAttributesGroupToggleIcon {\n align-items: center;\n display: flex;\n height: 20px;\n justify-content: center;\n margin-left: auto;\n margin-right: 8px;\n width: 20px;\n cursor: pointer;\n white-space: nowrap;\n }\n\n .NextspaceAttributesGroup[is-opened=\"false\"] .NextspaceAttributesGroupToggleIconOpened {\n display: none;\n }\n\n .NextspaceAttributesGroup[is-opened=\"true\"] .NextspaceAttributesGroupToggleIconOpened {\n display: block;\n }\n\n .NextspaceAttributesGroup[is-opened=\"false\"] .NextspaceAttributesGroupToggleIconClosed {\n display: block;\n }\n\n .NextspaceAttributesGroup[is-opened=\"true\"] .NextspaceAttributesGroupToggleIconClosed {\n display: none;\n }\n\n .NextspaceAttribute {\n align-items: center;\n display: flex;\n flex-direction: row;\n flex-grow: 1;\n }\n\n .NextspaceAttributeInput {\n align-items: center;\n background-color: #121619;\n border: 1px solid #434343;\n border-radius: 5px;\n display: flex;\n height: 35px;\n margin-bottom: 3px;\n width: 100%;\n }\n\n .NextspaceAttributeInputLabel {\n border-right: 1px solid #434343;\n flex-grow: .8;\n flex-shrink: 1;\n margin-right: 8px;\n overflow: hidden;\n padding-left: 8px;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: 90px;\n font-size: 12px;\n }\n\n .NextspaceAttributeInputValue {\n background-color: transparent;\n border: 1px solid transparent;\n color: #fff;\n flex-grow: 1;\n flex-shrink: 1;\n height: 100%;\n padding-left: 2px;\n text-align: left;\n width: 120px;\n cursor: default;\n opacity: .6;\n outline: none;\n padding: .5rem .75rem;\n border-radius: .375rem;\n font-size: 12px;\n }\n\n .NextspaceDefaultImageContainer {\n align-items: center;\n border-radius: 5px;\n display: flex;\n flex-direction: column;\n flex-grow: 0;\n flex-shrink: 1;\n height: 170px;\n overflow: hidden;\n position: relative;\n width: 100%;\n background-color: rgba(33, 39, 42, 0.8);\n margin-bottom: 20px;\n }\n\n .NextspaceDefaultImage {\n background-position: 50%;\n background-repeat: no-repeat;\n background-size: cover;\n height: 100%;\n width: 100%;\n user-select: none;\n }\n ";
26730
- document.head.appendChild(style);
26731
- };
26732
- WidgetInfoView.prototype._generateElement = function () {
26733
- var _this = this;
26734
- var element = document.createElement("div");
26735
- element.className = "NextspaceInfoView";
26736
- element.style.display = "none";
26737
- var topLeftButtons = document.createElement("div");
26738
- topLeftButtons.className = "NextspaceInfoViewTopLeftButtons";
26739
- topLeftButtons.innerHTML = "\n <button title=\"Fly to entity\" class=\"NextspaceInfoViewIconButton\">\n <svg width=\"22\" height=\"22\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M20.5926 2.12617L2.49072 12.5694C1.78383 12.9756 1.87366 13.9597 2.57664 14.2566L6.72815 15.9984L17.9486 6.10975C18.1634 5.91838 18.468 6.21129 18.2844 6.4339L8.87616 17.8964V21.0403C8.87616 21.962 9.98921 22.3252 10.536 21.6574L13.016 18.6385L17.8822 20.6771C18.4367 20.9115 19.0694 20.5639 19.171 19.9663L21.9829 3.09473C22.1157 2.30583 21.2682 1.73563 20.5926 2.12617Z\" fill=\"white\"></path></svg>\n </button>\n ";
26740
- element.appendChild(topLeftButtons);
26741
- var topRightButtons = document.createElement("div");
26742
- topRightButtons.className = "NextspaceInfoViewTopRightButtons";
26743
- topRightButtons.innerHTML = "\n <button title=\"Close\" class=\"NextspaceInfoViewIconButton\">\n <svg class=\"\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M18.3002 5.70973C17.9102 5.31973 17.2802 5.31973 16.8902 5.70973L12.0002 10.5897L7.11022 5.69973C6.72022 5.30973 6.09021 5.30973 5.70021 5.69973C5.31021 6.08973 5.31021 6.71973 5.70021 7.10973L10.5902 11.9997L5.70021 16.8897C5.31021 17.2797 5.31021 17.9097 5.70021 18.2997C6.09021 18.6897 6.72022 18.6897 7.11022 18.2997L12.0002 13.4097L16.8902 18.2997C17.2802 18.6897 17.9102 18.6897 18.3002 18.2997C18.6902 17.9097 18.6902 17.2797 18.3002 16.8897L13.4102 11.9997L18.3002 7.10973C18.6802 6.72973 18.6802 6.08973 18.3002 5.70973Z\" fill=\"white\"></path></svg>\n </button>\n ";
26744
- element.appendChild(topRightButtons);
26745
- var flyToButt = topLeftButtons.querySelector("button");
26746
- flyToButt.addEventListener("click", function () {
26747
- _this._clickFlyTo();
26748
- });
26749
- this._flyTo = flyToButt;
26750
- var closeButt = topRightButtons.querySelector("button");
26751
- closeButt.addEventListener("click", function () {
26752
- _this._manager.VisualsRegister.ClearSelected();
26753
- });
26754
- var content = document.createElement("div");
26755
- content.className = "NextspaceInfoViewContent";
26756
- element.appendChild(content);
26757
- var scrollBox = document.createElement("div");
26758
- scrollBox.className = "NextspaceInfoViewScrollBox";
26759
- content.appendChild(scrollBox);
26760
- var name = document.createElement("div");
26761
- name.className = "NextspaceInfoViewName";
26762
- scrollBox.appendChild(name);
26763
- this._name = name;
26764
- var type = document.createElement("div");
26765
- type.className = "NextspaceInfoViewType";
26766
- scrollBox.appendChild(type);
26767
- this._type = type;
26768
- var imageContainer = document.createElement("div");
26769
- imageContainer.className = "NextspaceDefaultImageContainer";
26770
- var image = document.createElement("div");
26771
- image.classList.add("NextspaceDefaultImage");
26772
- imageContainer.appendChild(image);
26773
- scrollBox.appendChild(imageContainer);
26774
- this._imageContainer = imageContainer;
26775
- this._image = image;
26776
- var title = document.createElement("div");
26777
- title.className = "NextspaceInfoViewTitle";
26778
- title.innerText = "Details";
26779
- scrollBox.appendChild(title);
26780
- this._title = title;
26781
- var summary = document.createElement("div");
26782
- summary.className = "NextspaceInfoViewSummary";
26783
- scrollBox.appendChild(summary);
26784
- this._summary = summary;
26661
+ if (window) {
26662
+ var winEvent_1 = null;
26663
+ window.addEventListener("message", winEvent_1 = function (event) {
26664
+ try {
26665
+ var data = (event.data && typeof event.data == "string" && String(event.data).startsWith("{")) ? JSON.parse(event.data) : event.data;
26666
+ if (!data) {
26667
+ return;
26668
+ }
26669
+ var embedId = data.embedId;
26670
+ // Detecting when selection changes within iframe.
26671
+ if (embedId == "info-view") {
26672
+ if (data.action == "select") {
26673
+ _this._manager.VisualsRegister.ClearSelected();
26674
+ _this._manager.VisualsRegister.SetSelected({
26675
+ entityIds: data.selectedIds ? data.selectedIds : [],
26676
+ selected: true
26677
+ });
26678
+ }
26679
+ else if (data.action == "fly-to") {
26680
+ _this._flyTo();
26681
+ }
26682
+ }
26683
+ }
26684
+ catch (e) {
26685
+ console.error(e);
26686
+ }
26687
+ });
26688
+ _this._windowTopRemoval = function () {
26689
+ window.removeEventListener("message", winEvent_1);
26690
+ };
26691
+ }
26692
+ return _this;
26693
+ }
26694
+ WidgetEmbeddedInfoView.prototype.Dispose = function () {
26695
+ var _a;
26696
+ _super.prototype.Dispose.call(this);
26697
+ this._updateRemoval();
26698
+ (_a = this._windowTopRemoval) === null || _a === void 0 ? void 0 : _a.call(this);
26699
+ this._windowTopRemoval = null;
26700
+ };
26701
+ WidgetEmbeddedInfoView.prototype._generateStyles = function () {
26702
+ if (document.getElementById(this.STYLESHEET_ID)) {
26703
+ return;
26704
+ }
26705
+ var style = document.createElement("style");
26706
+ style.id = this.STYLESHEET_ID;
26707
+ style.innerHTML = "\n .NextspaceInfoView {\n width: 500px;\n border-radius: 8px;\n right: 10px;\n top: 66px;\n height: 600px;\n max-height: calc(100% - 320px);\n min-height: 50px;\n align-items: center;\n background: rgba(33,39,42,0.8);\n border-radius: 9px;\n box-shadow: 0 0 1px rgba(18,22,25,.36),0 18px 36px -4px rgba(18,22,25,.36);\n backdrop-filter: blur(20px);\n display: flex;\n flex-direction: column;\n flex-shrink: 1;\n opacity: 0;\n position: absolute;\n z-index: 1;\n transition: opacity .3s ease,-webkit-transform .1s;\n transition: opacity .3s ease,transform .1s;\n transition: opacity .3s ease,transform .1s,-webkit-transform .1s;\n font-family: Arial;\n overflow: hidden;\n }\n\n .NextspaceInfoView * {\n box-sizing: border-box;\n }\n ";
26708
+ document.head.appendChild(style);
26709
+ };
26710
+ WidgetEmbeddedInfoView.prototype._generateElement = function () {
26711
+ var element = document.createElement("div");
26712
+ element.className = "NextspaceInfoView";
26713
+ element.style.display = "none";
26785
26714
  this.Container.appendChild(element);
26786
26715
  this._element = element;
26787
26716
  this._updateInfoView();
26788
26717
  };
26789
- WidgetInfoView.prototype._clickFlyTo = function () {
26718
+ WidgetEmbeddedInfoView.prototype._updateInfoView = function () {
26790
26719
  return __awaiter(this, void 0, void 0, function () {
26791
- var entityId, pos3d;
26720
+ var selectedIds, firstId, url, urlParams, iframe;
26792
26721
  return __generator(this, function (_a) {
26793
- switch (_a.label) {
26794
- case 0:
26795
- entityId = this._lastSelectedId;
26796
- if (!entityId) {
26797
- return [2 /*return*/];
26798
- }
26799
- return [4 /*yield*/, EntityUtils.GetPosAsync({
26800
- api: this._apiGetters.GetBruceApi(),
26801
- entityId: entityId,
26802
- viewer: this._viewer,
26803
- returnHeightRef: HeightReference.NONE,
26804
- recordHeightRef: HeightReference.NONE,
26805
- visualRegister: this._manager.VisualsRegister
26806
- })];
26807
- case 1:
26808
- pos3d = _a.sent();
26809
- if (!(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) return [3 /*break*/, 3];
26810
- return [4 /*yield*/, DrawingUtils.RaisePos3d(this._viewer, pos3d, 15)];
26811
- case 2:
26812
- pos3d = _a.sent();
26813
- this._viewer.camera.flyTo({
26814
- destination: pos3d,
26815
- duration: 1,
26816
- orientation: {
26817
- heading: 0,
26818
- pitch: -Math$1.PI_OVER_TWO,
26819
- roll: 0
26820
- }
26821
- });
26822
- return [3 /*break*/, 4];
26823
- case 3:
26824
- alert("Could not get position of entity.");
26825
- _a.label = 4;
26826
- case 4: return [2 /*return*/];
26722
+ selectedIds = this._manager.VisualsRegister.GetSelected();
26723
+ if (selectedIds.length <= 0) {
26724
+ this._element.style.display = "none";
26725
+ this._element.style.opacity = "0";
26726
+ return [2 /*return*/];
26727
+ }
26728
+ this._element.style.display = "flex";
26729
+ this._element.style.opacity = "1";
26730
+ firstId = selectedIds[0];
26731
+ if (this._lastSelectedId == firstId) {
26732
+ return [2 /*return*/];
26733
+ }
26734
+ this._lastSelectedId = firstId;
26735
+ try {
26736
+ url = "https://embed.nextspace.host/embed";
26737
+ urlParams = new URLSearchParams();
26738
+ urlParams.append("id", "info-view");
26739
+ urlParams.append("entityId", firstId);
26740
+ urlParams.append("sessionId", this._manager.Getters.GetSessionId());
26741
+ urlParams.append("accountId", this._manager.Getters.GetAccountId());
26742
+ urlParams.append("env", this._manager.Getters.GetEnv());
26743
+ urlParams.append("bgStyle", "transparent");
26744
+ urlParams.append("enableFlyTo", "true");
26745
+ iframe = document.createElement("iframe");
26746
+ iframe.src = "".concat(url, "?").concat(urlParams.toString());
26747
+ iframe.style.width = "100%";
26748
+ iframe.style.height = "100%";
26749
+ iframe.style.border = "none";
26750
+ this._element.innerHTML = "";
26751
+ this._element.appendChild(iframe);
26752
+ }
26753
+ catch (e) {
26754
+ console.error(e);
26827
26755
  }
26756
+ return [2 /*return*/];
26828
26757
  });
26829
26758
  });
26830
26759
  };
26831
- WidgetInfoView.prototype._updateInfoView = function () {
26832
- var _a, _b, _c;
26760
+ WidgetEmbeddedInfoView.prototype._flyTo = function () {
26761
+ var _a, _b;
26833
26762
  return __awaiter(this, void 0, void 0, function () {
26834
- var selectedIds, firstId, api, entity, entityType, name_1, data, items, images, defaultImage, url, attributes, groups, _i, groups_1, group, e_1;
26835
- return __generator(this, function (_d) {
26836
- switch (_d.label) {
26763
+ var flew, ids, viewer, location_1, destination, centerCartographic, pos3d, e_1;
26764
+ return __generator(this, function (_c) {
26765
+ switch (_c.label) {
26837
26766
  case 0:
26838
- selectedIds = this._manager.VisualsRegister.GetSelected();
26839
- if (selectedIds.length <= 0) {
26840
- this._element.style.display = "none";
26841
- this._element.style.opacity = "0";
26842
- return [2 /*return*/];
26843
- }
26844
- this._element.style.display = "flex";
26845
- this._element.style.opacity = "1";
26846
- firstId = selectedIds[0];
26847
- if (this._lastSelectedId == firstId) {
26848
- return [2 /*return*/];
26849
- }
26850
- this._lastSelectedId = firstId;
26851
- _d.label = 1;
26767
+ flew = false;
26768
+ _c.label = 1;
26852
26769
  case 1:
26853
- _d.trys.push([1, 5, , 6]);
26854
- this._title.style.display = "none";
26855
- this._flyTo.style.display = "none";
26856
- this._name.innerText = "Loading...";
26857
- this._type.innerText = "";
26858
- this._summary.innerHTML = "";
26859
- this._imageContainer.style.display = "none";
26860
- api = this._apiGetters.GetBruceApi();
26861
- return [4 /*yield*/, Entity$1.Get({
26862
- entityId: firstId,
26863
- api: api,
26864
- migrated: true
26770
+ _c.trys.push([1, 3, , 4]);
26771
+ ids = this._manager.VisualsRegister.GetSelected();
26772
+ viewer = this._manager.Viewer;
26773
+ return [4 /*yield*/, EntityUtils.GetLocation({
26774
+ samples: ids.map(function (id) { return ({
26775
+ entityId: id,
26776
+ returnHeightRef: HeightReference.NONE,
26777
+ heightRef: HeightReference.RELATIVE_TO_GROUND
26778
+ }); }),
26779
+ viewer: viewer,
26780
+ visualRegister: this._manager.VisualsRegister,
26781
+ api: this._manager.Getters.GetBruceApi(),
26782
+ minimumAlt: 5,
26783
+ paddingAlt: 5
26865
26784
  })];
26866
26785
  case 2:
26867
- entity = (_d.sent()).entity;
26868
- if (!entity) {
26869
- throw (new Error("Could not get entity."));
26786
+ location_1 = _c.sent();
26787
+ destination = null;
26788
+ if ((_a = location_1 === null || location_1 === void 0 ? void 0 : location_1.sphere) === null || _a === void 0 ? void 0 : _a.radius) {
26789
+ if (location_1.sphere.radius < 5) {
26790
+ location_1.sphere.radius = 5;
26791
+ }
26792
+ centerCartographic = Cartographic.fromCartesian(location_1.sphere.center);
26793
+ centerCartographic.height += (location_1.sphere.radius * 2);
26794
+ pos3d = Cartesian3.fromRadians(centerCartographic.longitude, centerCartographic.latitude, centerCartographic.height);
26795
+ destination = pos3d;
26870
26796
  }
26871
- return [4 /*yield*/, EntityType.Get({
26872
- entityTypeId: (_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a["EntityType.ID"],
26873
- api: api
26874
- })];
26875
- case 3:
26876
- entityType = (_d.sent()).entityType;
26877
- name_1 = Entity$1.CalculateName({
26878
- entity: entity,
26879
- type: entityType,
26880
- defaultToId: false
26881
- });
26882
- if (!name_1) {
26883
- name_1 = "Unnamed Entity";
26797
+ else if (location_1 === null || location_1 === void 0 ? void 0 : location_1.rectangle) {
26798
+ destination = location_1.rectangle;
26884
26799
  }
26885
- this._title.style.display = "block";
26886
- this._flyTo.style.display = "flex";
26887
- this._name.innerText = name_1;
26888
- this._type.innerText = (entityType === null || entityType === void 0 ? void 0 : entityType.Name) ? entityType.Name : "Unknown type";
26889
- return [4 /*yield*/, EntityAttachment.GetListByEntityId({
26890
- entityId: firstId,
26891
- api: api
26892
- })];
26893
- case 4:
26894
- data = _d.sent();
26895
- items = data.attachments;
26896
- images = [].concat(items).sort(function (a, b) { return b.DisplayOrder - a.DisplayOrder; }).filter(function (x) { return x["EntityAttachmentType.ID"] == EntityAttachmentType.EType.Photo; }).reverse();
26897
- defaultImage = images.length ? images[0] : null;
26898
- if (defaultImage) {
26899
- this._imageContainer.style.display = "flex";
26900
- url = ClientFile.GetUrl({
26901
- fileId: defaultImage["ClientFile.ID"],
26902
- api: api,
26903
- viaCdn: true
26800
+ else if ((_b = location_1 === null || location_1 === void 0 ? void 0 : location_1.pos3d) === null || _b === void 0 ? void 0 : _b.x) {
26801
+ destination = location_1.pos3d;
26802
+ }
26803
+ if (destination) {
26804
+ viewer.camera.flyTo({
26805
+ destination: destination,
26806
+ duration: 1,
26807
+ orientation: {
26808
+ heading: 0,
26809
+ pitch: -Math$1.PI_OVER_TWO,
26810
+ roll: 0
26811
+ }
26904
26812
  });
26905
- this._image.style.backgroundImage = "url(".concat(url, ")");
26813
+ flew = true;
26906
26814
  }
26907
- attributes = gatherAttributes(EMode.ShowAll, entity, entityType);
26908
- groups = groupAttributes(attributes, (_c = (_b = entityType.DataSchema) === null || _b === void 0 ? void 0 : _b.Structure) !== null && _c !== void 0 ? _c : []);
26909
- for (_i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
26910
- group = groups_1[_i];
26911
- this._generateAttrGroup(entityType, entity, group);
26815
+ else {
26816
+ flew = false;
26912
26817
  }
26913
- return [3 /*break*/, 6];
26914
- case 5:
26915
- e_1 = _d.sent();
26818
+ return [3 /*break*/, 4];
26819
+ case 3:
26820
+ e_1 = _c.sent();
26916
26821
  console.error(e_1);
26917
- this._name.innerText = "";
26918
- this._summary.innerHTML = "<p>Could not read entity information</p>";
26919
- return [3 /*break*/, 6];
26920
- case 6: return [2 /*return*/];
26822
+ return [3 /*break*/, 4];
26823
+ case 4:
26824
+ if (!flew) {
26825
+ window.alert("Could not fly to selection.");
26826
+ }
26827
+ return [2 /*return*/];
26921
26828
  }
26922
26829
  });
26923
26830
  });
26924
26831
  };
26925
- WidgetInfoView.prototype._generateAttrGroup = function (type, entity, group) {
26926
- var groupDiv = document.createElement("div");
26927
- groupDiv.className = "NextspaceAttributesGroup";
26928
- groupDiv.setAttribute("is-opened", group.open ? "true" : "false");
26929
- if (group.group.Key != "ROOT") {
26930
- var toggle = document.createElement("div");
26931
- toggle.className = "NextspaceAttributesGroupToggle";
26932
- toggle.innerHTML = "\n ".concat(group.group.Key, "\n <div class=\"NextspaceAttributesGroupToggleIcon\">\n <svg class=\"NextspaceAttributesGroupToggleIconOpened\" width=\"16\" height=\"9\" viewBox=\"0 0 16 9\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M15 1L8 8L1 1\" stroke=\"white\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path></svg>\n <svg class=\"NextspaceAttributesGroupToggleIconClosed\" width=\"10\" height=\"17\" viewBox=\"0 0 10 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M8.5 15.5L1.5 8.5L8.5 1.5\" stroke=\"white\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path></svg>\n </div>\n ");
26933
- toggle.addEventListener("click", function () {
26934
- var isOpened = groupDiv.getAttribute("is-opened") == "true";
26935
- groupDiv.setAttribute("is-opened", isOpened ? "false" : "true");
26936
- localStorage.setItem("".concat(OPEN_STORAGE_KEY).concat(group.group.Key), isOpened ? "false" : "true");
26937
- });
26938
- groupDiv.appendChild(toggle);
26832
+ return WidgetEmbeddedInfoView;
26833
+ }(Widget.AWidget));
26834
+
26835
+ var CESIUM_VIEWER_MANAGER_KEY = "_cesiumViewerManager";
26836
+ var CESIUM_VIEWER_EVENT_TRACKER_KEY = "_cesiumViewerEventTracker";
26837
+ /**
26838
+ * Bug related to entities not being visible after they were added then a render was requested.
26839
+ * It was 4 point entities in York. They would not appear until a request render was recalled.
26840
+ * Adding this slow render loop as a band-aid fix.
26841
+ */
26842
+ var BACKGROUND_RENDERING_KEY = "_backgroundRendering";
26843
+ function backgroundRendering(viewer) {
26844
+ if (viewer[BACKGROUND_RENDERING_KEY]) {
26845
+ return;
26846
+ }
26847
+ viewer[BACKGROUND_RENDERING_KEY] = true;
26848
+ var interval = setInterval(function () {
26849
+ var _a;
26850
+ if (!(viewer === null || viewer === void 0 ? void 0 : viewer.cesiumWidget) || !(viewer === null || viewer === void 0 ? void 0 : viewer.scene) || viewer.isDestroyed()) {
26851
+ clearInterval(interval);
26852
+ return;
26939
26853
  }
26940
- for (var _i = 0, _a = group.attributes; _i < _a.length; _i++) {
26941
- var attr = _a[_i];
26942
- var attrDiv = this._generateAttr(groupDiv, type, entity, attr);
26943
- if (group.group.Key != "ROOT") {
26944
- attrDiv.style.marginLeft = "12px";
26854
+ // We'll ignore the call if the viewer container is not visible.
26855
+ if (!viewer.container || ((_a = viewer.container.style) === null || _a === void 0 ? void 0 : _a.display) == "none") {
26856
+ return;
26857
+ }
26858
+ try {
26859
+ // Check if last render time is greater than 3 seconds ago.
26860
+ // We check in case something else is also requesting renders.
26861
+ var lastRenderTime = viewer.scene.lastRenderTime;
26862
+ if (!lastRenderTime || JulianDate.secondsDifference(JulianDate.now(), lastRenderTime) > 3) {
26863
+ // Check if window is active/in focus.
26864
+ // TODO: Should render the moment it is in focus as well.
26865
+ if (document.hasFocus()) {
26866
+ viewer.scene.requestRender();
26867
+ }
26945
26868
  }
26946
26869
  }
26947
- this._summary.appendChild(groupDiv);
26948
- };
26949
- WidgetInfoView.prototype._generateAttr = function (container, type, entity, path) {
26950
- var _a, _b, _c;
26951
- var attrDiv = document.createElement("div");
26952
- attrDiv.className = "NextspaceAttribute";
26953
- var typeItem = digTypeItem(path, (_b = (_a = type.DataSchema) === null || _a === void 0 ? void 0 : _a.Structure) !== null && _b !== void 0 ? _b : []);
26954
- var attrType = (_c = typeItem === null || typeItem === void 0 ? void 0 : typeItem.Type) !== null && _c !== void 0 ? _c : EntityAttribute.EType.String;
26955
- var input = document.createElement("div");
26956
- input.className = "NextspaceAttributeInput";
26957
- attrDiv.appendChild(input);
26958
- var attrName = document.createElement("div");
26959
- attrName.className = "NextspaceAttributeInputLabel";
26960
- attrName.innerText = typeItem ? typeItem.Name ? typeItem.Name : typeItem.Key : path[path.length - 1];
26961
- input.appendChild(attrName);
26962
- var value = Entity$1.GetValue({
26963
- entity: entity,
26964
- path: path
26965
- });
26966
- var valueStr = "";
26967
- if (attrType == EntityAttribute.EType.Boolean) {
26968
- valueStr = value ? "Yes" : "No";
26870
+ catch (e) {
26871
+ console.error("backgroundRendering", e);
26969
26872
  }
26970
- else if (attrType == EntityAttribute.EType.Integer || attrType == EntityAttribute.EType.Double) {
26971
- valueStr = +value;
26972
- if (isNaN(valueStr)) {
26973
- valueStr = 0;
26873
+ }, 1500);
26874
+ }
26875
+ // Cache of Cesium Token -> Validity.
26876
+ var _cToken_check_cache = {};
26877
+ var ViewerUtils;
26878
+ (function (ViewerUtils$$1) {
26879
+ /**
26880
+ * Destroys all the junk that cesium viewer ships with.
26881
+ * @param viewer
26882
+ */
26883
+ function InitViewer(params) {
26884
+ var viewer = params.viewer, destroyWidgets = params.destroyWidgets, styleContainer = params.styleContainer, nextspaceWidgets = params.nextspaceWidgets, widgetParams = params.widgetParams;
26885
+ var data = { widgets: {} };
26886
+ if (destroyWidgets != false) {
26887
+ try {
26888
+ ViewerUtils$$1.DestroyWidget(viewer.timeline);
26889
+ ViewerUtils$$1.DestroyWidget(viewer.vrButton);
26890
+ ViewerUtils$$1.DestroyWidget(viewer.sceneModePicker);
26891
+ ViewerUtils$$1.DestroyWidget(viewer.homeButton);
26892
+ ViewerUtils$$1.DestroyWidget(viewer.fullscreenButton);
26893
+ ViewerUtils$$1.DestroyWidget(viewer.baseLayerPicker);
26894
+ }
26895
+ catch (e) {
26896
+ console.error(e);
26974
26897
  }
26975
26898
  }
26976
- else if (attrType == EntityAttribute.EType.Structure) {
26977
- valueStr = "<Multiple values>";
26899
+ if (styleContainer != false) {
26900
+ ViewerUtils$$1.StyleContainer({ viewer: viewer });
26978
26901
  }
26979
- else if (attrType == EntityAttribute.EType.Geometry) {
26980
- valueStr = "<Multiple values>";
26902
+ if (nextspaceWidgets != false) {
26903
+ data.widgets = ViewerUtils$$1.CreateWidgets(__assign(__assign({}, widgetParams), { viewer: viewer }));
26981
26904
  }
26982
- else {
26983
- if (value && typeof value == "object") {
26984
- valueStr = "<Multiple values>";
26905
+ backgroundRendering(viewer);
26906
+ // Capturing the destroy call to destroy all widgets.
26907
+ var olDestroy = viewer.destroy;
26908
+ viewer.destroy = function () {
26909
+ if (!viewer || viewer.isDestroyed()) {
26910
+ return;
26985
26911
  }
26986
- else {
26987
- valueStr = value ? String(value) : "<No value>";
26912
+ try {
26913
+ ViewerUtils$$1.DisposeNextspaceWidgets(viewer);
26988
26914
  }
26989
- }
26990
- var attrValue = document.createElement("input");
26991
- attrValue.className = "NextspaceAttributeInputValue";
26992
- attrValue.value = String(valueStr);
26993
- input.appendChild(attrValue);
26994
- container.appendChild(attrDiv);
26995
- return attrDiv;
26996
- };
26997
- return WidgetInfoView;
26998
- }(Widget.AWidget));
26999
-
27000
- var WidgetEmbeddedInfoView = /** @class */ (function (_super) {
27001
- __extends(WidgetEmbeddedInfoView, _super);
27002
- function WidgetEmbeddedInfoView(params) {
27003
- var _this = _super.call(this, params) || this;
27004
- _this.STYLESHEET_ID = "nextspace-info-view-stylesheet";
27005
- _this._generateStyles();
27006
- _this._generateElement();
27007
- _this._updateRemoval = _this._manager.VisualsRegister.OnUpdate.Subscribe(function (data) {
27008
- if (data.type == "UPDATE" || data.type == "DESELECT_ALL") {
27009
- _this._updateInfoView();
26915
+ // We don't want the actual destroy to fail.
26916
+ catch (e) {
26917
+ console.error(e);
26918
+ }
26919
+ if (olDestroy) {
26920
+ // Calling with original binding to retain scope.
26921
+ olDestroy.call(viewer);
27010
26922
  }
26923
+ };
26924
+ return data;
26925
+ }
26926
+ ViewerUtils$$1.InitViewer = InitViewer;
26927
+ /**
26928
+ * Destroys all widgets attached to the given viewer.
26929
+ * All Nextspace widgets get auto-associated with the viewer they are created against.
26930
+ * @param viewer
26931
+ */
26932
+ function DisposeNextspaceWidgets(viewer) {
26933
+ Widget.GetWidgets(viewer).forEach(function (widget) {
26934
+ widget.Dispose();
27011
26935
  });
27012
- if (window) {
27013
- var winEvent_1 = null;
27014
- window.addEventListener("message", winEvent_1 = function (event) {
27015
- try {
27016
- var data = (event.data && typeof event.data == "string" && String(event.data).startsWith("{")) ? JSON.parse(event.data) : event.data;
27017
- if (!data) {
27018
- return;
27019
- }
27020
- var embedId = data.embedId;
27021
- // Detecting when selection changes within iframe.
27022
- if (embedId == "info-view") {
27023
- if (data.action == "select") {
27024
- _this._manager.VisualsRegister.ClearSelected();
27025
- _this._manager.VisualsRegister.SetSelected({
27026
- entityIds: data.selectedIds ? data.selectedIds : [],
27027
- selected: true
27028
- });
27029
- }
27030
- else if (data.action == "fly-to") {
27031
- _this._flyTo();
27032
- }
27033
- }
27034
- }
27035
- catch (e) {
27036
- console.error(e);
27037
- }
27038
- });
27039
- _this._windowTopRemoval = function () {
27040
- window.removeEventListener("message", winEvent_1);
27041
- };
26936
+ }
26937
+ ViewerUtils$$1.DisposeNextspaceWidgets = DisposeNextspaceWidgets;
26938
+ function DestroyWidget(widget) {
26939
+ // We're getting cases where calling destroy on a widget with missing a element is crashing Cesium.
26940
+ // To try avoid this we're checking against container existing.
26941
+ if (widget && !widget.isDestroyed() && widget.container) {
26942
+ widget.destroy();
27042
26943
  }
27043
- return _this;
27044
26944
  }
27045
- WidgetEmbeddedInfoView.prototype.Dispose = function () {
26945
+ ViewerUtils$$1.DestroyWidget = DestroyWidget;
26946
+ /**
26947
+ * Hides all unnecessary elements from the Cesium viewer container.
26948
+ * @param viewer
26949
+ */
26950
+ function StyleContainer(params) {
27046
26951
  var _a;
27047
- _super.prototype.Dispose.call(this);
27048
- this._updateRemoval();
27049
- (_a = this._windowTopRemoval) === null || _a === void 0 ? void 0 : _a.call(this);
27050
- this._windowTopRemoval = null;
26952
+ var viewer = params.viewer;
26953
+ var container = viewer.container;
26954
+ if (!container.style.position) {
26955
+ container.style.position = "relative";
26956
+ }
26957
+ var genContainer = (_a = container.getElementsByClassName("cesium-viewer")) === null || _a === void 0 ? void 0 : _a[0];
26958
+ if (genContainer) {
26959
+ var children = genContainer.children;
26960
+ for (var i = 0; i < children.length; i++) {
26961
+ var child = children[i];
26962
+ if (!child.classList.contains("cesium-viewer-cesiumWidgetContainer")) {
26963
+ child.style.display = "none";
26964
+ }
26965
+ }
26966
+ }
26967
+ var canvas = viewer.canvas;
26968
+ canvas.style.width = "100%";
26969
+ canvas.style.height = "100%";
26970
+ var widget = canvas.parentElement;
26971
+ widget.style.width = "100%";
26972
+ widget.style.height = "100%";
26973
+ widget.style.touchAction = "none";
26974
+ var widgetContainer = widget.parentElement;
26975
+ widgetContainer.style.width = "100%";
26976
+ widgetContainer.style.height = "100%";
26977
+ var viewerContainer = widgetContainer.parentElement;
26978
+ viewerContainer.style.fontFamily = "sans-serif";
26979
+ viewerContainer.style.fontSize = "16px";
26980
+ viewerContainer.style.overflow = "hidden";
26981
+ viewerContainer.style.display = "block";
26982
+ viewerContainer.style.position = "relative";
26983
+ viewerContainer.style.top = "0";
26984
+ viewerContainer.style.left = "0";
26985
+ viewerContainer.style.width = "100%";
26986
+ viewerContainer.style.height = "100%";
26987
+ }
26988
+ ViewerUtils$$1.StyleContainer = StyleContainer;
26989
+ /**
26990
+ * Returns a given Cesium viewer's menu item manager.
26991
+ * If one is missing then it'll optionally create one before returning it.
26992
+ * @param params
26993
+ * @returns
26994
+ */
26995
+ function GetManager(params) {
26996
+ var viewer = params.viewer, createIfMissing = params.createIfMissing, getters = params.getters;
26997
+ if (viewer[CESIUM_VIEWER_MANAGER_KEY]) {
26998
+ return viewer[CESIUM_VIEWER_MANAGER_KEY];
26999
+ }
27000
+ else if (createIfMissing != false) {
27001
+ var manager = new MenuItemManager.Manager({
27002
+ viewer: viewer,
27003
+ getters: getters
27004
+ });
27005
+ viewer[CESIUM_VIEWER_MANAGER_KEY] = manager;
27006
+ return manager;
27007
+ }
27008
+ return null;
27009
+ }
27010
+ ViewerUtils$$1.GetManager = GetManager;
27011
+ /**
27012
+ * Creates Nextspace default widgets.
27013
+ * Returns key/value pairs for created widgets. Key is widget name.
27014
+ * @param params
27015
+ */
27016
+ function CreateWidgets(params) {
27017
+ var viewer = params.viewer, manager = params.manager, container = params.container, apiGetters = params.apiGetters, navCompass = params.navCompass, defaultState = params.defaultState, branding = params.branding, cursorBar = params.cursorBar, viewBar = params.viewBar, searchBar = params.searchBar, bookmarks = params.bookmarks, infoView = params.infoView, embeddedInfoView = params.embeddedInfoView, leftPanel = params.leftPanel;
27018
+ var widgets = {};
27019
+ if (!viewer && manager) {
27020
+ viewer = manager.Viewer;
27021
+ }
27022
+ if (viewer && !manager) {
27023
+ manager = ViewerUtils$$1.GetManager({ viewer: viewer });
27024
+ }
27025
+ if (!container && viewer) {
27026
+ container = viewer.container;
27027
+ }
27028
+ if (!apiGetters) {
27029
+ apiGetters = ENVIRONMENT.Api();
27030
+ }
27031
+ if (defaultState == null) {
27032
+ defaultState = true;
27033
+ }
27034
+ var widgetParams = {
27035
+ viewer: viewer,
27036
+ container: container,
27037
+ apiGetters: apiGetters,
27038
+ manager: manager
27039
+ };
27040
+ if ((typeof navCompass == "boolean" && navCompass) || defaultState) {
27041
+ widgets["navCompass"] = new WidgetNavCompass$$1(widgetParams);
27042
+ }
27043
+ if ((typeof branding == "boolean" && branding) || defaultState) {
27044
+ widgets["navBranding"] = new WidgetBranding(widgetParams);
27045
+ }
27046
+ if ((typeof cursorBar == "boolean" && cursorBar) || defaultState) {
27047
+ widgets["cursorBar"] = new WidgetCursorBar(widgetParams);
27048
+ }
27049
+ if (
27050
+ // Backwards compatibility.
27051
+ typeof searchBar == "boolean" ? (searchBar) : (
27052
+ // Latest version.
27053
+ typeof viewBar == "boolean" ? (viewBar) : (
27054
+ // Fallback.
27055
+ defaultState))) {
27056
+ widgets["viewBar"] = new WidgetViewBar(widgetParams);
27057
+ }
27058
+ if ((typeof bookmarks == "boolean" && bookmarks) || (defaultState && !leftPanel)) {
27059
+ widgets["bookmarks"] = new WidgetBookmarks(__assign(__assign({}, widgetParams), { viewId: params.viewId, runFirstBookmark: params.runFirstBookmark }));
27060
+ }
27061
+ if (!(typeof bookmarks == "boolean" && bookmarks) && leftPanel) {
27062
+ widgets["leftPanel"] = new WidgetLeftPanel(__assign(__assign({}, widgetParams), { viewId: params.viewId, runFirstBookmark: params.runFirstBookmark }));
27063
+ }
27064
+ if ((typeof infoView == "boolean" && infoView) || (defaultState && !embeddedInfoView)) {
27065
+ widgets["infoView"] = new WidgetInfoView(widgetParams);
27066
+ }
27067
+ if (!(typeof infoView == "boolean" && infoView) && embeddedInfoView) {
27068
+ widgets["embeddedInfoView"] = new WidgetEmbeddedInfoView(__assign({}, widgetParams));
27069
+ }
27070
+ return widgets;
27071
+ }
27072
+ ViewerUtils$$1.CreateWidgets = CreateWidgets;
27073
+ /**
27074
+ * Returns if the given token is valid or not.
27075
+ * This will perform a test request to Cesium API.
27076
+ * @param token
27077
+ * @returns
27078
+ */
27079
+ function AssertIonToken(token) {
27080
+ return __awaiter(this, void 0, void 0, function () {
27081
+ var url, response, json, e_1;
27082
+ return __generator(this, function (_a) {
27083
+ switch (_a.label) {
27084
+ case 0:
27085
+ if (!token) {
27086
+ return [2 /*return*/, false];
27087
+ }
27088
+ if (_cToken_check_cache[token] != null) {
27089
+ return [2 /*return*/, _cToken_check_cache[token]];
27090
+ }
27091
+ _a.label = 1;
27092
+ case 1:
27093
+ _a.trys.push([1, 4, , 5]);
27094
+ url = "https://api.cesium.com/v1/assets/1/endpoint?access_token=".concat(token);
27095
+ return [4 /*yield*/, fetch(url)];
27096
+ case 2:
27097
+ response = _a.sent();
27098
+ return [4 /*yield*/, response.json()];
27099
+ case 3:
27100
+ json = _a.sent();
27101
+ _cToken_check_cache[token] = Boolean(json === null || json === void 0 ? void 0 : json.url);
27102
+ return [2 /*return*/, _cToken_check_cache[token]];
27103
+ case 4:
27104
+ e_1 = _a.sent();
27105
+ console.error(e_1);
27106
+ _cToken_check_cache[token] = false;
27107
+ return [3 /*break*/, 5];
27108
+ case 5: return [2 /*return*/];
27109
+ }
27110
+ });
27111
+ });
27112
+ }
27113
+ ViewerUtils$$1.AssertIonToken = AssertIonToken;
27114
+ /**
27115
+ * Gets or creates a viewer event tracker.
27116
+ * This will log and emit events that are tracked.
27117
+ * @param viewer
27118
+ * @returns
27119
+ */
27120
+ function GetEventTracker(viewer) {
27121
+ var tracker = viewer[CESIUM_VIEWER_EVENT_TRACKER_KEY];
27122
+ if (!tracker) {
27123
+ tracker = new ViewerEventTracker.Tracker("warn,error");
27124
+ }
27125
+ viewer[CESIUM_VIEWER_EVENT_TRACKER_KEY] = tracker;
27126
+ return tracker;
27127
+ }
27128
+ ViewerUtils$$1.GetEventTracker = GetEventTracker;
27129
+ })(ViewerUtils || (ViewerUtils = {}));
27130
+
27131
+ var WidgetControlViewBar;
27132
+ (function (WidgetControlViewBar) {
27133
+ var AControl = /** @class */ (function () {
27134
+ function AControl(params) {
27135
+ this._disposed = false;
27136
+ this._enabled = false;
27137
+ var container = params.container, widget = params.widget, element = params.element;
27138
+ this._widget = widget;
27139
+ this._container = container;
27140
+ this._element = element;
27141
+ }
27142
+ Object.defineProperty(AControl.prototype, "WidgetViewBar", {
27143
+ get: function () {
27144
+ return this._widget;
27145
+ },
27146
+ enumerable: false,
27147
+ configurable: true
27148
+ });
27149
+ Object.defineProperty(AControl.prototype, "Container", {
27150
+ get: function () {
27151
+ return this._container;
27152
+ },
27153
+ enumerable: false,
27154
+ configurable: true
27155
+ });
27156
+ Object.defineProperty(AControl.prototype, "Element", {
27157
+ get: function () {
27158
+ return this._element;
27159
+ },
27160
+ enumerable: false,
27161
+ configurable: true
27162
+ });
27163
+ Object.defineProperty(AControl.prototype, "Disposed", {
27164
+ get: function () {
27165
+ return this._disposed;
27166
+ },
27167
+ enumerable: false,
27168
+ configurable: true
27169
+ });
27170
+ Object.defineProperty(AControl.prototype, "Enabled", {
27171
+ get: function () {
27172
+ return this._enabled;
27173
+ },
27174
+ enumerable: false,
27175
+ configurable: true
27176
+ });
27177
+ AControl.prototype.Toggle = function () {
27178
+ };
27179
+ AControl.prototype.Dispose = function () {
27180
+ this._disposed = true;
27181
+ };
27182
+ return AControl;
27183
+ }());
27184
+ WidgetControlViewBar.AControl = AControl;
27185
+ })(WidgetControlViewBar || (WidgetControlViewBar = {}));
27186
+
27187
+ /**
27188
+ * The fullscreen control is a simple toggle.
27189
+ * There is no HTML element. However we do swap the icon based on the toggle state.
27190
+ */
27191
+ var WidgetControlViewBarFullscreen = /** @class */ (function (_super) {
27192
+ __extends(WidgetControlViewBarFullscreen, _super);
27193
+ function WidgetControlViewBarFullscreen(params) {
27194
+ return _super.call(this, params) || this;
27195
+ }
27196
+ WidgetControlViewBarFullscreen.prototype.Dispose = function () {
27197
+ _super.prototype.Dispose.call(this);
27051
27198
  };
27052
- WidgetEmbeddedInfoView.prototype._generateStyles = function () {
27199
+ WidgetControlViewBarFullscreen.prototype.Toggle = function () {
27200
+ if (this.Disposed) {
27201
+ return;
27202
+ }
27203
+ _super.prototype.Toggle.call(this);
27204
+ // Toggle fullscreen.
27205
+ this._enabled = false;
27206
+ if (Fullscreen.enabled) {
27207
+ if (Fullscreen.fullscreen) {
27208
+ Fullscreen.exitFullscreen();
27209
+ }
27210
+ else {
27211
+ Fullscreen.requestFullscreen(document.body);
27212
+ this._enabled = true;
27213
+ }
27214
+ }
27215
+ };
27216
+ return WidgetControlViewBarFullscreen;
27217
+ }(WidgetControlViewBar.AControl));
27218
+
27219
+ var WidgetControlViewBarSearch = /** @class */ (function (_super) {
27220
+ __extends(WidgetControlViewBarSearch, _super);
27221
+ function WidgetControlViewBarSearch(params) {
27222
+ var _this = _super.call(this, params) || this;
27223
+ _this.STYLESHEET_ID = "nextspace-control-view-bar-searchbar-stylesheet";
27224
+ _this._cApi = new AbstractApi({});
27225
+ _this._generateStyles();
27226
+ _this._generateElement();
27227
+ return _this;
27228
+ }
27229
+ WidgetControlViewBarSearch.prototype.Dispose = function () {
27230
+ _super.prototype.Dispose.call(this);
27231
+ if (this._element && this._element.parentElement) {
27232
+ this._element.parentElement.removeChild(this._element);
27233
+ }
27234
+ };
27235
+ WidgetControlViewBarSearch.prototype.Toggle = function () {
27236
+ if (this.Disposed) {
27237
+ return;
27238
+ }
27239
+ _super.prototype.Toggle.call(this);
27240
+ this._enabled = !this._enabled;
27241
+ if (this._enabled) {
27242
+ this._display();
27243
+ }
27244
+ else {
27245
+ this._hide();
27246
+ }
27247
+ };
27248
+ WidgetControlViewBarSearch.prototype._generateStyles = function () {
27053
27249
  if (document.getElementById(this.STYLESHEET_ID)) {
27054
27250
  return;
27055
27251
  }
27056
27252
  var style = document.createElement("style");
27057
27253
  style.id = this.STYLESHEET_ID;
27058
- style.innerHTML = "\n .NextspaceInfoView {\n width: 500px;\n border-radius: 8px;\n right: 10px;\n top: 66px;\n height: 600px;\n max-height: calc(100% - 320px);\n min-height: 50px;\n align-items: center;\n background: rgba(33,39,42,0.8);\n border-radius: 9px;\n box-shadow: 0 0 1px rgba(18,22,25,.36),0 18px 36px -4px rgba(18,22,25,.36);\n backdrop-filter: blur(20px);\n display: flex;\n flex-direction: column;\n flex-shrink: 1;\n opacity: 0;\n position: absolute;\n z-index: 1;\n transition: opacity .3s ease,-webkit-transform .1s;\n transition: opacity .3s ease,transform .1s;\n transition: opacity .3s ease,transform .1s,-webkit-transform .1s;\n font-family: Arial;\n overflow: hidden;\n }\n\n .NextspaceInfoView * {\n box-sizing: border-box;\n }\n ";
27254
+ style.innerHTML = "\n .NextspaceSearchBar {\n top: 10px;\n right: 10px;\n display: flex;\n box-sizing: border-box;\n box-shadow: 0 0 1px rgba(18,22,25,.24),0 18px 36px -4px rgba(18,22,25,.6);\n background: #21272a;\n border-radius: 9px;\n height: 48px;\n padding-left: 2px;\n padding-right: 2px;\n font-family: sans-serif;\n }\n\n .NextspaceSearchBar * {\n box-sizing: border-box;\n }\n\n .NextspaceSearchBar[is-opened=\"true\"] .NextspaceSearchBarContent {\n display: flex;\n width: 260px;\n }\n\n .NextspaceSearchBarContent {\n flex-grow: 0;\n flex-shrink: 0;\n overflow: hidden;\n transition: .3s ease;\n width: 0;\n }\n\n .NextspaceSearchBarContent >input {\n background: transparent;\n border: none;\n color: #fff;\n font-size: 15px;\n height: 100%;\n outline: none;\n padding: 0 8px;\n width: 100%;\n }\n\n .NextspaceSearchBarResults {\n background-color: #21272a;\n border-radius: 0 0 6px 6px;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n padding: 12px 8px 8px;\n position: absolute;\n top: calc(100% - 6px);\n width: 100%;\n left: 0;\n z-index: 1;\n }\n\n .NextspaceSearchBarResultsItem {\n align-items: center;\n color: #fff;\n cursor: pointer;\n display: flex;\n height: 30px;\n transition: .3s ease;\n font-size: 13px;\n }\n\n .NextspaceSearchBarResultsItem:hover .NextspaceSearchBarResultsItemIcon {\n -webkit-transform: scale(1.05);\n transform: scale(1.05);\n }\n\n .NextspaceSearchBarResultsItemIcon {\n align-items: center;\n display: flex;\n flex-grow: 0;\n flex-shrink: 0;\n justify-content: center;\n margin-right: 5px;\n width: 25px;\n }\n\n .NextspaceSearchBarResultsItemTip {\n flex-grow: 1;\n flex-shrink: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: 50px;\n font-size: 15px;\n }\n\n .NextspaceSearchBarResultsWarning {\n height: 30px;\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n font-size: 15px;\n }\n ";
27059
27255
  document.head.appendChild(style);
27060
27256
  };
27061
- WidgetEmbeddedInfoView.prototype._generateElement = function () {
27257
+ WidgetControlViewBarSearch.prototype._generateElement = function () {
27258
+ var _this = this;
27062
27259
  var element = document.createElement("div");
27063
- element.className = "NextspaceInfoView";
27064
- element.style.display = "none";
27260
+ element.className = "NextspaceSearchBar";
27261
+ element.setAttribute("is-opened", "false");
27262
+ var content = document.createElement("div");
27263
+ content.className = "NextspaceSearchBarContent";
27264
+ content.innerHTML = "\n <input placeholder=\"address\"/>\n ";
27265
+ element.appendChild(content);
27266
+ var input = content.querySelector("input");
27267
+ var searchTimeout = null;
27268
+ var counter = 0;
27269
+ input.onkeyup = function (e) {
27270
+ var _a;
27271
+ var value = (_a = e.currentTarget) === null || _a === void 0 ? void 0 : _a.value;
27272
+ if (!value || value.length < 3) {
27273
+ return;
27274
+ }
27275
+ counter += 1;
27276
+ var curCounter = counter;
27277
+ _this._displayLoading();
27278
+ clearTimeout(searchTimeout);
27279
+ searchTimeout = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
27280
+ var searchData, e_1;
27281
+ return __generator(this, function (_a) {
27282
+ switch (_a.label) {
27283
+ case 0:
27284
+ _a.trys.push([0, 2, , 3]);
27285
+ return [4 /*yield*/, this._doSearch(value)];
27286
+ case 1:
27287
+ searchData = _a.sent();
27288
+ if (curCounter !== counter) {
27289
+ return [2 /*return*/];
27290
+ }
27291
+ this._displayResults(searchData);
27292
+ return [3 /*break*/, 3];
27293
+ case 2:
27294
+ e_1 = _a.sent();
27295
+ console.error(e_1);
27296
+ return [3 /*break*/, 3];
27297
+ case 3: return [2 /*return*/];
27298
+ }
27299
+ });
27300
+ }); }, 200);
27301
+ };
27302
+ var results = document.createElement("div");
27303
+ results.className = "NextspaceSearchBarResults";
27304
+ element.appendChild(results);
27305
+ results.style.display = "none";
27306
+ this._results = results;
27065
27307
  this.Container.appendChild(element);
27066
27308
  this._element = element;
27067
- this._updateInfoView();
27068
27309
  };
27069
- WidgetEmbeddedInfoView.prototype._updateInfoView = function () {
27310
+ WidgetControlViewBarSearch.prototype._display = function () {
27311
+ var _a, _b;
27312
+ this._element.setAttribute("is-opened", "true");
27313
+ // Show prior results.
27314
+ if (this._results.innerHTML) {
27315
+ this._results.style.display = "flex";
27316
+ }
27317
+ // Focus input.
27318
+ (_b = (_a = this._element.querySelector("input")) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
27319
+ this._enabled = true;
27320
+ };
27321
+ WidgetControlViewBarSearch.prototype._hide = function () {
27322
+ this._element.setAttribute("is-opened", "false");
27323
+ this._results.style.display = "none";
27324
+ this._enabled = false;
27325
+ };
27326
+ WidgetControlViewBarSearch.prototype._displayResults = function (results) {
27327
+ var _this = this;
27328
+ this._results.style.display = "flex";
27329
+ if (results === null || results === void 0 ? void 0 : results.length) {
27330
+ this._results.innerHTML = "";
27331
+ var getIcon_1 = function (result) {
27332
+ if (result.type == ESearchType.CesiumAddress) {
27333
+ return "\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12 24C18.6274 24 24 18.6274 24 12C24 5.37259 18.6274 0 12 0C5.37258 0 0 5.37259 0 12C0 18.6274 5.37258 24 12 24Z\" fill=\"white\"/>\n <path d=\"M21.6985 10.4272C21.3489 10.4272 20.9994 10.631 20.7373 10.9806L17.4169 15.3786C16.8635 16.1068 16.0771 16.5145 15.2616 16.5145C14.446 16.5145 13.6596 16.1068 13.1062 15.3786L9.78584 10.9806C9.5237 10.631 9.17419 10.4272 8.82467 10.4272C8.47516 10.4272 8.12564 10.631 7.86351 10.9806L4.54312 15.3786C3.98972 16.1068 3.23244 16.5145 2.4169 16.5145C4.10623 20.0971 7.747 22.5728 11.9703 22.5728C17.7955 22.5728 22.5431 17.8543 22.5431 12C22.5431 11.5922 22.514 11.1844 22.4557 10.7767C22.2519 10.5437 21.9897 10.4272 21.6985 10.4272Z\" fill=\"#7A9C49\"/>\n <path d=\"M11.9996 1.42718C6.1744 1.42718 1.42683 6.14562 1.42683 12C1.42683 12.932 1.57246 13.8349 1.77634 14.6796C1.98022 14.8252 2.18411 14.9126 2.41712 14.9126C2.76663 14.9126 3.11615 14.7087 3.37828 14.3592L6.69867 9.96116C7.25207 9.233 8.03848 8.82523 8.85401 8.82523C9.66955 8.82523 10.456 9.233 11.0094 9.96116L14.2132 14.1845L14.3589 14.3592C14.621 14.7087 14.9705 14.8835 15.2909 14.9126C15.6404 14.9126 15.9608 14.7087 16.2229 14.3592L16.3686 14.1845L19.5725 9.96116C20.1259 9.233 20.9123 8.82523 21.7278 8.82523C21.8443 8.82523 21.9899 8.82524 22.1064 8.85436C20.7666 4.54368 16.7472 1.42718 11.9996 1.42718V1.42718ZM15.5239 8.12621C14.9123 8.12621 14.4171 7.63105 14.4171 7.0194C14.4171 6.40775 14.9123 5.91261 15.5239 5.91261C16.1356 5.91261 16.6307 6.40775 16.6307 7.0194C16.6307 7.63105 16.1356 8.12621 15.5239 8.12621Z\" fill=\"#6DABE4\"/>\n </svg>\n ";
27334
+ }
27335
+ return "\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M6 20H18C18.55 20 19 20.45 19 21C19 21.55 18.55 22 18 22H6C5.45 22 5 21.55 5 21C5 20.45 5.45 20 6 20ZM12 7C10.9 7 10 7.9 10 9C10 10.1 10.9 11 12 11C13.1 11 14 10.1 14 9C14 7.9 13.1 7 12 7ZM12 2C15.27 2 19 4.46 19 9.15C19 12.13 16.87 15.27 12.61 18.54C12.25 18.82 11.75 18.82 11.39 18.54C7.13 15.26 5 12.13 5 9.15C5 4.46 8.73 2 12 2Z\" fill=\"white\"/>\n </svg>\n ";
27336
+ };
27337
+ results.forEach(function (result) {
27338
+ var resultElement = document.createElement("div");
27339
+ resultElement.className = "NextspaceSearchBarResultsItem";
27340
+ resultElement.innerHTML = "\n <div class=\"NextspaceSearchBarResultsItemIcon\">\n ".concat(getIcon_1(result), "\n </div>\n <div class=\"NextspaceSearchBarResultsItemTip\">\n ").concat(result.tip, "\n </div>\n ");
27341
+ resultElement.onclick = function () {
27342
+ _this._clickResult(result);
27343
+ };
27344
+ _this._results.appendChild(resultElement);
27345
+ });
27346
+ }
27347
+ else {
27348
+ this._results.innerHTML = "\n <div class=\"NextspaceSearchBarResultsWarning\">No results found...</div>\n ";
27349
+ }
27350
+ };
27351
+ WidgetControlViewBarSearch.prototype._displayLoading = function () {
27352
+ this._results.style.display = "flex";
27353
+ this._results.innerHTML = "\n <div class=\"NextspaceSearchBarResultsWarning\">Loading...</div>\n ";
27354
+ };
27355
+ WidgetControlViewBarSearch.prototype._cesiumAutoComplete = function (text) {
27070
27356
  return __awaiter(this, void 0, void 0, function () {
27071
- var selectedIds, firstId, url, urlParams, iframe;
27357
+ var token;
27072
27358
  return __generator(this, function (_a) {
27073
- selectedIds = this._manager.VisualsRegister.GetSelected();
27074
- if (selectedIds.length <= 0) {
27075
- this._element.style.display = "none";
27076
- this._element.style.opacity = "0";
27077
- return [2 /*return*/];
27078
- }
27079
- this._element.style.display = "flex";
27080
- this._element.style.opacity = "1";
27081
- firstId = selectedIds[0];
27082
- if (this._lastSelectedId == firstId) {
27083
- return [2 /*return*/];
27084
- }
27085
- this._lastSelectedId = firstId;
27086
- try {
27087
- url = "https://embed.nextspace.host/embed";
27088
- urlParams = new URLSearchParams();
27089
- urlParams.append("id", "info-view");
27090
- urlParams.append("entityId", firstId);
27091
- urlParams.append("sessionId", this._manager.Getters.GetSessionId());
27092
- urlParams.append("accountId", this._manager.Getters.GetAccountId());
27093
- urlParams.append("env", this._manager.Getters.GetEnv());
27094
- urlParams.append("bgStyle", "transparent");
27095
- urlParams.append("enableFlyTo", "true");
27096
- iframe = document.createElement("iframe");
27097
- iframe.src = "".concat(url, "?").concat(urlParams.toString());
27098
- iframe.style.width = "100%";
27099
- iframe.style.height = "100%";
27100
- iframe.style.border = "none";
27101
- this._element.innerHTML = "";
27102
- this._element.appendChild(iframe);
27103
- }
27104
- catch (e) {
27105
- console.error(e);
27106
- }
27107
- return [2 /*return*/];
27359
+ token = Ion.defaultAccessToken;
27360
+ return [2 /*return*/, this._cApi.get("https://api.cesium.com/v1/geocode/autocomplete?text=".concat(encodeURI(text), "&access_token=").concat(token))];
27108
27361
  });
27109
27362
  });
27110
27363
  };
27111
- WidgetEmbeddedInfoView.prototype._flyTo = function () {
27112
- var _a, _b;
27364
+ WidgetControlViewBarSearch.prototype._doSearch = function (text) {
27365
+ var _a;
27113
27366
  return __awaiter(this, void 0, void 0, function () {
27114
- var flew, ids, viewer, location_1, destination, centerCartographic, pos3d, e_1;
27115
- return __generator(this, function (_c) {
27116
- switch (_c.label) {
27367
+ var result, parts, lat, lon, alt, res, MAX_ITEMS, added, _loop_1, i, state_1, e_2;
27368
+ return __generator(this, function (_b) {
27369
+ switch (_b.label) {
27117
27370
  case 0:
27118
- flew = false;
27119
- _c.label = 1;
27120
- case 1:
27121
- _c.trys.push([1, 3, , 4]);
27122
- ids = this._manager.VisualsRegister.GetSelected();
27123
- viewer = this._manager.Viewer;
27124
- return [4 /*yield*/, EntityUtils.GetLocation({
27125
- samples: ids.map(function (id) { return ({
27126
- entityId: id,
27127
- returnHeightRef: HeightReference.NONE,
27128
- heightRef: HeightReference.RELATIVE_TO_GROUND
27129
- }); }),
27130
- viewer: viewer,
27131
- visualRegister: this._manager.VisualsRegister,
27132
- api: this._manager.Getters.GetBruceApi(),
27133
- minimumAlt: 5,
27134
- paddingAlt: 5
27135
- })];
27136
- case 2:
27137
- location_1 = _c.sent();
27138
- destination = null;
27139
- if ((_a = location_1 === null || location_1 === void 0 ? void 0 : location_1.sphere) === null || _a === void 0 ? void 0 : _a.radius) {
27140
- if (location_1.sphere.radius < 5) {
27141
- location_1.sphere.radius = 5;
27142
- }
27143
- centerCartographic = Cartographic.fromCartesian(location_1.sphere.center);
27144
- centerCartographic.height += (location_1.sphere.radius * 2);
27145
- pos3d = Cartesian3.fromRadians(centerCartographic.longitude, centerCartographic.latitude, centerCartographic.height);
27146
- destination = pos3d;
27147
- }
27148
- else if (location_1 === null || location_1 === void 0 ? void 0 : location_1.rectangle) {
27149
- destination = location_1.rectangle;
27150
- }
27151
- else if ((_b = location_1 === null || location_1 === void 0 ? void 0 : location_1.pos3d) === null || _b === void 0 ? void 0 : _b.x) {
27152
- destination = location_1.pos3d;
27371
+ if (!text || text.length < 3) {
27372
+ return [2 /*return*/, []];
27153
27373
  }
27154
- if (destination) {
27155
- viewer.camera.flyTo({
27156
- destination: destination,
27157
- duration: 1,
27158
- orientation: {
27159
- heading: 0,
27160
- pitch: -Math$1.PI_OVER_TWO,
27161
- roll: 0
27374
+ result = [];
27375
+ if (isLatLon(text)) {
27376
+ parts = text.split(",");
27377
+ lat = parseFloat(parts[0]);
27378
+ lon = parseFloat(parts[1]);
27379
+ alt = parts.length > 2 ? parseFloat(parts[2]) : null;
27380
+ result.push({
27381
+ type: ESearchType.LatLon,
27382
+ tip: "Lat Lon Location",
27383
+ data: {
27384
+ altitude: alt,
27385
+ latitude: lat,
27386
+ longitude: lon
27162
27387
  }
27163
27388
  });
27164
- flew = true;
27389
+ return [2 /*return*/, result];
27165
27390
  }
27166
- else {
27167
- flew = false;
27391
+ if (!Ion.defaultAccessToken) return [3 /*break*/, 5];
27392
+ _b.label = 1;
27393
+ case 1:
27394
+ _b.trys.push([1, 3, , 4]);
27395
+ return [4 /*yield*/, this._cesiumAutoComplete(text)];
27396
+ case 2:
27397
+ res = _b.sent();
27398
+ console.log("Cesium search result", res);
27399
+ MAX_ITEMS = 5;
27400
+ added = 0;
27401
+ if (res && res.features) {
27402
+ _loop_1 = function (i) {
27403
+ var feature = res.features[i];
27404
+ if (feature.bbox || feature.geometry) {
27405
+ var name_1 = feature.properties.name;
27406
+ if (!name_1) {
27407
+ name_1 = feature.properties.label;
27408
+ }
27409
+ if (!name_1) {
27410
+ return "continue";
27411
+ }
27412
+ // We don't want results with the same visual name, even if they have different coordinate data.
27413
+ if (result.find(function (x) { return x.type == ESearchType.CesiumAddress && x.tip == name_1; })) {
27414
+ return "continue";
27415
+ }
27416
+ var coords = (_a = feature.geometry) === null || _a === void 0 ? void 0 : _a.coordinates;
27417
+ var bbox = feature.bbox;
27418
+ if (!coords && !bbox) {
27419
+ return "continue";
27420
+ }
27421
+ result.push({
27422
+ type: ESearchType.CesiumAddress,
27423
+ tip: name_1,
27424
+ data: {
27425
+ bbox: bbox,
27426
+ location: coords ? {
27427
+ altitude: coords[2],
27428
+ latitude: coords[1],
27429
+ longitude: coords[0]
27430
+ } : null
27431
+ }
27432
+ });
27433
+ added += 1;
27434
+ if (added >= MAX_ITEMS) {
27435
+ return "break";
27436
+ }
27437
+ }
27438
+ };
27439
+ for (i = 0; i < res.features.length; i++) {
27440
+ state_1 = _loop_1(i);
27441
+ if (state_1 === "break")
27442
+ break;
27443
+ }
27168
27444
  }
27169
27445
  return [3 /*break*/, 4];
27170
27446
  case 3:
27171
- e_1 = _c.sent();
27172
- console.error(e_1);
27447
+ e_2 = _b.sent();
27448
+ console.error(e_2);
27173
27449
  return [3 /*break*/, 4];
27174
- case 4:
27175
- if (!flew) {
27176
- window.alert("Could not fly to selection.");
27177
- }
27178
- return [2 /*return*/];
27450
+ case 4: return [3 /*break*/, 6];
27451
+ case 5:
27452
+ console.warn("No Cesium token set, skipping Cesium address search.");
27453
+ _b.label = 6;
27454
+ case 6: return [2 /*return*/, result];
27179
27455
  }
27180
27456
  });
27181
27457
  });
27182
27458
  };
27183
- return WidgetEmbeddedInfoView;
27184
- }(Widget.AWidget));
27185
-
27186
- var CESIUM_VIEWER_MANAGER_KEY = "_cesiumViewerManager";
27187
- var CESIUM_VIEWER_EVENT_TRACKER_KEY = "_cesiumViewerEventTracker";
27188
- /**
27189
- * Bug related to entities not being visible after they were added then a render was requested.
27190
- * It was 4 point entities in York. They would not appear until a request render was recalled.
27191
- * Adding this slow render loop as a band-aid fix.
27192
- */
27193
- var BACKGROUND_RENDERING_KEY = "_backgroundRendering";
27194
- function backgroundRendering(viewer) {
27195
- if (viewer[BACKGROUND_RENDERING_KEY]) {
27196
- return;
27197
- }
27198
- viewer[BACKGROUND_RENDERING_KEY] = true;
27199
- var interval = setInterval(function () {
27200
- var _a;
27201
- if (!(viewer === null || viewer === void 0 ? void 0 : viewer.cesiumWidget) || !(viewer === null || viewer === void 0 ? void 0 : viewer.scene) || viewer.isDestroyed()) {
27202
- clearInterval(interval);
27203
- return;
27204
- }
27205
- // We'll ignore the call if the viewer container is not visible.
27206
- if (!viewer.container || ((_a = viewer.container.style) === null || _a === void 0 ? void 0 : _a.display) == "none") {
27207
- return;
27208
- }
27209
- try {
27210
- // Check if last render time is greater than 3 seconds ago.
27211
- // We check in case something else is also requesting renders.
27212
- var lastRenderTime = viewer.scene.lastRenderTime;
27213
- if (!lastRenderTime || JulianDate.secondsDifference(JulianDate.now(), lastRenderTime) > 3) {
27214
- // Check if window is active/in focus.
27215
- // TODO: Should render the moment it is in focus as well.
27216
- if (document.hasFocus()) {
27217
- viewer.scene.requestRender();
27218
- }
27219
- }
27220
- }
27221
- catch (e) {
27222
- console.error("backgroundRendering", e);
27223
- }
27224
- }, 1500);
27225
- }
27226
- // Cache of Cesium Token -> Validity.
27227
- var _cToken_check_cache = {};
27228
- var ViewerUtils;
27229
- (function (ViewerUtils) {
27230
- /**
27231
- * Destroys all the junk that cesium viewer ships with.
27232
- * @param viewer
27233
- */
27234
- function InitViewer(params) {
27235
- var viewer = params.viewer, destroyWidgets = params.destroyWidgets, styleContainer = params.styleContainer, nextspaceWidgets = params.nextspaceWidgets, widgetParams = params.widgetParams;
27236
- var data = { widgets: {} };
27237
- if (destroyWidgets != false) {
27238
- try {
27239
- ViewerUtils.DestroyWidget(viewer.timeline);
27240
- ViewerUtils.DestroyWidget(viewer.vrButton);
27241
- ViewerUtils.DestroyWidget(viewer.sceneModePicker);
27242
- ViewerUtils.DestroyWidget(viewer.homeButton);
27243
- ViewerUtils.DestroyWidget(viewer.fullscreenButton);
27244
- ViewerUtils.DestroyWidget(viewer.baseLayerPicker);
27245
- }
27246
- catch (e) {
27247
- console.error(e);
27248
- }
27249
- }
27250
- if (styleContainer != false) {
27251
- ViewerUtils.StyleContainer({ viewer: viewer });
27252
- }
27253
- if (nextspaceWidgets != false) {
27254
- data.widgets = ViewerUtils.CreateWidgets(__assign(__assign({}, widgetParams), { viewer: viewer }));
27255
- }
27256
- backgroundRendering(viewer);
27257
- // Capturing the destroy call to destroy all widgets.
27258
- var olDestroy = viewer.destroy;
27259
- viewer.destroy = function () {
27260
- if (!viewer || viewer.isDestroyed()) {
27261
- return;
27262
- }
27263
- try {
27264
- ViewerUtils.DisposeNextspaceWidgets(viewer);
27265
- }
27266
- // We don't want the actual destroy to fail.
27267
- catch (e) {
27268
- console.error(e);
27269
- }
27270
- if (olDestroy) {
27271
- // Calling with original binding to retain scope.
27272
- olDestroy.call(viewer);
27459
+ WidgetControlViewBarSearch.prototype._clickResult = function (item) {
27460
+ return __awaiter(this, void 0, void 0, function () {
27461
+ function zoomToCarto(points) {
27462
+ var cartes = points.map(function (x) { var _a; return Cartesian3.fromDegrees(x.longitude, x.latitude, (_a = x.altitude) !== null && _a !== void 0 ? _a : 0); });
27463
+ zoomToCartes(cartes);
27273
27464
  }
27274
- };
27275
- return data;
27276
- }
27277
- ViewerUtils.InitViewer = InitViewer;
27278
- /**
27279
- * Destroys all widgets attached to the given viewer.
27280
- * All Nextspace widgets get auto-associated with the viewer they are created against.
27281
- * @param viewer
27282
- */
27283
- function DisposeNextspaceWidgets(viewer) {
27284
- Widget.GetWidgets(viewer).forEach(function (widget) {
27285
- widget.Dispose();
27465
+ var deduplicatePoints, raiseCartesToHeight, zoomToCartes, bbox, point;
27466
+ var _this = this;
27467
+ return __generator(this, function (_a) {
27468
+ deduplicatePoints = function (points) {
27469
+ var DIS_TOLERANCE = 0.001;
27470
+ var result = [];
27471
+ var _loop_2 = function (i) {
27472
+ var point_1 = points[i];
27473
+ if (result.find(function (x) { return Cartesian3.distance(x, point_1) < DIS_TOLERANCE; })) {
27474
+ return "continue";
27475
+ }
27476
+ result.push(point_1);
27477
+ };
27478
+ for (var i = 0; i < points.length; i++) {
27479
+ _loop_2(i);
27480
+ }
27481
+ return result;
27482
+ };
27483
+ raiseCartesToHeight = function (points, minHeight) {
27484
+ for (var i = 0; i < points.length; i++) {
27485
+ var carto = Cartographic.fromCartesian(points[i]);
27486
+ carto.height = Math.max(carto.height, minHeight);
27487
+ points[i] = Cartesian3.fromRadians(carto.longitude, carto.latitude, carto.height);
27488
+ }
27489
+ };
27490
+ zoomToCartes = function (points) {
27491
+ points = deduplicatePoints(points);
27492
+ raiseCartesToHeight(points, 2500);
27493
+ var viewer = _this._widget.Viewer;
27494
+ var orient = {
27495
+ heading: Math$1.toRadians(0),
27496
+ pitch: Math$1.toRadians(-90),
27497
+ roll: 0
27498
+ };
27499
+ var onComplete = function () {
27500
+ viewer.camera.lookAtTransform(Matrix4.IDENTITY);
27501
+ };
27502
+ if (points.length > 1) {
27503
+ var rectangle = Rectangle.fromCartesianArray(points);
27504
+ viewer.camera.flyTo({
27505
+ destination: rectangle,
27506
+ orientation: orient,
27507
+ duration: 1,
27508
+ complete: onComplete
27509
+ });
27510
+ }
27511
+ else {
27512
+ var carto = BoundingSphere.fromPoints(points).center;
27513
+ viewer.camera.flyTo({
27514
+ destination: carto,
27515
+ orientation: orient,
27516
+ duration: 1,
27517
+ complete: onComplete
27518
+ });
27519
+ }
27520
+ };
27521
+ switch (item.type) {
27522
+ case ESearchType.CesiumAddress:
27523
+ bbox = item.data.bbox;
27524
+ if (bbox) {
27525
+ zoomToCarto([
27526
+ {
27527
+ altitude: null,
27528
+ latitude: bbox[1],
27529
+ longitude: bbox[0]
27530
+ },
27531
+ {
27532
+ altitude: null,
27533
+ latitude: bbox[3],
27534
+ longitude: bbox[2]
27535
+ }
27536
+ ]);
27537
+ break;
27538
+ }
27539
+ point = item.data.location;
27540
+ if (point) {
27541
+ zoomToCarto([point]);
27542
+ break;
27543
+ }
27544
+ break;
27545
+ case ESearchType.LatLon:
27546
+ zoomToCarto([item.data]);
27547
+ break;
27548
+ }
27549
+ this._hide();
27550
+ return [2 /*return*/];
27551
+ });
27286
27552
  });
27553
+ };
27554
+ return WidgetControlViewBarSearch;
27555
+ }(WidgetControlViewBar.AControl));
27556
+ var ESearchType;
27557
+ (function (ESearchType) {
27558
+ ESearchType["CesiumAddress"] = "CESIUM_ADDRESS";
27559
+ ESearchType["LatLon"] = "LATLON";
27560
+ })(ESearchType || (ESearchType = {}));
27561
+ function isLatLon(text) {
27562
+ var parts = text.split(",");
27563
+ if (parts.length !== 2 && parts.length !== 3) {
27564
+ return false;
27287
27565
  }
27288
- ViewerUtils.DisposeNextspaceWidgets = DisposeNextspaceWidgets;
27289
- function DestroyWidget(widget) {
27290
- // We're getting cases where calling destroy on a widget with missing a element is crashing Cesium.
27291
- // To try avoid this we're checking against container existing.
27292
- if (widget && !widget.isDestroyed() && widget.container) {
27293
- widget.destroy();
27294
- }
27566
+ var lat = parseFloat(parts[0]);
27567
+ var lon = parseFloat(parts[1]);
27568
+ if (isNaN(lat) || isNaN(lon)) {
27569
+ return false;
27295
27570
  }
27296
- ViewerUtils.DestroyWidget = DestroyWidget;
27297
- /**
27298
- * Hides all unnecessary elements from the Cesium viewer container.
27299
- * @param viewer
27300
- */
27301
- function StyleContainer(params) {
27302
- var _a;
27303
- var viewer = params.viewer;
27304
- var container = viewer.container;
27305
- if (!container.style.position) {
27306
- container.style.position = "relative";
27307
- }
27308
- var genContainer = (_a = container.getElementsByClassName("cesium-viewer")) === null || _a === void 0 ? void 0 : _a[0];
27309
- if (genContainer) {
27310
- var children = genContainer.children;
27311
- for (var i = 0; i < children.length; i++) {
27312
- var child = children[i];
27313
- if (!child.classList.contains("cesium-viewer-cesiumWidgetContainer")) {
27314
- child.style.display = "none";
27315
- }
27316
- }
27317
- }
27318
- var canvas = viewer.canvas;
27319
- canvas.style.width = "100%";
27320
- canvas.style.height = "100%";
27321
- var widget = canvas.parentElement;
27322
- widget.style.width = "100%";
27323
- widget.style.height = "100%";
27324
- widget.style.touchAction = "none";
27325
- var widgetContainer = widget.parentElement;
27326
- widgetContainer.style.width = "100%";
27327
- widgetContainer.style.height = "100%";
27328
- var viewerContainer = widgetContainer.parentElement;
27329
- viewerContainer.style.fontFamily = "sans-serif";
27330
- viewerContainer.style.fontSize = "16px";
27331
- viewerContainer.style.overflow = "hidden";
27332
- viewerContainer.style.display = "block";
27333
- viewerContainer.style.position = "relative";
27334
- viewerContainer.style.top = "0";
27335
- viewerContainer.style.left = "0";
27336
- viewerContainer.style.width = "100%";
27337
- viewerContainer.style.height = "100%";
27571
+ return true;
27572
+ }
27573
+
27574
+ var VIEWER_LEFT_PANEL_WIDGET_KEY$1 = "_viewerViewBarWidget";
27575
+ var WidgetViewBar = /** @class */ (function (_super) {
27576
+ __extends(WidgetViewBar, _super);
27577
+ function WidgetViewBar(params) {
27578
+ var _this = _super.call(this, params) || this;
27579
+ _this.STYLESHEET_ID = "nextspace-view-bar-stylesheet";
27580
+ // Currently initialized controls.
27581
+ // Controls get initialized on addition and then a toggle event is called when the user clicks them.
27582
+ _this.controls = new Map();
27583
+ // Map of custom controls added by external devs by calling AddBarControl.
27584
+ // This is a mapping of the provided control key + content class.
27585
+ _this.customControls = new Map();
27586
+ _this._generateStyles();
27587
+ _this._generateElement();
27588
+ _this._viewer[VIEWER_LEFT_PANEL_WIDGET_KEY$1] = _this;
27589
+ return _this;
27338
27590
  }
27339
- ViewerUtils.StyleContainer = StyleContainer;
27340
- /**
27341
- * Returns a given Cesium viewer's menu item manager.
27342
- * If one is missing then it'll optionally create one before returning it.
27343
- * @param params
27344
- * @returns
27345
- */
27346
- function GetManager(params) {
27347
- var viewer = params.viewer, createIfMissing = params.createIfMissing, getters = params.getters;
27348
- if (viewer[CESIUM_VIEWER_MANAGER_KEY]) {
27349
- return viewer[CESIUM_VIEWER_MANAGER_KEY];
27591
+ // Getters for protected properties so that controls can access them.
27592
+ WidgetViewBar.prototype._getManager = function () {
27593
+ return this._manager;
27594
+ };
27595
+ WidgetViewBar.prototype._getViewer = function () {
27596
+ return this._viewer;
27597
+ };
27598
+ WidgetViewBar.prototype._getApiGetters = function () {
27599
+ return this._apiGetters;
27600
+ };
27601
+ WidgetViewBar.prototype.Dispose = function () {
27602
+ _super.prototype.Dispose.call(this);
27603
+ if (this.envSubRemoval) {
27604
+ this.envSubRemoval();
27605
+ this.envSubRemoval = null;
27350
27606
  }
27351
- else if (createIfMissing != false) {
27352
- var manager = new MenuItemManager.Manager({
27353
- viewer: viewer,
27354
- getters: getters
27607
+ if (this.controls) {
27608
+ this.controls.forEach(function (control) {
27609
+ control.Dispose();
27355
27610
  });
27356
- viewer[CESIUM_VIEWER_MANAGER_KEY] = manager;
27357
- return manager;
27611
+ this.controls.clear();
27358
27612
  }
27359
- return null;
27360
- }
27361
- ViewerUtils.GetManager = GetManager;
27613
+ };
27614
+ WidgetViewBar.prototype._generateStyles = function () {
27615
+ if (document.getElementById(this.STYLESHEET_ID)) {
27616
+ return;
27617
+ }
27618
+ var style = document.createElement("style");
27619
+ style.id = this.STYLESHEET_ID;
27620
+ style.innerHTML = "\n .NextspaceViewBar {\n align-items: center;\n background-color: #21272a;\n border-radius: 9px;\n display: flex;\n flex-shrink: 1;\n height: 48px;\n justify-content: center;\n position: absolute;\n z-index: 1;\n top: 10px;\n right: 10px;\n box-sizing: border-box;\n }\n\n .NextspaceViewBar * {\n box-sizing: border-box;\n }\n\n .NextspaceViewBarControl {\n align-items: center;\n border-radius: 0;\n color: #fff;\n cursor: pointer;\n display: flex;\n flex-shrink: 0;\n font-size: 18px;\n height: 100%;\n justify-content: center;\n padding: 8px;\n transition: .3s ease;\n width: 46px;\n }\n\n .NextspaceViewBarControlIcon {\n width: 32px;\n height: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .NextspaceViewBarControl svg {\n transition: .3s ease;\n }\n\n .NextspaceViewBarControl:hover svg {\n transform: scale(1.2);\n }\n\n .NextspaceViewBarControl[is-enabled=\"true\"] {\n background: #33b1ff;\n }\n\n .NextspaceViewBarEndBreaker {\n background: #ffffff1f;\n border-radius: 2px;\n flex-shrink: 0;\n height: 32px;\n margin-left: 6px;\n margin-right: 6px;\n width: 2px;\n }\n ";
27621
+ document.head.appendChild(style);
27622
+ };
27623
+ WidgetViewBar.prototype._generateElement = function () {
27624
+ var element = document.createElement("div");
27625
+ element.className = "NextspaceViewBar";
27626
+ this.Container.appendChild(element);
27627
+ this._element = element;
27628
+ this._addBarControl({
27629
+ control: "searchbar",
27630
+ title: "Search",
27631
+ iconDisabled: {
27632
+ icon: "\n <svg class=\"\" width=\"32\" height=\"32\" viewBox=\"0 0 32 32\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M14.3283 6C9.73857 6 6 9.73857 6 14.3283C6 18.918 9.73857 22.6566 14.3283 22.6566C16.3242 22.6566 18.1571 21.9479 19.5937 20.7714L24.5663 25.7439C24.643 25.8239 24.7349 25.8877 24.8366 25.9316C24.9383 25.9756 25.0478 25.9988 25.1586 26C25.2694 26.0011 25.3793 25.9801 25.4819 25.9382C25.5845 25.8963 25.6777 25.8344 25.756 25.756C25.8344 25.6777 25.8963 25.5845 25.9382 25.4819C25.9801 25.3793 26.0011 25.2694 26 25.1586C25.9988 25.0478 25.9756 24.9383 25.9316 24.8366C25.8877 24.7349 25.8239 24.643 25.7439 24.5663L20.7714 19.5937C21.9479 18.1571 22.6566 16.3242 22.6566 14.3283C22.6566 9.73857 18.918 6 14.3283 6ZM14.3283 7.66566C18.0178 7.66566 20.9909 10.6388 20.9909 14.3283C20.9909 18.0178 18.0178 20.9909 14.3283 20.9909C10.6388 20.9909 7.66566 18.0178 7.66566 14.3283C7.66566 10.6388 10.6388 7.66566 14.3283 7.66566Z\" fill=\"white\"></path></svg>\n ",
27633
+ iconSource: "svg"
27634
+ },
27635
+ customEnabledState: true
27636
+ });
27637
+ var breaker = document.createElement("div");
27638
+ breaker.className = "NextspaceViewBarEndBreaker";
27639
+ this._element.appendChild(breaker);
27640
+ this._addBarControl({
27641
+ control: "fullscreen",
27642
+ title: "Fullscreen",
27643
+ iconDisabled: {
27644
+ icon: "\n <svg class=\"\" width=\"28\" height=\"28\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M6 14C5.45 14 5 14.45 5 15V18C5 18.55 5.45 19 6 19H9C9.55 19 10 18.55 10 18C10 17.45 9.55 17 9 17H7V15C7 14.45 6.55 14 6 14ZM6 10C6.55 10 7 9.55 7 9V7H9C9.55 7 10 6.55 10 6C10 5.45 9.55 5 9 5H6C5.45 5 5 5.45 5 6V9C5 9.55 5.45 10 6 10ZM17 17H15C14.45 17 14 17.45 14 18C14 18.55 14.45 19 15 19H18C18.55 19 19 18.55 19 18V15C19 14.45 18.55 14 18 14C17.45 14 17 14.45 17 15V17ZM14 6C14 6.55 14.45 7 15 7H17V9C17 9.55 17.45 10 18 10C18.55 10 19 9.55 19 9V6C19 5.45 18.55 5 18 5H15C14.45 5 14 5.45 14 6Z\" fill=\"white\"></path></svg>\n ",
27645
+ iconSource: "svg"
27646
+ },
27647
+ iconEnabled: {
27648
+ icon: "\n <svg class=\"\" width=\"28\" height=\"28\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M6 16H8V18C8 18.55 8.45 19 9 19C9.55 19 10 18.55 10 18V15C10 14.45 9.55 14 9 14H6C5.45 14 5 14.45 5 15C5 15.55 5.45 16 6 16ZM8 8H6C5.45 8 5 8.45 5 9C5 9.55 5.45 10 6 10H9C9.55 10 10 9.55 10 9V6C10 5.45 9.55 5 9 5C8.45 5 8 5.45 8 6V8ZM15 19C15.55 19 16 18.55 16 18V16H18C18.55 16 19 15.55 19 15C19 14.45 18.55 14 18 14H15C14.45 14 14 14.45 14 15V18C14 18.55 14.45 19 15 19ZM16 8V6C16 5.45 15.55 5 15 5C14.45 5 14 5.45 14 6V9C14 9.55 14.45 10 15 10H18C18.55 10 19 9.55 19 9C19 8.45 18.55 8 18 8H16Z\" fill=\"white\"></path></svg>\n ",
27649
+ iconSource: "svg"
27650
+ },
27651
+ customEnabledState: true
27652
+ });
27653
+ };
27362
27654
  /**
27363
- * Creates Nextspace default widgets.
27364
- * Returns key/value pairs for created widgets. Key is widget name.
27655
+ * Adds a custom control to the view bar.
27365
27656
  * @param params
27366
27657
  */
27367
- function CreateWidgets(params) {
27368
- var viewer = params.viewer, manager = params.manager, container = params.container, apiGetters = params.apiGetters, navCompass = params.navCompass, defaultState = params.defaultState, branding = params.branding, cursorBar = params.cursorBar, searchBar = params.searchBar, bookmarks = params.bookmarks, infoView = params.infoView, embeddedInfoView = params.embeddedInfoView, leftPanel = params.leftPanel;
27369
- var widgets = {};
27370
- if (!viewer && manager) {
27371
- viewer = manager.Viewer;
27372
- }
27373
- if (viewer && !manager) {
27374
- manager = ViewerUtils.GetManager({ viewer: viewer });
27658
+ WidgetViewBar.prototype.AddBarControl = function (params) {
27659
+ this.customControls.set(params.control, params.content);
27660
+ // We insert before the end breaker.
27661
+ var endBreaker = this._element.querySelector(".NextspaceViewBarEndBreaker");
27662
+ var afterElement = endBreaker ? endBreaker.previousElementSibling : null;
27663
+ var icon;
27664
+ var iconSource;
27665
+ if (params.iconSvgStr) {
27666
+ icon = params.iconSvgStr;
27667
+ iconSource = "svg";
27375
27668
  }
27376
- if (!container && viewer) {
27377
- container = viewer.container;
27669
+ else if (params.iconImgUrl) {
27670
+ icon = params.iconImgUrl;
27671
+ iconSource = "file-url";
27378
27672
  }
27379
- if (!apiGetters) {
27380
- apiGetters = ENVIRONMENT.Api();
27673
+ else if (params.svgStr) {
27674
+ icon = params.svgStr;
27675
+ iconSource = "svg";
27381
27676
  }
27382
- if (defaultState == null) {
27383
- defaultState = true;
27677
+ this._addBarControl({
27678
+ control: params.control,
27679
+ title: params.title,
27680
+ afterElement: afterElement,
27681
+ iconDisabled: {
27682
+ icon: icon,
27683
+ iconSource: iconSource,
27684
+ }
27685
+ });
27686
+ };
27687
+ WidgetViewBar.prototype._addBarControl = function (params) {
27688
+ var _this = this;
27689
+ var control = params.control, title = params.title, iconDisabled = params.iconDisabled, iconEnabled = params.iconEnabled, afterElement = params.afterElement, customEnabledState = params.customEnabledState;
27690
+ if (!iconEnabled) {
27691
+ iconEnabled = iconDisabled;
27384
27692
  }
27385
- var widgetParams = {
27386
- viewer: viewer,
27387
- container: container,
27388
- apiGetters: apiGetters,
27389
- manager: manager
27693
+ var tabButton = document.createElement("div");
27694
+ tabButton.setAttribute("widget-view-bar-control", control);
27695
+ tabButton.setAttribute("custom-enabled-state", customEnabledState ? "true" : "false");
27696
+ tabButton.className = "NextspaceViewBarControl";
27697
+ tabButton.title = title;
27698
+ var buttonBookmarksIcon = document.createElement("div");
27699
+ buttonBookmarksIcon.className = "NextspaceViewBarControlIcon";
27700
+ var updateIcon = function (isEnabled) {
27701
+ var iconData = isEnabled ? iconEnabled : iconDisabled;
27702
+ buttonBookmarksIcon.innerHTML = "";
27703
+ if (iconData.iconSource == "svg") {
27704
+ buttonBookmarksIcon.innerHTML = iconData.icon;
27705
+ }
27706
+ else if (iconData.iconSource == "file-url") {
27707
+ var buttonBookmarksIconImg = document.createElement("img");
27708
+ buttonBookmarksIconImg.src = iconData.icon;
27709
+ buttonBookmarksIcon.appendChild(buttonBookmarksIconImg);
27710
+ buttonBookmarksIcon.setAttribute("style", "\n max-width: 32px;\n max-height: 32px;\n ");
27711
+ }
27712
+ };
27713
+ updateIcon(false);
27714
+ var controller;
27715
+ tabButton.appendChild(buttonBookmarksIcon);
27716
+ tabButton.onclick = function () {
27717
+ controller === null || controller === void 0 ? void 0 : controller.Toggle();
27718
+ _this._updatePanelStyles();
27719
+ updateIcon(controller === null || controller === void 0 ? void 0 : controller.Enabled);
27390
27720
  };
27391
- if ((typeof navCompass == "boolean" && navCompass) || defaultState) {
27392
- widgets["navCompass"] = new WidgetNavCompass$$1(widgetParams);
27393
- }
27394
- if ((typeof branding == "boolean" && branding) || defaultState) {
27395
- widgets["navBranding"] = new WidgetBranding(widgetParams);
27396
- }
27397
- if ((typeof cursorBar == "boolean" && cursorBar) || defaultState) {
27398
- widgets["cursorBar"] = new WidgetCursorBar(widgetParams);
27399
- }
27400
- if ((typeof searchBar == "boolean" && searchBar) || defaultState) {
27401
- widgets["searchBar"] = new WidgetSearchBar(widgetParams);
27402
- }
27403
- if ((typeof bookmarks == "boolean" && bookmarks) || (defaultState && !leftPanel)) {
27404
- widgets["bookmarks"] = new WidgetBookmarks(__assign(__assign({}, widgetParams), { viewId: params.viewId, runFirstBookmark: params.runFirstBookmark }));
27405
- }
27406
- if (!(typeof bookmarks == "boolean" && bookmarks) && leftPanel) {
27407
- widgets["leftPanel"] = new WidgetLeftPanel(__assign(__assign({}, widgetParams), { viewId: params.viewId, runFirstBookmark: params.runFirstBookmark }));
27721
+ if (afterElement && afterElement.parentElement) {
27722
+ if (afterElement.nextSibling) {
27723
+ afterElement.parentElement.insertBefore(tabButton, afterElement.nextSibling);
27724
+ }
27725
+ else {
27726
+ afterElement.parentElement.appendChild(tabButton);
27727
+ }
27408
27728
  }
27409
- if ((typeof infoView == "boolean" && infoView) || (defaultState && !embeddedInfoView)) {
27410
- widgets["infoView"] = new WidgetInfoView(widgetParams);
27729
+ else {
27730
+ this._element.appendChild(tabButton);
27411
27731
  }
27412
- if (!(typeof infoView == "boolean" && infoView) && embeddedInfoView) {
27413
- widgets["embeddedInfoView"] = new WidgetEmbeddedInfoView(__assign({}, widgetParams));
27732
+ switch (control) {
27733
+ case "fullscreen":
27734
+ controller = new WidgetControlViewBarFullscreen({
27735
+ widget: this,
27736
+ element: tabButton,
27737
+ container: this._element
27738
+ });
27739
+ break;
27740
+ case "searchbar":
27741
+ controller = new WidgetControlViewBarSearch({
27742
+ widget: this,
27743
+ element: tabButton,
27744
+ container: this._element
27745
+ });
27746
+ break;
27747
+ default:
27748
+ if (this.customControls.has(control) === false) {
27749
+ console.error("Control ".concat(control, " not found."));
27750
+ return;
27751
+ }
27752
+ var clazz = this.customControls.get(control);
27753
+ controller = new clazz({
27754
+ widget: this,
27755
+ container: this._element
27756
+ });
27757
+ break;
27414
27758
  }
27415
- return widgets;
27416
- }
27417
- ViewerUtils.CreateWidgets = CreateWidgets;
27759
+ this.controls.set(control, controller);
27760
+ };
27418
27761
  /**
27419
- * Returns if the given token is valid or not.
27420
- * This will perform a test request to Cesium API.
27421
- * @param token
27422
- * @returns
27762
+ * Updates the panel styles based on the current state.
27763
+ * Eg: if a control is enabled, the button should be highlighted.
27423
27764
  */
27424
- function AssertIonToken(token) {
27425
- return __awaiter(this, void 0, void 0, function () {
27426
- var url, response, json, e_1;
27427
- return __generator(this, function (_a) {
27428
- switch (_a.label) {
27429
- case 0:
27430
- if (!token) {
27431
- return [2 /*return*/, false];
27432
- }
27433
- if (_cToken_check_cache[token] != null) {
27434
- return [2 /*return*/, _cToken_check_cache[token]];
27435
- }
27436
- _a.label = 1;
27437
- case 1:
27438
- _a.trys.push([1, 4, , 5]);
27439
- url = "https://api.cesium.com/v1/assets/1/endpoint?access_token=".concat(token);
27440
- return [4 /*yield*/, fetch(url)];
27441
- case 2:
27442
- response = _a.sent();
27443
- return [4 /*yield*/, response.json()];
27444
- case 3:
27445
- json = _a.sent();
27446
- _cToken_check_cache[token] = Boolean(json === null || json === void 0 ? void 0 : json.url);
27447
- return [2 /*return*/, _cToken_check_cache[token]];
27448
- case 4:
27449
- e_1 = _a.sent();
27450
- console.error(e_1);
27451
- _cToken_check_cache[token] = false;
27452
- return [3 /*break*/, 5];
27453
- case 5: return [2 /*return*/];
27454
- }
27455
- });
27765
+ WidgetViewBar.prototype._updatePanelStyles = function () {
27766
+ var _this = this;
27767
+ var buttons = this._element.querySelectorAll(".NextspaceViewBarControl");
27768
+ buttons.forEach(function (button) {
27769
+ var buttonTab = button.getAttribute("widget-view-bar-control");
27770
+ var controller = _this.controls.get(buttonTab);
27771
+ var isCustomEnabledState = button.getAttribute("custom-enabled-state") === "true";
27772
+ if (isCustomEnabledState) {
27773
+ button.setAttribute("is-enabled", "false");
27774
+ }
27775
+ else {
27776
+ button.setAttribute("is-enabled", (controller === null || controller === void 0 ? void 0 : controller.Enabled) ? "true" : "false");
27777
+ }
27456
27778
  });
27457
- }
27458
- ViewerUtils.AssertIonToken = AssertIonToken;
27459
- /**
27460
- * Gets or creates a viewer event tracker.
27461
- * This will log and emit events that are tracked.
27462
- * @param viewer
27463
- * @returns
27464
- */
27465
- function GetEventTracker(viewer) {
27466
- var tracker = viewer[CESIUM_VIEWER_EVENT_TRACKER_KEY];
27467
- if (!tracker) {
27468
- tracker = new ViewerEventTracker.Tracker("warn,error");
27469
- }
27470
- viewer[CESIUM_VIEWER_EVENT_TRACKER_KEY] = tracker;
27471
- return tracker;
27472
- }
27473
- ViewerUtils.GetEventTracker = GetEventTracker;
27474
- })(ViewerUtils || (ViewerUtils = {}));
27779
+ };
27780
+ return WidgetViewBar;
27781
+ }(Widget.AWidget));
27475
27782
 
27476
- var VERSION = "4.5.6";
27783
+ var VERSION = "4.5.7";
27477
27784
 
27478
- export { VERSION, CesiumViewMonitor, ViewerUtils, ViewerEventTracker, MenuItemManager, EntityRenderEngine, EntityRenderEnginePoint, EntityRenderEnginePolyline, EntityRenderEnginePolygon, EntityRenderEngineModel3d, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, GoogleSearchRenderManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, CesiumEntityStyler, CesiumAnimatedProperty, CesiumAnimatedInOut, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, WidgetNavCompass$$1 as WidgetNavCompass, WidgetSearchBar, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, WidgetLeftPanel, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks };
27785
+ export { VERSION, CesiumViewMonitor, ViewerUtils, ViewerEventTracker, MenuItemManager, EntityRenderEngine, EntityRenderEnginePoint, EntityRenderEnginePolyline, EntityRenderEnginePolygon, EntityRenderEngineModel3d, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, GoogleSearchRenderManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, CesiumEntityStyler, CesiumAnimatedProperty, CesiumAnimatedInOut, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, WidgetNavCompass$$1 as WidgetNavCompass, VIEWER_LEFT_PANEL_WIDGET_KEY$1 as VIEWER_LEFT_PANEL_WIDGET_KEY, WidgetViewBar, WidgetControlViewBar, WidgetControlViewBarSearch, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks };
27479
27786
  //# sourceMappingURL=bruce-cesium.es5.js.map