import API from 'src/util/api';
import Versioning from 'src/util/versioning';
import URI from 'uri/URI';
import {OCLE} from './libs';

var externalInfo = JSON.parse(window.localStorage.getItem('external_cache') || '{}');
var smiles = externalInfo.smiles;
var molfile = externalInfo.molfile;
API.createData('nmr', []);
API.createData('mass', []);
API.createData('ir', []);

var uri = new URI(document.location.href);
var search = uri.search(true);
if (search.smiles) {
    smiles = search.smiles;
}

if (molfile) {
    const molecule = OCLE.Molecule.fromMolfile(molfile);
    API.createData('molfile', molecule.toMolfile());
} else if (smiles) {
    const molecule = OCLE.Molecule.fromSmiles(smiles);
    API.createData('molfile', molecule.toMolfile());
} else {
    molfile = window.localStorage.getItem('molfile');
    if (molfile) {
        API.createData('molfile', molfile);
    } else {
        API.createData('molfile', '');
    }
}

var data = Versioning.getData();
data.onChange(function (evt) {
    if (evt.jpath.length === 1 && evt.jpath[0] === 'molfile') {
        localStorage.setItem('molfile', evt.target.get());
    }
});

@@ -101,37 +101,8 @@
 RI';
-%0Aimport %7BOCLE%7D from './libs';
 %0A%0Ava
@@ -474,24 +474,44 @@
 (molfile) %7B%0A
+    if (OCLE) %7B%0A    
     const mo
@@ -551,24 +551,28 @@
 e(molfile);%0A
+    
     API.crea
@@ -608,24 +608,176 @@
 Molfile());%0A
+    %7D else %7B%0A        console.log('OCLE should be available in window in order to normalise molfile');%0A        API.createData('molfile', molfile);%0A    %7D%0A
 %7D else if (s
@@ -781,24 +781,44 @@
  (smiles) %7B%0A
+    if (OCLE) %7B%0A    
     const mo
@@ -860,24 +860,28 @@
 miles);%0A    
+   
+ 
 API.createDa
@@ -917,16 +917,20 @@
 ile());%0A
+    
 %7D else %7B
@@ -926,24 +926,129 @@
    %7D else %7B%0A
+        onsole.log('OCLE should be available in window in order to parse SMILES');%0A    %7D%0A%7D else %7Bmolfile%0A
     molfile 

Remove OCLE in order to prevent any conflict