@itwin/presentation-hierarchies 2.0.0-alpha.0 → 2.0.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/CHANGELOG.md +306 -7
  2. package/README.md +4 -22
  3. package/lib/cjs/hierarchies/HierarchyMerge.d.ts +19 -0
  4. package/lib/cjs/hierarchies/HierarchyMerge.d.ts.map +1 -0
  5. package/lib/cjs/hierarchies/HierarchyMerge.js +43 -0
  6. package/lib/cjs/hierarchies/HierarchyMerge.js.map +1 -0
  7. package/lib/cjs/hierarchies/HierarchyNode.d.ts +14 -24
  8. package/lib/cjs/hierarchies/HierarchyNode.d.ts.map +1 -1
  9. package/lib/cjs/hierarchies/HierarchyNode.js +1 -21
  10. package/lib/cjs/hierarchies/HierarchyNode.js.map +1 -1
  11. package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
  12. package/lib/cjs/hierarchies/HierarchyNodeKey.js +8 -8
  13. package/lib/cjs/hierarchies/HierarchyNodeKey.js.map +1 -1
  14. package/lib/cjs/hierarchies/HierarchyProvider.d.ts +11 -29
  15. package/lib/cjs/hierarchies/HierarchyProvider.d.ts.map +1 -1
  16. package/lib/cjs/hierarchies/HierarchyProvider.js +0 -37
  17. package/lib/cjs/hierarchies/HierarchyProvider.js.map +1 -1
  18. package/lib/cjs/hierarchies/HierarchySearch.d.ts +167 -0
  19. package/lib/cjs/hierarchies/HierarchySearch.d.ts.map +1 -0
  20. package/lib/cjs/hierarchies/HierarchySearch.js +259 -0
  21. package/lib/cjs/hierarchies/HierarchySearch.js.map +1 -0
  22. package/lib/cjs/hierarchies/imodel/HierarchyCache.js +3 -3
  23. package/lib/cjs/hierarchies/imodel/HierarchyCache.js.map +1 -1
  24. package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts +15 -4
  25. package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -1
  26. package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -1
  27. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts +46 -11
  28. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
  29. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js +192 -72
  30. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
  31. package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts +2 -2
  32. package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
  33. package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js +99 -40
  34. package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
  35. package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.d.ts +35 -0
  36. package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -0
  37. package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.js +285 -0
  38. package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -0
  39. package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts +5 -7
  40. package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
  41. package/lib/cjs/hierarchies/imodel/TreeNodesReader.js +15 -8
  42. package/lib/cjs/hierarchies/imodel/TreeNodesReader.js.map +1 -1
  43. package/lib/cjs/hierarchies/imodel/operators/HideIfNoChildren.d.ts.map +1 -1
  44. package/lib/cjs/hierarchies/imodel/operators/HideIfNoChildren.js +1 -0
  45. package/lib/cjs/hierarchies/imodel/operators/HideIfNoChildren.js.map +1 -1
  46. package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.d.ts.map +1 -1
  47. package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.js +6 -5
  48. package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
  49. package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -1
  50. package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.js +4 -3
  51. package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -1
  52. package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -1
  53. package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.js +21 -16
  54. package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -1
  55. package/lib/cjs/hierarchies/internal/Common.d.ts +3 -0
  56. package/lib/cjs/hierarchies/internal/Common.d.ts.map +1 -1
  57. package/lib/cjs/hierarchies/internal/Common.js +12 -1
  58. package/lib/cjs/hierarchies/internal/Common.js.map +1 -1
  59. package/lib/cjs/hierarchies/internal/EachValueFrom.d.ts.map +1 -1
  60. package/lib/cjs/hierarchies/internal/EachValueFrom.js +1 -0
  61. package/lib/cjs/hierarchies/internal/EachValueFrom.js.map +1 -1
  62. package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.d.ts +68 -0
  63. package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.d.ts.map +1 -0
  64. package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.js +26 -0
  65. package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.js.map +1 -0
  66. package/lib/cjs/presentation-hierarchies.d.ts +5 -4
  67. package/lib/cjs/presentation-hierarchies.d.ts.map +1 -1
  68. package/lib/cjs/presentation-hierarchies.js +7 -7
  69. package/lib/cjs/presentation-hierarchies.js.map +1 -1
  70. package/lib/esm/hierarchies/HierarchyMerge.d.ts +19 -0
  71. package/lib/esm/hierarchies/HierarchyMerge.d.ts.map +1 -0
  72. package/lib/esm/hierarchies/HierarchyMerge.js +40 -0
  73. package/lib/esm/hierarchies/HierarchyMerge.js.map +1 -0
  74. package/lib/esm/hierarchies/HierarchyNode.d.ts +14 -24
  75. package/lib/esm/hierarchies/HierarchyNode.d.ts.map +1 -1
  76. package/lib/esm/hierarchies/HierarchyNode.js +0 -20
  77. package/lib/esm/hierarchies/HierarchyNode.js.map +1 -1
  78. package/lib/esm/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
  79. package/lib/esm/hierarchies/HierarchyNodeKey.js +9 -9
  80. package/lib/esm/hierarchies/HierarchyNodeKey.js.map +1 -1
  81. package/lib/esm/hierarchies/HierarchyProvider.d.ts +11 -29
  82. package/lib/esm/hierarchies/HierarchyProvider.d.ts.map +1 -1
  83. package/lib/esm/hierarchies/HierarchyProvider.js +1 -36
  84. package/lib/esm/hierarchies/HierarchyProvider.js.map +1 -1
  85. package/lib/esm/hierarchies/HierarchySearch.d.ts +167 -0
  86. package/lib/esm/hierarchies/HierarchySearch.d.ts.map +1 -0
  87. package/lib/esm/hierarchies/HierarchySearch.js +254 -0
  88. package/lib/esm/hierarchies/HierarchySearch.js.map +1 -0
  89. package/lib/esm/hierarchies/imodel/HierarchyCache.js +3 -3
  90. package/lib/esm/hierarchies/imodel/HierarchyCache.js.map +1 -1
  91. package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts +15 -4
  92. package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -1
  93. package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -1
  94. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts +46 -11
  95. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
  96. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js +194 -75
  97. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
  98. package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts +2 -2
  99. package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
  100. package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js +100 -41
  101. package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
  102. package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.d.ts +35 -0
  103. package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -0
  104. package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.js +279 -0
  105. package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -0
  106. package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts +5 -7
  107. package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
  108. package/lib/esm/hierarchies/imodel/TreeNodesReader.js +13 -7
  109. package/lib/esm/hierarchies/imodel/TreeNodesReader.js.map +1 -1
  110. package/lib/esm/hierarchies/imodel/operators/HideIfNoChildren.d.ts.map +1 -1
  111. package/lib/esm/hierarchies/imodel/operators/HideIfNoChildren.js +1 -0
  112. package/lib/esm/hierarchies/imodel/operators/HideIfNoChildren.js.map +1 -1
  113. package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.d.ts.map +1 -1
  114. package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.js +7 -6
  115. package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
  116. package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -1
  117. package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.js +5 -4
  118. package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -1
  119. package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -1
  120. package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.js +22 -17
  121. package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -1
  122. package/lib/esm/hierarchies/internal/Common.d.ts +3 -0
  123. package/lib/esm/hierarchies/internal/Common.d.ts.map +1 -1
  124. package/lib/esm/hierarchies/internal/Common.js +11 -1
  125. package/lib/esm/hierarchies/internal/Common.js.map +1 -1
  126. package/lib/esm/hierarchies/internal/EachValueFrom.d.ts.map +1 -1
  127. package/lib/esm/hierarchies/internal/EachValueFrom.js +1 -0
  128. package/lib/esm/hierarchies/internal/EachValueFrom.js.map +1 -1
  129. package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.d.ts +68 -0
  130. package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.d.ts.map +1 -0
  131. package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.js +23 -0
  132. package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.js.map +1 -0
  133. package/lib/esm/presentation-hierarchies.d.ts +5 -4
  134. package/lib/esm/presentation-hierarchies.d.ts.map +1 -1
  135. package/lib/esm/presentation-hierarchies.js +3 -3
  136. package/lib/esm/presentation-hierarchies.js.map +1 -1
  137. package/package.json +19 -19
  138. package/lib/cjs/hierarchies/HierarchyFiltering.d.ts +0 -110
  139. package/lib/cjs/hierarchies/HierarchyFiltering.d.ts.map +0 -1
  140. package/lib/cjs/hierarchies/HierarchyFiltering.js +0 -210
  141. package/lib/cjs/hierarchies/HierarchyFiltering.js.map +0 -1
  142. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts +0 -34
  143. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +0 -1
  144. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js +0 -270
  145. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js.map +0 -1
  146. package/lib/esm/hierarchies/HierarchyFiltering.d.ts +0 -110
  147. package/lib/esm/hierarchies/HierarchyFiltering.d.ts.map +0 -1
  148. package/lib/esm/hierarchies/HierarchyFiltering.js +0 -205
  149. package/lib/esm/hierarchies/HierarchyFiltering.js.map +0 -1
  150. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts +0 -34
  151. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +0 -1
  152. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js +0 -264
  153. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js.map +0 -1
@@ -1,110 +0,0 @@
1
- import { HierarchyNode, NonGroupingHierarchyNode } from "./HierarchyNode.js";
2
- import { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from "./HierarchyNodeIdentifier.js";
3
- import { GenericNodeKey, GroupingNodeKey, InstancesNodeKey } from "./HierarchyNodeKey.js";
4
- /** @public */
5
- export interface FilterTargetGroupingNodeInfo {
6
- /** Key of the grouping node. */
7
- key: GroupingNodeKey;
8
- /**
9
- * Depth of the grouping node in the hierarchy.
10
- * Generally, it can be retrieved from `parentKeys.length`.
11
- */
12
- depth: number;
13
- }
14
- /** @public */
15
- export interface HierarchyFilteringPathOptions {
16
- /**
17
- * This option specifies the way `autoExpand` flag should be assigned to nodes in the filtered hierarchy.
18
- * - If it's `false` or `undefined`, nodes have no 'autoExpand' flag.
19
- * - If it's `true`, then all nodes up to the filter target will have `autoExpand` flag.
20
- * - If it's an instance of `FilterTargetGroupingNodeInfo`, then all nodes up to the grouping node that matches this property,
21
- * will have `autoExpand` flag.
22
- */
23
- autoExpand?: boolean | FilterTargetGroupingNodeInfo;
24
- }
25
- /**
26
- * A path of hierarchy node identifiers for filtering the hierarchy with additional options.
27
- * @public
28
- */
29
- export type HierarchyFilteringPath = HierarchyNodeIdentifiersPath | {
30
- path: HierarchyNodeIdentifiersPath;
31
- options?: HierarchyFilteringPathOptions;
32
- };
33
- /** @public */
34
- export declare namespace HierarchyFilteringPath {
35
- /**
36
- * Normalizes the hierarchy filtering path to the object form.
37
- * @public
38
- */
39
- function normalize(source: HierarchyFilteringPath): Exclude<HierarchyFilteringPath, HierarchyNodeIdentifiersPath>;
40
- /**
41
- * Merges two given `HierarchyFilteringPathOptions` objects.
42
- * - if both inputs are `undefined`, `undefined` is returned,
43
- * - else if one of the inputs is `undefined`, the other one is returned.
44
- * - else, merge each option individually.
45
- *
46
- * For the `autoExpand` attribute, the merge chooses to auto-expand as deep as the deepest input:
47
- * - if any one of the inputs is `true`, return `true`,
48
- * - else if both inputs are objects, return the one with the greater `depth` attribute.
49
- * - else if one input is an object, return it.
50
- * - else, return `false` or `undefined`.
51
- *
52
- * @public
53
- */
54
- function mergeOptions(lhs: HierarchyFilteringPathOptions | undefined, rhs: HierarchyFilteringPathOptions | undefined): HierarchyFilteringPathOptions | undefined;
55
- }
56
- /**
57
- * An utility that extracts filtering properties from given root level filtering props or
58
- * the parent node. Returns `undefined` if filtering props are not present.
59
- * @public
60
- * @deprecated in 1.3. Use `createHierarchyFilteringHelper` instead.
61
- */
62
- export declare function extractFilteringProps(rootLevelFilteringProps: HierarchyFilteringPath[], parentNode: Pick<NonGroupingHierarchyNode, "filtering"> | undefined): {
63
- filteredNodePaths: HierarchyFilteringPath[];
64
- hasFilterTargetAncestor: boolean;
65
- } | undefined;
66
- /**
67
- * Creates a set of utilities for making it easier to filter the given hierarchy
68
- * level.
69
- *
70
- * @public
71
- */
72
- export declare function createHierarchyFilteringHelper(rootLevelFilteringProps: HierarchyFilteringPath[] | undefined, parentNode: Pick<NonGroupingHierarchyNode, "filtering"> | undefined): {
73
- /**
74
- * Returns a flag indicating if the hierarchy level is filtered.
75
- */
76
- hasFilter: boolean;
77
- /**
78
- * Returns a flag indicating whether this hierarchy level has an ancestor node
79
- * that is a filter target. That generally means that this and all downstream hierarchy
80
- * levels should be displayed without filter being applied to them, even if filter paths
81
- * say otherwise.
82
- */
83
- hasFilterTargetAncestor: boolean;
84
- /**
85
- * Returns a list of hierarchy node identifiers that apply specifically for this
86
- * hierarchy level. Returns `undefined` if filtering is not applied to this level.
87
- */
88
- getChildNodeFilteringIdentifiers: () => HierarchyNodeIdentifier[] | undefined;
89
- /**
90
- * When a hierarchy node is created for a filtered hierarchy level, it needs some attributes (e.g. `filtering`
91
- * and `autoExpand`) to be set based on the filter paths and filtering options. This function calculates
92
- * these props for a child node based on its key or path matcher.
93
- *
94
- * When using `pathMatcher` prop, callers have more flexibility to decide whether the given `HierarchyNodeIdentifier` applies
95
- * to their node. For example, only some parts of the identifier can be checked for improved performance. Otherwise, the
96
- * `nodeKey` prop can be used to check the whole identifier.
97
- */
98
- createChildNodeProps: (props: {
99
- nodeKey: InstancesNodeKey | GenericNodeKey;
100
- } | {
101
- pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;
102
- }) => Pick<HierarchyNode, "filtering" | "autoExpand"> | undefined;
103
- /**
104
- * Similar to `createChildNodeProps`, but takes an async `pathMatcher` prop.
105
- */
106
- createChildNodePropsAsync: (props: {
107
- pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;
108
- }) => Promise<Pick<HierarchyNode, "filtering" | "autoExpand"> | undefined>;
109
- };
110
- //# sourceMappingURL=HierarchyFiltering.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HierarchyFiltering.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyFiltering.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,eAAe,EAAoB,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE5G,cAAc;AACd,MAAM,WAAW,4BAA4B;IAC3C,gCAAgC;IAChC,GAAG,EAAE,eAAe,CAAC;IAErB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED,cAAc;AACd,MAAM,WAAW,6BAA6B;IAC5C;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG,4BAA4B,CAAC;CACrD;AAED;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,4BAA4B,GAAG;IAAE,IAAI,EAAE,4BAA4B,CAAC;IAAC,OAAO,CAAC,EAAE,6BAA6B,CAAA;CAAE,CAAC;AACpJ,cAAc;AAEd,yBAAiB,sBAAsB,CAAC;IACtC;;;OAGG;IACH,SAAgB,SAAS,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,EAAE,4BAA4B,CAAC,CAKvH;IAED;;;;;;;;;;;;;OAaG;IACH,SAAgB,YAAY,CAC1B,GAAG,EAAE,6BAA6B,GAAG,SAAS,EAC9C,GAAG,EAAE,6BAA6B,GAAG,SAAS,GAC7C,6BAA6B,GAAG,SAAS,CAmB3C;CACF;AAED;;;;;GAKG;AAEH,wBAAgB,qBAAqB,CACnC,uBAAuB,EAAE,sBAAsB,EAAE,EACjD,UAAU,EAAE,IAAI,CAAC,wBAAwB,EAAE,WAAW,CAAC,GAAG,SAAS,GAEjE;IACE,iBAAiB,EAAE,sBAAsB,EAAE,CAAC;IAC5C,uBAAuB,EAAE,OAAO,CAAC;CAClC,GACD,SAAS,CAEZ;AAuBD;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,uBAAuB,EAAE,sBAAsB,EAAE,GAAG,SAAS,EAC7D,UAAU,EAAE,IAAI,CAAC,wBAAwB,EAAE,WAAW,CAAC,GAAG,SAAS;IAKjE;;OAEG;;IAGH;;;;;OAKG;;IAGH;;;OAGG;;IAWH;;;;;;;;OAQG;kCAGG;QACE,OAAO,EAAE,gBAAgB,GAAG,cAAc,CAAC;KAC5C,GACD;QACE,WAAW,EAAE,CAAC,UAAU,EAAE,uBAAuB,KAAK,OAAO,CAAC;KAC/D,KACJ,IAAI,CAAC,aAAa,EAAE,WAAW,GAAG,YAAY,CAAC,GAAG,SAAS;IAoB9D;;OAEG;uCACsC;QACvC,WAAW,EAAE,CAAC,UAAU,EAAE,uBAAuB,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;KAClF,KAAG,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,WAAW,GAAG,YAAY,CAAC,GAAG,SAAS,CAAC;EA2B3E"}
@@ -1,210 +0,0 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.HierarchyFilteringPath = void 0;
8
- exports.extractFilteringProps = extractFilteringProps;
9
- exports.createHierarchyFilteringHelper = createHierarchyFilteringHelper;
10
- const HierarchyNodeIdentifier_js_1 = require("./HierarchyNodeIdentifier.js");
11
- const HierarchyNodeKey_js_1 = require("./HierarchyNodeKey.js");
12
- /** @public */
13
- // eslint-disable-next-line @typescript-eslint/no-redeclare
14
- var HierarchyFilteringPath;
15
- (function (HierarchyFilteringPath) {
16
- /**
17
- * Normalizes the hierarchy filtering path to the object form.
18
- * @public
19
- */
20
- function normalize(source) {
21
- if (Array.isArray(source)) {
22
- return { path: source };
23
- }
24
- return source;
25
- }
26
- HierarchyFilteringPath.normalize = normalize;
27
- /**
28
- * Merges two given `HierarchyFilteringPathOptions` objects.
29
- * - if both inputs are `undefined`, `undefined` is returned,
30
- * - else if one of the inputs is `undefined`, the other one is returned.
31
- * - else, merge each option individually.
32
- *
33
- * For the `autoExpand` attribute, the merge chooses to auto-expand as deep as the deepest input:
34
- * - if any one of the inputs is `true`, return `true`,
35
- * - else if both inputs are objects, return the one with the greater `depth` attribute.
36
- * - else if one input is an object, return it.
37
- * - else, return `false` or `undefined`.
38
- *
39
- * @public
40
- */
41
- function mergeOptions(lhs, rhs) {
42
- if (!lhs || !rhs) {
43
- return lhs ?? rhs;
44
- }
45
- return {
46
- autoExpand: (() => {
47
- if (rhs.autoExpand === true || lhs.autoExpand === true) {
48
- return true;
49
- }
50
- if (typeof lhs.autoExpand === "object") {
51
- if (typeof rhs.autoExpand === "object" && rhs.autoExpand.depth > lhs.autoExpand.depth) {
52
- return rhs.autoExpand;
53
- }
54
- return lhs.autoExpand;
55
- }
56
- return rhs.autoExpand;
57
- })(),
58
- };
59
- }
60
- HierarchyFilteringPath.mergeOptions = mergeOptions;
61
- })(HierarchyFilteringPath || (exports.HierarchyFilteringPath = HierarchyFilteringPath = {}));
62
- /**
63
- * An utility that extracts filtering properties from given root level filtering props or
64
- * the parent node. Returns `undefined` if filtering props are not present.
65
- * @public
66
- * @deprecated in 1.3. Use `createHierarchyFilteringHelper` instead.
67
- */
68
- /* c8 ignore start */
69
- function extractFilteringProps(rootLevelFilteringProps, parentNode) {
70
- return extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);
71
- }
72
- /* c8 ignore end */
73
- function extractFilteringPropsInternal(rootLevelFilteringProps, parentNode) {
74
- if (!parentNode) {
75
- return rootLevelFilteringProps ? { filteredNodePaths: rootLevelFilteringProps, hasFilterTargetAncestor: false } : undefined;
76
- }
77
- return parentNode.filtering?.filteredChildrenIdentifierPaths
78
- ? {
79
- filteredNodePaths: parentNode.filtering.filteredChildrenIdentifierPaths,
80
- hasFilterTargetAncestor: !!parentNode.filtering.hasFilterTargetAncestor || !!parentNode.filtering.isFilterTarget,
81
- }
82
- : undefined;
83
- }
84
- /**
85
- * Creates a set of utilities for making it easier to filter the given hierarchy
86
- * level.
87
- *
88
- * @public
89
- */
90
- function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNode) {
91
- const filteringProps = extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);
92
- const hasFilter = !!filteringProps;
93
- return {
94
- /**
95
- * Returns a flag indicating if the hierarchy level is filtered.
96
- */
97
- hasFilter,
98
- /**
99
- * Returns a flag indicating whether this hierarchy level has an ancestor node
100
- * that is a filter target. That generally means that this and all downstream hierarchy
101
- * levels should be displayed without filter being applied to them, even if filter paths
102
- * say otherwise.
103
- */
104
- hasFilterTargetAncestor: filteringProps?.hasFilterTargetAncestor ?? false,
105
- /**
106
- * Returns a list of hierarchy node identifiers that apply specifically for this
107
- * hierarchy level. Returns `undefined` if filtering is not applied to this level.
108
- */
109
- getChildNodeFilteringIdentifiers: () => {
110
- if (!hasFilter) {
111
- return undefined;
112
- }
113
- return filteringProps.filteredNodePaths
114
- .map(HierarchyFilteringPath.normalize)
115
- .filter(({ path }) => path.length > 0)
116
- .map(({ path }) => path[0]);
117
- },
118
- /**
119
- * When a hierarchy node is created for a filtered hierarchy level, it needs some attributes (e.g. `filtering`
120
- * and `autoExpand`) to be set based on the filter paths and filtering options. This function calculates
121
- * these props for a child node based on its key or path matcher.
122
- *
123
- * When using `pathMatcher` prop, callers have more flexibility to decide whether the given `HierarchyNodeIdentifier` applies
124
- * to their node. For example, only some parts of the identifier can be checked for improved performance. Otherwise, the
125
- * `nodeKey` prop can be used to check the whole identifier.
126
- */
127
- createChildNodeProps: (props) => {
128
- if (!hasFilter) {
129
- return undefined;
130
- }
131
- const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);
132
- filteringProps.filteredNodePaths.forEach((filteredPath) => {
133
- const normalizedPath = HierarchyFilteringPath.normalize(filteredPath);
134
- if ("nodeKey" in props &&
135
- ((HierarchyNodeKey_js_1.HierarchyNodeKey.isGeneric(props.nodeKey) && HierarchyNodeIdentifier_js_1.HierarchyNodeIdentifier.equal(normalizedPath.path[0], props.nodeKey)) ||
136
- (HierarchyNodeKey_js_1.HierarchyNodeKey.isInstances(props.nodeKey) && props.nodeKey.instanceKeys.some((ik) => HierarchyNodeIdentifier_js_1.HierarchyNodeIdentifier.equal(normalizedPath.path[0], ik))))) {
137
- reducer.accept(normalizedPath);
138
- }
139
- else if ("pathMatcher" in props && props.pathMatcher(normalizedPath.path[0])) {
140
- reducer.accept(normalizedPath);
141
- }
142
- });
143
- return reducer.getNodeProps();
144
- },
145
- /**
146
- * Similar to `createChildNodeProps`, but takes an async `pathMatcher` prop.
147
- */
148
- createChildNodePropsAsync: async (props) => {
149
- if (!hasFilter) {
150
- return undefined;
151
- }
152
- const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);
153
- for (const filteredChildrenNodeIdentifierPath of filteringProps.filteredNodePaths) {
154
- const normalizedPath = HierarchyFilteringPath.normalize(filteredChildrenNodeIdentifierPath);
155
- /* c8 ignore next 3 */
156
- if (normalizedPath.path.length === 0) {
157
- continue;
158
- }
159
- const matchesPossiblyPromise = props.pathMatcher(normalizedPath.path[0]);
160
- if (matchesPossiblyPromise instanceof Promise) {
161
- if (!(await matchesPossiblyPromise)) {
162
- continue;
163
- }
164
- }
165
- if (!matchesPossiblyPromise) {
166
- continue;
167
- }
168
- reducer.accept(normalizedPath);
169
- }
170
- return reducer.getNodeProps();
171
- },
172
- };
173
- }
174
- class MatchingFilteringPathsReducer {
175
- _hasFilterTargetAncestor;
176
- _filteredChildrenIdentifierPaths = new Array();
177
- _isFilterTarget = false;
178
- _filterTargetOptions = undefined;
179
- _needsAutoExpand = false;
180
- constructor(_hasFilterTargetAncestor) {
181
- this._hasFilterTargetAncestor = _hasFilterTargetAncestor;
182
- }
183
- accept({ path, options }) {
184
- if (path.length === 1) {
185
- this._isFilterTarget = true;
186
- this._filterTargetOptions = HierarchyFilteringPath.mergeOptions(this._filterTargetOptions, options);
187
- }
188
- else if (path.length > 1) {
189
- this._filteredChildrenIdentifierPaths.push({ path: path.slice(1), options });
190
- if (options?.autoExpand) {
191
- this._needsAutoExpand = true;
192
- }
193
- }
194
- }
195
- getNodeProps() {
196
- return {
197
- ...(this._hasFilterTargetAncestor || this._isFilterTarget || this._filteredChildrenIdentifierPaths.length > 0
198
- ? {
199
- filtering: {
200
- ...(this._hasFilterTargetAncestor ? { hasFilterTargetAncestor: true } : undefined),
201
- ...(this._isFilterTarget ? { isFilterTarget: true, filterTargetOptions: this._filterTargetOptions } : undefined),
202
- ...(this._filteredChildrenIdentifierPaths.length > 0 ? { filteredChildrenIdentifierPaths: this._filteredChildrenIdentifierPaths } : undefined),
203
- },
204
- }
205
- : undefined),
206
- ...(this._needsAutoExpand ? { autoExpand: true } : undefined),
207
- };
208
- }
209
- }
210
- //# sourceMappingURL=HierarchyFiltering.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HierarchyFiltering.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyFiltering.ts"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EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;SAC9D,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { HierarchyNode, NonGroupingHierarchyNode } from \"./HierarchyNode.js\";\nimport { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from \"./HierarchyNodeIdentifier.js\";\nimport { GenericNodeKey, GroupingNodeKey, HierarchyNodeKey, InstancesNodeKey } from \"./HierarchyNodeKey.js\";\n\n/** @public */\nexport interface FilterTargetGroupingNodeInfo {\n /** Key of the grouping node. */\n key: GroupingNodeKey;\n\n /**\n * Depth of the grouping node in the hierarchy.\n * Generally, it can be retrieved from `parentKeys.length`.\n */\n depth: number;\n}\n\n/** @public */\nexport interface HierarchyFilteringPathOptions {\n /**\n * This option specifies the way `autoExpand` flag should be assigned to nodes in the filtered hierarchy.\n * - If it's `false` or `undefined`, nodes have no 'autoExpand' flag.\n * - If it's `true`, then all nodes up to the filter target will have `autoExpand` flag.\n * - If it's an instance of `FilterTargetGroupingNodeInfo`, then all nodes up to the grouping node that matches this property,\n * will have `autoExpand` flag.\n */\n autoExpand?: boolean | FilterTargetGroupingNodeInfo;\n}\n\n/**\n * A path of hierarchy node identifiers for filtering the hierarchy with additional options.\n * @public\n */\nexport type HierarchyFilteringPath = HierarchyNodeIdentifiersPath | { path: HierarchyNodeIdentifiersPath; options?: HierarchyFilteringPathOptions };\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyFilteringPath {\n /**\n * Normalizes the hierarchy filtering path to the object form.\n * @public\n */\n export function normalize(source: HierarchyFilteringPath): Exclude<HierarchyFilteringPath, HierarchyNodeIdentifiersPath> {\n if (Array.isArray(source)) {\n return { path: source };\n }\n return source;\n }\n\n /**\n * Merges two given `HierarchyFilteringPathOptions` objects.\n * - if both inputs are `undefined`, `undefined` is returned,\n * - else if one of the inputs is `undefined`, the other one is returned.\n * - else, merge each option individually.\n *\n * For the `autoExpand` attribute, the merge chooses to auto-expand as deep as the deepest input:\n * - if any one of the inputs is `true`, return `true`,\n * - else if both inputs are objects, return the one with the greater `depth` attribute.\n * - else if one input is an object, return it.\n * - else, return `false` or `undefined`.\n *\n * @public\n */\n export function mergeOptions(\n lhs: HierarchyFilteringPathOptions | undefined,\n rhs: HierarchyFilteringPathOptions | undefined,\n ): HierarchyFilteringPathOptions | undefined {\n if (!lhs || !rhs) {\n return lhs ?? rhs;\n }\n\n return {\n autoExpand: ((): HierarchyFilteringPathOptions[\"autoExpand\"] => {\n if (rhs.autoExpand === true || lhs.autoExpand === true) {\n return true;\n }\n if (typeof lhs.autoExpand === \"object\") {\n if (typeof rhs.autoExpand === \"object\" && rhs.autoExpand.depth > lhs.autoExpand.depth) {\n return rhs.autoExpand;\n }\n return lhs.autoExpand;\n }\n return rhs.autoExpand;\n })(),\n };\n }\n}\n\n/**\n * An utility that extracts filtering properties from given root level filtering props or\n * the parent node. Returns `undefined` if filtering props are not present.\n * @public\n * @deprecated in 1.3. Use `createHierarchyFilteringHelper` instead.\n */\n/* c8 ignore start */\nexport function extractFilteringProps(\n rootLevelFilteringProps: HierarchyFilteringPath[],\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n):\n | {\n filteredNodePaths: HierarchyFilteringPath[];\n hasFilterTargetAncestor: boolean;\n }\n | undefined {\n return extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);\n}\n/* c8 ignore end */\n\nfunction extractFilteringPropsInternal(\n rootLevelFilteringProps: HierarchyFilteringPath[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n):\n | {\n filteredNodePaths: HierarchyFilteringPath[];\n hasFilterTargetAncestor: boolean;\n }\n | undefined {\n if (!parentNode) {\n return rootLevelFilteringProps ? { filteredNodePaths: rootLevelFilteringProps, hasFilterTargetAncestor: false } : undefined;\n }\n return parentNode.filtering?.filteredChildrenIdentifierPaths\n ? {\n filteredNodePaths: parentNode.filtering.filteredChildrenIdentifierPaths,\n hasFilterTargetAncestor: !!parentNode.filtering.hasFilterTargetAncestor || !!parentNode.filtering.isFilterTarget,\n }\n : undefined;\n}\n\n/**\n * Creates a set of utilities for making it easier to filter the given hierarchy\n * level.\n *\n * @public\n */\nexport function createHierarchyFilteringHelper(\n rootLevelFilteringProps: HierarchyFilteringPath[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n) {\n const filteringProps = extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);\n const hasFilter = !!filteringProps;\n return {\n /**\n * Returns a flag indicating if the hierarchy level is filtered.\n */\n hasFilter,\n\n /**\n * Returns a flag indicating whether this hierarchy level has an ancestor node\n * that is a filter target. That generally means that this and all downstream hierarchy\n * levels should be displayed without filter being applied to them, even if filter paths\n * say otherwise.\n */\n hasFilterTargetAncestor: filteringProps?.hasFilterTargetAncestor ?? false,\n\n /**\n * Returns a list of hierarchy node identifiers that apply specifically for this\n * hierarchy level. Returns `undefined` if filtering is not applied to this level.\n */\n getChildNodeFilteringIdentifiers: () => {\n if (!hasFilter) {\n return undefined;\n }\n return filteringProps.filteredNodePaths\n .map(HierarchyFilteringPath.normalize)\n .filter(({ path }) => path.length > 0)\n .map(({ path }) => path[0]);\n },\n\n /**\n * When a hierarchy node is created for a filtered hierarchy level, it needs some attributes (e.g. `filtering`\n * and `autoExpand`) to be set based on the filter paths and filtering options. This function calculates\n * these props for a child node based on its key or path matcher.\n *\n * When using `pathMatcher` prop, callers have more flexibility to decide whether the given `HierarchyNodeIdentifier` applies\n * to their node. For example, only some parts of the identifier can be checked for improved performance. Otherwise, the\n * `nodeKey` prop can be used to check the whole identifier.\n */\n createChildNodeProps: (\n props:\n | {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n }\n | {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n },\n ): Pick<HierarchyNode, \"filtering\" | \"autoExpand\"> | undefined => {\n if (!hasFilter) {\n return undefined;\n }\n const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);\n filteringProps.filteredNodePaths.forEach((filteredPath) => {\n const normalizedPath = HierarchyFilteringPath.normalize(filteredPath);\n if (\n \"nodeKey\" in props &&\n ((HierarchyNodeKey.isGeneric(props.nodeKey) && HierarchyNodeIdentifier.equal(normalizedPath.path[0], props.nodeKey)) ||\n (HierarchyNodeKey.isInstances(props.nodeKey) && props.nodeKey.instanceKeys.some((ik) => HierarchyNodeIdentifier.equal(normalizedPath.path[0], ik))))\n ) {\n reducer.accept(normalizedPath);\n } else if (\"pathMatcher\" in props && props.pathMatcher(normalizedPath.path[0])) {\n reducer.accept(normalizedPath);\n }\n });\n return reducer.getNodeProps();\n },\n\n /**\n * Similar to `createChildNodeProps`, but takes an async `pathMatcher` prop.\n */\n createChildNodePropsAsync: async (props: {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): Promise<Pick<HierarchyNode, \"filtering\" | \"autoExpand\"> | undefined> => {\n if (!hasFilter) {\n return undefined;\n }\n const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);\n for (const filteredChildrenNodeIdentifierPath of filteringProps.filteredNodePaths) {\n const normalizedPath = HierarchyFilteringPath.normalize(filteredChildrenNodeIdentifierPath);\n /* c8 ignore next 3 */\n if (normalizedPath.path.length === 0) {\n continue;\n }\n\n const matchesPossiblyPromise = props.pathMatcher(normalizedPath.path[0]);\n if (matchesPossiblyPromise instanceof Promise) {\n if (!(await matchesPossiblyPromise)) {\n continue;\n }\n }\n if (!matchesPossiblyPromise) {\n continue;\n }\n\n reducer.accept(normalizedPath);\n }\n return reducer.getNodeProps();\n },\n };\n}\n\ntype NormalizedFilteringPath = ReturnType<(typeof HierarchyFilteringPath)[\"normalize\"]>;\nclass MatchingFilteringPathsReducer {\n private _filteredChildrenIdentifierPaths = new Array<NormalizedFilteringPath>();\n private _isFilterTarget = false;\n private _filterTargetOptions = undefined as HierarchyFilteringPathOptions | undefined;\n private _needsAutoExpand = false;\n\n public constructor(private _hasFilterTargetAncestor: boolean) {}\n\n public accept({ path, options }: NormalizedFilteringPath) {\n if (path.length === 1) {\n this._isFilterTarget = true;\n this._filterTargetOptions = HierarchyFilteringPath.mergeOptions(this._filterTargetOptions, options);\n } else if (path.length > 1) {\n this._filteredChildrenIdentifierPaths.push({ path: path.slice(1), options });\n if (options?.autoExpand) {\n this._needsAutoExpand = true;\n }\n }\n }\n public getNodeProps(): Pick<HierarchyNode, \"filtering\" | \"autoExpand\"> {\n return {\n ...(this._hasFilterTargetAncestor || this._isFilterTarget || this._filteredChildrenIdentifierPaths.length > 0\n ? {\n filtering: {\n ...(this._hasFilterTargetAncestor ? { hasFilterTargetAncestor: true } : undefined),\n ...(this._isFilterTarget ? { isFilterTarget: true, filterTargetOptions: this._filterTargetOptions } : undefined),\n ...(this._filteredChildrenIdentifierPaths.length > 0 ? { filteredChildrenIdentifierPaths: this._filteredChildrenIdentifierPaths } : undefined),\n },\n }\n : undefined),\n ...(this._needsAutoExpand ? { autoExpand: true } : undefined),\n };\n }\n}\n"]}
@@ -1,34 +0,0 @@
1
- import { ECClassHierarchyInspector, InstanceKey } from "@itwin/presentation-shared";
2
- import { HierarchyFilteringPath } from "../HierarchyFiltering.js";
3
- import { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyLevelDefinition, InstanceNodesQueryDefinition, NodeParser, NodePostProcessor, NodePreProcessor } from "./IModelHierarchyDefinition.js";
4
- interface FilteringHierarchyDefinitionProps {
5
- imodelAccess: ECClassHierarchyInspector & {
6
- imodelKey: string;
7
- };
8
- source: HierarchyDefinition;
9
- nodeIdentifierPaths: HierarchyFilteringPath[];
10
- nodesParser?: NodeParser;
11
- }
12
- /** @internal */
13
- export declare class FilteringHierarchyDefinition implements HierarchyDefinition {
14
- private _imodelAccess;
15
- private _source;
16
- private _nodeIdentifierPaths;
17
- private _nodesParser;
18
- constructor(props: FilteringHierarchyDefinitionProps);
19
- get preProcessNode(): NodePreProcessor;
20
- private shouldExpandGroupingNode;
21
- get postProcessNode(): NodePostProcessor;
22
- get parseNode(): NodeParser;
23
- defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;
24
- }
25
- /** @internal */
26
- export declare const ECSQL_COLUMN_NAME_FilterECInstanceId = "FilterECInstanceId";
27
- /** @internal */
28
- export declare const ECSQL_COLUMN_NAME_FilterClassName = "FilterClassName";
29
- /** @internal */
30
- export declare function applyECInstanceIdsFilter(def: InstanceNodesQueryDefinition, filteredInstanceKeys: InstanceKey[]): InstanceNodesQueryDefinition;
31
- /** @internal */
32
- export declare function applyECInstanceIdsSelector(def: InstanceNodesQueryDefinition): InstanceNodesQueryDefinition;
33
- export {};
34
- //# sourceMappingURL=FilteringHierarchyDefinition.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FilteringHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/FilteringHierarchyDefinition.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAAkC,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAIlG,OAAO,EACL,yBAAyB,EAEzB,mBAAmB,EAEnB,wBAAwB,EAExB,4BAA4B,EAC5B,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,gCAAgC,CAAC;AAKxC,UAAU,iCAAiC;IACzC,YAAY,EAAE,yBAAyB,GAAG;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAChE,MAAM,EAAE,mBAAmB,CAAC;IAC5B,mBAAmB,EAAE,sBAAsB,EAAE,CAAC;IAC9C,WAAW,CAAC,EAAE,UAAU,CAAC;CAC1B;AAED,gBAAgB;AAChB,qBAAa,4BAA6B,YAAW,mBAAmB;IACtE,OAA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