ketcher-react 2.19.0-rc.1 → 2.19.0-rc.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.
- package/dist/components/Accordion/Accordion.d.ts +1 -1
- package/dist/components/Accordion/types.d.ts +1 -0
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.js +4124 -4106
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1143 -1125
- package/dist/index.modern.js.map +1 -1
- package/dist/script/editor/tool/template.d.ts +2 -1
- package/dist/script/editor/tool/templatePreview.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -24,7 +24,7 @@ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
|
24
24
|
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
25
25
|
import _classCallCheck$2 from '@babel/runtime/helpers/classCallCheck';
|
|
26
26
|
import _createClass$2 from '@babel/runtime/helpers/createClass';
|
|
27
|
-
import { KetSerializer, MolSerializer, KetcherLogger, Ketcher, defaultBondThickness, FormatterFactory, notifyRequestCompleted, isControlKey, StereLabelStyleType, StereoColoringType, ShowHydrogenLabels, ShowHydrogenLabelNames, SettingsManager, SdfSerializer, KETCHER_SAVED_OPTIONS_KEY, Bond as Bond$2, Elements, AtomList, getAtomType, StereoLabel, isAttachmentBond, Atom as Atom$2, findStereoAtoms, RxnArrowMode, SimpleObjectMode, SGroup as SGroup$1, Pile, getStereoAtomsMap, identifyStructFormat, SupportedFormat, ChemicalMimeType, RenderStruct, Struct, shortcutStr, MonomerMicromolecule, FunctionalGroupsProvider, SaltsAndSolventsProvider, KetcherAsyncEvents, ElementColor, generateMenuShortcuts, Vec2, Scale, fromMultipleMove, FunctionalGroup, fromSgroupDeletion, fromFragmentDeletion, mergeMapOfItemsToSet, vectorUtils, fromBondAddition, Action, fromAtomAddition, fromAtomsAttrs, checkOverlapping, fromSeveralSgroupAddition, expandSGroupWithMultipleAttachmentPoint, SgContexts, fromSgroupAction, fromItemsFuse, ReBond, setExpandSGroup, fromBondsAttrs, OperationType, ReStruct, fromSimpleObjectResizing, fromArrowResizing, getItemsToFuse, getHoverToFuse, fromTextDeletion, fromTextUpdating, CoordinateTransformation, formatProperties, ketcherProvider, runAsyncAction, getStructure, initHotKeys, keyNorm, Fragment as Fragment$1, fromRGroupAttachmentPointUpdate, fromOneBondDeletion, bondChangingAction, fromChain, fromStereoFlagUpdate, fromOneAtomDeletion, fromArrowDeletion, fromPlusDeletion, fromSimpleObjectDeletion, fromRGroupAttachmentPointDeletion, fromPaste,
|
|
27
|
+
import { KetSerializer, MolSerializer, KetcherLogger, Ketcher, defaultBondThickness, FormatterFactory, notifyRequestCompleted, isControlKey, StereLabelStyleType, StereoColoringType, ShowHydrogenLabels, ShowHydrogenLabelNames, SettingsManager, SdfSerializer, KETCHER_SAVED_OPTIONS_KEY, Bond as Bond$2, Elements, AtomList, getAtomType, StereoLabel, isAttachmentBond, Atom as Atom$2, findStereoAtoms, RxnArrowMode, SimpleObjectMode, SGroup as SGroup$1, Pile, getStereoAtomsMap, identifyStructFormat, SupportedFormat, ChemicalMimeType, RenderStruct, Struct, shortcutStr, MonomerMicromolecule, FunctionalGroupsProvider, SaltsAndSolventsProvider, KetcherAsyncEvents, ElementColor, generateMenuShortcuts, Vec2, Scale, fromMultipleMove, FunctionalGroup, fromSgroupDeletion, fromFragmentDeletion, mergeMapOfItemsToSet, vectorUtils, fromBondAddition, Action, fromAtomAddition, fromAtomsAttrs, checkOverlapping, fromSeveralSgroupAddition, expandSGroupWithMultipleAttachmentPoint, SgContexts, fromSgroupAction, fromItemsFuse, ReBond, setExpandSGroup, fromBondsAttrs, OperationType, ReStruct, fromSimpleObjectResizing, fromArrowResizing, getItemsToFuse, getHoverToFuse, fromTextDeletion, fromTextUpdating, CoordinateTransformation, fromTemplateOnCanvas, fromTemplateOnBondAction, fromTemplateOnAtom, BondAttr, AtomAttr, formatProperties, ketcherProvider, runAsyncAction, getStructure, initHotKeys, keyNorm, Fragment as Fragment$1, fromRGroupAttachmentPointUpdate, fromOneBondDeletion, bondChangingAction, fromChain, fromStereoFlagUpdate, fromOneAtomDeletion, fromArrowDeletion, fromPlusDeletion, fromSimpleObjectDeletion, fromRGroupAttachmentPointDeletion, fromPaste, RGroup as RGroup$2, fromRGroupFragment, fromUpdateIfThen, fromRGroupAttrs, fromArrowAddition, fromPlusAddition, fromRotate, fromFlip, fromSimpleObjectAddition, fromTextCreation, fromHighlightCreate, fromHighlightClear, fromNewCanvas, Render, fromDescriptorsAlign, atomGetAttr, genericsList, getAtomCustomQuery, getFormatMimeTypeByFileName, getPropertiesByFormat, StereoFlag, getPropertiesByImgFormat, b64toBlob, Generics, TextCommand, DefaultStructServiceOptions } from 'ketcher-core';
|
|
28
28
|
import * as React from 'react';
|
|
29
29
|
import React__default, { createRef, Component, useRef, useEffect, useLayoutEffect, useState, useMemo, createElement, forwardRef, useCallback, Fragment as Fragment$2, PureComponent, lazy, Suspense } from 'react';
|
|
30
30
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
@@ -3140,7 +3140,7 @@ function load(struct, options) {
|
|
|
3140
3140
|
}));
|
|
3141
3141
|
}
|
|
3142
3142
|
} else {
|
|
3143
|
-
editor.struct(parsedStruct, method === 'layout'
|
|
3143
|
+
editor.struct(parsedStruct, method === 'layout');
|
|
3144
3144
|
}
|
|
3145
3145
|
editor.zoomAccordingContent(parsedStruct);
|
|
3146
3146
|
isIndigoFunctionCalled = !!method;
|
|
@@ -3595,7 +3595,7 @@ var zoom = {
|
|
|
3595
3595
|
|
|
3596
3596
|
var openHelpLink = function openHelpLink() {
|
|
3597
3597
|
var _window$open;
|
|
3598
|
-
return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.19.0-rc.
|
|
3598
|
+
return (_window$open = window.open("https://github.com/epam/ketcher/blob/".concat("v2.19.0-rc.2\n", "/documentation/help.md#ketcher-overview"))) === null || _window$open === void 0 ? void 0 : _window$open.focus();
|
|
3599
3599
|
};
|
|
3600
3600
|
var help = {
|
|
3601
3601
|
help: {
|
|
@@ -8019,13 +8019,15 @@ var Accordion$1 = function Accordion(_ref) {
|
|
|
8019
8019
|
details = _ref.details,
|
|
8020
8020
|
expanded = _ref.expanded,
|
|
8021
8021
|
className = _ref.className,
|
|
8022
|
-
onSummaryClick = _ref.onSummaryClick
|
|
8022
|
+
onSummaryClick = _ref.onSummaryClick,
|
|
8023
|
+
dataTestIdDetails = _ref.dataTestIdDetails;
|
|
8023
8024
|
return jsxs(Container, {
|
|
8024
8025
|
className: className,
|
|
8025
8026
|
children: [jsx(SummaryContainer, {
|
|
8026
8027
|
onClick: onSummaryClick,
|
|
8027
8028
|
children: summary
|
|
8028
8029
|
}), jsx(DetailsContainer, {
|
|
8030
|
+
"data-testid": dataTestIdDetails,
|
|
8029
8031
|
expanded: expanded,
|
|
8030
8032
|
children: details
|
|
8031
8033
|
})]
|
|
@@ -9296,15 +9298,27 @@ var shams = function hasToStringTagShams() {
|
|
|
9296
9298
|
return shams$1() && !!Symbol.toStringTag;
|
|
9297
9299
|
};
|
|
9298
9300
|
|
|
9301
|
+
/** @type {import('.')} */
|
|
9302
|
+
var esErrors = Error;
|
|
9303
|
+
|
|
9304
|
+
/** @type {import('./eval')} */
|
|
9305
|
+
var _eval = EvalError;
|
|
9306
|
+
|
|
9299
9307
|
/** @type {import('./range')} */
|
|
9300
9308
|
var range = RangeError;
|
|
9301
9309
|
|
|
9310
|
+
/** @type {import('./ref')} */
|
|
9311
|
+
var ref = ReferenceError;
|
|
9312
|
+
|
|
9302
9313
|
/** @type {import('./syntax')} */
|
|
9303
9314
|
var syntax = SyntaxError;
|
|
9304
9315
|
|
|
9305
9316
|
/** @type {import('./type')} */
|
|
9306
9317
|
var type = TypeError;
|
|
9307
9318
|
|
|
9319
|
+
/** @type {import('./uri')} */
|
|
9320
|
+
var uri = URIError;
|
|
9321
|
+
|
|
9308
9322
|
var origSymbol = typeof Symbol !== 'undefined' && Symbol;
|
|
9309
9323
|
|
|
9310
9324
|
|
|
@@ -9318,13 +9332,17 @@ var hasSymbols$3 = function hasNativeSymbols() {
|
|
|
9318
9332
|
};
|
|
9319
9333
|
|
|
9320
9334
|
var test = {
|
|
9335
|
+
__proto__: null,
|
|
9321
9336
|
foo: {}
|
|
9322
9337
|
};
|
|
9323
9338
|
|
|
9324
9339
|
var $Object = Object;
|
|
9325
9340
|
|
|
9341
|
+
/** @type {import('.')} */
|
|
9326
9342
|
var hasProto$1 = function hasProto() {
|
|
9327
|
-
|
|
9343
|
+
// @ts-expect-error: TS errors on an inherited property for some reason
|
|
9344
|
+
return { __proto__: test }.foo === test.foo
|
|
9345
|
+
&& !(test instanceof $Object);
|
|
9328
9346
|
};
|
|
9329
9347
|
|
|
9330
9348
|
/* eslint no-invalid-this: 1 */
|
|
@@ -9416,14 +9434,26 @@ var call = Function.prototype.call;
|
|
|
9416
9434
|
var $hasOwn = Object.prototype.hasOwnProperty;
|
|
9417
9435
|
|
|
9418
9436
|
|
|
9419
|
-
/** @type {(
|
|
9437
|
+
/** @type {import('.')} */
|
|
9420
9438
|
var hasown = functionBind.call(call, $hasOwn);
|
|
9421
9439
|
|
|
9440
|
+
var $Error = esErrors;
|
|
9441
|
+
|
|
9442
|
+
var $EvalError = _eval;
|
|
9443
|
+
|
|
9422
9444
|
var $RangeError = range;
|
|
9423
9445
|
|
|
9424
|
-
var $
|
|
9446
|
+
var $ReferenceError = ref;
|
|
9447
|
+
|
|
9448
|
+
var $SyntaxError = syntax;
|
|
9449
|
+
|
|
9450
|
+
var $TypeError = type;
|
|
9425
9451
|
|
|
9426
|
-
var $
|
|
9452
|
+
var $URIError = uri;
|
|
9453
|
+
|
|
9454
|
+
var require$$1 = hasProto$1;
|
|
9455
|
+
|
|
9456
|
+
var hasOwn = hasown;
|
|
9427
9457
|
|
|
9428
9458
|
var undefined$1;
|
|
9429
9459
|
|
|
@@ -9431,6 +9461,10 @@ var undefined$1;
|
|
|
9431
9461
|
|
|
9432
9462
|
|
|
9433
9463
|
|
|
9464
|
+
|
|
9465
|
+
|
|
9466
|
+
|
|
9467
|
+
|
|
9434
9468
|
var $Function = Function;
|
|
9435
9469
|
|
|
9436
9470
|
// eslint-disable-next-line consistent-return
|
|
@@ -9450,7 +9484,7 @@ if ($gOPD$1) {
|
|
|
9450
9484
|
}
|
|
9451
9485
|
|
|
9452
9486
|
var throwTypeError = function () {
|
|
9453
|
-
throw new $TypeError
|
|
9487
|
+
throw new $TypeError();
|
|
9454
9488
|
};
|
|
9455
9489
|
var ThrowTypeError = $gOPD$1
|
|
9456
9490
|
? (function () {
|
|
@@ -9470,7 +9504,7 @@ var ThrowTypeError = $gOPD$1
|
|
|
9470
9504
|
: throwTypeError;
|
|
9471
9505
|
|
|
9472
9506
|
var hasSymbols$2 = hasSymbols$3();
|
|
9473
|
-
var hasProto =
|
|
9507
|
+
var hasProto = require$$1();
|
|
9474
9508
|
|
|
9475
9509
|
var getProto$1 = Object.getPrototypeOf || (
|
|
9476
9510
|
hasProto
|
|
@@ -9504,9 +9538,9 @@ var INTRINSICS = {
|
|
|
9504
9538
|
'%decodeURIComponent%': decodeURIComponent,
|
|
9505
9539
|
'%encodeURI%': encodeURI,
|
|
9506
9540
|
'%encodeURIComponent%': encodeURIComponent,
|
|
9507
|
-
'%Error%': Error,
|
|
9541
|
+
'%Error%': $Error,
|
|
9508
9542
|
'%eval%': eval, // eslint-disable-line no-eval
|
|
9509
|
-
'%EvalError%': EvalError,
|
|
9543
|
+
'%EvalError%': $EvalError,
|
|
9510
9544
|
'%Float32Array%': typeof Float32Array === 'undefined' ? undefined$1 : Float32Array,
|
|
9511
9545
|
'%Float64Array%': typeof Float64Array === 'undefined' ? undefined$1 : Float64Array,
|
|
9512
9546
|
'%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined$1 : FinalizationRegistry,
|
|
@@ -9529,7 +9563,7 @@ var INTRINSICS = {
|
|
|
9529
9563
|
'%Promise%': typeof Promise === 'undefined' ? undefined$1 : Promise,
|
|
9530
9564
|
'%Proxy%': typeof Proxy === 'undefined' ? undefined$1 : Proxy,
|
|
9531
9565
|
'%RangeError%': $RangeError,
|
|
9532
|
-
'%ReferenceError%': ReferenceError,
|
|
9566
|
+
'%ReferenceError%': $ReferenceError,
|
|
9533
9567
|
'%Reflect%': typeof Reflect === 'undefined' ? undefined$1 : Reflect,
|
|
9534
9568
|
'%RegExp%': RegExp,
|
|
9535
9569
|
'%Set%': typeof Set === 'undefined' ? undefined$1 : Set,
|
|
@@ -9538,15 +9572,15 @@ var INTRINSICS = {
|
|
|
9538
9572
|
'%String%': String,
|
|
9539
9573
|
'%StringIteratorPrototype%': hasSymbols$2 && getProto$1 ? getProto$1(''[Symbol.iterator]()) : undefined$1,
|
|
9540
9574
|
'%Symbol%': hasSymbols$2 ? Symbol : undefined$1,
|
|
9541
|
-
'%SyntaxError%': $SyntaxError
|
|
9575
|
+
'%SyntaxError%': $SyntaxError,
|
|
9542
9576
|
'%ThrowTypeError%': ThrowTypeError,
|
|
9543
9577
|
'%TypedArray%': TypedArray,
|
|
9544
|
-
'%TypeError%': $TypeError
|
|
9578
|
+
'%TypeError%': $TypeError,
|
|
9545
9579
|
'%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined$1 : Uint8Array,
|
|
9546
9580
|
'%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined$1 : Uint8ClampedArray,
|
|
9547
9581
|
'%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined$1 : Uint16Array,
|
|
9548
9582
|
'%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined$1 : Uint32Array,
|
|
9549
|
-
'%URIError%': URIError,
|
|
9583
|
+
'%URIError%': $URIError,
|
|
9550
9584
|
'%WeakMap%': typeof WeakMap === 'undefined' ? undefined$1 : WeakMap,
|
|
9551
9585
|
'%WeakRef%': typeof WeakRef === 'undefined' ? undefined$1 : WeakRef,
|
|
9552
9586
|
'%WeakSet%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet
|
|
@@ -9657,9 +9691,9 @@ var stringToPath = function stringToPath(string) {
|
|
|
9657
9691
|
var first = $strSlice(string, 0, 1);
|
|
9658
9692
|
var last = $strSlice(string, -1);
|
|
9659
9693
|
if (first === '%' && last !== '%') {
|
|
9660
|
-
throw new $SyntaxError
|
|
9694
|
+
throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
|
|
9661
9695
|
} else if (last === '%' && first !== '%') {
|
|
9662
|
-
throw new $SyntaxError
|
|
9696
|
+
throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
|
|
9663
9697
|
}
|
|
9664
9698
|
var result = [];
|
|
9665
9699
|
$replace(string, rePropName, function (match, number, quote, subString) {
|
|
@@ -9672,18 +9706,18 @@ var stringToPath = function stringToPath(string) {
|
|
|
9672
9706
|
var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
|
|
9673
9707
|
var intrinsicName = name;
|
|
9674
9708
|
var alias;
|
|
9675
|
-
if (
|
|
9709
|
+
if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
|
|
9676
9710
|
alias = LEGACY_ALIASES[intrinsicName];
|
|
9677
9711
|
intrinsicName = '%' + alias[0] + '%';
|
|
9678
9712
|
}
|
|
9679
9713
|
|
|
9680
|
-
if (
|
|
9714
|
+
if (hasOwn(INTRINSICS, intrinsicName)) {
|
|
9681
9715
|
var value = INTRINSICS[intrinsicName];
|
|
9682
9716
|
if (value === needsEval) {
|
|
9683
9717
|
value = doEval(intrinsicName);
|
|
9684
9718
|
}
|
|
9685
9719
|
if (typeof value === 'undefined' && !allowMissing) {
|
|
9686
|
-
throw new $TypeError
|
|
9720
|
+
throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
|
|
9687
9721
|
}
|
|
9688
9722
|
|
|
9689
9723
|
return {
|
|
@@ -9693,19 +9727,19 @@ var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
|
|
|
9693
9727
|
};
|
|
9694
9728
|
}
|
|
9695
9729
|
|
|
9696
|
-
throw new $SyntaxError
|
|
9730
|
+
throw new $SyntaxError('intrinsic ' + name + ' does not exist!');
|
|
9697
9731
|
};
|
|
9698
9732
|
|
|
9699
9733
|
var getIntrinsic = function GetIntrinsic(name, allowMissing) {
|
|
9700
9734
|
if (typeof name !== 'string' || name.length === 0) {
|
|
9701
|
-
throw new $TypeError
|
|
9735
|
+
throw new $TypeError('intrinsic name must be a non-empty string');
|
|
9702
9736
|
}
|
|
9703
9737
|
if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
|
|
9704
|
-
throw new $TypeError
|
|
9738
|
+
throw new $TypeError('"allowMissing" argument must be a boolean');
|
|
9705
9739
|
}
|
|
9706
9740
|
|
|
9707
9741
|
if ($exec(/^%?[^%]*%?$/, name) === null) {
|
|
9708
|
-
throw new $SyntaxError
|
|
9742
|
+
throw new $SyntaxError('`%` may not be present anywhere but at the beginning and end of the intrinsic name');
|
|
9709
9743
|
}
|
|
9710
9744
|
var parts = stringToPath(name);
|
|
9711
9745
|
var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
|
|
@@ -9732,7 +9766,7 @@ var getIntrinsic = function GetIntrinsic(name, allowMissing) {
|
|
|
9732
9766
|
)
|
|
9733
9767
|
&& first !== last
|
|
9734
9768
|
) {
|
|
9735
|
-
throw new $SyntaxError
|
|
9769
|
+
throw new $SyntaxError('property names with quotes must have matching quotes');
|
|
9736
9770
|
}
|
|
9737
9771
|
if (part === 'constructor' || !isOwn) {
|
|
9738
9772
|
skipFurtherCaching = true;
|
|
@@ -9741,12 +9775,12 @@ var getIntrinsic = function GetIntrinsic(name, allowMissing) {
|
|
|
9741
9775
|
intrinsicBaseName += '.' + part;
|
|
9742
9776
|
intrinsicRealName = '%' + intrinsicBaseName + '%';
|
|
9743
9777
|
|
|
9744
|
-
if (
|
|
9778
|
+
if (hasOwn(INTRINSICS, intrinsicRealName)) {
|
|
9745
9779
|
value = INTRINSICS[intrinsicRealName];
|
|
9746
9780
|
} else if (value != null) {
|
|
9747
9781
|
if (!(part in value)) {
|
|
9748
9782
|
if (!allowMissing) {
|
|
9749
|
-
throw new $TypeError
|
|
9783
|
+
throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
|
|
9750
9784
|
}
|
|
9751
9785
|
return void undefined$1;
|
|
9752
9786
|
}
|
|
@@ -9767,7 +9801,7 @@ var getIntrinsic = function GetIntrinsic(name, allowMissing) {
|
|
|
9767
9801
|
value = value[part];
|
|
9768
9802
|
}
|
|
9769
9803
|
} else {
|
|
9770
|
-
isOwn =
|
|
9804
|
+
isOwn = hasOwn(value, part);
|
|
9771
9805
|
value = value[part];
|
|
9772
9806
|
}
|
|
9773
9807
|
|
|
@@ -9781,35 +9815,18 @@ var getIntrinsic = function GetIntrinsic(name, allowMissing) {
|
|
|
9781
9815
|
|
|
9782
9816
|
var GetIntrinsic = getIntrinsic;
|
|
9783
9817
|
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
if ($defineProperty$1) {
|
|
9788
|
-
try {
|
|
9789
|
-
$defineProperty$1({}, 'a', { value: 1 });
|
|
9790
|
-
return true;
|
|
9791
|
-
} catch (e) {
|
|
9792
|
-
// IE 8 has a broken defineProperty
|
|
9793
|
-
return false;
|
|
9794
|
-
}
|
|
9795
|
-
}
|
|
9796
|
-
return false;
|
|
9797
|
-
};
|
|
9798
|
-
|
|
9799
|
-
hasPropertyDescriptors$1.hasArrayLengthDefineBug = function hasArrayLengthDefineBug() {
|
|
9800
|
-
// node v0.6 has a bug where array lengths can be Set but not Defined
|
|
9801
|
-
if (!hasPropertyDescriptors$1()) {
|
|
9802
|
-
return null;
|
|
9803
|
-
}
|
|
9818
|
+
/** @type {import('.')} */
|
|
9819
|
+
var $defineProperty$1 = GetIntrinsic('%Object.defineProperty%', true) || false;
|
|
9820
|
+
if ($defineProperty$1) {
|
|
9804
9821
|
try {
|
|
9805
|
-
|
|
9822
|
+
$defineProperty$1({}, 'a', { value: 1 });
|
|
9806
9823
|
} catch (e) {
|
|
9807
|
-
//
|
|
9808
|
-
|
|
9824
|
+
// IE 8 has a broken defineProperty
|
|
9825
|
+
$defineProperty$1 = false;
|
|
9809
9826
|
}
|
|
9810
|
-
}
|
|
9827
|
+
}
|
|
9811
9828
|
|
|
9812
|
-
var
|
|
9829
|
+
var esDefineProperty = $defineProperty$1;
|
|
9813
9830
|
|
|
9814
9831
|
var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
|
|
9815
9832
|
|
|
@@ -9824,52 +9841,33 @@ if ($gOPD) {
|
|
|
9824
9841
|
|
|
9825
9842
|
var gopd = $gOPD;
|
|
9826
9843
|
|
|
9827
|
-
var
|
|
9844
|
+
var $defineProperty = esDefineProperty;
|
|
9828
9845
|
|
|
9829
9846
|
var gOPD = gopd;
|
|
9830
9847
|
|
|
9831
|
-
|
|
9832
|
-
|
|
9833
|
-
|
|
9834
|
-
|
|
9835
|
-
var $defineProperty = hasPropertyDescriptors && GetIntrinsic('%Object.defineProperty%', true);
|
|
9836
|
-
if ($defineProperty) {
|
|
9837
|
-
try {
|
|
9838
|
-
$defineProperty({}, 'a', { value: 1 });
|
|
9839
|
-
} catch (e) {
|
|
9840
|
-
// IE 8 has a broken defineProperty
|
|
9841
|
-
$defineProperty = false;
|
|
9842
|
-
}
|
|
9843
|
-
}
|
|
9844
|
-
|
|
9845
|
-
var $SyntaxError = GetIntrinsic('%SyntaxError%');
|
|
9846
|
-
var $TypeError$1 = GetIntrinsic('%TypeError%');
|
|
9847
|
-
|
|
9848
|
-
|
|
9849
|
-
|
|
9850
|
-
/** @type {(obj: Record<PropertyKey, unknown>, property: PropertyKey, value: unknown, nonEnumerable?: boolean | null, nonWritable?: boolean | null, nonConfigurable?: boolean | null, loose?: boolean) => void} */
|
|
9848
|
+
/** @type {import('.')} */
|
|
9851
9849
|
var defineDataProperty$1 = function defineDataProperty(
|
|
9852
9850
|
obj,
|
|
9853
9851
|
property,
|
|
9854
9852
|
value
|
|
9855
9853
|
) {
|
|
9856
9854
|
if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
|
9857
|
-
throw new $TypeError
|
|
9855
|
+
throw new $TypeError('`obj` must be an object or a function`');
|
|
9858
9856
|
}
|
|
9859
9857
|
if (typeof property !== 'string' && typeof property !== 'symbol') {
|
|
9860
|
-
throw new $TypeError
|
|
9858
|
+
throw new $TypeError('`property` must be a string or a symbol`');
|
|
9861
9859
|
}
|
|
9862
9860
|
if (arguments.length > 3 && typeof arguments[3] !== 'boolean' && arguments[3] !== null) {
|
|
9863
|
-
throw new $TypeError
|
|
9861
|
+
throw new $TypeError('`nonEnumerable`, if provided, must be a boolean or null');
|
|
9864
9862
|
}
|
|
9865
9863
|
if (arguments.length > 4 && typeof arguments[4] !== 'boolean' && arguments[4] !== null) {
|
|
9866
|
-
throw new $TypeError
|
|
9864
|
+
throw new $TypeError('`nonWritable`, if provided, must be a boolean or null');
|
|
9867
9865
|
}
|
|
9868
9866
|
if (arguments.length > 5 && typeof arguments[5] !== 'boolean' && arguments[5] !== null) {
|
|
9869
|
-
throw new $TypeError
|
|
9867
|
+
throw new $TypeError('`nonConfigurable`, if provided, must be a boolean or null');
|
|
9870
9868
|
}
|
|
9871
9869
|
if (arguments.length > 6 && typeof arguments[6] !== 'boolean') {
|
|
9872
|
-
throw new $TypeError
|
|
9870
|
+
throw new $TypeError('`loose`, if provided, must be a boolean');
|
|
9873
9871
|
}
|
|
9874
9872
|
|
|
9875
9873
|
var nonEnumerable = arguments.length > 3 ? arguments[3] : null;
|
|
@@ -9895,12 +9893,33 @@ var defineDataProperty$1 = function defineDataProperty(
|
|
|
9895
9893
|
}
|
|
9896
9894
|
};
|
|
9897
9895
|
|
|
9896
|
+
var hasPropertyDescriptors = function hasPropertyDescriptors() {
|
|
9897
|
+
return !!$defineProperty;
|
|
9898
|
+
};
|
|
9899
|
+
|
|
9900
|
+
hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBug() {
|
|
9901
|
+
// node v0.6 has a bug where array lengths can be Set but not Defined
|
|
9902
|
+
if (!$defineProperty) {
|
|
9903
|
+
return null;
|
|
9904
|
+
}
|
|
9905
|
+
try {
|
|
9906
|
+
return $defineProperty([], 'length', { value: 1 }).length !== 1;
|
|
9907
|
+
} catch (e) {
|
|
9908
|
+
// In Firefox 4-22, defining length on an array throws an exception.
|
|
9909
|
+
return true;
|
|
9910
|
+
}
|
|
9911
|
+
};
|
|
9912
|
+
|
|
9913
|
+
var hasPropertyDescriptors_1 = hasPropertyDescriptors;
|
|
9914
|
+
|
|
9898
9915
|
var defineDataProperty = defineDataProperty$1;
|
|
9899
9916
|
|
|
9917
|
+
var require$$0$1 = hasPropertyDescriptors_1;
|
|
9918
|
+
|
|
9900
9919
|
var hasDescriptors = require$$0$1();
|
|
9901
9920
|
|
|
9902
9921
|
|
|
9903
|
-
|
|
9922
|
+
|
|
9904
9923
|
var $floor = GetIntrinsic('%Math.floor%');
|
|
9905
9924
|
|
|
9906
9925
|
/** @typedef {(...args: unknown[]) => unknown} Func */
|
|
@@ -9946,22 +9965,13 @@ var callBind = createCommonjsModule(function (module) {
|
|
|
9946
9965
|
|
|
9947
9966
|
|
|
9948
9967
|
|
|
9949
|
-
|
|
9968
|
+
|
|
9950
9969
|
var $apply = GetIntrinsic('%Function.prototype.apply%');
|
|
9951
9970
|
var $call = GetIntrinsic('%Function.prototype.call%');
|
|
9952
9971
|
var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || functionBind.call($call, $apply);
|
|
9953
9972
|
|
|
9954
|
-
var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
|
|
9955
|
-
var $max = GetIntrinsic('%Math.max%');
|
|
9956
9973
|
|
|
9957
|
-
|
|
9958
|
-
try {
|
|
9959
|
-
$defineProperty({}, 'a', { value: 1 });
|
|
9960
|
-
} catch (e) {
|
|
9961
|
-
// IE 8 has a broken defineProperty
|
|
9962
|
-
$defineProperty = null;
|
|
9963
|
-
}
|
|
9964
|
-
}
|
|
9974
|
+
var $max = GetIntrinsic('%Math.max%');
|
|
9965
9975
|
|
|
9966
9976
|
module.exports = function callBind(originalFunction) {
|
|
9967
9977
|
if (typeof originalFunction !== 'function') {
|
|
@@ -10224,20 +10234,23 @@ var forEach = function forEach(list, iterator, thisArg) {
|
|
|
10224
10234
|
|
|
10225
10235
|
var forEach_1 = forEach;
|
|
10226
10236
|
|
|
10227
|
-
|
|
10228
|
-
|
|
10229
|
-
'BigUint64Array',
|
|
10237
|
+
/** @type {import('.')} */
|
|
10238
|
+
var possibleTypedArrayNames = [
|
|
10230
10239
|
'Float32Array',
|
|
10231
10240
|
'Float64Array',
|
|
10241
|
+
'Int8Array',
|
|
10232
10242
|
'Int16Array',
|
|
10233
10243
|
'Int32Array',
|
|
10234
|
-
'
|
|
10244
|
+
'Uint8Array',
|
|
10245
|
+
'Uint8ClampedArray',
|
|
10235
10246
|
'Uint16Array',
|
|
10236
10247
|
'Uint32Array',
|
|
10237
|
-
'
|
|
10238
|
-
'
|
|
10248
|
+
'BigInt64Array',
|
|
10249
|
+
'BigUint64Array'
|
|
10239
10250
|
];
|
|
10240
10251
|
|
|
10252
|
+
var possibleNames = possibleTypedArrayNames;
|
|
10253
|
+
|
|
10241
10254
|
var g$1 = typeof globalThis === 'undefined' ? commonjsGlobal : globalThis;
|
|
10242
10255
|
|
|
10243
10256
|
/** @type {import('.')} */
|
|
@@ -17609,155 +17622,840 @@ function getNewSelectedItems(editor, selectedSgroups) {
|
|
|
17609
17622
|
return newSelected;
|
|
17610
17623
|
}
|
|
17611
17624
|
|
|
17625
|
+
var PREVIEW_DELAY = 300;
|
|
17626
|
+
function getUniqueCiId(ci) {
|
|
17627
|
+
return "".concat(ci.id, "-").concat(ci.map);
|
|
17628
|
+
}
|
|
17629
|
+
var TemplatePreview = function () {
|
|
17630
|
+
function TemplatePreview(editor, template, mode) {
|
|
17631
|
+
_classCallCheck$2(this, TemplatePreview);
|
|
17632
|
+
_defineProperty$1(this, "connectedPreviewTimeout", null);
|
|
17633
|
+
this.editor = editor;
|
|
17634
|
+
this.template = template;
|
|
17635
|
+
this.floatingPreviewAction = new Action();
|
|
17636
|
+
this.connectedPreviewAction = null;
|
|
17637
|
+
this.connectedPreviewTimeout = null;
|
|
17638
|
+
this.lastPreviewId = null;
|
|
17639
|
+
this.mode = mode;
|
|
17640
|
+
this.floatingPreview = null;
|
|
17641
|
+
this.position = new Vec2();
|
|
17642
|
+
this.previousPosition = new Vec2();
|
|
17643
|
+
}
|
|
17644
|
+
_createClass$2(TemplatePreview, [{
|
|
17645
|
+
key: "struct",
|
|
17646
|
+
get: function get() {
|
|
17647
|
+
return this.restruct.molecule;
|
|
17648
|
+
}
|
|
17649
|
+
}, {
|
|
17650
|
+
key: "restruct",
|
|
17651
|
+
get: function get() {
|
|
17652
|
+
return this.editor.render.ctab;
|
|
17653
|
+
}
|
|
17654
|
+
}, {
|
|
17655
|
+
key: "isModeFunctionalGroup",
|
|
17656
|
+
get: function get() {
|
|
17657
|
+
return this.mode === MODES.FG;
|
|
17658
|
+
}
|
|
17659
|
+
}, {
|
|
17660
|
+
key: "hidePreview",
|
|
17661
|
+
value: function hidePreview() {
|
|
17662
|
+
this.hideConnectedPreview();
|
|
17663
|
+
this.hideFloatingPreview();
|
|
17664
|
+
}
|
|
17665
|
+
}, {
|
|
17666
|
+
key: "getPreviewTarget",
|
|
17667
|
+
value: function getPreviewTarget() {
|
|
17668
|
+
var _this$restruct$molecu;
|
|
17669
|
+
var ci = this.editor.findItem(event, ['atoms', 'bonds']);
|
|
17670
|
+
if (ci && ((_this$restruct$molecu = this.restruct.molecule[ci.map].get(ci.id)) === null || _this$restruct$molecu === void 0 ? void 0 : _this$restruct$molecu.isPreview) === false) {
|
|
17671
|
+
return ci;
|
|
17672
|
+
} else {
|
|
17673
|
+
return null;
|
|
17674
|
+
}
|
|
17675
|
+
}
|
|
17676
|
+
}, {
|
|
17677
|
+
key: "movePreview",
|
|
17678
|
+
value: function movePreview(event) {
|
|
17679
|
+
var _this = this;
|
|
17680
|
+
this.position = this.editor.render.page2obj(event);
|
|
17681
|
+
var struct = this.editor.struct();
|
|
17682
|
+
var previewTarget = this.getPreviewTarget();
|
|
17683
|
+
var isMouseAwayFromAtomsAndBonds = !previewTarget;
|
|
17684
|
+
var isPreviewTargetChanged = previewTarget && this.lastPreviewId !== getUniqueCiId(previewTarget);
|
|
17685
|
+
var shouldHidePreview = isMouseAwayFromAtomsAndBonds || isPreviewTargetChanged;
|
|
17686
|
+
var shouldShowPreview = previewTarget && !struct.isTargetFromMacromolecule(previewTarget) && !this.connectedPreviewAction && !this.connectedPreviewTimeout;
|
|
17687
|
+
if (shouldHidePreview) {
|
|
17688
|
+
this.hideConnectedPreview();
|
|
17689
|
+
}
|
|
17690
|
+
if (shouldShowPreview) {
|
|
17691
|
+
this.lastPreviewId = getUniqueCiId(previewTarget);
|
|
17692
|
+
this.connectedPreviewTimeout = setTimeout(function () {
|
|
17693
|
+
_this.previousPosition = _this.position;
|
|
17694
|
+
_this.hideFloatingPreview();
|
|
17695
|
+
_this.showConnectedPreview(event, previewTarget);
|
|
17696
|
+
}, PREVIEW_DELAY);
|
|
17697
|
+
} else if (shouldHidePreview) {
|
|
17698
|
+
if (!this.floatingPreview) {
|
|
17699
|
+
this.showFloatingPreview(this.position);
|
|
17700
|
+
this.previousPosition = this.position;
|
|
17701
|
+
this.editor.render.update(false, null);
|
|
17702
|
+
} else {
|
|
17703
|
+
this.moveFloatingPreview();
|
|
17704
|
+
}
|
|
17705
|
+
}
|
|
17706
|
+
}
|
|
17707
|
+
}, {
|
|
17708
|
+
key: "moveFloatingPreview",
|
|
17709
|
+
value: function moveFloatingPreview() {
|
|
17710
|
+
var dist = this.position.sub(this.previousPosition);
|
|
17711
|
+
this.previousPosition = this.position;
|
|
17712
|
+
fromMultipleMove(this.restruct, this.floatingPreview, dist);
|
|
17713
|
+
this.editor.render.update(false, null);
|
|
17714
|
+
}
|
|
17715
|
+
}, {
|
|
17716
|
+
key: "showFloatingPreview",
|
|
17717
|
+
value: function showFloatingPreview(position) {
|
|
17718
|
+
var _fromTemplateOnCanvas = fromTemplateOnCanvas(this.restruct, this.template, position);
|
|
17719
|
+
var _fromTemplateOnCanvas2 = _slicedToArray$1(_fromTemplateOnCanvas, 2);
|
|
17720
|
+
this.floatingPreviewAction = _fromTemplateOnCanvas2[0];
|
|
17721
|
+
this.floatingPreview = _fromTemplateOnCanvas2[1];
|
|
17722
|
+
this.editor.render.update(true, null);
|
|
17723
|
+
}
|
|
17724
|
+
}, {
|
|
17725
|
+
key: "hideFloatingPreview",
|
|
17726
|
+
value: function hideFloatingPreview() {
|
|
17727
|
+
if (this.floatingPreviewAction) {
|
|
17728
|
+
var action = this.floatingPreviewAction.perform(this.restruct);
|
|
17729
|
+
this.editor.update(action, true);
|
|
17730
|
+
this.floatingPreviewAction = null;
|
|
17731
|
+
this.floatingPreview = null;
|
|
17732
|
+
}
|
|
17733
|
+
}
|
|
17734
|
+
}, {
|
|
17735
|
+
key: "hideConnectedPreview",
|
|
17736
|
+
value: function hideConnectedPreview() {
|
|
17737
|
+
if (this.connectedPreviewAction) {
|
|
17738
|
+
this.connectedPreviewAction.perform(this.restruct);
|
|
17739
|
+
this.connectedPreviewAction = null;
|
|
17740
|
+
this.editor.render.update();
|
|
17741
|
+
}
|
|
17742
|
+
if (this.connectedPreviewTimeout) {
|
|
17743
|
+
clearTimeout(this.connectedPreviewTimeout);
|
|
17744
|
+
this.connectedPreviewTimeout = null;
|
|
17745
|
+
}
|
|
17746
|
+
}
|
|
17747
|
+
}, {
|
|
17748
|
+
key: "showConnectedPreview",
|
|
17749
|
+
value: function showConnectedPreview(event, ci) {
|
|
17750
|
+
var _this2 = this;
|
|
17751
|
+
if (ci.map === 'bonds' && !this.isModeFunctionalGroup) {
|
|
17752
|
+
var bond = this.struct.bonds.get(ci.id);
|
|
17753
|
+
if (!bond) {
|
|
17754
|
+
return;
|
|
17755
|
+
}
|
|
17756
|
+
var sign1 = getBondFlipSign(this.struct, bond);
|
|
17757
|
+
var sign2 = this.template.sign;
|
|
17758
|
+
var shouldFlip = sign1 * sign2 > 0;
|
|
17759
|
+
var promise = fromTemplateOnBondAction(this.restruct, this.template, ci.id, this.editor.event, shouldFlip, true, true);
|
|
17760
|
+
promise.then(function (_ref) {
|
|
17761
|
+
var _ref2 = _slicedToArray$1(_ref, 2),
|
|
17762
|
+
action = _ref2[0],
|
|
17763
|
+
pasteItems = _ref2[1];
|
|
17764
|
+
if (!_this2.isModeFunctionalGroup) {
|
|
17765
|
+
var mergeItems = getItemsToFuse(_this2.editor, pasteItems);
|
|
17766
|
+
action = fromItemsFuse(_this2.restruct, mergeItems).mergeWith(action);
|
|
17767
|
+
_this2.editor.update(action, true);
|
|
17768
|
+
_this2.connectedPreviewAction = action;
|
|
17769
|
+
}
|
|
17770
|
+
});
|
|
17771
|
+
} else if (ci.map === 'atoms') {
|
|
17772
|
+
var angle = getAngleFromEvent(event, ci, this.restruct);
|
|
17773
|
+
var _fromTemplateOnAtom = fromTemplateOnAtom(this.restruct, this.template, ci.id, angle, false, true),
|
|
17774
|
+
_fromTemplateOnAtom2 = _slicedToArray$1(_fromTemplateOnAtom, 2),
|
|
17775
|
+
action = _fromTemplateOnAtom2[0],
|
|
17776
|
+
pasteItems = _fromTemplateOnAtom2[1];
|
|
17777
|
+
if (pasteItems && !this.isModeFunctionalGroup) {
|
|
17778
|
+
var mergeItems = getItemsToFuse(this.editor, pasteItems);
|
|
17779
|
+
action = fromItemsFuse(this.restruct, mergeItems).mergeWith(action);
|
|
17780
|
+
}
|
|
17781
|
+
this.editor.update(action, true);
|
|
17782
|
+
this.connectedPreviewAction = action;
|
|
17783
|
+
}
|
|
17784
|
+
}
|
|
17785
|
+
}]);
|
|
17786
|
+
return TemplatePreview;
|
|
17787
|
+
}();
|
|
17788
|
+
|
|
17789
|
+
function _createForOfIteratorHelper$a(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$a(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
17790
|
+
function _unsupportedIterableToArray$a(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$a(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$a(o, minLen); }
|
|
17791
|
+
function _arrayLikeToArray$a(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
17612
17792
|
function ownKeys$T(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; }
|
|
17613
17793
|
function _objectSpread$T(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$T(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$T(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17614
|
-
function
|
|
17615
|
-
|
|
17616
|
-
|
|
17617
|
-
|
|
17618
|
-
|
|
17619
|
-
|
|
17620
|
-
|
|
17621
|
-
|
|
17622
|
-
|
|
17794
|
+
function getBondFlipSign(struct, bond) {
|
|
17795
|
+
var _struct$atoms$get, _struct$halfBonds$get;
|
|
17796
|
+
var xy0 = new Vec2();
|
|
17797
|
+
var frid = (_struct$atoms$get = struct.atoms.get(bond === null || bond === void 0 ? void 0 : bond.begin)) === null || _struct$atoms$get === void 0 ? void 0 : _struct$atoms$get.fragment;
|
|
17798
|
+
var frIds = struct.getFragmentIds(frid);
|
|
17799
|
+
var count = 0;
|
|
17800
|
+
var loop = (_struct$halfBonds$get = struct.halfBonds.get(bond === null || bond === void 0 ? void 0 : bond.hb1)) === null || _struct$halfBonds$get === void 0 ? void 0 : _struct$halfBonds$get.loop;
|
|
17801
|
+
if (loop && loop < 0) {
|
|
17802
|
+
var _struct$halfBonds$get2;
|
|
17803
|
+
loop = (_struct$halfBonds$get2 = struct.halfBonds.get(bond === null || bond === void 0 ? void 0 : bond.hb2)) === null || _struct$halfBonds$get2 === void 0 ? void 0 : _struct$halfBonds$get2.loop;
|
|
17623
17804
|
}
|
|
17624
|
-
|
|
17625
|
-
|
|
17626
|
-
|
|
17627
|
-
|
|
17628
|
-
|
|
17629
|
-
|
|
17630
|
-
|
|
17631
|
-
|
|
17632
|
-
|
|
17633
|
-
|
|
17634
|
-
|
|
17635
|
-
|
|
17636
|
-
}
|
|
17637
|
-
|
|
17638
|
-
|
|
17639
|
-
|
|
17640
|
-
|
|
17641
|
-
|
|
17642
|
-
|
|
17643
|
-
|
|
17644
|
-
|
|
17645
|
-
isFunctionalGroupChange({
|
|
17646
|
-
editor: editor,
|
|
17647
|
-
hoveredItemId: item[itemType][0],
|
|
17648
|
-
newAction: newAction,
|
|
17649
|
-
dispatch: dispatch
|
|
17650
|
-
}, itemType).then(function (res) {
|
|
17651
|
-
res && eraseItem({
|
|
17652
|
-
editor: editor,
|
|
17653
|
-
item: item
|
|
17654
|
-
});
|
|
17805
|
+
if (loop && loop >= 0) {
|
|
17806
|
+
var _struct$loops$get;
|
|
17807
|
+
var loopHbs = (_struct$loops$get = struct.loops.get(loop)) === null || _struct$loops$get === void 0 ? void 0 : _struct$loops$get.hbs;
|
|
17808
|
+
loopHbs === null || loopHbs === void 0 || loopHbs.forEach(function (hb) {
|
|
17809
|
+
var _struct$halfBonds$get3;
|
|
17810
|
+
var halfBondBegin = (_struct$halfBonds$get3 = struct.halfBonds.get(hb)) === null || _struct$halfBonds$get3 === void 0 ? void 0 : _struct$halfBonds$get3.begin;
|
|
17811
|
+
if (halfBondBegin) {
|
|
17812
|
+
var hbbAtom = struct.atoms.get(halfBondBegin);
|
|
17813
|
+
if (hbbAtom) {
|
|
17814
|
+
xy0.add_(hbbAtom.pp);
|
|
17815
|
+
count++;
|
|
17816
|
+
}
|
|
17817
|
+
}
|
|
17818
|
+
});
|
|
17819
|
+
} else {
|
|
17820
|
+
frIds.forEach(function (id) {
|
|
17821
|
+
var atomById = struct.atoms.get(id);
|
|
17822
|
+
if (atomById) {
|
|
17823
|
+
xy0.add_(atomById.pp);
|
|
17824
|
+
count++;
|
|
17825
|
+
}
|
|
17655
17826
|
});
|
|
17656
|
-
return;
|
|
17657
17827
|
}
|
|
17658
|
-
|
|
17659
|
-
|
|
17660
|
-
item: item
|
|
17661
|
-
});
|
|
17828
|
+
var v0 = xy0.scaled(1 / count);
|
|
17829
|
+
return getSign(struct, bond, v0) || 1;
|
|
17662
17830
|
}
|
|
17663
|
-
function
|
|
17664
|
-
var
|
|
17665
|
-
|
|
17666
|
-
|
|
17667
|
-
|
|
17668
|
-
|
|
17669
|
-
|
|
17670
|
-
|
|
17671
|
-
|
|
17672
|
-
var
|
|
17673
|
-
|
|
17674
|
-
|
|
17675
|
-
|
|
17676
|
-
|
|
17677
|
-
};
|
|
17678
|
-
return dialogHandler(props);
|
|
17831
|
+
function getAngleFromEvent(event, ci, restruct) {
|
|
17832
|
+
var _restruct$atoms$get;
|
|
17833
|
+
var degree = (_restruct$atoms$get = restruct.atoms.get(ci.id)) === null || _restruct$atoms$get === void 0 ? void 0 : _restruct$atoms$get.a.neighbors.length;
|
|
17834
|
+
var angle;
|
|
17835
|
+
if (degree && degree > 1) {
|
|
17836
|
+
angle = null;
|
|
17837
|
+
} else if (degree === 1) {
|
|
17838
|
+
var _restruct$molecule$ha;
|
|
17839
|
+
var atom = restruct.molecule.atoms.get(ci.id);
|
|
17840
|
+
var neiId = atom && ((_restruct$molecule$ha = restruct.molecule.halfBonds.get(atom.neighbors[0])) === null || _restruct$molecule$ha === void 0 ? void 0 : _restruct$molecule$ha.end);
|
|
17841
|
+
var nei = (neiId || neiId === 0) && restruct.molecule.atoms.get(neiId);
|
|
17842
|
+
angle = event.ctrlKey ? vectorUtils.calcAngle(nei === null || nei === void 0 ? void 0 : nei.pp, atom === null || atom === void 0 ? void 0 : atom.pp) : vectorUtils.fracAngle(vectorUtils.calcAngle(nei.pp, atom === null || atom === void 0 ? void 0 : atom.pp), null);
|
|
17843
|
+
} else {
|
|
17844
|
+
angle = 0;
|
|
17679
17845
|
}
|
|
17846
|
+
return angle;
|
|
17680
17847
|
}
|
|
17681
|
-
function
|
|
17682
|
-
|
|
17683
|
-
|
|
17684
|
-
|
|
17685
|
-
|
|
17686
|
-
|
|
17687
|
-
|
|
17688
|
-
|
|
17689
|
-
|
|
17690
|
-
|
|
17691
|
-
|
|
17692
|
-
|
|
17693
|
-
|
|
17694
|
-
|
|
17695
|
-
|
|
17696
|
-
|
|
17697
|
-
|
|
17698
|
-
|
|
17699
|
-
|
|
17700
|
-
var restruct = editor.render.ctab;
|
|
17701
|
-
if (atomsSelected && atomsSelected.includes(hoveredItemId)) {
|
|
17702
|
-
var atoms = getSelectedAtoms(selection, restruct.molecule);
|
|
17703
|
-
var changeAtomPromise = editor.event.elementEdit.dispatch(atoms);
|
|
17704
|
-
updateSelectedAtoms({
|
|
17705
|
-
atoms: selection.atoms || [],
|
|
17706
|
-
editor: editor,
|
|
17707
|
-
changeAtomPromise: changeAtomPromise
|
|
17708
|
-
});
|
|
17709
|
-
} else {
|
|
17710
|
-
var atomFromStruct = restruct.atoms.get(hoveredItemId);
|
|
17711
|
-
var convertedAtomForModal = fromAtom(atomFromStruct === null || atomFromStruct === void 0 ? void 0 : atomFromStruct.a);
|
|
17712
|
-
openDialog(dispatch, newAction.dialog, convertedAtomForModal).then(function (res) {
|
|
17713
|
-
var updatedAtom = fromAtomsAttrs(restruct, hoveredItemId, toAtom(res), false);
|
|
17714
|
-
editor.update(updatedAtom);
|
|
17715
|
-
})["catch"](function (e) {
|
|
17716
|
-
KetcherLogger.error('handleHotkeysOverItem.ts::handleAtomPropsDialog', e);
|
|
17848
|
+
var TemplateTool = function () {
|
|
17849
|
+
function TemplateTool(editor, tmpl) {
|
|
17850
|
+
_classCallCheck$2(this, TemplateTool);
|
|
17851
|
+
_defineProperty$1(this, "targetGroupsIds", []);
|
|
17852
|
+
this.editor = editor;
|
|
17853
|
+
this.mode = getTemplateMode(tmpl);
|
|
17854
|
+
this.editor.selection(null);
|
|
17855
|
+
this.isSaltOrSolvent = SGroup$1.isSaltOrSolvent(tmpl.struct.name);
|
|
17856
|
+
var sGroup = tmpl.struct.sgroups.values().next().value;
|
|
17857
|
+
this.template = {
|
|
17858
|
+
aid: parseInt(tmpl.aid) || (sGroup === null || sGroup === void 0 ? void 0 : sGroup.getAttachmentAtomId()) || 0,
|
|
17859
|
+
bid: parseInt(tmpl.bid) || 0
|
|
17860
|
+
};
|
|
17861
|
+
this.templatePreview = new TemplatePreview(editor, this.template, this.mode);
|
|
17862
|
+
var frag = tmpl.struct;
|
|
17863
|
+
frag.rescale();
|
|
17864
|
+
var xy0 = new Vec2();
|
|
17865
|
+
frag.atoms.forEach(function (atom) {
|
|
17866
|
+
xy0.add_(atom.pp);
|
|
17717
17867
|
});
|
|
17868
|
+
this.template.molecule = frag;
|
|
17869
|
+
this.findItems = [];
|
|
17870
|
+
this.template.xy0 = xy0.scaled(1 / (frag.atoms.size || 1));
|
|
17871
|
+
var atom = frag.atoms.get(this.template.aid);
|
|
17872
|
+
if (atom) {
|
|
17873
|
+
this.template.angle0 = vectorUtils.calcAngle(atom.pp, this.template.xy0);
|
|
17874
|
+
this.findItems.push('atoms');
|
|
17875
|
+
}
|
|
17876
|
+
var bond = frag.bonds.get(this.template.bid);
|
|
17877
|
+
if (bond && !this.isModeFunctionalGroup) {
|
|
17878
|
+
this.template.sign = getSign(frag, bond, this.template.xy0);
|
|
17879
|
+
this.findItems.push('bonds');
|
|
17880
|
+
}
|
|
17881
|
+
var sGroupSize = frag.sgroups.size;
|
|
17882
|
+
if (sGroupSize) {
|
|
17883
|
+
this.findItems.push('functionalGroups');
|
|
17884
|
+
}
|
|
17718
17885
|
}
|
|
17719
|
-
|
|
17720
|
-
|
|
17721
|
-
|
|
17722
|
-
|
|
17723
|
-
|
|
17724
|
-
|
|
17725
|
-
|
|
17726
|
-
|
|
17727
|
-
|
|
17728
|
-
|
|
17729
|
-
|
|
17730
|
-
|
|
17731
|
-
|
|
17732
|
-
|
|
17733
|
-
|
|
17734
|
-
}
|
|
17735
|
-
|
|
17736
|
-
|
|
17737
|
-
|
|
17738
|
-
|
|
17739
|
-
|
|
17740
|
-
|
|
17741
|
-
|
|
17742
|
-
|
|
17743
|
-
|
|
17744
|
-
|
|
17745
|
-
|
|
17746
|
-
|
|
17747
|
-
|
|
17748
|
-
|
|
17749
|
-
|
|
17750
|
-
|
|
17751
|
-
|
|
17752
|
-
|
|
17753
|
-
|
|
17886
|
+
_createClass$2(TemplateTool, [{
|
|
17887
|
+
key: "struct",
|
|
17888
|
+
get: function get() {
|
|
17889
|
+
return this.editor.render.ctab.molecule;
|
|
17890
|
+
}
|
|
17891
|
+
}, {
|
|
17892
|
+
key: "functionalGroups",
|
|
17893
|
+
get: function get() {
|
|
17894
|
+
return this.struct.functionalGroups;
|
|
17895
|
+
}
|
|
17896
|
+
}, {
|
|
17897
|
+
key: "isModeFunctionalGroup",
|
|
17898
|
+
get: function get() {
|
|
17899
|
+
return this.mode === MODES.FG;
|
|
17900
|
+
}
|
|
17901
|
+
}, {
|
|
17902
|
+
key: "closestItem",
|
|
17903
|
+
get: function get() {
|
|
17904
|
+
return this.editor.findItem(this.event, ['atoms', 'bonds', 'sgroups', 'functionalGroups']);
|
|
17905
|
+
}
|
|
17906
|
+
}, {
|
|
17907
|
+
key: "isNeedToShowRemoveAbbreviationPopup",
|
|
17908
|
+
get: function get() {
|
|
17909
|
+
var _this$closestItem;
|
|
17910
|
+
var targetId = this.findKeyOfRelatedGroupId((_this$closestItem = this.closestItem) === null || _this$closestItem === void 0 ? void 0 : _this$closestItem.id);
|
|
17911
|
+
var functionalGroup = this.functionalGroups.get(targetId);
|
|
17912
|
+
if ((functionalGroup === null || functionalGroup === void 0 ? void 0 : functionalGroup.relatedSGroup) instanceof MonomerMicromolecule) {
|
|
17913
|
+
return false;
|
|
17914
|
+
}
|
|
17915
|
+
var isTargetExpanded = functionalGroup === null || functionalGroup === void 0 ? void 0 : functionalGroup.isExpanded;
|
|
17916
|
+
var isTargetAtomOrBond = this.targetGroupsIds.length && !this.isModeFunctionalGroup;
|
|
17917
|
+
return Boolean(isTargetExpanded || isTargetAtomOrBond);
|
|
17918
|
+
}
|
|
17919
|
+
}, {
|
|
17920
|
+
key: "findKeyOfRelatedGroupId",
|
|
17921
|
+
value: function findKeyOfRelatedGroupId(clickedClosestItemId) {
|
|
17922
|
+
var targetId;
|
|
17923
|
+
var relatedGroupId = FunctionalGroup.findFunctionalGroupByAtom(this.functionalGroups, clickedClosestItemId);
|
|
17924
|
+
this.functionalGroups.forEach(function (fg, key) {
|
|
17925
|
+
if (fg.relatedSGroupId === relatedGroupId) {
|
|
17926
|
+
targetId = key;
|
|
17927
|
+
}
|
|
17754
17928
|
});
|
|
17929
|
+
return targetId;
|
|
17755
17930
|
}
|
|
17756
|
-
}
|
|
17757
|
-
|
|
17758
|
-
|
|
17759
|
-
|
|
17760
|
-
|
|
17931
|
+
}, {
|
|
17932
|
+
key: "showRemoveAbbreviationPopup",
|
|
17933
|
+
value: function showRemoveAbbreviationPopup() {
|
|
17934
|
+
var _this = this;
|
|
17935
|
+
return this.editor.event.removeFG.dispatch({
|
|
17936
|
+
fgIds: this.targetGroupsIds
|
|
17937
|
+
}).then(function () {
|
|
17938
|
+
_this.targetGroupsIds.length = 0;
|
|
17939
|
+
return Promise.resolve();
|
|
17940
|
+
});
|
|
17941
|
+
}
|
|
17942
|
+
}, {
|
|
17943
|
+
key: "mousedown",
|
|
17944
|
+
value: function () {
|
|
17945
|
+
var _mousedown = _asyncToGenerator( _regeneratorRuntime.mark(function _callee(event) {
|
|
17946
|
+
var _this$templatePreview;
|
|
17947
|
+
var target, struct, _this$closestItem2, _this$closestItem3, _this$closestItem4, dragCtx, ci, bond;
|
|
17948
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
17949
|
+
while (1) switch (_context.prev = _context.next) {
|
|
17950
|
+
case 0:
|
|
17951
|
+
target = this.editor.findItem(event, this.findItems);
|
|
17952
|
+
struct = this.editor.struct();
|
|
17953
|
+
this.event = event;
|
|
17954
|
+
(_this$templatePreview = this.templatePreview) === null || _this$templatePreview === void 0 || _this$templatePreview.hidePreview();
|
|
17955
|
+
if (this.functionalGroups.size) {
|
|
17956
|
+
this.targetGroupsIds = getGroupIdsFromItemArrays(this.struct, _objectSpread$T(_objectSpread$T({}, ((_this$closestItem2 = this.closestItem) === null || _this$closestItem2 === void 0 ? void 0 : _this$closestItem2.map) === 'atoms' && {
|
|
17957
|
+
atoms: [this.closestItem.id]
|
|
17958
|
+
}), ((_this$closestItem3 = this.closestItem) === null || _this$closestItem3 === void 0 ? void 0 : _this$closestItem3.map) === 'bonds' && {
|
|
17959
|
+
bonds: [this.closestItem.id]
|
|
17960
|
+
}));
|
|
17961
|
+
if (
|
|
17962
|
+
((_this$closestItem4 = this.closestItem) === null || _this$closestItem4 === void 0 ? void 0 : _this$closestItem4.map) === 'functionalGroups' && FunctionalGroup.isContractedFunctionalGroup(this.closestItem.id, this.functionalGroups)) {
|
|
17963
|
+
this.targetGroupsIds.push(this.closestItem.id);
|
|
17964
|
+
}
|
|
17965
|
+
}
|
|
17966
|
+
if (!struct.isTargetFromMacromolecule(target)) {
|
|
17967
|
+
_context.next = 7;
|
|
17968
|
+
break;
|
|
17969
|
+
}
|
|
17970
|
+
return _context.abrupt("return");
|
|
17971
|
+
case 7:
|
|
17972
|
+
if (!this.isNeedToShowRemoveAbbreviationPopup) {
|
|
17973
|
+
_context.next = 11;
|
|
17974
|
+
break;
|
|
17975
|
+
}
|
|
17976
|
+
_context.next = 10;
|
|
17977
|
+
return this.showRemoveAbbreviationPopup();
|
|
17978
|
+
case 10:
|
|
17979
|
+
return _context.abrupt("return");
|
|
17980
|
+
case 11:
|
|
17981
|
+
this.editor.hover(null);
|
|
17982
|
+
this.dragCtx = {
|
|
17983
|
+
xy0: this.editor.render.page2obj(event),
|
|
17984
|
+
item: this.editor.findItem(this.event, this.findItems)
|
|
17985
|
+
};
|
|
17986
|
+
dragCtx = this.dragCtx;
|
|
17987
|
+
ci = dragCtx.item;
|
|
17988
|
+
if (ci) {
|
|
17989
|
+
_context.next = 18;
|
|
17990
|
+
break;
|
|
17991
|
+
}
|
|
17992
|
+
delete dragCtx.item;
|
|
17993
|
+
return _context.abrupt("return");
|
|
17994
|
+
case 18:
|
|
17995
|
+
if (ci.map === 'bonds' && !this.isModeFunctionalGroup) {
|
|
17996
|
+
bond = this.struct.bonds.get(ci.id);
|
|
17997
|
+
dragCtx.sign1 = getBondFlipSign(this.struct, bond);
|
|
17998
|
+
dragCtx.sign2 = this.template.sign;
|
|
17999
|
+
}
|
|
18000
|
+
case 19:
|
|
18001
|
+
case "end":
|
|
18002
|
+
return _context.stop();
|
|
18003
|
+
}
|
|
18004
|
+
}, _callee, this);
|
|
18005
|
+
}));
|
|
18006
|
+
function mousedown(_x) {
|
|
18007
|
+
return _mousedown.apply(this, arguments);
|
|
18008
|
+
}
|
|
18009
|
+
return mousedown;
|
|
18010
|
+
}()
|
|
18011
|
+
}, {
|
|
18012
|
+
key: "mousemove",
|
|
18013
|
+
value: function mousemove(event) {
|
|
18014
|
+
if (!this.dragCtx) {
|
|
18015
|
+
var _this$templatePreview2;
|
|
18016
|
+
this.editor.hover(this.editor.findItem(event, this.findItems), null, event);
|
|
18017
|
+
(_this$templatePreview2 = this.templatePreview) === null || _this$templatePreview2 === void 0 || _this$templatePreview2.movePreview(event);
|
|
18018
|
+
return true;
|
|
18019
|
+
}
|
|
18020
|
+
if (this.isSaltOrSolvent) {
|
|
18021
|
+
delete this.dragCtx.item;
|
|
18022
|
+
return true;
|
|
18023
|
+
}
|
|
18024
|
+
var eventPosition = this.editor.render.page2obj(event);
|
|
18025
|
+
var dragCtx = this.dragCtx;
|
|
18026
|
+
var ci = dragCtx.item;
|
|
18027
|
+
var targetPos = null;
|
|
18028
|
+
if (ci && ci.map === 'bonds' && !this.isModeFunctionalGroup) {
|
|
18029
|
+
var bond = this.struct.bonds.get(ci.id);
|
|
18030
|
+
var sign = getSign(this.struct, bond, eventPosition);
|
|
18031
|
+
if (dragCtx.sign1 * this.template.sign > 0) {
|
|
18032
|
+
sign = -sign;
|
|
18033
|
+
}
|
|
18034
|
+
if (sign !== dragCtx.sign2 || !dragCtx.action) {
|
|
18035
|
+
if (dragCtx.action) {
|
|
18036
|
+
dragCtx.action.perform(this.editor.render.ctab);
|
|
18037
|
+
}
|
|
18038
|
+
dragCtx.sign2 = sign;
|
|
18039
|
+
var _fromTemplateOnBondAc = fromTemplateOnBondAction(this.editor.render.ctab, this.template, ci.id, this.editor.event, dragCtx.sign1 * dragCtx.sign2 > 0, false),
|
|
18040
|
+
_fromTemplateOnBondAc2 = _slicedToArray$1(_fromTemplateOnBondAc, 2),
|
|
18041
|
+
_action = _fromTemplateOnBondAc2[0],
|
|
18042
|
+
pasteItems = _fromTemplateOnBondAc2[1];
|
|
18043
|
+
dragCtx.action = _action;
|
|
18044
|
+
this.editor.update(dragCtx.action, true);
|
|
18045
|
+
dragCtx.mergeItems = getItemsToFuse(this.editor, pasteItems);
|
|
18046
|
+
this.editor.hover(getHoverToFuse(dragCtx.mergeItems));
|
|
18047
|
+
}
|
|
18048
|
+
return true;
|
|
18049
|
+
}
|
|
18050
|
+
var extraBond = null;
|
|
18051
|
+
if (!ci) {
|
|
18052
|
+
targetPos = dragCtx.xy0;
|
|
18053
|
+
} else if (ci.map === 'atoms' || ci.map === 'functionalGroups') {
|
|
18054
|
+
var atomId = getTargetAtomId(this.struct, ci);
|
|
18055
|
+
if (atomId !== undefined) {
|
|
18056
|
+
var atom = this.struct.atoms.get(atomId);
|
|
18057
|
+
targetPos = atom === null || atom === void 0 ? void 0 : atom.pp;
|
|
18058
|
+
if (targetPos) {
|
|
18059
|
+
extraBond = this.isModeFunctionalGroup ? true : Vec2.dist(targetPos, eventPosition) > 1;
|
|
18060
|
+
}
|
|
18061
|
+
}
|
|
18062
|
+
}
|
|
18063
|
+
if (!targetPos) {
|
|
18064
|
+
return true;
|
|
18065
|
+
}
|
|
18066
|
+
var angle = vectorUtils.calcAngle(targetPos, eventPosition);
|
|
18067
|
+
if (!event.ctrlKey) {
|
|
18068
|
+
angle = vectorUtils.fracAngle(angle, null);
|
|
18069
|
+
}
|
|
18070
|
+
var degrees = vectorUtils.degrees(angle);
|
|
18071
|
+
this.editor.event.message.dispatch({
|
|
18072
|
+
info: degrees + 'º'
|
|
18073
|
+
});
|
|
18074
|
+
if (
|
|
18075
|
+
dragCtx.hasOwnProperty('angle') && dragCtx.angle === degrees && (
|
|
18076
|
+
!dragCtx.hasOwnProperty('extra_bond') || dragCtx.extra_bond === extraBond)) {
|
|
18077
|
+
return true;
|
|
18078
|
+
}
|
|
18079
|
+
if (dragCtx.action) {
|
|
18080
|
+
dragCtx.action.perform(this.editor.render.ctab);
|
|
18081
|
+
}
|
|
18082
|
+
dragCtx.angle = degrees;
|
|
18083
|
+
var action = null;
|
|
18084
|
+
if (!ci) {
|
|
18085
|
+
var _this$template;
|
|
18086
|
+
var isAddingFunctionalGroup = (_this$template = this.template) === null || _this$template === void 0 || (_this$template = _this$template.molecule) === null || _this$template === void 0 ? void 0 : _this$template.sgroups.size;
|
|
18087
|
+
if (isAddingFunctionalGroup) {
|
|
18088
|
+
return true;
|
|
18089
|
+
}
|
|
18090
|
+
var _fromTemplateOnCanvas = fromTemplateOnCanvas(this.editor.render.ctab, this.template, targetPos, angle);
|
|
18091
|
+
var _fromTemplateOnCanvas2 = _slicedToArray$1(_fromTemplateOnCanvas, 1);
|
|
18092
|
+
action = _fromTemplateOnCanvas2[0];
|
|
18093
|
+
} else if ((ci === null || ci === void 0 ? void 0 : ci.map) === 'atoms' || (ci === null || ci === void 0 ? void 0 : ci.map) === 'functionalGroups') {
|
|
18094
|
+
var _atomId = getTargetAtomId(this.struct, ci);
|
|
18095
|
+
var _fromTemplateOnAtom = fromTemplateOnAtom(this.editor.render.ctab, this.template, _atomId, angle, extraBond);
|
|
18096
|
+
var _fromTemplateOnAtom2 = _slicedToArray$1(_fromTemplateOnAtom, 1);
|
|
18097
|
+
action = _fromTemplateOnAtom2[0];
|
|
18098
|
+
dragCtx.extra_bond = extraBond;
|
|
18099
|
+
}
|
|
18100
|
+
dragCtx.action = action;
|
|
18101
|
+
this.editor.update(dragCtx.action, true);
|
|
18102
|
+
if (this.targetGroupsIds.length) this.targetGroupsIds.length = 0;
|
|
18103
|
+
return true;
|
|
18104
|
+
}
|
|
18105
|
+
}, {
|
|
18106
|
+
key: "mouseup",
|
|
18107
|
+
value: function mouseup(event) {
|
|
18108
|
+
var _this2 = this,
|
|
18109
|
+
_ci;
|
|
18110
|
+
var dragCtx = this.dragCtx;
|
|
18111
|
+
if (!dragCtx) {
|
|
18112
|
+
return true;
|
|
18113
|
+
}
|
|
18114
|
+
delete this.dragCtx;
|
|
18115
|
+
var restruct = this.editor.render.ctab;
|
|
18116
|
+
var ci = dragCtx.item;
|
|
18117
|
+
if (dragCtx.action && ci && ci.map === 'bonds' && !this.isModeFunctionalGroup) {
|
|
18118
|
+
dragCtx.action.perform(restruct);
|
|
18119
|
+
var promise = fromTemplateOnBondAction(restruct, this.template, ci.id, this.editor.event, dragCtx.sign1 * dragCtx.sign2 > 0, true);
|
|
18120
|
+
promise.then(function (_ref) {
|
|
18121
|
+
var _ref2 = _slicedToArray$1(_ref, 2),
|
|
18122
|
+
action = _ref2[0],
|
|
18123
|
+
pasteItems = _ref2[1];
|
|
18124
|
+
var mergeItems = getItemsToFuse(_this2.editor, pasteItems);
|
|
18125
|
+
action = fromItemsFuse(restruct, mergeItems).mergeWith(action);
|
|
18126
|
+
_this2.editor.update(action);
|
|
18127
|
+
});
|
|
18128
|
+
return true;
|
|
18129
|
+
}
|
|
18130
|
+
var action, functionalGroupRemoveAction;
|
|
18131
|
+
if (((_ci = ci) === null || _ci === void 0 ? void 0 : _ci.map) === 'functionalGroups' && FunctionalGroup.isContractedFunctionalGroup(ci.id, this.functionalGroups) && this.isModeFunctionalGroup && this.targetGroupsIds.length) {
|
|
18132
|
+
var _restruct = this.editor.render.ctab;
|
|
18133
|
+
var functionalGroupToReplace = this.struct.sgroups.get(ci.id);
|
|
18134
|
+
if (this.isSaltOrSolvent && functionalGroupToReplace.isGroupAttached(this.struct)) {
|
|
18135
|
+
addOnCanvasWithoutMerge({
|
|
18136
|
+
restruct: _restruct,
|
|
18137
|
+
template: this.template,
|
|
18138
|
+
dragCtx: dragCtx,
|
|
18139
|
+
editor: this.editor,
|
|
18140
|
+
event: event
|
|
18141
|
+
});
|
|
18142
|
+
return true;
|
|
18143
|
+
}
|
|
18144
|
+
functionalGroupRemoveAction = new Action();
|
|
18145
|
+
var _functionalGroupToRep = functionalGroupToReplace.getContractedPosition(_restruct.molecule),
|
|
18146
|
+
sGroupPositionAtomId = _functionalGroupToRep.atomId;
|
|
18147
|
+
var atomsWithoutAttachmentAtom = SGroup$1.getAtoms(this.struct, functionalGroupToReplace).filter(function (id) {
|
|
18148
|
+
return id !== sGroupPositionAtomId;
|
|
18149
|
+
});
|
|
18150
|
+
functionalGroupRemoveAction.mergeWith(fromSgroupDeletion(_restruct, ci.id));
|
|
18151
|
+
functionalGroupRemoveAction.mergeWith(fromFragmentDeletion(_restruct, {
|
|
18152
|
+
atoms: atomsWithoutAttachmentAtom
|
|
18153
|
+
}));
|
|
18154
|
+
ci = {
|
|
18155
|
+
map: 'atoms',
|
|
18156
|
+
id: sGroupPositionAtomId
|
|
18157
|
+
};
|
|
18158
|
+
}
|
|
18159
|
+
if (!dragCtx.action) {
|
|
18160
|
+
if (!ci) {
|
|
18161
|
+
addOnCanvasWithoutMerge({
|
|
18162
|
+
restruct: restruct,
|
|
18163
|
+
template: this.template,
|
|
18164
|
+
dragCtx: dragCtx,
|
|
18165
|
+
editor: this.editor,
|
|
18166
|
+
event: event
|
|
18167
|
+
});
|
|
18168
|
+
return true;
|
|
18169
|
+
} else if (ci.map === 'atoms') {
|
|
18170
|
+
var _restruct$atoms$get2;
|
|
18171
|
+
var degree = (_restruct$atoms$get2 = restruct.atoms.get(ci.id)) === null || _restruct$atoms$get2 === void 0 ? void 0 : _restruct$atoms$get2.a.neighbors.length;
|
|
18172
|
+
if (degree && degree >= 1 && this.isSaltOrSolvent) {
|
|
18173
|
+
addOnCanvasWithoutMerge({
|
|
18174
|
+
restruct: restruct,
|
|
18175
|
+
template: this.template,
|
|
18176
|
+
dragCtx: dragCtx,
|
|
18177
|
+
editor: this.editor,
|
|
18178
|
+
event: event
|
|
18179
|
+
});
|
|
18180
|
+
return true;
|
|
18181
|
+
}
|
|
18182
|
+
var angle = getAngleFromEvent(event, ci, restruct);
|
|
18183
|
+
var _fromTemplateOnAtom3 = fromTemplateOnAtom(restruct, this.template, ci.id, angle, false);
|
|
18184
|
+
var _fromTemplateOnAtom4 = _slicedToArray$1(_fromTemplateOnAtom3, 1);
|
|
18185
|
+
action = _fromTemplateOnAtom4[0];
|
|
18186
|
+
if (functionalGroupRemoveAction) {
|
|
18187
|
+
action = functionalGroupRemoveAction.mergeWith(action);
|
|
18188
|
+
}
|
|
18189
|
+
dragCtx.action = action;
|
|
18190
|
+
} else if (ci.map === 'bonds' && !this.isModeFunctionalGroup) {
|
|
18191
|
+
var _promise = fromTemplateOnBondAction(restruct, this.template, ci.id, this.editor.event, dragCtx.sign1 * dragCtx.sign2 > 0, true);
|
|
18192
|
+
_promise.then(function (_ref3) {
|
|
18193
|
+
var _ref4 = _slicedToArray$1(_ref3, 2),
|
|
18194
|
+
action = _ref4[0],
|
|
18195
|
+
pasteItems = _ref4[1];
|
|
18196
|
+
if (!_this2.isModeFunctionalGroup) {
|
|
18197
|
+
var mergeItems = getItemsToFuse(_this2.editor, pasteItems);
|
|
18198
|
+
action = fromItemsFuse(restruct, mergeItems).mergeWith(action);
|
|
18199
|
+
_this2.editor.update(action);
|
|
18200
|
+
}
|
|
18201
|
+
});
|
|
18202
|
+
return true;
|
|
18203
|
+
}
|
|
18204
|
+
}
|
|
18205
|
+
var _iterator = _createForOfIteratorHelper$a(restruct.molecule.bonds.keys()),
|
|
18206
|
+
_step;
|
|
18207
|
+
try {
|
|
18208
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
18209
|
+
var id = _step.value;
|
|
18210
|
+
new BondAttr(id, 'isPreview', false).perform(restruct);
|
|
18211
|
+
}
|
|
18212
|
+
} catch (err) {
|
|
18213
|
+
_iterator.e(err);
|
|
18214
|
+
} finally {
|
|
18215
|
+
_iterator.f();
|
|
18216
|
+
}
|
|
18217
|
+
var _iterator2 = _createForOfIteratorHelper$a(restruct.molecule.atoms.keys()),
|
|
18218
|
+
_step2;
|
|
18219
|
+
try {
|
|
18220
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
18221
|
+
var _id = _step2.value;
|
|
18222
|
+
new AtomAttr(_id, 'isPreview', false).perform(restruct);
|
|
18223
|
+
}
|
|
18224
|
+
} catch (err) {
|
|
18225
|
+
_iterator2.e(err);
|
|
18226
|
+
} finally {
|
|
18227
|
+
_iterator2.f();
|
|
18228
|
+
}
|
|
18229
|
+
var completeAction = dragCtx.action;
|
|
18230
|
+
if (completeAction && !completeAction.isDummy()) {
|
|
18231
|
+
this.editor.update(completeAction);
|
|
18232
|
+
}
|
|
18233
|
+
this.editor.hover(this.editor.findItem(event, null), null, event);
|
|
18234
|
+
return true;
|
|
18235
|
+
}
|
|
18236
|
+
}, {
|
|
18237
|
+
key: "cancel",
|
|
18238
|
+
value: function cancel() {
|
|
18239
|
+
var _this$templatePreview3;
|
|
18240
|
+
(_this$templatePreview3 = this.templatePreview) === null || _this$templatePreview3 === void 0 || _this$templatePreview3.hidePreview();
|
|
18241
|
+
this.mouseup();
|
|
18242
|
+
}
|
|
18243
|
+
}, {
|
|
18244
|
+
key: "mouseleave",
|
|
18245
|
+
value: function mouseleave() {
|
|
18246
|
+
this.cancel();
|
|
18247
|
+
}
|
|
18248
|
+
}, {
|
|
18249
|
+
key: "mouseLeaveClientArea",
|
|
18250
|
+
value: function mouseLeaveClientArea() {
|
|
18251
|
+
var _this$templatePreview4;
|
|
18252
|
+
(_this$templatePreview4 = this.templatePreview) === null || _this$templatePreview4 === void 0 || _this$templatePreview4.hidePreview();
|
|
18253
|
+
}
|
|
18254
|
+
}]);
|
|
18255
|
+
return TemplateTool;
|
|
18256
|
+
}();
|
|
18257
|
+
function addOnCanvasWithoutMerge(_ref5) {
|
|
18258
|
+
var restruct = _ref5.restruct,
|
|
18259
|
+
template = _ref5.template,
|
|
18260
|
+
dragCtx = _ref5.dragCtx,
|
|
18261
|
+
editor = _ref5.editor,
|
|
18262
|
+
event = _ref5.event;
|
|
18263
|
+
var _fromTemplateOnCanvas3 = fromTemplateOnCanvas(restruct, template, dragCtx.xy0, 0, false),
|
|
18264
|
+
_fromTemplateOnCanvas4 = _slicedToArray$1(_fromTemplateOnCanvas3, 1),
|
|
18265
|
+
action = _fromTemplateOnCanvas4[0];
|
|
18266
|
+
editor.update(action);
|
|
18267
|
+
editor.selection(null);
|
|
18268
|
+
editor.hover(editor.findItem(event, null), null, event);
|
|
18269
|
+
editor.event.message.dispatch({
|
|
18270
|
+
info: false
|
|
18271
|
+
});
|
|
18272
|
+
}
|
|
18273
|
+
function getTemplateMode(tmpl) {
|
|
18274
|
+
var _tmpl$props;
|
|
18275
|
+
if (tmpl.mode) {
|
|
18276
|
+
return tmpl.mode;
|
|
18277
|
+
}
|
|
18278
|
+
if (['Functional Groups', 'Salts and Solvents'].includes((_tmpl$props = tmpl.props) === null || _tmpl$props === void 0 ? void 0 : _tmpl$props.group)) {
|
|
18279
|
+
return MODES.FG;
|
|
18280
|
+
}
|
|
18281
|
+
return null;
|
|
18282
|
+
}
|
|
18283
|
+
function getSign(molecule, bond, v) {
|
|
18284
|
+
var begin = molecule.atoms.get(bond.begin).pp;
|
|
18285
|
+
var end = molecule.atoms.get(bond.end).pp;
|
|
18286
|
+
var sign = Vec2.cross(Vec2.diff(begin, end), Vec2.diff(v, end));
|
|
18287
|
+
if (sign > 0) {
|
|
18288
|
+
return 1;
|
|
18289
|
+
}
|
|
18290
|
+
if (sign < 0) {
|
|
18291
|
+
return -1;
|
|
18292
|
+
}
|
|
18293
|
+
return 0;
|
|
18294
|
+
}
|
|
18295
|
+
function getTargetAtomId(struct, ci) {
|
|
18296
|
+
if (ci.map === 'atoms') {
|
|
18297
|
+
return ci.id;
|
|
18298
|
+
}
|
|
18299
|
+
if (ci.map === 'functionalGroups') {
|
|
18300
|
+
var group = struct.sgroups.get(ci.id);
|
|
18301
|
+
return group === null || group === void 0 ? void 0 : group.getAttachmentAtomId();
|
|
18302
|
+
}
|
|
18303
|
+
}
|
|
18304
|
+
|
|
18305
|
+
function ownKeys$S(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; }
|
|
18306
|
+
function _objectSpread$S(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$S(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$S(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18307
|
+
function handleHotkeyOverItem(props) {
|
|
18308
|
+
if (props.newAction.tool === 'eraser') {
|
|
18309
|
+
handleEraser(props);
|
|
18310
|
+
} else if (props.newAction.dialog) {
|
|
18311
|
+
handleDialog(props);
|
|
18312
|
+
} else if (props.newAction.tool) {
|
|
18313
|
+
handleTool(props);
|
|
18314
|
+
} else {
|
|
18315
|
+
handleOtherActions(props);
|
|
18316
|
+
}
|
|
18317
|
+
}
|
|
18318
|
+
function handleOtherActions(_ref) {
|
|
18319
|
+
var dispatch = _ref.dispatch,
|
|
18320
|
+
newAction = _ref.newAction;
|
|
18321
|
+
dispatch(onAction(newAction));
|
|
18322
|
+
}
|
|
18323
|
+
function eraseItem(_ref2) {
|
|
18324
|
+
var editor = _ref2.editor,
|
|
18325
|
+
item = _ref2.item;
|
|
18326
|
+
var action = fromFragmentDeletion(editor.render.ctab, item);
|
|
18327
|
+
editor.update(action);
|
|
18328
|
+
editor.hover(null);
|
|
18329
|
+
}
|
|
18330
|
+
function handleEraser(_ref3) {
|
|
18331
|
+
var editor = _ref3.editor,
|
|
18332
|
+
hoveredItem = _ref3.hoveredItem,
|
|
18333
|
+
newAction = _ref3.newAction,
|
|
18334
|
+
dispatch = _ref3.dispatch;
|
|
18335
|
+
var item = mapItemsToArrays(hoveredItem);
|
|
18336
|
+
var itemType = Object.keys(hoveredItem)[0];
|
|
18337
|
+
var activeTool = editor.tool();
|
|
18338
|
+
if (activeTool instanceof TemplateTool) {
|
|
18339
|
+
var _activeTool$templateP;
|
|
18340
|
+
(_activeTool$templateP = activeTool.templatePreview) === null || _activeTool$templateP === void 0 || _activeTool$templateP.hideConnectedPreview();
|
|
18341
|
+
}
|
|
18342
|
+
if ([STRUCT_TYPE.atoms, STRUCT_TYPE.bonds].includes(itemType)) {
|
|
18343
|
+
isFunctionalGroupChange({
|
|
18344
|
+
editor: editor,
|
|
18345
|
+
hoveredItemId: item[itemType][0],
|
|
18346
|
+
newAction: newAction,
|
|
18347
|
+
dispatch: dispatch
|
|
18348
|
+
}, itemType).then(function (res) {
|
|
18349
|
+
res && eraseItem({
|
|
18350
|
+
editor: editor,
|
|
18351
|
+
item: item
|
|
18352
|
+
});
|
|
18353
|
+
});
|
|
18354
|
+
} else {
|
|
18355
|
+
eraseItem({
|
|
18356
|
+
editor: editor,
|
|
18357
|
+
item: item
|
|
18358
|
+
});
|
|
18359
|
+
}
|
|
18360
|
+
}
|
|
18361
|
+
function handleDialog(_ref4) {
|
|
18362
|
+
var hoveredItem = _ref4.hoveredItem,
|
|
18363
|
+
newAction = _ref4.newAction,
|
|
18364
|
+
editor = _ref4.editor,
|
|
18365
|
+
dispatch = _ref4.dispatch;
|
|
18366
|
+
var dialogType = Object.keys(hoveredItem)[0];
|
|
18367
|
+
var dialogHandler = getDialogHandler(dialogType);
|
|
18368
|
+
var hoveredItemId = hoveredItem[dialogType];
|
|
18369
|
+
if (dialogHandler) {
|
|
18370
|
+
var props = {
|
|
18371
|
+
hoveredItemId: hoveredItemId,
|
|
18372
|
+
newAction: newAction,
|
|
18373
|
+
editor: editor,
|
|
18374
|
+
dispatch: dispatch
|
|
18375
|
+
};
|
|
18376
|
+
return dialogHandler(props);
|
|
18377
|
+
}
|
|
18378
|
+
}
|
|
18379
|
+
function getDialogHandler(itemType) {
|
|
18380
|
+
var dialogs = {
|
|
18381
|
+
atoms: function atoms(props) {
|
|
18382
|
+
return handleAtomPropsDialog(props);
|
|
18383
|
+
},
|
|
18384
|
+
bonds: function bonds(props) {
|
|
18385
|
+
return handleBondPropsDialog(props);
|
|
18386
|
+
}
|
|
18387
|
+
};
|
|
18388
|
+
var dialog = dialogs[itemType];
|
|
18389
|
+
return dialog;
|
|
18390
|
+
}
|
|
18391
|
+
function handleAtomPropsDialog(_ref5) {
|
|
18392
|
+
var hoveredItemId = _ref5.hoveredItemId,
|
|
18393
|
+
newAction = _ref5.newAction,
|
|
18394
|
+
editor = _ref5.editor,
|
|
18395
|
+
dispatch = _ref5.dispatch;
|
|
18396
|
+
var selection = editor.selection();
|
|
18397
|
+
var atomsSelected = selection === null || selection === void 0 ? void 0 : selection.atoms;
|
|
18398
|
+
var restruct = editor.render.ctab;
|
|
18399
|
+
if (atomsSelected && atomsSelected.includes(hoveredItemId)) {
|
|
18400
|
+
var atoms = getSelectedAtoms(selection, restruct.molecule);
|
|
18401
|
+
var changeAtomPromise = editor.event.elementEdit.dispatch(atoms);
|
|
18402
|
+
updateSelectedAtoms({
|
|
18403
|
+
atoms: selection.atoms || [],
|
|
18404
|
+
editor: editor,
|
|
18405
|
+
changeAtomPromise: changeAtomPromise
|
|
18406
|
+
});
|
|
18407
|
+
} else {
|
|
18408
|
+
var atomFromStruct = restruct.atoms.get(hoveredItemId);
|
|
18409
|
+
var convertedAtomForModal = fromAtom(atomFromStruct === null || atomFromStruct === void 0 ? void 0 : atomFromStruct.a);
|
|
18410
|
+
openDialog(dispatch, newAction.dialog, convertedAtomForModal).then(function (res) {
|
|
18411
|
+
var updatedAtom = fromAtomsAttrs(restruct, hoveredItemId, toAtom(res), false);
|
|
18412
|
+
editor.update(updatedAtom);
|
|
18413
|
+
})["catch"](function (e) {
|
|
18414
|
+
KetcherLogger.error('handleHotkeysOverItem.ts::handleAtomPropsDialog', e);
|
|
18415
|
+
});
|
|
18416
|
+
}
|
|
18417
|
+
}
|
|
18418
|
+
function handleBondPropsDialog(_ref6) {
|
|
18419
|
+
var hoveredItemId = _ref6.hoveredItemId,
|
|
18420
|
+
newAction = _ref6.newAction,
|
|
18421
|
+
editor = _ref6.editor,
|
|
18422
|
+
dispatch = _ref6.dispatch;
|
|
18423
|
+
var restruct = editor.render.ctab;
|
|
18424
|
+
var bondFromStruct = restruct.bonds.get(hoveredItemId);
|
|
18425
|
+
var convertedBondForModal = fromBond(bondFromStruct === null || bondFromStruct === void 0 ? void 0 : bondFromStruct.b);
|
|
18426
|
+
openDialog(dispatch, newAction.dialog, convertedBondForModal).then(function (res) {
|
|
18427
|
+
var updatedBond = fromBondsAttrs(restruct, hoveredItemId, toBond(res), false);
|
|
18428
|
+
editor.update(updatedBond);
|
|
18429
|
+
})["catch"](function (e) {
|
|
18430
|
+
KetcherLogger.error('handleHoutkeysOverItem.ts::handleBondPropsDialog', e);
|
|
18431
|
+
});
|
|
18432
|
+
}
|
|
18433
|
+
function handleTool(_ref7) {
|
|
18434
|
+
var hoveredItem = _ref7.hoveredItem,
|
|
18435
|
+
newAction = _ref7.newAction,
|
|
18436
|
+
editor = _ref7.editor,
|
|
18437
|
+
dispatch = _ref7.dispatch;
|
|
18438
|
+
var _loop = function _loop() {
|
|
18439
|
+
var toolHandler = getToolHandler(item, newAction.tool);
|
|
18440
|
+
var isChangeStructureTool = newAction.tool !== 'hand';
|
|
18441
|
+
var hoveredItemId = hoveredItem[item];
|
|
18442
|
+
if (toolHandler) {
|
|
18443
|
+
var props = {
|
|
18444
|
+
hoveredItemId: hoveredItemId,
|
|
18445
|
+
editor: editor,
|
|
18446
|
+
newAction: newAction,
|
|
18447
|
+
dispatch: dispatch
|
|
18448
|
+
};
|
|
18449
|
+
isFunctionalGroupChange(props, item).then(function (result) {
|
|
18450
|
+
if (!result && isChangeStructureTool) return;
|
|
18451
|
+
toolHandler(props);
|
|
18452
|
+
});
|
|
18453
|
+
}
|
|
18454
|
+
};
|
|
18455
|
+
for (var item in hoveredItem) {
|
|
18456
|
+
_loop();
|
|
18457
|
+
}
|
|
18458
|
+
}
|
|
17761
18459
|
function isFunctionalGroupChange(_x, _x2) {
|
|
17762
18460
|
return _isFunctionalGroupChange.apply(this, arguments);
|
|
17763
18461
|
}
|
|
@@ -17829,7 +18527,7 @@ function handleAtomTool(_ref10) {
|
|
|
17829
18527
|
var hoveredItemId = _ref10.hoveredItemId,
|
|
17830
18528
|
newAction = _ref10.newAction,
|
|
17831
18529
|
editor = _ref10.editor;
|
|
17832
|
-
var atomProps = _objectSpread$
|
|
18530
|
+
var atomProps = _objectSpread$S({}, newAction.opts);
|
|
17833
18531
|
var updatedAtoms = fromAtomsAttrs(editor.render.ctab, hoveredItemId, atomProps, true);
|
|
17834
18532
|
editor.update(updatedAtoms);
|
|
17835
18533
|
}
|
|
@@ -17837,7 +18535,7 @@ function handleSgroupsTool(_ref11) {
|
|
|
17837
18535
|
var hoveredItemId = _ref11.hoveredItemId,
|
|
17838
18536
|
newAction = _ref11.newAction,
|
|
17839
18537
|
editor = _ref11.editor;
|
|
17840
|
-
var atomProps = _objectSpread$
|
|
18538
|
+
var atomProps = _objectSpread$S({}, newAction.opts);
|
|
17841
18539
|
var action = new Action();
|
|
17842
18540
|
var ctab = editor.render.ctab;
|
|
17843
18541
|
var sGroup = ctab.molecule.sgroups.get(hoveredItemId);
|
|
@@ -18502,11 +19200,11 @@ var LoadingCircles = function LoadingCircles() {
|
|
|
18502
19200
|
});
|
|
18503
19201
|
};
|
|
18504
19202
|
|
|
18505
|
-
function ownKeys$
|
|
18506
|
-
function _objectSpread$
|
|
18507
|
-
function _createForOfIteratorHelper$
|
|
18508
|
-
function _unsupportedIterableToArray$
|
|
18509
|
-
function _arrayLikeToArray$
|
|
19203
|
+
function ownKeys$R(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; }
|
|
19204
|
+
function _objectSpread$R(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$R(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$R(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19205
|
+
function _createForOfIteratorHelper$9(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$9(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
19206
|
+
function _unsupportedIterableToArray$9(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$9(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$9(o, minLen); }
|
|
19207
|
+
function _arrayLikeToArray$9(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
18510
19208
|
var SELECTION_DISTANCE_COEFFICIENT = 0.4;
|
|
18511
19209
|
var SELECTION_WITHIN_TEXT = 0;
|
|
18512
19210
|
var findMaps = {
|
|
@@ -18839,7 +19537,7 @@ function findClosestSGroup(restruct, pos) {
|
|
|
18839
19537
|
function findClosestFG(restruct, pos, skip) {
|
|
18840
19538
|
var sGroups = restruct.sgroups;
|
|
18841
19539
|
var skipId = skip && skip.map === 'functionalGroups' ? skip.id : null;
|
|
18842
|
-
var _iterator = _createForOfIteratorHelper$
|
|
19540
|
+
var _iterator = _createForOfIteratorHelper$9(sGroups.entries()),
|
|
18843
19541
|
_step;
|
|
18844
19542
|
try {
|
|
18845
19543
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -18882,7 +19580,7 @@ function findClosestItem(restruct, pos, maps, skip, options) {
|
|
|
18882
19580
|
var minDist = res ? res.dist : null;
|
|
18883
19581
|
var item = findMaps[mp](restruct, pos, skip, minDist, options);
|
|
18884
19582
|
if (item !== null) {
|
|
18885
|
-
var enrichedItem = _objectSpread$
|
|
19583
|
+
var enrichedItem = _objectSpread$R({
|
|
18886
19584
|
map: mp
|
|
18887
19585
|
}, item);
|
|
18888
19586
|
if (mp === 'sgroupData') {
|
|
@@ -19006,9 +19704,9 @@ function _editRGroupAttachmentPoint() {
|
|
|
19006
19704
|
return _editRGroupAttachmentPoint.apply(this, arguments);
|
|
19007
19705
|
}
|
|
19008
19706
|
|
|
19009
|
-
function _createForOfIteratorHelper$
|
|
19010
|
-
function _unsupportedIterableToArray$
|
|
19011
|
-
function _arrayLikeToArray$
|
|
19707
|
+
function _createForOfIteratorHelper$8(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$8(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
19708
|
+
function _unsupportedIterableToArray$8(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$8(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$8(o, minLen); }
|
|
19709
|
+
function _arrayLikeToArray$8(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19012
19710
|
var APointTool = function () {
|
|
19013
19711
|
function APointTool(editor) {
|
|
19014
19712
|
_classCallCheck$2(this, APointTool);
|
|
@@ -19048,7 +19746,7 @@ var APointTool = function () {
|
|
|
19048
19746
|
}
|
|
19049
19747
|
}
|
|
19050
19748
|
if (atomResult.length > 0) {
|
|
19051
|
-
var _iterator = _createForOfIteratorHelper$
|
|
19749
|
+
var _iterator = _createForOfIteratorHelper$8(atomResult),
|
|
19052
19750
|
_step;
|
|
19053
19751
|
try {
|
|
19054
19752
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -19083,9 +19781,9 @@ var APointTool = function () {
|
|
|
19083
19781
|
return APointTool;
|
|
19084
19782
|
}();
|
|
19085
19783
|
|
|
19086
|
-
function _createForOfIteratorHelper$
|
|
19087
|
-
function _unsupportedIterableToArray$
|
|
19088
|
-
function _arrayLikeToArray$
|
|
19784
|
+
function _createForOfIteratorHelper$7(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$7(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
19785
|
+
function _unsupportedIterableToArray$7(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$7(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$7(o, minLen); }
|
|
19786
|
+
function _arrayLikeToArray$7(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19089
19787
|
var AttachTool = function () {
|
|
19090
19788
|
function AttachTool(editor, attachPoints) {
|
|
19091
19789
|
_classCallCheck$2(this, AttachTool);
|
|
@@ -19138,7 +19836,7 @@ var AttachTool = function () {
|
|
|
19138
19836
|
}
|
|
19139
19837
|
}
|
|
19140
19838
|
if (atomResult.length > 0) {
|
|
19141
|
-
var _iterator = _createForOfIteratorHelper$
|
|
19839
|
+
var _iterator = _createForOfIteratorHelper$7(atomResult),
|
|
19142
19840
|
_step;
|
|
19143
19841
|
try {
|
|
19144
19842
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -19158,7 +19856,7 @@ var AttachTool = function () {
|
|
|
19158
19856
|
});
|
|
19159
19857
|
return;
|
|
19160
19858
|
} else if (bondResult.length > 0) {
|
|
19161
|
-
var _iterator2 = _createForOfIteratorHelper$
|
|
19859
|
+
var _iterator2 = _createForOfIteratorHelper$7(bondResult),
|
|
19162
19860
|
_step2;
|
|
19163
19861
|
try {
|
|
19164
19862
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
@@ -19194,9 +19892,9 @@ var AttachTool = function () {
|
|
|
19194
19892
|
return AttachTool;
|
|
19195
19893
|
}();
|
|
19196
19894
|
|
|
19197
|
-
function _createForOfIteratorHelper$
|
|
19198
|
-
function _unsupportedIterableToArray$
|
|
19199
|
-
function _arrayLikeToArray$
|
|
19895
|
+
function _createForOfIteratorHelper$6(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$6(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
19896
|
+
function _unsupportedIterableToArray$6(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$6(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$6(o, minLen); }
|
|
19897
|
+
function _arrayLikeToArray$6(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19200
19898
|
var BondTool = function () {
|
|
19201
19899
|
function BondTool(editor, bondProps) {
|
|
19202
19900
|
var _editor$selection;
|
|
@@ -19236,7 +19934,7 @@ var BondTool = function () {
|
|
|
19236
19934
|
if (bondId !== null) bondResult.push(bondId);
|
|
19237
19935
|
}
|
|
19238
19936
|
if (atomResult.length > 0) {
|
|
19239
|
-
var _iterator = _createForOfIteratorHelper$
|
|
19937
|
+
var _iterator = _createForOfIteratorHelper$6(atomResult),
|
|
19240
19938
|
_step;
|
|
19241
19939
|
try {
|
|
19242
19940
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -19256,7 +19954,7 @@ var BondTool = function () {
|
|
|
19256
19954
|
});
|
|
19257
19955
|
return;
|
|
19258
19956
|
} else if (bondResult.length > 0) {
|
|
19259
|
-
var _iterator2 = _createForOfIteratorHelper$
|
|
19957
|
+
var _iterator2 = _createForOfIteratorHelper$6(bondResult),
|
|
19260
19958
|
_step2;
|
|
19261
19959
|
try {
|
|
19262
19960
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
@@ -19369,7 +20067,7 @@ var BondTool = function () {
|
|
|
19369
20067
|
}
|
|
19370
20068
|
}
|
|
19371
20069
|
if (atomResult.length > 0) {
|
|
19372
|
-
var _iterator3 = _createForOfIteratorHelper$
|
|
20070
|
+
var _iterator3 = _createForOfIteratorHelper$6(atomResult),
|
|
19373
20071
|
_step3;
|
|
19374
20072
|
try {
|
|
19375
20073
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
@@ -19489,7 +20187,7 @@ var BondTool = function () {
|
|
|
19489
20187
|
}, {
|
|
19490
20188
|
key: "getExistingBond",
|
|
19491
20189
|
value: function getExistingBond(struct, begin, end) {
|
|
19492
|
-
var _iterator4 = _createForOfIteratorHelper$
|
|
20190
|
+
var _iterator4 = _createForOfIteratorHelper$6(struct.bonds.entries()),
|
|
19493
20191
|
_step4;
|
|
19494
20192
|
try {
|
|
19495
20193
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
@@ -19512,9 +20210,9 @@ var BondTool = function () {
|
|
|
19512
20210
|
return BondTool;
|
|
19513
20211
|
}();
|
|
19514
20212
|
|
|
19515
|
-
function _createForOfIteratorHelper$
|
|
19516
|
-
function _unsupportedIterableToArray$
|
|
19517
|
-
function _arrayLikeToArray$
|
|
20213
|
+
function _createForOfIteratorHelper$5(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$5(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
20214
|
+
function _unsupportedIterableToArray$5(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$5(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$5(o, minLen); }
|
|
20215
|
+
function _arrayLikeToArray$5(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19518
20216
|
var ChainTool = function () {
|
|
19519
20217
|
function ChainTool(editor) {
|
|
19520
20218
|
_classCallCheck$2(this, ChainTool);
|
|
@@ -19549,7 +20247,7 @@ var ChainTool = function () {
|
|
|
19549
20247
|
}
|
|
19550
20248
|
}
|
|
19551
20249
|
if (atomResult.length > 0) {
|
|
19552
|
-
var _iterator = _createForOfIteratorHelper$
|
|
20250
|
+
var _iterator = _createForOfIteratorHelper$5(atomResult),
|
|
19553
20251
|
_step;
|
|
19554
20252
|
try {
|
|
19555
20253
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -19569,7 +20267,7 @@ var ChainTool = function () {
|
|
|
19569
20267
|
});
|
|
19570
20268
|
return;
|
|
19571
20269
|
} else if (bondResult.length > 0) {
|
|
19572
|
-
var _iterator2 = _createForOfIteratorHelper$
|
|
20270
|
+
var _iterator2 = _createForOfIteratorHelper$5(bondResult),
|
|
19573
20271
|
_step2;
|
|
19574
20272
|
try {
|
|
19575
20273
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
@@ -19674,7 +20372,7 @@ var ChainTool = function () {
|
|
|
19674
20372
|
}
|
|
19675
20373
|
}
|
|
19676
20374
|
if (atomResult.length > 0) {
|
|
19677
|
-
var _iterator3 = _createForOfIteratorHelper$
|
|
20375
|
+
var _iterator3 = _createForOfIteratorHelper$5(atomResult),
|
|
19678
20376
|
_step3;
|
|
19679
20377
|
try {
|
|
19680
20378
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
@@ -19736,9 +20434,9 @@ var ChainTool = function () {
|
|
|
19736
20434
|
return ChainTool;
|
|
19737
20435
|
}();
|
|
19738
20436
|
|
|
19739
|
-
function _createForOfIteratorHelper$
|
|
19740
|
-
function _unsupportedIterableToArray$
|
|
19741
|
-
function _arrayLikeToArray$
|
|
20437
|
+
function _createForOfIteratorHelper$4(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$4(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
20438
|
+
function _unsupportedIterableToArray$4(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$4(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$4(o, minLen); }
|
|
20439
|
+
function _arrayLikeToArray$4(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19742
20440
|
var ChargeTool = function () {
|
|
19743
20441
|
function ChargeTool(editor, charge) {
|
|
19744
20442
|
_classCallCheck$2(this, ChargeTool);
|
|
@@ -19779,7 +20477,7 @@ var ChargeTool = function () {
|
|
|
19779
20477
|
}
|
|
19780
20478
|
}
|
|
19781
20479
|
if (atomResult.length > 0) {
|
|
19782
|
-
var _iterator = _createForOfIteratorHelper$
|
|
20480
|
+
var _iterator = _createForOfIteratorHelper$4(atomResult),
|
|
19783
20481
|
_step;
|
|
19784
20482
|
try {
|
|
19785
20483
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -19859,9 +20557,9 @@ var EnhancedStereoTool = function () {
|
|
|
19859
20557
|
return EnhancedStereoTool;
|
|
19860
20558
|
}();
|
|
19861
20559
|
|
|
19862
|
-
function _createForOfIteratorHelper$
|
|
19863
|
-
function _unsupportedIterableToArray$
|
|
19864
|
-
function _arrayLikeToArray$
|
|
20560
|
+
function _createForOfIteratorHelper$3(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$3(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
20561
|
+
function _unsupportedIterableToArray$3(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); }
|
|
20562
|
+
function _arrayLikeToArray$3(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19865
20563
|
var EraserTool = function () {
|
|
19866
20564
|
function EraserTool(editor, mode) {
|
|
19867
20565
|
_classCallCheck$2(this, EraserTool);
|
|
@@ -19909,7 +20607,7 @@ var EraserTool = function () {
|
|
|
19909
20607
|
var bondsResult = [];
|
|
19910
20608
|
var preResult = [];
|
|
19911
20609
|
if (selected && functionalGroups.size && selected.atoms) {
|
|
19912
|
-
var _iterator = _createForOfIteratorHelper$
|
|
20610
|
+
var _iterator = _createForOfIteratorHelper$3(selected.atoms),
|
|
19913
20611
|
_step;
|
|
19914
20612
|
try {
|
|
19915
20613
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -19918,7 +20616,7 @@ var EraserTool = function () {
|
|
|
19918
20616
|
var atomId = FunctionalGroup.atomsInFunctionalGroup(functionalGroups, atom);
|
|
19919
20617
|
var atomFromStruct = atomId !== null && ((_struct$atoms$get = struct.atoms.get(atomId)) === null || _struct$atoms$get === void 0 ? void 0 : _struct$atoms$get.a);
|
|
19920
20618
|
if (atomFromStruct) {
|
|
19921
|
-
var _iterator2 = _createForOfIteratorHelper$
|
|
20619
|
+
var _iterator2 = _createForOfIteratorHelper$3(atomFromStruct.sgs.values()),
|
|
19922
20620
|
_step2;
|
|
19923
20621
|
try {
|
|
19924
20622
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
@@ -19948,7 +20646,7 @@ var EraserTool = function () {
|
|
|
19948
20646
|
}
|
|
19949
20647
|
}
|
|
19950
20648
|
if (selected && functionalGroups.size && selected.bonds) {
|
|
19951
|
-
var _iterator3 = _createForOfIteratorHelper$
|
|
20649
|
+
var _iterator3 = _createForOfIteratorHelper$3(selected.bonds),
|
|
19952
20650
|
_step3;
|
|
19953
20651
|
try {
|
|
19954
20652
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
@@ -19967,7 +20665,7 @@ var EraserTool = function () {
|
|
|
19967
20665
|
}
|
|
19968
20666
|
}
|
|
19969
20667
|
if (selected && functionalGroups.size && selected.rgroupAttachmentPoints) {
|
|
19970
|
-
var _iterator4 = _createForOfIteratorHelper$
|
|
20668
|
+
var _iterator4 = _createForOfIteratorHelper$3(selected.rgroupAttachmentPoints),
|
|
19971
20669
|
_step4;
|
|
19972
20670
|
try {
|
|
19973
20671
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
@@ -19984,7 +20682,7 @@ var EraserTool = function () {
|
|
|
19984
20682
|
}
|
|
19985
20683
|
}
|
|
19986
20684
|
if (atomsResult.length > 0) {
|
|
19987
|
-
var _iterator5 = _createForOfIteratorHelper$
|
|
20685
|
+
var _iterator5 = _createForOfIteratorHelper$3(atomsResult),
|
|
19988
20686
|
_step5;
|
|
19989
20687
|
try {
|
|
19990
20688
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
@@ -19999,7 +20697,7 @@ var EraserTool = function () {
|
|
|
19999
20697
|
}
|
|
20000
20698
|
}
|
|
20001
20699
|
if (bondsResult.length > 0) {
|
|
20002
|
-
var _iterator6 = _createForOfIteratorHelper$
|
|
20700
|
+
var _iterator6 = _createForOfIteratorHelper$3(bondsResult),
|
|
20003
20701
|
_step6;
|
|
20004
20702
|
try {
|
|
20005
20703
|
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
@@ -20075,7 +20773,7 @@ var EraserTool = function () {
|
|
|
20075
20773
|
}
|
|
20076
20774
|
}
|
|
20077
20775
|
if (atomResult.length) {
|
|
20078
|
-
var _iterator7 = _createForOfIteratorHelper$
|
|
20776
|
+
var _iterator7 = _createForOfIteratorHelper$3(atomResult),
|
|
20079
20777
|
_step7;
|
|
20080
20778
|
try {
|
|
20081
20779
|
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
@@ -20091,7 +20789,7 @@ var EraserTool = function () {
|
|
|
20091
20789
|
_iterator7.f();
|
|
20092
20790
|
}
|
|
20093
20791
|
} else if (bondResult.length) {
|
|
20094
|
-
var _iterator8 = _createForOfIteratorHelper$
|
|
20792
|
+
var _iterator8 = _createForOfIteratorHelper$3(bondResult),
|
|
20095
20793
|
_step8;
|
|
20096
20794
|
try {
|
|
20097
20795
|
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
@@ -20166,8 +20864,8 @@ var EraserTool = function () {
|
|
|
20166
20864
|
return EraserTool;
|
|
20167
20865
|
}();
|
|
20168
20866
|
|
|
20169
|
-
function ownKeys$
|
|
20170
|
-
function _objectSpread$
|
|
20867
|
+
function ownKeys$Q(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; }
|
|
20868
|
+
function _objectSpread$Q(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$Q(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$Q(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20171
20869
|
var HandTool = function () {
|
|
20172
20870
|
function HandTool(editor) {
|
|
20173
20871
|
_classCallCheck$2(this, HandTool);
|
|
@@ -20212,7 +20910,7 @@ var HandTool = function () {
|
|
|
20212
20910
|
var diff = Vec2.diff(this.endPos, this.begPos).scaled(1 / rnd.options.zoom);
|
|
20213
20911
|
this.begPos = this.endPos;
|
|
20214
20912
|
rnd.setViewBox(function (prev) {
|
|
20215
|
-
return _objectSpread$
|
|
20913
|
+
return _objectSpread$Q(_objectSpread$Q({}, prev), {}, {
|
|
20216
20914
|
minX: prev.minX - diff.x,
|
|
20217
20915
|
minY: prev.minY - diff.y
|
|
20218
20916
|
});
|
|
@@ -20255,8 +20953,8 @@ var HandTool = function () {
|
|
|
20255
20953
|
return HandTool;
|
|
20256
20954
|
}();
|
|
20257
20955
|
|
|
20258
|
-
function ownKeys$
|
|
20259
|
-
function _objectSpread$
|
|
20956
|
+
function ownKeys$P(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; }
|
|
20957
|
+
function _objectSpread$P(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$P(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$P(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20260
20958
|
var PasteTool = function () {
|
|
20261
20959
|
function PasteTool(editor, struct) {
|
|
20262
20960
|
var _struct$functionalGro;
|
|
@@ -20370,7 +21068,7 @@ var PasteTool = function () {
|
|
|
20370
21068
|
}, {
|
|
20371
21069
|
key: "mouseup",
|
|
20372
21070
|
value: function mouseup() {
|
|
20373
|
-
var idsOfItemsMerged = this.mergeItems && _objectSpread$
|
|
21071
|
+
var idsOfItemsMerged = this.mergeItems && _objectSpread$P(_objectSpread$P({}, this.mergeItems.atoms && {
|
|
20374
21072
|
atoms: Array.from(this.mergeItems.atoms.values())
|
|
20375
21073
|
}), this.mergeItems.bonds && {
|
|
20376
21074
|
bonds: Array.from(this.mergeItems.bonds.values())
|
|
@@ -20440,9 +21138,9 @@ function prepareTemplateFromSingleGroup(molecule) {
|
|
|
20440
21138
|
return template;
|
|
20441
21139
|
}
|
|
20442
21140
|
|
|
20443
|
-
function _createForOfIteratorHelper$
|
|
20444
|
-
function _unsupportedIterableToArray$
|
|
20445
|
-
function _arrayLikeToArray$
|
|
21141
|
+
function _createForOfIteratorHelper$2(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$2(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
21142
|
+
function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$2(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen); }
|
|
21143
|
+
function _arrayLikeToArray$2(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
20446
21144
|
var RGroupAtomTool = function () {
|
|
20447
21145
|
function RGroupAtomTool(editor) {
|
|
20448
21146
|
_classCallCheck$2(this, RGroupAtomTool);
|
|
@@ -20480,7 +21178,7 @@ var RGroupAtomTool = function () {
|
|
|
20480
21178
|
}
|
|
20481
21179
|
}
|
|
20482
21180
|
if (atomResult.length > 0) {
|
|
20483
|
-
var _iterator = _createForOfIteratorHelper$
|
|
21181
|
+
var _iterator = _createForOfIteratorHelper$2(atomResult),
|
|
20484
21182
|
_step;
|
|
20485
21183
|
try {
|
|
20486
21184
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -20546,9 +21244,9 @@ function propsDialog$1(editor, id, pos) {
|
|
|
20546
21244
|
});
|
|
20547
21245
|
}
|
|
20548
21246
|
|
|
20549
|
-
function _createForOfIteratorHelper$
|
|
20550
|
-
function _unsupportedIterableToArray$
|
|
20551
|
-
function _arrayLikeToArray$
|
|
21247
|
+
function _createForOfIteratorHelper$1(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
21248
|
+
function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
|
|
21249
|
+
function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
20552
21250
|
var RGroupFragmentTool = function () {
|
|
20553
21251
|
function RGroupFragmentTool(editor) {
|
|
20554
21252
|
_classCallCheck$2(this, RGroupFragmentTool);
|
|
@@ -20585,7 +21283,7 @@ var RGroupFragmentTool = function () {
|
|
|
20585
21283
|
}
|
|
20586
21284
|
}
|
|
20587
21285
|
if (atomResult.length > 0) {
|
|
20588
|
-
var _iterator = _createForOfIteratorHelper$
|
|
21286
|
+
var _iterator = _createForOfIteratorHelper$1(atomResult),
|
|
20589
21287
|
_step;
|
|
20590
21288
|
try {
|
|
20591
21289
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -20605,7 +21303,7 @@ var RGroupFragmentTool = function () {
|
|
|
20605
21303
|
});
|
|
20606
21304
|
return;
|
|
20607
21305
|
} else if (bondResult.length > 0) {
|
|
20608
|
-
var _iterator2 = _createForOfIteratorHelper$
|
|
21306
|
+
var _iterator2 = _createForOfIteratorHelper$1(bondResult),
|
|
20609
21307
|
_step2;
|
|
20610
21308
|
try {
|
|
20611
21309
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
@@ -21038,8 +21736,8 @@ function normalizeAngle(angle) {
|
|
|
21038
21736
|
return angleWithinFullCircle;
|
|
21039
21737
|
}
|
|
21040
21738
|
|
|
21041
|
-
function ownKeys$
|
|
21042
|
-
function _objectSpread$
|
|
21739
|
+
function ownKeys$O(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; }
|
|
21740
|
+
function _objectSpread$O(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$O(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$O(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21043
21741
|
var SNAP_ANGLES_RELATIVE_TO_FIXED_BOND = [Math.PI / 2, -Math.PI / 2, 2 * Math.PI / 3, -(2 * Math.PI) / 3, Math.PI];
|
|
21044
21742
|
var MAX_SNAP_DELTA = Math.PI / 18;
|
|
21045
21743
|
var ANGLE_INDICATOR_VISIBLE_DELTA = Math.PI / 9;
|
|
@@ -21116,7 +21814,7 @@ var RotateTool = function () {
|
|
|
21116
21814
|
get: function get() {
|
|
21117
21815
|
var _this$snapInfo;
|
|
21118
21816
|
if ((_this$snapInfo = this.snapInfo) !== null && _this$snapInfo !== void 0 && _this$snapInfo.snapAngleDrawingProps) {
|
|
21119
|
-
return _objectSpread$
|
|
21817
|
+
return _objectSpread$O({
|
|
21120
21818
|
snapMode: this.snapInfo.snapMode
|
|
21121
21819
|
}, this.snapInfo.snapAngleDrawingProps);
|
|
21122
21820
|
}
|
|
@@ -21293,861 +21991,181 @@ var RotateTool = function () {
|
|
|
21293
21991
|
var currentHalfBondId = fixedHalfBondIds[j];
|
|
21294
21992
|
var currentHalfBondAngle = fixedHalfBondAngles[j];
|
|
21295
21993
|
var difference = currentHalfBondAngle - previousHalfBondAngle;
|
|
21296
|
-
var bisectorAngle = normalizeAngle(currentHalfBondAngle - difference / 2);
|
|
21297
|
-
var snapAngle = difference > Math.PI ? bisectorAngle : normalizeAngle(bisectorAngle + Math.PI);
|
|
21298
|
-
absoluteSnapAngles.push(snapAngle);
|
|
21299
|
-
snapAngleToHalfBonds.set(snapAngle, [rotatableHalfBondId, previousHalfBondId, currentHalfBondId]);
|
|
21300
|
-
}
|
|
21301
|
-
}
|
|
21302
|
-
return [absoluteSnapAngles, snapAngleToHalfBonds];
|
|
21303
|
-
}
|
|
21304
|
-
}, {
|
|
21305
|
-
key: "partitionNeighborsBySelection",
|
|
21306
|
-
value: function partitionNeighborsBySelection(selection, atom) {
|
|
21307
|
-
var _this3 = this;
|
|
21308
|
-
var rotatableHalfBondIds = [];
|
|
21309
|
-
var rotatableHalfBondAngles = [];
|
|
21310
|
-
var fixedHalfBondIds = [];
|
|
21311
|
-
var fixedHalfBondAngles = [];
|
|
21312
|
-
atom.neighbors.forEach(function (halfBondId) {
|
|
21313
|
-
var _selection$atoms;
|
|
21314
|
-
var halfBond = _this3.struct.halfBonds.get(halfBondId);
|
|
21315
|
-
assert_1(halfBond != null);
|
|
21316
|
-
var neighborAtomId = halfBond.end;
|
|
21317
|
-
if (selection !== null && selection !== void 0 && (_selection$atoms = selection.atoms) !== null && _selection$atoms !== void 0 && _selection$atoms.includes(neighborAtomId)) {
|
|
21318
|
-
if (!FunctionalGroup.isHalfBondInContractedFunctionalGroup(halfBond, _this3.struct)) {
|
|
21319
|
-
rotatableHalfBondIds.push(halfBondId);
|
|
21320
|
-
rotatableHalfBondAngles.push(halfBond.ang);
|
|
21321
|
-
}
|
|
21322
|
-
} else {
|
|
21323
|
-
fixedHalfBondIds.push(halfBondId);
|
|
21324
|
-
fixedHalfBondAngles.push(halfBond.ang);
|
|
21325
|
-
}
|
|
21326
|
-
});
|
|
21327
|
-
return {
|
|
21328
|
-
rotatableHalfBondIds: rotatableHalfBondIds,
|
|
21329
|
-
rotatableHalfBondAngles: rotatableHalfBondAngles,
|
|
21330
|
-
fixedHalfBondIds: fixedHalfBondIds,
|
|
21331
|
-
fixedHalfBondAngles: fixedHalfBondAngles
|
|
21332
|
-
};
|
|
21333
|
-
}
|
|
21334
|
-
}, {
|
|
21335
|
-
key: "snap",
|
|
21336
|
-
value: function snap(mouseMoveAngle) {
|
|
21337
|
-
var _this4 = this;
|
|
21338
|
-
var isSnapping = false;
|
|
21339
|
-
var rotateAngle = 0;
|
|
21340
|
-
if (!this.snapInfo) {
|
|
21341
|
-
return [isSnapping, rotateAngle];
|
|
21342
|
-
}
|
|
21343
|
-
var newRotatedHalfBondAngle = normalizeAngle(this.snapInfo.rotatableHalfBondAngle + mouseMoveAngle);
|
|
21344
|
-
this.snapInfo.absoluteSnapAngles.some(function (snapAngle, index) {
|
|
21345
|
-
if (Math.abs(newRotatedHalfBondAngle - snapAngle) <= MAX_SNAP_DELTA) {
|
|
21346
|
-
isSnapping = true;
|
|
21347
|
-
assert_1(_this4.snapInfo != null);
|
|
21348
|
-
rotateAngle = snapAngle - _this4.snapInfo.rotatableHalfBondAngle;
|
|
21349
|
-
_this4.saveSnappingBonds(snapAngle);
|
|
21350
|
-
_this4.snapInfo.snapAngleDrawingProps = {
|
|
21351
|
-
isSnapping: isSnapping,
|
|
21352
|
-
absoluteAngle: snapAngle,
|
|
21353
|
-
relativeAngle: SNAP_ANGLES_RELATIVE_TO_FIXED_BOND[index]
|
|
21354
|
-
};
|
|
21355
|
-
return true;
|
|
21356
|
-
} else if (Math.abs(newRotatedHalfBondAngle - snapAngle) < ANGLE_INDICATOR_VISIBLE_DELTA) {
|
|
21357
|
-
assert_1(_this4.snapInfo != null);
|
|
21358
|
-
_this4.snapInfo.snapAngleDrawingProps = {
|
|
21359
|
-
isSnapping: isSnapping,
|
|
21360
|
-
absoluteAngle: snapAngle,
|
|
21361
|
-
relativeAngle: SNAP_ANGLES_RELATIVE_TO_FIXED_BOND[index]
|
|
21362
|
-
};
|
|
21363
|
-
return true;
|
|
21364
|
-
}
|
|
21365
|
-
return false;
|
|
21366
|
-
});
|
|
21367
|
-
return [isSnapping, rotateAngle];
|
|
21368
|
-
}
|
|
21369
|
-
}, {
|
|
21370
|
-
key: "saveSnappingBonds",
|
|
21371
|
-
value: function saveSnappingBonds(snapAngle) {
|
|
21372
|
-
var _this$snapInfo2,
|
|
21373
|
-
_this5 = this;
|
|
21374
|
-
var halfBondsToBeHighlighted = (_this$snapInfo2 = this.snapInfo) === null || _this$snapInfo2 === void 0 ? void 0 : _this$snapInfo2.snapAngleToHalfBonds.get(snapAngle);
|
|
21375
|
-
var bondIds = halfBondsToBeHighlighted === null || halfBondsToBeHighlighted === void 0 ? void 0 : halfBondsToBeHighlighted.map(function (halfBond) {
|
|
21376
|
-
var bondId = _this5.struct.getBondIdByHalfBond(halfBond);
|
|
21377
|
-
assert_1(bondId != null);
|
|
21378
|
-
return bondId;
|
|
21379
|
-
});
|
|
21380
|
-
bondIds === null || bondIds === void 0 || bondIds.forEach(function (bondId) {
|
|
21381
|
-
_this5.reStruct.addSnappingBonds(bondId);
|
|
21382
|
-
});
|
|
21383
|
-
}
|
|
21384
|
-
}]);
|
|
21385
|
-
return RotateTool;
|
|
21386
|
-
}();
|
|
21387
|
-
|
|
21388
|
-
var SimpleObjectTool = function () {
|
|
21389
|
-
function SimpleObjectTool(editor, mode) {
|
|
21390
|
-
_classCallCheck$2(this, SimpleObjectTool);
|
|
21391
|
-
this.mode = mode;
|
|
21392
|
-
this.editor = editor;
|
|
21393
|
-
this.editor.selection(null);
|
|
21394
|
-
}
|
|
21395
|
-
_createClass$2(SimpleObjectTool, [{
|
|
21396
|
-
key: "mousedown",
|
|
21397
|
-
value: function mousedown(event) {
|
|
21398
|
-
var rnd = this.editor.render;
|
|
21399
|
-
var p0 = rnd.page2obj(event);
|
|
21400
|
-
this.dragCtx = {
|
|
21401
|
-
p0: p0
|
|
21402
|
-
};
|
|
21403
|
-
var ci = this.editor.findItem(event, ['simpleObjects']);
|
|
21404
|
-
if (ci && ci.map === 'simpleObjects') {
|
|
21405
|
-
this.editor.hover(null);
|
|
21406
|
-
this.editor.selection({
|
|
21407
|
-
simpleObjects: [ci.id]
|
|
21408
|
-
});
|
|
21409
|
-
this.dragCtx.ci = ci;
|
|
21410
|
-
} else {
|
|
21411
|
-
this.dragCtx.isNew = true;
|
|
21412
|
-
this.editor.selection(null);
|
|
21413
|
-
}
|
|
21414
|
-
}
|
|
21415
|
-
}, {
|
|
21416
|
-
key: "mousemove",
|
|
21417
|
-
value: function mousemove(event) {
|
|
21418
|
-
var rnd = this.editor.render;
|
|
21419
|
-
if (this.dragCtx) {
|
|
21420
|
-
var current = rnd.page2obj(event);
|
|
21421
|
-
var diff = current.sub(this.dragCtx.p0);
|
|
21422
|
-
this.dragCtx.previous = current;
|
|
21423
|
-
if (this.dragCtx.ci) {
|
|
21424
|
-
if (this.dragCtx.action) {
|
|
21425
|
-
this.dragCtx.action.perform(rnd.ctab);
|
|
21426
|
-
}
|
|
21427
|
-
if (!this.dragCtx.ci.ref) {
|
|
21428
|
-
this.dragCtx.action = fromMultipleMove(rnd.ctab, this.editor.selection() || {}, diff);
|
|
21429
|
-
} else {
|
|
21430
|
-
this.dragCtx.action = fromSimpleObjectResizing(rnd.ctab, this.dragCtx.ci.id, diff, current, this.dragCtx.ci.ref, event.shiftKey);
|
|
21431
|
-
}
|
|
21432
|
-
this.editor.update(this.dragCtx.action, true);
|
|
21433
|
-
} else {
|
|
21434
|
-
if (!this.dragCtx.action) {
|
|
21435
|
-
var action = fromSimpleObjectAddition(rnd.ctab, [this.dragCtx.p0, this.dragCtx.p0], this.mode, false);
|
|
21436
|
-
var addOperation = action.operations[0];
|
|
21437
|
-
this.dragCtx.itemId = addOperation.data.id;
|
|
21438
|
-
this.dragCtx.action = action;
|
|
21439
|
-
this.editor.update(this.dragCtx.action, true);
|
|
21440
|
-
} else {
|
|
21441
|
-
this.dragCtx.action.perform(rnd.ctab);
|
|
21442
|
-
}
|
|
21443
|
-
this.dragCtx.action = fromSimpleObjectResizing(rnd.ctab, this.dragCtx.itemId, diff, current, null, event.shiftKey);
|
|
21444
|
-
this.editor.update(this.dragCtx.action, true);
|
|
21445
|
-
}
|
|
21446
|
-
} else {
|
|
21447
|
-
var items = this.editor.findItem(event, ['simpleObjects']);
|
|
21448
|
-
this.editor.hover(items, null, event);
|
|
21449
|
-
}
|
|
21450
|
-
}
|
|
21451
|
-
}, {
|
|
21452
|
-
key: "mouseup",
|
|
21453
|
-
value: function mouseup(event) {
|
|
21454
|
-
if (!this.dragCtx) {
|
|
21455
|
-
return true;
|
|
21456
|
-
}
|
|
21457
|
-
if (this.dragCtx.action) {
|
|
21458
|
-
if (this.dragCtx.isNew) {
|
|
21459
|
-
var rnd = this.editor.render;
|
|
21460
|
-
this.editor.update(fromSimpleObjectDeletion(rnd.ctab, this.dragCtx.itemId), true);
|
|
21461
|
-
this.dragCtx.action = fromSimpleObjectAddition(rnd.ctab, [this.dragCtx.p0, this.dragCtx.previous], this.mode, event.shiftKey);
|
|
21462
|
-
}
|
|
21463
|
-
this.editor.update(this.dragCtx.action);
|
|
21464
|
-
}
|
|
21465
|
-
delete this.dragCtx;
|
|
21466
|
-
return true;
|
|
21467
|
-
}
|
|
21468
|
-
}]);
|
|
21469
|
-
return SimpleObjectTool;
|
|
21470
|
-
}();
|
|
21471
|
-
|
|
21472
|
-
var PREVIEW_DELAY = 300;
|
|
21473
|
-
function getUniqueCiId(ci) {
|
|
21474
|
-
return "".concat(ci.id, "-").concat(ci.map);
|
|
21475
|
-
}
|
|
21476
|
-
var TemplatePreview = function () {
|
|
21477
|
-
function TemplatePreview(editor, template, mode) {
|
|
21478
|
-
_classCallCheck$2(this, TemplatePreview);
|
|
21479
|
-
_defineProperty$1(this, "connectedPreviewTimeout", null);
|
|
21480
|
-
this.editor = editor;
|
|
21481
|
-
this.template = template;
|
|
21482
|
-
this.floatingPreviewAction = new Action();
|
|
21483
|
-
this.connectedPreviewAction = null;
|
|
21484
|
-
this.connectedPreviewTimeout = null;
|
|
21485
|
-
this.lastPreviewId = null;
|
|
21486
|
-
this.mode = mode;
|
|
21487
|
-
this.floatingPreview = null;
|
|
21488
|
-
this.position = new Vec2();
|
|
21489
|
-
this.previousPosition = new Vec2();
|
|
21490
|
-
}
|
|
21491
|
-
_createClass$2(TemplatePreview, [{
|
|
21492
|
-
key: "struct",
|
|
21493
|
-
get: function get() {
|
|
21494
|
-
return this.restruct.molecule;
|
|
21495
|
-
}
|
|
21496
|
-
}, {
|
|
21497
|
-
key: "restruct",
|
|
21498
|
-
get: function get() {
|
|
21499
|
-
return this.editor.render.ctab;
|
|
21500
|
-
}
|
|
21501
|
-
}, {
|
|
21502
|
-
key: "isModeFunctionalGroup",
|
|
21503
|
-
get: function get() {
|
|
21504
|
-
return this.mode === MODES.FG;
|
|
21505
|
-
}
|
|
21506
|
-
}, {
|
|
21507
|
-
key: "hidePreview",
|
|
21508
|
-
value: function hidePreview() {
|
|
21509
|
-
this.hideConnectedPreview();
|
|
21510
|
-
this.hideFloatingPreview();
|
|
21511
|
-
}
|
|
21512
|
-
}, {
|
|
21513
|
-
key: "getPreviewTarget",
|
|
21514
|
-
value: function getPreviewTarget() {
|
|
21515
|
-
var _this$restruct$molecu;
|
|
21516
|
-
var ci = this.editor.findItem(event, ['atoms', 'bonds']);
|
|
21517
|
-
if (ci && ((_this$restruct$molecu = this.restruct.molecule[ci.map].get(ci.id)) === null || _this$restruct$molecu === void 0 ? void 0 : _this$restruct$molecu.isPreview) === false) {
|
|
21518
|
-
return ci;
|
|
21519
|
-
} else {
|
|
21520
|
-
return null;
|
|
21521
|
-
}
|
|
21522
|
-
}
|
|
21523
|
-
}, {
|
|
21524
|
-
key: "movePreview",
|
|
21525
|
-
value: function movePreview(event) {
|
|
21526
|
-
var _this = this;
|
|
21527
|
-
this.position = this.editor.render.page2obj(event);
|
|
21528
|
-
var struct = this.editor.struct();
|
|
21529
|
-
var previewTarget = this.getPreviewTarget();
|
|
21530
|
-
var isMouseAwayFromAtomsAndBonds = !previewTarget;
|
|
21531
|
-
var isPreviewTargetChanged = previewTarget && this.lastPreviewId !== getUniqueCiId(previewTarget);
|
|
21532
|
-
var shouldHidePreview = isMouseAwayFromAtomsAndBonds || isPreviewTargetChanged;
|
|
21533
|
-
var shouldShowPreview = previewTarget && !struct.isTargetFromMacromolecule(previewTarget) && !this.connectedPreviewAction && !this.connectedPreviewTimeout;
|
|
21534
|
-
if (shouldHidePreview) {
|
|
21535
|
-
this.hideConnectedPreview();
|
|
21536
|
-
}
|
|
21537
|
-
if (shouldShowPreview) {
|
|
21538
|
-
this.lastPreviewId = getUniqueCiId(previewTarget);
|
|
21539
|
-
this.connectedPreviewTimeout = setTimeout(function () {
|
|
21540
|
-
_this.previousPosition = _this.position;
|
|
21541
|
-
_this.hideFloatingPreview();
|
|
21542
|
-
_this.showConnectedPreview(event, previewTarget);
|
|
21543
|
-
}, PREVIEW_DELAY);
|
|
21544
|
-
} else if (shouldHidePreview) {
|
|
21545
|
-
if (!this.floatingPreview) {
|
|
21546
|
-
this.showFloatingPreview(this.position);
|
|
21547
|
-
this.previousPosition = this.position;
|
|
21548
|
-
this.editor.render.update(false, null);
|
|
21549
|
-
} else {
|
|
21550
|
-
this.moveFloatingPreview();
|
|
21551
|
-
}
|
|
21552
|
-
}
|
|
21553
|
-
}
|
|
21554
|
-
}, {
|
|
21555
|
-
key: "moveFloatingPreview",
|
|
21556
|
-
value: function moveFloatingPreview() {
|
|
21557
|
-
var dist = this.position.sub(this.previousPosition);
|
|
21558
|
-
this.previousPosition = this.position;
|
|
21559
|
-
fromMultipleMove(this.restruct, this.floatingPreview, dist);
|
|
21560
|
-
this.editor.render.update(false, null);
|
|
21561
|
-
}
|
|
21562
|
-
}, {
|
|
21563
|
-
key: "showFloatingPreview",
|
|
21564
|
-
value: function showFloatingPreview(position) {
|
|
21565
|
-
var _fromTemplateOnCanvas = fromTemplateOnCanvas(this.restruct, this.template, position);
|
|
21566
|
-
var _fromTemplateOnCanvas2 = _slicedToArray$1(_fromTemplateOnCanvas, 2);
|
|
21567
|
-
this.floatingPreviewAction = _fromTemplateOnCanvas2[0];
|
|
21568
|
-
this.floatingPreview = _fromTemplateOnCanvas2[1];
|
|
21569
|
-
this.editor.render.update(true, null);
|
|
21570
|
-
}
|
|
21571
|
-
}, {
|
|
21572
|
-
key: "hideFloatingPreview",
|
|
21573
|
-
value: function hideFloatingPreview() {
|
|
21574
|
-
if (this.floatingPreviewAction) {
|
|
21575
|
-
var action = this.floatingPreviewAction.perform(this.restruct);
|
|
21576
|
-
this.editor.update(action, true);
|
|
21577
|
-
this.floatingPreviewAction = null;
|
|
21578
|
-
this.floatingPreview = null;
|
|
21579
|
-
}
|
|
21580
|
-
}
|
|
21581
|
-
}, {
|
|
21582
|
-
key: "hideConnectedPreview",
|
|
21583
|
-
value: function hideConnectedPreview() {
|
|
21584
|
-
if (this.connectedPreviewAction) {
|
|
21585
|
-
this.connectedPreviewAction.perform(this.restruct);
|
|
21586
|
-
this.connectedPreviewAction = null;
|
|
21587
|
-
this.editor.render.update();
|
|
21588
|
-
}
|
|
21589
|
-
if (this.connectedPreviewTimeout) {
|
|
21590
|
-
clearTimeout(this.connectedPreviewTimeout);
|
|
21591
|
-
this.connectedPreviewTimeout = null;
|
|
21592
|
-
}
|
|
21593
|
-
}
|
|
21594
|
-
}, {
|
|
21595
|
-
key: "showConnectedPreview",
|
|
21596
|
-
value: function showConnectedPreview(event, ci) {
|
|
21597
|
-
var _this2 = this;
|
|
21598
|
-
if (ci.map === 'bonds' && !this.isModeFunctionalGroup) {
|
|
21599
|
-
var bond = this.struct.bonds.get(ci.id);
|
|
21600
|
-
if (!bond) {
|
|
21601
|
-
return;
|
|
21602
|
-
}
|
|
21603
|
-
var sign1 = getBondFlipSign(this.struct, bond);
|
|
21604
|
-
var sign2 = this.template.sign;
|
|
21605
|
-
var shouldFlip = sign1 * sign2 > 0;
|
|
21606
|
-
var promise = fromTemplateOnBondAction(this.restruct, this.template, ci.id, this.editor.event, shouldFlip, true, true);
|
|
21607
|
-
promise.then(function (_ref) {
|
|
21608
|
-
var _ref2 = _slicedToArray$1(_ref, 2),
|
|
21609
|
-
action = _ref2[0],
|
|
21610
|
-
pasteItems = _ref2[1];
|
|
21611
|
-
if (!_this2.isModeFunctionalGroup) {
|
|
21612
|
-
var mergeItems = getItemsToFuse(_this2.editor, pasteItems);
|
|
21613
|
-
action = fromItemsFuse(_this2.restruct, mergeItems).mergeWith(action);
|
|
21614
|
-
_this2.editor.update(action, true);
|
|
21615
|
-
_this2.connectedPreviewAction = action;
|
|
21616
|
-
}
|
|
21617
|
-
});
|
|
21618
|
-
} else if (ci.map === 'atoms') {
|
|
21619
|
-
var angle = getAngleFromEvent(event, ci, this.restruct);
|
|
21620
|
-
var _fromTemplateOnAtom = fromTemplateOnAtom(this.restruct, this.template, ci.id, angle, false, true),
|
|
21621
|
-
_fromTemplateOnAtom2 = _slicedToArray$1(_fromTemplateOnAtom, 2),
|
|
21622
|
-
action = _fromTemplateOnAtom2[0],
|
|
21623
|
-
pasteItems = _fromTemplateOnAtom2[1];
|
|
21624
|
-
if (pasteItems && !this.isModeFunctionalGroup) {
|
|
21625
|
-
var mergeItems = getItemsToFuse(this.editor, pasteItems);
|
|
21626
|
-
action = fromItemsFuse(this.restruct, mergeItems).mergeWith(action);
|
|
21627
|
-
}
|
|
21628
|
-
this.editor.update(action, true);
|
|
21629
|
-
this.connectedPreviewAction = action;
|
|
21630
|
-
}
|
|
21631
|
-
}
|
|
21632
|
-
}]);
|
|
21633
|
-
return TemplatePreview;
|
|
21634
|
-
}();
|
|
21635
|
-
|
|
21636
|
-
function _createForOfIteratorHelper$1(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
21637
|
-
function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
|
|
21638
|
-
function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
21639
|
-
function ownKeys$O(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; }
|
|
21640
|
-
function _objectSpread$O(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$O(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$O(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21641
|
-
function getBondFlipSign(struct, bond) {
|
|
21642
|
-
var _struct$atoms$get, _struct$halfBonds$get;
|
|
21643
|
-
var xy0 = new Vec2();
|
|
21644
|
-
var frid = (_struct$atoms$get = struct.atoms.get(bond === null || bond === void 0 ? void 0 : bond.begin)) === null || _struct$atoms$get === void 0 ? void 0 : _struct$atoms$get.fragment;
|
|
21645
|
-
var frIds = struct.getFragmentIds(frid);
|
|
21646
|
-
var count = 0;
|
|
21647
|
-
var loop = (_struct$halfBonds$get = struct.halfBonds.get(bond === null || bond === void 0 ? void 0 : bond.hb1)) === null || _struct$halfBonds$get === void 0 ? void 0 : _struct$halfBonds$get.loop;
|
|
21648
|
-
if (loop && loop < 0) {
|
|
21649
|
-
var _struct$halfBonds$get2;
|
|
21650
|
-
loop = (_struct$halfBonds$get2 = struct.halfBonds.get(bond === null || bond === void 0 ? void 0 : bond.hb2)) === null || _struct$halfBonds$get2 === void 0 ? void 0 : _struct$halfBonds$get2.loop;
|
|
21651
|
-
}
|
|
21652
|
-
if (loop && loop >= 0) {
|
|
21653
|
-
var _struct$loops$get;
|
|
21654
|
-
var loopHbs = (_struct$loops$get = struct.loops.get(loop)) === null || _struct$loops$get === void 0 ? void 0 : _struct$loops$get.hbs;
|
|
21655
|
-
loopHbs === null || loopHbs === void 0 || loopHbs.forEach(function (hb) {
|
|
21656
|
-
var _struct$halfBonds$get3;
|
|
21657
|
-
var halfBondBegin = (_struct$halfBonds$get3 = struct.halfBonds.get(hb)) === null || _struct$halfBonds$get3 === void 0 ? void 0 : _struct$halfBonds$get3.begin;
|
|
21658
|
-
if (halfBondBegin) {
|
|
21659
|
-
var hbbAtom = struct.atoms.get(halfBondBegin);
|
|
21660
|
-
if (hbbAtom) {
|
|
21661
|
-
xy0.add_(hbbAtom.pp);
|
|
21662
|
-
count++;
|
|
21663
|
-
}
|
|
21664
|
-
}
|
|
21665
|
-
});
|
|
21666
|
-
} else {
|
|
21667
|
-
frIds.forEach(function (id) {
|
|
21668
|
-
var atomById = struct.atoms.get(id);
|
|
21669
|
-
if (atomById) {
|
|
21670
|
-
xy0.add_(atomById.pp);
|
|
21671
|
-
count++;
|
|
21672
|
-
}
|
|
21673
|
-
});
|
|
21674
|
-
}
|
|
21675
|
-
var v0 = xy0.scaled(1 / count);
|
|
21676
|
-
return getSign(struct, bond, v0) || 1;
|
|
21677
|
-
}
|
|
21678
|
-
function getAngleFromEvent(event, ci, restruct) {
|
|
21679
|
-
var _restruct$atoms$get;
|
|
21680
|
-
var degree = (_restruct$atoms$get = restruct.atoms.get(ci.id)) === null || _restruct$atoms$get === void 0 ? void 0 : _restruct$atoms$get.a.neighbors.length;
|
|
21681
|
-
var angle;
|
|
21682
|
-
if (degree && degree > 1) {
|
|
21683
|
-
angle = null;
|
|
21684
|
-
} else if (degree === 1) {
|
|
21685
|
-
var _restruct$molecule$ha;
|
|
21686
|
-
var atom = restruct.molecule.atoms.get(ci.id);
|
|
21687
|
-
var neiId = atom && ((_restruct$molecule$ha = restruct.molecule.halfBonds.get(atom.neighbors[0])) === null || _restruct$molecule$ha === void 0 ? void 0 : _restruct$molecule$ha.end);
|
|
21688
|
-
var nei = (neiId || neiId === 0) && restruct.molecule.atoms.get(neiId);
|
|
21689
|
-
angle = event.ctrlKey ? vectorUtils.calcAngle(nei === null || nei === void 0 ? void 0 : nei.pp, atom === null || atom === void 0 ? void 0 : atom.pp) : vectorUtils.fracAngle(vectorUtils.calcAngle(nei.pp, atom === null || atom === void 0 ? void 0 : atom.pp), null);
|
|
21690
|
-
} else {
|
|
21691
|
-
angle = 0;
|
|
21692
|
-
}
|
|
21693
|
-
return angle;
|
|
21694
|
-
}
|
|
21695
|
-
var TemplateTool = function () {
|
|
21696
|
-
function TemplateTool(editor, tmpl) {
|
|
21697
|
-
_classCallCheck$2(this, TemplateTool);
|
|
21698
|
-
_defineProperty$1(this, "targetGroupsIds", []);
|
|
21699
|
-
this.editor = editor;
|
|
21700
|
-
this.mode = getTemplateMode(tmpl);
|
|
21701
|
-
this.editor.selection(null);
|
|
21702
|
-
this.isSaltOrSolvent = SGroup$1.isSaltOrSolvent(tmpl.struct.name);
|
|
21703
|
-
var sGroup = tmpl.struct.sgroups.values().next().value;
|
|
21704
|
-
this.template = {
|
|
21705
|
-
aid: parseInt(tmpl.aid) || (sGroup === null || sGroup === void 0 ? void 0 : sGroup.getAttachmentAtomId()) || 0,
|
|
21706
|
-
bid: parseInt(tmpl.bid) || 0
|
|
21707
|
-
};
|
|
21708
|
-
this.templatePreview = new TemplatePreview(editor, this.template, this.mode);
|
|
21709
|
-
var frag = tmpl.struct;
|
|
21710
|
-
frag.rescale();
|
|
21711
|
-
var xy0 = new Vec2();
|
|
21712
|
-
frag.atoms.forEach(function (atom) {
|
|
21713
|
-
xy0.add_(atom.pp);
|
|
21714
|
-
});
|
|
21715
|
-
this.template.molecule = frag;
|
|
21716
|
-
this.findItems = [];
|
|
21717
|
-
this.template.xy0 = xy0.scaled(1 / (frag.atoms.size || 1));
|
|
21718
|
-
var atom = frag.atoms.get(this.template.aid);
|
|
21719
|
-
if (atom) {
|
|
21720
|
-
this.template.angle0 = vectorUtils.calcAngle(atom.pp, this.template.xy0);
|
|
21721
|
-
this.findItems.push('atoms');
|
|
21722
|
-
}
|
|
21723
|
-
var bond = frag.bonds.get(this.template.bid);
|
|
21724
|
-
if (bond && !this.isModeFunctionalGroup) {
|
|
21725
|
-
this.template.sign = getSign(frag, bond, this.template.xy0);
|
|
21726
|
-
this.findItems.push('bonds');
|
|
21727
|
-
}
|
|
21728
|
-
var sGroupSize = frag.sgroups.size;
|
|
21729
|
-
if (sGroupSize) {
|
|
21730
|
-
this.findItems.push('functionalGroups');
|
|
21731
|
-
}
|
|
21732
|
-
}
|
|
21733
|
-
_createClass$2(TemplateTool, [{
|
|
21734
|
-
key: "struct",
|
|
21735
|
-
get: function get() {
|
|
21736
|
-
return this.editor.render.ctab.molecule;
|
|
21737
|
-
}
|
|
21738
|
-
}, {
|
|
21739
|
-
key: "functionalGroups",
|
|
21740
|
-
get: function get() {
|
|
21741
|
-
return this.struct.functionalGroups;
|
|
21742
|
-
}
|
|
21743
|
-
}, {
|
|
21744
|
-
key: "isModeFunctionalGroup",
|
|
21745
|
-
get: function get() {
|
|
21746
|
-
return this.mode === MODES.FG;
|
|
21994
|
+
var bisectorAngle = normalizeAngle(currentHalfBondAngle - difference / 2);
|
|
21995
|
+
var snapAngle = difference > Math.PI ? bisectorAngle : normalizeAngle(bisectorAngle + Math.PI);
|
|
21996
|
+
absoluteSnapAngles.push(snapAngle);
|
|
21997
|
+
snapAngleToHalfBonds.set(snapAngle, [rotatableHalfBondId, previousHalfBondId, currentHalfBondId]);
|
|
21998
|
+
}
|
|
21999
|
+
}
|
|
22000
|
+
return [absoluteSnapAngles, snapAngleToHalfBonds];
|
|
21747
22001
|
}
|
|
21748
22002
|
}, {
|
|
21749
|
-
key: "
|
|
21750
|
-
|
|
21751
|
-
|
|
22003
|
+
key: "partitionNeighborsBySelection",
|
|
22004
|
+
value: function partitionNeighborsBySelection(selection, atom) {
|
|
22005
|
+
var _this3 = this;
|
|
22006
|
+
var rotatableHalfBondIds = [];
|
|
22007
|
+
var rotatableHalfBondAngles = [];
|
|
22008
|
+
var fixedHalfBondIds = [];
|
|
22009
|
+
var fixedHalfBondAngles = [];
|
|
22010
|
+
atom.neighbors.forEach(function (halfBondId) {
|
|
22011
|
+
var _selection$atoms;
|
|
22012
|
+
var halfBond = _this3.struct.halfBonds.get(halfBondId);
|
|
22013
|
+
assert_1(halfBond != null);
|
|
22014
|
+
var neighborAtomId = halfBond.end;
|
|
22015
|
+
if (selection !== null && selection !== void 0 && (_selection$atoms = selection.atoms) !== null && _selection$atoms !== void 0 && _selection$atoms.includes(neighborAtomId)) {
|
|
22016
|
+
if (!FunctionalGroup.isHalfBondInContractedFunctionalGroup(halfBond, _this3.struct)) {
|
|
22017
|
+
rotatableHalfBondIds.push(halfBondId);
|
|
22018
|
+
rotatableHalfBondAngles.push(halfBond.ang);
|
|
22019
|
+
}
|
|
22020
|
+
} else {
|
|
22021
|
+
fixedHalfBondIds.push(halfBondId);
|
|
22022
|
+
fixedHalfBondAngles.push(halfBond.ang);
|
|
22023
|
+
}
|
|
22024
|
+
});
|
|
22025
|
+
return {
|
|
22026
|
+
rotatableHalfBondIds: rotatableHalfBondIds,
|
|
22027
|
+
rotatableHalfBondAngles: rotatableHalfBondAngles,
|
|
22028
|
+
fixedHalfBondIds: fixedHalfBondIds,
|
|
22029
|
+
fixedHalfBondAngles: fixedHalfBondAngles
|
|
22030
|
+
};
|
|
21752
22031
|
}
|
|
21753
22032
|
}, {
|
|
21754
|
-
key: "
|
|
21755
|
-
|
|
21756
|
-
var
|
|
21757
|
-
var
|
|
21758
|
-
var
|
|
21759
|
-
if (
|
|
21760
|
-
return
|
|
22033
|
+
key: "snap",
|
|
22034
|
+
value: function snap(mouseMoveAngle) {
|
|
22035
|
+
var _this4 = this;
|
|
22036
|
+
var isSnapping = false;
|
|
22037
|
+
var rotateAngle = 0;
|
|
22038
|
+
if (!this.snapInfo) {
|
|
22039
|
+
return [isSnapping, rotateAngle];
|
|
21761
22040
|
}
|
|
21762
|
-
var
|
|
21763
|
-
|
|
21764
|
-
|
|
21765
|
-
|
|
21766
|
-
|
|
21767
|
-
|
|
21768
|
-
|
|
21769
|
-
|
|
21770
|
-
|
|
21771
|
-
|
|
21772
|
-
|
|
21773
|
-
|
|
22041
|
+
var newRotatedHalfBondAngle = normalizeAngle(this.snapInfo.rotatableHalfBondAngle + mouseMoveAngle);
|
|
22042
|
+
this.snapInfo.absoluteSnapAngles.some(function (snapAngle, index) {
|
|
22043
|
+
if (Math.abs(newRotatedHalfBondAngle - snapAngle) <= MAX_SNAP_DELTA) {
|
|
22044
|
+
isSnapping = true;
|
|
22045
|
+
assert_1(_this4.snapInfo != null);
|
|
22046
|
+
rotateAngle = snapAngle - _this4.snapInfo.rotatableHalfBondAngle;
|
|
22047
|
+
_this4.saveSnappingBonds(snapAngle);
|
|
22048
|
+
_this4.snapInfo.snapAngleDrawingProps = {
|
|
22049
|
+
isSnapping: isSnapping,
|
|
22050
|
+
absoluteAngle: snapAngle,
|
|
22051
|
+
relativeAngle: SNAP_ANGLES_RELATIVE_TO_FIXED_BOND[index]
|
|
22052
|
+
};
|
|
22053
|
+
return true;
|
|
22054
|
+
} else if (Math.abs(newRotatedHalfBondAngle - snapAngle) < ANGLE_INDICATOR_VISIBLE_DELTA) {
|
|
22055
|
+
assert_1(_this4.snapInfo != null);
|
|
22056
|
+
_this4.snapInfo.snapAngleDrawingProps = {
|
|
22057
|
+
isSnapping: isSnapping,
|
|
22058
|
+
absoluteAngle: snapAngle,
|
|
22059
|
+
relativeAngle: SNAP_ANGLES_RELATIVE_TO_FIXED_BOND[index]
|
|
22060
|
+
};
|
|
22061
|
+
return true;
|
|
21774
22062
|
}
|
|
22063
|
+
return false;
|
|
21775
22064
|
});
|
|
21776
|
-
return
|
|
22065
|
+
return [isSnapping, rotateAngle];
|
|
21777
22066
|
}
|
|
21778
22067
|
}, {
|
|
21779
|
-
key: "
|
|
21780
|
-
value: function
|
|
21781
|
-
var _this
|
|
21782
|
-
|
|
21783
|
-
|
|
21784
|
-
|
|
21785
|
-
|
|
21786
|
-
|
|
22068
|
+
key: "saveSnappingBonds",
|
|
22069
|
+
value: function saveSnappingBonds(snapAngle) {
|
|
22070
|
+
var _this$snapInfo2,
|
|
22071
|
+
_this5 = this;
|
|
22072
|
+
var halfBondsToBeHighlighted = (_this$snapInfo2 = this.snapInfo) === null || _this$snapInfo2 === void 0 ? void 0 : _this$snapInfo2.snapAngleToHalfBonds.get(snapAngle);
|
|
22073
|
+
var bondIds = halfBondsToBeHighlighted === null || halfBondsToBeHighlighted === void 0 ? void 0 : halfBondsToBeHighlighted.map(function (halfBond) {
|
|
22074
|
+
var bondId = _this5.struct.getBondIdByHalfBond(halfBond);
|
|
22075
|
+
assert_1(bondId != null);
|
|
22076
|
+
return bondId;
|
|
22077
|
+
});
|
|
22078
|
+
bondIds === null || bondIds === void 0 || bondIds.forEach(function (bondId) {
|
|
22079
|
+
_this5.reStruct.addSnappingBonds(bondId);
|
|
21787
22080
|
});
|
|
21788
22081
|
}
|
|
21789
|
-
}
|
|
22082
|
+
}]);
|
|
22083
|
+
return RotateTool;
|
|
22084
|
+
}();
|
|
22085
|
+
|
|
22086
|
+
var SimpleObjectTool = function () {
|
|
22087
|
+
function SimpleObjectTool(editor, mode) {
|
|
22088
|
+
_classCallCheck$2(this, SimpleObjectTool);
|
|
22089
|
+
this.mode = mode;
|
|
22090
|
+
this.editor = editor;
|
|
22091
|
+
this.editor.selection(null);
|
|
22092
|
+
}
|
|
22093
|
+
_createClass$2(SimpleObjectTool, [{
|
|
21790
22094
|
key: "mousedown",
|
|
21791
|
-
value: function () {
|
|
21792
|
-
var
|
|
21793
|
-
|
|
21794
|
-
|
|
21795
|
-
|
|
21796
|
-
|
|
21797
|
-
|
|
21798
|
-
|
|
21799
|
-
|
|
21800
|
-
|
|
21801
|
-
|
|
21802
|
-
|
|
21803
|
-
|
|
21804
|
-
|
|
21805
|
-
|
|
21806
|
-
|
|
21807
|
-
}));
|
|
21808
|
-
if (
|
|
21809
|
-
((_this$closestItem4 = this.closestItem) === null || _this$closestItem4 === void 0 ? void 0 : _this$closestItem4.map) === 'functionalGroups' && FunctionalGroup.isContractedFunctionalGroup(this.closestItem.id, this.functionalGroups)) {
|
|
21810
|
-
this.targetGroupsIds.push(this.closestItem.id);
|
|
21811
|
-
}
|
|
21812
|
-
}
|
|
21813
|
-
if (!struct.isTargetFromMacromolecule(target)) {
|
|
21814
|
-
_context.next = 7;
|
|
21815
|
-
break;
|
|
21816
|
-
}
|
|
21817
|
-
return _context.abrupt("return");
|
|
21818
|
-
case 7:
|
|
21819
|
-
if (!this.isNeedToShowRemoveAbbreviationPopup) {
|
|
21820
|
-
_context.next = 11;
|
|
21821
|
-
break;
|
|
21822
|
-
}
|
|
21823
|
-
_context.next = 10;
|
|
21824
|
-
return this.showRemoveAbbreviationPopup();
|
|
21825
|
-
case 10:
|
|
21826
|
-
return _context.abrupt("return");
|
|
21827
|
-
case 11:
|
|
21828
|
-
this.editor.hover(null);
|
|
21829
|
-
this.dragCtx = {
|
|
21830
|
-
xy0: this.editor.render.page2obj(event),
|
|
21831
|
-
item: this.editor.findItem(this.event, this.findItems)
|
|
21832
|
-
};
|
|
21833
|
-
dragCtx = this.dragCtx;
|
|
21834
|
-
ci = dragCtx.item;
|
|
21835
|
-
if (ci) {
|
|
21836
|
-
_context.next = 18;
|
|
21837
|
-
break;
|
|
21838
|
-
}
|
|
21839
|
-
delete dragCtx.item;
|
|
21840
|
-
return _context.abrupt("return");
|
|
21841
|
-
case 18:
|
|
21842
|
-
if (ci.map === 'bonds' && !this.isModeFunctionalGroup) {
|
|
21843
|
-
bond = this.struct.bonds.get(ci.id);
|
|
21844
|
-
dragCtx.sign1 = getBondFlipSign(this.struct, bond);
|
|
21845
|
-
dragCtx.sign2 = this.template.sign;
|
|
21846
|
-
}
|
|
21847
|
-
case 19:
|
|
21848
|
-
case "end":
|
|
21849
|
-
return _context.stop();
|
|
21850
|
-
}
|
|
21851
|
-
}, _callee, this);
|
|
21852
|
-
}));
|
|
21853
|
-
function mousedown(_x) {
|
|
21854
|
-
return _mousedown.apply(this, arguments);
|
|
22095
|
+
value: function mousedown(event) {
|
|
22096
|
+
var rnd = this.editor.render;
|
|
22097
|
+
var p0 = rnd.page2obj(event);
|
|
22098
|
+
this.dragCtx = {
|
|
22099
|
+
p0: p0
|
|
22100
|
+
};
|
|
22101
|
+
var ci = this.editor.findItem(event, ['simpleObjects']);
|
|
22102
|
+
if (ci && ci.map === 'simpleObjects') {
|
|
22103
|
+
this.editor.hover(null);
|
|
22104
|
+
this.editor.selection({
|
|
22105
|
+
simpleObjects: [ci.id]
|
|
22106
|
+
});
|
|
22107
|
+
this.dragCtx.ci = ci;
|
|
22108
|
+
} else {
|
|
22109
|
+
this.dragCtx.isNew = true;
|
|
22110
|
+
this.editor.selection(null);
|
|
21855
22111
|
}
|
|
21856
|
-
|
|
21857
|
-
}()
|
|
22112
|
+
}
|
|
21858
22113
|
}, {
|
|
21859
22114
|
key: "mousemove",
|
|
21860
22115
|
value: function mousemove(event) {
|
|
21861
|
-
|
|
21862
|
-
|
|
21863
|
-
|
|
21864
|
-
|
|
21865
|
-
|
|
21866
|
-
|
|
21867
|
-
|
|
21868
|
-
|
|
21869
|
-
return true;
|
|
21870
|
-
}
|
|
21871
|
-
var eventPosition = this.editor.render.page2obj(event);
|
|
21872
|
-
var dragCtx = this.dragCtx;
|
|
21873
|
-
var ci = dragCtx.item;
|
|
21874
|
-
var targetPos = null;
|
|
21875
|
-
if (ci && ci.map === 'bonds' && !this.isModeFunctionalGroup) {
|
|
21876
|
-
var bond = this.struct.bonds.get(ci.id);
|
|
21877
|
-
var sign = getSign(this.struct, bond, eventPosition);
|
|
21878
|
-
if (dragCtx.sign1 * this.template.sign > 0) {
|
|
21879
|
-
sign = -sign;
|
|
21880
|
-
}
|
|
21881
|
-
if (sign !== dragCtx.sign2 || !dragCtx.action) {
|
|
21882
|
-
if (dragCtx.action) {
|
|
21883
|
-
dragCtx.action.perform(this.editor.render.ctab);
|
|
22116
|
+
var rnd = this.editor.render;
|
|
22117
|
+
if (this.dragCtx) {
|
|
22118
|
+
var current = rnd.page2obj(event);
|
|
22119
|
+
var diff = current.sub(this.dragCtx.p0);
|
|
22120
|
+
this.dragCtx.previous = current;
|
|
22121
|
+
if (this.dragCtx.ci) {
|
|
22122
|
+
if (this.dragCtx.action) {
|
|
22123
|
+
this.dragCtx.action.perform(rnd.ctab);
|
|
21884
22124
|
}
|
|
21885
|
-
dragCtx.
|
|
21886
|
-
|
|
21887
|
-
|
|
21888
|
-
|
|
21889
|
-
pasteItems = _fromTemplateOnBondAc2[1];
|
|
21890
|
-
dragCtx.action = _action;
|
|
21891
|
-
this.editor.update(dragCtx.action, true);
|
|
21892
|
-
dragCtx.mergeItems = getItemsToFuse(this.editor, pasteItems);
|
|
21893
|
-
this.editor.hover(getHoverToFuse(dragCtx.mergeItems));
|
|
21894
|
-
}
|
|
21895
|
-
return true;
|
|
21896
|
-
}
|
|
21897
|
-
var extraBond = null;
|
|
21898
|
-
if (!ci) {
|
|
21899
|
-
targetPos = dragCtx.xy0;
|
|
21900
|
-
} else if (ci.map === 'atoms' || ci.map === 'functionalGroups') {
|
|
21901
|
-
var atomId = getTargetAtomId(this.struct, ci);
|
|
21902
|
-
if (atomId !== undefined) {
|
|
21903
|
-
var atom = this.struct.atoms.get(atomId);
|
|
21904
|
-
targetPos = atom === null || atom === void 0 ? void 0 : atom.pp;
|
|
21905
|
-
if (targetPos) {
|
|
21906
|
-
extraBond = this.isModeFunctionalGroup ? true : Vec2.dist(targetPos, eventPosition) > 1;
|
|
22125
|
+
if (!this.dragCtx.ci.ref) {
|
|
22126
|
+
this.dragCtx.action = fromMultipleMove(rnd.ctab, this.editor.selection() || {}, diff);
|
|
22127
|
+
} else {
|
|
22128
|
+
this.dragCtx.action = fromSimpleObjectResizing(rnd.ctab, this.dragCtx.ci.id, diff, current, this.dragCtx.ci.ref, event.shiftKey);
|
|
21907
22129
|
}
|
|
22130
|
+
this.editor.update(this.dragCtx.action, true);
|
|
22131
|
+
} else {
|
|
22132
|
+
if (!this.dragCtx.action) {
|
|
22133
|
+
var action = fromSimpleObjectAddition(rnd.ctab, [this.dragCtx.p0, this.dragCtx.p0], this.mode, false);
|
|
22134
|
+
var addOperation = action.operations[0];
|
|
22135
|
+
this.dragCtx.itemId = addOperation.data.id;
|
|
22136
|
+
this.dragCtx.action = action;
|
|
22137
|
+
this.editor.update(this.dragCtx.action, true);
|
|
22138
|
+
} else {
|
|
22139
|
+
this.dragCtx.action.perform(rnd.ctab);
|
|
22140
|
+
}
|
|
22141
|
+
this.dragCtx.action = fromSimpleObjectResizing(rnd.ctab, this.dragCtx.itemId, diff, current, null, event.shiftKey);
|
|
22142
|
+
this.editor.update(this.dragCtx.action, true);
|
|
21908
22143
|
}
|
|
22144
|
+
} else {
|
|
22145
|
+
var items = this.editor.findItem(event, ['simpleObjects']);
|
|
22146
|
+
this.editor.hover(items, null, event);
|
|
21909
22147
|
}
|
|
21910
|
-
if (!targetPos) {
|
|
21911
|
-
return true;
|
|
21912
|
-
}
|
|
21913
|
-
var angle = vectorUtils.calcAngle(targetPos, eventPosition);
|
|
21914
|
-
if (!event.ctrlKey) {
|
|
21915
|
-
angle = vectorUtils.fracAngle(angle, null);
|
|
21916
|
-
}
|
|
21917
|
-
var degrees = vectorUtils.degrees(angle);
|
|
21918
|
-
this.editor.event.message.dispatch({
|
|
21919
|
-
info: degrees + 'º'
|
|
21920
|
-
});
|
|
21921
|
-
if (
|
|
21922
|
-
dragCtx.hasOwnProperty('angle') && dragCtx.angle === degrees && (
|
|
21923
|
-
!dragCtx.hasOwnProperty('extra_bond') || dragCtx.extra_bond === extraBond)) {
|
|
21924
|
-
return true;
|
|
21925
|
-
}
|
|
21926
|
-
if (dragCtx.action) {
|
|
21927
|
-
dragCtx.action.perform(this.editor.render.ctab);
|
|
21928
|
-
}
|
|
21929
|
-
dragCtx.angle = degrees;
|
|
21930
|
-
var action = null;
|
|
21931
|
-
if (!ci) {
|
|
21932
|
-
var _this$template;
|
|
21933
|
-
var isAddingFunctionalGroup = (_this$template = this.template) === null || _this$template === void 0 || (_this$template = _this$template.molecule) === null || _this$template === void 0 ? void 0 : _this$template.sgroups.size;
|
|
21934
|
-
if (isAddingFunctionalGroup) {
|
|
21935
|
-
return true;
|
|
21936
|
-
}
|
|
21937
|
-
var _fromTemplateOnCanvas = fromTemplateOnCanvas(this.editor.render.ctab, this.template, targetPos, angle);
|
|
21938
|
-
var _fromTemplateOnCanvas2 = _slicedToArray$1(_fromTemplateOnCanvas, 1);
|
|
21939
|
-
action = _fromTemplateOnCanvas2[0];
|
|
21940
|
-
} else if ((ci === null || ci === void 0 ? void 0 : ci.map) === 'atoms' || (ci === null || ci === void 0 ? void 0 : ci.map) === 'functionalGroups') {
|
|
21941
|
-
var _atomId = getTargetAtomId(this.struct, ci);
|
|
21942
|
-
var _fromTemplateOnAtom = fromTemplateOnAtom(this.editor.render.ctab, this.template, _atomId, angle, extraBond);
|
|
21943
|
-
var _fromTemplateOnAtom2 = _slicedToArray$1(_fromTemplateOnAtom, 1);
|
|
21944
|
-
action = _fromTemplateOnAtom2[0];
|
|
21945
|
-
dragCtx.extra_bond = extraBond;
|
|
21946
|
-
}
|
|
21947
|
-
dragCtx.action = action;
|
|
21948
|
-
this.editor.update(dragCtx.action, true);
|
|
21949
|
-
if (this.targetGroupsIds.length) this.targetGroupsIds.length = 0;
|
|
21950
|
-
return true;
|
|
21951
22148
|
}
|
|
21952
22149
|
}, {
|
|
21953
22150
|
key: "mouseup",
|
|
21954
22151
|
value: function mouseup(event) {
|
|
21955
|
-
|
|
21956
|
-
_ci;
|
|
21957
|
-
var dragCtx = this.dragCtx;
|
|
21958
|
-
if (!dragCtx) {
|
|
21959
|
-
return true;
|
|
21960
|
-
}
|
|
21961
|
-
delete this.dragCtx;
|
|
21962
|
-
var restruct = this.editor.render.ctab;
|
|
21963
|
-
var ci = dragCtx.item;
|
|
21964
|
-
if (dragCtx.action && ci && ci.map === 'bonds' && !this.isModeFunctionalGroup) {
|
|
21965
|
-
dragCtx.action.perform(restruct);
|
|
21966
|
-
var promise = fromTemplateOnBondAction(restruct, this.template, ci.id, this.editor.event, dragCtx.sign1 * dragCtx.sign2 > 0, true);
|
|
21967
|
-
promise.then(function (_ref) {
|
|
21968
|
-
var _ref2 = _slicedToArray$1(_ref, 2),
|
|
21969
|
-
action = _ref2[0],
|
|
21970
|
-
pasteItems = _ref2[1];
|
|
21971
|
-
var mergeItems = getItemsToFuse(_this2.editor, pasteItems);
|
|
21972
|
-
action = fromItemsFuse(restruct, mergeItems).mergeWith(action);
|
|
21973
|
-
_this2.editor.update(action);
|
|
21974
|
-
});
|
|
22152
|
+
if (!this.dragCtx) {
|
|
21975
22153
|
return true;
|
|
21976
22154
|
}
|
|
21977
|
-
|
|
21978
|
-
|
|
21979
|
-
|
|
21980
|
-
|
|
21981
|
-
|
|
21982
|
-
addOnCanvasWithoutMerge({
|
|
21983
|
-
restruct: _restruct,
|
|
21984
|
-
template: this.template,
|
|
21985
|
-
dragCtx: dragCtx,
|
|
21986
|
-
editor: this.editor,
|
|
21987
|
-
event: event
|
|
21988
|
-
});
|
|
21989
|
-
return true;
|
|
21990
|
-
}
|
|
21991
|
-
functionalGroupRemoveAction = new Action();
|
|
21992
|
-
var _functionalGroupToRep = functionalGroupToReplace.getContractedPosition(_restruct.molecule),
|
|
21993
|
-
sGroupPositionAtomId = _functionalGroupToRep.atomId;
|
|
21994
|
-
var atomsWithoutAttachmentAtom = SGroup$1.getAtoms(this.struct, functionalGroupToReplace).filter(function (id) {
|
|
21995
|
-
return id !== sGroupPositionAtomId;
|
|
21996
|
-
});
|
|
21997
|
-
functionalGroupRemoveAction.mergeWith(fromSgroupDeletion(_restruct, ci.id));
|
|
21998
|
-
functionalGroupRemoveAction.mergeWith(fromFragmentDeletion(_restruct, {
|
|
21999
|
-
atoms: atomsWithoutAttachmentAtom
|
|
22000
|
-
}));
|
|
22001
|
-
ci = {
|
|
22002
|
-
map: 'atoms',
|
|
22003
|
-
id: sGroupPositionAtomId
|
|
22004
|
-
};
|
|
22005
|
-
}
|
|
22006
|
-
if (!dragCtx.action) {
|
|
22007
|
-
if (!ci) {
|
|
22008
|
-
addOnCanvasWithoutMerge({
|
|
22009
|
-
restruct: restruct,
|
|
22010
|
-
template: this.template,
|
|
22011
|
-
dragCtx: dragCtx,
|
|
22012
|
-
editor: this.editor,
|
|
22013
|
-
event: event
|
|
22014
|
-
});
|
|
22015
|
-
return true;
|
|
22016
|
-
} else if (ci.map === 'atoms') {
|
|
22017
|
-
var _restruct$atoms$get2;
|
|
22018
|
-
var degree = (_restruct$atoms$get2 = restruct.atoms.get(ci.id)) === null || _restruct$atoms$get2 === void 0 ? void 0 : _restruct$atoms$get2.a.neighbors.length;
|
|
22019
|
-
if (degree && degree >= 1 && this.isSaltOrSolvent) {
|
|
22020
|
-
addOnCanvasWithoutMerge({
|
|
22021
|
-
restruct: restruct,
|
|
22022
|
-
template: this.template,
|
|
22023
|
-
dragCtx: dragCtx,
|
|
22024
|
-
editor: this.editor,
|
|
22025
|
-
event: event
|
|
22026
|
-
});
|
|
22027
|
-
return true;
|
|
22028
|
-
}
|
|
22029
|
-
var angle = getAngleFromEvent(event, ci, restruct);
|
|
22030
|
-
var _fromTemplateOnAtom3 = fromTemplateOnAtom(restruct, this.template, ci.id, angle, false);
|
|
22031
|
-
var _fromTemplateOnAtom4 = _slicedToArray$1(_fromTemplateOnAtom3, 1);
|
|
22032
|
-
action = _fromTemplateOnAtom4[0];
|
|
22033
|
-
if (functionalGroupRemoveAction) {
|
|
22034
|
-
action = functionalGroupRemoveAction.mergeWith(action);
|
|
22035
|
-
}
|
|
22036
|
-
dragCtx.action = action;
|
|
22037
|
-
} else if (ci.map === 'bonds' && !this.isModeFunctionalGroup) {
|
|
22038
|
-
var _promise = fromTemplateOnBondAction(restruct, this.template, ci.id, this.editor.event, dragCtx.sign1 * dragCtx.sign2 > 0, true);
|
|
22039
|
-
_promise.then(function (_ref3) {
|
|
22040
|
-
var _ref4 = _slicedToArray$1(_ref3, 2),
|
|
22041
|
-
action = _ref4[0],
|
|
22042
|
-
pasteItems = _ref4[1];
|
|
22043
|
-
if (!_this2.isModeFunctionalGroup) {
|
|
22044
|
-
var mergeItems = getItemsToFuse(_this2.editor, pasteItems);
|
|
22045
|
-
action = fromItemsFuse(restruct, mergeItems).mergeWith(action);
|
|
22046
|
-
_this2.editor.update(action);
|
|
22047
|
-
}
|
|
22048
|
-
});
|
|
22049
|
-
return true;
|
|
22050
|
-
}
|
|
22051
|
-
}
|
|
22052
|
-
var _iterator = _createForOfIteratorHelper$1(restruct.molecule.bonds.keys()),
|
|
22053
|
-
_step;
|
|
22054
|
-
try {
|
|
22055
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
22056
|
-
var id = _step.value;
|
|
22057
|
-
new BondAttr(id, 'isPreview', false).perform(restruct);
|
|
22058
|
-
}
|
|
22059
|
-
} catch (err) {
|
|
22060
|
-
_iterator.e(err);
|
|
22061
|
-
} finally {
|
|
22062
|
-
_iterator.f();
|
|
22063
|
-
}
|
|
22064
|
-
var _iterator2 = _createForOfIteratorHelper$1(restruct.molecule.atoms.keys()),
|
|
22065
|
-
_step2;
|
|
22066
|
-
try {
|
|
22067
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
22068
|
-
var _id = _step2.value;
|
|
22069
|
-
new AtomAttr(_id, 'isPreview', false).perform(restruct);
|
|
22155
|
+
if (this.dragCtx.action) {
|
|
22156
|
+
if (this.dragCtx.isNew) {
|
|
22157
|
+
var rnd = this.editor.render;
|
|
22158
|
+
this.editor.update(fromSimpleObjectDeletion(rnd.ctab, this.dragCtx.itemId), true);
|
|
22159
|
+
this.dragCtx.action = fromSimpleObjectAddition(rnd.ctab, [this.dragCtx.p0, this.dragCtx.previous], this.mode, event.shiftKey);
|
|
22070
22160
|
}
|
|
22071
|
-
|
|
22072
|
-
_iterator2.e(err);
|
|
22073
|
-
} finally {
|
|
22074
|
-
_iterator2.f();
|
|
22075
|
-
}
|
|
22076
|
-
var completeAction = dragCtx.action;
|
|
22077
|
-
if (completeAction && !completeAction.isDummy()) {
|
|
22078
|
-
this.editor.update(completeAction);
|
|
22161
|
+
this.editor.update(this.dragCtx.action);
|
|
22079
22162
|
}
|
|
22080
|
-
this.
|
|
22163
|
+
delete this.dragCtx;
|
|
22081
22164
|
return true;
|
|
22082
22165
|
}
|
|
22083
|
-
}, {
|
|
22084
|
-
key: "cancel",
|
|
22085
|
-
value: function cancel() {
|
|
22086
|
-
var _this$templatePreview3;
|
|
22087
|
-
(_this$templatePreview3 = this.templatePreview) === null || _this$templatePreview3 === void 0 || _this$templatePreview3.hidePreview();
|
|
22088
|
-
this.mouseup();
|
|
22089
|
-
}
|
|
22090
|
-
}, {
|
|
22091
|
-
key: "mouseleave",
|
|
22092
|
-
value: function mouseleave() {
|
|
22093
|
-
this.cancel();
|
|
22094
|
-
}
|
|
22095
|
-
}, {
|
|
22096
|
-
key: "mouseLeaveClientArea",
|
|
22097
|
-
value: function mouseLeaveClientArea() {
|
|
22098
|
-
var _this$templatePreview4;
|
|
22099
|
-
(_this$templatePreview4 = this.templatePreview) === null || _this$templatePreview4 === void 0 || _this$templatePreview4.hidePreview();
|
|
22100
|
-
}
|
|
22101
22166
|
}]);
|
|
22102
|
-
return
|
|
22167
|
+
return SimpleObjectTool;
|
|
22103
22168
|
}();
|
|
22104
|
-
function addOnCanvasWithoutMerge(_ref5) {
|
|
22105
|
-
var restruct = _ref5.restruct,
|
|
22106
|
-
template = _ref5.template,
|
|
22107
|
-
dragCtx = _ref5.dragCtx,
|
|
22108
|
-
editor = _ref5.editor,
|
|
22109
|
-
event = _ref5.event;
|
|
22110
|
-
var _fromTemplateOnCanvas3 = fromTemplateOnCanvas(restruct, template, dragCtx.xy0, 0, false),
|
|
22111
|
-
_fromTemplateOnCanvas4 = _slicedToArray$1(_fromTemplateOnCanvas3, 1),
|
|
22112
|
-
action = _fromTemplateOnCanvas4[0];
|
|
22113
|
-
editor.update(action);
|
|
22114
|
-
editor.selection(null);
|
|
22115
|
-
editor.hover(editor.findItem(event, null), null, event);
|
|
22116
|
-
editor.event.message.dispatch({
|
|
22117
|
-
info: false
|
|
22118
|
-
});
|
|
22119
|
-
}
|
|
22120
|
-
function getTemplateMode(tmpl) {
|
|
22121
|
-
var _tmpl$props;
|
|
22122
|
-
if (tmpl.mode) {
|
|
22123
|
-
return tmpl.mode;
|
|
22124
|
-
}
|
|
22125
|
-
if (['Functional Groups', 'Salts and Solvents'].includes((_tmpl$props = tmpl.props) === null || _tmpl$props === void 0 ? void 0 : _tmpl$props.group)) {
|
|
22126
|
-
return MODES.FG;
|
|
22127
|
-
}
|
|
22128
|
-
return null;
|
|
22129
|
-
}
|
|
22130
|
-
function getSign(molecule, bond, v) {
|
|
22131
|
-
var begin = molecule.atoms.get(bond.begin).pp;
|
|
22132
|
-
var end = molecule.atoms.get(bond.end).pp;
|
|
22133
|
-
var sign = Vec2.cross(Vec2.diff(begin, end), Vec2.diff(v, end));
|
|
22134
|
-
if (sign > 0) {
|
|
22135
|
-
return 1;
|
|
22136
|
-
}
|
|
22137
|
-
if (sign < 0) {
|
|
22138
|
-
return -1;
|
|
22139
|
-
}
|
|
22140
|
-
return 0;
|
|
22141
|
-
}
|
|
22142
|
-
function getTargetAtomId(struct, ci) {
|
|
22143
|
-
if (ci.map === 'atoms') {
|
|
22144
|
-
return ci.id;
|
|
22145
|
-
}
|
|
22146
|
-
if (ci.map === 'functionalGroups') {
|
|
22147
|
-
var group = struct.sgroups.get(ci.id);
|
|
22148
|
-
return group === null || group === void 0 ? void 0 : group.getAttachmentAtomId();
|
|
22149
|
-
}
|
|
22150
|
-
}
|
|
22151
22169
|
|
|
22152
22170
|
var TextTool = function () {
|
|
22153
22171
|
function TextTool(editor) {
|
|
@@ -32883,8 +32901,8 @@ var KetcherBuilder = function () {
|
|
|
32883
32901
|
initApp(element, appRoot, staticResourcesUrl, {
|
|
32884
32902
|
buttons: buttons || {},
|
|
32885
32903
|
errorHandler: errorHandler || null,
|
|
32886
|
-
version: "2.19.0-rc.
|
|
32887
|
-
buildDate: "2024-
|
|
32904
|
+
version: "2.19.0-rc.2" ,
|
|
32905
|
+
buildDate: "2024-03-11T08:48:42" ,
|
|
32888
32906
|
buildNumber: ''
|
|
32889
32907
|
}, structService, resolve, togglerComponent);
|
|
32890
32908
|
});
|