ketcher-core
Version:
Web-based molecule sketcher
2,220 lines (2,201 loc) • 5.46 MB
JavaScript
/****************************************************************************
* Copyright 2021 EPAM Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
import _createClass from '@babel/runtime/helpers/createClass';
import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn';
import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
import _assertThisInitialized from '@babel/runtime/helpers/assertThisInitialized';
import _inherits from '@babel/runtime/helpers/inherits';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import assert from 'assert';
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
import _regeneratorRuntime from '@babel/runtime/regenerator';
import _typeof from '@babel/runtime/helpers/typeof';
import { isMacOs } from 'react-device-detect';
import _wrapNativeSuper from '@babel/runtime/helpers/wrapNativeSuper';
import _, { isNumber, cloneDeepWith, cloneDeep, clamp, inRange, compact, values, uniq, difference, isEqual as isEqual$1, invert } from 'lodash';
import _get from '@babel/runtime/helpers/get';
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import { zoom, drag, ZoomTransform, select, line as line$1, brush } from 'd3';
import svgPath from 'svgpath';
import { flatten, isEqual, uniq as uniq$1, without } from 'lodash/fp';
import { saveAs } from 'file-saver';
var ElementColor = {
H: '#000000',
He: '#89a1a1',
Li: '#bd77ed',
Be: '#8fbc00',
B: '#c18989',
C: '#000000',
N: '#304ff7',
O: '#ff0d0d',
F: '#78bc42',
Ne: '#80a2af',
Na: '#ab5cf2',
Mg: '#6fcd00',
Al: '#a99393',
Si: '#b29478',
P: '#ff8000',
S: '#c99a19',
Cl: '#1fd01f',
Ar: '#69acba',
K: '#8f40d4',
Ca: '#38e900',
Sc: '#999999',
Ti: '#979a9e',
V: '#99999e',
Cr: '#8a99c7',
Mn: '#9c7ac7',
Fe: '#e06633',
Co: '#d37e8e',
Ni: '#4ece4e',
Cu: '#c78033',
Zn: '#7d80b0',
Ga: '#bc8b8b',
Ge: '#668f8f',
As: '#b87ddd',
Se: '#e59100',
Br: '#a62929',
Kr: '#59b1c9',
Rb: '#702eb0',
Sr: '#00ff00',
Y: '#66afaf',
Zr: '#71abab',
Nb: '#67aeb4',
Mo: '#54b5b5',
Tc: '#3b9e9e',
Ru: '#248f8f',
Rh: '#0a7d8c',
Pd: '#006985',
Ag: '#9a9a9a',
Cd: '#b29764',
In: '#a67573',
Sn: '#668080',
Sb: '#9e63b5',
Te: '#d47a00',
I: '#940094',
Xe: '#429eb0',
Cs: '#57178f',
Ba: '#00c900',
La: '#5caed1',
Ce: '#9d9d7b',
Pr: '#8ca581',
Nd: '#84a984',
Pm: '#71b18a',
Sm: '#66b68e',
Eu: '#4ac298',
Gd: '#37cb9e',
Tb: '#28d1a4',
Dy: '#1bd7a8',
Ho: '#00e98f',
Er: '#00e675',
Tm: '#00d452',
Yb: '#00bf38',
Lu: '#00ab24',
Hf: '#47b3ec',
Ta: '#4da6ff',
W: '#2194d6',
Re: '#267dab',
Os: '#266696',
Ir: '#175487',
Pt: '#9898a3',
Au: '#c19e1c',
Hg: '#9797ac',
Tl: '#a6544d',
Pb: '#575961',
Bi: '#9e4fb5',
Po: '#ab5c00',
At: '#754f45',
Rn: '#428296',
Fr: '#420066',
Ra: '#007d00',
Ac: '#6aa2ec',
Th: '#00baff',
Pa: '#00a1ff',
U: '#008fff',
Np: '#0080ff',
Pu: '#006bff',
Am: '#545cf2',
Cm: '#785ce3',
Bk: '#8a4fe3',
Cf: '#a136d4',
Es: '#b31fd4',
Fm: '#000000',
Md: '#000000',
No: '#000000',
Lr: '#000000',
Rf: '#47b3ec',
Db: '#4da6ff',
Sg: '#2194d6',
Bh: '#267dab',
Hs: '#266696',
Mt: '#175487',
Ds: '#9898a3',
Rg: '#c19e1c',
Cn: '#9797ac',
Nh: '#000000',
Fl: '#000000',
Mc: '#000000',
Lv: '#000000',
Ts: '#000000',
Og: '#000000'
};
var elementsArray = [{
number: 1,
label: 'H',
period: 1,
group: 1,
title: 'Hydrogen',
state: 'gas',
origin: 'primordial',
type: 'other-nonmetal',
mass: 1.00794
}, {
number: 2,
label: 'He',
period: 1,
group: 8,
title: 'Helium',
state: 'gas',
origin: 'primordial',
type: 'noble',
mass: 4.0026022
}, {
number: 3,
label: 'Li',
period: 2,
group: 1,
title: 'Lithium',
state: 'solid',
origin: 'primordial',
type: 'alkali',
mass: 6.94
}, {
number: 4,
label: 'Be',
period: 2,
group: 2,
title: 'Beryllium',
state: 'solid',
origin: 'primordial',
type: 'alkaline-earth',
mass: 9.01218315
}, {
number: 5,
label: 'B',
period: 2,
group: 3,
title: 'Boron',
state: 'solid',
origin: 'primordial',
type: 'metalloid',
mass: 10.81
}, {
number: 6,
label: 'C',
period: 2,
group: 4,
title: 'Carbon',
state: 'solid',
origin: 'primordial',
type: 'other-nonmetal',
mass: 12.011
}, {
number: 7,
label: 'N',
period: 2,
group: 5,
title: 'Nitrogen',
state: 'gas',
origin: 'primordial',
type: 'other-nonmetal',
mass: 14.007
}, {
number: 8,
label: 'O',
period: 2,
group: 6,
leftH: true,
title: 'Oxygen',
state: 'gas',
origin: 'primordial',
type: 'other-nonmetal',
mass: 15.999
}, {
number: 9,
label: 'F',
period: 2,
group: 7,
leftH: true,
title: 'Fluorine',
state: 'gas',
origin: 'primordial',
type: 'halogen',
mass: 18.9984031636
}, {
number: 10,
label: 'Ne',
period: 2,
group: 8,
title: 'Neon',
state: 'gas',
origin: 'primordial',
type: 'noble',
mass: 20.17976
}, {
number: 11,
label: 'Na',
period: 3,
group: 1,
title: 'Sodium',
state: 'solid',
origin: 'primordial',
type: 'alkali',
mass: 22.989769282
}, {
number: 12,
label: 'Mg',
period: 3,
group: 2,
title: 'Magnesium',
state: 'solid',
origin: 'primordial',
type: 'alkaline-earth',
mass: 24.305
}, {
number: 13,
label: 'Al',
period: 3,
group: 3,
title: 'Aluminium',
state: 'solid',
origin: 'primordial',
type: 'post-transition',
mass: 26.98153857
}, {
number: 14,
label: 'Si',
period: 3,
group: 4,
title: 'Silicon',
state: 'solid',
origin: 'primordial',
type: 'metalloid',
mass: 28.085
}, {
number: 15,
label: 'P',
period: 3,
group: 5,
title: 'Phosphorus',
state: 'solid',
origin: 'primordial',
type: 'other-nonmetal',
mass: 30.9737619985
}, {
number: 16,
label: 'S',
period: 3,
group: 6,
leftH: true,
title: 'Sulfur',
state: 'solid',
origin: 'primordial',
type: 'other-nonmetal',
mass: 32.06
}, {
number: 17,
label: 'Cl',
period: 3,
group: 7,
leftH: true,
title: 'Chlorine',
state: 'gas',
origin: 'primordial',
type: 'halogen',
mass: 35.45
}, {
number: 18,
label: 'Ar',
period: 3,
group: 8,
title: 'Argon',
state: 'gas',
origin: 'primordial',
type: 'noble',
mass: 39.9481
}, {
number: 19,
label: 'K',
period: 4,
group: 1,
title: 'Potassium',
state: 'solid',
origin: 'primordial',
type: 'alkali',
mass: 39.09831
}, {
number: 20,
label: 'Ca',
period: 4,
group: 2,
title: 'Calcium',
state: 'solid',
origin: 'primordial',
type: 'alkaline-earth',
mass: 40.0784
}, {
number: 21,
label: 'Sc',
period: 4,
group: 3,
title: 'Scandium',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 44.9559085
}, {
number: 22,
label: 'Ti',
period: 4,
group: 4,
title: 'Titanium',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 47.8671
}, {
number: 23,
label: 'V',
period: 4,
group: 5,
title: 'Vanadium',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 50.94151
}, {
number: 24,
label: 'Cr',
period: 4,
group: 6,
title: 'Chromium',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 51.99616
}, {
number: 25,
label: 'Mn',
period: 4,
group: 7,
title: 'Manganese',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 54.9380443
}, {
number: 26,
label: 'Fe',
period: 4,
group: 8,
title: 'Iron',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 55.8452
}, {
number: 27,
label: 'Co',
period: 4,
group: 8,
title: 'Cobalt',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 58.9331944
}, {
number: 28,
label: 'Ni',
period: 4,
group: 8,
title: 'Nickel',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 58.69344
}, {
number: 29,
label: 'Cu',
period: 4,
group: 1,
title: 'Copper',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 63.5463
}, {
number: 30,
label: 'Zn',
period: 4,
group: 2,
title: 'Zinc',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 65.382
}, {
number: 31,
label: 'Ga',
period: 4,
group: 3,
title: 'Gallium',
state: 'solid',
origin: 'primordial',
type: 'post-transition',
mass: 69.7231
}, {
number: 32,
label: 'Ge',
period: 4,
group: 4,
title: 'Germanium',
state: 'solid',
origin: 'primordial',
type: 'metalloid',
mass: 72.6308
}, {
number: 33,
label: 'As',
period: 4,
group: 5,
title: 'Arsenic',
state: 'solid',
origin: 'primordial',
type: 'metalloid',
mass: 74.9215956
}, {
number: 34,
label: 'Se',
period: 4,
group: 6,
leftH: true,
title: 'Selenium',
state: 'solid',
origin: 'primordial',
type: 'other-nonmetal',
mass: 78.9718
}, {
number: 35,
label: 'Br',
period: 4,
group: 7,
leftH: true,
title: 'Bromine',
state: 'liquid',
origin: 'primordial',
type: 'halogen',
mass: 79.904
}, {
number: 36,
label: 'Kr',
period: 4,
group: 8,
title: 'Krypton',
state: 'gas',
origin: 'primordial',
type: 'noble',
mass: 83.7982
}, {
number: 37,
label: 'Rb',
period: 5,
group: 1,
title: 'Rubidium',
state: 'solid',
origin: 'primordial',
type: 'alkali',
mass: 85.46783
}, {
number: 38,
label: 'Sr',
period: 5,
group: 2,
title: 'Strontium',
state: 'solid',
origin: 'primordial',
type: 'alkaline-earth',
mass: 87.621
}, {
number: 39,
label: 'Y',
period: 5,
group: 3,
title: 'Yttrium',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 88.905842
}, {
number: 40,
label: 'Zr',
period: 5,
group: 4,
title: 'Zirconium',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 91.2242
}, {
number: 41,
label: 'Nb',
period: 5,
group: 5,
title: 'Niobium',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 92.906372
}, {
number: 42,
label: 'Mo',
period: 5,
group: 6,
title: 'Molybdenum',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 95.951
}, {
number: 43,
label: 'Tc',
period: 5,
group: 7,
title: 'Technetium',
state: 'solid',
origin: 'decay',
type: 'transition',
mass: 98
}, {
number: 44,
label: 'Ru',
period: 5,
group: 8,
title: 'Ruthenium',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 101.072
}, {
number: 45,
label: 'Rh',
period: 5,
group: 8,
title: 'Rhodium',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 102.905502
}, {
number: 46,
label: 'Pd',
period: 5,
group: 8,
title: 'Palladium',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 106.421
}, {
number: 47,
label: 'Ag',
period: 5,
group: 1,
title: 'Silver',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 107.86822
}, {
number: 48,
label: 'Cd',
period: 5,
group: 2,
title: 'Cadmium',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 112.4144
}, {
number: 49,
label: 'In',
period: 5,
group: 3,
title: 'Indium',
state: 'solid',
origin: 'primordial',
type: 'post-transition',
mass: 114.8181
}, {
number: 50,
label: 'Sn',
period: 5,
group: 4,
title: 'Tin',
state: 'solid',
origin: 'primordial',
type: 'post-transition',
mass: 118.7107
}, {
number: 51,
label: 'Sb',
period: 5,
group: 5,
title: 'Antimony',
state: 'solid',
origin: 'primordial',
type: 'metalloid',
mass: 121.7601
}, {
number: 52,
label: 'Te',
period: 5,
group: 6,
title: 'Tellurium',
state: 'solid',
origin: 'primordial',
type: 'metalloid',
mass: 127.603
}, {
number: 53,
label: 'I',
period: 5,
group: 7,
leftH: true,
title: 'Iodine',
state: 'solid',
origin: 'primordial',
type: 'halogen',
mass: 126.904473
}, {
number: 54,
label: 'Xe',
period: 5,
group: 8,
title: 'Xenon',
state: 'gas',
origin: 'primordial',
type: 'noble',
mass: 131.2936
}, {
number: 55,
label: 'Cs',
period: 6,
group: 1,
title: 'Caesium',
state: 'solid',
origin: 'primordial',
type: 'alkali',
mass: 132.905451966
}, {
number: 56,
label: 'Ba',
period: 6,
group: 2,
title: 'Barium',
state: 'solid',
origin: 'primordial',
type: 'alkaline-earth',
mass: 137.3277
}, {
number: 57,
label: 'La',
period: 6,
group: 3,
title: 'Lanthanum',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 138.905477
}, {
number: 58,
label: 'Ce',
period: 6,
group: 3,
title: 'Cerium',
state: 'solid',
origin: 'primordial',
type: 'lanthanide',
mass: 140.1161
}, {
number: 59,
label: 'Pr',
period: 6,
group: 3,
title: 'Praseodymium',
state: 'solid',
origin: 'primordial',
type: 'lanthanide',
mass: 140.907662
}, {
number: 60,
label: 'Nd',
period: 6,
group: 3,
title: 'Neodymium',
state: 'solid',
origin: 'primordial',
type: 'lanthanide',
mass: 144.2423
}, {
number: 61,
label: 'Pm',
period: 6,
group: 3,
title: 'Promethium',
state: 'solid',
origin: 'decay',
type: 'lanthanide',
mass: 145
}, {
number: 62,
label: 'Sm',
period: 6,
group: 3,
title: 'Samarium',
state: 'solid',
origin: 'primordial',
type: 'lanthanide',
mass: 150.362
}, {
number: 63,
label: 'Eu',
period: 6,
group: 3,
title: 'Europium',
state: 'solid',
origin: 'primordial',
type: 'lanthanide',
mass: 151.9641
}, {
number: 64,
label: 'Gd',
period: 6,
group: 3,
title: 'Gadolinium',
state: 'solid',
origin: 'primordial',
type: 'lanthanide',
mass: 157.253
}, {
number: 65,
label: 'Tb',
period: 6,
group: 3,
title: 'Terbium',
state: 'solid',
origin: 'primordial',
type: 'lanthanide',
mass: 158.925352
}, {
number: 66,
label: 'Dy',
period: 6,
group: 3,
title: 'Dysprosium',
state: 'solid',
origin: 'primordial',
type: 'lanthanide',
mass: 162.5001
}, {
number: 67,
label: 'Ho',
period: 6,
group: 3,
title: 'Holmium',
state: 'solid',
origin: 'primordial',
type: 'lanthanide',
mass: 164.930332
}, {
number: 68,
label: 'Er',
period: 6,
group: 3,
title: 'Erbium',
state: 'solid',
origin: 'primordial',
type: 'lanthanide',
mass: 167.2593
}, {
number: 69,
label: 'Tm',
period: 6,
group: 3,
title: 'Thulium',
state: 'solid',
origin: 'primordial',
type: 'lanthanide',
mass: 168.934222
}, {
number: 70,
label: 'Yb',
period: 6,
group: 3,
title: 'Ytterbium',
state: 'solid',
origin: 'primordial',
type: 'lanthanide',
mass: 173.0451
}, {
number: 71,
label: 'Lu',
period: 6,
group: 3,
title: 'Lutetium',
state: 'solid',
origin: 'primordial',
type: 'lanthanide',
mass: 174.96681
}, {
number: 72,
label: 'Hf',
period: 6,
group: 4,
title: 'Hafnium',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 178.492
}, {
number: 73,
label: 'Ta',
period: 6,
group: 5,
title: 'Tantalum',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 180.947882
}, {
number: 74,
label: 'W',
period: 6,
group: 6,
title: 'Tungsten',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 183.841
}, {
number: 75,
label: 'Re',
period: 6,
group: 7,
title: 'Rhenium',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 186.2071
}, {
number: 76,
label: 'Os',
period: 6,
group: 8,
title: 'Osmium',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 190.233
}, {
number: 77,
label: 'Ir',
period: 6,
group: 8,
title: 'Iridium',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 192.2173
}, {
number: 78,
label: 'Pt',
period: 6,
group: 8,
title: 'Platinum',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 195.0849
}, {
number: 79,
label: 'Au',
period: 6,
group: 1,
title: 'Gold',
state: 'solid',
origin: 'primordial',
type: 'transition',
mass: 196.9665695
}, {
number: 80,
label: 'Hg',
period: 6,
group: 2,
title: 'Mercury',
state: 'liquid',
origin: 'primordial',
type: 'transition',
mass: 200.5923
}, {
number: 81,
label: 'Tl',
period: 6,
group: 3,
title: 'Thallium',
state: 'solid',
origin: 'primordial',
type: 'post-transition',
mass: 204.38
}, {
number: 82,
label: 'Pb',
period: 6,
group: 4,
title: 'Lead',
state: 'solid',
origin: 'primordial',
type: 'post-transition',
mass: 207.21
}, {
number: 83,
label: 'Bi',
period: 6,
group: 5,
title: 'Bismuth',
state: 'solid',
origin: 'primordial',
type: 'post-transition',
mass: 208.980401
}, {
number: 84,
label: 'Po',
period: 6,
group: 6,
title: 'Polonium',
state: 'solid',
origin: 'decay',
type: 'metalloid',
mass: 209
}, {
number: 85,
label: 'At',
period: 6,
group: 7,
title: 'Astatine',
state: 'solid',
origin: 'decay',
type: 'halogen',
mass: 210
}, {
number: 86,
label: 'Rn',
period: 6,
group: 8,
title: 'Radon',
state: 'gas',
origin: 'decay',
type: 'noble',
mass: 222
}, {
number: 87,
label: 'Fr',
period: 7,
group: 1,
title: 'Francium',
state: 'solid',
origin: 'decay',
type: 'alkali',
mass: 223
}, {
number: 88,
label: 'Ra',
period: 7,
group: 2,
title: 'Radium',
state: 'solid',
origin: 'decay',
type: 'alkaline-earth',
mass: 226
}, {
number: 89,
label: 'Ac',
period: 7,
group: 3,
title: 'Actinium',
state: 'solid',
origin: 'decay',
type: 'transition',
mass: 227
}, {
number: 90,
label: 'Th',
period: 7,
group: 3,
title: 'Thorium',
state: 'solid',
origin: 'primordial',
type: 'actinide',
mass: 232.03774
}, {
number: 91,
label: 'Pa',
period: 7,
group: 3,
title: 'Protactinium',
state: 'solid',
origin: 'decay',
type: 'actinide',
mass: 231.035882
}, {
number: 92,
label: 'U',
period: 7,
group: 3,
title: 'Uranium',
state: 'solid',
origin: 'primordial',
type: 'actinide',
mass: 238.028913
}, {
number: 93,
label: 'Np',
period: 7,
group: 3,
title: 'Neptunium',
state: 'solid',
origin: 'decay',
type: 'actinide',
mass: 237
}, {
number: 94,
label: 'Pu',
period: 7,
group: 3,
title: 'Plutonium',
state: 'solid',
origin: 'decay',
type: 'actinide',
mass: 244
}, {
number: 95,
label: 'Am',
period: 7,
group: 3,
title: 'Americium',
state: 'solid',
origin: 'synthetic',
type: 'actinide',
mass: 243
}, {
number: 96,
label: 'Cm',
period: 7,
group: 3,
title: 'Curium',
state: 'solid',
origin: 'synthetic',
type: 'actinide',
mass: 247
}, {
number: 97,
label: 'Bk',
period: 7,
group: 3,
title: 'Berkelium',
state: 'solid',
origin: 'synthetic',
type: 'actinide',
mass: 247
}, {
number: 98,
label: 'Cf',
period: 7,
group: 3,
title: 'Californium',
state: 'solid',
origin: 'synthetic',
type: 'actinide',
mass: 251
}, {
number: 99,
label: 'Es',
period: 7,
group: 3,
title: 'Einsteinium',
state: 'solid',
origin: 'synthetic',
type: 'actinide',
mass: 252
}, {
number: 100,
label: 'Fm',
period: 7,
group: 3,
title: 'Fermium',
origin: 'synthetic',
type: 'actinide',
mass: 257
}, {
number: 101,
label: 'Md',
period: 7,
group: 3,
title: 'Mendelevium',
origin: 'synthetic',
type: 'actinide',
mass: 258
}, {
number: 102,
label: 'No',
period: 7,
group: 3,
title: 'Nobelium',
origin: 'synthetic',
type: 'actinide',
mass: 259
}, {
number: 103,
label: 'Lr',
period: 7,
group: 3,
title: 'Lawrencium',
origin: 'synthetic',
type: 'actinide',
mass: 266
}, {
number: 104,
label: 'Rf',
period: 7,
group: 4,
title: 'Rutherfordium',
origin: 'synthetic',
type: 'transition',
mass: 267
}, {
number: 105,
label: 'Db',
period: 7,
group: 5,
title: 'Dubnium',
origin: 'synthetic',
type: 'transition',
mass: 268
}, {
number: 106,
label: 'Sg',
period: 7,
group: 6,
title: 'Seaborgium',
origin: 'synthetic',
type: 'transition',
mass: 269
}, {
number: 107,
label: 'Bh',
period: 7,
group: 7,
title: 'Bohrium',
origin: 'synthetic',
type: 'transition',
mass: 270
}, {
number: 108,
label: 'Hs',
period: 7,
group: 8,
title: 'Hassium',
origin: 'synthetic',
type: 'transition',
mass: 269
}, {
number: 109,
label: 'Mt',
period: 7,
group: 8,
title: 'Meitnerium',
origin: 'synthetic',
type: 'transition',
mass: 278
}, {
number: 110,
label: 'Ds',
period: 7,
group: 8,
title: 'Darmstadtium',
origin: 'synthetic',
type: 'transition',
mass: 281
}, {
number: 111,
label: 'Rg',
period: 7,
group: 1,
title: 'Roentgenium',
origin: 'synthetic',
type: 'transition',
mass: 282
}, {
number: 112,
label: 'Cn',
period: 7,
group: 2,
title: 'Copernicium',
origin: 'synthetic',
type: 'transition',
mass: 285
}, {
number: 113,
label: 'Nh',
period: 7,
group: 3,
title: 'Nihonium',
origin: 'synthetic',
type: 'post-transition',
mass: 286
}, {
number: 114,
label: 'Fl',
period: 7,
group: 4,
title: 'Flerovium',
origin: 'synthetic',
type: 'post-transition',
mass: 289
}, {
number: 115,
label: 'Mc',
period: 7,
group: 5,
title: 'Moscovium',
origin: 'synthetic',
type: 'post-transition',
mass: 289
}, {
number: 116,
label: 'Lv',
period: 7,
group: 6,
title: 'Livermorium',
origin: 'synthetic',
type: 'post-transition',
mass: 293
}, {
number: 117,
label: 'Ts',
period: 7,
group: 7,
title: 'Tennessine',
origin: 'synthetic',
type: 'halogen',
mass: 294
}, {
number: 118,
label: 'Og',
period: 7,
group: 8,
title: 'Oganesson',
origin: 'synthetic',
type: 'noble',
mass: 294
}];
var elementsMap = elementsArray.reduce(function (acc, element) {
acc.set(element.label, element);
acc.set(element.number, element);
return acc;
}, new Map());
var Elements = {
get: function get(key) {
return elementsMap.get(key);
},
filter: function filter(predicate) {
return elementsArray.filter(predicate);
},
getAll: function getAll() {
return [].concat(elementsArray);
}
};
var AtomLabel;
(function (AtomLabel) {
AtomLabel["Ac"] = "Ac";
AtomLabel["Ag"] = "Ag";
AtomLabel["Al"] = "Al";
AtomLabel["Am"] = "Am";
AtomLabel["Ar"] = "Ar";
AtomLabel["As"] = "As";
AtomLabel["At"] = "At";
AtomLabel["Au"] = "Au";
AtomLabel["B"] = "B";
AtomLabel["Ba"] = "Ba";
AtomLabel["Be"] = "Be";
AtomLabel["Bh"] = "Bh";
AtomLabel["Bi"] = "Bi";
AtomLabel["Bk"] = "Bk";
AtomLabel["Br"] = "Br";
AtomLabel["C"] = "C";
AtomLabel["Ca"] = "Ca";
AtomLabel["Cd"] = "Cd";
AtomLabel["Ce"] = "Ce";
AtomLabel["Cf"] = "Cf";
AtomLabel["Cl"] = "Cl";
AtomLabel["Cm"] = "Cm";
AtomLabel["Cn"] = "Cn";
AtomLabel["Co"] = "Co";
AtomLabel["Cr"] = "Cr";
AtomLabel["Cs"] = "Cs";
AtomLabel["Cu"] = "Cu";
AtomLabel["Db"] = "Db";
AtomLabel["Ds"] = "Ds";
AtomLabel["Dy"] = "Dy";
AtomLabel["Er"] = "Er";
AtomLabel["Es"] = "Es";
AtomLabel["Eu"] = "Eu";
AtomLabel["F"] = "F";
AtomLabel["Fe"] = "Fe";
AtomLabel["Fl"] = "Fl";
AtomLabel["Fm"] = "Fm";
AtomLabel["Fr"] = "Fr";
AtomLabel["Ga"] = "Ga";
AtomLabel["Gd"] = "Gd";
AtomLabel["Ge"] = "Ge";
AtomLabel["H"] = "H";
AtomLabel["He"] = "He";
AtomLabel["Hf"] = "Hf";
AtomLabel["Hg"] = "Hg";
AtomLabel["Ho"] = "Ho";
AtomLabel["Hs"] = "Hs";
AtomLabel["I"] = "I";
AtomLabel["In"] = "In";
AtomLabel["Ir"] = "Ir";
AtomLabel["K"] = "K";
AtomLabel["Kr"] = "Kr";
AtomLabel["La"] = "La";
AtomLabel["Li"] = "Li";
AtomLabel["Lr"] = "Lr";
AtomLabel["Lu"] = "Lu";
AtomLabel["Lv"] = "Lv";
AtomLabel["Mc"] = "Mc";
AtomLabel["Md"] = "Md";
AtomLabel["Mg"] = "Mg";
AtomLabel["Mn"] = "Mn";
AtomLabel["Mo"] = "Mo";
AtomLabel["Mt"] = "Mt";
AtomLabel["N"] = "N";
AtomLabel["Na"] = "Na";
AtomLabel["Nb"] = "Nb";
AtomLabel["Nd"] = "Nd";
AtomLabel["Ne"] = "Ne";
AtomLabel["Nh"] = "Nh";
AtomLabel["Ni"] = "Ni";
AtomLabel["No"] = "No";
AtomLabel["Np"] = "Np";
AtomLabel["O"] = "O";
AtomLabel["Og"] = "Og";
AtomLabel["Os"] = "Os";
AtomLabel["P"] = "P";
AtomLabel["Pa"] = "Pa";
AtomLabel["Pb"] = "Pb";
AtomLabel["Pd"] = "Pd";
AtomLabel["Pm"] = "Pm";
AtomLabel["Po"] = "Po";
AtomLabel["Pr"] = "Pr";
AtomLabel["Pt"] = "Pt";
AtomLabel["Pu"] = "Pu";
AtomLabel["Ra"] = "Ra";
AtomLabel["Rb"] = "Rb";
AtomLabel["Re"] = "Re";
AtomLabel["Rf"] = "Rf";
AtomLabel["Rg"] = "Rg";
AtomLabel["Rh"] = "Rh";
AtomLabel["Rn"] = "Rn";
AtomLabel["Ru"] = "Ru";
AtomLabel["S"] = "S";
AtomLabel["Sb"] = "Sb";
AtomLabel["Sc"] = "Sc";
AtomLabel["Se"] = "Se";
AtomLabel["Sg"] = "Sg";
AtomLabel["Si"] = "Si";
AtomLabel["Sm"] = "Sm";
AtomLabel["Sn"] = "Sn";
AtomLabel["Sr"] = "Sr";
AtomLabel["Ta"] = "Ta";
AtomLabel["Tb"] = "Tb";
AtomLabel["Tc"] = "Tc";
AtomLabel["Te"] = "Te";
AtomLabel["Th"] = "Th";
AtomLabel["Ti"] = "Ti";
AtomLabel["Tl"] = "Tl";
AtomLabel["Tm"] = "Tm";
AtomLabel["Ts"] = "Ts";
AtomLabel["U"] = "U";
AtomLabel["V"] = "V";
AtomLabel["W"] = "W";
AtomLabel["Xe"] = "Xe";
AtomLabel["Y"] = "Y";
AtomLabel["Yb"] = "Yb";
AtomLabel["Zn"] = "Zn";
AtomLabel["Zr"] = "Zr";
AtomLabel["D"] = "D";
AtomLabel["T"] = "T";
})(AtomLabel || (AtomLabel = {}));
var Generics = {
'atoms-gen': {
title: 'Atom Generics',
itemSets: [{
displayName: 'any atom',
items: [{
label: 'A',
description: 'Any atom except hydrogen'
}, {
label: 'AH',
description: 'Any atom, including hydrogen'
}]
}, {
displayName: 'except C or H',
items: [{
label: 'Q',
description: 'Any heteroatom (any atom except C or H)'
}, {
label: 'QH',
description: 'Any atom except C'
}]
}, {
displayName: 'any metal',
items: [{
label: 'M',
description: 'Any metal'
}, {
label: 'MH',
description: 'Any metal or hydrogen'
}]
}, {
displayName: 'any halogen',
items: [{
label: 'X',
description: 'Any halogen'
}, {
label: 'XH',
description: 'Any halogen or hydrogen'
}]
}]
},
'special-nodes': {
title: 'Special Nodes',
itemSets: [{
items: [{
label: 'H+',
description: 'Proton'
}, {
label: 'D',
description: 'Deuterium'
}, {
label: 'T',
description: 'Tritium'
}, {
label: 'R',
description: 'Pseudoatom'
}, {
label: 'Pol',
description: 'Polymer Bead'
}]
}]
},
'group-gen': {
title: 'Group Generics',
itemSets: [{
items: [{
label: 'G',
description: 'Any group'
}, {
label: 'GH',
description: 'Any group or hydrogen'
}]
}, {
items: [{
label: 'G*',
description: 'Any group with a ring closure'
}, {
label: 'GH*',
description: 'Any group with a ring closure or hydrogen'
}]
}],
subGroups: {
'group-acyclic': {
title: 'Acyclic',
itemSets: [{
items: [{
label: 'ACY',
description: 'Acyclic group'
}, {
label: 'ACH',
description: 'Acyclic group or hydrogen'
}]
}],
subGroups: {
'acyclic-carbo': {
title: 'Acyclic Carbo',
itemSets: [{
items: [{
label: 'ABC',
description: 'Carbocyclic'
}, {
label: 'ABH',
description: 'Carbocyclic of hydrogen'
}]
}, {
displayName: 'alkynyl',
items: [{
label: 'AYL',
description: 'Alkynyl'
}, {
label: 'AYH',
description: 'Alkynyl or hydrogen'
}]
}, {
displayName: 'alkyl',
items: [{
label: 'ALK',
description: 'Alkyl'
}, {
label: 'ALH',
description: 'Alkyl or hydrogen'
}]
}, {
displayName: 'alkenyl',
items: [{
label: 'AEL',
description: 'Alkenyl'
}, {
label: 'AEH',
description: 'Alkenyl or hydrogen'
}]
}]
},
'acyclic-hetero': {
title: 'Acyclic Hetero',
itemSets: [{
items: [{
label: 'AHC',
description: 'Heteroacyclic'
}, {
label: 'AHH',
description: 'Heterocyclic or hydrogen'
}]
}, {
items: [{
label: 'AOX',
description: 'Alkoxy'
}, {
label: 'AOH',
description: 'Alkoxy or hydrogen'
}]
}]
}
}
},
'group-cyclic': {
title: 'Cyclic',
itemSets: [{
items: [{
label: 'CYC',
description: 'Cyclic group'
}, {
label: 'CYH',
description: 'Cyclic group or hydrogen'
}]
}, {
displayName: 'no carbon',
items: [{
label: 'CXX',
description: 'Cyclic group with no Carbon atoms'
}, {
label: 'CXH',
description: 'Cyclic group with no Carbon atoms or hydrogen'
}]
}],
subGroups: {
'cyclic-carbo': {
title: 'Cyclic Carbo',
itemSets: [{
items: [{
label: 'CBC',
description: 'Carbocyclic derivatives'
}, {
label: 'CBH',
description: 'Carbocyclic derivatives or hydrogen'
}]
}, {
displayName: 'aryl',
items: [{
label: 'ARY',
description: 'Any aryl group'
}, {
label: 'ARH',
description: 'Any aryl group or hydrogen'
}]
}, {
displayName: 'cycloalkyl',
items: [{
label: 'CAL',
description: 'Any cycloalkyl group'
}, {
label: 'CAH',
description: 'Any cycloalkyl group or hydrogen'
}]
}, {
displayName: 'cycloalkenyl',
items: [{
label: 'CEL',
description: 'Any cyloalkenyl group'
}, {
label: 'CEH',
description: 'Any cyloalkenyl group or hydrogen'
}]
}]
},
'cyclic-hetero': {
title: 'Cyclic Hetero',
itemSets: [{
items: [{
label: 'CHC',
description: 'Heterocyclic group'
}, {
label: 'CHH',
description: 'Heterocyclic group or hydrogen'
}]
}, {
displayName: 'hetero aryl',
items: [{
label: 'HAR',
description: 'Heteroaryl group'
}, {
label: 'HAH',
description: 'Heteroaryl group or hydrogen'
}]
}]
}
}
}
}
}
};
function getGenericsList(generics) {
var _generics$;
if (Array.isArray(generics) && !((_generics$ = generics[0]) !== null && _generics$ !== void 0 && _generics$.items)) {
return generics.map(function (item) {
return item.label;
});
} else {
var result = [];
for (var _i = 0, _Object$values = Object.values(generics); _i < _Object$values.length; _i++) {
var subGroup = _Object$values[_i];
if (typeof generics === 'string') continue;
result = [].concat(_toConsumableArray(result), _toConsumableArray(getGenericsList(subGroup)));
}
return result;
}
}
var genericsList = getGenericsList(Generics);
var IMAGE_KEY = 'images';
var IMAGE_SERIALIZE_KEY = 'image';
var CURSOR_DIAGONAL_NWSE = 'nwse-resize';
var CURSOR_DIAGONAL_NESW = 'nesw-resize';
var CURSOR_VERTICAL = 'ns-resize';
var CURSOR_HORIZONTAL = 'ew-resize';
var imageReferencePositionToCursor = {
topLeftPosition: CURSOR_DIAGONAL_NWSE,
topMiddlePosition: CURSOR_VERTICAL,
topRightPosition: CURSOR_DIAGONAL_NESW,
rightMiddlePosition: CURSOR_HORIZONTAL,
bottomRightPosition: CURSOR_DIAGONAL_NWSE,
bottomMiddlePosition: CURSOR_VERTICAL,
bottomLeftPosition: CURSOR_DIAGONAL_NESW,
leftMiddlePosition: CURSOR_HORIZONTAL
};
var MULTITAIL_ARROW_KEY = 'multitailArrows';
var MULTITAIL_ARROW_TOOL_NAME = 'reaction-arrow-multitail';
var MULTITAIL_ARROW_SERIALIZE_KEY = 'multi-tailed-arrow';
var MOVE = 'move';
var CURSOR_RESIZE_VERTICAL = 'ns-resize';
var CURSOR_RESIZE_HORIZONTAL = 'ew-resize';
var multitailReferencePositionToCursor = {
topTail: CURSOR_RESIZE_HORIZONTAL,
tails: CURSOR_RESIZE_HORIZONTAL,
bottomTail: CURSOR_RESIZE_HORIZONTAL,
topSpine: MOVE,
bottomSpine: MOVE,
head: CURSOR_RESIZE_HORIZONTAL
};
var multitailArrowReferenceLinesToCursor = {
topTail: CURSOR_RESIZE_VERTICAL,
bottomTail: CURSOR_RESIZE_VERTICAL,
tails: CURSOR_RESIZE_VERTICAL,
head: CURSOR_RESIZE_VERTICAL,
spine: MOVE
};
var STRAND_TYPE;
(function (STRAND_TYPE) {
STRAND_TYPE["SENSE"] = "sense";
STRAND_TYPE["ANTISENSE"] = "antisense";
})(STRAND_TYPE || (STRAND_TYPE = {}));
var RNA_DNA_NON_MODIFIED_PART;
(function (RNA_DNA_NON_MODIFIED_PART) {
RNA_DNA_NON_MODIFIED_PART["SUGAR_RNA"] = "R";
RNA_DNA_NON_MODIFIED_PART["SUGAR_DNA"] = "dR";
RNA_DNA_NON_MODIFIED_PART["PHOSPHATE"] = "P";
})(RNA_DNA_NON_MODIFIED_PART || (RNA_DNA_NON_MODIFIED_PART = {}));
var RnaDnaNaturalAnaloguesEnum;
(function (RnaDnaNaturalAnaloguesEnum) {
RnaDnaNaturalAnaloguesEnum["ADENINE"] = "A";
RnaDnaNaturalAnaloguesEnum["THYMINE"] = "T";
RnaDnaNaturalAnaloguesEnum["GUANINE"] = "G";
RnaDnaNaturalAnaloguesEnum["CYTOSINE"] = "C";
RnaDnaNaturalAnaloguesEnum["URACIL"] = "U";
})(RnaDnaNaturalAnaloguesEnum || (RnaDnaNaturalAnaloguesEnum = {}));
var RnaDnaBaseNames;
(function (RnaDnaBaseNames) {
RnaDnaBaseNames["URACIL"] = "Uracil";
RnaDnaBaseNames["THYMINE"] = "Thymine";
})(RnaDnaBaseNames || (RnaDnaBaseNames = {}));
var StandardAmbiguousRnaBase;
(function (StandardAmbiguousRnaBase) {
StandardAmbiguousRnaBase["N"] = "N";
StandardAmbiguousRnaBase["B"] = "B";
StandardAmbiguousRnaBase["V"] = "V";
StandardAmbiguousRnaBase["D"] = "D";
StandardAmbiguousRnaBase["H"] = "H";
StandardAmbiguousRnaBase["K"] = "K";
StandardAmbiguousRnaBase["M"] = "M";
StandardAmbiguousRnaBase["W"] = "W";
StandardAmbiguousRnaBase["Y"] = "Y";
StandardAmbiguousRnaBase["R"] = "R";
StandardAmbiguousRnaBase["S"] = "S";
})(StandardAmbiguousRnaBase || (StandardAmbiguousRnaBase = {}));
var rnaDnaNaturalAnalogues = [RnaDnaNaturalAnaloguesEnum.ADENINE, RnaDnaNaturalAnaloguesEnum.THYMINE, RnaDnaNaturalAnaloguesEnum.GUANINE, RnaDnaNaturalAnaloguesEnum.CYTOSINE, RnaDnaNaturalAnaloguesEnum.URACIL];
var unknownNaturalAnalogues = ['.', 'X'];
var peptideNaturalAnalogues = ['A', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'V', 'U', 'W', 'Y'];
var NO_NATURAL_ANALOGUE = 'X';
var MONOMER_CONST = {
AMINO_ACID: 'AminoAcid',
PEPTIDE: 'PEPTIDE',
CHEM: 'CHEM',
RNA: 'RNA',
DNA: 'DNA',
MODDNA: 'MODDNA',
R: 'R',
P: 'P',
SUGAR: 'SUGAR',
BASE: 'BASE',
PHOSPHATE: 'PHOSPHATE'
};
function _createForOfIteratorHelper$d(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$d(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; } } }; }
function _unsupportedIterableToArray$d(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$d(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$d(o, minLen); }
function _arrayLikeToArray$d(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; }
var AtomList = function () {
function AtomList(params) {
_classCallCheck(this, AtomList);
this.notList = params.notList;
this.ids = params.ids;
}
_createClass(AtomList, [{
key: "labelList",
value: function labelList() {
var labels = [];
var _iterator = _createForOfIteratorHelper$d(this.ids),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var id = _step.value;
var currenElement = Elements.get(id);
currenElement && labels.push(currenElement.label);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
return labels;
}
}, {
key: "label",
value: function label() {
var label = '[' + this.labelList().join(',') + ']';
if (this.notList) {
label = '!' + label;
}
return label;
}
}, {
key: "equals",
value: function equals(atomList) {
return this.notList === atomList.notList && (this.ids || []).sort().toString() === (atomList.ids || []).sort().toString();
}
}]);
return AtomList;
}();
function ifDef(target, key, value, defaultValue) {
if (value !== undefined && value !== null && value !== defaultValue && !(Array.isArray(value) && value.length === 0)) {
target[key] = value;
}
}
function tfx(value) {
var parsedValue;
if (typeof value === 'number') {
parsedValue = value;
} else {
parsedValue = parseFloat(value);
}
return parsedValue.toFixed(8);
}
var LogLevel;
(function (LogLevel) {
LogLevel[LogLevel["ERROR"] = 0] = "ERROR";
LogLevel[LogLevel["WARN"] = 1] = "WARN";
LogLevel[LogLevel["INFO"] = 2] = "INFO";
LogLevel[LogLevel["LOG"] = 3] = "LOG";
})(LogLevel || (LogLevel = {}));
var KetcherLogger = function () {
function KetcherLogger() {
_classCallCheck(this, KetcherLogger);
}
_createClass(KetcherLogger, null, [{
key: "settings",
get: function get() {
var _window, _window$ketcher$loggi, _window$ketcher;
if (typeof window === 'undefined') {
return {};
}
if (!((_window = window) !== null && _window !== void 0 && _window.ketcher)) {
throw new Error('Ketcher needs to be initialized before KetcherLogger is used');
}
return (_window$ketcher$loggi = (_window$ketcher = window.ketcher) === null || _window$ketcher === void 0 ? void 0 : _window$ketcher.logging) !== null && _window$ketcher$loggi !== void 0 ? _window$ketcher$loggi : {};
},
set: function set(newSettings) {
for (var _i = 0, _Object$entries = Object.entries(newSettings); _i < _Object$entries.length; _i++) {
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
settingName = _Object$entries$_i[0],
settingValue = _Object$entries$_i[1];
this.settings[settingName] = settingValue;
}
}
}, {
key: "log",
value: function log() {
if (!this.isMinimumLogLevel(LogLevel.LOG)) {
return;
}
var showTrace = this.settings.showTrace;
for (var _len = arguments.length, messages = new Array(_len), _key = 0; _key < _len; _key++) {
messages[_key] = arguments[_key];
}
if (showTrace) {
window.console.trace(messages);
} else {
window.console.log(messages);
}
}
}, {
key: "info",
value: function info() {
if (!this.isMinimumLogLevel(LogLevel.INFO)) {
return;
}
var showTrace = this.settings.showTrace;
for (var _len2 = arguments.length, messages = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
messages[_key2] = arguments[_key2];
}
if (showTrace) {
window.console.trace(messages);
} else {
window.console.info(messages);
}
}
}, {
key: "warn",
value: function warn() {
if (!this.isMinimumLogLevel(LogLevel.WARN)) {
return;
}
for (var _len3 = arguments.length, warnings = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
warnings[_key3] = arguments[_key3];
}
window.console.warn(warnings);
}
}, {
key: "error",
value: function error() {
if (!this.isMinimumLogLevel(LogLevel.ERROR)) {
return;
}
for (var _len4 = arguments.length, errors = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
errors[_key4] = arguments[_key4];
}
window.console.error(errors);
}
}, {
key: "isMinimumLogLevel",
value: function isMinimumLogLevel(minimumLevel) {
var _this$settings = this.settings,
enabled = _this$settings.enabled,
level = _this$settings.level;
if (!enabled || level == null) {
return false;
}
return level >= minimumLevel;
}
}]);
return KetcherLogger;
}();
var KetcherAsyncEvents;
(function (KetcherAsyncEvents) {
KetcherAsyncEvents["LOADING"] = "LOADING";
KetcherAsyncEvents["SUCCESS"] = "SUCCESS";
KetcherAsyncEvents["FAILURE"] = "FAILURE";
})(KetcherAsyncEvents || (KetcherAsyncEvents = {}));
var runAsyncAction = function () {
var _ref = _asyncToGenerator( _regeneratorRuntime.mark(function _callee(action, eventEmitter) {
var res;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
eventEmitter.emit(KetcherAsyncEvents.LOADING);
_context.prev = 1;
_context.next = 4;
return action();
case 4:
res = _context.sent;
eventEmitter.emit(KetcherAsyncEvents.SUCCESS);
return _context.abrupt("return", res);
case 9:
_context.prev = 9;
_context.t0 = _context["catch"](1);
KetcherLogger.error('runAsyncAction.ts::runAsyncAction', _context.t0);
eventEmitter.emit(KetcherAsyncEvents.FAILURE);
return _context.abrupt("return", undefined);
case 14:
case "end":
return _context.stop();
}
}, _callee, null, [[1, 9]]);
}));
return function runAsyncAction(_x, _x2) {
return _ref.apply(this, arguments);
};
}();
function b64toBlob(b64Data) {
var contentType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var sliceSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 512;
var byteCharacters = window.atob(b64Data);
var byteArrays = [];
for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
var slice = byteCharacters.slice(offset, offset + sliceSize);
var byteNumbers = new Array(slice.length);
for (var i = 0; i < slice.length; i++) {
byteNumbers[i] = slice.charCodeAt(i);
}
var byteArray = new Uint8Array(byteNumbers);
byteArrays.push(byteArray);
}
var blob = new Blob(byteArrays, {
type: contentType
});
return blob;
}
function notifyRequestCompleted() {
var event = new Event('requestCompleted');
window.dispatchEvent(event);
}
function ownKeys$B(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; }
function _objectSpread$B(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$B(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$B(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var KETCHER_SAVED_SETTINGS_KEY = 'ketcher_editor_saved_settings';
var KETCHER_SAVED_OPTIONS_KEY = 'ketcher-opts';
var SettingsManager = function () {
function SettingsManager() {
_classCallCheck(this, SettingsManager);
}
_createClass(SettingsManager, null, [{
key: "getSettings",
value: function getSettings() {
try {
return JSON.parse(localStorage.getItem(KETCHER_SAVED_SETTINGS_KEY) || '{}');
} catch (e) {
KetcherLogger.error('settingsManager.ts::SettingsManager::getSettings', e);
return {};
}
}
}, {
key: "saveSettings",
value: function saveSettings(settings) {
if (!settings) {
return;
}
localStorage.setItem(KETCHER_SAVED_SETTINGS_KEY, JSON.stringify(settings));
}
}, {
key: "getOptions",
value: function getOptions() {
try {
var optionsFromLocalStorage = JSON.parse(localStorage.getItem(KETCHER_SAVED_OPTIONS_KEY) || '{}');
if (optionsFromLocalStorage.bondLength === 2.1 && optionsFromLocalStorage.bondLengthUnit === 'px') {
optionsFromLocalStorage.bondLength = 40;
}
return optionsFromLocalStorage;
} catch (e) {
KetcherLogger.error('SettingsManager.ts::SettingsManager::getOptions', e);
return {};
}
}
}, {
key: "saveOptions",
value: function saveOptions(options) {
if (!options) {
return;
}
localStorage.setItem(KETCHER_SAVED_OPTIONS_KEY, JSON.stringify(options));
}
}, {
key: "selectionTool",
get: function get() {
var _this$getSettings = this.getSettings(),
selectionTool = _this$getSettings.selectionTool;
return selectionTool;
},
set: function set(selectionTool) {
var settings = this.getSettings();
this.saveSettings(_objectSpread$B(_objectSpread$B({}, settings), {}, {
selectionTool: selectionTool
}));
}
}, {
key: "disableCustomQuery",
get: function get() {
return this._disableCustomQuery;
},
set: function set(disableCustomQuery) {
this._disableCustomQuery = disableCustomQuery;
}
}, {
key: "ignoreChiralFlag",
get: function get() {
var _this$getOptions = this.getOptions(),
ignoreChiralFlag = _this$getOptions.ignoreChiralFlag;
return ignoreChiralFlag;
},
set: function set(ignoreChiralFlag) {
var options = this.getOptions();
this.saveOptions(_objectSpread$B(_objectSpread$B({}, options), {}, {
ignoreChiralFlag: ignoreChiralFlag
}));
}
}]);
return SettingsManager;
}();
var base = {
8: "Backspace",
9: "Tab",
10: "Enter",
12: "NumLock",
13: "Enter",
16: "Shift",
17: "Control",
18: "Alt",
20: "CapsLock",
27: "Escape",
32: " ",
33: "PageUp",
34: "PageDown",
35: "End",
36: "Home",
37: "ArrowLeft",
38: "ArrowUp",
39: "ArrowRight",
40: "ArrowDown",
44: "PrintScreen",
45: "Insert",
46: "Delete",
59: ";",
61: "=",
91: "Meta",
92: "Meta",
106: "*",
107: "+",
108: ",",
109: "-",
110: ".",
111: "/",
144: "NumLock",
145: "ScrollLock",
160: "Shift",
161: "Shift",
162: "Control",
163: "Control",
164: "Alt",
165: "Alt",
173: "-",
186: ";",
187: "=",
188: ",",
189: "-",
190: ".",
191: "/",
192: "`",
219: "[",
220: "\\",
221: "]",
222: "'"
};
var shift = {
48: ")",
49: "!",
50: "@",
51: "#",
52: "$",
53: "%",
54: "^",
55: "&",
56: "*",
57: "(",
59: ":",
61: "+",
173: "_",
186: ":",
187: "+",
188: "<",
189: "_",
190: ">",
191: "?",
192: "~",
219: "{",
220: "|",
221: "}",
222: "\""
};
typeof navigator != "undefined" && /Mac/.test(navigator.platform);
typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(