@kent-tokyo/chematic 0.1.10 → 0.1.20

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/chematic_wasm.js CHANGED
@@ -1,9 +1,2917 @@
1
1
  /* @ts-self-types="./chematic_wasm.d.ts" */
2
- import * as wasm from "./chematic_wasm_bg.wasm";
3
- import { __wbg_set_wasm } from "./chematic_wasm_bg.js";
4
-
5
- __wbg_set_wasm(wasm);
6
- wasm.__wbindgen_start();
7
- export {
8
- DepictOptions, MolHandle, add_hydrogens, brics_fragment_count, depict_svg_grid, ecfp4_bitvec, is_valid_smiles, parse_smiles, remove_hydrogens, run_reactants, tanimoto_atom_pair, tanimoto_ecfp4, tanimoto_fcfp4, tanimoto_torsion
9
- } from "./chematic_wasm_bg.js";
2
+
3
+ /**
4
+ * A conformer ensemble: one molecule geometry with multiple 3D coordinate sets.
5
+ *
6
+ * Create with `new(smiles)`, then add conformers with `add_generated_conformer`
7
+ * or `add_minimized_conformer`. Retrieve coordinates as PDB strings via
8
+ * `get_conformer_pdb(idx)`. Compare conformers with `conformer_rmsd`.
9
+ */
10
+ export class ConformerHandle {
11
+ __destroy_into_raw() {
12
+ const ptr = this.__wbg_ptr;
13
+ this.__wbg_ptr = 0;
14
+ ConformerHandleFinalization.unregister(this);
15
+ return ptr;
16
+ }
17
+ free() {
18
+ const ptr = this.__destroy_into_raw();
19
+ wasm.__wbg_conformerhandle_free(ptr, 0);
20
+ }
21
+ /**
22
+ * Generate a new 3D conformer using distance-geometry and add it to the ensemble.
23
+ *
24
+ * Returns the index of the newly added conformer.
25
+ * @returns {number}
26
+ */
27
+ add_generated_conformer() {
28
+ const ret = wasm.conformerhandle_add_generated_conformer(this.__wbg_ptr);
29
+ return ret >>> 0;
30
+ }
31
+ /**
32
+ * Generate a new 3D conformer, run force-field minimization, and add it.
33
+ *
34
+ * Returns the index of the newly added conformer.
35
+ * @returns {number}
36
+ */
37
+ add_minimized_conformer() {
38
+ const ret = wasm.conformerhandle_add_minimized_conformer(this.__wbg_ptr);
39
+ return ret >>> 0;
40
+ }
41
+ /**
42
+ * Number of conformers currently stored.
43
+ * @returns {number}
44
+ */
45
+ conformer_count() {
46
+ const ret = wasm.conformerhandle_conformer_count(this.__wbg_ptr);
47
+ return ret >>> 0;
48
+ }
49
+ /**
50
+ * Kabsch-aligned RMSD (Å) between conformers `a` and `b`.
51
+ *
52
+ * Returns `NaN` if either index is out of range.
53
+ * @param {number} a
54
+ * @param {number} b
55
+ * @returns {number}
56
+ */
57
+ conformer_rmsd(a, b) {
58
+ const ret = wasm.conformerhandle_conformer_rmsd(this.__wbg_ptr, a, b);
59
+ return ret;
60
+ }
61
+ /**
62
+ * Un-aligned (translation + rotation NOT removed) RMSD (Å) between conformers `a` and `b`.
63
+ *
64
+ * Returns `NaN` if either index is out of range.
65
+ * @param {number} a
66
+ * @param {number} b
67
+ * @returns {number}
68
+ */
69
+ conformer_rmsd_no_align(a, b) {
70
+ const ret = wasm.conformerhandle_conformer_rmsd_no_align(this.__wbg_ptr, a, b);
71
+ return ret;
72
+ }
73
+ /**
74
+ * Return conformer `idx` as a PDB string, or `null` if `idx` is out of range.
75
+ * @param {number} idx
76
+ * @returns {string | undefined}
77
+ */
78
+ get_conformer_pdb(idx) {
79
+ const ret = wasm.conformerhandle_get_conformer_pdb(this.__wbg_ptr, idx);
80
+ let v1;
81
+ if (ret[0] !== 0) {
82
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
83
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
84
+ }
85
+ return v1;
86
+ }
87
+ /**
88
+ * The ensemble's molecule as a `MolHandle`.
89
+ * @returns {MolHandle}
90
+ */
91
+ mol() {
92
+ const ret = wasm.conformerhandle_mol(this.__wbg_ptr);
93
+ return MolHandle.__wrap(ret);
94
+ }
95
+ /**
96
+ * Create a new empty ensemble for the molecule given by `smiles`.
97
+ *
98
+ * Returns a JS error on SMILES parse failure.
99
+ * @param {string} smiles
100
+ */
101
+ constructor(smiles) {
102
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
103
+ const len0 = WASM_VECTOR_LEN;
104
+ const ret = wasm.conformerhandle_new(ptr0, len0);
105
+ if (ret[2]) {
106
+ throw takeFromExternrefTable0(ret[1]);
107
+ }
108
+ this.__wbg_ptr = ret[0];
109
+ ConformerHandleFinalization.register(this, this.__wbg_ptr, this);
110
+ return this;
111
+ }
112
+ /**
113
+ * Remove conformer `idx` and return `true`, or `false` if `idx` is out of range.
114
+ * @param {number} idx
115
+ * @returns {boolean}
116
+ */
117
+ remove_conformer(idx) {
118
+ const ret = wasm.conformerhandle_remove_conformer(this.__wbg_ptr, idx);
119
+ return ret !== 0;
120
+ }
121
+ }
122
+ if (Symbol.dispose) ConformerHandle.prototype[Symbol.dispose] = ConformerHandle.prototype.free;
123
+
124
+ /**
125
+ * Style options for [`MolHandle::depict_svg_opts`].
126
+ *
127
+ * Construct with `new DepictOptions()`, then call setters:
128
+ * ```js
129
+ * const opts = new DepictOptions();
130
+ * opts.set_background("transparent");
131
+ * opts.set_dark(true);
132
+ * opts.set_width(240);
133
+ * opts.set_height(240);
134
+ * ```
135
+ */
136
+ export class DepictOptions {
137
+ __destroy_into_raw() {
138
+ const ptr = this.__wbg_ptr;
139
+ this.__wbg_ptr = 0;
140
+ DepictOptionsFinalization.unregister(this);
141
+ return ptr;
142
+ }
143
+ free() {
144
+ const ptr = this.__destroy_into_raw();
145
+ wasm.__wbg_depictoptions_free(ptr, 0);
146
+ }
147
+ constructor() {
148
+ const ret = wasm.depictoptions_new();
149
+ this.__wbg_ptr = ret;
150
+ DepictOptionsFinalization.register(this, this.__wbg_ptr, this);
151
+ return this;
152
+ }
153
+ /**
154
+ * Set a per-atom color override (CSS color string). Calling multiple times
155
+ * for the same `idx` uses the last value. The atom is highlighted even if
156
+ * not in `set_highlight_atoms`.
157
+ * @param {number} idx
158
+ * @param {string} color
159
+ */
160
+ set_atom_color(idx, color) {
161
+ const ptr0 = passStringToWasm0(color, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
162
+ const len0 = WASM_VECTOR_LEN;
163
+ wasm.depictoptions_set_atom_color(this.__wbg_ptr, idx, ptr0, len0);
164
+ }
165
+ /**
166
+ * @param {boolean} v
167
+ */
168
+ set_atom_ids(v) {
169
+ wasm.depictoptions_set_atom_ids(this.__wbg_ptr, v);
170
+ }
171
+ /**
172
+ * @param {string} bg
173
+ */
174
+ set_background(bg) {
175
+ const ptr0 = passStringToWasm0(bg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
176
+ const len0 = WASM_VECTOR_LEN;
177
+ wasm.depictoptions_set_background(this.__wbg_ptr, ptr0, len0);
178
+ }
179
+ /**
180
+ * @param {boolean} dark
181
+ */
182
+ set_dark(dark) {
183
+ wasm.depictoptions_set_dark(this.__wbg_ptr, dark);
184
+ }
185
+ /**
186
+ * @param {number} h
187
+ */
188
+ set_height(h) {
189
+ wasm.depictoptions_set_height(this.__wbg_ptr, h);
190
+ }
191
+ /**
192
+ * @param {Uint32Array} atoms
193
+ */
194
+ set_highlight_atoms(atoms) {
195
+ const ptr0 = passArray32ToWasm0(atoms, wasm.__wbindgen_malloc);
196
+ const len0 = WASM_VECTOR_LEN;
197
+ wasm.depictoptions_set_highlight_atoms(this.__wbg_ptr, ptr0, len0);
198
+ }
199
+ /**
200
+ * @param {Uint32Array} bonds
201
+ */
202
+ set_highlight_bonds(bonds) {
203
+ const ptr0 = passArray32ToWasm0(bonds, wasm.__wbindgen_malloc);
204
+ const len0 = WASM_VECTOR_LEN;
205
+ wasm.depictoptions_set_highlight_bonds(this.__wbg_ptr, ptr0, len0);
206
+ }
207
+ /**
208
+ * @param {string} color
209
+ */
210
+ set_highlight_color(color) {
211
+ const ptr0 = passStringToWasm0(color, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
212
+ const len0 = WASM_VECTOR_LEN;
213
+ wasm.depictoptions_set_highlight_color(this.__wbg_ptr, ptr0, len0);
214
+ }
215
+ /**
216
+ * @param {boolean} v
217
+ */
218
+ set_kekulize(v) {
219
+ wasm.depictoptions_set_kekulize(this.__wbg_ptr, v);
220
+ }
221
+ /**
222
+ * @param {number} p
223
+ */
224
+ set_padding(p) {
225
+ wasm.depictoptions_set_padding(this.__wbg_ptr, p);
226
+ }
227
+ /**
228
+ * @param {boolean} v
229
+ */
230
+ set_show_atom_indices(v) {
231
+ wasm.depictoptions_set_show_atom_indices(this.__wbg_ptr, v);
232
+ }
233
+ /**
234
+ * @param {number} w
235
+ */
236
+ set_width(w) {
237
+ wasm.depictoptions_set_width(this.__wbg_ptr, w);
238
+ }
239
+ }
240
+ if (Symbol.dispose) DepictOptions.prototype[Symbol.dispose] = DepictOptions.prototype.free;
241
+
242
+ /**
243
+ * A handle to a parsed molecule. Owns the molecule behind an `Rc` so that
244
+ * it can be cheaply cloned on the JS side without copying atom/bond data.
245
+ */
246
+ export class MolHandle {
247
+ static __wrap(ptr) {
248
+ const obj = Object.create(MolHandle.prototype);
249
+ obj.__wbg_ptr = ptr;
250
+ MolHandleFinalization.register(obj, obj.__wbg_ptr, obj);
251
+ return obj;
252
+ }
253
+ __destroy_into_raw() {
254
+ const ptr = this.__wbg_ptr;
255
+ this.__wbg_ptr = 0;
256
+ MolHandleFinalization.unregister(this);
257
+ return ptr;
258
+ }
259
+ free() {
260
+ const ptr = this.__destroy_into_raw();
261
+ wasm.__wbg_molhandle_free(ptr, 0);
262
+ }
263
+ /**
264
+ * Number of aromatic rings (all ring atoms aromatic).
265
+ * @returns {number}
266
+ */
267
+ aromatic_ring_count() {
268
+ const ret = wasm.molhandle_aromatic_ring_count(this.__wbg_ptr);
269
+ return ret >>> 0;
270
+ }
271
+ /**
272
+ * Number of heavy atoms (explicit atoms in the graph; does not count implicit H).
273
+ * @returns {number}
274
+ */
275
+ atom_count() {
276
+ const ret = wasm.molhandle_atom_count(this.__wbg_ptr);
277
+ return ret >>> 0;
278
+ }
279
+ /**
280
+ * Bertz complexity index (BertzCT).
281
+ * @returns {number}
282
+ */
283
+ bertz_ct() {
284
+ const ret = wasm.molhandle_bertz_ct(this.__wbg_ptr);
285
+ return ret;
286
+ }
287
+ /**
288
+ * Number of bonds.
289
+ * @returns {number}
290
+ */
291
+ bond_count() {
292
+ const ret = wasm.molhandle_bond_count(this.__wbg_ptr);
293
+ return ret >>> 0;
294
+ }
295
+ /**
296
+ * Canonical SMILES string.
297
+ * @returns {string}
298
+ */
299
+ canonical_smiles() {
300
+ let deferred1_0;
301
+ let deferred1_1;
302
+ try {
303
+ const ret = wasm.molhandle_canonical_smiles(this.__wbg_ptr);
304
+ deferred1_0 = ret[0];
305
+ deferred1_1 = ret[1];
306
+ return getStringFromWasm0(ret[0], ret[1]);
307
+ } finally {
308
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
309
+ }
310
+ }
311
+ /**
312
+ * Kier–Hall χ0 molecular connectivity index.
313
+ * @returns {number}
314
+ */
315
+ chi0() {
316
+ const ret = wasm.molhandle_chi0(this.__wbg_ptr);
317
+ return ret;
318
+ }
319
+ /**
320
+ * Kier–Hall χ0v valence-weighted connectivity index.
321
+ * @returns {number}
322
+ */
323
+ chi0v() {
324
+ const ret = wasm.molhandle_chi0v(this.__wbg_ptr);
325
+ return ret;
326
+ }
327
+ /**
328
+ * Kier–Hall χ1 molecular connectivity index.
329
+ * @returns {number}
330
+ */
331
+ chi1() {
332
+ const ret = wasm.molhandle_chi1(this.__wbg_ptr);
333
+ return ret;
334
+ }
335
+ /**
336
+ * Kier–Hall χ1v valence-weighted connectivity index.
337
+ * @returns {number}
338
+ */
339
+ chi1v() {
340
+ const ret = wasm.molhandle_chi1v(this.__wbg_ptr);
341
+ return ret;
342
+ }
343
+ /**
344
+ * Kier–Hall χ2 molecular connectivity index.
345
+ * @returns {number}
346
+ */
347
+ chi2() {
348
+ const ret = wasm.molhandle_chi2(this.__wbg_ptr);
349
+ return ret;
350
+ }
351
+ /**
352
+ * Kier–Hall χ2v valence-weighted connectivity index.
353
+ * @returns {number}
354
+ */
355
+ chi2v() {
356
+ const ret = wasm.molhandle_chi2v(this.__wbg_ptr);
357
+ return ret;
358
+ }
359
+ /**
360
+ * Kier–Hall χ3 molecular connectivity index.
361
+ * @returns {number}
362
+ */
363
+ chi3() {
364
+ const ret = wasm.molhandle_chi3(this.__wbg_ptr);
365
+ return ret;
366
+ }
367
+ /**
368
+ * Kier–Hall χ3v valence-weighted connectivity index.
369
+ * @returns {number}
370
+ */
371
+ chi3v() {
372
+ const ret = wasm.molhandle_chi3v(this.__wbg_ptr);
373
+ return ret;
374
+ }
375
+ /**
376
+ * Kier–Hall χ4 molecular connectivity index.
377
+ * @returns {number}
378
+ */
379
+ chi4() {
380
+ const ret = wasm.molhandle_chi4(this.__wbg_ptr);
381
+ return ret;
382
+ }
383
+ /**
384
+ * Kier–Hall χ4v valence-weighted connectivity index.
385
+ * @returns {number}
386
+ */
387
+ chi4v() {
388
+ const ret = wasm.molhandle_chi4v(this.__wbg_ptr);
389
+ return ret;
390
+ }
391
+ /**
392
+ * 2D SVG depiction of the molecule (CPK coloring).
393
+ * @returns {string}
394
+ */
395
+ depict_svg() {
396
+ let deferred1_0;
397
+ let deferred1_1;
398
+ try {
399
+ const ret = wasm.molhandle_depict_svg(this.__wbg_ptr);
400
+ deferred1_0 = ret[0];
401
+ deferred1_1 = ret[1];
402
+ return getStringFromWasm0(ret[0], ret[1]);
403
+ } finally {
404
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
405
+ }
406
+ }
407
+ /**
408
+ * 2D SVG depiction with style options.
409
+ * @param {DepictOptions} opts
410
+ * @returns {string}
411
+ */
412
+ depict_svg_opts(opts) {
413
+ let deferred1_0;
414
+ let deferred1_1;
415
+ try {
416
+ _assertClass(opts, DepictOptions);
417
+ const ret = wasm.molhandle_depict_svg_opts(this.__wbg_ptr, opts.__wbg_ptr);
418
+ deferred1_0 = ret[0];
419
+ deferred1_1 = ret[1];
420
+ return getStringFromWasm0(ret[0], ret[1]);
421
+ } finally {
422
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
423
+ }
424
+ }
425
+ /**
426
+ * Returns `true` if the molecule passes Egan's absorption criteria
427
+ * (TPSA ≤ 131.6 Ų and LogP ≤ 5.88).
428
+ * @returns {boolean}
429
+ */
430
+ egan_passes() {
431
+ const ret = wasm.molhandle_egan_passes(this.__wbg_ptr);
432
+ return ret !== 0;
433
+ }
434
+ /**
435
+ * Monoisotopic (exact) mass.
436
+ * @returns {number}
437
+ */
438
+ exact_mass() {
439
+ const ret = wasm.molhandle_exact_mass(this.__wbg_ptr);
440
+ return ret;
441
+ }
442
+ /**
443
+ * Sum of formal charges.
444
+ * @returns {number}
445
+ */
446
+ formal_charge_sum() {
447
+ const ret = wasm.molhandle_formal_charge_sum(this.__wbg_ptr);
448
+ return ret;
449
+ }
450
+ /**
451
+ * Molecular formula string (Hill notation: C first, H second, then alphabetical).
452
+ * @returns {string}
453
+ */
454
+ formula() {
455
+ let deferred1_0;
456
+ let deferred1_1;
457
+ try {
458
+ const ret = wasm.molhandle_formula(this.__wbg_ptr);
459
+ deferred1_0 = ret[0];
460
+ deferred1_1 = ret[1];
461
+ return getStringFromWasm0(ret[0], ret[1]);
462
+ } finally {
463
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
464
+ }
465
+ }
466
+ /**
467
+ * Fraction of sp3 carbons (Fsp3).
468
+ * @returns {number}
469
+ */
470
+ fsp3() {
471
+ const ret = wasm.molhandle_fsp3(this.__wbg_ptr);
472
+ return ret;
473
+ }
474
+ /**
475
+ * Returns `true` if the molecule passes Ghose's drug-likeness filter
476
+ * (MW 160–480, LogP −0.4–5.6, HeavyAtoms 20–70, MR 40–130).
477
+ * @returns {boolean}
478
+ */
479
+ ghose_passes() {
480
+ const ret = wasm.molhandle_ghose_passes(this.__wbg_ptr);
481
+ return ret !== 0;
482
+ }
483
+ /**
484
+ * Number of hydrogen bond acceptors (Lipinski: all N and O atoms).
485
+ * @returns {number}
486
+ */
487
+ hba_count() {
488
+ const ret = wasm.molhandle_hba_count(this.__wbg_ptr);
489
+ return ret >>> 0;
490
+ }
491
+ /**
492
+ * Number of hydrogen bond donors (N-H or O-H groups).
493
+ * @returns {number}
494
+ */
495
+ hbd_count() {
496
+ const ret = wasm.molhandle_hbd_count(this.__wbg_ptr);
497
+ return ret >>> 0;
498
+ }
499
+ /**
500
+ * Number of non-hydrogen heavy atoms.
501
+ * @returns {number}
502
+ */
503
+ heavy_atom_count() {
504
+ const ret = wasm.molhandle_heavy_atom_count(this.__wbg_ptr);
505
+ return ret >>> 0;
506
+ }
507
+ /**
508
+ * Hall–Kier κ1 shape index.
509
+ * @returns {number}
510
+ */
511
+ kappa1() {
512
+ const ret = wasm.molhandle_kappa1(this.__wbg_ptr);
513
+ return ret;
514
+ }
515
+ /**
516
+ * Hall–Kier κ2 shape index.
517
+ * @returns {number}
518
+ */
519
+ kappa2() {
520
+ const ret = wasm.molhandle_kappa2(this.__wbg_ptr);
521
+ return ret;
522
+ }
523
+ /**
524
+ * Hall–Kier κ3 shape index.
525
+ * @returns {number}
526
+ */
527
+ kappa3() {
528
+ const ret = wasm.molhandle_kappa3(this.__wbg_ptr);
529
+ return ret;
530
+ }
531
+ /**
532
+ * Labute approximate surface area (Ų).
533
+ * @returns {number}
534
+ */
535
+ labute_asa() {
536
+ const ret = wasm.molhandle_labute_asa(this.__wbg_ptr);
537
+ return ret;
538
+ }
539
+ /**
540
+ * Returns `true` if the molecule satisfies Lipinski's Rule of Five.
541
+ * @returns {boolean}
542
+ */
543
+ lipinski_passes() {
544
+ const ret = wasm.molhandle_lipinski_passes(this.__wbg_ptr);
545
+ return ret !== 0;
546
+ }
547
+ /**
548
+ * Crippen–Wildman octanol/water partition coefficient (LogP).
549
+ * @returns {number}
550
+ */
551
+ logp_crippen() {
552
+ const ret = wasm.molhandle_logp_crippen(this.__wbg_ptr);
553
+ return ret;
554
+ }
555
+ /**
556
+ * Maximum EState index across all heavy atoms.
557
+ * @returns {number}
558
+ */
559
+ max_estate() {
560
+ const ret = wasm.molhandle_max_estate(this.__wbg_ptr);
561
+ return ret;
562
+ }
563
+ /**
564
+ * Minimum EState index across all heavy atoms.
565
+ * @returns {number}
566
+ */
567
+ min_estate() {
568
+ const ret = wasm.molhandle_min_estate(this.__wbg_ptr);
569
+ return ret;
570
+ }
571
+ /**
572
+ * Wildman–Crippen molar refractivity (MR).
573
+ * @returns {number}
574
+ */
575
+ molar_refractivity() {
576
+ const ret = wasm.molhandle_molar_refractivity(this.__wbg_ptr);
577
+ return ret;
578
+ }
579
+ /**
580
+ * Average molecular weight (Da).
581
+ * @returns {number}
582
+ */
583
+ molecular_weight() {
584
+ const ret = wasm.molhandle_molecular_weight(this.__wbg_ptr);
585
+ return ret;
586
+ }
587
+ /**
588
+ * Morgan count fingerprint as a JSON object string (`{"<hash>": count, …}`).
589
+ *
590
+ * `radius` controls the ECFP radius (2 = ECFP4-equivalent).
591
+ * @param {number} radius
592
+ * @returns {string}
593
+ */
594
+ morgan_fp_counts_json(radius) {
595
+ let deferred1_0;
596
+ let deferred1_1;
597
+ try {
598
+ const ret = wasm.molhandle_morgan_fp_counts_json(this.__wbg_ptr, radius);
599
+ deferred1_0 = ret[0];
600
+ deferred1_1 = ret[1];
601
+ return getStringFromWasm0(ret[0], ret[1]);
602
+ } finally {
603
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
604
+ }
605
+ }
606
+ /**
607
+ * Number of non-aromatic rings containing at least one heteroatom.
608
+ * @returns {number}
609
+ */
610
+ num_aliphatic_heterocycles() {
611
+ const ret = wasm.molhandle_num_aliphatic_heterocycles(this.__wbg_ptr);
612
+ return ret >>> 0;
613
+ }
614
+ /**
615
+ * Count of aliphatic (non-aromatic) rings in the SSSR.
616
+ * @returns {number}
617
+ */
618
+ num_aliphatic_rings() {
619
+ const ret = wasm.molhandle_num_aliphatic_rings(this.__wbg_ptr);
620
+ return ret >>> 0;
621
+ }
622
+ /**
623
+ * Number of aromatic rings containing at least one heteroatom (N, O, S, …).
624
+ * @returns {number}
625
+ */
626
+ num_aromatic_heterocycles() {
627
+ const ret = wasm.molhandle_num_aromatic_heterocycles(this.__wbg_ptr);
628
+ return ret >>> 0;
629
+ }
630
+ /**
631
+ * Number of bridgehead atoms (shared by ≥2 rings with ≥3 ring bonds).
632
+ * @returns {number}
633
+ */
634
+ num_bridgehead_atoms() {
635
+ const ret = wasm.molhandle_num_bridgehead_atoms(this.__wbg_ptr);
636
+ return ret >>> 0;
637
+ }
638
+ /**
639
+ * Number of heteroatoms (non-C, non-H heavy atoms).
640
+ * @returns {number}
641
+ */
642
+ num_heteroatoms() {
643
+ const ret = wasm.molhandle_num_heteroatoms(this.__wbg_ptr);
644
+ return ret >>> 0;
645
+ }
646
+ /**
647
+ * Number of fully saturated rings containing at least one heteroatom.
648
+ * @returns {number}
649
+ */
650
+ num_saturated_heterocycles() {
651
+ const ret = wasm.molhandle_num_saturated_heterocycles(this.__wbg_ptr);
652
+ return ret >>> 0;
653
+ }
654
+ /**
655
+ * Count of fully saturated rings in the SSSR.
656
+ * @returns {number}
657
+ */
658
+ num_saturated_rings() {
659
+ const ret = wasm.molhandle_num_saturated_rings(this.__wbg_ptr);
660
+ return ret >>> 0;
661
+ }
662
+ /**
663
+ * Number of spiro atoms (sole shared atom between exactly 2 rings).
664
+ * @returns {number}
665
+ */
666
+ num_spiro_atoms() {
667
+ const ret = wasm.molhandle_num_spiro_atoms(this.__wbg_ptr);
668
+ return ret >>> 0;
669
+ }
670
+ /**
671
+ * Number of assigned stereocenters (R/S).
672
+ * @returns {number}
673
+ */
674
+ num_stereocenters() {
675
+ const ret = wasm.molhandle_num_stereocenters(this.__wbg_ptr);
676
+ return ret >>> 0;
677
+ }
678
+ /**
679
+ * Count of tetrahedral stereocenters with unspecified configuration.
680
+ * @returns {number}
681
+ */
682
+ num_unspecified_stereocenters() {
683
+ const ret = wasm.molhandle_num_unspecified_stereocenters(this.__wbg_ptr);
684
+ return ret >>> 0;
685
+ }
686
+ /**
687
+ * Returns `true` if the molecule has no PAINS structural alerts.
688
+ * @returns {boolean}
689
+ */
690
+ pains_passes() {
691
+ const ret = wasm.molhandle_pains_passes(this.__wbg_ptr);
692
+ return ret !== 0;
693
+ }
694
+ /**
695
+ * Quantitative Estimate of Drug-likeness (QED); range [0, 1].
696
+ * @returns {number}
697
+ */
698
+ qed() {
699
+ const ret = wasm.molhandle_qed(this.__wbg_ptr);
700
+ return ret;
701
+ }
702
+ /**
703
+ * Returns `true` if the molecule passes the REOS (Rapid Elimination Of Swill) filter.
704
+ * @returns {boolean}
705
+ */
706
+ reos_passes() {
707
+ const ret = wasm.molhandle_reos_passes(this.__wbg_ptr);
708
+ return ret !== 0;
709
+ }
710
+ /**
711
+ * Total number of rings (SSSR count).
712
+ * @returns {number}
713
+ */
714
+ ring_count() {
715
+ const ret = wasm.molhandle_ring_count(this.__wbg_ptr);
716
+ return ret >>> 0;
717
+ }
718
+ /**
719
+ * Number of rotatable bonds.
720
+ * @returns {number}
721
+ */
722
+ rotatable_bond_count() {
723
+ const ret = wasm.molhandle_rotatable_bond_count(this.__wbg_ptr);
724
+ return ret >>> 0;
725
+ }
726
+ /**
727
+ * Sum of EState indices over all heavy atoms.
728
+ * @returns {number}
729
+ */
730
+ sum_estate() {
731
+ const ret = wasm.molhandle_sum_estate(this.__wbg_ptr);
732
+ return ret;
733
+ }
734
+ /**
735
+ * Topological polar surface area (Ų).
736
+ * @returns {number}
737
+ */
738
+ tpsa() {
739
+ const ret = wasm.molhandle_tpsa(this.__wbg_ptr);
740
+ return ret;
741
+ }
742
+ /**
743
+ * Returns `true` if the molecule passes Veber's oral bioavailability criteria
744
+ * (TPSA ≤ 140 Ų and rotatable bonds ≤ 10).
745
+ * @returns {boolean}
746
+ */
747
+ veber_passes() {
748
+ const ret = wasm.molhandle_veber_passes(this.__wbg_ptr);
749
+ return ret !== 0;
750
+ }
751
+ /**
752
+ * Wiener topological index (sum of all pairwise shortest-path distances).
753
+ * @returns {number}
754
+ */
755
+ wiener_index() {
756
+ const ret = wasm.molhandle_wiener_index(this.__wbg_ptr);
757
+ return ret;
758
+ }
759
+ }
760
+ if (Symbol.dispose) MolHandle.prototype[Symbol.dispose] = MolHandle.prototype.free;
761
+
762
+ /**
763
+ * Return a copy of the molecule with all implicit hydrogens converted to explicit H atoms.
764
+ * @param {MolHandle} mol
765
+ * @returns {MolHandle}
766
+ */
767
+ export function add_hydrogens(mol) {
768
+ _assertClass(mol, MolHandle);
769
+ const ret = wasm.add_hydrogens(mol.__wbg_ptr);
770
+ return MolHandle.__wrap(ret);
771
+ }
772
+
773
+ /**
774
+ * AtomPair fingerprint as a bit-packed byte vector (256 bytes = 2048 bits).
775
+ * @param {MolHandle} mol
776
+ * @returns {Uint8Array}
777
+ */
778
+ export function atom_pair_bitvec(mol) {
779
+ _assertClass(mol, MolHandle);
780
+ const ret = wasm.atom_pair_bitvec(mol.__wbg_ptr);
781
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
782
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
783
+ return v1;
784
+ }
785
+
786
+ /**
787
+ * Number of BRICS fragments produced by fragmenting the molecule.
788
+ *
789
+ * Returns 1 if no BRICS-breakable bonds exist (whole molecule is one fragment).
790
+ * @param {MolHandle} mol
791
+ * @returns {number}
792
+ */
793
+ export function brics_fragment_count(mol) {
794
+ _assertClass(mol, MolHandle);
795
+ const ret = wasm.brics_fragment_count(mol.__wbg_ptr);
796
+ return ret >>> 0;
797
+ }
798
+
799
+ /**
800
+ * BRICS fragment SMILES as a JSON array.
801
+ *
802
+ * Applies the BRICS fragmentation rules and returns the canonical SMILES of
803
+ * every resulting fragment. Returns `[]` for molecules with no BRICS-breakable
804
+ * bonds (e.g. benzene).
805
+ *
806
+ * The count of fragments equals `brics_fragment_count`.
807
+ * @param {MolHandle} mol
808
+ * @returns {string}
809
+ */
810
+ export function brics_fragments_json(mol) {
811
+ let deferred1_0;
812
+ let deferred1_1;
813
+ try {
814
+ _assertClass(mol, MolHandle);
815
+ const ret = wasm.brics_fragments_json(mol.__wbg_ptr);
816
+ deferred1_0 = ret[0];
817
+ deferred1_1 = ret[1];
818
+ return getStringFromWasm0(ret[0], ret[1]);
819
+ } finally {
820
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
821
+ }
822
+ }
823
+
824
+ /**
825
+ * Cluster molecules by structural similarity (Butina algorithm, ECFP4 Tanimoto).
826
+ *
827
+ * `smiles_json` — a JSON array of SMILES strings.
828
+ * `cutoff` — Tanimoto similarity threshold (0.0–1.0); molecules within this
829
+ * distance of a cluster centre are assigned to that cluster.
830
+ * Returns a JSON array of clusters, each cluster being an array of 0-based input indices.
831
+ * Returns a JS error if any SMILES fails to parse.
832
+ * @param {string} smiles_json
833
+ * @param {number} cutoff
834
+ * @returns {string}
835
+ */
836
+ export function butina_cluster_ecfp4_json(smiles_json, cutoff) {
837
+ let deferred3_0;
838
+ let deferred3_1;
839
+ try {
840
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
841
+ const len0 = WASM_VECTOR_LEN;
842
+ const ret = wasm.butina_cluster_ecfp4_json(ptr0, len0, cutoff);
843
+ var ptr2 = ret[0];
844
+ var len2 = ret[1];
845
+ if (ret[3]) {
846
+ ptr2 = 0; len2 = 0;
847
+ throw takeFromExternrefTable0(ret[2]);
848
+ }
849
+ deferred3_0 = ptr2;
850
+ deferred3_1 = len2;
851
+ return getStringFromWasm0(ptr2, len2);
852
+ } finally {
853
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
854
+ }
855
+ }
856
+
857
+ /**
858
+ * Canonical tautomer of `mol`.
859
+ *
860
+ * Applies a rule-based tautomer normalisation and returns the canonical form
861
+ * as a new `MolHandle`.
862
+ * @param {MolHandle} mol
863
+ * @returns {MolHandle}
864
+ */
865
+ export function canonical_tautomer(mol) {
866
+ _assertClass(mol, MolHandle);
867
+ const ret = wasm.canonical_tautomer(mol.__wbg_ptr);
868
+ return MolHandle.__wrap(ret);
869
+ }
870
+
871
+ /**
872
+ * CIP stereo assignments as a JSON array of `{atomIdx, cipCode}` objects.
873
+ *
874
+ * `cipCode` is one of `"R"`, `"S"`, `"E"`, or `"Z"`.
875
+ * Returns `[]` for molecules with no specified stereocenters.
876
+ * @param {MolHandle} mol
877
+ * @returns {string}
878
+ */
879
+ export function cip_assignments_json(mol) {
880
+ let deferred1_0;
881
+ let deferred1_1;
882
+ try {
883
+ _assertClass(mol, MolHandle);
884
+ const ret = wasm.cip_assignments_json(mol.__wbg_ptr);
885
+ deferred1_0 = ret[0];
886
+ deferred1_1 = ret[1];
887
+ return getStringFromWasm0(ret[0], ret[1]);
888
+ } finally {
889
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
890
+ }
891
+ }
892
+
893
+ /**
894
+ * Return the CPK color (CSS hex string) for the given element symbol.
895
+ *
896
+ * Returns `"#000000"` (black) for carbon and unknown elements.
897
+ * @param {string} element_symbol
898
+ * @returns {string}
899
+ */
900
+ export function cpk_color(element_symbol) {
901
+ let deferred2_0;
902
+ let deferred2_1;
903
+ try {
904
+ const ptr0 = passStringToWasm0(element_symbol, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
905
+ const len0 = WASM_VECTOR_LEN;
906
+ const ret = wasm.cpk_color(ptr0, len0);
907
+ deferred2_0 = ret[0];
908
+ deferred2_1 = ret[1];
909
+ return getStringFromWasm0(ret[0], ret[1]);
910
+ } finally {
911
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
912
+ }
913
+ }
914
+
915
+ /**
916
+ * Compute structured depiction data for `mol` as a JSON object.
917
+ *
918
+ * Returns:
919
+ * ```json
920
+ * {
921
+ * "atoms": [
922
+ * {"idx": 0, "element": "C", "x": 1.5, "y": 0.0, "charge": 0,
923
+ * "label": null, "color": "#000000"},
924
+ * ...
925
+ * ],
926
+ * "bonds": [
927
+ * {"idx": 0, "atom1": 0, "atom2": 1, "kind": "Single"},
928
+ * ...
929
+ * ]
930
+ * }
931
+ * ```
932
+ *
933
+ * `label` is `null` for carbon atoms in skeletal structures (label suppressed).
934
+ * `kind` is one of `"Single"`, `"Double"`, `"Triple"`, `"Aromatic"`, `"Up"`, `"Down"`.
935
+ * @param {MolHandle} mol
936
+ * @returns {string}
937
+ */
938
+ export function depict_data_json(mol) {
939
+ let deferred1_0;
940
+ let deferred1_1;
941
+ try {
942
+ _assertClass(mol, MolHandle);
943
+ const ret = wasm.depict_data_json(mol.__wbg_ptr);
944
+ deferred1_0 = ret[0];
945
+ deferred1_1 = ret[1];
946
+ return getStringFromWasm0(ret[0], ret[1]);
947
+ } finally {
948
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
949
+ }
950
+ }
951
+
952
+ /**
953
+ * Render a reaction SMILES string (e.g. `"CC(=O)O.CCO>>CC(=O)OCC.O"`) as a
954
+ * single SVG showing reactants → products with `+` separators.
955
+ *
956
+ * Returns a self-contained SVG string. Returns a JS error on invalid input.
957
+ * @param {string} rxn_smiles
958
+ * @returns {string}
959
+ */
960
+ export function depict_reaction_svg(rxn_smiles) {
961
+ let deferred3_0;
962
+ let deferred3_1;
963
+ try {
964
+ const ptr0 = passStringToWasm0(rxn_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
965
+ const len0 = WASM_VECTOR_LEN;
966
+ const ret = wasm.depict_reaction_svg(ptr0, len0);
967
+ var ptr2 = ret[0];
968
+ var len2 = ret[1];
969
+ if (ret[3]) {
970
+ ptr2 = 0; len2 = 0;
971
+ throw takeFromExternrefTable0(ret[2]);
972
+ }
973
+ deferred3_0 = ptr2;
974
+ deferred3_1 = len2;
975
+ return getStringFromWasm0(ptr2, len2);
976
+ } finally {
977
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
978
+ }
979
+ }
980
+
981
+ /**
982
+ * Render a grid SVG from newline-separated SMILES (one per line).
983
+ *
984
+ * Lines that fail to parse are silently skipped.
985
+ * `cols` controls the number of columns (each cell is 200×200 px).
986
+ * @param {string} smiles_block
987
+ * @param {number} cols
988
+ * @returns {string}
989
+ */
990
+ export function depict_svg_grid(smiles_block, cols) {
991
+ let deferred2_0;
992
+ let deferred2_1;
993
+ try {
994
+ const ptr0 = passStringToWasm0(smiles_block, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
995
+ const len0 = WASM_VECTOR_LEN;
996
+ const ret = wasm.depict_svg_grid(ptr0, len0, cols);
997
+ deferred2_0 = ret[0];
998
+ deferred2_1 = ret[1];
999
+ return getStringFromWasm0(ret[0], ret[1]);
1000
+ } finally {
1001
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1002
+ }
1003
+ }
1004
+
1005
+ /**
1006
+ * Render a molecule grid with SMARTS-based atom highlighting.
1007
+ *
1008
+ * `smiles_block` — newline-separated SMILES strings (same format as `depict_svg_grid`).
1009
+ * `cols` — number of grid columns.
1010
+ * `match_smarts` — SMARTS pattern; matched atoms in each molecule are highlighted.
1011
+ * Pass an empty string `""` to render without any highlighting.
1012
+ *
1013
+ * Invalid SMILES are rendered as empty cells; SMARTS parse failure returns an
1014
+ * unhighlighted grid (the SMARTS is silently ignored).
1015
+ * @param {string} smiles_block
1016
+ * @param {number} cols
1017
+ * @param {string} match_smarts
1018
+ * @returns {string}
1019
+ */
1020
+ export function depict_svg_grid_highlighted(smiles_block, cols, match_smarts) {
1021
+ let deferred3_0;
1022
+ let deferred3_1;
1023
+ try {
1024
+ const ptr0 = passStringToWasm0(smiles_block, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1025
+ const len0 = WASM_VECTOR_LEN;
1026
+ const ptr1 = passStringToWasm0(match_smarts, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1027
+ const len1 = WASM_VECTOR_LEN;
1028
+ const ret = wasm.depict_svg_grid_highlighted(ptr0, len0, cols, ptr1, len1);
1029
+ deferred3_0 = ret[0];
1030
+ deferred3_1 = ret[1];
1031
+ return getStringFromWasm0(ret[0], ret[1]);
1032
+ } finally {
1033
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1034
+ }
1035
+ }
1036
+
1037
+ /**
1038
+ * Detect named functional groups in `mol`.
1039
+ *
1040
+ * Returns a JSON array of `{"name":"hydroxyl","atoms":[3]}` objects.
1041
+ * Multiple matches of the same group (e.g. two hydroxyl groups) each appear
1042
+ * as a separate entry. Overlapping groups (carboxylic acid → "carboxyl" +
1043
+ * "hydroxyl" + "carbonyl") are all returned.
1044
+ * @param {MolHandle} mol
1045
+ * @returns {string}
1046
+ */
1047
+ export function detect_functional_groups(mol) {
1048
+ let deferred1_0;
1049
+ let deferred1_1;
1050
+ try {
1051
+ _assertClass(mol, MolHandle);
1052
+ const ret = wasm.detect_functional_groups(mol.__wbg_ptr);
1053
+ deferred1_0 = ret[0];
1054
+ deferred1_1 = ret[1];
1055
+ return getStringFromWasm0(ret[0], ret[1]);
1056
+ } finally {
1057
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1058
+ }
1059
+ }
1060
+
1061
+ /**
1062
+ * Dice similarity between `a` and `b` using ECFP4 fingerprints.
1063
+ * @param {MolHandle} a
1064
+ * @param {MolHandle} b
1065
+ * @returns {number}
1066
+ */
1067
+ export function dice_ecfp4(a, b) {
1068
+ _assertClass(a, MolHandle);
1069
+ _assertClass(b, MolHandle);
1070
+ const ret = wasm.dice_ecfp4(a.__wbg_ptr, b.__wbg_ptr);
1071
+ return ret;
1072
+ }
1073
+
1074
+ /**
1075
+ * Dice similarity between `a` and `b` using ECFP6 fingerprints.
1076
+ * @param {MolHandle} a
1077
+ * @param {MolHandle} b
1078
+ * @returns {number}
1079
+ */
1080
+ export function dice_ecfp6(a, b) {
1081
+ _assertClass(a, MolHandle);
1082
+ _assertClass(b, MolHandle);
1083
+ const ret = wasm.dice_ecfp6(a.__wbg_ptr, b.__wbg_ptr);
1084
+ return ret;
1085
+ }
1086
+
1087
+ /**
1088
+ * Dice similarity between `a` and `b` using MACCS 166-bit fingerprints.
1089
+ * @param {MolHandle} a
1090
+ * @param {MolHandle} b
1091
+ * @returns {number}
1092
+ */
1093
+ export function dice_maccs(a, b) {
1094
+ _assertClass(a, MolHandle);
1095
+ _assertClass(b, MolHandle);
1096
+ const ret = wasm.dice_maccs(a.__wbg_ptr, b.__wbg_ptr);
1097
+ return ret;
1098
+ }
1099
+
1100
+ /**
1101
+ * Compute the ECFP4 fingerprint as a bit-packed byte vector (256 bytes = 2048 bits).
1102
+ * @param {MolHandle} mol
1103
+ * @returns {Uint8Array}
1104
+ */
1105
+ export function ecfp4_bitvec(mol) {
1106
+ _assertClass(mol, MolHandle);
1107
+ const ret = wasm.ecfp4_bitvec(mol.__wbg_ptr);
1108
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1109
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1110
+ return v1;
1111
+ }
1112
+
1113
+ /**
1114
+ * ECFP6 (radius-3) fingerprint as a bit-packed byte vector (256 bytes = 2048 bits).
1115
+ * @param {MolHandle} mol
1116
+ * @returns {Uint8Array}
1117
+ */
1118
+ export function ecfp6_bitvec(mol) {
1119
+ _assertClass(mol, MolHandle);
1120
+ const ret = wasm.ecfp6_bitvec(mol.__wbg_ptr);
1121
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1122
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1123
+ return v1;
1124
+ }
1125
+
1126
+ /**
1127
+ * Compute a fingerprint bit-vector with configurable ECFP radius and bit width.
1128
+ *
1129
+ * `radius` — Morgan radius (1 = ECFP2, 2 = ECFP4, 3 = ECFP6).
1130
+ * `nbits` — bit width; must be one of 256, 512, 1024, or 2048.
1131
+ * Returns a `Uint8Array` of `nbits/8` bytes.
1132
+ *
1133
+ * The hash modulo is applied at fingerprint-generation time (`id % nbits`),
1134
+ * so no post-processing fold is needed.
1135
+ * @param {MolHandle} mol
1136
+ * @param {number} radius
1137
+ * @param {number} nbits
1138
+ * @returns {Uint8Array}
1139
+ */
1140
+ export function ecfp_bitvec_custom(mol, radius, nbits) {
1141
+ _assertClass(mol, MolHandle);
1142
+ const ret = wasm.ecfp_bitvec_custom(mol.__wbg_ptr, radius, nbits);
1143
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1144
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1145
+ return v1;
1146
+ }
1147
+
1148
+ /**
1149
+ * Enumerate all stereoisomers arising from unspecified tetrahedral stereocenters.
1150
+ *
1151
+ * Only considers carbon stereocenters without explicit `@`/`@@` annotation.
1152
+ * Already-specified centers and E/Z double-bond geometry are unchanged.
1153
+ * Returns a JSON array of canonical SMILES strings.
1154
+ *
1155
+ * At most 2^6 = 64 combinations are enumerated; if more than 6 unspecified
1156
+ * centers are present this function returns a JS error to avoid combinatorial
1157
+ * explosion.
1158
+ * @param {MolHandle} mol
1159
+ * @returns {string}
1160
+ */
1161
+ export function enumerate_stereo_isomers_json(mol) {
1162
+ let deferred2_0;
1163
+ let deferred2_1;
1164
+ try {
1165
+ _assertClass(mol, MolHandle);
1166
+ const ret = wasm.enumerate_stereo_isomers_json(mol.__wbg_ptr);
1167
+ var ptr1 = ret[0];
1168
+ var len1 = ret[1];
1169
+ if (ret[3]) {
1170
+ ptr1 = 0; len1 = 0;
1171
+ throw takeFromExternrefTable0(ret[2]);
1172
+ }
1173
+ deferred2_0 = ptr1;
1174
+ deferred2_1 = len1;
1175
+ return getStringFromWasm0(ptr1, len1);
1176
+ } finally {
1177
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1178
+ }
1179
+ }
1180
+
1181
+ /**
1182
+ * All enumerated tautomers of `mol` as a JSON array of canonical SMILES strings.
1183
+ *
1184
+ * Example return value: `["Oc1cccc2ccccc12","O=C1C=CC=Cc2ccccc21"]`
1185
+ * @param {MolHandle} mol
1186
+ * @returns {string}
1187
+ */
1188
+ export function enumerate_tautomers_json(mol) {
1189
+ let deferred1_0;
1190
+ let deferred1_1;
1191
+ try {
1192
+ _assertClass(mol, MolHandle);
1193
+ const ret = wasm.enumerate_tautomers_json(mol.__wbg_ptr);
1194
+ deferred1_0 = ret[0];
1195
+ deferred1_1 = ret[1];
1196
+ return getStringFromWasm0(ret[0], ret[1]);
1197
+ } finally {
1198
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1199
+ }
1200
+ }
1201
+
1202
+ /**
1203
+ * Per-atom EState values as a JSON array of f64.
1204
+ *
1205
+ * Indices match `mol.atoms()` order. Hydrogen atoms get 0.0.
1206
+ * @param {MolHandle} mol
1207
+ * @returns {string}
1208
+ */
1209
+ export function estate_indices_json(mol) {
1210
+ let deferred1_0;
1211
+ let deferred1_1;
1212
+ try {
1213
+ _assertClass(mol, MolHandle);
1214
+ const ret = wasm.estate_indices_json(mol.__wbg_ptr);
1215
+ deferred1_0 = ret[0];
1216
+ deferred1_1 = ret[1];
1217
+ return getStringFromWasm0(ret[0], ret[1]);
1218
+ } finally {
1219
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1220
+ }
1221
+ }
1222
+
1223
+ /**
1224
+ * FCFP4 (pharmacophore, radius-2) fingerprint as a bit-packed byte vector (256 bytes).
1225
+ * @param {MolHandle} mol
1226
+ * @returns {Uint8Array}
1227
+ */
1228
+ export function fcfp4_bitvec(mol) {
1229
+ _assertClass(mol, MolHandle);
1230
+ const ret = wasm.fcfp4_bitvec(mol.__wbg_ptr);
1231
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1232
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1233
+ return v1;
1234
+ }
1235
+
1236
+ /**
1237
+ * FCFP6 (pharmacophore, radius-3) fingerprint as a bit-packed byte vector (256 bytes).
1238
+ * @param {MolHandle} mol
1239
+ * @returns {Uint8Array}
1240
+ */
1241
+ export function fcfp6_bitvec(mol) {
1242
+ _assertClass(mol, MolHandle);
1243
+ const ret = wasm.fcfp6_bitvec(mol.__wbg_ptr);
1244
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1245
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1246
+ return v1;
1247
+ }
1248
+
1249
+ /**
1250
+ * Gasteiger-Marsili PEOE partial charges as a JSON array of f64.
1251
+ * @param {MolHandle} mol
1252
+ * @returns {string}
1253
+ */
1254
+ export function gasteiger_charges_json(mol) {
1255
+ let deferred1_0;
1256
+ let deferred1_1;
1257
+ try {
1258
+ _assertClass(mol, MolHandle);
1259
+ const ret = wasm.gasteiger_charges_json(mol.__wbg_ptr);
1260
+ deferred1_0 = ret[0];
1261
+ deferred1_1 = ret[1];
1262
+ return getStringFromWasm0(ret[0], ret[1]);
1263
+ } finally {
1264
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1265
+ }
1266
+ }
1267
+
1268
+ /**
1269
+ * Generate energy-minimized 3D coordinates and return a PDB string.
1270
+ *
1271
+ * Runs distance-geometry placement followed by gradient-descent force-field
1272
+ * minimization. Geometry quality is better than `generate_3d_pdb` for
1273
+ * flexible molecules; the force field is approximate (not MMFF94/UFF).
1274
+ * @param {MolHandle} mol
1275
+ * @returns {string}
1276
+ */
1277
+ export function generate_3d_minimized_pdb(mol) {
1278
+ let deferred1_0;
1279
+ let deferred1_1;
1280
+ try {
1281
+ _assertClass(mol, MolHandle);
1282
+ const ret = wasm.generate_3d_minimized_pdb(mol.__wbg_ptr);
1283
+ deferred1_0 = ret[0];
1284
+ deferred1_1 = ret[1];
1285
+ return getStringFromWasm0(ret[0], ret[1]);
1286
+ } finally {
1287
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1288
+ }
1289
+ }
1290
+
1291
+ /**
1292
+ * Generate 3D coordinates for the molecule and return a PDB string.
1293
+ *
1294
+ * Coordinates are generated using distance-geometry placement with ring templates.
1295
+ * Returns heavy-atom PDB (HETATM records, no explicit H).
1296
+ * @param {MolHandle} mol
1297
+ * @returns {string}
1298
+ */
1299
+ export function generate_3d_pdb(mol) {
1300
+ let deferred1_0;
1301
+ let deferred1_1;
1302
+ try {
1303
+ _assertClass(mol, MolHandle);
1304
+ const ret = wasm.generate_3d_pdb(mol.__wbg_ptr);
1305
+ deferred1_0 = ret[0];
1306
+ deferred1_1 = ret[1];
1307
+ return getStringFromWasm0(ret[0], ret[1]);
1308
+ } finally {
1309
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1310
+ }
1311
+ }
1312
+
1313
+ /**
1314
+ * Generic (atom-type-erased) Murcko scaffold of `mol`.
1315
+ *
1316
+ * All atoms become carbon and all bonds become single bonds, giving the pure
1317
+ * graph topology of the scaffold.
1318
+ * @param {MolHandle} mol
1319
+ * @returns {MolHandle}
1320
+ */
1321
+ export function generic_murcko_scaffold(mol) {
1322
+ _assertClass(mol, MolHandle);
1323
+ const ret = wasm.generic_murcko_scaffold(mol.__wbg_ptr);
1324
+ return MolHandle.__wrap(ret);
1325
+ }
1326
+
1327
+ /**
1328
+ * Return information about a single atom as a JSON object.
1329
+ *
1330
+ * `idx` is the 0-based atom index (matching `atoms()` order).
1331
+ * Returns `"null"` if `idx` is out of range.
1332
+ *
1333
+ * Fields: `element` (symbol), `hybridization` ("sp"/"sp2"/"sp3"),
1334
+ * `charge` (formal charge integer), `isAromatic` (bool),
1335
+ * `totalHydrogens` (explicit + implicit H count, integer).
1336
+ * sp3d/sp3d2 (hypervalent P/S) are not distinguished from sp3/sp2.
1337
+ * @param {MolHandle} mol
1338
+ * @param {number} idx
1339
+ * @returns {string}
1340
+ */
1341
+ export function get_atom_info(mol, idx) {
1342
+ let deferred1_0;
1343
+ let deferred1_1;
1344
+ try {
1345
+ _assertClass(mol, MolHandle);
1346
+ const ret = wasm.get_atom_info(mol.__wbg_ptr, idx);
1347
+ deferred1_0 = ret[0];
1348
+ deferred1_1 = ret[1];
1349
+ return getStringFromWasm0(ret[0], ret[1]);
1350
+ } finally {
1351
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1352
+ }
1353
+ }
1354
+
1355
+ /**
1356
+ * Return bond information as a JSON object, looked up by the two bonded atom indices.
1357
+ *
1358
+ * Useful when you know the atom indices from SMARTS matching or `data-atom-idx` SVG
1359
+ * attributes but not the bond index. Returns `"null"` if no bond exists between them.
1360
+ *
1361
+ * Fields: same as `get_bond_info` plus `bondIdx` (u32).
1362
+ * @param {MolHandle} mol
1363
+ * @param {number} atom1
1364
+ * @param {number} atom2
1365
+ * @returns {string}
1366
+ */
1367
+ export function get_bond_between(mol, atom1, atom2) {
1368
+ let deferred1_0;
1369
+ let deferred1_1;
1370
+ try {
1371
+ _assertClass(mol, MolHandle);
1372
+ const ret = wasm.get_bond_between(mol.__wbg_ptr, atom1, atom2);
1373
+ deferred1_0 = ret[0];
1374
+ deferred1_1 = ret[1];
1375
+ return getStringFromWasm0(ret[0], ret[1]);
1376
+ } finally {
1377
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1378
+ }
1379
+ }
1380
+
1381
+ /**
1382
+ * Return bond information as a JSON object, looked up by bond index.
1383
+ *
1384
+ * `idx` is the 0-based bond index (order matches `mol.bonds()` iteration).
1385
+ * Returns `"null"` if `idx` is out of range.
1386
+ *
1387
+ * Fields: `bondOrder` (1.0/1.5/2.0/3.0), `isAromatic` (bool),
1388
+ * `isInRing` (bool), `atomFrom` (u32), `atomTo` (u32).
1389
+ * @param {MolHandle} mol
1390
+ * @param {number} idx
1391
+ * @returns {string}
1392
+ */
1393
+ export function get_bond_info(mol, idx) {
1394
+ let deferred1_0;
1395
+ let deferred1_1;
1396
+ try {
1397
+ _assertClass(mol, MolHandle);
1398
+ const ret = wasm.get_bond_info(mol.__wbg_ptr, idx);
1399
+ deferred1_0 = ret[0];
1400
+ deferred1_1 = ret[1];
1401
+ return getStringFromWasm0(ret[0], ret[1]);
1402
+ } finally {
1403
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1404
+ }
1405
+ }
1406
+
1407
+ /**
1408
+ * All scalar molecular descriptors as a single JSON object.
1409
+ *
1410
+ * Keys use camelCase and match the individual `MolHandle` method names.
1411
+ * Drug-likeness rule outcomes are included as boolean fields.
1412
+ * @param {MolHandle} mol
1413
+ * @returns {string}
1414
+ */
1415
+ export function get_descriptors_json(mol) {
1416
+ let deferred1_0;
1417
+ let deferred1_1;
1418
+ try {
1419
+ _assertClass(mol, MolHandle);
1420
+ const ret = wasm.get_descriptors_json(mol.__wbg_ptr);
1421
+ deferred1_0 = ret[0];
1422
+ deferred1_1 = ret[1];
1423
+ return getStringFromWasm0(ret[0], ret[1]);
1424
+ } finally {
1425
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1426
+ }
1427
+ }
1428
+
1429
+ /**
1430
+ * Identify functional groups. Returns a JSON array of objects:
1431
+ * `[{"atoms":[0,2,3],"type":"C,N,O"}, …]`
1432
+ * @param {MolHandle} mol
1433
+ * @returns {string}
1434
+ */
1435
+ export function identify_functional_groups(mol) {
1436
+ let deferred1_0;
1437
+ let deferred1_1;
1438
+ try {
1439
+ _assertClass(mol, MolHandle);
1440
+ const ret = wasm.identify_functional_groups(mol.__wbg_ptr);
1441
+ deferred1_0 = ret[0];
1442
+ deferred1_1 = ret[1];
1443
+ return getStringFromWasm0(ret[0], ret[1]);
1444
+ } finally {
1445
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1446
+ }
1447
+ }
1448
+
1449
+ /**
1450
+ * Returns `true` if the SMILES string can be parsed without error.
1451
+ * @param {string} s
1452
+ * @returns {boolean}
1453
+ */
1454
+ export function is_valid_smiles(s) {
1455
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1456
+ const len0 = WASM_VECTOR_LEN;
1457
+ const ret = wasm.is_valid_smiles(ptr0, len0);
1458
+ return ret !== 0;
1459
+ }
1460
+
1461
+ /**
1462
+ * Per-atom Labute approximate surface area contributions as a JSON array of f64.
1463
+ *
1464
+ * Non-finite values (single-atom molecules etc.) are emitted as JSON `null`.
1465
+ * @param {MolHandle} mol
1466
+ * @returns {string}
1467
+ */
1468
+ export function labute_asa_per_atom_json(mol) {
1469
+ let deferred1_0;
1470
+ let deferred1_1;
1471
+ try {
1472
+ _assertClass(mol, MolHandle);
1473
+ const ret = wasm.labute_asa_per_atom_json(mol.__wbg_ptr);
1474
+ deferred1_0 = ret[0];
1475
+ deferred1_1 = ret[1];
1476
+ return getStringFromWasm0(ret[0], ret[1]);
1477
+ } finally {
1478
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1479
+ }
1480
+ }
1481
+
1482
+ /**
1483
+ * Return the largest fragment of `mol` (salt/solvent stripping).
1484
+ *
1485
+ * For single-component molecules returns a copy of the same molecule.
1486
+ * @param {MolHandle} mol
1487
+ * @returns {MolHandle}
1488
+ */
1489
+ export function largest_fragment(mol) {
1490
+ _assertClass(mol, MolHandle);
1491
+ const ret = wasm.largest_fragment(mol.__wbg_ptr);
1492
+ return MolHandle.__wrap(ret);
1493
+ }
1494
+
1495
+ /**
1496
+ * Per-atom Crippen LogP contributions as a JSON array of f64.
1497
+ *
1498
+ * Index `i` corresponds to atom `i` in `mol.atoms()` order.
1499
+ * @param {MolHandle} mol
1500
+ * @returns {string}
1501
+ */
1502
+ export function logp_per_atom_json(mol) {
1503
+ let deferred1_0;
1504
+ let deferred1_1;
1505
+ try {
1506
+ _assertClass(mol, MolHandle);
1507
+ const ret = wasm.logp_per_atom_json(mol.__wbg_ptr);
1508
+ deferred1_0 = ret[0];
1509
+ deferred1_1 = ret[1];
1510
+ return getStringFromWasm0(ret[0], ret[1]);
1511
+ } finally {
1512
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1513
+ }
1514
+ }
1515
+
1516
+ /**
1517
+ * MACCS 166-bit structural keys fingerprint as a byte array (21 bytes, LSB-first).
1518
+ *
1519
+ * Bit `i` (0-indexed) corresponds to MACCS key `i+1`.
1520
+ * @param {MolHandle} mol
1521
+ * @returns {Uint8Array}
1522
+ */
1523
+ export function maccs_bitvec(mol) {
1524
+ _assertClass(mol, MolHandle);
1525
+ const ret = wasm.maccs_bitvec(mol.__wbg_ptr);
1526
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1527
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1528
+ return v1;
1529
+ }
1530
+
1531
+ /**
1532
+ * Find all SMARTS matches in a molecule given only SMILES strings.
1533
+ *
1534
+ * Convenience wrapper around `smarts_match_atoms` that accepts raw SMILES
1535
+ * instead of a `MolHandle`. Returns the same JSON format: `[[0,1],[3,4]]`.
1536
+ * Returns a JS error on SMILES or SMARTS parse failure.
1537
+ * @param {string} smiles
1538
+ * @param {string} smarts
1539
+ * @returns {string}
1540
+ */
1541
+ export function match_smarts_smiles(smiles, smarts) {
1542
+ let deferred4_0;
1543
+ let deferred4_1;
1544
+ try {
1545
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1546
+ const len0 = WASM_VECTOR_LEN;
1547
+ const ptr1 = passStringToWasm0(smarts, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1548
+ const len1 = WASM_VECTOR_LEN;
1549
+ const ret = wasm.match_smarts_smiles(ptr0, len0, ptr1, len1);
1550
+ var ptr3 = ret[0];
1551
+ var len3 = ret[1];
1552
+ if (ret[3]) {
1553
+ ptr3 = 0; len3 = 0;
1554
+ throw takeFromExternrefTable0(ret[2]);
1555
+ }
1556
+ deferred4_0 = ptr3;
1557
+ deferred4_1 = len3;
1558
+ return getStringFromWasm0(ptr3, len3);
1559
+ } finally {
1560
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1561
+ }
1562
+ }
1563
+
1564
+ /**
1565
+ * Select `n` maximally-diverse molecules (MaxMin algorithm, ECFP4 Tanimoto).
1566
+ *
1567
+ * `smiles_json` — a JSON array of SMILES strings, e.g. `["CC","c1ccccc1","CCO"]`.
1568
+ * Returns a JSON array of 0-based indices into the input array.
1569
+ * Returns a JS error if any SMILES fails to parse (indices would otherwise shift).
1570
+ * @param {string} smiles_json
1571
+ * @param {number} n
1572
+ * @returns {string}
1573
+ */
1574
+ export function maxmin_picks_ecfp4_json(smiles_json, n) {
1575
+ let deferred3_0;
1576
+ let deferred3_1;
1577
+ try {
1578
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1579
+ const len0 = WASM_VECTOR_LEN;
1580
+ const ret = wasm.maxmin_picks_ecfp4_json(ptr0, len0, n);
1581
+ var ptr2 = ret[0];
1582
+ var len2 = ret[1];
1583
+ if (ret[3]) {
1584
+ ptr2 = 0; len2 = 0;
1585
+ throw takeFromExternrefTable0(ret[2]);
1586
+ }
1587
+ deferred3_0 = ptr2;
1588
+ deferred3_1 = len2;
1589
+ return getStringFromWasm0(ptr2, len2);
1590
+ } finally {
1591
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1592
+ }
1593
+ }
1594
+
1595
+ /**
1596
+ * Maximum Common Substructure of a set of molecules, returned as a canonical SMILES string.
1597
+ *
1598
+ * `smiles_json` — a JSON array of at least 2 SMILES strings.
1599
+ * Returns the MCS SMILES, or `"null"` when no common substructure was found.
1600
+ * Returns a JS error on SMILES parse failure.
1601
+ * @param {string} smiles_json
1602
+ * @returns {string}
1603
+ */
1604
+ export function mcs_smiles_json(smiles_json) {
1605
+ let deferred3_0;
1606
+ let deferred3_1;
1607
+ try {
1608
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1609
+ const len0 = WASM_VECTOR_LEN;
1610
+ const ret = wasm.mcs_smiles_json(ptr0, len0);
1611
+ var ptr2 = ret[0];
1612
+ var len2 = ret[1];
1613
+ if (ret[3]) {
1614
+ ptr2 = 0; len2 = 0;
1615
+ throw takeFromExternrefTable0(ret[2]);
1616
+ }
1617
+ deferred3_0 = ptr2;
1618
+ deferred3_1 = len2;
1619
+ return getStringFromWasm0(ptr2, len2);
1620
+ } finally {
1621
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1622
+ }
1623
+ }
1624
+
1625
+ /**
1626
+ * Find matched molecular pairs in a set of molecules as JSON.
1627
+ *
1628
+ * `smiles_json` — JSON array of SMILES strings to analyze.
1629
+ *
1630
+ * Returns a JSON array of matched pairs:
1631
+ * ```json
1632
+ * [
1633
+ * {
1634
+ * "mol_a": "CC(=O)Oc1ccccc1",
1635
+ * "mol_b": "CC(=O)Nc1ccccc1",
1636
+ * "core": "c1ccccc1[*]",
1637
+ * "fragment_a": "[*]OC(C)=O",
1638
+ * "fragment_b": "[*]NC(C)=O"
1639
+ * }
1640
+ * ]
1641
+ * ```
1642
+ *
1643
+ * Each pair represents molecules that share a common core scaffold but differ
1644
+ * by exactly one structural fragment at a single BRICS-breakable bond cut.
1645
+ *
1646
+ * Returns a JS error if any SMILES fails to parse.
1647
+ * @param {string} smiles_json
1648
+ * @returns {string}
1649
+ */
1650
+ export function mmp_pairs_json(smiles_json) {
1651
+ let deferred3_0;
1652
+ let deferred3_1;
1653
+ try {
1654
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1655
+ const len0 = WASM_VECTOR_LEN;
1656
+ const ret = wasm.mmp_pairs_json(ptr0, len0);
1657
+ var ptr2 = ret[0];
1658
+ var len2 = ret[1];
1659
+ if (ret[3]) {
1660
+ ptr2 = 0; len2 = 0;
1661
+ throw takeFromExternrefTable0(ret[2]);
1662
+ }
1663
+ deferred3_0 = ptr2;
1664
+ deferred3_1 = len2;
1665
+ return getStringFromWasm0(ptr2, len2);
1666
+ } finally {
1667
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1668
+ }
1669
+ }
1670
+
1671
+ /**
1672
+ * Serialize a SMILES string directly to a MOL V2000 block with 2D coordinates.
1673
+ *
1674
+ * Returns a JS error on SMILES parse failure.
1675
+ * @param {string} smiles
1676
+ * @returns {string}
1677
+ */
1678
+ export function mol_block_from_smiles(smiles) {
1679
+ let deferred3_0;
1680
+ let deferred3_1;
1681
+ try {
1682
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1683
+ const len0 = WASM_VECTOR_LEN;
1684
+ const ret = wasm.mol_block_from_smiles(ptr0, len0);
1685
+ var ptr2 = ret[0];
1686
+ var len2 = ret[1];
1687
+ if (ret[3]) {
1688
+ ptr2 = 0; len2 = 0;
1689
+ throw takeFromExternrefTable0(ret[2]);
1690
+ }
1691
+ deferred3_0 = ptr2;
1692
+ deferred3_1 = len2;
1693
+ return getStringFromWasm0(ptr2, len2);
1694
+ } finally {
1695
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1696
+ }
1697
+ }
1698
+
1699
+ /**
1700
+ * Parse a ChemDraw XML (CDXML) string into a `MolHandle`.
1701
+ *
1702
+ * Only the first molecular fragment in the document is returned.
1703
+ * Returns a JS error if the document cannot be parsed.
1704
+ * @param {string} cdxml
1705
+ * @returns {MolHandle}
1706
+ */
1707
+ export function mol_from_cdxml(cdxml) {
1708
+ const ptr0 = passStringToWasm0(cdxml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1709
+ const len0 = WASM_VECTOR_LEN;
1710
+ const ret = wasm.mol_from_cdxml(ptr0, len0);
1711
+ if (ret[2]) {
1712
+ throw takeFromExternrefTable0(ret[1]);
1713
+ }
1714
+ return MolHandle.__wrap(ret[0]);
1715
+ }
1716
+
1717
+ /**
1718
+ * Parse a CML string into a `MolHandle`.
1719
+ *
1720
+ * Returns a JS error if the CML is invalid (unknown element, bad bond, etc.).
1721
+ * @param {string} cml
1722
+ * @returns {MolHandle}
1723
+ */
1724
+ export function mol_from_cml(cml) {
1725
+ const ptr0 = passStringToWasm0(cml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1726
+ const len0 = WASM_VECTOR_LEN;
1727
+ const ret = wasm.mol_from_cml(ptr0, len0);
1728
+ if (ret[2]) {
1729
+ throw takeFromExternrefTable0(ret[1]);
1730
+ }
1731
+ return MolHandle.__wrap(ret[0]);
1732
+ }
1733
+
1734
+ /**
1735
+ * Parse a PDB file and return a `MolHandle` (topology only; coordinates are discarded).
1736
+ *
1737
+ * Uses CONECT records for connectivity if present; otherwise infers bonds from
1738
+ * atom distances (the same heuristic as the internal `pdb_to_molecule` function).
1739
+ * @param {string} pdb
1740
+ * @returns {MolHandle}
1741
+ */
1742
+ export function mol_from_pdb(pdb) {
1743
+ const ptr0 = passStringToWasm0(pdb, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1744
+ const len0 = WASM_VECTOR_LEN;
1745
+ const ret = wasm.mol_from_pdb(ptr0, len0);
1746
+ return MolHandle.__wrap(ret);
1747
+ }
1748
+
1749
+ /**
1750
+ * Parse a MOL V2000 block and return a `MolHandle`.
1751
+ *
1752
+ * Returns a JS error string on parse failure.
1753
+ * @param {string} block
1754
+ * @returns {MolHandle}
1755
+ */
1756
+ export function mol_from_sdf_block(block) {
1757
+ const ptr0 = passStringToWasm0(block, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1758
+ const len0 = WASM_VECTOR_LEN;
1759
+ const ret = wasm.mol_from_sdf_block(ptr0, len0);
1760
+ if (ret[2]) {
1761
+ throw takeFromExternrefTable0(ret[1]);
1762
+ }
1763
+ return MolHandle.__wrap(ret[0]);
1764
+ }
1765
+
1766
+ /**
1767
+ * Parse a MOL V3000 block and return a `MolHandle`.
1768
+ *
1769
+ * Returns a JS error string on parse failure.
1770
+ * @param {string} block
1771
+ * @returns {MolHandle}
1772
+ */
1773
+ export function mol_from_v3000_block(block) {
1774
+ const ptr0 = passStringToWasm0(block, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1775
+ const len0 = WASM_VECTOR_LEN;
1776
+ const ret = wasm.mol_from_v3000_block(ptr0, len0);
1777
+ if (ret[2]) {
1778
+ throw takeFromExternrefTable0(ret[1]);
1779
+ }
1780
+ return MolHandle.__wrap(ret[0]);
1781
+ }
1782
+
1783
+ /**
1784
+ * Parse an XYZ file and return a `MolHandle` (topology only; coordinates are discarded).
1785
+ *
1786
+ * Returns a JS error on parse failure.
1787
+ * @param {string} xyz
1788
+ * @returns {MolHandle}
1789
+ */
1790
+ export function mol_from_xyz(xyz) {
1791
+ const ptr0 = passStringToWasm0(xyz, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1792
+ const len0 = WASM_VECTOR_LEN;
1793
+ const ret = wasm.mol_from_xyz(ptr0, len0);
1794
+ if (ret[2]) {
1795
+ throw takeFromExternrefTable0(ret[1]);
1796
+ }
1797
+ return MolHandle.__wrap(ret[0]);
1798
+ }
1799
+
1800
+ /**
1801
+ * Return the index that would be assigned to an atom appended to `mol`.
1802
+ * @param {MolHandle} mol
1803
+ * @returns {number}
1804
+ */
1805
+ export function mol_next_atom_idx(mol) {
1806
+ _assertClass(mol, MolHandle);
1807
+ const ret = wasm.mol_next_atom_idx(mol.__wbg_ptr);
1808
+ return ret >>> 0;
1809
+ }
1810
+
1811
+ /**
1812
+ * Return a new `MolHandle` with one atom appended.
1813
+ *
1814
+ * The second return value is the new atom's index (as a JS number).
1815
+ * Use `with_atom_added_idx` to retrieve the index.
1816
+ * @param {MolHandle} mol
1817
+ * @param {string} element_symbol
1818
+ * @returns {MolHandle}
1819
+ */
1820
+ export function mol_with_atom_added(mol, element_symbol) {
1821
+ _assertClass(mol, MolHandle);
1822
+ const ptr0 = passStringToWasm0(element_symbol, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1823
+ const len0 = WASM_VECTOR_LEN;
1824
+ const ret = wasm.mol_with_atom_added(mol.__wbg_ptr, ptr0, len0);
1825
+ if (ret[2]) {
1826
+ throw takeFromExternrefTable0(ret[1]);
1827
+ }
1828
+ return MolHandle.__wrap(ret[0]);
1829
+ }
1830
+
1831
+ /**
1832
+ * Return a new `MolHandle` with atom `idx` and all its bonds removed.
1833
+ *
1834
+ * Atom indices above `idx` shift down by 1. Returns a JS error if `idx`
1835
+ * is out of range.
1836
+ * @param {MolHandle} mol
1837
+ * @param {number} idx
1838
+ * @returns {MolHandle}
1839
+ */
1840
+ export function mol_with_atom_removed(mol, idx) {
1841
+ _assertClass(mol, MolHandle);
1842
+ const ret = wasm.mol_with_atom_removed(mol.__wbg_ptr, idx);
1843
+ if (ret[2]) {
1844
+ throw takeFromExternrefTable0(ret[1]);
1845
+ }
1846
+ return MolHandle.__wrap(ret[0]);
1847
+ }
1848
+
1849
+ /**
1850
+ * Return a new `MolHandle` with one bond added between `a` and `b`.
1851
+ *
1852
+ * `order` — 1 = single, 2 = double, 3 = triple.
1853
+ * Returns a JS error if the bond already exists or `a == b`.
1854
+ * @param {MolHandle} mol
1855
+ * @param {number} a
1856
+ * @param {number} b
1857
+ * @param {number} order
1858
+ * @returns {MolHandle}
1859
+ */
1860
+ export function mol_with_bond_added(mol, a, b, order) {
1861
+ _assertClass(mol, MolHandle);
1862
+ const ret = wasm.mol_with_bond_added(mol.__wbg_ptr, a, b, order);
1863
+ if (ret[2]) {
1864
+ throw takeFromExternrefTable0(ret[1]);
1865
+ }
1866
+ return MolHandle.__wrap(ret[0]);
1867
+ }
1868
+
1869
+ /**
1870
+ * Return a new `MolHandle` with bond `idx` removed.
1871
+ *
1872
+ * Atom indices are unchanged; bond indices above `idx` shift down.
1873
+ * Returns a JS error if `idx` is out of range.
1874
+ * @param {MolHandle} mol
1875
+ * @param {number} idx
1876
+ * @returns {MolHandle}
1877
+ */
1878
+ export function mol_with_bond_removed(mol, idx) {
1879
+ _assertClass(mol, MolHandle);
1880
+ const ret = wasm.mol_with_bond_removed(mol.__wbg_ptr, idx);
1881
+ if (ret[2]) {
1882
+ throw takeFromExternrefTable0(ret[1]);
1883
+ }
1884
+ return MolHandle.__wrap(ret[0]);
1885
+ }
1886
+
1887
+ /**
1888
+ * Per-atom molar refractivity contributions as a JSON array of f64.
1889
+ * @param {MolHandle} mol
1890
+ * @returns {string}
1891
+ */
1892
+ export function mr_per_atom_json(mol) {
1893
+ let deferred1_0;
1894
+ let deferred1_1;
1895
+ try {
1896
+ _assertClass(mol, MolHandle);
1897
+ const ret = wasm.mr_per_atom_json(mol.__wbg_ptr);
1898
+ deferred1_0 = ret[0];
1899
+ deferred1_1 = ret[1];
1900
+ return getStringFromWasm0(ret[0], ret[1]);
1901
+ } finally {
1902
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1903
+ }
1904
+ }
1905
+
1906
+ /**
1907
+ * Murcko scaffold of `mol` — the ring system plus linkers, side-chains removed.
1908
+ *
1909
+ * Returns a new `MolHandle`. For acyclic molecules returns an empty molecule.
1910
+ * @param {MolHandle} mol
1911
+ * @returns {MolHandle}
1912
+ */
1913
+ export function murcko_scaffold(mol) {
1914
+ _assertClass(mol, MolHandle);
1915
+ const ret = wasm.murcko_scaffold(mol.__wbg_ptr);
1916
+ return MolHandle.__wrap(ret);
1917
+ }
1918
+
1919
+ /**
1920
+ * Neutralize formal charges on `mol` by proton addition/removal.
1921
+ *
1922
+ * Returns a new `MolHandle` with all formal charges set to zero where possible.
1923
+ * @param {MolHandle} mol
1924
+ * @returns {MolHandle}
1925
+ */
1926
+ export function neutralize_charges(mol) {
1927
+ _assertClass(mol, MolHandle);
1928
+ const ret = wasm.neutralize_charges(mol.__wbg_ptr);
1929
+ return MolHandle.__wrap(ret);
1930
+ }
1931
+
1932
+ /**
1933
+ * Parse and re-serialise a reaction SMILES string, returning the normalised form.
1934
+ *
1935
+ * Useful for validating reaction SMILES and obtaining a canonical representation.
1936
+ * Returns a JS error on parse failure.
1937
+ * @param {string} rxn_smiles
1938
+ * @returns {string}
1939
+ */
1940
+ export function normalize_reaction_smiles(rxn_smiles) {
1941
+ let deferred3_0;
1942
+ let deferred3_1;
1943
+ try {
1944
+ const ptr0 = passStringToWasm0(rxn_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1945
+ const len0 = WASM_VECTOR_LEN;
1946
+ const ret = wasm.normalize_reaction_smiles(ptr0, len0);
1947
+ var ptr2 = ret[0];
1948
+ var len2 = ret[1];
1949
+ if (ret[3]) {
1950
+ ptr2 = 0; len2 = 0;
1951
+ throw takeFromExternrefTable0(ret[2]);
1952
+ }
1953
+ deferred3_0 = ptr2;
1954
+ deferred3_1 = len2;
1955
+ return getStringFromWasm0(ptr2, len2);
1956
+ } finally {
1957
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1958
+ }
1959
+ }
1960
+
1961
+ /**
1962
+ * PAINS structural alert names matched by `mol` as a JSON array.
1963
+ *
1964
+ * Returns `[]` when no alerts fire, or e.g. `["ene_six_het_A(483)"]`.
1965
+ * Use alongside `pains_passes()` to know *which* alerts triggered.
1966
+ * @param {MolHandle} mol
1967
+ * @returns {string}
1968
+ */
1969
+ export function pains_matches_json(mol) {
1970
+ let deferred1_0;
1971
+ let deferred1_1;
1972
+ try {
1973
+ _assertClass(mol, MolHandle);
1974
+ const ret = wasm.pains_matches_json(mol.__wbg_ptr);
1975
+ deferred1_0 = ret[0];
1976
+ deferred1_1 = ret[1];
1977
+ return getStringFromWasm0(ret[0], ret[1]);
1978
+ } finally {
1979
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1980
+ }
1981
+ }
1982
+
1983
+ /**
1984
+ * Parse a SMILES string into a `MolHandle`.
1985
+ *
1986
+ * Returns a JS error string on parse failure.
1987
+ * @param {string} s
1988
+ * @returns {MolHandle}
1989
+ */
1990
+ export function parse_smiles(s) {
1991
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1992
+ const len0 = WASM_VECTOR_LEN;
1993
+ const ret = wasm.parse_smiles(ptr0, len0);
1994
+ if (ret[2]) {
1995
+ throw takeFromExternrefTable0(ret[1]);
1996
+ }
1997
+ return MolHandle.__wrap(ret[0]);
1998
+ }
1999
+
2000
+ /**
2001
+ * PEOE_VSA descriptors (14 bins) as a JSON array.
2002
+ * @param {MolHandle} mol
2003
+ * @returns {string}
2004
+ */
2005
+ export function peoe_vsa_json(mol) {
2006
+ let deferred1_0;
2007
+ let deferred1_1;
2008
+ try {
2009
+ _assertClass(mol, MolHandle);
2010
+ const ret = wasm.peoe_vsa_json(mol.__wbg_ptr);
2011
+ deferred1_0 = ret[0];
2012
+ deferred1_1 = ret[1];
2013
+ return getStringFromWasm0(ret[0], ret[1]);
2014
+ } finally {
2015
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2016
+ }
2017
+ }
2018
+
2019
+ /**
2020
+ * Return a copy of the molecule with all explicit hydrogen atoms removed.
2021
+ * @param {MolHandle} mol
2022
+ * @returns {MolHandle}
2023
+ */
2024
+ export function remove_hydrogens(mol) {
2025
+ _assertClass(mol, MolHandle);
2026
+ const ret = wasm.remove_hydrogens(mol.__wbg_ptr);
2027
+ return MolHandle.__wrap(ret);
2028
+ }
2029
+
2030
+ /**
2031
+ * Decompose a set of molecules against a core SMARTS, returning R-group SMILES.
2032
+ *
2033
+ * `smiles_json` — JSON array of SMILES strings.
2034
+ * `core_smarts` — SMARTS pattern with `*` (wildcard) atoms marking R-group
2035
+ * attachment points. For example `c1ccc(*)cc1` for para-substituted benzene.
2036
+ *
2037
+ * Returns a JSON array with one entry per input molecule:
2038
+ * ```json
2039
+ * [
2040
+ * {"matched":true, "r1":"C"},
2041
+ * {"matched":true, "r1":"CC"},
2042
+ * {"matched":false}
2043
+ * ]
2044
+ * ```
2045
+ * R-group keys are `"r1"`, `"r2"`, … in the order the `*` atoms appear in
2046
+ * the SMARTS pattern. A molecule that does not contain the core gets
2047
+ * `"matched": false` and no R-group keys.
2048
+ *
2049
+ * Returns a JS error if the SMARTS fails to parse or any SMILES is invalid.
2050
+ * @param {string} smiles_json
2051
+ * @param {string} core_smarts
2052
+ * @returns {string}
2053
+ */
2054
+ export function rgroup_decompose_json(smiles_json, core_smarts) {
2055
+ let deferred4_0;
2056
+ let deferred4_1;
2057
+ try {
2058
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2059
+ const len0 = WASM_VECTOR_LEN;
2060
+ const ptr1 = passStringToWasm0(core_smarts, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2061
+ const len1 = WASM_VECTOR_LEN;
2062
+ const ret = wasm.rgroup_decompose_json(ptr0, len0, ptr1, len1);
2063
+ var ptr3 = ret[0];
2064
+ var len3 = ret[1];
2065
+ if (ret[3]) {
2066
+ ptr3 = 0; len3 = 0;
2067
+ throw takeFromExternrefTable0(ret[2]);
2068
+ }
2069
+ deferred4_0 = ptr3;
2070
+ deferred4_1 = len3;
2071
+ return getStringFromWasm0(ptr3, len3);
2072
+ } finally {
2073
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
2074
+ }
2075
+ }
2076
+
2077
+ /**
2078
+ * Apply a SMIRKS reaction template and return product SMILES as a JSON string.
2079
+ *
2080
+ * `reactants_smiles`: pipe-separated SMILES, one per reactant slot in the SMIRKS.
2081
+ * Returns a JSON array of arrays: `[["product_smi", …], …]`.
2082
+ * Returns a JS error on parse failure or arity mismatch.
2083
+ * @param {string} smirks
2084
+ * @param {string} reactants_smiles
2085
+ * @returns {string}
2086
+ */
2087
+ export function run_reactants(smirks, reactants_smiles) {
2088
+ let deferred4_0;
2089
+ let deferred4_1;
2090
+ try {
2091
+ const ptr0 = passStringToWasm0(smirks, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2092
+ const len0 = WASM_VECTOR_LEN;
2093
+ const ptr1 = passStringToWasm0(reactants_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2094
+ const len1 = WASM_VECTOR_LEN;
2095
+ const ret = wasm.run_reactants(ptr0, len0, ptr1, len1);
2096
+ var ptr3 = ret[0];
2097
+ var len3 = ret[1];
2098
+ if (ret[3]) {
2099
+ ptr3 = 0; len3 = 0;
2100
+ throw takeFromExternrefTable0(ret[2]);
2101
+ }
2102
+ deferred4_0 = ptr3;
2103
+ deferred4_1 = len3;
2104
+ return getStringFromWasm0(ptr3, len3);
2105
+ } finally {
2106
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
2107
+ }
2108
+ }
2109
+
2110
+ /**
2111
+ * Synthetic Accessibility Score (1 = easy, 10 = hard).
2112
+ * @param {MolHandle} mol
2113
+ * @returns {number}
2114
+ */
2115
+ export function sa_score(mol) {
2116
+ _assertClass(mol, MolHandle);
2117
+ const ret = wasm.sa_score(mol.__wbg_ptr);
2118
+ return ret;
2119
+ }
2120
+
2121
+ /**
2122
+ * Serialize multiple molecules with properties to an SDF string.
2123
+ *
2124
+ * # Arguments
2125
+ * * `smiles_json` — JSON array of SMILES strings, e.g. `["CC(=O)O","c1ccccc1"]`
2126
+ * * `names_json` — JSON array of molecule names (same length as `smiles_json`)
2127
+ * * `props_json` — JSON array where each element encodes one molecule's SD data fields
2128
+ * as `"key1\tvalue1\nkey2\tvalue2"` (tab-separated key/value, `\n`-separated pairs;
2129
+ * pass `""` for a molecule with no properties)
2130
+ *
2131
+ * Returns the SDF string, or a JS error if any SMILES fails to parse or the
2132
+ * arrays have mismatched lengths.
2133
+ *
2134
+ * The `\n` and `\t` sequences in `props_json` are JSON-escaped — they are
2135
+ * decoded to the actual characters before SDF formatting.
2136
+ * @param {string} smiles_json
2137
+ * @param {string} names_json
2138
+ * @param {string} props_json
2139
+ * @returns {string}
2140
+ */
2141
+ export function sdf_from_records_json(smiles_json, names_json, props_json) {
2142
+ let deferred5_0;
2143
+ let deferred5_1;
2144
+ try {
2145
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2146
+ const len0 = WASM_VECTOR_LEN;
2147
+ const ptr1 = passStringToWasm0(names_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2148
+ const len1 = WASM_VECTOR_LEN;
2149
+ const ptr2 = passStringToWasm0(props_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2150
+ const len2 = WASM_VECTOR_LEN;
2151
+ const ret = wasm.sdf_from_records_json(ptr0, len0, ptr1, len1, ptr2, len2);
2152
+ var ptr4 = ret[0];
2153
+ var len4 = ret[1];
2154
+ if (ret[3]) {
2155
+ ptr4 = 0; len4 = 0;
2156
+ throw takeFromExternrefTable0(ret[2]);
2157
+ }
2158
+ deferred5_0 = ptr4;
2159
+ deferred5_1 = len4;
2160
+ return getStringFromWasm0(ptr4, len4);
2161
+ } finally {
2162
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
2163
+ }
2164
+ }
2165
+
2166
+ /**
2167
+ * Parse an SDF string and return a JSON array of record objects.
2168
+ *
2169
+ * Each record has the shape:
2170
+ * ```json
2171
+ * {"smiles":"CC(=O)O","name":"aspirin","properties":{"MW":"180.2","Activity":"high"}}
2172
+ * ```
2173
+ *
2174
+ * Invalid records are represented as `null`. SD data fields are included in
2175
+ * `properties`; multi-line values are joined with `\n`.
2176
+ * @param {string} sdf
2177
+ * @returns {string}
2178
+ */
2179
+ export function sdf_to_records_json(sdf) {
2180
+ let deferred2_0;
2181
+ let deferred2_1;
2182
+ try {
2183
+ const ptr0 = passStringToWasm0(sdf, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2184
+ const len0 = WASM_VECTOR_LEN;
2185
+ const ret = wasm.sdf_to_records_json(ptr0, len0);
2186
+ deferred2_0 = ret[0];
2187
+ deferred2_1 = ret[1];
2188
+ return getStringFromWasm0(ret[0], ret[1]);
2189
+ } finally {
2190
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
2191
+ }
2192
+ }
2193
+
2194
+ /**
2195
+ * Parse an SDF string and return a JSON array of canonical SMILES strings.
2196
+ *
2197
+ * Invalid records are represented as `null` in the array.
2198
+ * @param {string} sdf
2199
+ * @returns {string}
2200
+ */
2201
+ export function sdf_to_smiles_json(sdf) {
2202
+ let deferred2_0;
2203
+ let deferred2_1;
2204
+ try {
2205
+ const ptr0 = passStringToWasm0(sdf, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2206
+ const len0 = WASM_VECTOR_LEN;
2207
+ const ret = wasm.sdf_to_smiles_json(ptr0, len0);
2208
+ deferred2_0 = ret[0];
2209
+ deferred2_1 = ret[1];
2210
+ return getStringFromWasm0(ret[0], ret[1]);
2211
+ } finally {
2212
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
2213
+ }
2214
+ }
2215
+
2216
+ /**
2217
+ * 3D shape descriptors as a JSON object.
2218
+ *
2219
+ * Keys: `pmi1`, `pmi2`, `pmi3`, `npr1`, `npr2`, `asphericity`, `eccentricity`,
2220
+ * `radiusOfGyration`, `planeOfBestFit`. Non-finite values (e.g. single-atom
2221
+ * molecules where pmi3 = 0) are serialised as JSON `null`.
2222
+ * @param {MolHandle} mol
2223
+ * @returns {string}
2224
+ */
2225
+ export function shape_descriptors_json(mol) {
2226
+ let deferred1_0;
2227
+ let deferred1_1;
2228
+ try {
2229
+ _assertClass(mol, MolHandle);
2230
+ const ret = wasm.shape_descriptors_json(mol.__wbg_ptr);
2231
+ deferred1_0 = ret[0];
2232
+ deferred1_1 = ret[1];
2233
+ return getStringFromWasm0(ret[0], ret[1]);
2234
+ } finally {
2235
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2236
+ }
2237
+ }
2238
+
2239
+ /**
2240
+ * SlogP_VSA descriptors (12 bins) as a JSON array.
2241
+ * @param {MolHandle} mol
2242
+ * @returns {string}
2243
+ */
2244
+ export function slogp_vsa_json(mol) {
2245
+ let deferred1_0;
2246
+ let deferred1_1;
2247
+ try {
2248
+ _assertClass(mol, MolHandle);
2249
+ const ret = wasm.slogp_vsa_json(mol.__wbg_ptr);
2250
+ deferred1_0 = ret[0];
2251
+ deferred1_1 = ret[1];
2252
+ return getStringFromWasm0(ret[0], ret[1]);
2253
+ } finally {
2254
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2255
+ }
2256
+ }
2257
+
2258
+ /**
2259
+ * Find all substructure matches of a SMARTS pattern in `mol`.
2260
+ *
2261
+ * Returns JSON array of arrays of atom indices (sorted, 0-based).
2262
+ * Example: `[[0,1,2],[3,4,5]]` — two matches.
2263
+ * Returns `"[]"` if no match. Returns a JS error on invalid SMARTS.
2264
+ * @param {string} smarts
2265
+ * @param {MolHandle} mol
2266
+ * @returns {string}
2267
+ */
2268
+ export function smarts_match_atoms(smarts, mol) {
2269
+ let deferred3_0;
2270
+ let deferred3_1;
2271
+ try {
2272
+ const ptr0 = passStringToWasm0(smarts, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2273
+ const len0 = WASM_VECTOR_LEN;
2274
+ _assertClass(mol, MolHandle);
2275
+ const ret = wasm.smarts_match_atoms(ptr0, len0, mol.__wbg_ptr);
2276
+ var ptr2 = ret[0];
2277
+ var len2 = ret[1];
2278
+ if (ret[3]) {
2279
+ ptr2 = 0; len2 = 0;
2280
+ throw takeFromExternrefTable0(ret[2]);
2281
+ }
2282
+ deferred3_0 = ptr2;
2283
+ deferred3_1 = len2;
2284
+ return getStringFromWasm0(ptr2, len2);
2285
+ } finally {
2286
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2287
+ }
2288
+ }
2289
+
2290
+ /**
2291
+ * Serialise a JSON array of SMILES to an SDF string.
2292
+ *
2293
+ * Generates 2D coordinates for each molecule. Property data can be
2294
+ * included by using `sdf_from_records_json` instead.
2295
+ * @param {string} smiles_json
2296
+ * @returns {string}
2297
+ */
2298
+ export function smiles_array_to_sdf(smiles_json) {
2299
+ let deferred3_0;
2300
+ let deferred3_1;
2301
+ try {
2302
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2303
+ const len0 = WASM_VECTOR_LEN;
2304
+ const ret = wasm.smiles_array_to_sdf(ptr0, len0);
2305
+ var ptr2 = ret[0];
2306
+ var len2 = ret[1];
2307
+ if (ret[3]) {
2308
+ ptr2 = 0; len2 = 0;
2309
+ throw takeFromExternrefTable0(ret[2]);
2310
+ }
2311
+ deferred3_0 = ptr2;
2312
+ deferred3_1 = len2;
2313
+ return getStringFromWasm0(ptr2, len2);
2314
+ } finally {
2315
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2316
+ }
2317
+ }
2318
+
2319
+ /**
2320
+ * Render a highlighted SVG from a SMILES string in one call.
2321
+ *
2322
+ * `atoms` — 0-based atom indices to highlight (Uint32Array in JS).
2323
+ * `bonds` — 0-based bond indices to highlight (Uint32Array in JS).
2324
+ * `color` — CSS color for highlights (e.g. `"#ef4444"`); empty string uses default yellow.
2325
+ *
2326
+ * Returns a JS error on SMILES parse failure.
2327
+ * @param {string} smiles
2328
+ * @param {Uint32Array} atoms
2329
+ * @param {Uint32Array} bonds
2330
+ * @param {string} color
2331
+ * @returns {string}
2332
+ */
2333
+ export function smiles_to_svg_highlighted(smiles, atoms, bonds, color) {
2334
+ let deferred6_0;
2335
+ let deferred6_1;
2336
+ try {
2337
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2338
+ const len0 = WASM_VECTOR_LEN;
2339
+ const ptr1 = passArray32ToWasm0(atoms, wasm.__wbindgen_malloc);
2340
+ const len1 = WASM_VECTOR_LEN;
2341
+ const ptr2 = passArray32ToWasm0(bonds, wasm.__wbindgen_malloc);
2342
+ const len2 = WASM_VECTOR_LEN;
2343
+ const ptr3 = passStringToWasm0(color, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2344
+ const len3 = WASM_VECTOR_LEN;
2345
+ const ret = wasm.smiles_to_svg_highlighted(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
2346
+ var ptr5 = ret[0];
2347
+ var len5 = ret[1];
2348
+ if (ret[3]) {
2349
+ ptr5 = 0; len5 = 0;
2350
+ throw takeFromExternrefTable0(ret[2]);
2351
+ }
2352
+ deferred6_0 = ptr5;
2353
+ deferred6_1 = len5;
2354
+ return getStringFromWasm0(ptr5, len5);
2355
+ } finally {
2356
+ wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
2357
+ }
2358
+ }
2359
+
2360
+ /**
2361
+ * SMR_VSA descriptors (10 bins) as a JSON array.
2362
+ * @param {MolHandle} mol
2363
+ * @returns {string}
2364
+ */
2365
+ export function smr_vsa_json(mol) {
2366
+ let deferred1_0;
2367
+ let deferred1_1;
2368
+ try {
2369
+ _assertClass(mol, MolHandle);
2370
+ const ret = wasm.smr_vsa_json(mol.__wbg_ptr);
2371
+ deferred1_0 = ret[0];
2372
+ deferred1_1 = ret[1];
2373
+ return getStringFromWasm0(ret[0], ret[1]);
2374
+ } finally {
2375
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2376
+ }
2377
+ }
2378
+
2379
+ /**
2380
+ * Smallest Set of Smallest Rings (SSSR) as a JSON array of atom-index arrays.
2381
+ *
2382
+ * Example return value for naphthalene:
2383
+ * `[[0,1,2,3,4,5],[5,6,7,8,9,4]]`
2384
+ * @param {MolHandle} mol
2385
+ * @returns {string}
2386
+ */
2387
+ export function sssr_rings_json(mol) {
2388
+ let deferred1_0;
2389
+ let deferred1_1;
2390
+ try {
2391
+ _assertClass(mol, MolHandle);
2392
+ const ret = wasm.sssr_rings_json(mol.__wbg_ptr);
2393
+ deferred1_0 = ret[0];
2394
+ deferred1_1 = ret[1];
2395
+ return getStringFromWasm0(ret[0], ret[1]);
2396
+ } finally {
2397
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2398
+ }
2399
+ }
2400
+
2401
+ export function start() {
2402
+ wasm.start();
2403
+ }
2404
+
2405
+ /**
2406
+ * Tanimoto similarity between two molecules using AtomPair fingerprints.
2407
+ * @param {MolHandle} a
2408
+ * @param {MolHandle} b
2409
+ * @returns {number}
2410
+ */
2411
+ export function tanimoto_atom_pair(a, b) {
2412
+ _assertClass(a, MolHandle);
2413
+ _assertClass(b, MolHandle);
2414
+ const ret = wasm.tanimoto_atom_pair(a.__wbg_ptr, b.__wbg_ptr);
2415
+ return ret;
2416
+ }
2417
+
2418
+ /**
2419
+ * Tanimoto similarity between two molecules using ECFP4 fingerprints.
2420
+ * @param {MolHandle} a
2421
+ * @param {MolHandle} b
2422
+ * @returns {number}
2423
+ */
2424
+ export function tanimoto_ecfp4(a, b) {
2425
+ _assertClass(a, MolHandle);
2426
+ _assertClass(b, MolHandle);
2427
+ const ret = wasm.tanimoto_ecfp4(a.__wbg_ptr, b.__wbg_ptr);
2428
+ return ret;
2429
+ }
2430
+
2431
+ /**
2432
+ * Tanimoto similarity between `a` and `b` using ECFP6 fingerprints.
2433
+ * @param {MolHandle} a
2434
+ * @param {MolHandle} b
2435
+ * @returns {number}
2436
+ */
2437
+ export function tanimoto_ecfp6(a, b) {
2438
+ _assertClass(a, MolHandle);
2439
+ _assertClass(b, MolHandle);
2440
+ const ret = wasm.tanimoto_ecfp6(a.__wbg_ptr, b.__wbg_ptr);
2441
+ return ret;
2442
+ }
2443
+
2444
+ /**
2445
+ * Tanimoto similarity between two molecules using FCFP4 fingerprints (pharmacophore-based).
2446
+ * @param {MolHandle} a
2447
+ * @param {MolHandle} b
2448
+ * @returns {number}
2449
+ */
2450
+ export function tanimoto_fcfp4(a, b) {
2451
+ _assertClass(a, MolHandle);
2452
+ _assertClass(b, MolHandle);
2453
+ const ret = wasm.tanimoto_fcfp4(a.__wbg_ptr, b.__wbg_ptr);
2454
+ return ret;
2455
+ }
2456
+
2457
+ /**
2458
+ * Tanimoto similarity between `a` and `b` using FCFP6 (radius-3 pharmacophore) fingerprints.
2459
+ * @param {MolHandle} a
2460
+ * @param {MolHandle} b
2461
+ * @returns {number}
2462
+ */
2463
+ export function tanimoto_fcfp6(a, b) {
2464
+ _assertClass(a, MolHandle);
2465
+ _assertClass(b, MolHandle);
2466
+ const ret = wasm.tanimoto_fcfp6(a.__wbg_ptr, b.__wbg_ptr);
2467
+ return ret;
2468
+ }
2469
+
2470
+ /**
2471
+ * Tanimoto similarity between `a` and `b` using MACCS 166-bit fingerprints.
2472
+ * @param {MolHandle} a
2473
+ * @param {MolHandle} b
2474
+ * @returns {number}
2475
+ */
2476
+ export function tanimoto_maccs(a, b) {
2477
+ _assertClass(a, MolHandle);
2478
+ _assertClass(b, MolHandle);
2479
+ const ret = wasm.tanimoto_maccs(a.__wbg_ptr, b.__wbg_ptr);
2480
+ return ret;
2481
+ }
2482
+
2483
+ /**
2484
+ * Tanimoto similarity between two molecules given only SMILES strings (ECFP4).
2485
+ *
2486
+ * Returns a JS error on parse failure.
2487
+ * @param {string} smiles1
2488
+ * @param {string} smiles2
2489
+ * @returns {number}
2490
+ */
2491
+ export function tanimoto_smiles(smiles1, smiles2) {
2492
+ const ptr0 = passStringToWasm0(smiles1, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2493
+ const len0 = WASM_VECTOR_LEN;
2494
+ const ptr1 = passStringToWasm0(smiles2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2495
+ const len1 = WASM_VECTOR_LEN;
2496
+ const ret = wasm.tanimoto_smiles(ptr0, len0, ptr1, len1);
2497
+ if (ret[2]) {
2498
+ throw takeFromExternrefTable0(ret[1]);
2499
+ }
2500
+ return ret[0];
2501
+ }
2502
+
2503
+ /**
2504
+ * Tanimoto similarity between two molecules using topological path fingerprints.
2505
+ * @param {MolHandle} a
2506
+ * @param {MolHandle} b
2507
+ * @returns {number}
2508
+ */
2509
+ export function tanimoto_topo_path(a, b) {
2510
+ _assertClass(a, MolHandle);
2511
+ _assertClass(b, MolHandle);
2512
+ const ret = wasm.tanimoto_topo_path(a.__wbg_ptr, b.__wbg_ptr);
2513
+ return ret;
2514
+ }
2515
+
2516
+ /**
2517
+ * Tanimoto similarity between two molecules using Topological Torsion fingerprints.
2518
+ * @param {MolHandle} a
2519
+ * @param {MolHandle} b
2520
+ * @returns {number}
2521
+ */
2522
+ export function tanimoto_torsion(a, b) {
2523
+ _assertClass(a, MolHandle);
2524
+ _assertClass(b, MolHandle);
2525
+ const ret = wasm.tanimoto_torsion(a.__wbg_ptr, b.__wbg_ptr);
2526
+ return ret;
2527
+ }
2528
+
2529
+ /**
2530
+ * Serialise a `MolHandle` to a CML string with 2D coordinates.
2531
+ *
2532
+ * Coordinates are generated using the same 2D layout engine as `to_mol_block`.
2533
+ * @param {MolHandle} mol
2534
+ * @returns {string}
2535
+ */
2536
+ export function to_cml(mol) {
2537
+ let deferred1_0;
2538
+ let deferred1_1;
2539
+ try {
2540
+ _assertClass(mol, MolHandle);
2541
+ const ret = wasm.to_cml(mol.__wbg_ptr);
2542
+ deferred1_0 = ret[0];
2543
+ deferred1_1 = ret[1];
2544
+ return getStringFromWasm0(ret[0], ret[1]);
2545
+ } finally {
2546
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2547
+ }
2548
+ }
2549
+
2550
+ /**
2551
+ * Serialize a molecule to a MOL V2000 block with 2D coordinates.
2552
+ *
2553
+ * Atom positions are computed via the same layout engine used for SVG depiction
2554
+ * and converted to Ångström units (`1.5 Å` per bond).
2555
+ * @param {MolHandle} mol
2556
+ * @returns {string}
2557
+ */
2558
+ export function to_mol_block(mol) {
2559
+ let deferred1_0;
2560
+ let deferred1_1;
2561
+ try {
2562
+ _assertClass(mol, MolHandle);
2563
+ const ret = wasm.to_mol_block(mol.__wbg_ptr);
2564
+ deferred1_0 = ret[0];
2565
+ deferred1_1 = ret[1];
2566
+ return getStringFromWasm0(ret[0], ret[1]);
2567
+ } finally {
2568
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2569
+ }
2570
+ }
2571
+
2572
+ /**
2573
+ * Serialise a `MolHandle` to MOL V3000 format with 2D coordinates.
2574
+ * @param {MolHandle} mol
2575
+ * @returns {string}
2576
+ */
2577
+ export function to_mol_v3000_block(mol) {
2578
+ let deferred1_0;
2579
+ let deferred1_1;
2580
+ try {
2581
+ _assertClass(mol, MolHandle);
2582
+ const ret = wasm.to_mol_v3000_block(mol.__wbg_ptr);
2583
+ deferred1_0 = ret[0];
2584
+ deferred1_1 = ret[1];
2585
+ return getStringFromWasm0(ret[0], ret[1]);
2586
+ } finally {
2587
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2588
+ }
2589
+ }
2590
+
2591
+ /**
2592
+ * Serialize a molecule to XYZ format.
2593
+ *
2594
+ * 3D coordinates are generated via distance-geometry placement.
2595
+ * @param {MolHandle} mol
2596
+ * @returns {string}
2597
+ */
2598
+ export function to_xyz(mol) {
2599
+ let deferred1_0;
2600
+ let deferred1_1;
2601
+ try {
2602
+ _assertClass(mol, MolHandle);
2603
+ const ret = wasm.to_xyz(mol.__wbg_ptr);
2604
+ deferred1_0 = ret[0];
2605
+ deferred1_1 = ret[1];
2606
+ return getStringFromWasm0(ret[0], ret[1]);
2607
+ } finally {
2608
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2609
+ }
2610
+ }
2611
+
2612
+ /**
2613
+ * Torsion fingerprint as a bit-packed byte vector (256 bytes = 2048 bits).
2614
+ * @param {MolHandle} mol
2615
+ * @returns {Uint8Array}
2616
+ */
2617
+ export function torsion_bitvec(mol) {
2618
+ _assertClass(mol, MolHandle);
2619
+ const ret = wasm.torsion_bitvec(mol.__wbg_ptr);
2620
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
2621
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2622
+ return v1;
2623
+ }
2624
+
2625
+ /**
2626
+ * Non-canonical SMILES for `mol`.
2627
+ *
2628
+ * Unlike `canonical_smiles`, the output depends on the internal atom ordering
2629
+ * and is not normalised. Useful when round-trip fidelity (preserving atom
2630
+ * order) matters more than a canonical form.
2631
+ * @param {MolHandle} mol
2632
+ * @returns {string}
2633
+ */
2634
+ export function write_smiles(mol) {
2635
+ let deferred1_0;
2636
+ let deferred1_1;
2637
+ try {
2638
+ _assertClass(mol, MolHandle);
2639
+ const ret = wasm.write_smiles(mol.__wbg_ptr);
2640
+ deferred1_0 = ret[0];
2641
+ deferred1_1 = ret[1];
2642
+ return getStringFromWasm0(ret[0], ret[1]);
2643
+ } finally {
2644
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2645
+ }
2646
+ }
2647
+ function __wbg_get_imports() {
2648
+ const import0 = {
2649
+ __proto__: null,
2650
+ __wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
2651
+ throw new Error(getStringFromWasm0(arg0, arg1));
2652
+ },
2653
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
2654
+ let deferred0_0;
2655
+ let deferred0_1;
2656
+ try {
2657
+ deferred0_0 = arg0;
2658
+ deferred0_1 = arg1;
2659
+ console.error(getStringFromWasm0(arg0, arg1));
2660
+ } finally {
2661
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
2662
+ }
2663
+ },
2664
+ __wbg_new_227d7c05414eb861: function() {
2665
+ const ret = new Error();
2666
+ return ret;
2667
+ },
2668
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
2669
+ const ret = arg1.stack;
2670
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2671
+ const len1 = WASM_VECTOR_LEN;
2672
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2673
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2674
+ },
2675
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
2676
+ // Cast intrinsic for `Ref(String) -> Externref`.
2677
+ const ret = getStringFromWasm0(arg0, arg1);
2678
+ return ret;
2679
+ },
2680
+ __wbindgen_init_externref_table: function() {
2681
+ const table = wasm.__wbindgen_externrefs;
2682
+ const offset = table.grow(4);
2683
+ table.set(0, undefined);
2684
+ table.set(offset + 0, undefined);
2685
+ table.set(offset + 1, null);
2686
+ table.set(offset + 2, true);
2687
+ table.set(offset + 3, false);
2688
+ },
2689
+ };
2690
+ return {
2691
+ __proto__: null,
2692
+ "./chematic_wasm_bg.js": import0,
2693
+ };
2694
+ }
2695
+
2696
+ const ConformerHandleFinalization = (typeof FinalizationRegistry === 'undefined')
2697
+ ? { register: () => {}, unregister: () => {} }
2698
+ : new FinalizationRegistry(ptr => wasm.__wbg_conformerhandle_free(ptr, 1));
2699
+ const DepictOptionsFinalization = (typeof FinalizationRegistry === 'undefined')
2700
+ ? { register: () => {}, unregister: () => {} }
2701
+ : new FinalizationRegistry(ptr => wasm.__wbg_depictoptions_free(ptr, 1));
2702
+ const MolHandleFinalization = (typeof FinalizationRegistry === 'undefined')
2703
+ ? { register: () => {}, unregister: () => {} }
2704
+ : new FinalizationRegistry(ptr => wasm.__wbg_molhandle_free(ptr, 1));
2705
+
2706
+ function _assertClass(instance, klass) {
2707
+ if (!(instance instanceof klass)) {
2708
+ throw new Error(`expected instance of ${klass.name}`);
2709
+ }
2710
+ }
2711
+
2712
+ function getArrayU8FromWasm0(ptr, len) {
2713
+ ptr = ptr >>> 0;
2714
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
2715
+ }
2716
+
2717
+ let cachedDataViewMemory0 = null;
2718
+ function getDataViewMemory0() {
2719
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
2720
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
2721
+ }
2722
+ return cachedDataViewMemory0;
2723
+ }
2724
+
2725
+ function getStringFromWasm0(ptr, len) {
2726
+ return decodeText(ptr >>> 0, len);
2727
+ }
2728
+
2729
+ let cachedUint32ArrayMemory0 = null;
2730
+ function getUint32ArrayMemory0() {
2731
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
2732
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
2733
+ }
2734
+ return cachedUint32ArrayMemory0;
2735
+ }
2736
+
2737
+ let cachedUint8ArrayMemory0 = null;
2738
+ function getUint8ArrayMemory0() {
2739
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
2740
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
2741
+ }
2742
+ return cachedUint8ArrayMemory0;
2743
+ }
2744
+
2745
+ function passArray32ToWasm0(arg, malloc) {
2746
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
2747
+ getUint32ArrayMemory0().set(arg, ptr / 4);
2748
+ WASM_VECTOR_LEN = arg.length;
2749
+ return ptr;
2750
+ }
2751
+
2752
+ function passStringToWasm0(arg, malloc, realloc) {
2753
+ if (realloc === undefined) {
2754
+ const buf = cachedTextEncoder.encode(arg);
2755
+ const ptr = malloc(buf.length, 1) >>> 0;
2756
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
2757
+ WASM_VECTOR_LEN = buf.length;
2758
+ return ptr;
2759
+ }
2760
+
2761
+ let len = arg.length;
2762
+ let ptr = malloc(len, 1) >>> 0;
2763
+
2764
+ const mem = getUint8ArrayMemory0();
2765
+
2766
+ let offset = 0;
2767
+
2768
+ for (; offset < len; offset++) {
2769
+ const code = arg.charCodeAt(offset);
2770
+ if (code > 0x7F) break;
2771
+ mem[ptr + offset] = code;
2772
+ }
2773
+ if (offset !== len) {
2774
+ if (offset !== 0) {
2775
+ arg = arg.slice(offset);
2776
+ }
2777
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
2778
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
2779
+ const ret = cachedTextEncoder.encodeInto(arg, view);
2780
+
2781
+ offset += ret.written;
2782
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
2783
+ }
2784
+
2785
+ WASM_VECTOR_LEN = offset;
2786
+ return ptr;
2787
+ }
2788
+
2789
+ function takeFromExternrefTable0(idx) {
2790
+ const value = wasm.__wbindgen_externrefs.get(idx);
2791
+ wasm.__externref_table_dealloc(idx);
2792
+ return value;
2793
+ }
2794
+
2795
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2796
+ cachedTextDecoder.decode();
2797
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
2798
+ let numBytesDecoded = 0;
2799
+ function decodeText(ptr, len) {
2800
+ numBytesDecoded += len;
2801
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
2802
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2803
+ cachedTextDecoder.decode();
2804
+ numBytesDecoded = len;
2805
+ }
2806
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
2807
+ }
2808
+
2809
+ const cachedTextEncoder = new TextEncoder();
2810
+
2811
+ if (!('encodeInto' in cachedTextEncoder)) {
2812
+ cachedTextEncoder.encodeInto = function (arg, view) {
2813
+ const buf = cachedTextEncoder.encode(arg);
2814
+ view.set(buf);
2815
+ return {
2816
+ read: arg.length,
2817
+ written: buf.length
2818
+ };
2819
+ };
2820
+ }
2821
+
2822
+ let WASM_VECTOR_LEN = 0;
2823
+
2824
+ let wasmModule, wasmInstance, wasm;
2825
+ function __wbg_finalize_init(instance, module) {
2826
+ wasmInstance = instance;
2827
+ wasm = instance.exports;
2828
+ wasmModule = module;
2829
+ cachedDataViewMemory0 = null;
2830
+ cachedUint32ArrayMemory0 = null;
2831
+ cachedUint8ArrayMemory0 = null;
2832
+ wasm.__wbindgen_start();
2833
+ return wasm;
2834
+ }
2835
+
2836
+ async function __wbg_load(module, imports) {
2837
+ if (typeof Response === 'function' && module instanceof Response) {
2838
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
2839
+ try {
2840
+ return await WebAssembly.instantiateStreaming(module, imports);
2841
+ } catch (e) {
2842
+ const validResponse = module.ok && expectedResponseType(module.type);
2843
+
2844
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
2845
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
2846
+
2847
+ } else { throw e; }
2848
+ }
2849
+ }
2850
+
2851
+ const bytes = await module.arrayBuffer();
2852
+ return await WebAssembly.instantiate(bytes, imports);
2853
+ } else {
2854
+ const instance = await WebAssembly.instantiate(module, imports);
2855
+
2856
+ if (instance instanceof WebAssembly.Instance) {
2857
+ return { instance, module };
2858
+ } else {
2859
+ return instance;
2860
+ }
2861
+ }
2862
+
2863
+ function expectedResponseType(type) {
2864
+ switch (type) {
2865
+ case 'basic': case 'cors': case 'default': return true;
2866
+ }
2867
+ return false;
2868
+ }
2869
+ }
2870
+
2871
+ function initSync(module) {
2872
+ if (wasm !== undefined) return wasm;
2873
+
2874
+
2875
+ if (module !== undefined) {
2876
+ if (Object.getPrototypeOf(module) === Object.prototype) {
2877
+ ({module} = module)
2878
+ } else {
2879
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
2880
+ }
2881
+ }
2882
+
2883
+ const imports = __wbg_get_imports();
2884
+ if (!(module instanceof WebAssembly.Module)) {
2885
+ module = new WebAssembly.Module(module);
2886
+ }
2887
+ const instance = new WebAssembly.Instance(module, imports);
2888
+ return __wbg_finalize_init(instance, module);
2889
+ }
2890
+
2891
+ async function __wbg_init(module_or_path) {
2892
+ if (wasm !== undefined) return wasm;
2893
+
2894
+
2895
+ if (module_or_path !== undefined) {
2896
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
2897
+ ({module_or_path} = module_or_path)
2898
+ } else {
2899
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
2900
+ }
2901
+ }
2902
+
2903
+ if (module_or_path === undefined) {
2904
+ module_or_path = new URL('chematic_wasm_bg.wasm', import.meta.url);
2905
+ }
2906
+ const imports = __wbg_get_imports();
2907
+
2908
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
2909
+ module_or_path = fetch(module_or_path);
2910
+ }
2911
+
2912
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
2913
+
2914
+ return __wbg_finalize_init(instance, module);
2915
+ }
2916
+
2917
+ export { initSync, __wbg_init as default };