ketcher-react 3.8.0-rc.1 → 3.8.0-rc.3

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.
@@ -111,6 +111,8 @@ declare class Editor implements KetcherEditor {
111
111
  reassignAttachmentPointAtom(atomId: number, atomLabel: string): void;
112
112
  reassignAttachmentPoint(currentName: AttachmentPointName, newName: AttachmentPointName): void;
113
113
  removeAttachmentPoint(name: AttachmentPointName): void;
114
+ cleanupCloseAttachmentPointEditPopup(): void;
115
+ setProblematicAttachmentPoints(problematicPoints: Set<AttachmentPointName>): void;
114
116
  selection(ci?: any): Selection | null;
115
117
  hover(ci: {
116
118
  id: number;
@@ -2,6 +2,7 @@ import { AttachmentPointName } from 'ketcher-core';
2
2
  declare type Props = {
3
3
  name: AttachmentPointName;
4
4
  atomLabel: string;
5
+ implicitH: number;
5
6
  };
6
- declare const AttachmentPoint: ({ name, atomLabel }: Props) => import("react/jsx-runtime").JSX.Element;
7
+ declare const AttachmentPoint: ({ name, atomLabel, implicitH }: Props) => import("react/jsx-runtime").JSX.Element;
7
8
  export default AttachmentPoint;
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ import 'url-search-params-polyfill';
27
27
  import 'whatwg-fetch';
28
28
  import _classCallCheck$2 from '@babel/runtime/helpers/classCallCheck';
29
29
  import _createClass$2 from '@babel/runtime/helpers/createClass';
30
- import { KetSerializer, MolSerializer, KetcherLogger, ketcherProvider, defaultBondThickness, isClipboardAPIAvailable, notifyCopyCut, notifyRequestCompleted, isControlKey, StereLabelStyleType, StereoColoringType, ShowHydrogenLabels, ShowHydrogenLabelNames, SettingsManager, SdfSerializer, KETCHER_SAVED_OPTIONS_KEY, SUPERATOM_CLASS, Bond as Bond$2, Elements, AtomList, getAtomType, StereoLabel, isAttachmentBond, Atom as Atom$2, findStereoAtoms, RxnArrowMode, MULTITAIL_ARROW_TOOL_NAME, CREATE_MONOMER_TOOL_NAME, SimpleObjectMode, IMAGE_KEY, SGroup as SGroup$1, identifyStructFormat, SupportedFormat, FormatterFactory, MULTITAIL_ARROW_KEY, ChemicalMimeType, RenderStruct, Struct, ZoomTool, KETCHER_MACROMOLECULES_ROOT_NODE_SELECTOR, shortcutStr, MonomerMicromolecule, UnresolvedMonomer, FunctionalGroupsProvider, SaltsAndSolventsProvider, KetcherAsyncEvents, ElementColor, generateMenuShortcuts, Vec2, Scale, fromMultipleMove, FunctionalGroup, mergeMapOfItemsToSet, fromSgroupDeletion, fromFragmentDeletion, vectorUtils, fromBondAddition, Action, fromAtomAddition, fromAtomsAttrs, checkOverlapping, fromSeveralSgroupAddition, expandSGroupWithMultipleAttachmentPoint, SgContexts, Pile, fromSgroupAction, fromItemsFuse, ReBond, setExpandSGroup, fromBondsAttrs, OperationType, ReStruct, imageReferencePositionToCursor, multitailArrowReferenceLinesToCursor, multitailReferencePositionToCursor, CoordinateTransformation, MultitailArrowRefName, fromMultitailArrowHeadTailMove, fromMultitailArrowHeadTailsResize, fromMultitailArrowMove, fromArrowResizing, fromPaste, fromImageResize, fromSimpleObjectResizing, getItemsToFuse, getHoverToFuse, fromTextDeletion, fromTextUpdating, fromTemplateOnCanvas, fromTemplateOnBondAction, fromTemplateOnAtom, BondAttr, AtomAttr, formatProperties, runAsyncAction, getStructStringFromClipboardData, getStructure, initHotKeys, keyNorm, Fragment as Fragment$1, fromRGroupAttachmentPointUpdate, fromOneBondDeletion, bondChangingAction, fromChain, removeInfoLabelFromAtoms, fromStereoFlagUpdate, fromOneAtomDeletion, fromArrowDeletion, fromPlusDeletion, fromSimpleObjectDeletion, fromRGroupAttachmentPointDeletion, fromImageDeletion, fromMultitailArrowDeletion, notifyItemsToMergeInitializationComplete, RGroup as RGroup$2, fromRGroupFragment, fromUpdateIfThen, fromRGroupAttrs, fromArrowAddition, fromMultitailArrowCreation, fromPlusAddition, getRelSGroupsBySelection, RotateMonomerOperation, fromRotate, fromFlip, fromSimpleObjectAddition, fromTextCreation, fromImageMove, fromImageCreation, fromHighlightCreate, fromHighlightClear, getOptionsWithConvertedUnits, provideEditorSettings, fromNewCanvas, Render, Coordinates, genericsList, getAttachmentPointLabel, getNextFreeAttachmentPoint, AttachmentPointName, setMonomerTemplatePrefix, getHELMClassByKetMonomerClass, fillNaturalAnalogueForPhosphateAndSugar, KetTemplateType, normalizeMonomerAtomsPositions, monomerFactory, MacromoleculesConverter, fromSgroupAddition, fromDescriptorsAlign, MonomerCreationAttachmentPointClickEvent, atomGetAttr, fromBondFlipping, setExpandMonomerSGroup, fromMultitailArrowTailAdd, MultitailArrow, fromMultitailArrowTailRemove, AmbiguousMonomer, KetMonomerClass, CoreEditor, getAttachmentPointNumberFromLabel, getAtomCustomQuery, getFormatMimeTypeByFileName, getPropertiesByFormat, StereoFlag, getPropertiesByImgFormat, legacyCopy as legacyCopy$1, b64toBlob, Generics, TextCommand, Ketcher, DefaultStructServiceOptions } from 'ketcher-core';
30
+ import { KetSerializer, MolSerializer, KetcherLogger, ketcherProvider, defaultBondThickness, isClipboardAPIAvailable, notifyCopyCut, notifyRequestCompleted, isControlKey, StereLabelStyleType, StereoColoringType, ShowHydrogenLabels, ShowHydrogenLabelNames, SettingsManager, SdfSerializer, KETCHER_SAVED_OPTIONS_KEY, SUPERATOM_CLASS, Bond as Bond$2, Elements, AtomList, getAtomType, StereoLabel, isAttachmentBond, Atom as Atom$2, findStereoAtoms, RxnArrowMode, MULTITAIL_ARROW_TOOL_NAME, CREATE_MONOMER_TOOL_NAME, SimpleObjectMode, IMAGE_KEY, SGroup as SGroup$1, identifyStructFormat, SupportedFormat, FormatterFactory, MULTITAIL_ARROW_KEY, ChemicalMimeType, RenderStruct, Struct, ZoomTool, KETCHER_MACROMOLECULES_ROOT_NODE_SELECTOR, shortcutStr, MonomerMicromolecule, UnresolvedMonomer, FunctionalGroupsProvider, SaltsAndSolventsProvider, KetcherAsyncEvents, ElementColor, generateMenuShortcuts, Vec2, Scale, fromMultipleMove, FunctionalGroup, mergeMapOfItemsToSet, fromSgroupDeletion, fromFragmentDeletion, vectorUtils, fromBondAddition, Action, fromAtomAddition, fromAtomsAttrs, checkOverlapping, fromSeveralSgroupAddition, expandSGroupWithMultipleAttachmentPoint, SgContexts, Pile, fromSgroupAction, fromItemsFuse, ReBond, setExpandSGroup, fromBondsAttrs, OperationType, ReStruct, imageReferencePositionToCursor, multitailArrowReferenceLinesToCursor, multitailReferencePositionToCursor, CoordinateTransformation, MultitailArrowRefName, fromMultitailArrowHeadTailMove, fromMultitailArrowHeadTailsResize, fromMultitailArrowMove, fromArrowResizing, fromPaste, fromImageResize, fromSimpleObjectResizing, getItemsToFuse, getHoverToFuse, fromTextDeletion, fromTextUpdating, fromTemplateOnCanvas, fromTemplateOnBondAction, fromTemplateOnAtom, BondAttr, AtomAttr, formatProperties, runAsyncAction, getStructStringFromClipboardData, getStructure, initHotKeys, keyNorm, Fragment as Fragment$1, fromRGroupAttachmentPointUpdate, fromOneBondDeletion, bondChangingAction, fromChain, removeInfoLabelFromAtoms, fromStereoFlagUpdate, fromOneAtomDeletion, fromArrowDeletion, fromPlusDeletion, fromSimpleObjectDeletion, fromRGroupAttachmentPointDeletion, fromImageDeletion, fromMultitailArrowDeletion, notifyItemsToMergeInitializationComplete, RGroup as RGroup$2, fromRGroupFragment, fromUpdateIfThen, fromRGroupAttrs, fromArrowAddition, fromMultitailArrowCreation, fromPlusAddition, getRelSGroupsBySelection, RotateMonomerOperation, fromRotate, fromFlip, fromSimpleObjectAddition, fromTextCreation, fromImageMove, fromImageCreation, fromHighlightCreate, fromHighlightClear, getOptionsWithConvertedUnits, provideEditorSettings, fromNewCanvas, Render, Coordinates, isSingleRGroupAttachmentPoint, genericsList, getAttachmentPointLabelWithBinaryShift, AttachmentPointName, getAttachmentPointLabel, getAttachmentPointNumberFromLabel, getNextFreeAttachmentPoint, AtomLabel, setMonomerTemplatePrefix, getHELMClassByKetMonomerClass, fillNaturalAnalogueForPhosphateAndSugar, KetTemplateType, normalizeMonomerAtomsPositions, monomerFactory, MacromoleculesConverter, fromSgroupAddition, fromDescriptorsAlign, MonomerCreationAttachmentPointClickEvent, atomGetAttr, fromBondFlipping, setExpandMonomerSGroup, fromMultitailArrowTailAdd, MultitailArrow, fromMultitailArrowTailRemove, AmbiguousMonomer, KetMonomerClass, CoreEditor, getAtomCustomQuery, getFormatMimeTypeByFileName, getPropertiesByFormat, StereoFlag, getPropertiesByImgFormat, legacyCopy as legacyCopy$1, b64toBlob, Generics, TextCommand, Ketcher, DefaultStructServiceOptions } from 'ketcher-core';
31
31
  export { EditorClassName, KETCHER_MACROMOLECULES_ROOT_NODE_SELECTOR } from 'ketcher-core';
32
32
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
33
33
  import _possibleConstructorReturn$2 from '@babel/runtime/helpers/possibleConstructorReturn';
@@ -3787,7 +3787,7 @@ var zoom = {
3787
3787
 
3788
3788
  var openHelpLink = function openHelpLink() {
3789
3789
  var _window$open;
3790
- return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v3.8.0-rc.1\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
3790
+ return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v3.8.0-rc.3\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
3791
3791
  };
3792
3792
  var help = {
3793
3793
  help: {
@@ -24268,8 +24268,9 @@ var HoverIcon = function () {
24268
24268
  }, {
24269
24269
  key: "isOverLoader",
24270
24270
  value: function isOverLoader(event) {
24271
+ var _target$classList;
24271
24272
  var target = (event === null || event === void 0 ? void 0 : event.relatedTarget) || event.target;
24272
- return target === null || target === void 0 ? void 0 : target.classList.contains('loading-spinner');
24273
+ return target === null || target === void 0 || (_target$classList = target.classList) === null || _target$classList === void 0 ? void 0 : _target$classList.contains('loading-spinner');
24273
24274
  }
24274
24275
  }, {
24275
24276
  key: "onMouseMove",
@@ -25343,9 +25344,20 @@ var Editor$3 = function () {
25343
25344
  var selectionInvalid = selection.atoms.some(function (atomId) {
25344
25345
  var atom = _this.render.ctab.molecule.atoms.get(atomId);
25345
25346
  assert_1(atom);
25346
- return atom.sgs.size > 0 || atom.attachmentPoints !== null || atom.rglabel !== null && atom.neighbors.length > 1 || _this.render.ctab.molecule.rgroups.some(function (rgroup) {
25347
+ var sgs = atom.sgs,
25348
+ attachmentPoints = atom.attachmentPoints,
25349
+ rglabel = atom.rglabel,
25350
+ neighbors = atom.neighbors,
25351
+ label = atom.label;
25352
+ var belongsToSGroup = sgs.size > 0;
25353
+ var isAttachmentPoint = attachmentPoints !== null;
25354
+ var isNonTerminalRGroupLabel = rglabel !== null && neighbors.length > 1;
25355
+ var hasMultipleRGroupLabel = rglabel !== null && !isSingleRGroupAttachmentPoint(Number(rglabel));
25356
+ var belongsToRGroup = _this.render.ctab.molecule.rgroups.some(function (rgroup) {
25347
25357
  return rgroup.frags.has(atom.fragment);
25348
- }) || genericsList.includes(atom.label);
25358
+ });
25359
+ var isExtendedTableAtom = genericsList.includes(label);
25360
+ return belongsToSGroup || isAttachmentPoint || isNonTerminalRGroupLabel || hasMultipleRGroupLabel || belongsToRGroup || isExtendedTableAtom;
25349
25361
  });
25350
25362
  if (selectionInvalid) {
25351
25363
  return false;
@@ -25374,11 +25386,24 @@ var Editor$3 = function () {
25374
25386
  potentialLeavingAtoms.push(bond.begin);
25375
25387
  }
25376
25388
  });
25389
+ selectionAtoms.forEach(function (selectionAtomId) {
25390
+ var selectionAtom = currentStruct.atoms.get(selectionAtomId);
25391
+ assert_1(selectionAtom);
25392
+ if (selectionAtom.neighbors.length === 1 && !isNumber(selectionAtom.rglabel)) {
25393
+ potentialLeavingAtoms.push(selectionAtomId);
25394
+ }
25395
+ });
25377
25396
  var totalPotentialLeavingAtoms = terminalRGroupAtoms.length + potentialLeavingAtoms.length;
25378
25397
  if (totalPotentialLeavingAtoms > 8) {
25379
25398
  return false;
25380
25399
  }
25381
- this.terminalRGroupAtoms = terminalRGroupAtoms;
25400
+ this.terminalRGroupAtoms = terminalRGroupAtoms.map(function (atomId) {
25401
+ var atom = currentStruct.atoms.get(atomId);
25402
+ assert_1(atom);
25403
+ assert_1(atom.rglabel);
25404
+ var attachmentPointLabel = getAttachmentPointLabelWithBinaryShift(Number(atom.rglabel));
25405
+ return [atomId, attachmentPointLabel];
25406
+ });
25382
25407
  this.potentialLeavingAtoms = potentialLeavingAtoms;
25383
25408
  return terminalRGroupAtoms.length > 0 || potentialLeavingAtoms.length > 0;
25384
25409
  }
@@ -25403,47 +25428,102 @@ var Editor$3 = function () {
25403
25428
  _this2.selectedToOriginalAtomsIdMap.set(i, atomId);
25404
25429
  });
25405
25430
  var assignedAttachmentPoints = new Map();
25406
- var potentialAttachmentPoints = new Map();
25407
- this.terminalRGroupAtoms.forEach(function (atomId, i) {
25431
+ var sideTerminalSGroupAtoms = this.terminalRGroupAtoms.filter(function (_ref) {
25432
+ var _ref2 = _slicedToArray$1(_ref, 2),
25433
+ attachmentPointLabel = _ref2[1];
25434
+ return attachmentPointLabel !== AttachmentPointName.R1 && attachmentPointLabel !== AttachmentPointName.R2;
25435
+ });
25436
+ var sideAttachmentPointsNames = [];
25437
+ for (var i = 0; i < sideTerminalSGroupAtoms.length; i++) {
25438
+ var attachmentPointNumber = i + 3;
25439
+ if (attachmentPointNumber > 8) {
25440
+ break;
25441
+ }
25442
+ sideAttachmentPointsNames = sideAttachmentPointsNames.concat(getAttachmentPointLabel(attachmentPointNumber));
25443
+ }
25444
+ var terminalRGroupAtomsSortedByLabel = _toConsumableArray(this.terminalRGroupAtoms).sort(function (_ref3, _ref4) {
25445
+ var _ref5 = _slicedToArray$1(_ref3, 2),
25446
+ labelA = _ref5[1];
25447
+ var _ref6 = _slicedToArray$1(_ref4, 2),
25448
+ labelB = _ref6[1];
25449
+ var labelANumber = getAttachmentPointNumberFromLabel(labelA);
25450
+ var labelBNumber = getAttachmentPointNumberFromLabel(labelB);
25451
+ return labelANumber - labelBNumber;
25452
+ });
25453
+ terminalRGroupAtomsSortedByLabel.forEach(function (_ref7) {
25408
25454
  var _selectedStruct$halfB;
25455
+ var _ref8 = _slicedToArray$1(_ref7, 2),
25456
+ atomId = _ref8[0],
25457
+ attachmentPointLabel = _ref8[1];
25409
25458
  var selectedStructLeavingAtomId = originalToSelectedAtomsIdMap.get(atomId);
25410
25459
  assert_1(selectedStructLeavingAtomId !== undefined);
25411
25460
  var selectedStructLeavingAtom = selectedStruct.atoms.get(selectedStructLeavingAtomId);
25412
25461
  assert_1(selectedStructLeavingAtom);
25462
+ assert_1(selectedStructLeavingAtom.rglabel);
25463
+ var attachmentPointName;
25464
+ if (attachmentPointLabel === AttachmentPointName.R1 || attachmentPointLabel === AttachmentPointName.R2 || sideAttachmentPointsNames.includes(attachmentPointLabel)) {
25465
+ attachmentPointName = attachmentPointLabel;
25466
+ } else {
25467
+ var assignedAttachmentPointNames = Array.from(assignedAttachmentPoints.keys());
25468
+ attachmentPointName = getNextFreeAttachmentPoint(assignedAttachmentPointNames, assignedAttachmentPointNames.length < sideAttachmentPointsNames.length);
25469
+ }
25413
25470
  selectedStructLeavingAtom.rglabel = null;
25414
- selectedStructLeavingAtom.label = 'H';
25471
+ selectedStructLeavingAtom.label = AtomLabel.H;
25415
25472
  var neighborHalfBondId = selectedStructLeavingAtom.neighbors[0];
25416
25473
  var selectedStructAttachmentAtomId = (_selectedStruct$halfB = selectedStruct.halfBonds.get(neighborHalfBondId)) === null || _selectedStruct$halfB === void 0 ? void 0 : _selectedStruct$halfB.end;
25417
- var attachmentPointName = getAttachmentPointLabel(i + 1);
25418
25474
  assert_1(selectedStructAttachmentAtomId !== undefined);
25419
25475
  assignedAttachmentPoints.set(attachmentPointName, [selectedStructAttachmentAtomId, selectedStructLeavingAtomId]);
25420
25476
  });
25477
+ var selectedPotentialLeavingAtoms = new Map();
25421
25478
  this.potentialLeavingAtoms.forEach(function (atomId) {
25422
- var _selectedStruct$atoms, _selectedStruct$atoms2, _currentStruct$halfBo;
25479
+ var _selectedStruct$atoms, _selectedStruct$atoms2;
25423
25480
  var leavingAtom = currentStruct.atoms.get(atomId);
25424
25481
  assert_1(leavingAtom);
25425
- var selectedStructLeavingAtom = leavingAtom.clone();
25482
+ var attachmentAtomId = -1;
25483
+ leavingAtom.neighbors.forEach(function (halfBondId) {
25484
+ var _selection$atoms3;
25485
+ var halfBond = currentStruct.halfBonds.get(halfBondId);
25486
+ assert_1(halfBond !== undefined);
25487
+ if ((_selection$atoms3 = selection.atoms) !== null && _selection$atoms3 !== void 0 && _selection$atoms3.includes(halfBond.end)) {
25488
+ attachmentAtomId = halfBond.end;
25489
+ }
25490
+ });
25491
+ if (attachmentAtomId === -1) {
25492
+ return;
25493
+ }
25494
+ var originalLeavingAtomId = originalToSelectedAtomsIdMap.get(atomId);
25495
+ var isLeavingAtomSelected = isNumber(originalLeavingAtomId);
25496
+ if (isLeavingAtomSelected) {
25497
+ var originalAttachmentAtomId = originalToSelectedAtomsIdMap.get(attachmentAtomId);
25498
+ if (!isNumber(originalAttachmentAtomId)) {
25499
+ return;
25500
+ }
25501
+ selectedPotentialLeavingAtoms.set(originalAttachmentAtomId, originalLeavingAtomId);
25502
+ return;
25503
+ }
25504
+ var selectedStructLeavingAtom = new Atom$2({
25505
+ label: AtomLabel.H,
25506
+ pp: leavingAtom.pp
25507
+ });
25426
25508
  selectedStructLeavingAtom.fragment = (_selectedStruct$atoms = (_selectedStruct$atoms2 = selectedStruct.atoms.get(0)) === null || _selectedStruct$atoms2 === void 0 ? void 0 : _selectedStruct$atoms2.fragment) !== null && _selectedStruct$atoms !== void 0 ? _selectedStruct$atoms : 0;
25427
25509
  var selectedStructLeavingAtomId = selectedStruct.atoms.add(selectedStructLeavingAtom);
25428
25510
  _this2.selectedToOriginalAtomsIdMap.set(selectedStructLeavingAtomId, atomId);
25429
- var neighborHalfBondId = leavingAtom === null || leavingAtom === void 0 ? void 0 : leavingAtom.neighbors[0];
25430
- assert_1(neighborHalfBondId !== undefined);
25431
- var attachmentAtomId = (_currentStruct$halfBo = currentStruct.halfBonds.get(neighborHalfBondId)) === null || _currentStruct$halfBo === void 0 ? void 0 : _currentStruct$halfBo.end;
25432
- assert_1(attachmentAtomId !== undefined);
25433
25511
  var selectedStructAttachmentAtomId = originalToSelectedAtomsIdMap.get(attachmentAtomId);
25434
25512
  assert_1(selectedStructAttachmentAtomId !== undefined);
25513
+ _this2.selectedToOriginalAtomsIdMap.set(selectedStructAttachmentAtomId, attachmentAtomId);
25435
25514
  var newBond = new Bond$2({
25436
25515
  type: Bond$2.PATTERN.TYPE.SINGLE,
25437
25516
  begin: selectedStructAttachmentAtomId,
25438
25517
  end: selectedStructLeavingAtomId
25439
25518
  });
25440
25519
  selectedStruct.bonds.add(newBond);
25441
- potentialAttachmentPoints.set(selectedStructAttachmentAtomId, selectedStructLeavingAtomId);
25442
- _this2.selectedToOriginalAtomsIdMap.set(selectedStructAttachmentAtomId, attachmentAtomId);
25520
+ var assignedAttachmentPointNames = Array.from(assignedAttachmentPoints.keys());
25521
+ var attachmentPointName = getNextFreeAttachmentPoint(assignedAttachmentPointNames, assignedAttachmentPointNames.length < sideAttachmentPointsNames.length);
25522
+ assignedAttachmentPoints.set(attachmentPointName, [selectedStructAttachmentAtomId, selectedStructLeavingAtomId]);
25443
25523
  });
25444
25524
  this.monomerCreationState = {
25445
25525
  assignedAttachmentPoints: assignedAttachmentPoints,
25446
- potentialAttachmentPoints: potentialAttachmentPoints
25526
+ potentialAttachmentPoints: selectedPotentialLeavingAtoms
25447
25527
  };
25448
25528
  this.originalStruct = currentStruct;
25449
25529
  this.struct(selectedStruct);
@@ -25480,8 +25560,6 @@ var Editor$3 = function () {
25480
25560
  leavingAtomId = _atomPairForLeavingGr2[1];
25481
25561
  var leavingAtom = this.render.ctab.molecule.atoms.get(leavingAtomId);
25482
25562
  assert_1(leavingAtom);
25483
- leavingAtom.label = 'H';
25484
- this.render.ctab.molecule.calcImplicitHydrogen(leavingAtomId);
25485
25563
  var attachmentPointName = getNextFreeAttachmentPoint(Array.from(this.monomerCreationState.assignedAttachmentPoints.keys()));
25486
25564
  this.monomerCreationState.assignedAttachmentPoints.set(attachmentPointName, atomPairForLeavingGroup);
25487
25565
  this.monomerCreationState.potentialAttachmentPoints["delete"](attachmentAtomId);
@@ -25501,8 +25579,8 @@ var Editor$3 = function () {
25501
25579
  }, {
25502
25580
  key: "saveNewMonomer",
25503
25581
  value: function saveNewMonomer(data) {
25504
- var _this$originalSelecti,
25505
- _this3 = this;
25582
+ var _this3 = this,
25583
+ _this$originalSelecti;
25506
25584
  if (!this.monomerCreationState) {
25507
25585
  throw new Error('Monomer creation wizard is not active, cannot save new monomer');
25508
25586
  }
@@ -25513,10 +25591,10 @@ var Editor$3 = function () {
25513
25591
  type = data.type,
25514
25592
  naturalAnalogue = data.naturalAnalogue;
25515
25593
  var attachmentPoints = [];
25516
- this.monomerCreationState.assignedAttachmentPoints.forEach(function (_ref, attachmentPointName) {
25517
- var _ref2 = _slicedToArray$1(_ref, 2),
25518
- attachmentAtomId = _ref2[0],
25519
- leavingAtomId = _ref2[1];
25594
+ this.monomerCreationState.assignedAttachmentPoints.forEach(function (_ref9, attachmentPointName) {
25595
+ var _ref10 = _slicedToArray$1(_ref9, 2),
25596
+ attachmentAtomId = _ref10[0],
25597
+ leavingAtomId = _ref10[1];
25520
25598
  var attachmentPoint = {
25521
25599
  attachmentAtom: attachmentAtomId,
25522
25600
  leavingGroup: {
@@ -25555,6 +25633,20 @@ var Editor$3 = function () {
25555
25633
  Monomer = _monomerFactory2[0];
25556
25634
  var monomerPosition = new Vec2((this.selectionBBox.min.x + this.selectionBBox.max.x) / 2, (this.selectionBBox.min.y + this.selectionBBox.max.y) / 2);
25557
25635
  var monomer = new Monomer(monomerItem, monomerPosition);
25636
+ var finalAttachmentPoints = this.monomerCreationState.assignedAttachmentPoints;
25637
+ finalAttachmentPoints.forEach(function (atomPair) {
25638
+ var _atomPair2 = _slicedToArray$1(atomPair, 2),
25639
+ leavingAtomId = _atomPair2[1];
25640
+ var leavingAtom = _this3.struct().atoms.get(leavingAtomId);
25641
+ assert_1(leavingAtom);
25642
+ var originalLeavingAtomId = _this3.selectedToOriginalAtomsIdMap.get(leavingAtomId);
25643
+ assert_1(isNumber(originalLeavingAtomId));
25644
+ var originalLeavingAtom = _this3.originalStruct.atoms.get(originalLeavingAtomId);
25645
+ assert_1(originalLeavingAtom);
25646
+ originalLeavingAtom.rglabel = null;
25647
+ originalLeavingAtom.label = leavingAtom.label;
25648
+ _this3.originalStruct.calcImplicitHydrogen(originalLeavingAtomId);
25649
+ });
25558
25650
  this.closeMonomerCreationWizard();
25559
25651
  (_this$originalSelecti = this.originalSelection.atoms) === null || _this$originalSelecti === void 0 || _this$originalSelecti.forEach(function (atomId) {
25560
25652
  var atom = _this3.render.ctab.molecule.atoms.get(atomId);
@@ -25563,9 +25655,19 @@ var Editor$3 = function () {
25563
25655
  }
25564
25656
  });
25565
25657
  var sGroupAttachmentPoints = MacromoleculesConverter.convertMonomerAttachmentPointsToSGroupAttachmentPoints(monomer, this.selectedToOriginalAtomsIdMap);
25658
+ sGroupAttachmentPoints.forEach(function (ap) {
25659
+ _this3.render.ctab.molecule.bonds.forEach(function (bond) {
25660
+ var _this3$originalSelect, _this3$originalSelect2;
25661
+ if ((bond.begin === ap.atomId || bond.end === ap.atomId) && (!((_this3$originalSelect = _this3.originalSelection.atoms) !== null && _this3$originalSelect !== void 0 && _this3$originalSelect.includes(bond.begin)) || !((_this3$originalSelect2 = _this3.originalSelection.atoms) !== null && _this3$originalSelect2 !== void 0 && _this3$originalSelect2.includes(bond.end)))) {
25662
+ bond.beginSuperatomAttachmentPointNumber = ap.attachmentPointNumber;
25663
+ }
25664
+ });
25665
+ });
25566
25666
  var action = fromSgroupAddition(this.render.ctab, SGroup$1.TYPES.SUP, this.originalSelection.atoms, {
25567
25667
  expanded: true
25568
25668
  }, this.render.ctab.molecule.sgroups.newId(), sGroupAttachmentPoints, monomer.position, true, monomer.monomerItem.props.MonomerName, null, monomer);
25669
+ this.render.ctab.molecule.clearFragments();
25670
+ this.render.ctab.molecule.markFragments();
25569
25671
  this.update(action);
25570
25672
  var templateRoot = monomerTemplate.root,
25571
25673
  templateData = _objectWithoutProperties(monomerTemplate, _excluded$p);
@@ -25614,6 +25716,21 @@ var Editor$3 = function () {
25614
25716
  this.monomerCreationState = Object.assign({}, this.monomerCreationState);
25615
25717
  this.render.update(true);
25616
25718
  }
25719
+ }, {
25720
+ key: "cleanupCloseAttachmentPointEditPopup",
25721
+ value: function cleanupCloseAttachmentPointEditPopup() {
25722
+ assert_1(this.monomerCreationState);
25723
+ this.monomerCreationState.clickedAttachmentPoint = null;
25724
+ this.render.update(true);
25725
+ }
25726
+ }, {
25727
+ key: "setProblematicAttachmentPoints",
25728
+ value: function setProblematicAttachmentPoints(problematicPoints) {
25729
+ assert_1(this.monomerCreationState);
25730
+ this.monomerCreationState.problematicAttachmentPoints = problematicPoints;
25731
+ this.monomerCreationState = Object.assign({}, this.monomerCreationState);
25732
+ this.render.update(true);
25733
+ }
25617
25734
  }, {
25618
25735
  key: "selection",
25619
25736
  value: function selection(ci) {
@@ -26033,10 +26150,10 @@ function domEventSetup(editor, clientArea) {
26033
26150
  eventName: 'mouseover',
26034
26151
  toolEventHandler: 'mouseover'
26035
26152
  }];
26036
- trackedDomEvents.forEach(function (_ref3) {
26037
- var target = _ref3.target,
26038
- eventName = _ref3.eventName,
26039
- toolEventHandler = _ref3.toolEventHandler;
26153
+ trackedDomEvents.forEach(function (_ref11) {
26154
+ var target = _ref11.target,
26155
+ eventName = _ref11.eventName,
26156
+ toolEventHandler = _ref11.toolEventHandler;
26040
26157
  editor.event[eventName] = new DOMSubscription();
26041
26158
  var subs = editor.event[eventName];
26042
26159
  target.addEventListener(eventName, function () {
@@ -26410,7 +26527,7 @@ var useMakeLeavingGroupAtomMenuItem = function useMakeLeavingGroupAtomMenuItem(_
26410
26527
  var attachmentPointName = Array.from(assignedAttachmentPoints.keys()).find(function (key) {
26411
26528
  var atomsPair = assignedAttachmentPoints.get(key);
26412
26529
  assert_1(atomsPair);
26413
- return atomsPair.includes(selectedAtomId);
26530
+ return atomsPair[1] === selectedAtomId;
26414
26531
  });
26415
26532
  var isAtomAssignedAttachmentPoint = Boolean(attachmentPointName);
26416
26533
  if (!isAtomPotentialAttachmentPoint && !isAtomAssignedAttachmentPoint) {
@@ -26441,20 +26558,22 @@ var useMakeLeavingGroupAtomMenuItem = function useMakeLeavingGroupAtomMenuItem(_
26441
26558
  };
26442
26559
  return isAtomAssignedAttachmentPoint ? jsxs(Fragment, {
26443
26560
  children: [jsxs(Item, {
26561
+ "data-testid": "edit-connection-point",
26562
+ onClick: handleEditClick,
26444
26563
  children: [jsx(Icon, {
26445
26564
  name: "editMenu",
26446
- className: styles$m.icon,
26447
- onClick: handleEditClick
26565
+ className: styles$m.icon
26448
26566
  }), "Edit connection point"]
26449
26567
  }), jsxs(Item, {
26568
+ "data-testid": "remove-assignment",
26569
+ onClick: handleRemoveClick,
26450
26570
  children: [jsx(Icon, {
26451
26571
  name: "deleteMenu",
26452
- className: styles$m.icon,
26453
- onClick: handleRemoveClick
26572
+ className: styles$m.icon
26454
26573
  }), "Remove assignment"]
26455
26574
  })]
26456
26575
  }) : jsxs(Item, _objectSpread$S(_objectSpread$S({}, props), {}, {
26457
- "data-testid": "Assign as a leaving group",
26576
+ "data-testid": "assign-as-a-leaving-group",
26458
26577
  onClick: handleMakeLeavingGroupAtomClick,
26459
26578
  disabled: attachmentPointsLimitReached,
26460
26579
  children: [jsx(Icon, {
@@ -28555,20 +28674,23 @@ var attachmentPointNameOptions = Array.from({
28555
28674
  };
28556
28675
  });
28557
28676
  var attachmentPointAtomOptions = [{
28558
- value: 'H',
28677
+ value: AtomLabel.H,
28559
28678
  label: 'H'
28560
28679
  }, {
28561
- value: 'O',
28680
+ value: AtomLabel.O,
28562
28681
  label: 'OH'
28563
28682
  }, {
28564
- value: 'N',
28683
+ value: AtomLabel.N,
28565
28684
  label: 'NH2'
28566
28685
  }, {
28567
- value: 'Cl',
28686
+ value: AtomLabel.Cl,
28568
28687
  label: 'Cl'
28569
28688
  }, {
28570
- value: 'F',
28689
+ value: AtomLabel.F,
28571
28690
  label: 'F'
28691
+ }, {
28692
+ value: AtomLabel.C,
28693
+ label: 'CH3'
28572
28694
  }];
28573
28695
  var AttachmentPointEditPopup = function AttachmentPointEditPopup(_ref) {
28574
28696
  var data = _ref.data,
@@ -28660,7 +28782,8 @@ var styles$f = {"attachmentPoint":"AttachmentPoint-module_attachmentPoint__6KD5K
28660
28782
 
28661
28783
  var AttachmentPoint = function AttachmentPoint(_ref) {
28662
28784
  var name = _ref.name,
28663
- atomLabel = _ref.atomLabel;
28785
+ atomLabel = _ref.atomLabel,
28786
+ implicitH = _ref.implicitH;
28664
28787
  return jsx("div", {
28665
28788
  className: styles$f.attachmentPoint,
28666
28789
  children: jsxs("p", {
@@ -28668,7 +28791,13 @@ var AttachmentPoint = function AttachmentPoint(_ref) {
28668
28791
  children: [jsx("span", {
28669
28792
  className: styles$f.attachmentPointIndex,
28670
28793
  children: name
28671
- }), "\xA0(", atomLabel, ")"]
28794
+ }), "\xA0", jsxs("span", {
28795
+ children: ["(", implicitH > 1 && jsxs(Fragment, {
28796
+ children: ["H", jsx("sub", {
28797
+ children: implicitH
28798
+ })]
28799
+ }), atomLabel, ")"]
28800
+ })]
28672
28801
  })
28673
28802
  });
28674
28803
  };
@@ -28795,31 +28924,50 @@ var validateInputs = function validateInputs(values) {
28795
28924
  };
28796
28925
  var validateAttachmentPoints = function validateAttachmentPoints(attachmentPoints) {
28797
28926
  var notifications = new Map();
28927
+ var problematicAttachmentPoints = new Set();
28798
28928
  if (attachmentPoints.length === 0) {
28799
28929
  notifications.set('noAttachmentPoints', {
28800
28930
  type: 'error',
28801
28931
  message: NotificationMessages.noAttachmentPoints
28802
28932
  });
28803
- return notifications;
28933
+ return {
28934
+ notifications: notifications,
28935
+ problematicAttachmentPoints: problematicAttachmentPoints
28936
+ };
28804
28937
  }
28805
- var attachmentPointNumbers = attachmentPoints.map(getAttachmentPointNumberFromLabel);
28806
- attachmentPointNumbers.sort(function (a, b) {
28807
- return a - b;
28938
+ var sideAttachmentPoints = attachmentPoints.filter(function (attachmentPointName) {
28939
+ var pointNumber = getAttachmentPointNumberFromLabel(attachmentPointName);
28940
+ return pointNumber > 2;
28808
28941
  });
28809
- var startingIndex = 0;
28810
- while (attachmentPointNumbers[startingIndex] <= 2) {
28811
- startingIndex++;
28942
+ if (sideAttachmentPoints.length === 0) {
28943
+ return {
28944
+ notifications: notifications,
28945
+ problematicAttachmentPoints: problematicAttachmentPoints
28946
+ };
28812
28947
  }
28813
- for (var i = startingIndex; i < attachmentPointNumbers.length; i++) {
28814
- if (attachmentPointNumbers[i] - attachmentPointNumbers[i - 1] > 1) {
28815
- notifications.set('incorrectAttachmentPointsOrder', {
28816
- type: 'error',
28817
- message: NotificationMessages.incorrectAttachmentPointsOrder
28818
- });
28819
- break;
28948
+ var expectedSequence = [];
28949
+ for (var i = 3; i < 3 + sideAttachmentPoints.length; i++) {
28950
+ expectedSequence.push(i);
28951
+ }
28952
+ var actualNumbers = sideAttachmentPoints.map(getAttachmentPointNumberFromLabel).sort(function (a, b) {
28953
+ return a - b;
28954
+ });
28955
+ actualNumbers.forEach(function (actualNumber) {
28956
+ if (!expectedSequence.includes(actualNumber)) {
28957
+ var problematicPointName = getAttachmentPointLabel(actualNumber);
28958
+ problematicAttachmentPoints.add(problematicPointName);
28820
28959
  }
28960
+ });
28961
+ if (problematicAttachmentPoints.size > 0) {
28962
+ notifications.set('incorrectAttachmentPointsOrder', {
28963
+ type: 'error',
28964
+ message: NotificationMessages.incorrectAttachmentPointsOrder
28965
+ });
28821
28966
  }
28822
- return notifications;
28967
+ return {
28968
+ notifications: notifications,
28969
+ problematicAttachmentPoints: problematicAttachmentPoints
28970
+ };
28823
28971
  };
28824
28972
  var MonomerCreationWizard = function MonomerCreationWizard() {
28825
28973
  var _useAppContext = useAppContext(),
@@ -28916,6 +29064,7 @@ var MonomerCreationWizard = function MonomerCreationWizard() {
28916
29064
  };
28917
29065
  var handleAttachmentPointEditPopupClose = function handleAttachmentPointEditPopupClose() {
28918
29066
  setAttachmentPointEditPopupData(null);
29067
+ editor.cleanupCloseAttachmentPointEditPopup();
28919
29068
  };
28920
29069
  var handleDiscard = function handleDiscard() {
28921
29070
  editor.closeMonomerCreationWizard();
@@ -28940,12 +29089,15 @@ var MonomerCreationWizard = function MonomerCreationWizard() {
28940
29089
  return;
28941
29090
  }
28942
29091
  assert_1(editor.monomerCreationState);
28943
- var attachmentPointsNotifications = validateAttachmentPoints(Array.from(editor.monomerCreationState.assignedAttachmentPoints.keys()));
29092
+ var _validateAttachmentPo = validateAttachmentPoints(Array.from(editor.monomerCreationState.assignedAttachmentPoints.keys())),
29093
+ attachmentPointsNotifications = _validateAttachmentPo.notifications,
29094
+ problematicAttachmentPoints = _validateAttachmentPo.problematicAttachmentPoints;
28944
29095
  if (attachmentPointsNotifications.size > 0) {
28945
29096
  wizardStateDispatch({
28946
29097
  type: 'SetNotifications',
28947
29098
  notifications: attachmentPointsNotifications
28948
29099
  });
29100
+ editor.setProblematicAttachmentPoints(problematicAttachmentPoints);
28949
29101
  return;
28950
29102
  }
28951
29103
  editor.saveNewMonomer({
@@ -28955,6 +29107,7 @@ var MonomerCreationWizard = function MonomerCreationWizard() {
28955
29107
  naturalAnalogue: naturalAnalogue
28956
29108
  });
28957
29109
  resetWizard();
29110
+ editor.setProblematicAttachmentPoints(new Set());
28958
29111
  };
28959
29112
  var monomerCreationState = useSelector(editorMonomerCreationStateSelector);
28960
29113
  if (!monomerCreationState) {
@@ -28970,12 +29123,14 @@ var MonomerCreationWizard = function MonomerCreationWizard() {
28970
29123
  if (!atom) {
28971
29124
  return {
28972
29125
  name: attachmentPointName,
28973
- atomLabel: 'H'
29126
+ atomLabel: 'H',
29127
+ implicitH: 0
28974
29128
  };
28975
29129
  }
28976
29130
  return {
28977
29131
  name: attachmentPointName,
28978
- atomLabel: atom.label
29132
+ atomLabel: atom.label,
29133
+ implicitH: atom.implicitH
28979
29134
  };
28980
29135
  });
28981
29136
  var ketcherEditorRootElement = document.querySelector(KETCHER_ROOT_NODE_CSS_SELECTOR);
@@ -29075,10 +29230,12 @@ var MonomerCreationWizard = function MonomerCreationWizard() {
29075
29230
  className: styles$l.attachmentPoints,
29076
29231
  children: attachmentPointsData.map(function (_ref5) {
29077
29232
  var name = _ref5.name,
29078
- atomLabel = _ref5.atomLabel;
29233
+ atomLabel = _ref5.atomLabel,
29234
+ implicitH = _ref5.implicitH;
29079
29235
  return jsx(AttachmentPoint, {
29080
29236
  name: name,
29081
- atomLabel: atomLabel
29237
+ atomLabel: atomLabel,
29238
+ implicitH: implicitH
29082
29239
  }, name);
29083
29240
  })
29084
29241
  })]
@@ -37089,8 +37246,8 @@ var KetcherBuilder = function () {
37089
37246
  cleanup = initApp(prevKetcherId, ketcherId, element, appRoot, staticResourcesUrl, {
37090
37247
  buttons: buttons || {},
37091
37248
  errorHandler: errorHandler || null,
37092
- version: "3.8.0-rc.1" ,
37093
- buildDate: "2025-09-03T08:19:34" ,
37249
+ version: "3.8.0-rc.3" ,
37250
+ buildDate: "2025-09-16T18:11:14" ,
37094
37251
  buildNumber: '',
37095
37252
  customButtons: customButtons || []
37096
37253
  }, structService, resolve, togglerComponent);
@@ -37385,7 +37542,7 @@ var ModeControl = function ModeControl(_ref3) {
37385
37542
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
37386
37543
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
37387
37544
  var MacromoleculesEditorComponent = lazy(function () {
37388
- return import('./index.modern-1aebb8e6.js');
37545
+ return import('./index.modern-ea9bb715.js');
37389
37546
  });
37390
37547
  var Editor = function Editor(props) {
37391
37548
  var _useState = useState(false),