UNPKG

95.2 kBJavaScriptView Raw
1import { a as __extends, b as __awaiter, c as __generator, d as __spreadArray, _ as __assign } from './tslib.es6-f952ba6f.js';
2import { I as InstancesSort, H as HierarchiesExpand, e as HierarchiesSort, U as Utils, K as KeyCodes } from './Utils-38a0872e.js';
3import { create, select, selectAll, pointer } from 'd3';
4import { S as ServerClient } from './ServerClient-8d9a15d8.js';
5import { C as Component } from './Component-5173b5ea.js';
6import { M as ModelAutocomplete } from './ModelAutocomplete-31909926.js';
7
8var HierarchyNavigation = /** @class */ (function (_super) {
9 __extends(HierarchyNavigation, _super);
10 function HierarchyNavigation(renderTarget) {
11 var _this = _super.call(this, renderTarget) || this;
12 _this.usedInstanceSearchContinuationTokens = {};
13 _this.envHierarchies = {};
14 _this.envTypes = {};
15 _this.selectedHierarchyName = HierarchySelectionValues.All;
16 _this.viewType = ViewType.Hierarchy;
17 _this.mode = State.Navigate;
18 _this.searchString = "";
19 _this.path = [];
20 _this.originalPathBeforeReverseLookup = [];
21 _this.renderHierarchySelection = function () {
22 var hierarchyList = __spreadArray(__spreadArray([HierarchySelectionValues.All], Object.keys(_this.envHierarchies)), [HierarchySelectionValues.Unparented]);
23 _this.hierarchyListElem.text('');
24 var self = _this;
25 hierarchyList.forEach(function (h) {
26 var title = h === HierarchySelectionValues.All ? _this.getString("All hierarchies") :
27 h === HierarchySelectionValues.Unparented ? _this.getString("Unassigned Time Series Instances") : h;
28 _this.hierarchyListElem.append('li').classed('selected', h === _this.selectedHierarchyName)
29 .attr("hName", h)
30 .attr('tabindex', 0)
31 .attr('role', 'option')
32 .attr('aria-selected', h === _this.selectedHierarchyName)
33 .attr('title', title)
34 .text(title).on('click keydown', function (event) {
35 if (event && event.type && event.type === 'keydown') {
36 event.preventDefault();
37 var key = event.which || event.keyCode;
38 if (key === KeyCodes.Down) {
39 if (this.nextElementSibling)
40 this.nextElementSibling.focus();
41 else {
42 self.hierarchyListElem.selectAll("li").nodes()[0].focus();
43 }
44 }
45 else if (key === KeyCodes.Up) {
46 if (this.previousElementSibling)
47 this.previousElementSibling.focus();
48 else {
49 self.hierarchyListElem.selectAll("li").nodes()[self.hierarchyListElem.selectAll("li").nodes().length - 1].focus();
50 }
51 }
52 else if (key === KeyCodes.Enter) {
53 self.selectHierarchy(h);
54 self.searchGloballyElem.node().style.display = 'none';
55 self.hierarchySelectorElem.node().focus();
56 }
57 else if (key === KeyCodes.Esc) {
58 self.isHierarchySelectionActive = false;
59 self.hierarchyListWrapperElem.style('display', 'none');
60 self.hierarchySelectorElem.node().focus();
61 }
62 return;
63 }
64 self.selectHierarchy(h);
65 self.hierarchySelectorElem.node().focus();
66 if (h === HierarchySelectionValues.All) {
67 self.searchGloballyElem.node().style.display = 'none';
68 }
69 });
70 });
71 _this.hierarchyListWrapperElem.style('display', 'inline-flex');
72 _this.hierarchyListElem.select("li.selected").node().focus();
73 };
74 //to switch between list view and hierarchy view when search string exists, i.e. in Search mode
75 _this.switchToSearchView = function (view, applySearch) {
76 if (applySearch === void 0) { applySearch = true; }
77 return __awaiter(_this, void 0, void 0, function () {
78 return __generator(this, function (_a) {
79 switch (_a.label) {
80 case 0:
81 this.closeContextMenu();
82 this.viewType = view;
83 this.viewTypesElem.selectAll('.tsi-view-type').classed('selected', false).attr('aria-selected', false);
84 if (!(this.viewType === ViewType.Hierarchy)) return [3 /*break*/, 3];
85 select(this.viewTypesElem.selectAll('.tsi-view-type').nodes()[0]).classed('selected', true).attr('aria-selected', true);
86 if (this.searchString) {
87 this.setModeAndRequestParamsForFilter();
88 }
89 else {
90 this.setModeAndRequestParamsForNavigate();
91 }
92 if (!(selectAll('.tsi-hierarchy ul').size() === 0 && applySearch)) return [3 /*break*/, 2];
93 this.hierarchyElem.text('');
94 return [4 /*yield*/, this.pathSearchAndRenderResult({ search: { payload: this.requestPayload() }, render: { target: this.hierarchyElem } })];
95 case 1:
96 _a.sent();
97 _a.label = 2;
98 case 2:
99 this.hierarchyElem.node().style.display = 'block';
100 this.instanceListWrapperElem.node().style.display = 'none';
101 return [3 /*break*/, 6];
102 case 3:
103 select(this.viewTypesElem.selectAll('.tsi-view-type').nodes()[1]).classed('selected', true).attr('aria-selected', true);
104 this.setModeAndRequestParamsForSearch();
105 if (this.selectedHierarchyName === HierarchySelectionValues.Unparented) {
106 this.chartOptions.hierarchyOptions.isInstancesRecursive = false;
107 }
108 if (!(selectAll('.tsi-modelResultWrapper').size() === 0 && applySearch)) return [3 /*break*/, 5];
109 this.instanceListElem.text('');
110 this.lastInstanceContinuationToken = null;
111 this.usedInstanceSearchContinuationTokens = {};
112 return [4 /*yield*/, this.pathSearchAndRenderResult({ search: { payload: this.requestPayload() }, render: { target: this.instanceListElem } })];
113 case 4:
114 _a.sent();
115 _a.label = 5;
116 case 5:
117 this.hierarchyElem.node().style.display = 'none';
118 this.instanceListWrapperElem.node().style.display = 'block';
119 _a.label = 6;
120 case 6: return [2 /*return*/];
121 }
122 });
123 });
124 };
125 _this.showNoResultsForSearch = function () {
126 _this.viewTypesElem.node().style.display = 'none';
127 if (_this.mode === State.Search && ((_this.selectedHierarchyName !== HierarchySelectionValues.All) || _this.filterPathElem.classed('visible'))) {
128 _this.searchGloballyElem.style('display', 'inline');
129 _this.noResultsElem.select(".tsi-clear").style('display', 'inline-block');
130 }
131 else {
132 _this.searchGloballyElem.style('display', 'none');
133 _this.noResultsElem.select(".tsi-clear").style('display', 'none');
134 }
135 _this.noResultsElem.classed('border-top', _this.filterPathElem.classed('visible'));
136 _this.noResultsElem.select(".tsi-not-found-message").node().childNodes[0].textContent = _this.mode === State.Search ? _this.getString("No search result") : _this.getString("No instances");
137 _this.noResultsElem.style('display', 'flex');
138 };
139 // do exact search with tsid to retrieve all possible paths until that instance to traverse for expansion
140 _this.doExactSearchWithPossiblePaths = function (tsid, hNames) {
141 _this.setModeAndRequestParamsForFilter();
142 var escapedTsidString = Utils.escapedTsidForExactSearch(tsid === null || tsid === void 0 ? void 0 : tsid.join(" "));
143 _this.searchString = "\"" + escapedTsidString + "\""; //TODO: null vs string null check for exact search and escape for character : fix from backend will come here!!
144 return Promise.all(hNames.map(function (hName) {
145 var payload = hName ? _this.requestPayload([hName]) : _this.requestPayload(null);
146 return _this.getToken().then(function (token) {
147 return _this.server.getTimeseriesInstancesPathSearch(token, _this.environmentFqdn, payload, null, null)
148 .catch(function (err) { throw err; });
149 })
150 .catch(function (err) { throw err; });
151 })).catch(function (err) { return _this.chartOptions.onError("Error in hierarchy navigation", "Failed to complete search", err instanceof XMLHttpRequest ? err : null); });
152 };
153 // clear dom and reset some variables for fresh navigation experience
154 _this.prepareComponentForLookup = function (timeSeriesID) {
155 _this.hierarchyElem.style('display', 'none');
156 _this.noResultsElem.style('display', 'none');
157 _this.notFoundElem.style('display', 'none');
158 _this.instanceLookupLoadingElem.select('.tsi-lookup-instance').text(_this.getString("Looking for") + " " + timeSeriesID.join(" "));
159 _this.instanceLookupLoadingElem.style('display', 'flex');
160 _this.viewTypesElem.style("display", "none");
161 _this.searchWrapperElem.select("input").node().value = "";
162 _this.searchGloballyElem.style("display", "none");
163 _this.originalPathBeforeReverseLookup = _this.path;
164 _this.path = _this.selectedHierarchyName !== HierarchySelectionValues.All && _this.selectedHierarchyName !== HierarchySelectionValues.Unparented ? [_this.selectedHierarchyName] : [];
165 };
166 // pull instance to get its name to search in the tree if exist
167 _this.getInstance = function (timeSeriesID) {
168 return _this.getToken()
169 .then(function (token) {
170 return _this.server.getTimeseriesInstances(token, _this.environmentFqdn, 1, [timeSeriesID]).catch(function (err) { return _this.chartOptions.onError("Error in hierarchy navigation", "Failed to get instance details", err instanceof XMLHttpRequest ? err : null); });
171 })
172 .catch(function (err) { return _this.chartOptions.onError("Error in hierarchy navigation", "Failed to get token", err instanceof XMLHttpRequest ? err : null); });
173 };
174 // simulate expand operation for each hierarchy node in a full path until the instance and then locate the instance
175 _this.simulateExpand = function (path, hierarchyNamesFromParam, instance) { return __awaiter(_this, void 0, void 0, function () {
176 var instanceIdentifier, isHierarchySelected, lastHierarchyNodeParent, ulToLook, nameSpan, _loop_1, this_1, idx, instanceNode, li, newListContentElem, instanceCount, hitElem;
177 var _this = this;
178 return __generator(this, function (_a) {
179 switch (_a.label) {
180 case 0:
181 instanceIdentifier = this.instanceNodeIdentifier(instance);
182 isHierarchySelected = this.selectedHierarchyName !== HierarchySelectionValues.All && this.selectedHierarchyName !== HierarchySelectionValues.Unparented;
183 lastHierarchyNodeParent = document.getElementsByClassName("tsi-hierarchy")[0];
184 _loop_1 = function (idx) {
185 var p, hierarchyNodeToExpand, pathNodeName, hierarchyNode_1, li, newListContentElem, hitCount, onClickFunc;
186 return __generator(this, function (_b) {
187 switch (_b.label) {
188 case 0:
189 p = path[idx];
190 if (isHierarchySelected && idx === 0) {
191 return [2 /*return*/, "continue"];
192 }
193 hierarchyNodeToExpand = void 0;
194 pathNodeName = this_1.hierarchyNodeIdentifier(p);
195 ulToLook = lastHierarchyNodeParent.getElementsByTagName("ul")[0];
196 nameSpan = Array.from(ulToLook.getElementsByClassName("tsi-name")).find(function (e) { return e.innerText === pathNodeName; });
197 if (!nameSpan) { // if the hierarchy node we are looking is not there, add it manually to prevent possible show more calls and dom insertions
198 hierarchyNode_1 = new HierarchyNode(pathNodeName, path.slice(0, idx), isHierarchySelected || hierarchyNamesFromParam ? idx - 1 : idx, '');
199 hierarchyNode_1.expand = function () {
200 return _this.pathSearchAndRenderResult({ search: { payload: _this.requestPayload(hierarchyNode_1.path), bubbleUpReject: true }, render: { target: hierarchyNode_1.node } })
201 .then(function (r) { return __awaiter(_this, void 0, void 0, function () {
202 var payload;
203 return __generator(this, function (_a) {
204 switch (_a.label) {
205 case 0:
206 payload = this.requestPayload(hierarchyNode_1.path);
207 payload["instances"].recursive = true;
208 return [4 /*yield*/, this.pathSearch(payload, null, null) // make a second call to retrieve the cumulative instance count for manually added hierarchy node
209 .then(function (r) {
210 hierarchyNode_1.node.select(".tsi-instanceCount").text(r.instances.hitCount);
211 })
212 .catch(function (err) { })];
213 case 1:
214 _a.sent();
215 hierarchyNode_1.isExpanded = true;
216 hierarchyNode_1.node.classed('tsi-expanded', true);
217 return [2 /*return*/];
218 }
219 });
220 }); })
221 .catch(function (err) { });
222 };
223 li = create("li").attr("role", "none");
224 ulToLook.insertBefore(li.node(), ulToLook.firstChild); // put it to the top of the list
225 newListContentElem = this_1.createHierarchyItemElem(hierarchyNode_1, this_1.hierarchyNodeIdentifier(hierarchyNode_1.name));
226 li.node().appendChild(newListContentElem.node());
227 hierarchyNode_1.node = li;
228 nameSpan = newListContentElem.select('.tsi-name').node();
229 hitCount = parseInt(lastHierarchyNodeParent.getElementsByClassName("tsi-hitCount")[0].innerText);
230 if (ulToLook.getElementsByClassName("tsi-hierarchyItem").length === hitCount + 1) {
231 ulToLook.removeChild(ulToLook.lastChild); // remove show more to prevent duplication
232 }
233 }
234 hierarchyNodeToExpand = nameSpan.parentNode;
235 lastHierarchyNodeParent = hierarchyNodeToExpand.parentNode;
236 onClickFunc = select(hierarchyNodeToExpand).on("click");
237 return [4 /*yield*/, onClickFunc.apply(hierarchyNodeToExpand)];
238 case 1:
239 _b.sent();
240 return [2 /*return*/];
241 }
242 });
243 };
244 this_1 = this;
245 idx = 0;
246 _a.label = 1;
247 case 1:
248 if (!(idx < path.length)) return [3 /*break*/, 4];
249 return [5 /*yield**/, _loop_1(idx)];
250 case 2:
251 _a.sent();
252 _a.label = 3;
253 case 3:
254 idx++;
255 return [3 /*break*/, 1];
256 case 4:
257 // locate the instance
258 ulToLook = lastHierarchyNodeParent.getElementsByTagName("ul")[0];
259 nameSpan = Array.from(ulToLook.getElementsByClassName("tsi-name")).find(function (e) { return e.innerText === _this.instanceNodeString(instance); });
260 if (!nameSpan) { //if the instance node we are looking is not there after expansion, add it manually to prevent possible show more calls and dom insertions
261 instanceNode = new InstanceNode(instance.timeSeriesId, instance.name, this.envTypes[instance.typeId], instance.hierarchyIds, instance.highlights, isHierarchySelected || hierarchyNamesFromParam ? path.length - 1 : path.length);
262 li = create("li").classed('tsi-leaf', true).attr("role", "none");
263 newListContentElem = this.createHierarchyItemElem(instanceNode, instanceIdentifier);
264 li.node().appendChild(newListContentElem.node());
265 ulToLook.insertBefore(li.node(), ulToLook.getElementsByClassName('tsi-leaf')[0]); // put it to the top of the instance list after hierarchy nodes
266 instanceNode.node = li;
267 instanceCount = parseInt(lastHierarchyNodeParent.getElementsByClassName("tsi-instanceCount")[0].innerText);
268 if (ulToLook.getElementsByClassName("tsi-hierarchyItem").length === instanceCount + 1) {
269 ulToLook.removeChild(ulToLook.lastChild); // remove show more to prevent duplication
270 }
271 nameSpan = newListContentElem.select('.tsi-name').node();
272 }
273 else {
274 ulToLook.insertBefore(nameSpan.parentNode.parentNode, ulToLook.getElementsByClassName('tsi-leaf')[0]); // move it to the top of the instance list after hierarchy nodes
275 }
276 hitElem = document.createElement('hit');
277 Utils.appendFormattedElementsFromString(select(hitElem), nameSpan.innerText);
278 nameSpan.innerText = '';
279 nameSpan.appendChild(hitElem);
280 return [2 /*return*/];
281 }
282 });
283 }); };
284 _this.prepareComponentForAfterLookup = function () {
285 _this.searchString = "";
286 _this.setModeAndRequestParamsForNavigate();
287 _this.viewType = ViewType.Hierarchy;
288 };
289 _this.removeCurrentHitsOfLastLookup = function () {
290 var hitNodes = _this.hierarchyElem.selectAll('hit').nodes();
291 if (hitNodes) {
292 hitNodes.forEach(function (hitNode) {
293 var spanElem = hitNode.parentNode;
294 spanElem.innerText = '';
295 Utils.appendFormattedElementsFromString(select(spanElem), _this.instanceNodeStringToDisplay(_this.lastLookedupInstance));
296 });
297 }
298 };
299 _this.showNotFoundForReverseLookup = function () {
300 _this.prepareComponentForAfterLookup();
301 _this.instanceLookupLoadingElem.style('display', 'none');
302 if (_this.selectedHierarchyName !== HierarchySelectionValues.All || _this.filterPathElem.classed('visible')) {
303 _this.lookupGloballyElem.style('display', 'inline');
304 }
305 else {
306 _this.lookupGloballyElem.style('display', 'none');
307 if (_this.hierarchyElem.text() === '') {
308 _this.clearAndGetResults();
309 }
310 }
311 _this.notFoundElem.classed('border-top', _this.filterPathElem.classed('visible'));
312 _this.notFoundElem.style('display', 'flex');
313 _this.hierarchyElem.style('display', 'block');
314 _this.path = _this.originalPathBeforeReverseLookup;
315 };
316 // renders instances data in flat list view, only in 'Search' mode
317 _this.renderInstances = function (data, target) {
318 var self = _this;
319 if (Object.keys(data).length === 0) {
320 _this.showNoResultsForSearch();
321 return;
322 }
323 else {
324 _this.noResultsElem.style('display', 'none');
325 _this.viewTypesElem.node().style.display = 'inline-flex';
326 }
327 target.select('.tsi-show-more.tsi-show-more-instance').remove();
328 Object.keys(data).forEach(function (i) {
329 var div;
330 if (data[i].name === _this.getString("Show More Instances")) {
331 div = target.append('div').classed('tsi-show-more tsi-show-more-instance', true);
332 div.append('span').classed('tsi-markedName', true).attr('tabindex', 0).text(i).on('click keydown', function (event) {
333 if (Utils.isKeyDownAndNotEnter(event)) {
334 return;
335 }
336 data[i].onClick();
337 });
338 }
339 else {
340 div = target.append('div').classed('tsi-modelResultWrapper', true).attr('tabindex', 0);
341 var instanceElem = _this.createInstanceElem(data[i]);
342 div.node().appendChild(instanceElem.node());
343 div.on('click keydown', function (event) {
344 var clickInstance = function () {
345 event.stopPropagation();
346 self.closeContextMenu();
347 var target = self.instanceListElem.select(function () { return this.parentNode.parentNode; });
348 var mouseWrapper = pointer(event, target.node());
349 var mouseElt = pointer(event);
350 self.prepareForContextMenu(data[i], target, mouseWrapper[1], mouseElt[1]);
351 self.chartOptions.onInstanceClick(data[i]);
352 };
353 if (event && event.type && event.type === 'keydown') {
354 var key = event.which || event.keyCode;
355 if (key === 40) { // pressed down
356 if (this.nextElementSibling)
357 this.nextElementSibling.focus();
358 }
359 else if (key === 38) { //pressed up
360 if (this.previousElementSibling)
361 this.previousElementSibling.focus();
362 }
363 else if (key === 13) {
364 clickInstance();
365 }
366 return;
367 }
368 clickInstance();
369 });
370 }
371 data[i].node = div;
372 });
373 };
374 _this.pathSearchAndRenderResult = function (_a) {
375 var _b = _a.search, payload = _b.payload, _c = _b.instancesContinuationToken, instancesContinuationToken = _c === void 0 ? null : _c, _d = _b.hierarchiesContinuationToken, hierarchiesContinuationToken = _d === void 0 ? null : _d, _e = _b.bubbleUpReject, bubbleUpReject = _e === void 0 ? false : _e, _f = _a.render, target = _f.target, _g = _f.locInTarget, locInTarget = _g === void 0 ? null : _g, _h = _f.skipLevels, skipLevels = _h === void 0 ? null : _h;
376 return _this.pathSearch(payload, instancesContinuationToken, hierarchiesContinuationToken).then(function (r) {
377 try {
378 if (r.error) {
379 throw r.error;
380 }
381 else {
382 _this.renderSearchResult(r, payload, target, locInTarget, skipLevels);
383 }
384 }
385 catch (err) {
386 throw err;
387 }
388 }).catch(function (err) {
389 _this.chartOptions.onError("Error in hierarchy navigation", "Failed to complete search", err instanceof XMLHttpRequest ? err : null);
390 if (bubbleUpReject) {
391 throw err;
392 }
393 });
394 };
395 _this.pathSearch = function (payload, instancesContinuationToken, hierarchiesContinuationToken) {
396 if (instancesContinuationToken === void 0) { instancesContinuationToken = null; }
397 if (hierarchiesContinuationToken === void 0) { hierarchiesContinuationToken = null; }
398 return _this.getToken().then(function (token) {
399 return _this.server.getTimeseriesInstancesPathSearch(token, _this.environmentFqdn, payload, instancesContinuationToken, hierarchiesContinuationToken);
400 }).catch(function (err) { throw err; });
401 };
402 _this.renderSearchResult = function (r, payload, target, locInTarget, skipLevels) {
403 var _a, _b, _c, _d, _e;
404 if (locInTarget === void 0) { locInTarget = null; }
405 if (skipLevels === void 0) { skipLevels = null; }
406 var self = _this;
407 var hierarchyData = {};
408 var instancesData = {};
409 if ((_b = (_a = r.hierarchyNodes) === null || _a === void 0 ? void 0 : _a.hits) === null || _b === void 0 ? void 0 : _b.length) {
410 var hitCountElem = target.select(".tsi-hitCount");
411 if (hitCountElem.size() == 0) {
412 hitCountElem = target.append('span').classed('tsi-hitCount', true).text('');
413 }
414 hitCountElem.text(r.hierarchyNodes.hitCount);
415 hierarchyData = self.fillDataRecursively(r.hierarchyNodes, _this.getToken, _this.environmentFqdn, payload, payload);
416 }
417 if ((_d = (_c = r.instances) === null || _c === void 0 ? void 0 : _c.hits) === null || _d === void 0 ? void 0 : _d.length) {
418 r.instances.hits.forEach(function (i) {
419 instancesData[_this.instanceNodeIdentifier(i)] = new InstanceNode(i.timeSeriesId, i.name, self.envTypes[i.typeId], i.hierarchyIds, i.highlights, payload.path.length - self.path.length);
420 });
421 }
422 if (((_e = r.instances) === null || _e === void 0 ? void 0 : _e.continuationToken) && r.instances.continuationToken !== 'END') {
423 var showMoreInstances_1 = new InstanceNode(null, _this.getString("Show More Instances"), null, null, null, payload.path.length - self.path.length);
424 showMoreInstances_1.onClick = function () { return __awaiter(_this, void 0, void 0, function () {
425 return __generator(this, function (_a) {
426 this.pathSearchAndRenderResult({
427 search: { payload: payload, hierarchiesContinuationToken: null, instancesContinuationToken: r.instances['continuationToken'] },
428 render: { target: showMoreInstances_1.node.select(function () { return this.parentNode; }), locInTarget: '.tsi-show-more.tsi-show-more-instance' }
429 });
430 return [2 /*return*/];
431 });
432 }); };
433 instancesData[showMoreInstances_1.name] = showMoreInstances_1;
434 if (!self.usedInstanceSearchContinuationTokens[r.instances.continuationToken]) {
435 self.lastInstanceContinuationToken = r.instances.continuationToken;
436 }
437 }
438 else {
439 self.lastInstanceContinuationToken = "END";
440 }
441 if (self.mode === State.Navigate) {
442 if (self.selectedHierarchyName !== HierarchySelectionValues.Unparented) {
443 self.renderTree(__assign(__assign({}, hierarchyData), instancesData), target, locInTarget);
444 }
445 else {
446 self.renderTree(instancesData, target, locInTarget);
447 }
448 }
449 else if (self.mode === State.Filter) {
450 self.renderTree(__assign(__assign({}, hierarchyData), instancesData), target, locInTarget, skipLevels);
451 }
452 else {
453 self.renderInstances(instancesData, target);
454 }
455 };
456 _this.closeContextMenu = function () {
457 if (_this.clickedInstance && _this.contextMenu) {
458 _this.contextMenu.remove();
459 selectAll('li.tsi-selected').classed('tsi-selected', false);
460 }
461 selectAll('.tsi-modelResultWrapper').classed('tsi-selected', false);
462 _this.clickedInstance = null;
463 };
464 _this.prepareForContextMenu = function (instanceObj, target, wrapperMousePos, eltMousePos) {
465 var contextMenuProps = {};
466 contextMenuProps['target'] = target;
467 contextMenuProps['wrapperMousePos'] = wrapperMousePos;
468 contextMenuProps['eltMousePos'] = eltMousePos;
469 _this.contextMenuProps = contextMenuProps;
470 _this.clickedInstance = instanceObj;
471 instanceObj.node.classed('tsi-selected', true);
472 };
473 _this.drawContextMenu = function (contextMenuItems, contextMenuOptions) {
474 var itemList = [];
475 var contextMenuList;
476 var searchString = "";
477 _this.contextMenu = _this.contextMenuProps['target'].append('div').classed('tsi-hierarchyNavigationContextMenu', true).attr('style', function () { return "top: " + (_this.contextMenuProps['wrapperMousePos'] - _this.contextMenuProps['eltMousePos']) + "px"; });
478 var renderList = function (contextMenuItems) {
479 if (_this.contextMenu.select("ul").empty()) {
480 contextMenuList = _this.contextMenu.append('ul');
481 }
482 else {
483 _this.contextMenu.select("ul").text('');
484 }
485 contextMenuItems.forEach(function (item) {
486 var option = item.name;
487 var li = contextMenuList.append('li');
488 if (!contextMenuOptions.isSelectionEnabled) {
489 li.attr('tabindex', 0)
490 .attr('arialabel', option)
491 .attr('title', option)
492 .on('click keydown', function (event) {
493 if (Utils.isKeyDownAndNotEnter(event)) {
494 return;
495 }
496 item.action();
497 _this.closeContextMenu();
498 });
499 var itemWrapperElem = li.append('div').classed('tsi-selectionItemWrapper', true);
500 Utils.appendFormattedElementsFromString(itemWrapperElem, Utils.mark(searchString, option), { splitByTag: 'mark' });
501 }
502 else {
503 li.attr('tabindex', 0)
504 .on('click keydown', function (event) {
505 if (Utils.isKeyDownAndNotEnter(event)) {
506 return;
507 }
508 var elem = select(event.currentTarget).select(".tsi-hierarchyCheckbox");
509 if (elem.classed("tsi-notSelected")) {
510 itemList.push(item);
511 elem.classed("tsi-notSelected", false);
512 elem.attr("aria-checked", true);
513 }
514 else {
515 var index = itemList.map(function (elem) { return elem.name; }).indexOf(item.name);
516 itemList.splice(index, 1);
517 elem.classed("tsi-notSelected", true);
518 elem.attr("aria-checked", false);
519 }
520 itemList.length === 0 ?
521 _this.contextMenu.select("button").classed("disabled", true)
522 : _this.contextMenu.select("button").classed("disabled", false);
523 });
524 var itemWrapperElem = li.append('div').classed('tsi-selectionItemWrapper', true);
525 itemWrapperElem.append('span').classed('tsi-hierarchyCheckbox tsi-notSelected', true)
526 .attr("role", "checkbox").attr("aria-checked", false);
527 var itemElem = itemWrapperElem.append('span').classed('tsi-selectionItem', true).attr('title', option);
528 Utils.appendFormattedElementsFromString(itemElem, Utils.mark(searchString, option), { splitByTag: 'mark' });
529 itemWrapperElem.append('span').classed('tsi-selectionItemKind', true).classed(item.kind, true).attr('title', item.kind.charAt(0).toUpperCase() + item.kind.slice(1));
530 }
531 });
532 };
533 // draw filter box if enabled
534 if (contextMenuOptions.isFilterEnabled) {
535 var searchBox = _this.contextMenu.append('div').classed('tsi-search', true);
536 searchBox.append('i').classed('tsi-search-icon', true);
537 searchBox.append('input').classed('tsi-searchInput', true).attr('placeholder', _this.getString('Search'))
538 .on('input', function (event) {
539 var regex = new RegExp(event.currentTarget.value, 'gi');
540 searchString = event.currentTarget.value;
541 renderList(contextMenuItems.filter(function (varObj) { return varObj.name.match(regex); }));
542 itemList = [];
543 _this.contextMenu.select("button").classed("disabled", true);
544 });
545 }
546 //draw variable list with checkbox if selection enabled
547 renderList(contextMenuItems);
548 //add button
549 if (contextMenuOptions.isSelectionEnabled) {
550 _this.contextMenu.append('button').classed("tsi-primaryButton", true).classed("disabled", true).text(_this.getString("Add")).on('click', function () {
551 itemList.forEach(function (item) { return item.action(); });
552 _this.closeContextMenu();
553 });
554 }
555 // move context menu above if necessary for tag selection visibility around the bottom of the page
556 var leftSpaceAtBottom = _this.contextMenuProps['target'].node().getBoundingClientRect().height - parseFloat(_this.contextMenu.node().style.top);
557 var overflowAtBottom = _this.contextMenu.node().getBoundingClientRect().height - leftSpaceAtBottom;
558 if (overflowAtBottom > 0)
559 _this.contextMenu.style('top', (parseFloat(_this.contextMenu.node().style.top) - overflowAtBottom) + 'px');
560 var contextMenuFirstElt = select('.tsi-hierarchyNavigationContextMenu li').node();
561 if (contextMenuFirstElt) {
562 contextMenuFirstElt.focus();
563 }
564 };
565 _this.hasHits = function (str) {
566 return str && (str.indexOf("<hit>") !== -1);
567 };
568 _this.hierarchyNodeIdentifier = function (hName) {
569 return hName ? hName : '(' + _this.getString("Empty") + ')';
570 };
571 _this.instanceNodeIdentifier = function (instance) {
572 return "instance-" + Utils.getInstanceKey(instance);
573 };
574 _this.instanceNodeStringToDisplay = function (instance) {
575 var _a;
576 return ((_a = instance.highlights) === null || _a === void 0 ? void 0 : _a.name) || Utils.getHighlightedTimeSeriesIdToDisplay(instance)
577 || instance.name || Utils.getTimeSeriesIdToDisplay(instance, _this.getString('Empty'));
578 };
579 _this.instanceNodeString = function (instance) {
580 return instance.name || Utils.getTimeSeriesIdString(instance);
581 };
582 _this.clearAndHideFilterPath = function () {
583 select('.tsi-path-list').text('');
584 select('.tsi-filter-clear').style('display', 'none');
585 _this.filterPathElem.classed('visible', false);
586 };
587 // when an hierarchy is selected from the flyout selection menu
588 _this.selectHierarchy = function (pathName, applySearch) {
589 if (applySearch === void 0) { applySearch = true; }
590 _this.path = pathName === HierarchySelectionValues.All || pathName === HierarchySelectionValues.Unparented ? [] : [pathName];
591 _this.selectedHierarchyName = pathName;
592 var selectedhierarchyId = pathName === HierarchySelectionValues.All || pathName === HierarchySelectionValues.Unparented ? pathName : _this.envHierarchies[_this.selectedHierarchyName].id;
593 _this.chartOptions.onSelect(selectedhierarchyId);
594 var pathText = pathName === HierarchySelectionValues.All ? _this.getString("All hierarchies") : pathName === HierarchySelectionValues.Unparented ? _this.getString("Unassigned Time Series Instances") : pathName;
595 select('.tsi-hierarchy-name').text(pathText).attr('title', pathText);
596 _this.clearAndGetResults(applySearch);
597 _this.clearAndHideFilterPath();
598 _this.isHierarchySelectionActive = false;
599 _this.hierarchyListWrapperElem.style('display', 'none');
600 _this.notFoundElem.style('display', 'none');
601 };
602 _this.resettingVariablesForEnvChange = function () {
603 _this.path = [];
604 _this.selectedHierarchyName = HierarchySelectionValues.All;
605 _this.searchString = '';
606 _this.lastInstanceContinuationToken = null;
607 _this.usedInstanceSearchContinuationTokens = {};
608 _this.envHierarchies = {};
609 _this.envTypes = {};
610 _this.setModeAndRequestParamsForNavigate();
611 _this.viewType = ViewType.Hierarchy;
612 _this.clickedInstance = null;
613 _this.isHierarchySelectionActive = false;
614 };
615 _this.server = new ServerClient();
616 function isTarget(event) {
617 return event.target === this || this.contains(event.target);
618 }
619 select("html").on("click. keydown." + Utils.guid(), function (event) {
620 if (_this.clickedInstance && _this.contextMenu) {
621 if (event.type && event.type === 'keydown') {
622 if (!_this.contextMenu.filter(isTarget).empty()) {
623 var key = event.which || event.keyCode;
624 if (key === KeyCodes.Esc) { // close context menu when pressed esc on it
625 _this.closeContextMenu();
626 }
627 return;
628 }
629 }
630 else {
631 if (_this.contextMenu.filter(isTarget).empty()) { // close context menu when clicked any other target outside of it
632 _this.closeContextMenu();
633 }
634 }
635 }
636 if (_this.isHierarchySelectionActive) {
637 if (event && event.type && event.type === 'keydown') {
638 if (!select(_this.hierarchyListWrapperElem.node().parentNode).filter(isTarget).empty()) {
639 var key = event.which || event.keyCode;
640 if (key === KeyCodes.Esc) { // close hierarchy selection dropdown when pressed esc on it
641 _this.isHierarchySelectionActive = false;
642 _this.hierarchyListWrapperElem.style('display', 'none');
643 }
644 return;
645 }
646 }
647 else {
648 if (select(_this.hierarchyListWrapperElem.node().parentNode).filter(isTarget).empty()) { // close hierarchy selection dropdown when clicked any other target outside of it
649 _this.isHierarchySelectionActive = false;
650 _this.hierarchyListWrapperElem.style('display', 'none');
651 }
652 }
653 }
654 });
655 return _this;
656 }
657 HierarchyNavigation.prototype.HierarchyNavigation = function () {
658 };
659 HierarchyNavigation.prototype.render = function (environmentFqdn, getToken, hierarchyNavOptions) {
660 if (hierarchyNavOptions === void 0) { hierarchyNavOptions = {}; }
661 return __awaiter(this, void 0, void 0, function () {
662 var self, targetElement, hierarchyNavWrapper, selectedHierarchyId, hierarchy, autocompleteOnInput, handleKeydown;
663 var _this = this;
664 return __generator(this, function (_a) {
665 switch (_a.label) {
666 case 0:
667 self = this;
668 this.chartOptions.setOptions(hierarchyNavOptions);
669 this.getToken = getToken;
670 this.environmentFqdn = environmentFqdn;
671 this.resettingVariablesForEnvChange();
672 targetElement = select(this.renderTarget);
673 targetElement.text('');
674 hierarchyNavWrapper = targetElement.append('div').attr('class', 'tsi-hierarchy-nav-wrapper');
675 _super.prototype.themify.call(this, hierarchyNavWrapper, this.chartOptions.theme);
676 //get the most recent types to show in the context menu on instance click
677 return [4 /*yield*/, getToken().then(function (token) {
678 return _this.server.getTimeseriesTypes(token, environmentFqdn).then(function (r) {
679 try {
680 if (r.error) {
681 throw r.error;
682 }
683 else {
684 r.types.forEach(function (t) {
685 _this.envTypes[t.id] = t;
686 });
687 }
688 }
689 catch (err) {
690 throw err;
691 }
692 }).catch(function (err) { return _this.chartOptions.onError("Error in hierarchy navigation", "Failed to load types for navigation", err instanceof XMLHttpRequest ? err : null); });
693 }).catch(function (err) { return _this.chartOptions.onError("Error in hierarchy navigation", "Failed to get token", err instanceof XMLHttpRequest ? err : null); })];
694 case 1:
695 //get the most recent types to show in the context menu on instance click
696 _a.sent();
697 //get the most recent hierarchies for reverse lookup
698 return [4 /*yield*/, getToken().then(function (token) {
699 return _this.server.getTimeseriesHierarchies(token, environmentFqdn).then(function (r) {
700 try {
701 if (r.error) {
702 throw r.error;
703 }
704 else {
705 r.hierarchies.forEach(function (h) {
706 _this.envHierarchies[h.name] = h;
707 });
708 }
709 }
710 catch (err) {
711 throw err;
712 }
713 }).catch(function (err) { return _this.chartOptions.onError("Error in hierarchy navigation", "Failed to load hierarchies for navigation", err instanceof XMLHttpRequest ? err : null); });
714 }).catch(function (err) { return _this.chartOptions.onError("Error in hierarchy navigation", "Failed to get token", err instanceof XMLHttpRequest ? err : null); })];
715 case 2:
716 //get the most recent hierarchies for reverse lookup
717 _a.sent();
718 selectedHierarchyId = hierarchyNavOptions.selectedHierarchyId;
719 if (selectedHierarchyId) {
720 if (selectedHierarchyId === HierarchySelectionValues.All || selectedHierarchyId === HierarchySelectionValues.Unparented) {
721 this.selectedHierarchyName = selectedHierarchyId; //Using enum values of All and Unparented as both name and id
722 this.path = [];
723 }
724 else {
725 hierarchy = Object.values(this.envHierarchies).find(function (h) { return h["id"] === selectedHierarchyId; });
726 if (hierarchy) {
727 this.selectedHierarchyName = hierarchy["name"];
728 this.path = [this.selectedHierarchyName];
729 }
730 }
731 }
732 getToken().then(function (token) {
733 self.server.getTimeseriesInstancesPathSearch(token, environmentFqdn, { searchString: '', path: _this.path, hierarchies: { sort: { by: HierarchiesSort.CumulativeInstanceCount }, expand: { kind: HierarchiesExpand.OneLevel }, pageSize: 100 } }).then(function (r) {
734 try {
735 if (r.error) {
736 throw r.error;
737 }
738 else {
739 // hierarchy selection button
740 var hierarchySelectionWrapper = hierarchyNavWrapper.append('div').classed('tsi-hierarchy-selection-wrapper', true);
741 _this.hierarchySelectorElem = hierarchySelectionWrapper.append('button').classed('tsi-hierarchy-select', true)
742 .attr("aria-haspopup", "listbox")
743 .on('click keydown', function (event) {
744 if (Utils.isKeyDownAndNotEnter(event)) {
745 return;
746 }
747 if (_this.isHierarchySelectionActive) {
748 _this.hierarchyListWrapperElem.style('display', 'none');
749 _this.isHierarchySelectionActive = false;
750 }
751 else {
752 _this.renderHierarchySelection();
753 _this.isHierarchySelectionActive = true;
754 }
755 });
756 _this.hierarchySelectorElem.append('span').classed('tsi-hierarchy-name', true).text(_this.selectedHierarchyName === HierarchySelectionValues.All ? _this.getString("All hierarchies")
757 : _this.selectedHierarchyName === HierarchySelectionValues.Unparented ? _this.getString("Unassigned Time Series Instances")
758 : _this.selectedHierarchyName);
759 _this.hierarchySelectorElem.append('i').classed('tsi-down-caret-icon', true);
760 // hierarchy flyout list
761 _this.hierarchyListWrapperElem = hierarchySelectionWrapper.append('div').classed('tsi-hierarchy-list-wrapper', true);
762 _this.hierarchyListElem = _this.hierarchyListWrapperElem.append('ul').classed('tsi-hierarchy-list', true).attr('role', 'listbox').attr("id", "tsi-hierarchy-listbox");
763 // search
764 _this.searchWrapperElem = hierarchyNavWrapper.append('div').classed('tsi-hierarchy-search', true);
765 var modelAutocomplete = new ModelAutocomplete(_this.searchWrapperElem.node());
766 modelAutocomplete.render(environmentFqdn, getToken, {
767 onInput: autocompleteOnInput,
768 onKeydown: function (event, ap) { handleKeydown(event, ap); },
769 theme: hierarchyNavOptions.theme,
770 strings: _this.chartOptions.strings
771 });
772 _this.viewTypesElem = _this.searchWrapperElem.append('div').classed('tsi-view-types', true).attr("role", "tablist");
773 _this.viewTypesElem.append('div').classed('tsi-view-type', true)
774 .attr('title', 'Hierarchy View')
775 .attr('tabindex', 0)
776 .attr('arialabel', 'Hierarchy View')
777 .attr('role', 'tab')
778 .on('click keydown', function (event) {
779 if (Utils.isKeyDownAndNotEnter(event)) {
780 return;
781 }
782 self.switchToSearchView(ViewType.Hierarchy);
783 })
784 .append('i').classed('tsi-tree-icon', true);
785 _this.viewTypesElem.append('div').classed('tsi-view-type selected', true)
786 .attr('title', 'List View')
787 .attr('tabindex', 0)
788 .attr('arialabel', 'List View')
789 .attr('role', 'tab')
790 .attr('aria-selected', true)
791 .on('click keydown', function (event) {
792 if (Utils.isKeyDownAndNotEnter(event)) {
793 return;
794 }
795 self.switchToSearchView(ViewType.List);
796 })
797 .append('i').classed('tsi-list-icon', true);
798 // filter path
799 _this.filterPathElem = hierarchyNavWrapper.append('div').classed('tsi-filter-path-wrapper', true);
800 var filterPath = _this.filterPathElem.append('div').classed('tsi-filter-path', true);
801 filterPath.append('span').classed('tsi-path-list', true);
802 filterPath.append('i').classed('tsi-close-icon tsi-filter-clear', true)
803 .attr('tabindex', 0)
804 .attr('arialabel', 'Clear Path Filter')
805 .attr('title', 'Clear Path Filter')
806 .on('click keydown', function (event) {
807 if (Utils.isKeyDownAndNotEnter(event)) {
808 return;
809 }
810 self.path = (self.selectedHierarchyName === HierarchySelectionValues.All || self.selectedHierarchyName === HierarchySelectionValues.Unparented) ? [] : [self.selectedHierarchyName];
811 self.noResultsElem.style('display', 'none');
812 self.clearAndGetResults();
813 self.clearAndHideFilterPath();
814 });
815 _this.instanceLookupLoadingElem = hierarchyNavWrapper.append('div').classed('tsi-instance-lookup-loading', true);
816 _this.instanceLookupLoadingElem.append('i').classed('tsi-spinner-icon', true);
817 _this.instanceLookupLoadingElem.append('span').classed('tsi-lookup-instance', true);
818 // no search results
819 _this.noResultsElem = hierarchyNavWrapper.append('div').classed('tsi-noResults', true).style('display', 'none');
820 var noInstancesMessage = _this.noResultsElem.append('div').classed('tsi-not-found-message', true).text(_this.getString("No search result")).attr("role", "alert");
821 _this.searchGloballyElem = noInstancesMessage.append('a').classed('tsi-search-globally-link', true).text(_this.getString("Search globally")).style('display', 'none')
822 .attr('title', _this.getString("Search globally"))
823 .attr('tabindex', 0)
824 .attr('arialabel', _this.getString("Search globally"))
825 .on('click keydown', function (event) {
826 if (Utils.isKeyDownAndNotEnter(event)) {
827 return;
828 }
829 self.selectHierarchy(HierarchySelectionValues.All, false);
830 self.switchToSearchView(ViewType.List);
831 self.noResultsElem.style('display', 'none');
832 });
833 _this.noResultsElem.append('i').attr('class', 'tsi-clear')
834 .attr('title', _this.getString("Dismiss"))
835 .attr("tabindex", "0").attr("role", "button")
836 .attr("aria-label", _this.getString("Dismiss"))
837 .on('click keydown', function (event) {
838 if (Utils.isKeyDownAndNotEnter(event)) {
839 return;
840 }
841 self.searchWrapperElem.select("input").node().value = "";
842 self.searchWrapperElem.select(".tsi-clear").dispatch('click');
843 self.noResultsElem.style('display', 'none');
844 });
845 // could not find the reverse lookup item under the selected hierarchy
846 _this.notFoundElem = hierarchyNavWrapper.append('div').classed('tsi-notFound', true).style('display', 'none');
847 var notFoundMessage = _this.notFoundElem.append('div').classed('tsi-not-found-message', true).text(_this.getString("Instance not found")).attr("role", "alert");
848 _this.lookupGloballyElem = notFoundMessage.append('a').classed('tsi-search-globally-link', true).text(_this.getString("Lookup globally")).style('display', 'none')
849 .attr('title', _this.getString("Lookup globally"))
850 .attr('tabindex', 0)
851 .attr('arialabel', _this.getString("Lookup globally"))
852 .on('click keydown', function (event) {
853 if (Utils.isKeyDownAndNotEnter(event)) {
854 return;
855 }
856 self.selectHierarchy(HierarchySelectionValues.All, false);
857 self.showInstance(self.timeSeriesIdForLookup);
858 });
859 _this.notFoundElem.append('i').attr('class', 'tsi-clear')
860 .attr('title', _this.getString("Dismiss"))
861 .attr("tabindex", "0").attr("role", "button")
862 .attr("aria-label", _this.getString("Dismiss"))
863 .on('click keydown', function (event) {
864 if (Utils.isKeyDownAndNotEnter(event)) {
865 return;
866 }
867 self.notFoundElem.style('display', 'none');
868 });
869 // result (hierarchy or flat list)
870 var results = hierarchyNavWrapper.append('div').classed('tsi-hierarchy-or-list-wrapper', true);
871 // hierarchy
872 _this.hierarchyElem = results.append('div').classed('tsi-hierarchy', true).attr("role", "navigation").on('scroll', function () {
873 self.closeContextMenu();
874 });
875 // flat list
876 _this.instanceListWrapperElem = results.append('div').classed('tsi-list', true).on('scroll', function () {
877 if (self.viewType === ViewType.List) {
878 self.closeContextMenu();
879 if (self.lastInstanceContinuationToken && (self.lastInstanceContinuationToken !== "END")) {
880 var that = this;
881 if (that.scrollTop + that.clientHeight + 50 > self.instanceListElem.node().clientHeight) {
882 if (self.lastInstanceContinuationToken === null || !self.usedInstanceSearchContinuationTokens[self.lastInstanceContinuationToken]) {
883 self.usedInstanceSearchContinuationTokens[self.lastInstanceContinuationToken] = true;
884 self.pathSearchAndRenderResult({ search: { payload: self.requestPayload(), instancesContinuationToken: self.lastInstanceContinuationToken }, render: { target: self.instanceListElem } });
885 }
886 }
887 }
888 }
889 });
890 _this.instanceListElem = _this.instanceListWrapperElem.append('div').classed('tsi-search-results', true);
891 _this.pathSearchAndRenderResult({ search: { payload: self.requestPayload() }, render: { target: _this.hierarchyElem } });
892 }
893 }
894 catch (err) {
895 throw err;
896 }
897 }).catch(function (err) { return _this.chartOptions.onError("Error in hierarchy navigation", "Failed to complete search", err instanceof XMLHttpRequest ? err : null); });
898 }).catch(function (err) { return _this.chartOptions.onError("Error in hierarchy navigation", "Failed to get token", err instanceof XMLHttpRequest ? err : null); });
899 autocompleteOnInput = function (st, event) {
900 if (st.length === 0) {
901 _this.searchString = st;
902 _this.viewTypesElem.node().style.display = 'none';
903 _this.searchGloballyElem.node().style.display = 'none';
904 _this.switchToSearchView(ViewType.Hierarchy, false);
905 _this.clearAndGetResults();
906 }
907 else {
908 if (event.which === 13 || event.keyCode === 13) {
909 _this.searchString = st;
910 _this.switchToSearchView(ViewType.List, false);
911 _this.clearAndGetResults();
912 }
913 }
914 };
915 handleKeydown = function (event, ap) {
916 if (!ap.isOpened) ;
917 };
918 return [2 /*return*/];
919 }
920 });
921 });
922 };
923 HierarchyNavigation.prototype.setModeAndRequestParamsForSearch = function () {
924 this.mode = State.Search;
925 var options = this.chartOptions.hierarchyOptions;
926 options.isInstancesRecursive = true;
927 options.isInstancesHighlighted = true;
928 options.instancesSort = InstancesSort.Rank;
929 options.hierarchiesExpand = HierarchiesExpand.UntilChildren;
930 options.hierarchiesSort = HierarchiesSort.CumulativeInstanceCount;
931 };
932 HierarchyNavigation.prototype.setModeAndRequestParamsForNavigate = function () {
933 this.mode = State.Navigate;
934 var options = this.chartOptions.hierarchyOptions;
935 options.isInstancesRecursive = false;
936 options.isInstancesHighlighted = true;
937 options.instancesSort = InstancesSort.DisplayName;
938 options.hierarchiesExpand = HierarchiesExpand.OneLevel;
939 options.hierarchiesSort = HierarchiesSort.Name;
940 };
941 HierarchyNavigation.prototype.setModeAndRequestParamsForFilter = function () {
942 this.mode = State.Filter;
943 var options = this.chartOptions.hierarchyOptions;
944 options.isInstancesRecursive = false;
945 options.isInstancesHighlighted = true;
946 options.instancesSort = InstancesSort.DisplayName;
947 options.hierarchiesExpand = HierarchiesExpand.UntilChildren;
948 options.hierarchiesSort = HierarchiesSort.CumulativeInstanceCount;
949 };
950 // prepares the parameters for search request
951 HierarchyNavigation.prototype.requestPayload = function (path) {
952 if (path === void 0) { path = null; }
953 var payload = {};
954 payload["searchString"] = this.searchString;
955 payload["path"] = path ? path : this.path;
956 payload["instances"] = { recursive: this.chartOptions.hierarchyOptions.isInstancesRecursive, sort: { by: this.chartOptions.hierarchyOptions.instancesSort }, highlights: this.chartOptions.hierarchyOptions.isInstancesHighlighted, pageSize: this.chartOptions.hierarchyOptions.instancesPageSize };
957 if (this.selectedHierarchyName !== HierarchySelectionValues.Unparented && (this.mode !== State.Search)) { // hierarchyNodes are not needed for showing unassigned instances or flat list instance search results
958 payload["hierarchies"] = { expand: { kind: this.chartOptions.hierarchyOptions.hierarchiesExpand }, sort: { by: this.chartOptions.hierarchyOptions.hierarchiesSort }, pageSize: this.chartOptions.hierarchyOptions.hierarchiesPageSize };
959 }
960 return payload;
961 };
962 // clears both hierarchy tree and flat list for new results
963 HierarchyNavigation.prototype.clearAndGetResults = function (applySearch) {
964 if (applySearch === void 0) { applySearch = true; }
965 this.instanceListElem.text('');
966 this.hierarchyElem.text('');
967 this.lastInstanceContinuationToken = null;
968 this.usedInstanceSearchContinuationTokens = {};
969 if (this.mode === State.Search) {
970 this.chartOptions.hierarchyOptions.isInstancesRecursive = this.selectedHierarchyName === HierarchySelectionValues.Unparented ? false : true;
971 }
972 if (applySearch) {
973 if (this.viewType === ViewType.Hierarchy) {
974 return this.pathSearchAndRenderResult({ search: { payload: this.requestPayload() }, render: { target: this.hierarchyElem } });
975 }
976 else {
977 return this.pathSearchAndRenderResult({ search: { payload: this.requestPayload() }, render: { target: this.instanceListElem } });
978 }
979 }
980 };
981 HierarchyNavigation.prototype.showInstance = function (timeSeriesID, hierarchyIds) {
982 if (hierarchyIds === void 0) { hierarchyIds = null; }
983 return __awaiter(this, void 0, void 0, function () {
984 var isHierarchySelected, hierarchyNamesFromParam, hNames, instance, paths, response, instanceFieldValues_1, err_1, err_2;
985 var _this = this;
986 return __generator(this, function (_a) {
987 switch (_a.label) {
988 case 0:
989 this.removeCurrentHitsOfLastLookup();
990 this.timeSeriesIdForLookup = timeSeriesID;
991 isHierarchySelected = this.selectedHierarchyName !== HierarchySelectionValues.All && this.selectedHierarchyName !== HierarchySelectionValues.Unparented;
992 hierarchyNamesFromParam = hierarchyIds ? hierarchyIds.map(function (hId) { return Object.keys(_this.envHierarchies).find(function (n) { return _this.envHierarchies[n].id === hId; }); }) : null;
993 hNames = hierarchyNamesFromParam ? hierarchyNamesFromParam : isHierarchySelected ? [null, this.selectedHierarchyName] : __spreadArray([null], Object.keys(this.envHierarchies));
994 paths = [];
995 _a.label = 1;
996 case 1:
997 _a.trys.push([1, 13, , 14]);
998 this.prepareComponentForLookup(timeSeriesID);
999 response = void 0;
1000 return [4 /*yield*/, this.getInstance(timeSeriesID)];
1001 case 2:
1002 response = _a.sent();
1003 instance = response['get'][0]['instance'];
1004 instanceFieldValues_1 = instance.instanceFields ? Object.values(instance.instanceFields) : [];
1005 if (!instance) return [3 /*break*/, 11];
1006 _a.label = 3;
1007 case 3:
1008 _a.trys.push([3, 9, , 10]);
1009 this.lastLookedupInstance = instance;
1010 return [4 /*yield*/, this.doExactSearchWithPossiblePaths(timeSeriesID, hNames)];
1011 case 4:
1012 response = _a.sent();
1013 response.forEach(function (r, idx) {
1014 var _a, _b, _c, _d;
1015 if (r.error) {
1016 throw r.error;
1017 }
1018 if (idx === 0) { // if instance is direct instance of the top root
1019 if ((_a = r.instances) === null || _a === void 0 ? void 0 : _a.hitCount) {
1020 paths.push([]);
1021 }
1022 }
1023 else { // under defined hierarchies
1024 if ((_c = (_b = r.hierarchyNodes) === null || _b === void 0 ? void 0 : _b.hits) === null || _c === void 0 ? void 0 : _c.length) { // if the instance is under sub nodes in the hierarchy
1025 r.hierarchyNodes.hits.forEach(function (h) {
1026 var currentHit = h;
1027 if (instanceFieldValues_1.indexOf(currentHit.name) !== -1) {
1028 var path = [hNames[idx]];
1029 path.push(currentHit.name);
1030 while (currentHit.hierarchyNodes) {
1031 currentHit = currentHit.hierarchyNodes.hits[0];
1032 if ((instanceFieldValues_1 === null || instanceFieldValues_1 === void 0 ? void 0 : instanceFieldValues_1.indexOf(currentHit.name)) !== -1) {
1033 path.push(currentHit.name);
1034 }
1035 }
1036 paths.push(path);
1037 }
1038 });
1039 }
1040 else if ((_d = r.instances) === null || _d === void 0 ? void 0 : _d.hitCount) { // if it is direct instance under the defined the hierarchy
1041 var path = [hNames[idx]];
1042 paths.push(path);
1043 }
1044 }
1045 });
1046 if (!paths.length) return [3 /*break*/, 7];
1047 // go back to default navigate mode without exact search
1048 this.prepareComponentForAfterLookup();
1049 return [4 /*yield*/, this.clearAndGetResults()];
1050 case 5:
1051 _a.sent(); // get a fresh hierarchy with defaulf settings for navigation, ready to expand and locate
1052 return [4 /*yield*/, Promise.all(paths.map(function (p) { return _this.simulateExpand(p, hierarchyNamesFromParam, instance); }))];
1053 case 6:
1054 _a.sent();
1055 this.clearAndHideFilterPath();
1056 return [3 /*break*/, 8];
1057 case 7:
1058 this.showNotFoundForReverseLookup();
1059 _a.label = 8;
1060 case 8:
1061 this.hierarchyElem.style('display', 'block');
1062 this.instanceLookupLoadingElem.style('display', 'none');
1063 return [3 /*break*/, 10];
1064 case 9:
1065 err_1 = _a.sent();
1066 throw err_1; // throw to be catched by parent try/catch block
1067 case 10: return [3 /*break*/, 12];
1068 case 11:
1069 this.showNotFoundForReverseLookup();
1070 _a.label = 12;
1071 case 12: return [3 /*break*/, 14];
1072 case 13:
1073 err_2 = _a.sent();
1074 this.showNotFoundForReverseLookup();
1075 return [3 /*break*/, 14];
1076 case 14: return [2 /*return*/];
1077 }
1078 });
1079 });
1080 };
1081 // renders tree for both 'Navigate' and 'Filter' mode (with Hierarchy View option selected), locInTarget refers to the 'show more' element -either hierarchy or instance- within the target
1082 HierarchyNavigation.prototype.renderTree = function (data, target, locInTarget, skipLevels) {
1083 var _this = this;
1084 if (locInTarget === void 0) { locInTarget = null; }
1085 if (skipLevels === void 0) { skipLevels = null; }
1086 if (Object.keys(data).length === 0) {
1087 this.showNoResultsForSearch();
1088 return;
1089 }
1090 else {
1091 this.noResultsElem.style('display', 'none');
1092 if (this.mode === State.Filter) {
1093 this.viewTypesElem.node().style.display = 'inline-flex';
1094 }
1095 }
1096 var list, currentShowMore;
1097 if (!locInTarget) {
1098 list = target.append('ul').attr("role", target === this.hierarchyElem ? "tree" : "group");
1099 }
1100 else {
1101 if (locInTarget === '.tsi-show-more.tsi-show-more-hierarchy')
1102 currentShowMore = target.selectAll('.tsi-show-more.tsi-show-more-hierarchy').filter(function (d, i, list) {
1103 return i === list.length - 1;
1104 });
1105 else
1106 currentShowMore = target.selectAll('.tsi-show-more.tsi-show-more-instance').filter(function (d, i, list) {
1107 return i === list.length - 1;
1108 });
1109 currentShowMore.node().style.display = 'none';
1110 currentShowMore.classed('tsi-target-loc', true);
1111 }
1112 if (locInTarget && skipLevels) {
1113 while (skipLevels) {
1114 data = data[Object.keys(data)[0]].children;
1115 skipLevels--;
1116 }
1117 }
1118 Object.keys(data).forEach(function (el) {
1119 var li, newListElem;
1120 var nodeNameToCheckIfExists = data[el] instanceof InstanceNode && data[el].name !== _this.getString("Show More Instances") ? _this.instanceNodeString(data[el]) : el;
1121 if (locInTarget) {
1122 if (target.selectAll(".tsi-name").nodes().find(function (e) { return e.innerText === nodeNameToCheckIfExists; })) {
1123 return;
1124 }
1125 li = target.insert('li', '.tsi-target-loc').classed('tsi-leaf', data[el].isLeaf);
1126 }
1127 else {
1128 if (list.selectAll(".tsi-name").nodes().find(function (e) { return e.innerText === nodeNameToCheckIfExists; })) {
1129 return;
1130 }
1131 li = list.append('li').classed('tsi-leaf', data[el].isLeaf);
1132 }
1133 li.attr("role", "none");
1134 if (el === _this.getString("Show More Hierarchies")) {
1135 li.classed('tsi-show-more tsi-show-more-hierarchy', true)
1136 .append('span')
1137 .classed('tsi-hierarchyItem', true)
1138 .attr('tabindex', 0)
1139 .attr("role", "treeitem").attr('aria-expanded', false)
1140 .attr('style', "padding-left: " + ((data[el].level) * 18 + 20) + "px").text(_this.getString("Show more")).on('click keydown', function (event) {
1141 if (Utils.isKeyDownAndNotEnter(event)) {
1142 return;
1143 }
1144 return data[el].onClick();
1145 });
1146 }
1147 else if (el === _this.getString("Show More Instances")) {
1148 li.classed('tsi-show-more tsi-show-more-instance', true)
1149 .append('span')
1150 .classed('tsi-hierarchyItem', true)
1151 .attr('tabindex', 0)
1152 .attr("role", "treeitem").attr('aria-expanded', false)
1153 .attr('style', "padding-left: " + ((data[el].level) * 18 + 20) + "px").text(_this.getString("Show more")).on('click keydown', function (event) {
1154 if (Utils.isKeyDownAndNotEnter(event)) {
1155 return;
1156 }
1157 data[el].onClick();
1158 });
1159 }
1160 else {
1161 newListElem = _this.createHierarchyItemElem(data[el], el);
1162 li.node().appendChild(newListElem.node());
1163 }
1164 data[el].node = li;
1165 if (data[el].children) {
1166 data[el].isExpanded = true;
1167 data[el].node.classed('tsi-expanded', true);
1168 _this.renderTree(data[el].children, data[el].node);
1169 }
1170 if (data[el] instanceof HierarchyNode && el !== _this.getString("Show More Hierarchies") && _this.mode === State.Filter && data[el].cumulativeInstanceCount == 1 && !data[el].isExpanded) { //expand the last parent node by default to prevent additional click to see the filter results
1171 newListElem.node().click();
1172 }
1173 });
1174 if (locInTarget) {
1175 currentShowMore.remove();
1176 }
1177 };
1178 // creates in-depth data object using the server response for hierarchyNodes to show in the tree all expanded, considering UntilChildren
1179 HierarchyNavigation.prototype.fillDataRecursively = function (hierarchyNodes, getToken, envFqdn, payload, payloadForContinuation) {
1180 var _this = this;
1181 if (payloadForContinuation === void 0) { payloadForContinuation = null; }
1182 var data = {};
1183 hierarchyNodes.hits.forEach(function (h) {
1184 var hierarchy = new HierarchyNode(h.name, payload.path, payload.path.length - _this.path.length, h.cumulativeInstanceCount);
1185 hierarchy.expand = function () {
1186 var expandNode = function () {
1187 hierarchy.isExpanded = true;
1188 hierarchy.node.classed('tsi-expanded', true);
1189 };
1190 if (_this.mode === State.Search) {
1191 return _this.pathSearchAndRenderResult({ search: { payload: _this.requestPayload(hierarchy.path), bubbleUpReject: true }, render: { target: _this.instanceListElem } }).then(function (r) { return expandNode(); }).catch(function (err) { });
1192 }
1193 else {
1194 return _this.pathSearchAndRenderResult({ search: { payload: _this.requestPayload(hierarchy.path), bubbleUpReject: true }, render: { target: hierarchy.node } }).then(function (r) { return expandNode(); }).catch(function (err) { });
1195 }
1196 };
1197 data[_this.hierarchyNodeIdentifier(h.name)] = hierarchy;
1198 if (h.hierarchyNodes && h.hierarchyNodes.hits.length) {
1199 hierarchy.children = _this.fillDataRecursively(h.hierarchyNodes, getToken, envFqdn, _this.requestPayload(hierarchy.path), payloadForContinuation);
1200 }
1201 });
1202 if (hierarchyNodes.continuationToken && hierarchyNodes.continuationToken !== 'END') {
1203 var showMorehierarchy_1 = new HierarchyNode(this.getString("Show More Hierarchies"), payload.path, payload.path.length - this.path.length);
1204 showMorehierarchy_1.onClick = function () {
1205 return _this.pathSearchAndRenderResult({
1206 search: { payload: (payloadForContinuation ? payloadForContinuation : payload), hierarchiesContinuationToken: hierarchyNodes.continuationToken },
1207 render: { target: showMorehierarchy_1.node.select(function () { return this.parentNode; }), locInTarget: '.tsi-show-more.tsi-show-more-hierarchy', skipLevels: payloadForContinuation ? payload.path.length - payloadForContinuation.path.length : null }
1208 });
1209 };
1210 data[showMorehierarchy_1.name] = showMorehierarchy_1;
1211 }
1212 return data;
1213 };
1214 //returns the dom element of one hierarchy level item for tree rendering
1215 HierarchyNavigation.prototype.createHierarchyItemElem = function (hORi, key) {
1216 var _this = this;
1217 var self = this;
1218 var isHierarchyNode = hORi instanceof HierarchyNode;
1219 var hierarchyItemElem = create('div').classed('tsi-hierarchyItem', true)
1220 .attr('style', "padding-left: " + (hORi.isLeaf ? hORi.level * 18 + 20 : (hORi.level + 1) * 18 + 20) + "px")
1221 .attr('tabindex', 0)
1222 .attr('arialabel', isHierarchyNode ? key : Utils.getTimeSeriesIdString(hORi))
1223 .attr('title', isHierarchyNode ? key : Utils.getTimeSeriesIdString(hORi))
1224 .attr("role", "treeitem").attr('aria-expanded', hORi.isExpanded)
1225 .on('click keydown', function (event) {
1226 return __awaiter(this, void 0, void 0, function () {
1227 var mouseElt, target, mouseWrapper;
1228 return __generator(this, function (_a) {
1229 switch (_a.label) {
1230 case 0:
1231 if (Utils.isKeyDownAndNotEnter(event)) {
1232 return [2 /*return*/];
1233 }
1234 if (!!isHierarchyNode) return [3 /*break*/, 1];
1235 event.stopPropagation();
1236 self.closeContextMenu();
1237 mouseElt = pointer(event);
1238 target = self.hierarchyElem.select(function () { return this.parentNode; });
1239 mouseWrapper = pointer(event, target.node());
1240 self.prepareForContextMenu(hORi, target, mouseWrapper[1], mouseElt[1]);
1241 self.chartOptions.onInstanceClick(hORi);
1242 return [3 /*break*/, 4];
1243 case 1:
1244 if (!hORi.isExpanded) return [3 /*break*/, 2];
1245 hORi.collapse();
1246 return [3 /*break*/, 4];
1247 case 2: return [4 /*yield*/, hORi.expand()];
1248 case 3:
1249 _a.sent();
1250 _a.label = 4;
1251 case 4: return [2 /*return*/];
1252 }
1253 });
1254 });
1255 })
1256 .on('mouseover focus', function (event) {
1257 if (isHierarchyNode) {
1258 if (event.relatedTarget != select(event.parentNode).select('.tsi-filter-icon').node()) {
1259 select(event.parentNode).select('.tsi-filter-icon').node().style.visibility = 'visible';
1260 }
1261 }
1262 })
1263 .on('mouseleave blur', function (event) {
1264 if (isHierarchyNode) {
1265 if (event.relatedTarget != select(event.parentNode).select('.tsi-filter-icon').node()) {
1266 select(event.parentNode).select('.tsi-filter-icon').node().style.visibility = 'hidden';
1267 }
1268 }
1269 });
1270 if (isHierarchyNode) {
1271 hierarchyItemElem.append('span').classed('tsi-caret-icon', true).attr('style', "left: " + ((hORi.level) * 18 + 20) + "px");
1272 hierarchyItemElem.append('span').classed('tsi-name', true).text(key);
1273 hierarchyItemElem.append('span').classed('tsi-instanceCount', true).text(hORi.cumulativeInstanceCount);
1274 hierarchyItemElem.append('span').classed('tsi-hitCount', true).text(''); // hit count is the number of hierarchy nodes below, it is filled after expand is clicked for this node (after search is done for this path)
1275 hierarchyItemElem.append('div').classed('tsi-filter-icon', true).attr('title', this.getString('Add to Filter Path'))
1276 .attr('tabindex', 0)
1277 .attr('arialabel', this.getString('Add to Filter Path'))
1278 .attr('role', 'button')
1279 .on('click keydown', function (event) {
1280 if (Utils.isKeyDownAndNotEnter(event)) {
1281 return;
1282 }
1283 self.path = hORi.path;
1284 var pathListElem = select('.tsi-path-list');
1285 pathListElem.text('');
1286 var pathToLoop = self.selectedHierarchyName !== HierarchySelectionValues.All ? hORi.path.slice(1) : hORi.path;
1287 pathToLoop.forEach(function (a, i) {
1288 if (i > 0) {
1289 pathListElem.append('span').text(' / ');
1290 }
1291 var pathName = self.hierarchyNodeIdentifier(a);
1292 pathListElem.append('span').classed('tsi-path', true)
1293 .text(pathName)
1294 .attr('title', pathName)
1295 .attr('tabindex', 0)
1296 .attr('arialabel', pathName)
1297 .on('click keydown', function (event) {
1298 if (Utils.isKeyDownAndNotEnter(event)) {
1299 return;
1300 }
1301 self.path = self.path.slice(0, i + (self.selectedHierarchyName === HierarchySelectionValues.All ? 1 : 2));
1302 selectAll(pathListElem.selectAll('span').nodes().splice((i * 2) + 1, pathListElem.selectAll('span').nodes().length)).remove();
1303 self.clearAndGetResults();
1304 });
1305 });
1306 select('.tsi-filter-clear').style('display', 'inline-block');
1307 self.filterPathElem.classed('visible', true);
1308 self.clearAndGetResults();
1309 }).on('mouseleave blur', function (event) {
1310 if (event.relatedTarget != select(event.parentNode)) {
1311 this.style.visibility = 'hidden';
1312 }
1313 });
1314 }
1315 else {
1316 var spanElem = hierarchyItemElem.append('span').classed('tsi-name', true);
1317 Utils.appendFormattedElementsFromString(spanElem, this.instanceNodeStringToDisplay(hORi));
1318 if (hORi.highlights) {
1319 var hitsExist_1 = false;
1320 var highlightDetails = hierarchyItemElem.append('div').classed('tsi-highlights-detail', true);
1321 if (hORi.highlights.description && this.hasHits(hORi.highlights.description)) {
1322 hitsExist_1 = true;
1323 Utils.appendFormattedElementsFromString(highlightDetails, hORi.highlights.description);
1324 }
1325 var hitTuples_1 = [];
1326 if (hORi.highlights.name && this.hasHits(Utils.getHighlightedTimeSeriesIdToDisplay(hORi))) {
1327 hitsExist_1 = true;
1328 hitTuples_1.push([this.getString("Time Series ID"), Utils.getHighlightedTimeSeriesIdToDisplay(hORi)]);
1329 }
1330 hORi.highlights.instanceFieldNames.forEach(function (ifn, idx) {
1331 var val = hORi.highlights.instanceFieldValues[idx];
1332 if (_this.hasHits(ifn) || _this.hasHits(val)) {
1333 hitsExist_1 = true;
1334 hitTuples_1.push([ifn, hORi.highlights.instanceFieldValues[idx]]);
1335 }
1336 });
1337 var rows = highlightDetails.append('table').selectAll("tr")
1338 .data(hitTuples_1)
1339 .enter()
1340 .append("tr");
1341 var cells = rows.selectAll("td")
1342 .data(function (d) {
1343 return d;
1344 });
1345 cells.enter()
1346 .append("td")
1347 .each(function (d) {
1348 Utils.appendFormattedElementsFromString(select(this), d);
1349 })
1350 .merge(cells);
1351 cells.exit().remove();
1352 rows.exit().remove();
1353 if (hitsExist_1) {
1354 highlightDetails.style("display", "block");
1355 }
1356 }
1357 }
1358 return hierarchyItemElem;
1359 };
1360 //returns the dom elem of one instance item for flat list rendering
1361 HierarchyNavigation.prototype.createInstanceElem = function (i) {
1362 var _this = this;
1363 var instanceElem = create('div').classed('tsi-modelResult', true);
1364 var firstLine = instanceElem.append('div').classed('tsi-modelPK', true);
1365 i.highlights.name ? Utils.appendFormattedElementsFromString(firstLine, i.highlights.name) : Utils.appendFormattedElementsFromString(firstLine, Utils.getHighlightedTimeSeriesIdToDisplay(i));
1366 var secondLine = instanceElem.append('div').classed('tsi-modelHighlights', true);
1367 Utils.appendFormattedElementsFromString(secondLine, i.highlights.description && i.highlights.description.length ? i.highlights.description : 'No description');
1368 secondLine.append('br');
1369 var hitTuples = [];
1370 if (i.highlights.name) {
1371 hitTuples.push([this.getString("Time Series ID"), Utils.getHighlightedTimeSeriesIdToDisplay(i)]);
1372 }
1373 i.highlights.instanceFieldNames.forEach(function (ifn, idx) {
1374 var val = i.highlights.instanceFieldValues[idx];
1375 if (_this.searchString) {
1376 if (_this.hasHits(ifn) || _this.hasHits(val)) {
1377 hitTuples.push([ifn, i.highlights.instanceFieldValues[idx]]);
1378 }
1379 }
1380 else if (val.length !== 0) {
1381 hitTuples.push([ifn, i.highlights.instanceFieldValues[idx]]);
1382 }
1383 });
1384 var rows = secondLine.append('table').selectAll("tr")
1385 .data(hitTuples)
1386 .enter()
1387 .append("tr");
1388 var cells = rows.selectAll("td")
1389 .data(function (d) {
1390 return d;
1391 });
1392 cells.enter()
1393 .append("td")
1394 .each(function (d) {
1395 Utils.appendFormattedElementsFromString(select(this), d);
1396 })
1397 .merge(cells);
1398 cells.exit().remove();
1399 rows.exit().remove();
1400 return instanceElem;
1401 };
1402 return HierarchyNavigation;
1403}(Component));
1404function HierarchyNode(name, parentPath, level, cumulativeInstanceCount) {
1405 var _this = this;
1406 if (cumulativeInstanceCount === void 0) { cumulativeInstanceCount = null; }
1407 this.name = name;
1408 this.path = parentPath.concat([name]);
1409 this.expand = function () { };
1410 this.level = level;
1411 this.cumulativeInstanceCount = cumulativeInstanceCount;
1412 this.node = null;
1413 this.children = null;
1414 this.isExpanded = false;
1415 this.collapse = function () { _this.isExpanded = false; _this.node.classed('tsi-expanded', false); _this.node.selectAll('ul').remove(); };
1416}
1417function InstanceNode(tsId, name, type, hierarchyIds, highlights, level) {
1418 if (name === void 0) { name = null; }
1419 this.timeSeriesId = tsId;
1420 this.name = name;
1421 this.type = type;
1422 this.hierarchyIds = hierarchyIds;
1423 this.highlights = highlights;
1424 this.suppressDrawContextMenu = false;
1425 this.isLeaf = true;
1426 this.level = level;
1427 this.node = null;
1428}
1429var HierarchySelectionValues;
1430(function (HierarchySelectionValues) {
1431 HierarchySelectionValues["All"] = "0";
1432 HierarchySelectionValues["Unparented"] = "-1";
1433})(HierarchySelectionValues || (HierarchySelectionValues = {}));
1434var ViewType;
1435(function (ViewType) {
1436 ViewType[ViewType["Hierarchy"] = 0] = "Hierarchy";
1437 ViewType[ViewType["List"] = 1] = "List";
1438})(ViewType || (ViewType = {}));
1439var State;
1440(function (State) {
1441 State[State["Navigate"] = 0] = "Navigate";
1442 State[State["Search"] = 1] = "Search";
1443 State[State["Filter"] = 2] = "Filter";
1444})(State || (State = {}));
1445
1446export { HierarchyNavigation as H };