@itwin/unified-selection 0.2.0 → 0.3.0

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 (94) hide show
  1. package/CHANGELOG.md +119 -0
  2. package/README.md +34 -14
  3. package/lib/cjs/unified-selection/CachingHiliteSetProvider.d.ts +3 -7
  4. package/lib/cjs/unified-selection/CachingHiliteSetProvider.d.ts.map +1 -1
  5. package/lib/cjs/unified-selection/CachingHiliteSetProvider.js +14 -17
  6. package/lib/cjs/unified-selection/CachingHiliteSetProvider.js.map +1 -1
  7. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts +90 -0
  8. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts.map +1 -0
  9. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.js +205 -0
  10. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.js.map +1 -0
  11. package/lib/cjs/unified-selection/HiliteSetProvider.d.ts +2 -4
  12. package/lib/cjs/unified-selection/HiliteSetProvider.d.ts.map +1 -1
  13. package/lib/cjs/unified-selection/HiliteSetProvider.js +156 -110
  14. package/lib/cjs/unified-selection/HiliteSetProvider.js.map +1 -1
  15. package/lib/cjs/unified-selection/Selectable.d.ts +0 -3
  16. package/lib/cjs/unified-selection/Selectable.d.ts.map +1 -1
  17. package/lib/cjs/unified-selection/Selectable.js +2 -2
  18. package/lib/cjs/unified-selection/Selectable.js.map +1 -1
  19. package/lib/cjs/unified-selection/SelectionChangeEvent.d.ts +5 -3
  20. package/lib/cjs/unified-selection/SelectionChangeEvent.d.ts.map +1 -1
  21. package/lib/cjs/unified-selection/SelectionChangeEvent.js.map +1 -1
  22. package/lib/cjs/unified-selection/SelectionScope.d.ts +2 -2
  23. package/lib/cjs/unified-selection/SelectionScope.d.ts.map +1 -1
  24. package/lib/cjs/unified-selection/SelectionScope.js +87 -54
  25. package/lib/cjs/unified-selection/SelectionScope.js.map +1 -1
  26. package/lib/cjs/unified-selection/SelectionStorage.d.ts +20 -28
  27. package/lib/cjs/unified-selection/SelectionStorage.d.ts.map +1 -1
  28. package/lib/cjs/unified-selection/SelectionStorage.js +21 -18
  29. package/lib/cjs/unified-selection/SelectionStorage.js.map +1 -1
  30. package/lib/cjs/unified-selection/Utils.d.ts +7 -0
  31. package/lib/cjs/unified-selection/Utils.d.ts.map +1 -0
  32. package/lib/cjs/unified-selection/{queries/ECSqlCore.js → Utils.js} +2 -1
  33. package/lib/cjs/unified-selection/Utils.js.map +1 -0
  34. package/lib/cjs/unified-selection/types/IModel.d.ts +84 -0
  35. package/lib/cjs/unified-selection/types/IModel.d.ts.map +1 -0
  36. package/lib/cjs/unified-selection/types/IModel.js +24 -0
  37. package/lib/cjs/unified-selection/types/IModel.js.map +1 -0
  38. package/lib/cjs/unified-selection.d.ts +1 -6
  39. package/lib/cjs/unified-selection.d.ts.map +1 -1
  40. package/lib/cjs/unified-selection.js +3 -7
  41. package/lib/cjs/unified-selection.js.map +1 -1
  42. package/lib/esm/unified-selection/CachingHiliteSetProvider.d.ts +3 -7
  43. package/lib/esm/unified-selection/CachingHiliteSetProvider.d.ts.map +1 -1
  44. package/lib/esm/unified-selection/CachingHiliteSetProvider.js +14 -17
  45. package/lib/esm/unified-selection/CachingHiliteSetProvider.js.map +1 -1
  46. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts +90 -0
  47. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts.map +1 -0
  48. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.js +200 -0
  49. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.js.map +1 -0
  50. package/lib/esm/unified-selection/HiliteSetProvider.d.ts +2 -4
  51. package/lib/esm/unified-selection/HiliteSetProvider.d.ts.map +1 -1
  52. package/lib/esm/unified-selection/HiliteSetProvider.js +155 -109
  53. package/lib/esm/unified-selection/HiliteSetProvider.js.map +1 -1
  54. package/lib/esm/unified-selection/Selectable.d.ts +0 -3
  55. package/lib/esm/unified-selection/Selectable.d.ts.map +1 -1
  56. package/lib/esm/unified-selection/Selectable.js.map +1 -1
  57. package/lib/esm/unified-selection/SelectionChangeEvent.d.ts +5 -3
  58. package/lib/esm/unified-selection/SelectionChangeEvent.d.ts.map +1 -1
  59. package/lib/esm/unified-selection/SelectionChangeEvent.js.map +1 -1
  60. package/lib/esm/unified-selection/SelectionScope.d.ts +2 -2
  61. package/lib/esm/unified-selection/SelectionScope.d.ts.map +1 -1
  62. package/lib/esm/unified-selection/SelectionScope.js +84 -51
  63. package/lib/esm/unified-selection/SelectionScope.js.map +1 -1
  64. package/lib/esm/unified-selection/SelectionStorage.d.ts +20 -28
  65. package/lib/esm/unified-selection/SelectionStorage.d.ts.map +1 -1
  66. package/lib/esm/unified-selection/SelectionStorage.js +21 -18
  67. package/lib/esm/unified-selection/SelectionStorage.js.map +1 -1
  68. package/lib/esm/unified-selection/Utils.d.ts +7 -0
  69. package/lib/esm/unified-selection/Utils.d.ts.map +1 -0
  70. package/lib/esm/unified-selection/{queries/ECSqlCore.js → Utils.js} +2 -1
  71. package/lib/esm/unified-selection/Utils.js.map +1 -0
  72. package/lib/esm/unified-selection/types/IModel.d.ts +84 -0
  73. package/lib/esm/unified-selection/types/IModel.d.ts.map +1 -0
  74. package/lib/esm/unified-selection/types/IModel.js +21 -0
  75. package/lib/esm/unified-selection/types/IModel.js.map +1 -0
  76. package/lib/esm/unified-selection.d.ts +1 -6
  77. package/lib/esm/unified-selection.d.ts.map +1 -1
  78. package/lib/esm/unified-selection.js +1 -6
  79. package/lib/esm/unified-selection.js.map +1 -1
  80. package/package.json +23 -16
  81. package/lib/cjs/unified-selection/queries/ECMetadata.d.ts +0 -44
  82. package/lib/cjs/unified-selection/queries/ECMetadata.d.ts.map +0 -1
  83. package/lib/cjs/unified-selection/queries/ECMetadata.js +0 -17
  84. package/lib/cjs/unified-selection/queries/ECMetadata.js.map +0 -1
  85. package/lib/cjs/unified-selection/queries/ECSqlCore.d.ts +0 -69
  86. package/lib/cjs/unified-selection/queries/ECSqlCore.d.ts.map +0 -1
  87. package/lib/cjs/unified-selection/queries/ECSqlCore.js.map +0 -1
  88. package/lib/esm/unified-selection/queries/ECMetadata.d.ts +0 -44
  89. package/lib/esm/unified-selection/queries/ECMetadata.d.ts.map +0 -1
  90. package/lib/esm/unified-selection/queries/ECMetadata.js +0 -13
  91. package/lib/esm/unified-selection/queries/ECMetadata.js.map +0 -1
  92. package/lib/esm/unified-selection/queries/ECSqlCore.d.ts +0 -69
  93. package/lib/esm/unified-selection/queries/ECSqlCore.d.ts.map +0 -1
  94. package/lib/esm/unified-selection/queries/ECSqlCore.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Selectable.js","sourceRoot":"","sources":["../../../src/unified-selection/Selectable.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AA0ChG,YAAY;AACZ,2DAA2D;AAC3D,IAAiB,UAAU,CAW1B;AAXD,WAAiB,UAAU;IACzB,oEAAoE;IACpE,SAAgB,aAAa,CAAC,UAA6C;QACzE,MAAM,WAAW,GAAG,UAAmC,CAAC;QACxD,OAAO,CAAC,CAAC,WAAW,CAAC,SAAS,IAAI,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC;IACrD,CAAC;IAHe,wBAAa,gBAG5B,CAAA;IAED,+DAA+D;IAC/D,SAAgB,QAAQ,CAAC,UAAsB;QAC7C,OAAO,CAAC,CAAE,UAA+B,CAAC,UAAU,CAAC;IACvD,CAAC;IAFe,mBAAQ,WAEvB,CAAA;AACH,CAAC,EAXgB,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAW1B;AAiBD,YAAY;AACZ,2DAA2D;AAC3D,IAAiB,WAAW,CA+L3B;AA/LD,WAAiB,WAAW;IAC1B;;;;OAIG;IACH,SAAgB,MAAM,CAAC,MAAoB;QACzC,MAAM,cAAc,GAAG;YACrB,YAAY,EAAE,IAAI,GAAG,EAAu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,KAAK,EAAE,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;IARe,mBAAO,UAQtB,CAAA;IAED,SAAS,kBAAkB,CAAC,SAAiB;QAC3C,OAAO,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACrC,CAAC;AACH,CAAC,EA/LgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QA+L3B","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\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\n/**\n * ECInstance selectable\n * @beta\n */\nexport interface SelectableInstanceKey {\n /** Full class name in format `SchemaName:ClassName` or `SchemaName.ClassName`. */\n className: string;\n /** ECInstance ID */\n id: string;\n}\n\n/**\n * A custom selectable\n * @beta\n */\nexport interface CustomSelectable {\n /** Unique identifier of the selectable. */\n identifier: string;\n /** Asynchronous function for loading instance keys associated with this selectable. */\n loadInstanceKeys: () => AsyncIterableIterator<SelectableInstanceKey>;\n /** Custom data associated with the selectable. */\n data: unknown;\n}\n\n/**\n * A single selectable that identifies something in an iTwin.js application\n * @beta\n */\nexport type Selectable = SelectableInstanceKey | CustomSelectable;\n\n/**\n * Type of identifier that can be used to identify selectable in storage.\n * @beta\n */\nexport type SelectableIdentifier = SelectableInstanceKey | Pick<CustomSelectable, \"identifier\">;\n\n/** @beta */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace Selectable {\n /** Check if the supplied selectable is a `SelectableInstanceKey` */\n export function isInstanceKey(selectable: Selectable | SelectableIdentifier): selectable is SelectableInstanceKey {\n const instanceKey = selectable as SelectableInstanceKey;\n return !!instanceKey.className && !!instanceKey.id;\n }\n\n /** Check if the supplied selectable is a `CustomSelectable` */\n export function isCustom(selectable: Selectable): selectable is CustomSelectable {\n return !!(selectable as CustomSelectable).identifier;\n }\n}\n\n/**\n * A collection of selectables that identify something that can be selected in an iTwin.js application\n * @beta\n */\nexport interface Selectables {\n /**\n * Map between `SelectableInstanceKey.className` and a set of selected element IDs.\n */\n instanceKeys: Map<string, Set<string>>;\n /**\n * Map between unique identifier of `CustomSelectable` and the selectable itself.\n */\n custom: Map<string, CustomSelectable>;\n}\n\n/** @beta */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace Selectables {\n /**\n * Creates `Selectables` from array of selectable\n * @param source Source to create selectables from\n * @beta\n */\n export function create(source: Selectable[]): Selectables {\n const newSelectables = {\n instanceKeys: new Map<string, Set<string>>(),\n custom: new Map<string, CustomSelectable>(),\n };\n Selectables.add(newSelectables, source);\n return newSelectables;\n }\n\n /**\n * Get the number of selectables stored in a `Selectables` object.\n * @param selectables `Selectables` object to get size for\n * @beta\n */\n export function size(selectables: Selectables): number {\n let insatanceCount = 0;\n selectables.instanceKeys.forEach((set: Set<string>) => (insatanceCount += set.size));\n return insatanceCount + selectables.custom.size;\n }\n\n /**\n * Is a `Selectables` object currently empty.\n * @param selectables `Selectables` object to check\n * @beta\n */\n export function isEmpty(selectables: Selectables): boolean {\n return Selectables.size(selectables) === 0;\n }\n\n /**\n * Check if a `Selectables` object contains the specified selectable.\n * @param selectables `Selectables` object to check\n * @param value The selectable to check for.\n * @beta\n */\n export function has(selectables: Selectables, value: SelectableIdentifier): boolean {\n if (Selectable.isInstanceKey(value)) {\n const normalizedClassName = normalizeClassName(value.className);\n const set = selectables.instanceKeys.get(normalizedClassName);\n return !!(set && set.has(value.id));\n }\n return selectables.custom.has(value.identifier);\n }\n\n /**\n * Check if a `Selectables` object contains all the specified selectables.\n * @param selectables `Selectables` object to check\n * @param values The selectables to check for.\n * @beta\n */\n export function hasAll(selectables: Selectables, values: SelectableIdentifier[]): boolean {\n if (Selectables.size(selectables) < values.length) {\n return false;\n }\n for (const selectable of values) {\n if (!Selectables.has(selectables, selectable)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Check if a `Selectables` object contains any of the specified selectables.\n * @param selectables `Selectables` object to check\n * @param values The selectables to check for.\n * @beta\n */\n export function hasAny(selectables: Selectables, values: SelectableIdentifier[]): boolean {\n for (const selectable of values) {\n if (Selectables.has(selectables, selectable)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Add a one or more selectables to a `Selectables`\n * @param selectables `Selectables` object to add selectables for\n * @param values Selectables to add.\n * @beta\n */\n export function add(selectables: Selectables, values: Selectable[]): boolean {\n let hasChanged = false;\n for (const selectable of values) {\n if (Selectable.isInstanceKey(selectable)) {\n const normalizedClassName = normalizeClassName(selectable.className);\n let set = selectables.instanceKeys.get(normalizedClassName);\n if (!set) {\n set = new Set<string>();\n }\n if (!set.has(selectable.id)) {\n set.add(selectable.id);\n selectables.instanceKeys.set(normalizedClassName, set);\n hasChanged = true;\n }\n } else if (!selectables.custom.has(selectable.identifier)) {\n selectables.custom.set(selectable.identifier, selectable);\n hasChanged = true;\n }\n }\n return hasChanged;\n }\n\n /**\n * Removes one or more selectables from a `Selectables` object.\n * @param selectables `Selectables` object to remove selectables for\n * @param values Selectables to remove.\n * @beta\n */\n export function remove(selectables: Selectables, values: Selectable[]): boolean {\n let hasChanged = false;\n for (const selectable of values) {\n if (Selectable.isInstanceKey(selectable)) {\n const normalizedClassName = normalizeClassName(selectable.className);\n const set = selectables.instanceKeys.get(normalizedClassName);\n if (set && set.has(selectable.id)) {\n set.delete(selectable.id);\n hasChanged = true;\n if (set.size === 0) {\n selectables.instanceKeys.delete(normalizedClassName);\n }\n }\n } else if (selectables.custom.has(selectable.identifier)) {\n selectables.custom.delete(selectable.identifier);\n hasChanged = true;\n }\n }\n return hasChanged;\n }\n\n /**\n * Clear a `Selectables` object.\n * @param selectables `Selectables` object to clear selectables for\n * @beta\n */\n export function clear(selectables: Selectables): boolean {\n if (Selectables.size(selectables) === 0) {\n return false;\n }\n selectables.instanceKeys = new Map<string, Set<string>>();\n selectables.custom = new Map<string, CustomSelectable>();\n return true;\n }\n\n /**\n * Check whether at least one selectable passes a condition in a `Selectables` object.\n * @param selectables `Selectables` object to check\n * @beta\n */\n export function some(selectables: Selectables, callback: (selectable: Selectable) => boolean) {\n for (const entry of selectables.instanceKeys) {\n for (const item of entry[1]) {\n if (callback({ className: entry[0], id: item })) {\n return true;\n }\n }\n }\n for (const entry of selectables.custom) {\n if (callback(entry[1])) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Iterate over all keys in a `Selectables` object.\n * @param selectables `Selectables` object to iterate over\n * @beta\n */\n export function forEach(selectables: Selectables, callback: (selectable: Selectable, index: number) => void) {\n let index = 0;\n selectables.instanceKeys.forEach((ids: Set<string>, className: string) => {\n ids.forEach((id: string) => callback({ className, id }, index++));\n });\n selectables.custom.forEach((data) => {\n callback(data, index++);\n });\n }\n\n function normalizeClassName(className: string): string {\n return className.replace(\".\", \":\");\n }\n}\n"]}
1
+ {"version":3,"file":"Selectable.js","sourceRoot":"","sources":["../../../src/unified-selection/Selectable.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAsChG,YAAY;AACZ,2DAA2D;AAC3D,IAAiB,UAAU,CAW1B;AAXD,WAAiB,UAAU;IACzB,oEAAoE;IACpE,SAAgB,aAAa,CAAC,UAA6C;QACzE,MAAM,WAAW,GAAG,UAAmC,CAAC;QACxD,OAAO,CAAC,CAAC,WAAW,CAAC,SAAS,IAAI,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC;IACrD,CAAC;IAHe,wBAAa,gBAG5B,CAAA;IAED,+DAA+D;IAC/D,SAAgB,QAAQ,CAAC,UAAsB;QAC7C,OAAO,CAAC,CAAE,UAA+B,CAAC,UAAU,CAAC;IACvD,CAAC;IAFe,mBAAQ,WAEvB,CAAA;AACH,CAAC,EAXgB,UAAU,0BAAV,UAAU,QAW1B;AAiBD,YAAY;AACZ,2DAA2D;AAC3D,IAAiB,WAAW,CA+L3B;AA/LD,WAAiB,WAAW;IAC1B;;;;OAIG;IACH,SAAgB,MAAM,CAAC,MAAoB;QACz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,CAAC,OAAO,CAAC,CAAC,GAAgB,EAAE,SAAiB,EAAE,EAAE;YACvE,GAAG,CAAC,OAAO,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;QACH,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAClC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;IARe,mBAAO,UAQtB,CAAA;IAED,SAAS,kBAAkB,CAAC,SAAiB;QAC3C,OAAO,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACrC,CAAC;AACH,CAAC,EA/LgB,WAAW,2BAAX,WAAW,QA+L3B","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\n/**\n * ECInstance selectable\n * @beta\n */\nexport interface SelectableInstanceKey {\n /** Full class name in format `SchemaName:ClassName` or `SchemaName.ClassName`. */\n className: string;\n /** ECInstance ID */\n id: string;\n}\n\n/**\n * A custom selectable\n * @beta\n */\nexport interface CustomSelectable {\n /** Unique identifier of the selectable. */\n identifier: string;\n /** Asynchronous function for loading instance keys associated with this selectable. */\n loadInstanceKeys: () => AsyncIterableIterator<SelectableInstanceKey>;\n /** Custom data associated with the selectable. */\n data: unknown;\n}\n\n/**\n * A single selectable that identifies something in an iTwin.js application\n * @beta\n */\nexport type Selectable = SelectableInstanceKey | CustomSelectable;\n\n/**\n * Type of identifier that can be used to identify selectable in storage.\n * @beta\n */\nexport type SelectableIdentifier = SelectableInstanceKey | Pick<CustomSelectable, \"identifier\">;\n\n/** @beta */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace Selectable {\n /** Check if the supplied selectable is a `SelectableInstanceKey` */\n export function isInstanceKey(selectable: Selectable | SelectableIdentifier): selectable is SelectableInstanceKey {\n const instanceKey = selectable as SelectableInstanceKey;\n return !!instanceKey.className && !!instanceKey.id;\n }\n\n /** Check if the supplied selectable is a `CustomSelectable` */\n export function isCustom(selectable: Selectable): selectable is CustomSelectable {\n return !!(selectable as CustomSelectable).identifier;\n }\n}\n\n/**\n * A collection of selectables that identify something that can be selected in an iTwin.js application\n * @beta\n */\nexport interface Selectables {\n /**\n * Map between `SelectableInstanceKey.className` and a set of selected element IDs.\n */\n instanceKeys: Map<string, Set<string>>;\n /**\n * Map between unique identifier of `CustomSelectable` and the selectable itself.\n */\n custom: Map<string, CustomSelectable>;\n}\n\n/** @beta */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace Selectables {\n /**\n * Creates `Selectables` from array of selectable\n * @param source Source to create selectables from\n * @beta\n */\n export function create(source: Selectable[]): Selectables {\n const newSelectables = {\n instanceKeys: new Map<string, Set<string>>(),\n custom: new Map<string, CustomSelectable>(),\n };\n Selectables.add(newSelectables, source);\n return newSelectables;\n }\n\n /**\n * Get the number of selectables stored in a `Selectables` object.\n * @param selectables `Selectables` object to get size for\n * @beta\n */\n export function size(selectables: Selectables): number {\n let insatanceCount = 0;\n selectables.instanceKeys.forEach((set: Set<string>) => (insatanceCount += set.size));\n return insatanceCount + selectables.custom.size;\n }\n\n /**\n * Is a `Selectables` object currently empty.\n * @param selectables `Selectables` object to check\n * @beta\n */\n export function isEmpty(selectables: Selectables): boolean {\n return Selectables.size(selectables) === 0;\n }\n\n /**\n * Check if a `Selectables` object contains the specified selectable.\n * @param selectables `Selectables` object to check\n * @param value The selectable to check for.\n * @beta\n */\n export function has(selectables: Selectables, value: SelectableIdentifier): boolean {\n if (Selectable.isInstanceKey(value)) {\n const normalizedClassName = normalizeClassName(value.className);\n const set = selectables.instanceKeys.get(normalizedClassName);\n return !!(set && set.has(value.id));\n }\n return selectables.custom.has(value.identifier);\n }\n\n /**\n * Check if a `Selectables` object contains all the specified selectables.\n * @param selectables `Selectables` object to check\n * @param values The selectables to check for.\n * @beta\n */\n export function hasAll(selectables: Selectables, values: SelectableIdentifier[]): boolean {\n if (Selectables.size(selectables) < values.length) {\n return false;\n }\n for (const selectable of values) {\n if (!Selectables.has(selectables, selectable)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Check if a `Selectables` object contains any of the specified selectables.\n * @param selectables `Selectables` object to check\n * @param values The selectables to check for.\n * @beta\n */\n export function hasAny(selectables: Selectables, values: SelectableIdentifier[]): boolean {\n for (const selectable of values) {\n if (Selectables.has(selectables, selectable)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Add a one or more selectables to a `Selectables`\n * @param selectables `Selectables` object to add selectables for\n * @param values Selectables to add.\n * @beta\n */\n export function add(selectables: Selectables, values: Selectable[]): boolean {\n let hasChanged = false;\n for (const selectable of values) {\n if (Selectable.isInstanceKey(selectable)) {\n const normalizedClassName = normalizeClassName(selectable.className);\n let set = selectables.instanceKeys.get(normalizedClassName);\n if (!set) {\n set = new Set<string>();\n }\n if (!set.has(selectable.id)) {\n set.add(selectable.id);\n selectables.instanceKeys.set(normalizedClassName, set);\n hasChanged = true;\n }\n } else if (!selectables.custom.has(selectable.identifier)) {\n selectables.custom.set(selectable.identifier, selectable);\n hasChanged = true;\n }\n }\n return hasChanged;\n }\n\n /**\n * Removes one or more selectables from a `Selectables` object.\n * @param selectables `Selectables` object to remove selectables for\n * @param values Selectables to remove.\n * @beta\n */\n export function remove(selectables: Selectables, values: Selectable[]): boolean {\n let hasChanged = false;\n for (const selectable of values) {\n if (Selectable.isInstanceKey(selectable)) {\n const normalizedClassName = normalizeClassName(selectable.className);\n const set = selectables.instanceKeys.get(normalizedClassName);\n if (set && set.has(selectable.id)) {\n set.delete(selectable.id);\n hasChanged = true;\n if (set.size === 0) {\n selectables.instanceKeys.delete(normalizedClassName);\n }\n }\n } else if (selectables.custom.has(selectable.identifier)) {\n selectables.custom.delete(selectable.identifier);\n hasChanged = true;\n }\n }\n return hasChanged;\n }\n\n /**\n * Clear a `Selectables` object.\n * @param selectables `Selectables` object to clear selectables for\n * @beta\n */\n export function clear(selectables: Selectables): boolean {\n if (Selectables.size(selectables) === 0) {\n return false;\n }\n selectables.instanceKeys = new Map<string, Set<string>>();\n selectables.custom = new Map<string, CustomSelectable>();\n return true;\n }\n\n /**\n * Check whether at least one selectable passes a condition in a `Selectables` object.\n * @param selectables `Selectables` object to check\n * @beta\n */\n export function some(selectables: Selectables, callback: (selectable: Selectable) => boolean) {\n for (const entry of selectables.instanceKeys) {\n for (const item of entry[1]) {\n if (callback({ className: entry[0], id: item })) {\n return true;\n }\n }\n }\n for (const entry of selectables.custom) {\n if (callback(entry[1])) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Iterate over all keys in a `Selectables` object.\n * @param selectables `Selectables` object to iterate over\n * @beta\n */\n export function forEach(selectables: Selectables, callback: (selectable: Selectable, index: number) => void) {\n let index = 0;\n selectables.instanceKeys.forEach((ids: Set<string>, className: string) => {\n ids.forEach((id: string) => callback({ className, id }, index++));\n });\n selectables.custom.forEach((data) => {\n callback(data, index++);\n });\n }\n\n function normalizeClassName(className: string): string {\n return className.replace(\".\", \":\");\n }\n}\n"]}
@@ -1,8 +1,5 @@
1
1
  import { Selectables } from "./Selectable";
2
2
  import { SelectionStorage } from "./SelectionStorage";
3
- /** @packageDocumentation
4
- * @module UnifiedSelection
5
- */
6
3
  /**
7
4
  * The type of selection change.
8
5
  * @beta
@@ -32,6 +29,11 @@ export interface StorageSelectionChangeEventArgs {
32
29
  /** Selectables affected by this selection change event. */
33
30
  selectables: Selectables;
34
31
  /** iModel key with which the selection is associated with. */
32
+ imodelKey: string;
33
+ /**
34
+ * iModel key with which the selection is associated with.
35
+ * @deprecated in 0.2. Use `imodelKey` instead.
36
+ */
35
37
  iModelKey: string;
36
38
  /** The timestamp of when the selection change happened */
37
39
  timestamp: Date;
@@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A+B,GAAG,IAAI;IAItE;;;;;OAKG;IACI,UAAU,CAAC,IAAI,EAAE,+BAA+B,EAAE,OAAO,EAAE,gBAAgB;CAGnF"}
1
+ {"version":3,"file":"SelectionChangeEvent.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/SelectionChangeEvent.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,0BAA0B;AACpC,0BAA0B;AACxB,KAAK;AACP,8BAA8B;GAC5B,QAAQ;AACV,8BAA8B;GAC5B,SAAS;AACX,6BAA6B;GAC3B,OAAO,CAAC;AAEZ;;;;;GAKG;AACH,MAAM,WAAW,+BAA+B;IAC9C,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,UAAU,EAAE,0BAA0B,CAAC;IACvC,2DAA2D;IAC3D,WAAW,EAAE,WAAW,CAAC;IACzB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,SAAS,EAAE,IAAI,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,MAAM,+BAA+B,GAAG,CAAC,IAAI,EAAE,+BAA+B,EAAE,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;AAEjI;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,+BAA+B,GAAG,MAAM,IAAI,CAAC;IACnE;;;;OAIG;IACH,cAAc,CAAC,QAAQ,EAAE,+BAA+B,GAAG,IAAI,CAAC;CACjE;AAED;;;GAGG;AACH,qBAAa,wBAAyB,YAAW,oBAAoB;IACnE,OAAO,CAAC,UAAU,CAAyC;IAE3D;;;;;OAKG;IACI,WAAW,CAAC,QAAQ,EAAE,+BAA+B,GAAG,MAAM,IAAI;IAKzE;;;;OAIG;IACI,cAAc,CAAC,QAAQ,EAAE,+BAA+B,GAAG,IAAI;IAItE;;;;;OAKG;IACI,UAAU,CAAC,IAAI,EAAE,+BAA+B,EAAE,OAAO,EAAE,gBAAgB;CAGnF"}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionChangeEvent.js","sourceRoot":"","sources":["../../../src/unified-selection/SelectionChangeEvent.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAuEhG;;;GAGG;AACH,MAAa,wBAAwB;IAC3B,UAAU,GAAsC,EAAE,CAAC;IAE3D;;;;;OAKG;IACI,WAAW,CAAC,QAAyC;QAC1D,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/B,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,cAAc,CAAC,QAAyC;QAC7D,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC;IAClE,CAAC;IAED;;;;;OAKG;IACI,UAAU,CAAC,IAAqC,EAAE,OAAyB;QAChF,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACjE,CAAC;CACF;AAhCD,4DAgCC","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 { Selectables } from \"./Selectable\";\nimport { SelectionStorage } from \"./SelectionStorage\";\n\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\n/**\n * The type of selection change.\n * @beta\n */\nexport type StorageSelectionChangeType =\n /** Added to selection. */\n | \"add\"\n /** Removed from selection. */\n | \"remove\"\n /** Selection was replaced. */\n | \"replace\"\n /** Selection was cleared. */\n | \"clear\";\n\n/**\n * The event object that is sent when the selection changes.\n *\n * @beta Used in public API as an argument for `StorageSelectionChangesListener`. Not expected to be created / extended by package\n * consumers, may be supplemented with required attributes any time.\n */\nexport interface StorageSelectionChangeEventArgs {\n /** The name of the selection source which caused the selection change. */\n source: string;\n /** Level of the selection. */\n level: number;\n /** The selection change type. */\n changeType: StorageSelectionChangeType;\n /** Selectables affected by this selection change event. */\n selectables: Selectables;\n /** iModel key with which the selection is associated with. */\n iModelKey: string;\n /** The timestamp of when the selection change happened */\n timestamp: Date;\n}\n\n/**\n * An interface for selection change listeners.\n * @beta\n */\nexport declare type StorageSelectionChangesListener = (args: StorageSelectionChangeEventArgs, storage: SelectionStorage) => void;\n\n/**\n * An interface that allows subscribing and unsubscribing listeners that\n * are called when a selection has changed.\n * @beta\n */\nexport interface SelectionChangeEvent {\n /**\n * Registers a Listener to be executed whenever this event is raised\n * @param listener The function to be executed when the event is raised\n * @returns A function that will remove this event listener\n * @beta\n */\n addListener(listener: StorageSelectionChangesListener): () => void;\n /**\n * Un-register a previously registered listener\n * @param listener The listener to be unregistered\n * @beta\n */\n removeListener(listener: StorageSelectionChangesListener): void;\n}\n\n/**\n * An event broadcasted on selection changes.\n * @internal\n */\nexport class SelectionChangeEventImpl implements SelectionChangeEvent {\n private _listeners: StorageSelectionChangesListener[] = [];\n\n /**\n * Registers a Listener to be executed whenever this event is raised\n * @param listener The function to be executed when the event is raised\n * @returns A function that will remove this event listener\n * @beta\n */\n public addListener(listener: StorageSelectionChangesListener): () => void {\n this._listeners.push(listener);\n return () => this.removeListener(listener);\n }\n\n /**\n * Un-register a previously registered listener\n * @param listener The listener to be unregistered\n * @beta\n */\n public removeListener(listener: StorageSelectionChangesListener): void {\n this._listeners = this._listeners.filter((x) => x !== listener);\n }\n\n /**\n * Raises the event by calling each registered listener with the supplied arguments\n * @param args Event arguments\n * @param storage Storage that the selection changed in\n * @beta\n */\n public raiseEvent(args: StorageSelectionChangeEventArgs, storage: SelectionStorage) {\n this._listeners.forEach((listener) => listener(args, storage));\n }\n}\n"]}
1
+ {"version":3,"file":"SelectionChangeEvent.js","sourceRoot":"","sources":["../../../src/unified-selection/SelectionChangeEvent.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAwEhG;;;GAGG;AACH,MAAa,wBAAwB;IAC3B,UAAU,GAAsC,EAAE,CAAC;IAE3D;;;;;OAKG;IACI,WAAW,CAAC,QAAyC;QAC1D,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/B,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,cAAc,CAAC,QAAyC;QAC7D,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC;IAClE,CAAC;IAED;;;;;OAKG;IACI,UAAU,CAAC,IAAqC,EAAE,OAAyB;QAChF,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACjE,CAAC;CACF;AAhCD,4DAgCC","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 { Selectables } from \"./Selectable\";\nimport { SelectionStorage } from \"./SelectionStorage\";\n\n/**\n * The type of selection change.\n * @beta\n */\nexport type StorageSelectionChangeType =\n /** Added to selection. */\n | \"add\"\n /** Removed from selection. */\n | \"remove\"\n /** Selection was replaced. */\n | \"replace\"\n /** Selection was cleared. */\n | \"clear\";\n\n/**\n * The event object that is sent when the selection changes.\n *\n * @beta Used in public API as an argument for `StorageSelectionChangesListener`. Not expected to be created / extended by package\n * consumers, may be supplemented with required attributes any time.\n */\nexport interface StorageSelectionChangeEventArgs {\n /** The name of the selection source which caused the selection change. */\n source: string;\n /** Level of the selection. */\n level: number;\n /** The selection change type. */\n changeType: StorageSelectionChangeType;\n /** Selectables affected by this selection change event. */\n selectables: Selectables;\n /** iModel key with which the selection is associated with. */\n imodelKey: string;\n /**\n * iModel key with which the selection is associated with.\n * @deprecated in 0.2. Use `imodelKey` instead.\n */\n iModelKey: string;\n /** The timestamp of when the selection change happened */\n timestamp: Date;\n}\n\n/**\n * An interface for selection change listeners.\n * @beta\n */\nexport declare type StorageSelectionChangesListener = (args: StorageSelectionChangeEventArgs, storage: SelectionStorage) => void;\n\n/**\n * An interface that allows subscribing and unsubscribing listeners that\n * are called when a selection has changed.\n * @beta\n */\nexport interface SelectionChangeEvent {\n /**\n * Registers a Listener to be executed whenever this event is raised\n * @param listener The function to be executed when the event is raised\n * @returns A function that will remove this event listener\n * @beta\n */\n addListener(listener: StorageSelectionChangesListener): () => void;\n /**\n * Un-register a previously registered listener\n * @param listener The listener to be unregistered\n * @beta\n */\n removeListener(listener: StorageSelectionChangesListener): void;\n}\n\n/**\n * An event broadcasted on selection changes.\n * @internal\n */\nexport class SelectionChangeEventImpl implements SelectionChangeEvent {\n private _listeners: StorageSelectionChangesListener[] = [];\n\n /**\n * Registers a Listener to be executed whenever this event is raised\n * @param listener The function to be executed when the event is raised\n * @returns A function that will remove this event listener\n * @beta\n */\n public addListener(listener: StorageSelectionChangesListener): () => void {\n this._listeners.push(listener);\n return () => this.removeListener(listener);\n }\n\n /**\n * Un-register a previously registered listener\n * @param listener The listener to be unregistered\n * @beta\n */\n public removeListener(listener: StorageSelectionChangesListener): void {\n this._listeners = this._listeners.filter((x) => x !== listener);\n }\n\n /**\n * Raises the event by calling each registered listener with the supplied arguments\n * @param args Event arguments\n * @param storage Storage that the selection changed in\n * @beta\n */\n public raiseEvent(args: StorageSelectionChangeEventArgs, storage: SelectionStorage) {\n this._listeners.forEach((listener) => listener(args, storage));\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { IECSqlQueryExecutor } from "./queries/ECSqlCore";
1
+ import { ECSqlQueryExecutor } from "@itwin/presentation-shared";
2
2
  import { SelectableInstanceKey } from "./Selectable";
3
3
  /**
4
4
  * Available selection scopes.
@@ -27,7 +27,7 @@ export interface ElementSelectionScopeProps {
27
27
  * @internal Not exported through barrel, but used in public API as an argument. May be supplemented with optional attributes any time.
28
28
  */
29
29
  export interface ComputeSelectionProps {
30
- queryExecutor: IECSqlQueryExecutor;
30
+ queryExecutor: ECSqlQueryExecutor;
31
31
  elementIds: string[];
32
32
  scope: ElementSelectionScopeProps | {
33
33
  id: SelectionScope;
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionScope.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/SelectionScope.ts"],"names":[],"mappings":"AAMA,OAAO,EAAgC,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,YAAY,CAAC;AAE7E;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,0EAA0E;IAC1E,EAAE,EAAE,SAAS,GAAG,YAAY,CAAC;IAC7B;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,mBAAmB,CAAC;IACnC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,EAAE,0BAA0B,GAAG;QAAE,EAAE,EAAE,cAAc,CAAA;KAAE,GAAG,cAAc,CAAC;CAC7E;AAED;;;;;;GAMG;AACH,wBAAuB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,CAwBlH"}
1
+ {"version":3,"file":"SelectionScope.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/SelectionScope.ts"],"names":[],"mappings":"AAMA,OAAO,EAA+B,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAGrD;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,YAAY,CAAC;AAE7E;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,0EAA0E;IAC1E,EAAE,EAAE,SAAS,GAAG,YAAY,CAAC;IAC7B;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,kBAAkB,CAAC;IAClC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,EAAE,0BAA0B,GAAG;QAAE,EAAE,EAAE,cAAc,CAAA;KAAE,GAAG,cAAc,CAAC;CAC7E;AAED;;;;;;GAMG;AACH,wBAAuB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,CAwBlH"}
@@ -6,7 +6,7 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.computeSelection = void 0;
8
8
  const core_bentley_1 = require("@itwin/core-bentley");
9
- const ECSqlCore_1 = require("./queries/ECSqlCore");
9
+ const Utils_1 = require("./Utils");
10
10
  /**
11
11
  * Computes selection from given element ID's.
12
12
  * @param queryExecutor iModel query executor.
@@ -40,50 +40,64 @@ exports.computeSelection = computeSelection;
40
40
  async function* computeElementSelection(queryExecutor, elementIds, ancestorLevel) {
41
41
  const bindings = [];
42
42
  const recurseUntilRoot = ancestorLevel < 0;
43
- const query = `
44
- WITH RECURSIVE
45
- AncestorElements (ECInstanceId, ECClassId, Depth, ParentId) AS (
43
+ const ctes = [
44
+ `
45
+ AncestorElements(ECInstanceId, ECClassId, Depth, ParentId) AS (
46
46
  SELECT ECInstanceId, ECClassId, ${formAncestorLevelBinding(ancestorLevel, bindings)}, Parent.Id
47
47
  FROM BisCore.Element
48
- WHERE ${(0, ECSqlCore_1.formIdBindings)("ECInstanceId", elementIds, bindings)}
48
+ WHERE ${(0, Utils_1.formIdBindings)("ECInstanceId", elementIds, bindings)}
49
49
  UNION ALL
50
- SELECT pe.ECInstanceId, pe.ECClassId, a.Depth - 1, pe.Parent.Id FROM AncestorElements a
51
- JOIN BisCore.Element pe ON pe.ECInstanceId = a.ParentId
50
+ SELECT pe.ECInstanceId, pe.ECClassId, a.Depth - 1, pe.Parent.Id
51
+ FROM AncestorElements a
52
+ JOIN BisCore.Element pe ON pe.ECInstanceId = a.ParentId
52
53
  WHERE ${recurseUntilRoot ? "" : "Depth > 0 AND"} ParentId IS NOT NULL
53
54
  )
54
- SELECT DISTINCT ECInstanceId, ec_classname(ECClassId, 's.c') AS ClassName FROM AncestorElements
55
- WHERE ${recurseUntilRoot ? "" : "Depth = 0 OR"} ParentId IS NULL`;
56
- yield* executeQuery(queryExecutor, query, bindings);
55
+ `,
56
+ ];
57
+ const ecsql = `
58
+ SELECT DISTINCT ECInstanceId, ec_classname(ECClassId, 's.c') AS ClassName
59
+ FROM AncestorElements
60
+ WHERE ${recurseUntilRoot ? "" : "Depth = 0 OR"} ParentId IS NULL
61
+ `;
62
+ yield* executeQuery(queryExecutor, { ctes, ecsql, bindings });
57
63
  }
58
64
  async function* computeCategorySelection(queryExecutor, ids) {
59
65
  const bindings = [];
60
- const query = `
61
- SELECT DISTINCT c.ECInstanceId, ec_classname(c.ECClassId, 's.c') AS ClassName
62
- FROM BisCore.Category c JOIN BisCore.GeometricElement2d ge ON ge.Category.Id = c.ECInstanceId
63
- WHERE ${(0, ECSqlCore_1.formIdBindings)("ge.ECInstanceId", ids, bindings)}
64
- UNION ALL
65
- SELECT DISTINCT c.ECInstanceId, ec_classname(c.ECClassId, 's.c') AS ClassName
66
- FROM BisCore.Category c JOIN BisCore.GeometricElement3d ge ON ge.Category.Id = c.ECInstanceId
67
- WHERE ${(0, ECSqlCore_1.formIdBindings)("ge.ECInstanceId", ids, bindings)}`;
68
- yield* executeQuery(queryExecutor, query, bindings);
66
+ const ecsql = [
67
+ `
68
+ SELECT DISTINCT c.ECInstanceId, ec_classname(c.ECClassId, 's.c') AS ClassName
69
+ FROM BisCore.Category c
70
+ JOIN BisCore.GeometricElement2d ge ON ge.Category.Id = c.ECInstanceId
71
+ WHERE ${(0, Utils_1.formIdBindings)("ge.ECInstanceId", ids, bindings)}
72
+ `,
73
+ `
74
+ SELECT DISTINCT c.ECInstanceId, ec_classname(c.ECClassId, 's.c') AS ClassName
75
+ FROM BisCore.Category c
76
+ JOIN BisCore.GeometricElement3d ge ON ge.Category.Id = c.ECInstanceId
77
+ WHERE ${(0, Utils_1.formIdBindings)("ge.ECInstanceId", ids, bindings)}
78
+ `,
79
+ ].join(" UNION ALL ");
80
+ yield* executeQuery(queryExecutor, { ecsql, bindings });
69
81
  }
70
82
  async function* computeModelSelection(queryExecutor, ids) {
71
83
  const bindings = [];
72
- const query = `
84
+ const ecsql = `
73
85
  SELECT DISTINCT m.ECInstanceId, ec_classname(m.ECClassId, 's.c') AS ClassName
74
- FROM BisCore.Model m JOIN BisCore.Element e ON e.Model.Id = m.ECInstanceId
75
- WHERE ${(0, ECSqlCore_1.formIdBindings)("e.ECInstanceId", ids, bindings)}`;
76
- yield* executeQuery(queryExecutor, query, bindings);
86
+ FROM BisCore.Model m
87
+ JOIN BisCore.Element e ON e.Model.Id = m.ECInstanceId
88
+ WHERE ${(0, Utils_1.formIdBindings)("e.ECInstanceId", ids, bindings)}
89
+ `;
90
+ yield* executeQuery(queryExecutor, { ecsql, bindings });
77
91
  }
78
92
  async function* computeFunctionalElementSelection(queryExecutor, ids, ancestorLevel) {
79
93
  const bindings = [];
80
94
  const recurseUntilRoot = ancestorLevel < 0;
81
- const query = `
82
- WITH RECURSIVE
83
- Elements2dOrNearestFunctionalElements (OriginalECInstanceId, OriginalECClassId, ECInstanceId, ECClassId, ParentId) AS (
95
+ const ctes = [
96
+ `
97
+ Elements2dOrNearestFunctionalElements(OriginalECInstanceId, OriginalECClassId, ECInstanceId, ECClassId, ParentId) AS (
84
98
  SELECT ECInstanceId, ECClassId, ECInstanceId, ECClassId, Parent.Id
85
99
  FROM BisCore.Element
86
- WHERE ${(0, ECSqlCore_1.formIdBindings)("ECInstanceId", ids, bindings)} AND ECClassId IS NOT (BisCore.GeometricElement3d)
100
+ WHERE ${(0, Utils_1.formIdBindings)("ECInstanceId", ids, bindings)} AND ECClassId IS NOT (BisCore.GeometricElement3d)
87
101
  UNION ALL
88
102
  SELECT
89
103
  e2onfe.OriginalECInstanceId,
@@ -92,67 +106,86 @@ async function* computeFunctionalElementSelection(queryExecutor, ids, ancestorLe
92
106
  COALESCE(dgrfe.TargetECClassId, pe.ECClassId),
93
107
  pe.Parent.Id
94
108
  FROM Elements2dOrNearestFunctionalElements e2onfe
95
- LEFT JOIN BisCore.Element pe ON pe.ECInstanceId = e2onfe.ParentId
96
- LEFT JOIN Functional.DrawingGraphicRepresentsFunctionalElement dgrfe ON dgrfe.SourceECInstanceId = e2onfe.ECInstanceId
109
+ LEFT JOIN BisCore.Element pe ON pe.ECInstanceId = e2onfe.ParentId
110
+ LEFT JOIN Functional.DrawingGraphicRepresentsFunctionalElement dgrfe ON dgrfe.SourceECInstanceId = e2onfe.ECInstanceId
97
111
  WHERE e2onfe.ECClassId IS NOT (Functional.FunctionalElement) AND (e2onfe.ParentId IS NOT NULL OR dgrfe.TargetECInstanceId IS NOT NULL)
98
- ),
99
- Element2dNearestFunctionalElements (OriginalECInstanceId, ECInstanceId, ECClassId) AS (
112
+ )
113
+ `,
114
+ `
115
+ Element2dNearestFunctionalElements(OriginalECInstanceId, ECInstanceId, ECClassId) AS (
100
116
  SELECT OriginalECInstanceId, ECInstanceId, ECClassId
101
117
  FROM Elements2dOrNearestFunctionalElements
102
118
  WHERE ECClassId IS (Functional.FunctionalElement)
103
- ),
104
- Elements2dWithoutFunctionalElement (ECInstanceId, ECClassId) AS (
119
+ )
120
+ `,
121
+ `
122
+ Elements2dWithoutFunctionalElement(ECInstanceId, ECClassId) AS (
105
123
  SELECT e2wfe.OriginalECInstanceId, OriginalECClassId
106
124
  FROM Elements2dOrNearestFunctionalElements e2wfe
107
- LEFT JOIN Element2dNearestFunctionalElements e2nfe ON e2nfe.OriginalECInstanceId = e2wfe.OriginalECInstanceId
125
+ LEFT JOIN Element2dNearestFunctionalElements e2nfe ON e2nfe.OriginalECInstanceId = e2wfe.OriginalECInstanceId
108
126
  WHERE e2wfe.ParentId IS NULL AND e2nfe.ECInstanceId IS NULL
109
- ),
110
- Elements2d (ECInstanceId, ECClassId) AS (
127
+ )
128
+ `,
129
+ `
130
+ Elements2d(ECInstanceId, ECClassId) AS (
111
131
  SELECT ECInstanceId, ECClassId FROM Element2dNearestFunctionalElements
112
132
  UNION
113
133
  SELECT ECInstanceId, ECClassId FROM Elements2dWithoutFunctionalElement
114
- ),
115
- Element2dAncestorElements (ECInstanceId, ECClassId, Depth, ParentId) AS (
134
+ )
135
+ `,
136
+ `
137
+ Element2dAncestorElements(ECInstanceId, ECClassId, Depth, ParentId) AS (
116
138
  SELECT e.ECInstanceId, e.ECClassId, ${formAncestorLevelBinding(ancestorLevel, bindings)}, e.Parent.Id
117
139
  FROM BisCore.Element e
118
- JOIN Elements2d e2d ON e2d.ECInstanceId = e.ECInstanceId
140
+ JOIN Elements2d e2d ON e2d.ECInstanceId = e.ECInstanceId
119
141
  UNION ALL
120
142
  SELECT pe.ECInstanceId, pe.ECClassId, e2ae.Depth - 1, pe.Parent.Id
121
143
  FROM Element2dAncestorElements e2ae
122
- JOIN BisCore.Element pe ON pe.ECInstanceId = e2ae.ParentId
144
+ JOIN BisCore.Element pe ON pe.ECInstanceId = e2ae.ParentId
123
145
  WHERE ${recurseUntilRoot ? "" : "Depth > 0 AND"} ParentId IS NOT NULL
124
- ),
125
- Element3dAncestorElements (ECInstanceId, ECClassId, Depth, ParentId) AS (
146
+ )
147
+ `,
148
+ `
149
+ Element3dAncestorElements(ECInstanceId, ECClassId, Depth, ParentId) AS (
126
150
  SELECT ge.ECInstanceId, ge.ECClassId, ${formAncestorLevelBinding(ancestorLevel, bindings)}, ge.Parent.Id
127
151
  FROM BisCore.GeometricElement3d ge
128
- WHERE ${(0, ECSqlCore_1.formIdBindings)("ge.ECInstanceId", ids, bindings)}
152
+ WHERE ${(0, Utils_1.formIdBindings)("ge.ECInstanceId", ids, bindings)}
129
153
  UNION ALL
130
154
  SELECT pe.ECInstanceId, pe.ECClassId, e3ae.Depth - 1, pe.Parent.Id
131
155
  FROM Element3dAncestorElements e3ae
132
- JOIN BisCore.Element pe ON pe.ECInstanceId = e3ae.ParentId
156
+ JOIN BisCore.Element pe ON pe.ECInstanceId = e3ae.ParentId
133
157
  WHERE ${recurseUntilRoot ? "" : "Depth > 0 AND"} ParentId IS NOT NULL
134
- ),
135
- Element3dAncestorRelatedFunctionalElement (ECInstanceId, ClassName) AS (
158
+ )
159
+ `,
160
+ `
161
+ Element3dAncestorRelatedFunctionalElement(ECInstanceId, ClassName) AS (
136
162
  SELECT
137
163
  COALESCE(peff.TargetECInstanceId, e3ae.ECInstanceId),
138
164
  ec_classname(COALESCE(peff.TargetECClassId, e3ae.ECClassId), 's.c')
139
165
  FROM Element3dAncestorElements e3ae
140
- LEFT JOIN Functional.PhysicalElementFulfillsFunction peff ON peff.SourceECInstanceId = e3ae.ECInstanceId
166
+ LEFT JOIN Functional.PhysicalElementFulfillsFunction peff ON peff.SourceECInstanceId = e3ae.ECInstanceId
141
167
  WHERE ${recurseUntilRoot ? "" : "e3ae.Depth = 0 OR"} e3ae.ParentId IS NULL
142
168
  )
169
+ `,
170
+ ];
171
+ const ecsql = [
172
+ `
143
173
  SELECT DISTINCT ECInstanceId, ec_classname(ECClassId, 's.c') AS ClassName
144
- FROM Element2dAncestorElements
145
- WHERE ${recurseUntilRoot ? "" : "Depth = 0 OR"} ParentId IS NULL
146
- UNION ALL
147
- SELECT DISTINCT ECInstanceId, ClassName FROM Element3dAncestorRelatedFunctionalElement`;
148
- yield* executeQuery(queryExecutor, query, bindings);
174
+ FROM Element2dAncestorElements
175
+ WHERE ${recurseUntilRoot ? "" : "Depth = 0 OR"} ParentId IS NULL
176
+ `,
177
+ `
178
+ SELECT DISTINCT ECInstanceId, ClassName FROM Element3dAncestorRelatedFunctionalElement
179
+ `,
180
+ ].join(" UNION ALL ");
181
+ yield* executeQuery(queryExecutor, { ctes, ecsql, bindings });
149
182
  }
150
183
  function formAncestorLevelBinding(ancestorLevel, bindings) {
151
184
  bindings.push({ type: "int", value: ancestorLevel });
152
185
  return "?";
153
186
  }
154
- async function* executeQuery(queryExecutor, query, bindings) {
155
- const reader = queryExecutor.createQueryReader(query, bindings);
187
+ async function* executeQuery(queryExecutor, query) {
188
+ const reader = queryExecutor.createQueryReader(query);
156
189
  for await (const row of reader) {
157
190
  yield { className: row.ClassName, id: row.ECInstanceId };
158
191
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionScope.js","sourceRoot":"","sources":["../../../src/unified-selection/SelectionScope.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,sDAA2C;AAC3C,mDAAwF;AAqCxF;;;;;;GAMG;AACI,KAAK,SAAS,CAAC,CAAC,gBAAgB,CAAC,KAA4B;IAClE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAEnD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,KAAK,CAAC,CAAC,gBAAgB,CAAC,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAC7E,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C,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe;;;;;;;;gBAQvC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,mBAAmB;;;;cAI7C,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc;;6FAEyC,CAAC;IAE5F,KAAK,CAAC,CAAC,YAAY,CAAC,aAAa,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,wBAAwB,CAAC,aAAqB,EAAE,QAAwB;IAC/E,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;IACrD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,KAAK,SAAS,CAAC,CAAC,YAAY,CAAC,aAAkC,EAAE,KAAa,EAAE,QAAyB;IACvG,MAAM,MAAM,GAAG,aAAa,CAAC,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAEhE,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,MAAM,EAAE;QAC9B,MAAM,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,EAAE,EAAE,GAAG,CAAC,YAAY,EAAE,CAAC;KAC1D;AACH,CAAC","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 { Id64 } from \"@itwin/core-bentley\";\nimport { ECSqlBinding, formIdBindings, IECSqlQueryExecutor } from \"./queries/ECSqlCore\";\nimport { SelectableInstanceKey } from \"./Selectable\";\n\n/**\n * Available selection scopes.\n * @internal Not exported through barrel, but used in public API as an argument. May be supplemented with additional items in the union at any time.\n */\nexport type SelectionScope = \"element\" | \"model\" | \"category\" | \"functional\";\n\n/**\n * Props for computing element selection.\n * @internal Not exported through barrel, but used in public API as an argument. May be supplemented with optional attributes any time.\n */\nexport interface ElementSelectionScopeProps {\n /** Identifies this as either \"element\" or \"functional\" selection scope */\n id: \"element\" | \"functional\";\n /**\n * Specifies how far \"up\" we should walk to find the target element. When not specified or `0`,\n * the target element matches the request element. When set to `1`, the target element matches the direct parent element.\n * When set to `2`, the target element is parent of the parent element and so on. In all situations when this is `> 0`,\n * we're not walking further than the last existing element, for example when `ancestorLevel = 1` (direct parent\n * element is requested), but the request element doesn't have a parent, the request element is returned as the result.\n * A negative value would result in the top-most element to be returned.\n */\n ancestorLevel?: number;\n}\n\n/**\n * Props for `computeSelection`.\n * @internal Not exported through barrel, but used in public API as an argument. May be supplemented with optional attributes any time.\n */\nexport interface ComputeSelectionProps {\n queryExecutor: IECSqlQueryExecutor;\n elementIds: string[];\n scope: ElementSelectionScopeProps | { id: SelectionScope } | SelectionScope;\n}\n\n/**\n * Computes selection from given element ID's.\n * @param queryExecutor iModel query executor.\n * @param elementIds ID's of elements to compute selection for.\n * @param scope Selection scope to compute selection with.\n * @beta\n */\nexport async function* computeSelection(props: ComputeSelectionProps): AsyncIterableIterator<SelectableInstanceKey> {\n const { queryExecutor, elementIds, scope } = props;\n\n if (typeof scope === \"string\") {\n yield* computeSelection({ queryExecutor, elementIds, scope: { id: scope } });\n return;\n }\n\n const nonTransientKeys = elementIds.filter((key) => !Id64.isTransient(key));\n\n switch (scope.id) {\n case \"element\":\n yield* computeElementSelection(queryExecutor, nonTransientKeys, (scope as ElementSelectionScopeProps).ancestorLevel ?? 0);\n return;\n case \"category\":\n yield* computeCategorySelection(queryExecutor, nonTransientKeys);\n return;\n case \"model\":\n yield* computeModelSelection(queryExecutor, nonTransientKeys);\n return;\n case \"functional\":\n yield* computeFunctionalElementSelection(queryExecutor, nonTransientKeys, (scope as ElementSelectionScopeProps).ancestorLevel ?? 0);\n return;\n }\n}\n\nasync function* computeElementSelection(\n queryExecutor: IECSqlQueryExecutor,\n elementIds: string[],\n ancestorLevel: number,\n): AsyncIterableIterator<SelectableInstanceKey> {\n const bindings: ECSqlBinding[] = [];\n const recurseUntilRoot = ancestorLevel < 0;\n const query = `\n WITH RECURSIVE\n AncestorElements (ECInstanceId, ECClassId, Depth, ParentId) AS (\n SELECT ECInstanceId, ECClassId, ${formAncestorLevelBinding(ancestorLevel, bindings)}, Parent.Id\n FROM BisCore.Element\n WHERE ${formIdBindings(\"ECInstanceId\", elementIds, bindings)}\n UNION ALL\n SELECT pe.ECInstanceId, pe.ECClassId, a.Depth - 1, pe.Parent.Id FROM AncestorElements a\n JOIN BisCore.Element pe ON pe.ECInstanceId = a.ParentId\n WHERE ${recurseUntilRoot ? \"\" : \"Depth > 0 AND\"} ParentId IS NOT NULL\n )\n SELECT DISTINCT ECInstanceId, ec_classname(ECClassId, 's.c') AS ClassName FROM AncestorElements\n WHERE ${recurseUntilRoot ? \"\" : \"Depth = 0 OR\"} ParentId IS NULL`;\n\n yield* executeQuery(queryExecutor, query, bindings);\n}\n\nasync function* computeCategorySelection(queryExecutor: IECSqlQueryExecutor, ids: string[]): AsyncIterableIterator<SelectableInstanceKey> {\n const bindings: ECSqlBinding[] = [];\n const query = `\n SELECT DISTINCT c.ECInstanceId, ec_classname(c.ECClassId, 's.c') AS ClassName\n FROM BisCore.Category c JOIN BisCore.GeometricElement2d ge ON ge.Category.Id = c.ECInstanceId\n WHERE ${formIdBindings(\"ge.ECInstanceId\", ids, bindings)}\n UNION ALL\n SELECT DISTINCT c.ECInstanceId, ec_classname(c.ECClassId, 's.c') AS ClassName\n FROM BisCore.Category c JOIN BisCore.GeometricElement3d ge ON ge.Category.Id = c.ECInstanceId\n WHERE ${formIdBindings(\"ge.ECInstanceId\", ids, bindings)}`;\n\n yield* executeQuery(queryExecutor, query, bindings);\n}\n\nasync function* computeModelSelection(queryExecutor: IECSqlQueryExecutor, ids: string[]): AsyncIterableIterator<SelectableInstanceKey> {\n const bindings: ECSqlBinding[] = [];\n const query = `\n SELECT DISTINCT m.ECInstanceId, ec_classname(m.ECClassId, 's.c') AS ClassName\n FROM BisCore.Model m JOIN BisCore.Element e ON e.Model.Id = m.ECInstanceId\n WHERE ${formIdBindings(\"e.ECInstanceId\", ids, bindings)}`;\n\n yield* executeQuery(queryExecutor, query, bindings);\n}\n\nasync function* computeFunctionalElementSelection(\n queryExecutor: IECSqlQueryExecutor,\n ids: string[],\n ancestorLevel: number,\n): AsyncIterableIterator<SelectableInstanceKey> {\n const bindings: ECSqlBinding[] = [];\n const recurseUntilRoot = ancestorLevel < 0;\n const query = `\n WITH RECURSIVE\n Elements2dOrNearestFunctionalElements (OriginalECInstanceId, OriginalECClassId, ECInstanceId, ECClassId, ParentId) AS (\n SELECT ECInstanceId, ECClassId, ECInstanceId, ECClassId, Parent.Id\n FROM BisCore.Element\n WHERE ${formIdBindings(\"ECInstanceId\", ids, bindings)} AND ECClassId IS NOT (BisCore.GeometricElement3d)\n UNION ALL\n SELECT\n e2onfe.OriginalECInstanceId,\n e2onfe.OriginalECClassId,\n COALESCE(dgrfe.TargetECInstanceId, pe.ECInstanceId),\n COALESCE(dgrfe.TargetECClassId, pe.ECClassId),\n pe.Parent.Id\n FROM Elements2dOrNearestFunctionalElements e2onfe\n LEFT JOIN BisCore.Element pe ON pe.ECInstanceId = e2onfe.ParentId\n LEFT JOIN Functional.DrawingGraphicRepresentsFunctionalElement dgrfe ON dgrfe.SourceECInstanceId = e2onfe.ECInstanceId\n WHERE e2onfe.ECClassId IS NOT (Functional.FunctionalElement) AND (e2onfe.ParentId IS NOT NULL OR dgrfe.TargetECInstanceId IS NOT NULL)\n ),\n Element2dNearestFunctionalElements (OriginalECInstanceId, ECInstanceId, ECClassId) AS (\n SELECT OriginalECInstanceId, ECInstanceId, ECClassId\n FROM Elements2dOrNearestFunctionalElements\n WHERE ECClassId IS (Functional.FunctionalElement)\n ),\n Elements2dWithoutFunctionalElement (ECInstanceId, ECClassId) AS (\n SELECT e2wfe.OriginalECInstanceId, OriginalECClassId\n FROM Elements2dOrNearestFunctionalElements e2wfe\n LEFT JOIN Element2dNearestFunctionalElements e2nfe ON e2nfe.OriginalECInstanceId = e2wfe.OriginalECInstanceId\n WHERE e2wfe.ParentId IS NULL AND e2nfe.ECInstanceId IS NULL\n ),\n Elements2d (ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId FROM Element2dNearestFunctionalElements\n UNION\n SELECT ECInstanceId, ECClassId FROM Elements2dWithoutFunctionalElement\n ),\n Element2dAncestorElements (ECInstanceId, ECClassId, Depth, ParentId) AS (\n SELECT e.ECInstanceId, e.ECClassId, ${formAncestorLevelBinding(ancestorLevel, bindings)}, e.Parent.Id\n FROM BisCore.Element e\n JOIN Elements2d e2d ON e2d.ECInstanceId = e.ECInstanceId\n UNION ALL\n SELECT pe.ECInstanceId, pe.ECClassId, e2ae.Depth - 1, pe.Parent.Id\n FROM Element2dAncestorElements e2ae\n JOIN BisCore.Element pe ON pe.ECInstanceId = e2ae.ParentId\n WHERE ${recurseUntilRoot ? \"\" : \"Depth > 0 AND\"} ParentId IS NOT NULL\n ),\n Element3dAncestorElements (ECInstanceId, ECClassId, Depth, ParentId) AS (\n SELECT ge.ECInstanceId, ge.ECClassId, ${formAncestorLevelBinding(ancestorLevel, bindings)}, ge.Parent.Id\n FROM BisCore.GeometricElement3d ge\n WHERE ${formIdBindings(\"ge.ECInstanceId\", ids, bindings)}\n UNION ALL\n SELECT pe.ECInstanceId, pe.ECClassId, e3ae.Depth - 1, pe.Parent.Id\n FROM Element3dAncestorElements e3ae\n JOIN BisCore.Element pe ON pe.ECInstanceId = e3ae.ParentId\n WHERE ${recurseUntilRoot ? \"\" : \"Depth > 0 AND\"} ParentId IS NOT NULL\n ),\n Element3dAncestorRelatedFunctionalElement (ECInstanceId, ClassName) AS (\n SELECT\n COALESCE(peff.TargetECInstanceId, e3ae.ECInstanceId),\n ec_classname(COALESCE(peff.TargetECClassId, e3ae.ECClassId), 's.c')\n FROM Element3dAncestorElements e3ae\n LEFT JOIN Functional.PhysicalElementFulfillsFunction peff ON peff.SourceECInstanceId = e3ae.ECInstanceId\n WHERE ${recurseUntilRoot ? \"\" : \"e3ae.Depth = 0 OR\"} e3ae.ParentId IS NULL\n )\n SELECT DISTINCT ECInstanceId, ec_classname(ECClassId, 's.c') AS ClassName\n FROM Element2dAncestorElements\n WHERE ${recurseUntilRoot ? \"\" : \"Depth = 0 OR\"} ParentId IS NULL\n UNION ALL\n SELECT DISTINCT ECInstanceId, ClassName FROM Element3dAncestorRelatedFunctionalElement`;\n\n yield* executeQuery(queryExecutor, query, bindings);\n}\n\nfunction formAncestorLevelBinding(ancestorLevel: number, bindings: ECSqlBinding[]) {\n bindings.push({ type: \"int\", value: ancestorLevel });\n return \"?\";\n}\n\nasync function* executeQuery(queryExecutor: IECSqlQueryExecutor, query: string, bindings?: ECSqlBinding[]): AsyncIterableIterator<SelectableInstanceKey> {\n const reader = queryExecutor.createQueryReader(query, bindings);\n\n for await (const row of reader) {\n yield { className: row.ClassName, id: row.ECInstanceId };\n }\n}\n"]}
1
+ {"version":3,"file":"SelectionScope.js","sourceRoot":"","sources":["../../../src/unified-selection/SelectionScope.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,sDAA2C;AAG3C,mCAAyC;AAoCzC;;;;;;GAMG;AACI,KAAK,SAAS,CAAC,CAAC,gBAAgB,CAAC,KAA4B;IAClE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAEnD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,KAAK,CAAC,CAAC,gBAAgB,CAAC,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAC7E,OAAO;IACT,CAAC;IAED,MAAM,gBAAgB,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,mBAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;IAE5E,QAAQ,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,GAAG,EAAE,QAAQ,CAAC;;;;;gBAKhD,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe;;KAElD;QACD;;;;;;;gBAOY,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,mBAAmB;;KAEtD;KACF,CAAC;IACF,MAAM,KAAK,GAAG;QACZ;;;eAGW,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc;KAChD;QACD;;KAEC;KACF,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACtB,KAAK,CAAC,CAAC,YAAY,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,wBAAwB,CAAC,aAAqB,EAAE,QAAwB;IAC/E,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;IACrD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,KAAK,SAAS,CAAC,CAAC,YAAY,CAAC,aAAiC,EAAE,KAAoB;IAClF,MAAM,MAAM,GAAG,aAAa,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACtD,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QAC/B,MAAM,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,EAAE,EAAE,GAAG,CAAC,YAAY,EAAE,CAAC;IAC3D,CAAC;AACH,CAAC","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 { Id64 } from \"@itwin/core-bentley\";\nimport { ECSqlBinding, ECSqlQueryDef, ECSqlQueryExecutor } from \"@itwin/presentation-shared\";\nimport { SelectableInstanceKey } from \"./Selectable\";\nimport { formIdBindings } from \"./Utils\";\n\n/**\n * Available selection scopes.\n * @internal Not exported through barrel, but used in public API as an argument. May be supplemented with additional items in the union at any time.\n */\nexport type SelectionScope = \"element\" | \"model\" | \"category\" | \"functional\";\n\n/**\n * Props for computing element selection.\n * @internal Not exported through barrel, but used in public API as an argument. May be supplemented with optional attributes any time.\n */\nexport interface ElementSelectionScopeProps {\n /** Identifies this as either \"element\" or \"functional\" selection scope */\n id: \"element\" | \"functional\";\n /**\n * Specifies how far \"up\" we should walk to find the target element. When not specified or `0`,\n * the target element matches the request element. When set to `1`, the target element matches the direct parent element.\n * When set to `2`, the target element is parent of the parent element and so on. In all situations when this is `> 0`,\n * we're not walking further than the last existing element, for example when `ancestorLevel = 1` (direct parent\n * element is requested), but the request element doesn't have a parent, the request element is returned as the result.\n * A negative value would result in the top-most element to be returned.\n */\n ancestorLevel?: number;\n}\n\n/**\n * Props for `computeSelection`.\n * @internal Not exported through barrel, but used in public API as an argument. May be supplemented with optional attributes any time.\n */\nexport interface ComputeSelectionProps {\n queryExecutor: ECSqlQueryExecutor;\n elementIds: string[];\n scope: ElementSelectionScopeProps | { id: SelectionScope } | SelectionScope;\n}\n\n/**\n * Computes selection from given element ID's.\n * @param queryExecutor iModel query executor.\n * @param elementIds ID's of elements to compute selection for.\n * @param scope Selection scope to compute selection with.\n * @beta\n */\nexport async function* computeSelection(props: ComputeSelectionProps): AsyncIterableIterator<SelectableInstanceKey> {\n const { queryExecutor, elementIds, scope } = props;\n\n if (typeof scope === \"string\") {\n yield* computeSelection({ queryExecutor, elementIds, scope: { id: scope } });\n return;\n }\n\n const nonTransientKeys = elementIds.filter((key) => !Id64.isTransient(key));\n\n switch (scope.id) {\n case \"element\":\n yield* computeElementSelection(queryExecutor, nonTransientKeys, (scope as ElementSelectionScopeProps).ancestorLevel ?? 0);\n return;\n case \"category\":\n yield* computeCategorySelection(queryExecutor, nonTransientKeys);\n return;\n case \"model\":\n yield* computeModelSelection(queryExecutor, nonTransientKeys);\n return;\n case \"functional\":\n yield* computeFunctionalElementSelection(queryExecutor, nonTransientKeys, (scope as ElementSelectionScopeProps).ancestorLevel ?? 0);\n return;\n }\n}\n\nasync function* computeElementSelection(\n queryExecutor: ECSqlQueryExecutor,\n elementIds: string[],\n ancestorLevel: number,\n): AsyncIterableIterator<SelectableInstanceKey> {\n const bindings: ECSqlBinding[] = [];\n const recurseUntilRoot = ancestorLevel < 0;\n const ctes = [\n `\n AncestorElements(ECInstanceId, ECClassId, Depth, ParentId) AS (\n SELECT ECInstanceId, ECClassId, ${formAncestorLevelBinding(ancestorLevel, bindings)}, Parent.Id\n FROM BisCore.Element\n WHERE ${formIdBindings(\"ECInstanceId\", elementIds, bindings)}\n UNION ALL\n SELECT pe.ECInstanceId, pe.ECClassId, a.Depth - 1, pe.Parent.Id\n FROM AncestorElements a\n JOIN BisCore.Element pe ON pe.ECInstanceId = a.ParentId\n WHERE ${recurseUntilRoot ? \"\" : \"Depth > 0 AND\"} ParentId IS NOT NULL\n )\n `,\n ];\n const ecsql = `\n SELECT DISTINCT ECInstanceId, ec_classname(ECClassId, 's.c') AS ClassName\n FROM AncestorElements\n WHERE ${recurseUntilRoot ? \"\" : \"Depth = 0 OR\"} ParentId IS NULL\n `;\n yield* executeQuery(queryExecutor, { ctes, ecsql, bindings });\n}\n\nasync function* computeCategorySelection(queryExecutor: ECSqlQueryExecutor, ids: string[]): AsyncIterableIterator<SelectableInstanceKey> {\n const bindings: ECSqlBinding[] = [];\n const ecsql = [\n `\n SELECT DISTINCT c.ECInstanceId, ec_classname(c.ECClassId, 's.c') AS ClassName\n FROM BisCore.Category c\n JOIN BisCore.GeometricElement2d ge ON ge.Category.Id = c.ECInstanceId\n WHERE ${formIdBindings(\"ge.ECInstanceId\", ids, bindings)}\n `,\n `\n SELECT DISTINCT c.ECInstanceId, ec_classname(c.ECClassId, 's.c') AS ClassName\n FROM BisCore.Category c\n JOIN BisCore.GeometricElement3d ge ON ge.Category.Id = c.ECInstanceId\n WHERE ${formIdBindings(\"ge.ECInstanceId\", ids, bindings)}\n `,\n ].join(\" UNION ALL \");\n yield* executeQuery(queryExecutor, { ecsql, bindings });\n}\n\nasync function* computeModelSelection(queryExecutor: ECSqlQueryExecutor, ids: string[]): AsyncIterableIterator<SelectableInstanceKey> {\n const bindings: ECSqlBinding[] = [];\n const ecsql = `\n SELECT DISTINCT m.ECInstanceId, ec_classname(m.ECClassId, 's.c') AS ClassName\n FROM BisCore.Model m\n JOIN BisCore.Element e ON e.Model.Id = m.ECInstanceId\n WHERE ${formIdBindings(\"e.ECInstanceId\", ids, bindings)}\n `;\n yield* executeQuery(queryExecutor, { ecsql, bindings });\n}\n\nasync function* computeFunctionalElementSelection(\n queryExecutor: ECSqlQueryExecutor,\n ids: string[],\n ancestorLevel: number,\n): AsyncIterableIterator<SelectableInstanceKey> {\n const bindings: ECSqlBinding[] = [];\n const recurseUntilRoot = ancestorLevel < 0;\n const ctes = [\n `\n Elements2dOrNearestFunctionalElements(OriginalECInstanceId, OriginalECClassId, ECInstanceId, ECClassId, ParentId) AS (\n SELECT ECInstanceId, ECClassId, ECInstanceId, ECClassId, Parent.Id\n FROM BisCore.Element\n WHERE ${formIdBindings(\"ECInstanceId\", ids, bindings)} AND ECClassId IS NOT (BisCore.GeometricElement3d)\n UNION ALL\n SELECT\n e2onfe.OriginalECInstanceId,\n e2onfe.OriginalECClassId,\n COALESCE(dgrfe.TargetECInstanceId, pe.ECInstanceId),\n COALESCE(dgrfe.TargetECClassId, pe.ECClassId),\n pe.Parent.Id\n FROM Elements2dOrNearestFunctionalElements e2onfe\n LEFT JOIN BisCore.Element pe ON pe.ECInstanceId = e2onfe.ParentId\n LEFT JOIN Functional.DrawingGraphicRepresentsFunctionalElement dgrfe ON dgrfe.SourceECInstanceId = e2onfe.ECInstanceId\n WHERE e2onfe.ECClassId IS NOT (Functional.FunctionalElement) AND (e2onfe.ParentId IS NOT NULL OR dgrfe.TargetECInstanceId IS NOT NULL)\n )\n `,\n `\n Element2dNearestFunctionalElements(OriginalECInstanceId, ECInstanceId, ECClassId) AS (\n SELECT OriginalECInstanceId, ECInstanceId, ECClassId\n FROM Elements2dOrNearestFunctionalElements\n WHERE ECClassId IS (Functional.FunctionalElement)\n )\n `,\n `\n Elements2dWithoutFunctionalElement(ECInstanceId, ECClassId) AS (\n SELECT e2wfe.OriginalECInstanceId, OriginalECClassId\n FROM Elements2dOrNearestFunctionalElements e2wfe\n LEFT JOIN Element2dNearestFunctionalElements e2nfe ON e2nfe.OriginalECInstanceId = e2wfe.OriginalECInstanceId\n WHERE e2wfe.ParentId IS NULL AND e2nfe.ECInstanceId IS NULL\n )\n `,\n `\n Elements2d(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId FROM Element2dNearestFunctionalElements\n UNION\n SELECT ECInstanceId, ECClassId FROM Elements2dWithoutFunctionalElement\n )\n `,\n `\n Element2dAncestorElements(ECInstanceId, ECClassId, Depth, ParentId) AS (\n SELECT e.ECInstanceId, e.ECClassId, ${formAncestorLevelBinding(ancestorLevel, bindings)}, e.Parent.Id\n FROM BisCore.Element e\n JOIN Elements2d e2d ON e2d.ECInstanceId = e.ECInstanceId\n UNION ALL\n SELECT pe.ECInstanceId, pe.ECClassId, e2ae.Depth - 1, pe.Parent.Id\n FROM Element2dAncestorElements e2ae\n JOIN BisCore.Element pe ON pe.ECInstanceId = e2ae.ParentId\n WHERE ${recurseUntilRoot ? \"\" : \"Depth > 0 AND\"} ParentId IS NOT NULL\n )\n `,\n `\n Element3dAncestorElements(ECInstanceId, ECClassId, Depth, ParentId) AS (\n SELECT ge.ECInstanceId, ge.ECClassId, ${formAncestorLevelBinding(ancestorLevel, bindings)}, ge.Parent.Id\n FROM BisCore.GeometricElement3d ge\n WHERE ${formIdBindings(\"ge.ECInstanceId\", ids, bindings)}\n UNION ALL\n SELECT pe.ECInstanceId, pe.ECClassId, e3ae.Depth - 1, pe.Parent.Id\n FROM Element3dAncestorElements e3ae\n JOIN BisCore.Element pe ON pe.ECInstanceId = e3ae.ParentId\n WHERE ${recurseUntilRoot ? \"\" : \"Depth > 0 AND\"} ParentId IS NOT NULL\n )\n `,\n `\n Element3dAncestorRelatedFunctionalElement(ECInstanceId, ClassName) AS (\n SELECT\n COALESCE(peff.TargetECInstanceId, e3ae.ECInstanceId),\n ec_classname(COALESCE(peff.TargetECClassId, e3ae.ECClassId), 's.c')\n FROM Element3dAncestorElements e3ae\n LEFT JOIN Functional.PhysicalElementFulfillsFunction peff ON peff.SourceECInstanceId = e3ae.ECInstanceId\n WHERE ${recurseUntilRoot ? \"\" : \"e3ae.Depth = 0 OR\"} e3ae.ParentId IS NULL\n )\n `,\n ];\n const ecsql = [\n `\n SELECT DISTINCT ECInstanceId, ec_classname(ECClassId, 's.c') AS ClassName\n FROM Element2dAncestorElements\n WHERE ${recurseUntilRoot ? \"\" : \"Depth = 0 OR\"} ParentId IS NULL\n `,\n `\n SELECT DISTINCT ECInstanceId, ClassName FROM Element3dAncestorRelatedFunctionalElement\n `,\n ].join(\" UNION ALL \");\n yield* executeQuery(queryExecutor, { ctes, ecsql, bindings });\n}\n\nfunction formAncestorLevelBinding(ancestorLevel: number, bindings: ECSqlBinding[]) {\n bindings.push({ type: \"int\", value: ancestorLevel });\n return \"?\";\n}\n\nasync function* executeQuery(queryExecutor: ECSqlQueryExecutor, query: ECSqlQueryDef): AsyncIterableIterator<SelectableInstanceKey> {\n const reader = queryExecutor.createQueryReader(query);\n for await (const row of reader) {\n yield { className: row.ClassName, id: row.ECInstanceId };\n }\n}\n"]}
@@ -1,8 +1,15 @@
1
- /** @packageDocumentation
2
- * @module UnifiedSelection
3
- */
4
1
  import { Selectable, Selectables } from "./Selectable";
5
2
  import { SelectionChangeEvent } from "./SelectionChangeEvent";
3
+ type IModelKeyProp = {
4
+ /** Key of the iModel to get selection levels for. */
5
+ imodelKey: string;
6
+ } | {
7
+ /**
8
+ * Key of the iModel to get selection levels for.
9
+ * @deprecated in 0.2. Use `imodelKey` instead.
10
+ */
11
+ iModelKey: string;
12
+ };
6
13
  /**
7
14
  * Defines return value of `createStorage`.
8
15
  *
@@ -13,21 +20,14 @@ export interface SelectionStorage {
13
20
  /** An event that is raised when selection changes. */
14
21
  selectionChangeEvent: SelectionChangeEvent;
15
22
  /** Get the selection levels currently stored for the specified iModel. */
16
- getSelectionLevels(props: {
17
- /** Key of the iModel to get selection levels for. */
18
- iModelKey: string;
19
- }): number[];
23
+ getSelectionLevels(props: IModelKeyProp): number[];
20
24
  /** Get the selection stored in the storage. */
21
- getSelection(props: {
22
- /** Key of the iModel to get selection for. */
23
- iModelKey: string;
25
+ getSelection(props: IModelKeyProp & {
24
26
  /** Level of the selection. Defaults to `0`. */
25
27
  level?: number;
26
28
  }): Selectables;
27
29
  /** Add keys to the selection. */
28
- addToSelection(props: {
29
- /** Key of the iModel to change selection for. */
30
- iModelKey: string;
30
+ addToSelection(props: IModelKeyProp & {
31
31
  /** Name of the selection source. Generally, this identifies the component that makes the selection change. */
32
32
  source: string;
33
33
  /** The selectables to add to selection. */
@@ -36,9 +36,7 @@ export interface SelectionStorage {
36
36
  level?: number;
37
37
  }): void;
38
38
  /** Remove keys from current selection. */
39
- removeFromSelection(props: {
40
- /** Key of the iModel to change selection for. */
41
- iModelKey: string;
39
+ removeFromSelection(props: IModelKeyProp & {
42
40
  /** Name of the selection source. Generally, this identifies the component that makes the selection change. */
43
41
  source: string;
44
42
  /** The selectables to remove from selection. */
@@ -47,9 +45,7 @@ export interface SelectionStorage {
47
45
  level?: number;
48
46
  }): void;
49
47
  /** Replace current selection. */
50
- replaceSelection(props: {
51
- /** Key of the iModel to change selection for. */
52
- iModelKey: string;
48
+ replaceSelection(props: IModelKeyProp & {
53
49
  /** Name of the selection source. Generally, this identifies the component that makes the selection change. */
54
50
  source: string;
55
51
  /** The selectables to add to selection. */
@@ -58,19 +54,14 @@ export interface SelectionStorage {
58
54
  level?: number;
59
55
  }): void;
60
56
  /** Clear current selection. */
61
- clearSelection(props: {
62
- /** Key of the iModel to change selection for. */
63
- iModelKey: string;
57
+ clearSelection(props: IModelKeyProp & {
64
58
  /** Name of the selection source. Generally, this identifies the component that makes the selection change. */
65
59
  source: string;
66
60
  /** Level of the selection. Defaults to `0`. */
67
61
  level?: number;
68
62
  }): void;
69
63
  /** Clear storage for an iModel. This function should be called when iModel is closed. */
70
- clearStorage(props: {
71
- /** Key of the iModel to change selection for. */
72
- iModelKey: string;
73
- }): void;
64
+ clearStorage(props: IModelKeyProp): void;
74
65
  }
75
66
  /**
76
67
  * Creates a selection storage which stores and allows managing application-level selection.
@@ -78,8 +69,8 @@ export interface SelectionStorage {
78
69
  * **Note:** `clearSelection` should be called upon iModel close to free-up memory:
79
70
  * ```ts
80
71
  * import { IModelConnection } from "@itwin/core-frontend";
81
- * IModelConnection.onClose.addListener((iModel) => {
82
- * storage.clearStorage(iModel.key);
72
+ * IModelConnection.onClose.addListener((imodel) => {
73
+ * storage.clearStorage(imodel.key);
83
74
  * });
84
75
  * ```
85
76
  *
@@ -88,4 +79,5 @@ export interface SelectionStorage {
88
79
  export declare function createStorage(): SelectionStorage;
89
80
  /** @internal */
90
81
  export declare const IMODEL_CLOSE_SELECTION_CLEAR_SOURCE = "Unified selection storage: clear";
82
+ export {};
91
83
  //# sourceMappingURL=SelectionStorage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionStorage.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/SelectionStorage.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAyF,MAAM,wBAAwB,CAAC;AAErJ;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sDAAsD;IACtD,oBAAoB,EAAE,oBAAoB,CAAC;IAE3C,0EAA0E;IAC1E,kBAAkB,CAAC,KAAK,EAAE;QACxB,qDAAqD;QACrD,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,MAAM,EAAE,CAAC;IAE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,EAAE,MAAM,CAAC;KACnB,GAAG,IAAI,CAAC;CACV;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,IAAI,gBAAgB,CAEhD;AAED,gBAAgB;AAChB,eAAO,MAAM,mCAAmC,qCAAqC,CAAC"}
1
+ {"version":3,"file":"SelectionStorage.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/SelectionStorage.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAyF,MAAM,wBAAwB,CAAC;AAErJ,KAAK,aAAa,GACd;IACE,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;CACnB,GACD;IACE;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEN;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sDAAsD;IACtD,oBAAoB,EAAE,oBAAoB,CAAC;IAE3C,0EAA0E;IAC1E,kBAAkB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,EAAE,CAAC;IAEnD,+CAA+C;IAC/C,YAAY,CACV,KAAK,EAAE,aAAa,GAAG;QACrB,+CAA+C;QAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,WAAW,CAAC;IAEf,iCAAiC;IACjC,cAAc,CACZ,KAAK,EAAE,aAAa,GAAG;QACrB,8GAA8G;QAC9G,MAAM,EAAE,MAAM,CAAC;QACf,2CAA2C;QAC3C,WAAW,EAAE,UAAU,EAAE,CAAC;QAC1B,+CAA+C;QAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,IAAI,CAAC;IAER,0CAA0C;IAC1C,mBAAmB,CACjB,KAAK,EAAE,aAAa,GAAG;QACrB,8GAA8G;QAC9G,MAAM,EAAE,MAAM,CAAC;QACf,gDAAgD;QAChD,WAAW,EAAE,UAAU,EAAE,CAAC;QAC1B,+CAA+C;QAC/C,KAAK,CAAC,EAAE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