drugflow-molstar 0.2.1 → 0.2.2

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 (113) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +15 -15
  3. package/build/{drugflow-molstar-component-0.2.1.js → drugflow-molstar-component-0.2.2.js} +4 -4
  4. package/build/drugflow-molstar-light.css +1 -1
  5. package/build/{drugflow-molstar-plugin-0.2.1.js → drugflow-molstar-plugin-0.2.2.js} +2 -2
  6. package/lib/alphafold-transparency.d.ts +6 -6
  7. package/lib/alphafold-transparency.js +153 -153
  8. package/lib/app/molstar/lib/apps/docking-viewer/index.html +37 -0
  9. package/lib/app/molstar/lib/apps/viewer/embedded.html +44 -0
  10. package/lib/app/molstar/lib/apps/viewer/favicon.ico +0 -0
  11. package/lib/app/molstar/lib/apps/viewer/index.html +110 -0
  12. package/lib/app/molstar/lib/examples/alpha-orbitals/index.html +73 -0
  13. package/lib/app/molstar/lib/examples/basic-wrapper/index.html +138 -0
  14. package/lib/app/molstar/lib/examples/lighting/index.html +89 -0
  15. package/lib/app/molstar/lib/examples/proteopedia-wrapper/index.html +237 -0
  16. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/base.scss +33 -0
  17. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/controls-base.scss +334 -0
  18. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/controls.scss +419 -0
  19. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/help.scss +27 -0
  20. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/line-graph.scss +68 -0
  21. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/log.scss +100 -0
  22. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/misc.scss +644 -0
  23. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/sequence.scss +126 -0
  24. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/slider.scss +166 -0
  25. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/tasks.scss +99 -0
  26. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/toast.scss +84 -0
  27. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/transformer.scss +164 -0
  28. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/viewport.scss +128 -0
  29. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/layout/common.scss +72 -0
  30. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/layout/controls-landscape.scss +90 -0
  31. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/layout/controls-outside.scss +99 -0
  32. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/layout/controls-portrait.scss +109 -0
  33. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/layout.scss +41 -0
  34. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/logo.scss +13 -0
  35. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/normalize.scss +210 -0
  36. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/ui.scss +41 -0
  37. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/variables.scss +86 -0
  38. package/lib/app/molstar/lib/mol-plugin-ui/skin/blue.scss +2 -0
  39. package/lib/app/molstar/lib/mol-plugin-ui/skin/colors/blue.scss +24 -0
  40. package/lib/app/molstar/lib/mol-plugin-ui/skin/colors/dark.scss +24 -0
  41. package/lib/app/molstar/lib/mol-plugin-ui/skin/colors/light.scss +30 -0
  42. package/lib/app/molstar/lib/mol-plugin-ui/skin/dark.scss +2 -0
  43. package/lib/app/molstar/lib/mol-plugin-ui/skin/light.scss +2 -0
  44. package/lib/custom-events.d.ts +4 -4
  45. package/lib/custom-events.js +56 -56
  46. package/lib/domain-annotations/behavior.d.ts +5 -5
  47. package/lib/domain-annotations/behavior.js +49 -49
  48. package/lib/domain-annotations/color.d.ts +10 -10
  49. package/lib/domain-annotations/color.js +78 -78
  50. package/lib/domain-annotations/prop.d.ts +35 -35
  51. package/lib/domain-annotations/prop.js +160 -160
  52. package/lib/drugflow-molstar-component-build-0.1.2.js +4268 -0
  53. package/lib/drugflow-molstar-component-build-0.1.2.js.LICENSE.txt +24 -0
  54. package/lib/drugflow-molstar-component-build-0.1.2.js.map +1 -0
  55. package/lib/drugflow-molstar-component-build-0.1.3.js +2 -0
  56. package/lib/drugflow-molstar-component-build-0.1.3.js.LICENSE.txt +24 -0
  57. package/lib/drugflow-molstar-component-build-0.1.4.js +2 -0
  58. package/lib/drugflow-molstar-component-build-0.1.4.js.LICENSE.txt +24 -0
  59. package/lib/drugflow-molstar-component-build-0.1.6.js +2 -0
  60. package/lib/drugflow-molstar-component-build-0.1.6.js.LICENSE.txt +24 -0
  61. package/lib/drugflow-molstar-component-build-0.2.2.js +2 -0
  62. package/lib/drugflow-molstar-component-build-0.2.2.js.LICENSE.txt +24 -0
  63. package/lib/helpers.d.ts +82 -81
  64. package/lib/helpers.js +278 -278
  65. package/lib/index.d.ts +1 -1
  66. package/lib/index.js +1274 -1239
  67. package/lib/labels.d.ts +2 -2
  68. package/lib/labels.js +42 -42
  69. package/lib/loci-details.d.ts +27 -27
  70. package/lib/loci-details.js +128 -128
  71. package/lib/pdbe-molstar-component-build-3.1.2.js +2 -0
  72. package/lib/pdbe-molstar-component-build-3.1.2.js.LICENSE.txt +24 -0
  73. package/lib/sifts-mapping.d.ts +16 -16
  74. package/lib/sifts-mapping.js +83 -83
  75. package/lib/sifts-mappings-behaviour.d.ts +5 -5
  76. package/lib/sifts-mappings-behaviour.js +64 -64
  77. package/lib/spec.d.ts +76 -76
  78. package/lib/spec.js +105 -105
  79. package/lib/subscribe-events.d.ts +1 -1
  80. package/lib/subscribe-events.js +194 -194
  81. package/lib/superposition-export.d.ts +4 -4
  82. package/lib/superposition-export.js +152 -152
  83. package/lib/superposition-focus-representation.d.ts +16 -16
  84. package/lib/superposition-focus-representation.js +153 -153
  85. package/lib/superposition-sifts-mapping.d.ts +22 -22
  86. package/lib/superposition-sifts-mapping.js +159 -159
  87. package/lib/superposition.d.ts +18 -18
  88. package/lib/superposition.js +794 -794
  89. package/lib/ui/alphafold-superposition.d.ts +56 -56
  90. package/lib/ui/alphafold-superposition.js +178 -178
  91. package/lib/ui/alphafold-tranparency.d.ts +22 -22
  92. package/lib/ui/alphafold-tranparency.js +65 -65
  93. package/lib/ui/annotation-controls.d.ts +24 -24
  94. package/lib/ui/annotation-controls.js +166 -166
  95. package/lib/ui/export-superposition.d.ts +6 -6
  96. package/lib/ui/export-superposition.js +71 -71
  97. package/lib/ui/pdbe-left-panel.d.ts +18 -18
  98. package/lib/ui/pdbe-left-panel.js +167 -167
  99. package/lib/ui/pdbe-screenshot-controls.d.ts +20 -20
  100. package/lib/ui/pdbe-screenshot-controls.js +101 -101
  101. package/lib/ui/pdbe-structure-controls.d.ts +17 -17
  102. package/lib/ui/pdbe-structure-controls.js +70 -70
  103. package/lib/ui/pdbe-viewport-controls.d.ts +6 -6
  104. package/lib/ui/pdbe-viewport-controls.js +56 -56
  105. package/lib/ui/segment-tree.d.ts +18 -18
  106. package/lib/ui/segment-tree.js +804 -804
  107. package/lib/ui/superposition-components.d.ts +10 -10
  108. package/lib/ui/superposition-components.js +435 -435
  109. package/lib/ui/superposition-viewport.d.ts +5 -5
  110. package/lib/ui/superposition-viewport.js +23 -23
  111. package/package.json +79 -79
  112. /package/build/{drugflow-molstar-0.2.1.css → drugflow-molstar-0.2.2.css} +0 -0
  113. /package/build/{drugflow-molstar-plugin-0.2.1.js.LICENSE.txt → drugflow-molstar-plugin-0.2.2.js.LICENSE.txt} +0 -0
@@ -1,435 +1,435 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SuperpositionComponentControls = void 0;
4
- var tslib_1 = require("tslib");
5
- var jsx_runtime_1 = require("react/jsx-runtime");
6
- var commands_1 = require("Molstar/mol-plugin/commands");
7
- var mol_state_1 = require("Molstar/mol-state");
8
- var param_definition_1 = require("Molstar/mol-util/param-definition");
9
- var base_1 = require("Molstar/mol-plugin-ui/base");
10
- var common_1 = require("Molstar/mol-plugin-ui/controls/common");
11
- var icons_1 = require("Molstar/mol-plugin-ui/controls/icons");
12
- var parameters_1 = require("Molstar/mol-plugin-ui/controls/parameters");
13
- var operators_1 = require("rxjs/operators");
14
- var rxjs_1 = require("rxjs");
15
- var SuperpositionComponentControls = /** @class */ (function (_super) {
16
- tslib_1.__extends(SuperpositionComponentControls, _super);
17
- function SuperpositionComponentControls() {
18
- return _super !== null && _super.apply(this, arguments) || this;
19
- }
20
- SuperpositionComponentControls.prototype.defaultState = function () {
21
- return {
22
- header: 'Components',
23
- isCollapsed: false,
24
- isDisabled: false,
25
- brand: { accent: 'blue', svg: icons_1.CubeOutlineSvg }
26
- };
27
- };
28
- SuperpositionComponentControls.prototype.renderControls = function () {
29
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(ComponentListControls, {}) });
30
- };
31
- return SuperpositionComponentControls;
32
- }(base_1.CollapsableControls));
33
- exports.SuperpositionComponentControls = SuperpositionComponentControls;
34
- ;
35
- var ComponentListControls = /** @class */ (function (_super) {
36
- tslib_1.__extends(ComponentListControls, _super);
37
- function ComponentListControls() {
38
- var _this = _super !== null && _super.apply(this, arguments) || this;
39
- _this.state = {
40
- segmentWatch: false,
41
- ligSearchText: '',
42
- carbSearchText: '',
43
- componentGroups: { nonLigGroups: [], ligGroups: [], carbGroups: [], alphafold: [] },
44
- ligGroups: [],
45
- isLigCollapsed: false,
46
- carbGroups: [],
47
- isCarbCollapsed: false,
48
- isBusy: false
49
- };
50
- _this.ligInputStream = new rxjs_1.Subject();
51
- _this.handleLigInputStream = function (inputStr) {
52
- _this.setState({ ligSearchText: inputStr });
53
- var filteredRes = _this.state.componentGroups.ligGroups.filter(function (g) {
54
- var gKeys = g[0].key.split(',');
55
- var cId1Arr = gKeys[0].split('-');
56
- return cId1Arr[2].toLowerCase().indexOf(inputStr.toLowerCase()) >= 0;
57
- });
58
- _this.setState({ ligGroups: filteredRes });
59
- };
60
- _this.carbInputStream = new rxjs_1.Subject();
61
- _this.handleCarbInputStream = function (inputStr) {
62
- _this.setState({ carbSearchText: inputStr });
63
- var filteredRes = _this.state.componentGroups.carbGroups.filter(function (g) {
64
- var gKeys = g[0].key.split(',');
65
- var cId1Arr = gKeys[0].split('-');
66
- cId1Arr.splice(0, 2);
67
- cId1Arr.pop();
68
- return cId1Arr.join('-').toLowerCase().indexOf(inputStr.toLowerCase()) >= 0;
69
- });
70
- _this.setState({ carbGroups: filteredRes });
71
- };
72
- _this.toggleVisible = function (e, action, type) {
73
- e.preventDefault();
74
- e.currentTarget.blur();
75
- var customState = _this.plugin.customState;
76
- customState.events.isBusy.next(true);
77
- var visualEntites = (type === 'ligands') ? _this.state.ligGroups : _this.state.carbGroups;
78
- setTimeout(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
79
- var visualEntites_1, visualEntites_1_1, visualEntity, e_1_1;
80
- var e_1, _a;
81
- return tslib_1.__generator(this, function (_b) {
82
- switch (_b.label) {
83
- case 0:
84
- _b.trys.push([0, 5, 6, 11]);
85
- visualEntites_1 = tslib_1.__asyncValues(visualEntites);
86
- _b.label = 1;
87
- case 1: return [4 /*yield*/, visualEntites_1.next()];
88
- case 2:
89
- if (!(visualEntites_1_1 = _b.sent(), !visualEntites_1_1.done)) return [3 /*break*/, 4];
90
- visualEntity = visualEntites_1_1.value;
91
- this.plugin.managers.structure.hierarchy.toggleVisibility(visualEntity, action);
92
- _b.label = 3;
93
- case 3: return [3 /*break*/, 1];
94
- case 4: return [3 /*break*/, 11];
95
- case 5:
96
- e_1_1 = _b.sent();
97
- e_1 = { error: e_1_1 };
98
- return [3 /*break*/, 11];
99
- case 6:
100
- _b.trys.push([6, , 9, 10]);
101
- if (!(visualEntites_1_1 && !visualEntites_1_1.done && (_a = visualEntites_1.return))) return [3 /*break*/, 8];
102
- return [4 /*yield*/, _a.call(visualEntites_1)];
103
- case 7:
104
- _b.sent();
105
- _b.label = 8;
106
- case 8: return [3 /*break*/, 10];
107
- case 9:
108
- if (e_1) throw e_1.error;
109
- return [7 /*endfinally*/];
110
- case 10: return [7 /*endfinally*/];
111
- case 11:
112
- ;
113
- customState.events.isBusy.next(false);
114
- return [2 /*return*/];
115
- }
116
- });
117
- }); });
118
- };
119
- _this.showHideAllControls = function (type) {
120
- return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(common_1.Button, tslib_1.__assign({ icon: icons_1.CheckSvg, flex: true, onClick: function (e) { return _this.toggleVisible(e, 'show', type); }, style: { flex: '0 0 50px', textAlign: 'center', fontSize: '80%', color: '#9cacc3', padding: 0 }, title: "Show all ".concat(type), disabled: false }, { children: "All" })), (0, jsx_runtime_1.jsx)(common_1.Button, tslib_1.__assign({ icon: icons_1.CloseSvg, flex: true, onClick: function (e) { return _this.toggleVisible(e, 'hide', type); }, style: { flex: '0 0 50px', textAlign: 'center', fontSize: '80%', color: '#9cacc3', padding: 0 }, title: "Hide all ".concat(type), disabled: false }, { children: "None" }))] });
121
- };
122
- _this.clearLigSearch = function (e) {
123
- e.preventDefault();
124
- _this.setState({ ligSearchText: '' });
125
- _this.ligInputStream.next('');
126
- e.currentTarget.blur();
127
- };
128
- _this.clearCarbSearch = function (e) {
129
- e.preventDefault();
130
- _this.setState({ carbSearchText: '' });
131
- _this.carbInputStream.next('');
132
- e.currentTarget.blur();
133
- };
134
- _this.collapseSection = function (e, type) {
135
- e.preventDefault();
136
- e.currentTarget.blur();
137
- if (type === 'ligands') {
138
- _this.setState({ isLigCollapsed: !_this.state.isLigCollapsed });
139
- }
140
- else {
141
- _this.setState({ isCarbCollapsed: !_this.state.isCarbCollapsed });
142
- }
143
- };
144
- _this.sectionHeader = function (type) {
145
- var showHideAllControls = (type === 'ligands') ? _this.showHideAllControls('ligands') : _this.showHideAllControls('carbohydrates');
146
- var title = (type === 'ligands') ? 'Ligand' : 'Carbohydrates';
147
- var visibleVisuals = (type === 'ligands') ? _this.state.ligGroups.length : _this.state.carbGroups.length;
148
- var totalVisuals = (type === 'ligands') ? _this.state.componentGroups.ligGroups.length : _this.state.componentGroups.carbGroups.length;
149
- return (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-flex-row', style: { marginTop: '6px' } }, { children: [(0, jsx_runtime_1.jsxs)("button", tslib_1.__assign({ className: 'msp-form-control msp-control-button-label msp-transform-header-brand-gray', style: { textAlign: 'left' }, onClick: function (e) { return _this.collapseSection(e, type); } }, { children: [(0, jsx_runtime_1.jsx)("span", { children: (0, jsx_runtime_1.jsx)("strong", { children: title }) }), (0, jsx_runtime_1.jsxs)("small", tslib_1.__assign({ style: { color: '#7d91b0' } }, { children: [" ( ", visibleVisuals, visibleVisuals < totalVisuals ? " / ".concat(totalVisuals) : '', " )"] }))] })), visibleVisuals > 1 && showHideAllControls] }));
150
- };
151
- return _this;
152
- }
153
- ComponentListControls.prototype.componentDidMount = function () {
154
- var _this = this;
155
- this.subscribe(this.plugin.managers.structure.hierarchy.behaviors.selection, function () {
156
- _this.categoriseGroups();
157
- _this.forceUpdate();
158
- });
159
- this.subscribe(this.plugin.behaviors.state.isBusy, function (v) {
160
- _this.setState({ isBusy: v });
161
- });
162
- };
163
- ComponentListControls.prototype.componentDidUpdate = function () {
164
- var _this = this;
165
- var customState = this.plugin.customState;
166
- if (customState.events && !this.state.segmentWatch) {
167
- this.setState({ segmentWatch: true });
168
- this.subscribe(customState.events.segmentUpdate, function () {
169
- _this.categoriseGroups();
170
- _this.forceUpdate();
171
- });
172
- }
173
- this.subscribe(this.ligInputStream.pipe((0, operators_1.debounceTime)(1000 / 24)), function (e) { return _this.handleLigInputStream(e); });
174
- this.subscribe(this.carbInputStream.pipe((0, operators_1.debounceTime)(1000 / 24)), function (e) { return _this.handleCarbInputStream(e); });
175
- };
176
- ComponentListControls.prototype.categoriseGroups = function () {
177
- var componentGroupsVal = { nonLigGroups: [], ligGroups: [], carbGroups: [], alphafold: [] };
178
- var componentGroups = this.plugin.managers.structure.hierarchy.currentComponentGroups;
179
- var customState = this.plugin.customState;
180
- componentGroups.forEach(function (g) {
181
- var isLigandView = false;
182
- if (customState.initParams && customState.initParams.superpositionParams && customState.initParams.superpositionParams.ligandView) {
183
- isLigandView = true;
184
- }
185
- if (isLigandView) {
186
- var gKeys = g[0].key.split(',');
187
- var cId1Arr = gKeys[0].split('-');
188
- if (gKeys.indexOf('superposition-focus-surr-sel') === -1) {
189
- if (cId1Arr[cId1Arr.length - 1] !== (customState.superpositionState.activeSegment - 1) + '')
190
- return;
191
- if (gKeys.indexOf('superposition-ligand-sel') >= 0) {
192
- componentGroupsVal.ligGroups.push(g);
193
- }
194
- else if (gKeys.indexOf('superposition-carb-sel') >= 0) {
195
- componentGroupsVal.carbGroups.push(g);
196
- }
197
- else if (gKeys.indexOf('alphafold-chain') >= 0) {
198
- componentGroupsVal.alphafold.push(g);
199
- }
200
- else {
201
- componentGroupsVal.nonLigGroups.push(g);
202
- }
203
- }
204
- else {
205
- componentGroupsVal.nonLigGroups.push(g);
206
- }
207
- }
208
- else {
209
- var gKeys = g[0].key.split(',');
210
- if (gKeys.indexOf('superposition-focus-surr-sel') >= 0 || gKeys.indexOf("Chain-".concat(customState.superpositionState.activeSegment - 1)) >= 0) {
211
- componentGroupsVal.nonLigGroups.push(g);
212
- }
213
- else if (gKeys.indexOf('alphafold-chain') >= 0) {
214
- componentGroupsVal.alphafold.push(g);
215
- }
216
- }
217
- });
218
- this.setState({ componentGroups: componentGroupsVal, ligGroups: componentGroupsVal.ligGroups, carbGroups: componentGroupsVal.carbGroups, ligSearchText: '', carbSearchText: '' });
219
- };
220
- ComponentListControls.prototype.render = function () {
221
- var _this = this;
222
- var ligSearchControls = (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-mapped-parameter-group', style: { fontSize: '90%' } }, { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-control-row msp-transform-header-brand-gray', style: { height: '33px' } }, { children: [(0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ className: 'msp-control-row-label' }, { children: "Search Ligand" })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-control-row-ctrl' }, { children: (0, jsx_runtime_1.jsx)("input", { type: 'text', placeholder: 'Enter HET code', disabled: this.state.isBusy, onChange: function (e) { return _this.ligInputStream.next(e.target.value); }, value: this.state.ligSearchText, maxLength: 3 }) }))] })), (0, jsx_runtime_1.jsx)(common_1.IconButton, { svg: icons_1.CloseSvg, flex: true, onClick: this.clearLigSearch, style: { flex: '0 0 24px', padding: 0 }, disabled: this.state.ligSearchText === '' || this.state.isBusy, toggleState: this.state.ligSearchText !== '', title: 'Clear search input' })] }));
223
- var carbSearchControls = (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-mapped-parameter-group', style: { fontSize: '90%' } }, { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-control-row msp-transform-header-brand-gray', style: { height: '33px' } }, { children: [(0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ className: 'msp-control-row-label' }, { children: "Search Carbohydrate" })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-control-row-ctrl' }, { children: (0, jsx_runtime_1.jsx)("input", { type: 'text', placeholder: 'Enter HET code', disabled: this.state.isBusy, onChange: function (e) { return _this.carbInputStream.next(e.target.value); }, value: this.state.carbSearchText, maxLength: 3 }) }))] })), (0, jsx_runtime_1.jsx)(common_1.IconButton, { svg: icons_1.CloseSvg, flex: true, onClick: this.clearCarbSearch, style: { flex: '0 0 24px', padding: 0 }, disabled: this.state.carbSearchText === '' || this.state.isBusy, toggleState: this.state.carbSearchText !== '', title: 'Clear search input' })] }));
224
- var ligSectionHeader = this.sectionHeader('ligands');
225
- var carbSectionHeader = this.sectionHeader('carbohydrates');
226
- return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(this.state.componentGroups.nonLigGroups.length > 0) && (0, jsx_runtime_1.jsx)("div", { children: this.state.componentGroups.nonLigGroups.map(function (g) { return (0, jsx_runtime_1.jsx)(StructureComponentGroup, { group: g, boldHeader: true }, g[0].cell.transform.ref); }) }), (this.state.componentGroups.alphafold.length > 0) && (0, jsx_runtime_1.jsx)("div", { children: this.state.componentGroups.alphafold.map(function (g) { return (0, jsx_runtime_1.jsx)(StructureComponentGroup, { group: g, boldHeader: true, type: 'alphafold' }, g[0].cell.transform.ref); }) }), (this.state.componentGroups.ligGroups.length > 0) && ligSectionHeader, (!this.state.isLigCollapsed && this.state.componentGroups.ligGroups.length > 5) && ligSearchControls, (this.state.componentGroups.ligGroups.length > 0) && (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-control-offset', style: { maxHeight: '800px', overflowY: 'auto' } }, { children: !this.state.isLigCollapsed && this.state.ligGroups.map(function (g) { return (0, jsx_runtime_1.jsx)(StructureComponentGroup, { group: g, boldHeader: false }, g[0].cell.transform.ref); }) })), (this.state.componentGroups.carbGroups.length > 0) && carbSectionHeader, (!this.state.isCarbCollapsed && this.state.componentGroups.carbGroups.length > 5) && carbSearchControls, (this.state.componentGroups.carbGroups.length > 0) && (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-control-offset', style: { maxHeight: '800px', overflowY: 'auto' } }, { children: !this.state.isCarbCollapsed && this.state.carbGroups.map(function (g) { return (0, jsx_runtime_1.jsx)(StructureComponentGroup, { group: g, boldHeader: false }, g[0].cell.transform.ref); }) }))] });
227
- };
228
- return ComponentListControls;
229
- }(base_1.PurePluginUIComponent));
230
- var StructureComponentGroup = /** @class */ (function (_super) {
231
- tslib_1.__extends(StructureComponentGroup, _super);
232
- function StructureComponentGroup() {
233
- var _this = _super !== null && _super.apply(this, arguments) || this;
234
- _this.state = {
235
- action: void 0,
236
- isHidden: false,
237
- isBusy: false
238
- };
239
- _this.checkAllHidden = function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
240
- var allHidden, _i, _a, c;
241
- return tslib_1.__generator(this, function (_b) {
242
- allHidden = true;
243
- for (_i = 0, _a = this.props.group; _i < _a.length; _i++) {
244
- c = _a[_i];
245
- if (!c.cell.state.isHidden) {
246
- allHidden = false;
247
- break;
248
- }
249
- }
250
- if (allHidden)
251
- this.setState({ isHidden: true });
252
- return [2 /*return*/];
253
- });
254
- }); };
255
- _this.toggleVisible = function (e) {
256
- e.preventDefault();
257
- e.currentTarget.blur();
258
- _this.plugin.managers.structure.component.toggleVisibility(_this.props.group);
259
- _this.setState({ isHidden: !_this.state.isHidden });
260
- if (_this.props.type === 'alphafold') {
261
- var spState = _this.plugin.customState.superpositionState;
262
- spState.alphafold.visibility[spState.activeSegment - 1] = _this.state.isHidden;
263
- }
264
- };
265
- _this.toggleAction = function () { return _this.setState({ action: _this.state.action === 'action' ? void 0 : 'action' }); };
266
- _this.highlight = function (e) {
267
- e.preventDefault();
268
- if (!_this.props.group[0].cell.parent)
269
- return;
270
- commands_1.PluginCommands.Interactivity.Object.Highlight(_this.plugin, { state: _this.props.group[0].cell.parent, ref: _this.props.group.map(function (c) { return c.cell.transform.ref; }) });
271
- };
272
- _this.clearHighlight = function (e) {
273
- e.preventDefault();
274
- commands_1.PluginCommands.Interactivity.ClearHighlights(_this.plugin);
275
- };
276
- _this.focus = function () {
277
- var allHidden = true;
278
- for (var _i = 0, _a = _this.props.group; _i < _a.length; _i++) {
279
- var c = _a[_i];
280
- if (!c.cell.state.isHidden) {
281
- allHidden = false;
282
- break;
283
- }
284
- }
285
- if (allHidden) {
286
- _this.plugin.managers.structure.hierarchy.toggleVisibility(_this.props.group, 'show');
287
- }
288
- _this.plugin.managers.camera.focusSpheres(_this.props.group, function (e) {
289
- var _a;
290
- if (e.cell.state.isHidden)
291
- return;
292
- return (_a = e.cell.obj) === null || _a === void 0 ? void 0 : _a.data.boundary.sphere;
293
- });
294
- };
295
- return _this;
296
- }
297
- Object.defineProperty(StructureComponentGroup.prototype, "pivot", {
298
- get: function () {
299
- return this.props.group[0];
300
- },
301
- enumerable: false,
302
- configurable: true
303
- });
304
- StructureComponentGroup.prototype.componentDidMount = function () {
305
- var _this = this;
306
- this.checkAllHidden();
307
- this.subscribe(this.plugin.state.events.cell.stateUpdated, function (e) {
308
- var _a, _b;
309
- // if (State.ObjectEvent.isCell(e, this.pivot.cell)) this.forceUpdate();
310
- if (((_a = _this.pivot.cell.obj) === null || _a === void 0 ? void 0 : _a.label) === ((_b = e.cell.obj) === null || _b === void 0 ? void 0 : _b.label)) {
311
- if (!e.cell.state.isHidden) {
312
- _this.setState({ isHidden: false });
313
- }
314
- else {
315
- _this.checkAllHidden();
316
- }
317
- }
318
- });
319
- this.subscribe(this.plugin.behaviors.state.isBusy, function (v) {
320
- _this.setState({ isBusy: v });
321
- });
322
- this.subscribe(this.plugin.customState.events.isBusy, function (e) {
323
- _this.setState({ isBusy: e });
324
- });
325
- };
326
- StructureComponentGroup.prototype.render = function () {
327
- var _this = this;
328
- var _a;
329
- var component = this.pivot;
330
- var cell = component.cell;
331
- var label = (_a = cell.obj) === null || _a === void 0 ? void 0 : _a.label;
332
- var labelEle = this.props.boldHeader ? (0, jsx_runtime_1.jsx)("strong", { children: label }) : label;
333
- return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-flex-row' }, { children: [(0, jsx_runtime_1.jsx)(common_1.Button, tslib_1.__assign({ noOverflow: true, className: 'msp-control-button-label', title: "".concat(label, " - Click to focus."), onClick: this.focus, style: { textAlign: 'left' }, disabled: this.state.isBusy }, { children: labelEle })), (0, jsx_runtime_1.jsx)(common_1.IconButton, { disabled: this.state.isBusy, svg: this.state.isHidden ? icons_1.VisibilityOffOutlinedSvg : icons_1.VisibilityOutlinedSvg, toggleState: false, onClick: this.toggleVisible, title: "".concat(this.state.isHidden ? 'Show' : 'Hide', " component"), small: true, className: 'msp-form-control', flex: true }), (0, jsx_runtime_1.jsx)(common_1.IconButton, { disabled: this.state.isBusy, svg: icons_1.MoreHorizSvg, onClick: this.toggleAction, title: 'Actions', toggleState: this.state.action === 'action', className: 'msp-form-control', flex: true })] })), this.state.action === 'action' && (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-accent-offset' }, { children: (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: { marginBottom: '6px' } }, { children: component.representations.map(function (r) { return (0, jsx_runtime_1.jsx)(StructureRepresentationEntry, { group: _this.props.group, representation: r }, r.cell.transform.ref); }) })) }))] });
334
- };
335
- return StructureComponentGroup;
336
- }(base_1.PurePluginUIComponent));
337
- var StructureRepresentationEntry = /** @class */ (function (_super) {
338
- tslib_1.__extends(StructureRepresentationEntry, _super);
339
- function StructureRepresentationEntry() {
340
- var _this = _super !== null && _super.apply(this, arguments) || this;
341
- _this.state = {
342
- isBusy: false,
343
- clusterVal: { cluster: 'All' }
344
- };
345
- _this.remove = function () { return _this.plugin.managers.structure.component.removeRepresentations(_this.props.group, _this.props.representation); };
346
- _this.toggleVisible = function (e) {
347
- e.preventDefault();
348
- e.currentTarget.blur();
349
- _this.plugin.managers.structure.component.toggleVisibility(_this.props.group, _this.props.representation);
350
- };
351
- _this.update = function (params) {
352
- return _this.updateRepresentations(_this.props.group, _this.props.representation, params);
353
- };
354
- _this.selectCluster = function (params) {
355
- _this.setState({ clusterVal: { cluster: params.cluster } });
356
- };
357
- return _this;
358
- }
359
- StructureRepresentationEntry.prototype.componentDidMount = function () {
360
- var _this = this;
361
- this.subscribe(this.plugin.state.events.cell.stateUpdated, function (e) {
362
- if (mol_state_1.State.ObjectEvent.isCell(e, _this.props.representation.cell))
363
- _this.forceUpdate();
364
- });
365
- this.subscribe(this.plugin.behaviors.state.isBusy, function (v) {
366
- _this.setState({ isBusy: v });
367
- });
368
- this.subscribe(this.plugin.customState.events.isBusy, function (e) {
369
- _this.setState({ isBusy: e });
370
- });
371
- };
372
- StructureRepresentationEntry.prototype.updateRepresentations = function (components, pivot, params) {
373
- var _a, _b, _c;
374
- if (components.length === 0)
375
- return Promise.resolve();
376
- var index = components[0].representations.indexOf(pivot);
377
- if (index < 0)
378
- return Promise.resolve();
379
- var superpositionState = this.plugin.customState.superpositionState;
380
- var filteredComps = [];
381
- if (this.state.clusterVal.cluster !== 'All') {
382
- var clusterData = superpositionState.segmentData[superpositionState.activeSegment - 1].clusters[parseInt(this.state.clusterVal.cluster) - 1];
383
- filteredComps = clusterData.map(function (s) {
384
- return "".concat(s.pdb_id, "_").concat(s.struct_asym_id);
385
- });
386
- if (filteredComps.length === 0)
387
- return;
388
- }
389
- var update = this.plugin.state.data.build();
390
- for (var _i = 0, components_1 = components; _i < components_1.length; _i++) {
391
- var c = components_1[_i];
392
- // TODO: is it ok to use just the index here? Could possible lead to ugly edge cases, but perhaps not worth the trouble to "fix".
393
- var repr = c.representations[index];
394
- if (!repr)
395
- continue;
396
- if (repr.cell.transform.transformer !== pivot.cell.transform.transformer)
397
- continue;
398
- if (this.state.clusterVal.cluster !== 'All') {
399
- var rmIndex = filteredComps.indexOf(superpositionState.refMaps[repr.cell.transform.parent]);
400
- if (rmIndex === -1)
401
- continue;
402
- }
403
- var updatedParams = {
404
- type: params.type ? params.type : (_a = repr.cell.params) === null || _a === void 0 ? void 0 : _a.values.type,
405
- colorTheme: params.colorTheme ? params.colorTheme : (_b = repr.cell.params) === null || _b === void 0 ? void 0 : _b.values.colorTheme,
406
- sizeTheme: params.sizeTheme ? params.sizeTheme : (_c = repr.cell.params) === null || _c === void 0 ? void 0 : _c.values.sizeTheme
407
- };
408
- update.to(repr.cell).update(updatedParams);
409
- }
410
- return update.commit({ canUndo: 'Update Representation' });
411
- };
412
- StructureRepresentationEntry.prototype.render = function () {
413
- var _a, _b, _c, _d, _e, _f;
414
- var repr = this.props.representation.cell;
415
- var superpositionState = this.plugin.customState.superpositionState;
416
- var clusterSelectArr = [['All', 'All']];
417
- superpositionState.segmentData[superpositionState.activeSegment - 1].clusters.forEach(function (c, i) {
418
- clusterSelectArr.push([(i + 1) + '', (i + 1) + '']);
419
- });
420
- var clusterOptions = {
421
- cluster: param_definition_1.ParamDefinition.Select('All', clusterSelectArr, { label: 'Select Cluster' })
422
- };
423
- var isSurrVisual = false;
424
- var isAlphafold = false;
425
- if (repr && repr.obj) {
426
- var reprObj = repr.obj;
427
- if (reprObj.tags && reprObj.tags.indexOf('superposition-focus-surr-repr') >= 0)
428
- isSurrVisual = true;
429
- if (reprObj.tags && reprObj.tags.indexOf('af-superposition-visual') >= 0)
430
- isAlphafold = true;
431
- }
432
- return (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-representation-entry' }, { children: repr.parent && (0, jsx_runtime_1.jsxs)("div", { children: [(clusterSelectArr.length > 2 && !isSurrVisual && !isAlphafold) && (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-representation-entry' }, { children: (0, jsx_runtime_1.jsx)(parameters_1.ParameterControls, { params: clusterOptions, values: this.state.clusterVal, onChangeValues: this.selectCluster, isDisabled: this.state.isBusy }) })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-representation-entry' }, { children: (0, jsx_runtime_1.jsx)(parameters_1.ParameterControls, { params: { type: (_a = repr.params) === null || _a === void 0 ? void 0 : _a.definition.type }, values: { type: (_b = repr.params) === null || _b === void 0 ? void 0 : _b.values.type }, onChangeValues: this.update, isDisabled: this.state.isBusy }) })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-representation-entry' }, { children: (0, jsx_runtime_1.jsx)(parameters_1.ParameterControls, { params: { colorTheme: (_c = repr.params) === null || _c === void 0 ? void 0 : _c.definition.colorTheme }, values: { colorTheme: (_d = repr.params) === null || _d === void 0 ? void 0 : _d.values.colorTheme }, onChangeValues: this.update, isDisabled: this.state.isBusy }) })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-representation-entry' }, { children: (0, jsx_runtime_1.jsx)(parameters_1.ParameterControls, { params: { sizeTheme: (_e = repr.params) === null || _e === void 0 ? void 0 : _e.definition.sizeTheme }, values: { sizeTheme: (_f = repr.params) === null || _f === void 0 ? void 0 : _f.values.sizeTheme }, onChangeValues: this.update, isDisabled: this.state.isBusy }) }))] }) }));
433
- };
434
- return StructureRepresentationEntry;
435
- }(base_1.PurePluginUIComponent));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SuperpositionComponentControls = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var jsx_runtime_1 = require("react/jsx-runtime");
6
+ var commands_1 = require("Molstar/mol-plugin/commands");
7
+ var mol_state_1 = require("Molstar/mol-state");
8
+ var param_definition_1 = require("Molstar/mol-util/param-definition");
9
+ var base_1 = require("Molstar/mol-plugin-ui/base");
10
+ var common_1 = require("Molstar/mol-plugin-ui/controls/common");
11
+ var icons_1 = require("Molstar/mol-plugin-ui/controls/icons");
12
+ var parameters_1 = require("Molstar/mol-plugin-ui/controls/parameters");
13
+ var operators_1 = require("rxjs/operators");
14
+ var rxjs_1 = require("rxjs");
15
+ var SuperpositionComponentControls = /** @class */ (function (_super) {
16
+ tslib_1.__extends(SuperpositionComponentControls, _super);
17
+ function SuperpositionComponentControls() {
18
+ return _super !== null && _super.apply(this, arguments) || this;
19
+ }
20
+ SuperpositionComponentControls.prototype.defaultState = function () {
21
+ return {
22
+ header: 'Components',
23
+ isCollapsed: false,
24
+ isDisabled: false,
25
+ brand: { accent: 'blue', svg: icons_1.CubeOutlineSvg }
26
+ };
27
+ };
28
+ SuperpositionComponentControls.prototype.renderControls = function () {
29
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(ComponentListControls, {}) });
30
+ };
31
+ return SuperpositionComponentControls;
32
+ }(base_1.CollapsableControls));
33
+ exports.SuperpositionComponentControls = SuperpositionComponentControls;
34
+ ;
35
+ var ComponentListControls = /** @class */ (function (_super) {
36
+ tslib_1.__extends(ComponentListControls, _super);
37
+ function ComponentListControls() {
38
+ var _this = _super !== null && _super.apply(this, arguments) || this;
39
+ _this.state = {
40
+ segmentWatch: false,
41
+ ligSearchText: '',
42
+ carbSearchText: '',
43
+ componentGroups: { nonLigGroups: [], ligGroups: [], carbGroups: [], alphafold: [] },
44
+ ligGroups: [],
45
+ isLigCollapsed: false,
46
+ carbGroups: [],
47
+ isCarbCollapsed: false,
48
+ isBusy: false
49
+ };
50
+ _this.ligInputStream = new rxjs_1.Subject();
51
+ _this.handleLigInputStream = function (inputStr) {
52
+ _this.setState({ ligSearchText: inputStr });
53
+ var filteredRes = _this.state.componentGroups.ligGroups.filter(function (g) {
54
+ var gKeys = g[0].key.split(',');
55
+ var cId1Arr = gKeys[0].split('-');
56
+ return cId1Arr[2].toLowerCase().indexOf(inputStr.toLowerCase()) >= 0;
57
+ });
58
+ _this.setState({ ligGroups: filteredRes });
59
+ };
60
+ _this.carbInputStream = new rxjs_1.Subject();
61
+ _this.handleCarbInputStream = function (inputStr) {
62
+ _this.setState({ carbSearchText: inputStr });
63
+ var filteredRes = _this.state.componentGroups.carbGroups.filter(function (g) {
64
+ var gKeys = g[0].key.split(',');
65
+ var cId1Arr = gKeys[0].split('-');
66
+ cId1Arr.splice(0, 2);
67
+ cId1Arr.pop();
68
+ return cId1Arr.join('-').toLowerCase().indexOf(inputStr.toLowerCase()) >= 0;
69
+ });
70
+ _this.setState({ carbGroups: filteredRes });
71
+ };
72
+ _this.toggleVisible = function (e, action, type) {
73
+ e.preventDefault();
74
+ e.currentTarget.blur();
75
+ var customState = _this.plugin.customState;
76
+ customState.events.isBusy.next(true);
77
+ var visualEntites = (type === 'ligands') ? _this.state.ligGroups : _this.state.carbGroups;
78
+ setTimeout(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
79
+ var visualEntites_1, visualEntites_1_1, visualEntity, e_1_1;
80
+ var e_1, _a;
81
+ return tslib_1.__generator(this, function (_b) {
82
+ switch (_b.label) {
83
+ case 0:
84
+ _b.trys.push([0, 5, 6, 11]);
85
+ visualEntites_1 = tslib_1.__asyncValues(visualEntites);
86
+ _b.label = 1;
87
+ case 1: return [4 /*yield*/, visualEntites_1.next()];
88
+ case 2:
89
+ if (!(visualEntites_1_1 = _b.sent(), !visualEntites_1_1.done)) return [3 /*break*/, 4];
90
+ visualEntity = visualEntites_1_1.value;
91
+ this.plugin.managers.structure.hierarchy.toggleVisibility(visualEntity, action);
92
+ _b.label = 3;
93
+ case 3: return [3 /*break*/, 1];
94
+ case 4: return [3 /*break*/, 11];
95
+ case 5:
96
+ e_1_1 = _b.sent();
97
+ e_1 = { error: e_1_1 };
98
+ return [3 /*break*/, 11];
99
+ case 6:
100
+ _b.trys.push([6, , 9, 10]);
101
+ if (!(visualEntites_1_1 && !visualEntites_1_1.done && (_a = visualEntites_1.return))) return [3 /*break*/, 8];
102
+ return [4 /*yield*/, _a.call(visualEntites_1)];
103
+ case 7:
104
+ _b.sent();
105
+ _b.label = 8;
106
+ case 8: return [3 /*break*/, 10];
107
+ case 9:
108
+ if (e_1) throw e_1.error;
109
+ return [7 /*endfinally*/];
110
+ case 10: return [7 /*endfinally*/];
111
+ case 11:
112
+ ;
113
+ customState.events.isBusy.next(false);
114
+ return [2 /*return*/];
115
+ }
116
+ });
117
+ }); });
118
+ };
119
+ _this.showHideAllControls = function (type) {
120
+ return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(common_1.Button, tslib_1.__assign({ icon: icons_1.CheckSvg, flex: true, onClick: function (e) { return _this.toggleVisible(e, 'show', type); }, style: { flex: '0 0 50px', textAlign: 'center', fontSize: '80%', color: '#9cacc3', padding: 0 }, title: "Show all ".concat(type), disabled: false }, { children: "All" })), (0, jsx_runtime_1.jsx)(common_1.Button, tslib_1.__assign({ icon: icons_1.CloseSvg, flex: true, onClick: function (e) { return _this.toggleVisible(e, 'hide', type); }, style: { flex: '0 0 50px', textAlign: 'center', fontSize: '80%', color: '#9cacc3', padding: 0 }, title: "Hide all ".concat(type), disabled: false }, { children: "None" }))] });
121
+ };
122
+ _this.clearLigSearch = function (e) {
123
+ e.preventDefault();
124
+ _this.setState({ ligSearchText: '' });
125
+ _this.ligInputStream.next('');
126
+ e.currentTarget.blur();
127
+ };
128
+ _this.clearCarbSearch = function (e) {
129
+ e.preventDefault();
130
+ _this.setState({ carbSearchText: '' });
131
+ _this.carbInputStream.next('');
132
+ e.currentTarget.blur();
133
+ };
134
+ _this.collapseSection = function (e, type) {
135
+ e.preventDefault();
136
+ e.currentTarget.blur();
137
+ if (type === 'ligands') {
138
+ _this.setState({ isLigCollapsed: !_this.state.isLigCollapsed });
139
+ }
140
+ else {
141
+ _this.setState({ isCarbCollapsed: !_this.state.isCarbCollapsed });
142
+ }
143
+ };
144
+ _this.sectionHeader = function (type) {
145
+ var showHideAllControls = (type === 'ligands') ? _this.showHideAllControls('ligands') : _this.showHideAllControls('carbohydrates');
146
+ var title = (type === 'ligands') ? 'Ligand' : 'Carbohydrates';
147
+ var visibleVisuals = (type === 'ligands') ? _this.state.ligGroups.length : _this.state.carbGroups.length;
148
+ var totalVisuals = (type === 'ligands') ? _this.state.componentGroups.ligGroups.length : _this.state.componentGroups.carbGroups.length;
149
+ return (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-flex-row', style: { marginTop: '6px' } }, { children: [(0, jsx_runtime_1.jsxs)("button", tslib_1.__assign({ className: 'msp-form-control msp-control-button-label msp-transform-header-brand-gray', style: { textAlign: 'left' }, onClick: function (e) { return _this.collapseSection(e, type); } }, { children: [(0, jsx_runtime_1.jsx)("span", { children: (0, jsx_runtime_1.jsx)("strong", { children: title }) }), (0, jsx_runtime_1.jsxs)("small", tslib_1.__assign({ style: { color: '#7d91b0' } }, { children: [" ( ", visibleVisuals, visibleVisuals < totalVisuals ? " / ".concat(totalVisuals) : '', " )"] }))] })), visibleVisuals > 1 && showHideAllControls] }));
150
+ };
151
+ return _this;
152
+ }
153
+ ComponentListControls.prototype.componentDidMount = function () {
154
+ var _this = this;
155
+ this.subscribe(this.plugin.managers.structure.hierarchy.behaviors.selection, function () {
156
+ _this.categoriseGroups();
157
+ _this.forceUpdate();
158
+ });
159
+ this.subscribe(this.plugin.behaviors.state.isBusy, function (v) {
160
+ _this.setState({ isBusy: v });
161
+ });
162
+ };
163
+ ComponentListControls.prototype.componentDidUpdate = function () {
164
+ var _this = this;
165
+ var customState = this.plugin.customState;
166
+ if (customState.events && !this.state.segmentWatch) {
167
+ this.setState({ segmentWatch: true });
168
+ this.subscribe(customState.events.segmentUpdate, function () {
169
+ _this.categoriseGroups();
170
+ _this.forceUpdate();
171
+ });
172
+ }
173
+ this.subscribe(this.ligInputStream.pipe((0, operators_1.debounceTime)(1000 / 24)), function (e) { return _this.handleLigInputStream(e); });
174
+ this.subscribe(this.carbInputStream.pipe((0, operators_1.debounceTime)(1000 / 24)), function (e) { return _this.handleCarbInputStream(e); });
175
+ };
176
+ ComponentListControls.prototype.categoriseGroups = function () {
177
+ var componentGroupsVal = { nonLigGroups: [], ligGroups: [], carbGroups: [], alphafold: [] };
178
+ var componentGroups = this.plugin.managers.structure.hierarchy.currentComponentGroups;
179
+ var customState = this.plugin.customState;
180
+ componentGroups.forEach(function (g) {
181
+ var isLigandView = false;
182
+ if (customState.initParams && customState.initParams.superpositionParams && customState.initParams.superpositionParams.ligandView) {
183
+ isLigandView = true;
184
+ }
185
+ if (isLigandView) {
186
+ var gKeys = g[0].key.split(',');
187
+ var cId1Arr = gKeys[0].split('-');
188
+ if (gKeys.indexOf('superposition-focus-surr-sel') === -1) {
189
+ if (cId1Arr[cId1Arr.length - 1] !== (customState.superpositionState.activeSegment - 1) + '')
190
+ return;
191
+ if (gKeys.indexOf('superposition-ligand-sel') >= 0) {
192
+ componentGroupsVal.ligGroups.push(g);
193
+ }
194
+ else if (gKeys.indexOf('superposition-carb-sel') >= 0) {
195
+ componentGroupsVal.carbGroups.push(g);
196
+ }
197
+ else if (gKeys.indexOf('alphafold-chain') >= 0) {
198
+ componentGroupsVal.alphafold.push(g);
199
+ }
200
+ else {
201
+ componentGroupsVal.nonLigGroups.push(g);
202
+ }
203
+ }
204
+ else {
205
+ componentGroupsVal.nonLigGroups.push(g);
206
+ }
207
+ }
208
+ else {
209
+ var gKeys = g[0].key.split(',');
210
+ if (gKeys.indexOf('superposition-focus-surr-sel') >= 0 || gKeys.indexOf("Chain-".concat(customState.superpositionState.activeSegment - 1)) >= 0) {
211
+ componentGroupsVal.nonLigGroups.push(g);
212
+ }
213
+ else if (gKeys.indexOf('alphafold-chain') >= 0) {
214
+ componentGroupsVal.alphafold.push(g);
215
+ }
216
+ }
217
+ });
218
+ this.setState({ componentGroups: componentGroupsVal, ligGroups: componentGroupsVal.ligGroups, carbGroups: componentGroupsVal.carbGroups, ligSearchText: '', carbSearchText: '' });
219
+ };
220
+ ComponentListControls.prototype.render = function () {
221
+ var _this = this;
222
+ var ligSearchControls = (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-mapped-parameter-group', style: { fontSize: '90%' } }, { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-control-row msp-transform-header-brand-gray', style: { height: '33px' } }, { children: [(0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ className: 'msp-control-row-label' }, { children: "Search Ligand" })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-control-row-ctrl' }, { children: (0, jsx_runtime_1.jsx)("input", { type: 'text', placeholder: 'Enter HET code', disabled: this.state.isBusy, onChange: function (e) { return _this.ligInputStream.next(e.target.value); }, value: this.state.ligSearchText, maxLength: 3 }) }))] })), (0, jsx_runtime_1.jsx)(common_1.IconButton, { svg: icons_1.CloseSvg, flex: true, onClick: this.clearLigSearch, style: { flex: '0 0 24px', padding: 0 }, disabled: this.state.ligSearchText === '' || this.state.isBusy, toggleState: this.state.ligSearchText !== '', title: 'Clear search input' })] }));
223
+ var carbSearchControls = (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-mapped-parameter-group', style: { fontSize: '90%' } }, { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-control-row msp-transform-header-brand-gray', style: { height: '33px' } }, { children: [(0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ className: 'msp-control-row-label' }, { children: "Search Carbohydrate" })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-control-row-ctrl' }, { children: (0, jsx_runtime_1.jsx)("input", { type: 'text', placeholder: 'Enter HET code', disabled: this.state.isBusy, onChange: function (e) { return _this.carbInputStream.next(e.target.value); }, value: this.state.carbSearchText, maxLength: 3 }) }))] })), (0, jsx_runtime_1.jsx)(common_1.IconButton, { svg: icons_1.CloseSvg, flex: true, onClick: this.clearCarbSearch, style: { flex: '0 0 24px', padding: 0 }, disabled: this.state.carbSearchText === '' || this.state.isBusy, toggleState: this.state.carbSearchText !== '', title: 'Clear search input' })] }));
224
+ var ligSectionHeader = this.sectionHeader('ligands');
225
+ var carbSectionHeader = this.sectionHeader('carbohydrates');
226
+ return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(this.state.componentGroups.nonLigGroups.length > 0) && (0, jsx_runtime_1.jsx)("div", { children: this.state.componentGroups.nonLigGroups.map(function (g) { return (0, jsx_runtime_1.jsx)(StructureComponentGroup, { group: g, boldHeader: true }, g[0].cell.transform.ref); }) }), (this.state.componentGroups.alphafold.length > 0) && (0, jsx_runtime_1.jsx)("div", { children: this.state.componentGroups.alphafold.map(function (g) { return (0, jsx_runtime_1.jsx)(StructureComponentGroup, { group: g, boldHeader: true, type: 'alphafold' }, g[0].cell.transform.ref); }) }), (this.state.componentGroups.ligGroups.length > 0) && ligSectionHeader, (!this.state.isLigCollapsed && this.state.componentGroups.ligGroups.length > 5) && ligSearchControls, (this.state.componentGroups.ligGroups.length > 0) && (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-control-offset', style: { maxHeight: '800px', overflowY: 'auto' } }, { children: !this.state.isLigCollapsed && this.state.ligGroups.map(function (g) { return (0, jsx_runtime_1.jsx)(StructureComponentGroup, { group: g, boldHeader: false }, g[0].cell.transform.ref); }) })), (this.state.componentGroups.carbGroups.length > 0) && carbSectionHeader, (!this.state.isCarbCollapsed && this.state.componentGroups.carbGroups.length > 5) && carbSearchControls, (this.state.componentGroups.carbGroups.length > 0) && (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-control-offset', style: { maxHeight: '800px', overflowY: 'auto' } }, { children: !this.state.isCarbCollapsed && this.state.carbGroups.map(function (g) { return (0, jsx_runtime_1.jsx)(StructureComponentGroup, { group: g, boldHeader: false }, g[0].cell.transform.ref); }) }))] });
227
+ };
228
+ return ComponentListControls;
229
+ }(base_1.PurePluginUIComponent));
230
+ var StructureComponentGroup = /** @class */ (function (_super) {
231
+ tslib_1.__extends(StructureComponentGroup, _super);
232
+ function StructureComponentGroup() {
233
+ var _this = _super !== null && _super.apply(this, arguments) || this;
234
+ _this.state = {
235
+ action: void 0,
236
+ isHidden: false,
237
+ isBusy: false
238
+ };
239
+ _this.checkAllHidden = function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
240
+ var allHidden, _i, _a, c;
241
+ return tslib_1.__generator(this, function (_b) {
242
+ allHidden = true;
243
+ for (_i = 0, _a = this.props.group; _i < _a.length; _i++) {
244
+ c = _a[_i];
245
+ if (!c.cell.state.isHidden) {
246
+ allHidden = false;
247
+ break;
248
+ }
249
+ }
250
+ if (allHidden)
251
+ this.setState({ isHidden: true });
252
+ return [2 /*return*/];
253
+ });
254
+ }); };
255
+ _this.toggleVisible = function (e) {
256
+ e.preventDefault();
257
+ e.currentTarget.blur();
258
+ _this.plugin.managers.structure.component.toggleVisibility(_this.props.group);
259
+ _this.setState({ isHidden: !_this.state.isHidden });
260
+ if (_this.props.type === 'alphafold') {
261
+ var spState = _this.plugin.customState.superpositionState;
262
+ spState.alphafold.visibility[spState.activeSegment - 1] = _this.state.isHidden;
263
+ }
264
+ };
265
+ _this.toggleAction = function () { return _this.setState({ action: _this.state.action === 'action' ? void 0 : 'action' }); };
266
+ _this.highlight = function (e) {
267
+ e.preventDefault();
268
+ if (!_this.props.group[0].cell.parent)
269
+ return;
270
+ commands_1.PluginCommands.Interactivity.Object.Highlight(_this.plugin, { state: _this.props.group[0].cell.parent, ref: _this.props.group.map(function (c) { return c.cell.transform.ref; }) });
271
+ };
272
+ _this.clearHighlight = function (e) {
273
+ e.preventDefault();
274
+ commands_1.PluginCommands.Interactivity.ClearHighlights(_this.plugin);
275
+ };
276
+ _this.focus = function () {
277
+ var allHidden = true;
278
+ for (var _i = 0, _a = _this.props.group; _i < _a.length; _i++) {
279
+ var c = _a[_i];
280
+ if (!c.cell.state.isHidden) {
281
+ allHidden = false;
282
+ break;
283
+ }
284
+ }
285
+ if (allHidden) {
286
+ _this.plugin.managers.structure.hierarchy.toggleVisibility(_this.props.group, 'show');
287
+ }
288
+ _this.plugin.managers.camera.focusSpheres(_this.props.group, function (e) {
289
+ var _a;
290
+ if (e.cell.state.isHidden)
291
+ return;
292
+ return (_a = e.cell.obj) === null || _a === void 0 ? void 0 : _a.data.boundary.sphere;
293
+ });
294
+ };
295
+ return _this;
296
+ }
297
+ Object.defineProperty(StructureComponentGroup.prototype, "pivot", {
298
+ get: function () {
299
+ return this.props.group[0];
300
+ },
301
+ enumerable: false,
302
+ configurable: true
303
+ });
304
+ StructureComponentGroup.prototype.componentDidMount = function () {
305
+ var _this = this;
306
+ this.checkAllHidden();
307
+ this.subscribe(this.plugin.state.events.cell.stateUpdated, function (e) {
308
+ var _a, _b;
309
+ // if (State.ObjectEvent.isCell(e, this.pivot.cell)) this.forceUpdate();
310
+ if (((_a = _this.pivot.cell.obj) === null || _a === void 0 ? void 0 : _a.label) === ((_b = e.cell.obj) === null || _b === void 0 ? void 0 : _b.label)) {
311
+ if (!e.cell.state.isHidden) {
312
+ _this.setState({ isHidden: false });
313
+ }
314
+ else {
315
+ _this.checkAllHidden();
316
+ }
317
+ }
318
+ });
319
+ this.subscribe(this.plugin.behaviors.state.isBusy, function (v) {
320
+ _this.setState({ isBusy: v });
321
+ });
322
+ this.subscribe(this.plugin.customState.events.isBusy, function (e) {
323
+ _this.setState({ isBusy: e });
324
+ });
325
+ };
326
+ StructureComponentGroup.prototype.render = function () {
327
+ var _this = this;
328
+ var _a;
329
+ var component = this.pivot;
330
+ var cell = component.cell;
331
+ var label = (_a = cell.obj) === null || _a === void 0 ? void 0 : _a.label;
332
+ var labelEle = this.props.boldHeader ? (0, jsx_runtime_1.jsx)("strong", { children: label }) : label;
333
+ return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-flex-row' }, { children: [(0, jsx_runtime_1.jsx)(common_1.Button, tslib_1.__assign({ noOverflow: true, className: 'msp-control-button-label', title: "".concat(label, " - Click to focus."), onClick: this.focus, style: { textAlign: 'left' }, disabled: this.state.isBusy }, { children: labelEle })), (0, jsx_runtime_1.jsx)(common_1.IconButton, { disabled: this.state.isBusy, svg: this.state.isHidden ? icons_1.VisibilityOffOutlinedSvg : icons_1.VisibilityOutlinedSvg, toggleState: false, onClick: this.toggleVisible, title: "".concat(this.state.isHidden ? 'Show' : 'Hide', " component"), small: true, className: 'msp-form-control', flex: true }), (0, jsx_runtime_1.jsx)(common_1.IconButton, { disabled: this.state.isBusy, svg: icons_1.MoreHorizSvg, onClick: this.toggleAction, title: 'Actions', toggleState: this.state.action === 'action', className: 'msp-form-control', flex: true })] })), this.state.action === 'action' && (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-accent-offset' }, { children: (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: { marginBottom: '6px' } }, { children: component.representations.map(function (r) { return (0, jsx_runtime_1.jsx)(StructureRepresentationEntry, { group: _this.props.group, representation: r }, r.cell.transform.ref); }) })) }))] });
334
+ };
335
+ return StructureComponentGroup;
336
+ }(base_1.PurePluginUIComponent));
337
+ var StructureRepresentationEntry = /** @class */ (function (_super) {
338
+ tslib_1.__extends(StructureRepresentationEntry, _super);
339
+ function StructureRepresentationEntry() {
340
+ var _this = _super !== null && _super.apply(this, arguments) || this;
341
+ _this.state = {
342
+ isBusy: false,
343
+ clusterVal: { cluster: 'All' }
344
+ };
345
+ _this.remove = function () { return _this.plugin.managers.structure.component.removeRepresentations(_this.props.group, _this.props.representation); };
346
+ _this.toggleVisible = function (e) {
347
+ e.preventDefault();
348
+ e.currentTarget.blur();
349
+ _this.plugin.managers.structure.component.toggleVisibility(_this.props.group, _this.props.representation);
350
+ };
351
+ _this.update = function (params) {
352
+ return _this.updateRepresentations(_this.props.group, _this.props.representation, params);
353
+ };
354
+ _this.selectCluster = function (params) {
355
+ _this.setState({ clusterVal: { cluster: params.cluster } });
356
+ };
357
+ return _this;
358
+ }
359
+ StructureRepresentationEntry.prototype.componentDidMount = function () {
360
+ var _this = this;
361
+ this.subscribe(this.plugin.state.events.cell.stateUpdated, function (e) {
362
+ if (mol_state_1.State.ObjectEvent.isCell(e, _this.props.representation.cell))
363
+ _this.forceUpdate();
364
+ });
365
+ this.subscribe(this.plugin.behaviors.state.isBusy, function (v) {
366
+ _this.setState({ isBusy: v });
367
+ });
368
+ this.subscribe(this.plugin.customState.events.isBusy, function (e) {
369
+ _this.setState({ isBusy: e });
370
+ });
371
+ };
372
+ StructureRepresentationEntry.prototype.updateRepresentations = function (components, pivot, params) {
373
+ var _a, _b, _c;
374
+ if (components.length === 0)
375
+ return Promise.resolve();
376
+ var index = components[0].representations.indexOf(pivot);
377
+ if (index < 0)
378
+ return Promise.resolve();
379
+ var superpositionState = this.plugin.customState.superpositionState;
380
+ var filteredComps = [];
381
+ if (this.state.clusterVal.cluster !== 'All') {
382
+ var clusterData = superpositionState.segmentData[superpositionState.activeSegment - 1].clusters[parseInt(this.state.clusterVal.cluster) - 1];
383
+ filteredComps = clusterData.map(function (s) {
384
+ return "".concat(s.pdb_id, "_").concat(s.struct_asym_id);
385
+ });
386
+ if (filteredComps.length === 0)
387
+ return;
388
+ }
389
+ var update = this.plugin.state.data.build();
390
+ for (var _i = 0, components_1 = components; _i < components_1.length; _i++) {
391
+ var c = components_1[_i];
392
+ // TODO: is it ok to use just the index here? Could possible lead to ugly edge cases, but perhaps not worth the trouble to "fix".
393
+ var repr = c.representations[index];
394
+ if (!repr)
395
+ continue;
396
+ if (repr.cell.transform.transformer !== pivot.cell.transform.transformer)
397
+ continue;
398
+ if (this.state.clusterVal.cluster !== 'All') {
399
+ var rmIndex = filteredComps.indexOf(superpositionState.refMaps[repr.cell.transform.parent]);
400
+ if (rmIndex === -1)
401
+ continue;
402
+ }
403
+ var updatedParams = {
404
+ type: params.type ? params.type : (_a = repr.cell.params) === null || _a === void 0 ? void 0 : _a.values.type,
405
+ colorTheme: params.colorTheme ? params.colorTheme : (_b = repr.cell.params) === null || _b === void 0 ? void 0 : _b.values.colorTheme,
406
+ sizeTheme: params.sizeTheme ? params.sizeTheme : (_c = repr.cell.params) === null || _c === void 0 ? void 0 : _c.values.sizeTheme
407
+ };
408
+ update.to(repr.cell).update(updatedParams);
409
+ }
410
+ return update.commit({ canUndo: 'Update Representation' });
411
+ };
412
+ StructureRepresentationEntry.prototype.render = function () {
413
+ var _a, _b, _c, _d, _e, _f;
414
+ var repr = this.props.representation.cell;
415
+ var superpositionState = this.plugin.customState.superpositionState;
416
+ var clusterSelectArr = [['All', 'All']];
417
+ superpositionState.segmentData[superpositionState.activeSegment - 1].clusters.forEach(function (c, i) {
418
+ clusterSelectArr.push([(i + 1) + '', (i + 1) + '']);
419
+ });
420
+ var clusterOptions = {
421
+ cluster: param_definition_1.ParamDefinition.Select('All', clusterSelectArr, { label: 'Select Cluster' })
422
+ };
423
+ var isSurrVisual = false;
424
+ var isAlphafold = false;
425
+ if (repr && repr.obj) {
426
+ var reprObj = repr.obj;
427
+ if (reprObj.tags && reprObj.tags.indexOf('superposition-focus-surr-repr') >= 0)
428
+ isSurrVisual = true;
429
+ if (reprObj.tags && reprObj.tags.indexOf('af-superposition-visual') >= 0)
430
+ isAlphafold = true;
431
+ }
432
+ return (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-representation-entry' }, { children: repr.parent && (0, jsx_runtime_1.jsxs)("div", { children: [(clusterSelectArr.length > 2 && !isSurrVisual && !isAlphafold) && (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-representation-entry' }, { children: (0, jsx_runtime_1.jsx)(parameters_1.ParameterControls, { params: clusterOptions, values: this.state.clusterVal, onChangeValues: this.selectCluster, isDisabled: this.state.isBusy }) })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-representation-entry' }, { children: (0, jsx_runtime_1.jsx)(parameters_1.ParameterControls, { params: { type: (_a = repr.params) === null || _a === void 0 ? void 0 : _a.definition.type }, values: { type: (_b = repr.params) === null || _b === void 0 ? void 0 : _b.values.type }, onChangeValues: this.update, isDisabled: this.state.isBusy }) })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-representation-entry' }, { children: (0, jsx_runtime_1.jsx)(parameters_1.ParameterControls, { params: { colorTheme: (_c = repr.params) === null || _c === void 0 ? void 0 : _c.definition.colorTheme }, values: { colorTheme: (_d = repr.params) === null || _d === void 0 ? void 0 : _d.values.colorTheme }, onChangeValues: this.update, isDisabled: this.state.isBusy }) })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-representation-entry' }, { children: (0, jsx_runtime_1.jsx)(parameters_1.ParameterControls, { params: { sizeTheme: (_e = repr.params) === null || _e === void 0 ? void 0 : _e.definition.sizeTheme }, values: { sizeTheme: (_f = repr.params) === null || _f === void 0 ? void 0 : _f.values.sizeTheme }, onChangeValues: this.update, isDisabled: this.state.isBusy }) }))] }) }));
433
+ };
434
+ return StructureRepresentationEntry;
435
+ }(base_1.PurePluginUIComponent));