@zakodium/nmrium-core 0.6.8 → 0.7.1

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/README.md CHANGED
@@ -52,7 +52,7 @@ console.log(result);
52
52
  // readSource function accept a partial FileCollectionItems and a baseURL to generate a
53
53
  // data structure with a source object inside with { files, filter, baseURL }
54
54
 
55
- const nmriumObject = await core.readFromWebSource(
55
+ const { state } = await core.readFromWebSource(
56
56
  {
57
57
  baseURL: 'https://cheminfo.github.io',
58
58
  files: [
@@ -1,6 +1,6 @@
1
1
  import type { CorrelationData } from 'nmr-correlation';
2
2
  import type { FifoLoggerOptions } from 'fifo-logger';
3
- import { FileCollection } from 'file-collection';
3
+ import type { FileCollection } from 'file-collection';
4
4
  import type { FileItem } from 'file-collection';
5
5
  import type { Filter1DEntry } from '@zakodium/nmr-types';
6
6
  import type { Filter1DOptions } from '@zakodium/nmr-types';
@@ -197,25 +197,34 @@ export declare interface ContourItem {
197
197
  numberOfLayers: number;
198
198
  }
199
199
 
200
- export declare interface ContourOptions {
200
+ export declare interface ContourLevel {
201
201
  positive: ContourItem;
202
202
  negative: ContourItem;
203
203
  }
204
204
 
205
- declare interface ContourOptions_2 {
206
- positive: {
207
- contourLevels: [number, number];
208
- numberOfLayers: number;
209
- };
210
- negative: {
211
- contourLevels: [number, number];
212
- numberOfLayers: number;
213
- };
205
+ export declare interface CoreReadReturn {
206
+ /**
207
+ * Common state representation between NMRium component and NMRium apps
208
+ */
209
+ state: Partial<NmriumState>;
210
+ /**
211
+ * Meta file collection.
212
+ * Each user source of data is placed in his dedicated uuid folder.
213
+ * In the UI, it means one drag n drop (with possibly multiple files) = one uuid folder.
214
+ */
215
+ aggregator: FileCollection;
216
+ /**
217
+ * Is input given to the read method contains a nmrium file?
218
+ * This also means that the reader ignored the rest of the content.
219
+ * Or the reading method read a nmrium object / file.
220
+ *
221
+ * This information is generally used by the NMRium component
222
+ * or an NMRium app to know if it should merge state and aggregator or replace them.
223
+ */
224
+ containsNmrium: boolean;
214
225
  }
215
226
 
216
- export declare type ContoursLevels = Record<string, Level>;
217
-
218
- export declare const CURRENT_EXPORT_VERSION: 13;
227
+ export declare const CURRENT_EXPORT_VERSION: 14;
219
228
 
220
229
  export declare type CustomWorkspaces = Record<string, InnerWorkspace>;
221
230
 
@@ -289,7 +298,6 @@ export declare interface Display1D extends Display {
289
298
  export declare interface Display2D extends Color2D, Display {
290
299
  isPositiveVisible: boolean;
291
300
  isNegativeVisible: boolean;
292
- contourOptions: ContourOptions_2;
293
301
  }
294
302
 
295
303
  declare interface DisplayPreferences {
@@ -437,11 +445,6 @@ export declare type Layout = 'portrait' | 'landscape';
437
445
 
438
446
  export declare type LegendField = JpathLegendField | PredefinedLegendField;
439
447
 
440
- export declare interface Level {
441
- positive: ContourItem;
442
- negative: ContourItem;
443
- }
444
-
445
448
  declare interface LoadersPreferences {
446
449
  general: GeneralLoadersSelector;
447
450
  bruker: BrukerLoaderSelector;
@@ -504,7 +507,7 @@ export declare interface MultipleSpectraAnalysisPreferences {
504
507
 
505
508
  export declare class NMRiumCore {
506
509
  #private;
507
- readonly version: 13;
510
+ readonly version: 14;
508
511
  registerPlugin(plugin: NMRiumPlugin): void;
509
512
  registerPlugins(plugins: NMRiumPlugin[]): void;
510
513
  private getPlugin;
@@ -518,8 +521,8 @@ export declare class NMRiumCore {
518
521
  */
519
522
  read(input: FileCollection | FileItem, options?: Partial<ParsingOptions>, fromSourceOptions?: {
520
523
  baseURL?: string;
521
- }): ReturnType<typeof read>;
522
- readNMRiumArchive(input: ZipFileContent, options?: Partial<ParsingOptions>): ReturnType<typeof readNMRiumArchive>;
524
+ }): Promise<CoreReadReturn>;
525
+ readNMRiumArchive(input: ZipFileContent, options?: Partial<ParsingOptions>): Promise<CoreReadReturn>;
523
526
  /**
524
527
  * Read a nmrium state, migrate it to the current version,
525
528
  * fetch data from sources contained, and format spectra and molecules.
@@ -530,7 +533,7 @@ export declare class NMRiumCore {
530
533
  */
531
534
  readNMRiumObject(nmriumObjectInput: object, options?: ParsingOptions, fromSourceOptions?: {
532
535
  baseURL?: string;
533
- }): ReturnType<typeof readNMRiumObject>;
536
+ }): Promise<CoreReadReturn>;
534
537
  /**
535
538
  * Same than `readNMRiumObject` but from a file from `FileCollection`
536
539
  * @param file - supports nmrium state file with any extension, compressed or not.
@@ -539,8 +542,8 @@ export declare class NMRiumCore {
539
542
  */
540
543
  readNMRiumFile(file: FileItem, options?: Partial<ParsingOptions>, fromSourceOptions?: {
541
544
  baseURL?: string;
542
- }): ReturnType<typeof readNMRiumObject>;
543
- readFromWebSource(source: Source, options?: ParsingOptions): Promise<[state: Partial<NmriumState>, fileCollection: FileCollection, selectorRoot: string]>;
545
+ }): Promise<CoreReadReturn>;
546
+ readFromWebSource(source: Source, options?: ParsingOptions): Promise<CoreReadReturn>;
544
547
  /**
545
548
  * Serialize a state to nmrium object.
546
549
  * It can be serialized to json then,
@@ -1100,58 +1103,6 @@ export declare interface RangesViewState {
1100
1103
  rangesBounding: BoundingBox;
1101
1104
  }
1102
1105
 
1103
- declare function read(_options: ReadOptions): Promise<ReadReturn>;
1104
-
1105
- declare function readNMRiumArchive(_options: ReadNMRiumArchiveOptions): Promise<readonly [NmriumState, FileCollection]>;
1106
-
1107
- declare interface ReadNMRiumArchiveOptions {
1108
- input: ZipFileContent;
1109
- options?: Partial<ParsingOptions>;
1110
- plugins: Map<string, NMRiumPlugin>;
1111
- migrator: (state: object) => any;
1112
- }
1113
-
1114
- declare function readNMRiumObject(_options: ReadNMRiumObjectOptions): Promise<ReadNMRiumObjectReturn>;
1115
-
1116
- declare interface ReadNMRiumObjectOptions {
1117
- nmriumObjectInput: object;
1118
- migrator: (state: object) => any;
1119
- plugins: Map<string, NMRiumPlugin>;
1120
- options?: ParsingOptions;
1121
- fromSourceOptions?: {
1122
- baseURL?: string;
1123
- };
1124
- }
1125
-
1126
- declare type ReadNMRiumObjectReturn = [
1127
- /**
1128
- * State read from `nmriumObjectInput`
1129
- */
1130
- state: Partial<NmriumState>,
1131
- /**
1132
- * A file collection where each subfolder is
1133
- * an uuid of a file collection from sources.
1134
- */
1135
- aggregator: FileCollection
1136
- ];
1137
-
1138
- declare interface ReadOptions {
1139
- input: FileCollection | FileItem;
1140
- migrator: (state: object) => any;
1141
- plugins: Map<string, NMRiumPlugin>;
1142
- options?: ParsingOptions;
1143
- fromSourceOptions?: {
1144
- baseURL?: string;
1145
- };
1146
- }
1147
-
1148
- declare interface ReadReturn {
1149
- nmriumState: Partial<NmriumState>;
1150
- containsNmrium: boolean;
1151
- fileCollection: FileCollection;
1152
- selectorRoot: string;
1153
- }
1154
-
1155
1106
  export declare type SerializedNmriumState = Omit<Partial<NmriumState>, 'data'> & {
1156
1107
  version: number;
1157
1108
  data?: NmriumData | NmriumDataSource;
@@ -1236,6 +1187,8 @@ export declare interface SpectraColors {
1236
1187
  indicatorLineColor: string;
1237
1188
  }
1238
1189
 
1190
+ export declare type SpectraContourLevels = Record<string, ContourLevel>;
1191
+
1239
1192
  declare type SpectraPredictionOptions = Record<Experiment, boolean>;
1240
1193
 
1241
1194
  export declare interface SpectraPreferences {
@@ -1445,9 +1398,7 @@ export declare interface ViewState {
1445
1398
  */
1446
1399
  showSimilarityTree: boolean;
1447
1400
  };
1448
- zoom: {
1449
- levels: ContoursLevels;
1450
- };
1401
+ spectraContourLevels: SpectraContourLevels;
1451
1402
  /**
1452
1403
  * options to control spectra vertical alignment
1453
1404
  * @default 'bottom'
@@ -1465,8 +1416,8 @@ export declare interface ViewState {
1465
1416
 
1466
1417
  export declare interface WheelOptions {
1467
1418
  shiftKey: boolean;
1468
- contourOptions: ContourOptions;
1469
- currentLevel: Level;
1419
+ contourLevel: ContourLevel;
1420
+ currentContourLevel: ContourLevel;
1470
1421
  }
1471
1422
 
1472
1423
  export declare type Workspace = WorkspaceMeta & Required<WorkspacePreferences>;
@@ -1,6 +1,6 @@
1
- var De={NORMAL:"NORMAL",FORMULA:"FORMULA"};var Me={RELATIVE:"relative",ABSOLUTE:"absolute",MIN:"min",MAX:"max"};var Ce=[{name:"pixels",unit:"px"},{name:"inches",unit:"in"},{name:"feet",unit:"ft"},{name:"yards",unit:"yd"},{name:"centimeters",unit:"cm"},{name:"millimeters",unit:"mm"},{name:"meters",unit:"m"},{name:"points",unit:"pt"},{name:"picas",unit:"pc"}];var N=13;var Ae=[{key:"CT",description:"CT from NMR Solutions"}];import{isAnyArray as Fe}from"is-any-array";import{xMultiply as B}from"ml-spectra-processing";var we=crypto.randomUUID.bind(crypto),x=we;function O(e){let{id:t=x(),meta:o,peaks:r={},filters:i=[],info:n={},ranges:c={},integrals:s={},selector:l,sourceId:a,dependentVariables:p=[],...m}=e,u={id:t,meta:o,filters:i},{data:f=Te(p[0]?.components??[])}=e;if(Array.isArray(n.nucleus)&&(n.nucleus=n.nucleus[0]),u.data={x:[],re:[],im:[],...f},"scaleFactor"in n){let{scaleFactor:g}=n,{re:S,im:y}=u.data;B(S,g,{output:S}),y&&B(y,g,{output:y})}l&&(u.selector=l),a&&(u.sourceId=a,u.fileCollectionId=a);let d=Fe(f.im);if(u.info={phc0:0,phc1:0,nucleus:"1H",isFid:!1,isComplex:d,dimension:1,name:n?.name||t,...n},n.isFid&&n.reverse&&d){let{im:g}=u.data;B(g,-1,{output:g}),u.info.reverse=!1}return u.display={isVisible:!0,isPeaksMarkersVisible:!0,isRealSpectrumVisible:!0,isVisibleInDomain:!0,...e.display},u.peaks={values:[],options:{},...r},u.ranges={values:[],options:{sum:null,isSumConstant:!0,sumAuto:!0},...c},u.integrals={values:[],options:{},...s},{...m,...u}}function Te(e){let t=e[0]?.data?.x||[],o=e[0]?.data?.re||e[0]?.data?.y||[],r=e[0]?.data?.im||e[1]?.data?.y||null;return t.length>0&&t[0]>t[1]&&(t.reverse(),o.reverse(),r&&r.reverse()),{x:t,re:o,im:r}}import{matrixToArray as Ee,xMinMaxValues as Le,xNoiseSanPlot as ze}from"ml-spectra-processing";var K={z:[[]],minX:0,minY:0,maxX:0,maxY:0},ke={re:K,im:K},Ue={rr:K};function M(e){let{id:t=x(),meta:o={},dependentVariables:r=[],info:i={},filters:n=[],zones:c=[],sourceId:s,...l}=e,a={id:t,meta:o,filters:n};s&&(a.sourceId=s,a.fileCollectionId=s),a.info={nucleus:["1H","1H"],isFid:!1,isComplex:!1,name:i?.name||x(),...i},a.originalInfo=structuredClone(a.info),a.display={isPositiveVisible:!0,isNegativeVisible:!0,isVisible:!0,dimension:2,...e.display};let{data:p=r[0]?.components??{}}=e;if(a.data={...a.info.isFid?ke:Ue,...p},a.originalData=structuredClone(a.data),!("spectrumSize"in i)){let m=i.isFid?"re":"rr",u=a.data[m].z.length,f=u>0?a.data[m].z[0].length:0;a.info.spectrumSize=[f,u]}if(!i.isFid){let m=a.data.rr,u=Ee(m.z),{positive:f,negative:d}=ze(u),{min:g,max:S}=Le(u);a.data.rr={...m,minZ:g,maxZ:S},a.info.noise={positive:f,negative:d}}return a.zones={values:[],options:{},...c},{...l,...a}}import{xSequentialFillFromTo as Ve}from"ml-spectra-processing";import{isAnyArray as je}from"is-any-array";function W(e,t=0){if(je(e)){let o=e.at(t);if(o!==void 0)return o;throw new RangeError("An array with a index out of boundaries")}return e}var _e=new Set(["t1ir","T1"]);function se(e){let t=[];for(let o of e){let{info:{pulseSequence:r,isFid:i}}=o,{data:n,info:c,meta:{vdlistValues:s=[]}={}}=o;if(!(r&&_e.has(r))||s.length===0){t.push(o);continue}let a=i?"re":"rr",p={};for(let y in c)p[y]=W(c[y]);let{z:m,maxX:u,minX:f}=n[a],d=Ve({from:f,to:u,size:m[0].length}),[g,S]=Ke(o);for(let y=0;y<s.length;y++){let P={re:d,x:d};for(let h in n)P[Be(h)]=n[h].z.at(g*(y+S));t.push(O({data:P,info:{...p,name:`${p.name}_${s[y]}`,dimension:1,vd:s[y]}}))}}return t}function Be(e){return["rr","re"].includes(e)?"re":["im","ri","ir","ii"].includes(e)?"im":"x"}function Ke(e){let{meta:{PAGE:t}}=e,o=!0;if(t){let r=i=>Number.parseFloat(i.replace(/[F|T]1=/,""));o=r(t[0])>r(t[2])}return o?[-1,1]:[1,0]}var We=2,Xe=1;function Ye(e){let{spectra:t=[],molecules:o}=e,r=[];for(let i of t){let{info:n}=i;switch(n.dimension){case Xe:r.push(O(i));break;case We:r.push(M(i));break;default:throw new Error("dimension does not supported")}}return{molecules:o,spectra:se(r)}}function Ze(e){return e}function b(e,t){return JSON.parse(JSON.stringify(e),function(r,i){if(r in t){this[t[r]]=i;return}return i})}function X(e){if(e?.version===1)return e;let t={...e,version:1},o={j:"js",signal:"signals",integral:"integration",peak:"peaks",diaID:"diaIDs"};for(let r of t.spectra){if(r.ranges){let i=b(r.ranges,o);r.ranges=Array.isArray(i)?{values:i}:i}else if(r.zones){let i=b(r.zones,o);r.zones=Array.isArray(i)?{values:i}:i}r.peaks&&(r.peaks=Array.isArray(r.peaks)?{values:r.peaks}:r.peaks),r.integrals&&(r.integrals=Array.isArray(r.integrals)?{values:r.integrals}:r.integrals)}return t}function Y(e){if(e?.version===2)return e;let t={...e,version:2},o={peaks:{delta:"x",originDelta:"originalX",intensity:"y"},ranges:{atomIDs:"atoms",intensity:"y"}};for(let r of t.spectra)r.peaks?r.peaks=b(r.peaks,o.peaks):r.ranges?r.ranges=b(r.ranges,o.ranges):r.zones&&(r.zones.values=$e(r.zones.values));return t}function $e(e){return e.map(t=>(t.signals&&(t.signals=t.signals.map(o=>{if(o.x&&o.y){let{x:{fromTo:r,...i},y:{fromTo:n,...c}}=o;o={...o,x:{...i,...r},y:{...c,...n}}}else{let{fromTo:r,deltaX:i,resolutionX:n,nucleusX:c,deltaY:s,resolutionY:l,nucleusY:a,shiftX:p,shiftY:m,...u}=o;o={...u,x:{from:r[0].from,to:r[0].to,delta:i,resolution:n,nucleus:c},y:{from:r[1].from,to:r[1].to,delta:s,resolution:l,nucleus:a}}}return o},[])),t),[])}var Ge={name:"apodization",label:"Apodization",value:{lineBroadening:1,gaussBroadening:0,lineBroadeningCenter:0}};function Z(e){if(e?.version===3)return e;let t={...e,version:3};for(let o of t.spectra)if(Array.isArray(o?.filters)&&o?.filters.length>0){let r=o.filters.findIndex(i=>i.name==="lineBroadening");if(r!==-1){let i={...o.filters[r],...Ge};o.filters[r]=o.filters[r-1],o.filters[r-1]=i}}return t}function $(e){if(e?.version===4)return e;let{version:t,...o}=e,r=[],i={};for(let{source:s,...l}of o.spectra){let a={},{info:p={},display:m={}}=l;if(p?.dimension===2&&!s?.jcampURL)if(p.isFt)a.data={rr:l.data};else continue;if(s?.jcampURL){let{jcampURL:d,jcampSpectrumIndex:g}=s,S=d.match(/(?<baseURL>^\w+:\/{2}\w+\/)(?<relativePath>.*)/);i[d]||(i[d]={baseURL:S?.groups.baseURL||"",relativePath:S?.groups.relativePath||d.replace(/^\.\//,"")}),a.sourceSelector={files:[i[d].relativePath]},g!==void 0&&(a.sourceSelector.jcamp={index:g})}a.filters=Je(l.filters);let{name:u,...f}=m;u&&(a.info={...p,name:u}),a.display=f,r.push({...l,...a})}let n={data:{...o,spectra:r},version:4},c={entries:Object.values(i)};return c.entries.length>0&&(n.data.source=c),n}function Je(e=[]){let t=[];for(let o of e){let{name:r,value:i}=o;switch(r){case"zeroFilling":t.push({...o,value:{nbPoints:i}});break;case"shiftX":case"shift2DX":case"shift2DY":t.push({...o,value:{shift:i}});break;default:t.push({...o})}}return t}function G(e){if(e?.version===5)return e;let t={...e,version:5},o={originFrom:"originalFrom",originTo:"originalTo",originDelta:"originalDelta",originX:"originalX",originY:"originalY",originZ:"originalZ"};for(let r of t?.data?.spectra||[])for(let i of["peaks","ranges","zones"])r?.[i]&&(r[i]=b(r[i],o));return t}function J(e){if(e?.version===6)return e;let t={...e,version:6};for(let o of t?.data?.spectra||[]){let{digitalFilter:r,fft:i,phaseCorrection:n}=qe(o);i?.flag&&r?.flag&&n&&Math.floor(r.value.digitalFilterValue)%2>0&&(n.value.ph0-=180)}return t}function qe(e,t=["phaseCorrection","fft","digitalFilter"]){let{filters:o=[]}=e,r={};for(let i of t)r[i]=o.find(n=>n.name===i);return r}function C(e,t="localStorage"){if(e?.version===7)return e;if(t==="nmrium")return ae(e);let o={...e,version:7};for(let r in e.workspaces)o.workspaces[r]=ae(o.workspaces[r]);return o}function ae(e){let{formatting:{nuclei:t,panels:o}={nuclei:null,panels:null},version:r,...i}=e,n={...i};return t&&(n.nuclei=He(t)),o&&(n.panels=o),n}function He(e){let t=[],o={name:"nucleus",ppm:"ppmFormat",hz:"hzFormat"};for(let r in e)t.push(b(e[r],o));return t}function q(e){if(e?.version===7)return e;let t={...e,version:7};return t?.settings&&(t.settings=C(t.settings,"nmrium")),t}function A(e,t="localStorage"){if(e?.version===8)return e;if(t==="nmrium")return le(e);let o={...e,version:8};for(let r in e.workspaces)o.workspaces[r]=le(o.workspaces[r]);return o}function le(e){let{version:t,...o}=e,r={...o};return r.display.panels=Qe(e),r}function Qe(e){let t={},o=e.display.panels;for(let r of Object.keys(o)){let{display:i,open:n}=o[r];t[r]={display:i,visible:i,open:n}}return t}function H(e){if(e?.version===8)return e;let t={...e,version:8};t?.settings&&(t.settings=A(t.settings,"nmrium"));for(let o of t?.data?.spectra||[]){let{filters:r=[]}=o;for(let s=0;s<r.length;s++){let{flag:l,isDeleteAllow:a,label:p,...m}=r[s];r[s]={...m,enabled:l}}let i=r.findIndex(s=>s.name==="apodization");if(i!==-1){let s=r[i],{lineBroadening:l,gaussBroadening:a,lineBroadeningCenter:p}=s.value;s.value={exponential:{apply:!0,options:{lineBroadening:a>0?-l:l}}},a>0&&(s.value.gaussian={apply:!0,options:{lineBroadening:.6*a,lineBroadeningCenter:p}}),r[i]=s}let n=r.findIndex(s=>s.name==="apodizationDimension1"),c=r.findIndex(s=>s.name==="apodizationDimension2");if(n!==-1){let s=r[n],{shapes:l}=s.value.compose;s.value=ce(l)}if(c!==-1){let s=r[c],{shapes:l}=s.value.compose;s.value=ce(l)}}return t}function ce(e){let t={};for(let{shape:o}of e){let{kind:r,options:i}=o;if(r==="sineBell"){let{exponent:n,offset:c}=i,s=n===2?"sineSquare":"sineBell";t[s]={apply:!0,options:{offset:c}}}}return t}function Q(e){let{version:t,plugins:o,...r}=e;return t===9?e:{version:9,plugins:{},...r}}function ee(e){if(e?.version>=10)return e;let t={...e,version:10};if(e.data){let{source:o,spectra:r,...i}=e.data,n=o?x():void 0,c=o?[{...o,id:n}]:[];t.data={...i,sources:c,spectra:o?r?.map(s=>({...s,sourceId:n})):r}}return t}function te(e){let{version:t}=e;if(t>=11)return e;let o={...e,version:11};return e?.view?.molecules&&(o.view=et(e.view)),o}function et(e){let{molecules:t,...o}=e,r={};for(let[i,n]of Object.entries(t)){let{showAtomNumber:c,...s}=n;r[i]={...s,atomAnnotation:"none",showLabel:!1}}return{molecules:r,...o}}function re(e){if(e?.version>=12)return e;let t={...e,version:12};if(t.data){let o=e.data.spectra??[],r=e.data.molecules??[];for(let i of o){let{sourceId:n,fileCollectionId:c,sourceSelector:s}=i;delete i.sourceId,delete i.fileCollectionId,delete i.sourceSelector,s&&(i.selector={...s,root:c??n})}for(let i of r){let{sourceId:n,fileCollectionId:c,sourceSelector:s}=i;delete i.sourceId,delete i.fileCollectionId,delete i.sourceSelector,s&&(i.selector={...s,root:c??n})}}return t}function oe(e){if(e?.version>=13)return e;let t={...e,version:13};if(t.data){let o=e.data.spectra??[];for(let r of o){let i=r.ranges?.values??[];for(let n of i){let{diaIDs:c,assignment:s,nbAtoms:l,signals:a=[]}=n,p=a.some(m=>m.diaIDs&&m.diaIDs.length>0);for(let m of a)!p&&c&&l&&(m.diaIDs=c,m.nbAtoms=l),!m.assignment&&s&&(m.assignment=s);delete n.diaIDs,delete n.assignment,delete n.nbAtoms}}}return t}function I(e,t){e.plugins||(e.plugins={});let o=e.plugins;for(let r of t.values()){if(!r.shouldSerialize){delete o[r.id];continue}o[r.id]||(o[r.id]={id:r.id,version:r.version}),o[r.id].id=r.id,o[r.id].version=r.version}}var tt=[X,Y,Z,$,G,J,q,H,Q,ee,te,re,oe];function ue(e,t,o){let r=structuredClone(e),i=Object.entries(e?.plugins??{});for(let[s,{version:l}]of i){let a=o.get(s);if(!(a&&a.version>=l)){if(a){console.warn(`Plugin "${a.id}" is loaded with a version older (${a.version}) than the one used to save the state (${l}).
1
+ var we={NORMAL:"NORMAL",FORMULA:"FORMULA"};var Ae={RELATIVE:"relative",ABSOLUTE:"absolute",MIN:"min",MAX:"max"};var Fe=[{name:"pixels",unit:"px"},{name:"inches",unit:"in"},{name:"feet",unit:"ft"},{name:"yards",unit:"yd"},{name:"centimeters",unit:"cm"},{name:"millimeters",unit:"mm"},{name:"meters",unit:"m"},{name:"points",unit:"pt"},{name:"picas",unit:"pc"}];var b=14;var Te=[{key:"CT",description:"CT from NMR Solutions"}];import{isAnyArray as Le}from"is-any-array";import{xMultiply as B}from"ml-spectra-processing";var Ee=crypto.randomUUID.bind(crypto),x=Ee;function O(e){let{id:t=x(),meta:o,peaks:r={},filters:i=[],info:n={},ranges:c={},integrals:s={},selector:l,sourceId:a,dependentVariables:p=[],...m}=e,u={id:t,meta:o,filters:i},{data:f=ze(p[0]?.components??[])}=e;if(Array.isArray(n.nucleus)&&(n.nucleus=n.nucleus[0]),u.data={x:[],re:[],im:[],...f},"scaleFactor"in n){let{scaleFactor:g}=n,{re:S,im:y}=u.data;B(S,g,{output:S}),y&&B(y,g,{output:y})}l&&(u.selector=l),a&&(u.sourceId=a,u.fileCollectionId=a);let d=Le(f.im);if(u.info={phc0:0,phc1:0,nucleus:"1H",isFid:!1,isComplex:d,dimension:1,name:n?.name||t,...n},n.isFid&&n.reverse&&d){let{im:g}=u.data;B(g,-1,{output:g}),u.info.reverse=!1}return u.display={isVisible:!0,isPeaksMarkersVisible:!0,isRealSpectrumVisible:!0,isVisibleInDomain:!0,...e.display},u.peaks={values:[],options:{},...r},u.ranges={values:[],options:{sum:null,isSumConstant:!0,sumAuto:!0},...c},u.integrals={values:[],options:{},...s},{...m,...u}}function ze(e){let t=e[0]?.data?.x||[],o=e[0]?.data?.re||e[0]?.data?.y||[],r=e[0]?.data?.im||e[1]?.data?.y||null;return t.length>0&&t[0]>t[1]&&(t.reverse(),o.reverse(),r&&r.reverse()),{x:t,re:o,im:r}}import{matrixToArray as ke,xMinMaxValues as Ue,xNoiseSanPlot as Ve}from"ml-spectra-processing";var K={z:[[]],minX:0,minY:0,maxX:0,maxY:0},je={re:K,im:K},_e={rr:K};function M(e){let{id:t=x(),meta:o={},dependentVariables:r=[],info:i={},filters:n=[],zones:c=[],sourceId:s,...l}=e,a={id:t,meta:o,filters:n};s&&(a.sourceId=s,a.fileCollectionId=s),a.info={nucleus:["1H","1H"],isFid:!1,isComplex:!1,name:i?.name||x(),...i},a.originalInfo=structuredClone(a.info),a.display={isPositiveVisible:!0,isNegativeVisible:!0,isVisible:!0,dimension:2,...e.display};let{data:p=r[0]?.components??{}}=e;if(a.data={...a.info.isFid?je:_e,...p},a.originalData=structuredClone(a.data),!("spectrumSize"in i)){let m=i.isFid?"re":"rr",u=a.data[m].z.length,f=u>0?a.data[m].z[0].length:0;a.info.spectrumSize=[f,u]}if(!i.isFid){let m=a.data.rr,u=ke(m.z),{positive:f,negative:d}=Ve(u),{min:g,max:S}=Ue(u);a.data.rr={...m,minZ:g,maxZ:S},a.info.noise={positive:f,negative:d}}return a.zones={values:[],options:{},...c},{...l,...a}}import{xSequentialFillFromTo as Ke}from"ml-spectra-processing";import{isAnyArray as Be}from"is-any-array";function W(e,t=0){if(Be(e)){let o=e.at(t);if(o!==void 0)return o;throw new RangeError("An array with a index out of boundaries")}return e}var We=new Set(["t1ir","T1"]);function ae(e){let t=[];for(let o of e){let{info:{pulseSequence:r,isFid:i}}=o,{data:n,info:c,meta:{vdlistValues:s=[]}={}}=o;if(!(r&&We.has(r))||s.length===0){t.push(o);continue}let a=i?"re":"rr",p={};for(let y in c)p[y]=W(c[y]);let{z:m,maxX:u,minX:f}=n[a],d=Ke({from:f,to:u,size:m[0].length}),[g,S]=Ye(o);for(let y=0;y<s.length;y++){let P={re:d,x:d};for(let h in n)P[Xe(h)]=n[h].z.at(g*(y+S));t.push(O({data:P,info:{...p,name:`${p.name}_${s[y]}`,dimension:1,vd:s[y]}}))}}return t}function Xe(e){return["rr","re"].includes(e)?"re":["im","ri","ir","ii"].includes(e)?"im":"x"}function Ye(e){let{meta:{PAGE:t}}=e,o=!0;if(t){let r=i=>Number.parseFloat(i.replace(/[F|T]1=/,""));o=r(t[0])>r(t[2])}return o?[-1,1]:[1,0]}var Ze=2,$e=1;function Ge(e){let{spectra:t=[],molecules:o}=e,r=[];for(let i of t){let{info:n}=i;switch(n.dimension){case $e:r.push(O(i));break;case Ze:r.push(M(i));break;default:throw new Error("dimension does not supported")}}return{molecules:o,spectra:ae(r)}}function Je(e){return e}function N(e,t){return JSON.parse(JSON.stringify(e),function(r,i){if(r in t){this[t[r]]=i;return}return i})}function X(e){if(e?.version===1)return e;let t={...e,version:1},o={j:"js",signal:"signals",integral:"integration",peak:"peaks",diaID:"diaIDs"};for(let r of t.spectra){if(r.ranges){let i=N(r.ranges,o);r.ranges=Array.isArray(i)?{values:i}:i}else if(r.zones){let i=N(r.zones,o);r.zones=Array.isArray(i)?{values:i}:i}r.peaks&&(r.peaks=Array.isArray(r.peaks)?{values:r.peaks}:r.peaks),r.integrals&&(r.integrals=Array.isArray(r.integrals)?{values:r.integrals}:r.integrals)}return t}function Y(e){if(e?.version===2)return e;let t={...e,version:2},o={peaks:{delta:"x",originDelta:"originalX",intensity:"y"},ranges:{atomIDs:"atoms",intensity:"y"}};for(let r of t.spectra)r.peaks?r.peaks=N(r.peaks,o.peaks):r.ranges?r.ranges=N(r.ranges,o.ranges):r.zones&&(r.zones.values=qe(r.zones.values));return t}function qe(e){return e.map(t=>(t.signals&&(t.signals=t.signals.map(o=>{if(o.x&&o.y){let{x:{fromTo:r,...i},y:{fromTo:n,...c}}=o;o={...o,x:{...i,...r},y:{...c,...n}}}else{let{fromTo:r,deltaX:i,resolutionX:n,nucleusX:c,deltaY:s,resolutionY:l,nucleusY:a,shiftX:p,shiftY:m,...u}=o;o={...u,x:{from:r[0].from,to:r[0].to,delta:i,resolution:n,nucleus:c},y:{from:r[1].from,to:r[1].to,delta:s,resolution:l,nucleus:a}}}return o},[])),t),[])}var He={name:"apodization",label:"Apodization",value:{lineBroadening:1,gaussBroadening:0,lineBroadeningCenter:0}};function Z(e){if(e?.version===3)return e;let t={...e,version:3};for(let o of t.spectra)if(Array.isArray(o?.filters)&&o?.filters.length>0){let r=o.filters.findIndex(i=>i.name==="lineBroadening");if(r!==-1){let i={...o.filters[r],...He};o.filters[r]=o.filters[r-1],o.filters[r-1]=i}}return t}function $(e){if(e?.version===4)return e;let{version:t,...o}=e,r=[],i={};for(let{source:s,...l}of o.spectra){let a={},{info:p={},display:m={}}=l;if(p?.dimension===2&&!s?.jcampURL)if(p.isFt)a.data={rr:l.data};else continue;if(s?.jcampURL){let{jcampURL:d,jcampSpectrumIndex:g}=s,S=d.match(/(?<baseURL>^\w+:\/{2}\w+\/)(?<relativePath>.*)/);i[d]||(i[d]={baseURL:S?.groups.baseURL||"",relativePath:S?.groups.relativePath||d.replace(/^\.\//,"")}),a.sourceSelector={files:[i[d].relativePath]},g!==void 0&&(a.sourceSelector.jcamp={index:g})}a.filters=Qe(l.filters);let{name:u,...f}=m;u&&(a.info={...p,name:u}),a.display=f,r.push({...l,...a})}let n={data:{...o,spectra:r},version:4},c={entries:Object.values(i)};return c.entries.length>0&&(n.data.source=c),n}function Qe(e=[]){let t=[];for(let o of e){let{name:r,value:i}=o;switch(r){case"zeroFilling":t.push({...o,value:{nbPoints:i}});break;case"shiftX":case"shift2DX":case"shift2DY":t.push({...o,value:{shift:i}});break;default:t.push({...o})}}return t}function G(e){if(e?.version===5)return e;let t={...e,version:5},o={originFrom:"originalFrom",originTo:"originalTo",originDelta:"originalDelta",originX:"originalX",originY:"originalY",originZ:"originalZ"};for(let r of t?.data?.spectra||[])for(let i of["peaks","ranges","zones"])r?.[i]&&(r[i]=N(r[i],o));return t}function J(e){if(e?.version===6)return e;let t={...e,version:6};for(let o of t?.data?.spectra||[]){let{digitalFilter:r,fft:i,phaseCorrection:n}=et(o);i?.flag&&r?.flag&&n&&Math.floor(r.value.digitalFilterValue)%2>0&&(n.value.ph0-=180)}return t}function et(e,t=["phaseCorrection","fft","digitalFilter"]){let{filters:o=[]}=e,r={};for(let i of t)r[i]=o.find(n=>n.name===i);return r}function C(e,t="localStorage"){if(e?.version===7)return e;if(t==="nmrium")return le(e);let o={...e,version:7};for(let r in e.workspaces)o.workspaces[r]=le(o.workspaces[r]);return o}function le(e){let{formatting:{nuclei:t,panels:o}={nuclei:null,panels:null},version:r,...i}=e,n={...i};return t&&(n.nuclei=tt(t)),o&&(n.panels=o),n}function tt(e){let t=[],o={name:"nucleus",ppm:"ppmFormat",hz:"hzFormat"};for(let r in e)t.push(N(e[r],o));return t}function q(e){if(e?.version===7)return e;let t={...e,version:7};return t?.settings&&(t.settings=C(t.settings,"nmrium")),t}function w(e,t="localStorage"){if(e?.version===8)return e;if(t==="nmrium")return ce(e);let o={...e,version:8};for(let r in e.workspaces)o.workspaces[r]=ce(o.workspaces[r]);return o}function ce(e){let{version:t,...o}=e,r={...o};return r.display.panels=rt(e),r}function rt(e){let t={},o=e.display.panels;for(let r of Object.keys(o)){let{display:i,open:n}=o[r];t[r]={display:i,visible:i,open:n}}return t}function H(e){if(e?.version===8)return e;let t={...e,version:8};t?.settings&&(t.settings=w(t.settings,"nmrium"));for(let o of t?.data?.spectra||[]){let{filters:r=[]}=o;for(let s=0;s<r.length;s++){let{flag:l,isDeleteAllow:a,label:p,...m}=r[s];r[s]={...m,enabled:l}}let i=r.findIndex(s=>s.name==="apodization");if(i!==-1){let s=r[i],{lineBroadening:l,gaussBroadening:a,lineBroadeningCenter:p}=s.value;s.value={exponential:{apply:!0,options:{lineBroadening:a>0?-l:l}}},a>0&&(s.value.gaussian={apply:!0,options:{lineBroadening:.6*a,lineBroadeningCenter:p}}),r[i]=s}let n=r.findIndex(s=>s.name==="apodizationDimension1"),c=r.findIndex(s=>s.name==="apodizationDimension2");if(n!==-1){let s=r[n],{shapes:l}=s.value.compose;s.value=ue(l)}if(c!==-1){let s=r[c],{shapes:l}=s.value.compose;s.value=ue(l)}}return t}function ue(e){let t={};for(let{shape:o}of e){let{kind:r,options:i}=o;if(r==="sineBell"){let{exponent:n,offset:c}=i,s=n===2?"sineSquare":"sineBell";t[s]={apply:!0,options:{offset:c}}}}return t}function Q(e){let{version:t,plugins:o,...r}=e;return t===9?e:{version:9,plugins:{},...r}}function ee(e){if(e?.version>=10)return e;let t={...e,version:10};if(e.data){let{source:o,spectra:r,...i}=e.data,n=o?x():void 0,c=o?[{...o,id:n}]:[];t.data={...i,sources:c,spectra:o?r?.map(s=>({...s,sourceId:n})):r}}return t}function te(e){let{version:t}=e;if(t>=11)return e;let o={...e,version:11};return e?.view?.molecules&&(o.view=ot(e.view)),o}function ot(e){let{molecules:t,...o}=e,r={};for(let[i,n]of Object.entries(t)){let{showAtomNumber:c,...s}=n;r[i]={...s,atomAnnotation:"none",showLabel:!1}}return{molecules:r,...o}}function re(e){if(e?.version>=12)return e;let t={...e,version:12};if(t.data){let o=e.data.spectra??[],r=e.data.molecules??[];for(let i of o){let{sourceId:n,fileCollectionId:c,sourceSelector:s}=i;delete i.sourceId,delete i.fileCollectionId,delete i.sourceSelector,s&&(i.selector={...s,root:c??n})}for(let i of r){let{sourceId:n,fileCollectionId:c,sourceSelector:s}=i;delete i.sourceId,delete i.fileCollectionId,delete i.sourceSelector,s&&(i.selector={...s,root:c??n})}}return t}function oe(e){if(e?.version>=13)return e;let t={...e,version:13};if(t.data){let o=e.data.spectra??[];for(let r of o){let i=r.ranges?.values??[];for(let n of i){let{diaIDs:c,assignment:s,nbAtoms:l,signals:a=[]}=n,p=a.some(m=>m.diaIDs&&m.diaIDs.length>0);for(let m of a)!p&&c&&l&&(m.diaIDs=c,m.nbAtoms=l),!m.assignment&&s&&(m.assignment=s);delete n.diaIDs,delete n.assignment,delete n.nbAtoms}}}return t}function ie(e){if(e?.version>=14)return e;let t={...e,version:14};if(e?.data?.spectra){let o=e.data.spectra??[],r={};for(let i of o){let{display:n={}}=i;if(!("contourOptions"in n))continue;let{contourOptions:c}=n;r[i.id]=c,delete i.display.contourOptions}Object.keys(r).length>0&&(t.view={...e.view,spectraContourLevels:r}),t.view&&delete t.view.zoom}return t}function I(e,t){e.plugins||(e.plugins={});let o=e.plugins;for(let r of t.values()){if(!r.shouldSerialize){delete o[r.id];continue}o[r.id]||(o[r.id]={id:r.id,version:r.version}),o[r.id].id=r.id,o[r.id].version=r.version}}var it=[X,Y,Z,$,G,J,q,H,Q,ee,te,re,oe,ie];function pe(e,t,o){let r=structuredClone(e),i=Object.entries(e?.plugins??{});for(let[s,{version:l}]of i){let a=o.get(s);if(!(a&&a.version>=l)){if(a){console.warn(`Plugin "${a.id}" is loaded with a version older (${a.version}) than the one used to save the state (${l}).
2
2
  NMRium may fail to load the state.
3
3
  Please update the plugin to the latest version.`);continue}console.warn(`Plugin "${s}@${l}" is not registered. NMRium may fail to load the state.
4
- Please consider open this file with the plugin installed.`)}}let n=new Set,c=()=>{let s=r.version;for(let l of o.values())for(let a of l.migrations){if(n.has(a)||s<a.minCore||a.maxCore&&s>a.maxCore)continue;if((r.plugins?.[l.id]?.version||0)===l.version)break;r=a.up(r),n.add(a)}};for(let s=e?.version||0;s<t;s++){let l=tt[s];r=l(r),c()}return c(),I(r,o),r}var rt=["topbar.right","topbar.about_us.modal"],ot=[],eo=[...rt,...ot],it={},ie={};nt(it,ie);function nt(e,t){for(let[o,r]of Object.entries(e))t[r]||(t[r]=[]),t[r]?.push(o)}function*pe(e){let{slot:t,plugins:o,supportedToDeprecatedSlots:r=ie}=e,i=r[t];for(let[n,c]of o.entries()){let s=c.ui;if(!s)continue;let l=s[t];if(l){yield[n,l];continue}if(i)for(let a of i){let p=c.ui?.[a];if(p){yield[n,p],console.warn(`Plugin ${c.id} used deprecated slot "${a}". Please update this plugin to use "${t}" instead.`);break}}}}import{FileCollection as ut}from"file-collection";var me={SDF:"sdf",MOL:"mol",NMRIUM:"nmrium",NMRIUM_ARCHIVE:"nmrium.zip",JSON:"json",JCAMP:"jcamp",DX:"dx",JDX:"jdx",JDF:"jdf",NMREDATA:"nmredata",SMILES:"smiles",SMI:"smi"};function w(e){return e.includes(".")?e.replace(/^.*\./,"").toLowerCase():""}function T(e,t={},o){let{data:r,...i}=e;if(!r)return e;let{spectra:n=[]}=r,{keep1D:c=!0,keep2D:s=!0,onlyReal:l}=t,a=l?"ft":t.dataSelection||"both",p=[];for(let m of n){if(!m.info){p.push(m);continue}let{isFid:u,dimension:f,name:d}=m.info;if(!F(f===1&&!c,d,o)&&!F(f===2&&!s,d,o)&&!F(u&&a==="ft",d,o)&&!F(!u&&a==="fid",d,o))if(l&&!u)if(m.info.isComplex=!1,st(m)){let{rr:g}=m.data;p.push({...m,data:{rr:g}})}else{let{re:g,x:S}=m.data;p.push({...m,data:{re:g,x:S}})}else p.push(m)}return{data:{...r,spectra:p},...i}}function F(e,t,o){return e?(o?.warn(`Skipping ${t} because it didn't match the import filters.`),!0):!1}function st(e){let{info:t}=e;return t?.dimension===2}function E(e){let{nmriumState:t,plugins:o,options:r}=e;for(let i of o.values()){let n=i.onReadProcess?.onProcessing;n&&n(t,r)}}async function L(e,t,o={}){let{selector:r,converter:i,logger:n}=o,c=[],s=[];for(let u of t.values()){let{onReadProcess:f}=u;f&&(f?.onFiles&&c.push(u),f?.supportedExtensions?.length&&f?.onFile&&s.push(u))}let l=await Promise.allSettled(c.map(u=>u.onReadProcess.onFiles(e,o))),a=[],p=await Promise.allSettled(e.files.flatMap(u=>{let f=w(u.name).toLowerCase();return s.flatMap(d=>{let{supportedExtensions:g,onFile:S}=d.onReadProcess;return g.includes(f)?(a.push({file:u,plugin:d}),S(u,{logger:n,selector:r,converter:i})):[]})})),m={spectra:[],molecules:[]};for(let u=0;u<l.length;u++){let f=l[u];switch(f.status){case"fulfilled":{let{spectra:d=[],molecules:g=[]}=f.value||{};m.spectra.push(...d),m.molecules.push(...g);break}case"rejected":{let d=f.reason,g=c[u];o.logger?.error(`Load file collection with plugin ${g.id}@${g.version} fails with: ${d}`);break}}}for(let u=0;u<p.length;u++){let f=p[u];switch(f.status){case"fulfilled":{let{spectra:d=[],molecules:g=[]}=f.value||{};m.spectra.push(...d),m.molecules.push(...g);break}case"rejected":{let d=f.reason,{file:g,plugin:S}=a[u];o.logger?.error(`Load file ${g.relativePath} with plugin ${S.id}@${S.version} fails with: ${d}`);break}}}return m}import{FileCollection as Se}from"file-collection";import{FileCollection as ge}from"file-collection";import fe from"lodash.merge";import{xIsEquallySpaced as at}from"ml-spectra-processing";async function z(e){let{input:t,spectraResult:o,unserializedSpectrum:r,options:i,plugins:n,migrator:c}=e,l=(await v({input:t,migrator:c,plugins:n,options:{...i,selector:r.selector}}))?.nmriumState?.data?.spectra??[],a=l.pop();if(a){o.push(de(r,a));for(let p of l)o.push(de(r,lt(p)))}}function de(e,t){let{data:o,...r}=e;if(!t.selector?.root&&e.selector?.root&&(t.selector??=e.selector,t.selector.root=e.selector.root),"ranges"in t){let{data:i,...n}=t;return{...fe(n,r),data:i}}else if("zones"in t){let{data:i,...n}=t;return{...fe(n,r),data:i}}else return t}function lt(e){return{...e,id:x()}}function k(e){let{spectrum:t,spectraResult:o,logger:r}=e,{dimension:i}=t.info;if(i===1){if(!at(t.data)){r?.error('The ".nmrium" file is corrupted; the X-axis values are not equally distant.');return}o.push(O(t))}else i===2&&o.push(M(t))}async function U(e){let{input:t,moleculesResult:o,unserializedMolecule:r,options:i,plugins:n,migrator:c}=e,{selector:s}=r,a=(await v({input:t,migrator:c,plugins:n,options:{...i,selector:s}}))?.nmriumState?.data?.molecules??[];for(let p of a)!p.selector?.root&&s?.root&&(p.selector??=s,p.selector.root=s.root),o.push({...r,...p})}function j(e){let{molecule:t,moleculesResult:o}=e;o.push(t)}async function V(e){let{nmriumObjectInput:t,options:o={},migrator:r,plugins:i,fromSourceOptions:n}=e,c=r(t),{data:s,...l}=c,a=new ge;if(!s)return[{...l},a];let p={data:{...s,spectra:[],molecules:[]},...l},m=p.data,{sources:u=[],spectra:f,molecules:d}=m,g=await Promise.all(u.map(async P=>{let h=await ge.fromSource(P,{unzip:{zipExtensions:["zip","nmredata"]}},n);if(!P.baseURL)for(let R of P.entries)R.baseURL||(R.baseURL=n?.baseURL);return[P.id,h]})),S=new Map(g),y=[];for(let P of s.spectra){let h=P.selector?.root??"",R=S.get(h);if(!R){k({spectrum:P,spectraResult:f,logger:o.logger});continue}y.push(z({input:R,spectraResult:f,unserializedSpectrum:P,migrator:r,plugins:i,options:o}))}for(let P of s.molecules??[]){let h=P.selector?.root??"",R=S.get(h);if(!R){j({molecule:P,moleculesResult:d,logger:o.logger});continue}y.push(U({input:R,unserializedMolecule:P,moleculesResult:d,migrator:r,plugins:i,options:o}))}await Promise.allSettled(y);for(let[P,h]of S.entries())a.appendFileCollection(h,P);return[p,a]}async function _(e){let{file:t,options:o={},migrator:r,plugins:i,fromSourceOptions:n}=e,c="byteLength"in t?t:await t.arrayBuffer(),s=Se.isZip(c)?await ct(c):new TextDecoder("utf-8").decode(c);return V({nmriumObjectInput:JSON.parse(s),plugins:i,migrator:r,options:o,fromSourceOptions:n})}async function ct(e){let t=await Se.fromZip(e);if(t.files.length===0)throw new Error("compressed nmrium file is corrupted");return t.files[0].text()}async function v(e){let{options:t={},input:o,migrator:r,plugins:i,fromSourceOptions:n}=e,{selectorRoot:c=x()}=t,s=ft(await pt(o),t.selector?.files),l=dt(s);if(l){let[d,g]=await _({file:l,migrator:r,plugins:i,options:t,fromSourceOptions:n});return{nmriumState:d,containsNmrium:!0,fileCollection:g,selectorRoot:c}}let a=await L(s,i,t),p=T({version:13,data:a},t?.selector?.general,t.logger),{onLoadProcessing:m,experimentalFeatures:u}=t,f={...m,autoProcessing:m?.autoProcessing??!1,experimentalFeatures:u};return E({nmriumState:p,plugins:i,options:f}),gt(p,c),{nmriumState:p,containsNmrium:!1,fileCollection:s,selectorRoot:c}}function pt(e){return Array.isArray(e)?Promise.reject(new Error("For a set of fileCollectionItems pass a FileCollection instance")):mt(e)?Promise.resolve(e):new ut().appendExtendedSource({...e,uuid:x()})}function mt(e){return typeof e=="object"&&"files"in e}function ft(e,t){if(!t)return e;let o=new Set(t);return e.filter(r=>o.has(r.relativePath))}function dt(e){return e.files.find(t=>w(t.name).toLowerCase()===me.NMRIUM)}function gt(e,t){for(let o of e.data?.spectra??[])o.selector?.root||(o.selector??={root:t},o.selector.root||=t);for(let o of e.data?.molecules??[])o.selector?.root||(o.selector??={root:t},o.selector.root||=t)}import{FileCollection as yt}from"file-collection";async function ye(e){let t={},o=[];for(let r of e.sources)switch(r.relativePath){case"META-INF/NMRIUM_ARCHIVE":t.archive=r;break;case"META-INF/VERSION":o.push(r.text().then(i=>{t.version=Number.parseInt(i,10)}));break;case"state.json":o.push(r.text().then(i=>{t.state=JSON.parse(i)}));break;default:}return await Promise.all(o),t}function Pe(e){if(!e.archive)throw new Error("Not a valid NMRium archive");if(typeof e.version!="number"||Number.isNaN(e.version))throw new Error("Not a valid NMRium archive, no version specified");if(e.version===0)throw new Error("NMRium Archive generated behind experimental flag are not supported.");if(!e.state)throw new Error("NMRium Archive corrupted, state.json is missing")}function xe(e){return e.filter(t=>!St(t.relativePath))}function St(e){return e.startsWith("META-INF/")||e==="state.json"||e==="index.txt"}async function he(e){let{options:t,plugins:o,migrator:r}=e,i=await yt.fromIum(e.input),n=await ye(i);Pe(n);let c=xe(i),s=r(n.state),l={...s,data:{...s.data,spectra:[],molecules:[]}},a=l.data.spectra,p=l.data.molecules,m=s.data?.spectra??[],u=s.data?.molecules??[],f=Pt(i),d=[];for(let g of m)d.push(xt({subRoots:f,unserializedSpectrum:g,spectraResult:a,options:t,plugins:o,migrator:r}));for(let g of u)d.push(ht({subRoots:f,unserializedMolecule:g,moleculesResult:p,options:t,plugins:o,migrator:r}));return await Promise.allSettled(d),[l,c]}function Pt(e){let t=new Map;return{get(o){let r=t.get(o);return r||(r=e.subroot(o),t.set(o,r)),r},[Symbol("debug")]:{ium:e,views:t}}}async function xt(e){let{subRoots:t}=e,{unserializedSpectrum:o,spectraResult:r}=e,{options:i,plugins:n,migrator:c}=e,{selector:s}=o,l=await Ne({subRoots:t,selector:s});if(!l)return k({spectrum:o,spectraResult:r,logger:i?.logger});await z({input:l,unserializedSpectrum:o,spectraResult:r,options:i,plugins:n,migrator:c})}async function ht(e){let{subRoots:t}=e,{unserializedMolecule:o,moleculesResult:r}=e,{options:i,plugins:n,migrator:c}=e,{selector:s}=o,l=await Ne({subRoots:t,selector:s});if(!l)return j({molecule:o,moleculesResult:r,logger:i?.logger});await U({input:l,unserializedMolecule:o,moleculesResult:r,options:i,plugins:n,migrator:c})}async function Ne(e){let{subRoots:t,selector:o}=e;if(!o)return;let{root:r}=o;if(r)return t.get(r)}import{FileCollection as Nt}from"file-collection";async function be(e){let{source:t,plugins:o,options:r={},sourceId:i=x()}=e,{converter:n,...c}=r,s={...t,id:i},l={spectra:[],molecules:[]},a=await Nt.fromSource(s,{unzip:{zipExtensions:["zip","nmredata"]}}),{spectra:p=[],molecules:m=[]}=await L(a,o,{converter:{...n,bruker:{keepFiles:!0,...Reflect.get(n??{},"bruker")}},...c});l.spectra.push(...p),l.molecules.push(...m);for(let g of l.spectra)g.selector??={root:i},g.selector.root=i;for(let g of l.molecules)g.selector??={root:i},g.selector.root=i;l.sources??=[],l.sources.push(s);let u=T({version:13,data:l},r?.selector?.general),{onLoadProcessing:f}=c,d={filters:f?.filters,autoProcessing:f?.autoProcessing??!1,experimentalFeatures:r.experimentalFeatures};return E({nmriumState:u,plugins:o,options:d}),[u,a,i]}function D(e,t){let o={};for(let r in e)t.includes(r)||(o[r]=e[r]);return o}var bt=["data","originalData","info","originalInfo","meta","customInfo"],Rt=["data","originalData","info","originalInfo","meta","customInfo"],Ot=["selector","originalData","originalInfo"];function Re(e,t,o={}){let{version:r,data:i}=e;if(i.actionType)return e;let n={version:r,plugins:e.plugins},{includeData:c,forceRawSpectra:s=[]}=o;c!=="noData"&&(n.data=It({...i},c,s));let{includeSettings:l,includeView:a}=o;return l&&(n.settings=e.settings),a&&(n.view=e.view),I(n,t),n}function It(e,t="rawData",o){let{spectra:r}=e;switch(t){case"dataSource":return vt(e);case"selfContained":case"selfContainedExternalDatasource":return Dt(e,o);case"rawData":return{...D(e,["sources"]),spectra:r.map(Oe)};default:return e}}function vt(e){let{spectra:t}=e;if(!e.sources)throw new Error("sources property should exists for dataSource serialization");return{...e,spectra:t.map(Mt)}}function Dt(e,t){let{spectra:o,sources:r,...i}=e;return{...i,spectra:o.map(n=>Ct(n,t))}}function Mt(e){return D(e,bt)}function Ct(e,t){return!("selector"in e)||t?.includes(e.id)?Oe(e):D(e,Rt)}function Oe(e){let{data:t,info:o,originalData:r,originalInfo:i}=e,n=D(e,Ot);return n.data=r||t,n.info=i||o,n}import{FileCollection as At}from"file-collection";async function Ie(e,t){let{state:o,aggregator:r,externalData:i="embedded",includeData:n=!0,includeSettings:c,includeView:s}=t,{spectra:l,molecules:a}=o.data,p=new At({filter:{ignoreDotfiles:!1}});return n&&p.appendFileCollection(r),p.toIum({includeData:i==="embedded",mimetype:"chemical/x-nmrium+zip",*getExtraFiles(m){yield{relativePath:"META-INF/NMRIUM_ARCHIVE",data:""},yield{relativePath:"META-INF/VERSION",data:"1"},yield{relativePath:"state.json",data:wt(e,o,r,{externalData:i,includeData:n,includeView:s,includeSettings:c})},yield{relativePath:"index.txt",data:Ft({aggregator:r,spectra:l,molecules:a,index:m})}}})}function wt(e,t,o,r){let{includeData:i,includeView:n,includeSettings:c,externalData:s="embedded"}=r,l="noData";i&&(l=s==="embedded"?"selfContained":"selfContainedExternalDatasource");let a=[];if(l!=="noData")for(let u of t.data?.spectra??[]){let f=u.selector?.root;f&&o.subroot(f).files.length>0||a.push(u.id)}let p=e(t,{includeData:l,includeView:n,includeSettings:c,forceRawSpectra:a}),m=JSON.stringify(p,(u,f)=>ArrayBuffer.isView(f)?Array.from(f):f,2);return new Blob([m],{type:"application/json"})}function Ft(e){let{aggregator:t,spectra:o,molecules:r,index:i}=e,n=new Map,c=new Map(i.sources.map(l=>[l.uuid,l]));for(let l of o){let a=l.selector?.root;a&&(n.has(a)||n.set(a,t.subroot(a)))}for(let l of r){let a=l.selector?.root;a&&(n.has(a)||n.set(a,t.subroot(a)))}let s=[];for(let[l,a]of n.entries()){let p=new Map(a.sources.map(u=>[u.uuid,u])),m=`data/${l}/`;s.push(m);for(let u of a.files){let f=c.get(u.sourceUUID),d=p.get(u.sourceUUID),g=f?.baseURL?.startsWith("ium:/")?"embedded":"linked",y=i.paths[u.sourceUUID]?.replace(m,""),P=u.relativePath.replace(d?.relativePath??"",""),h=y?y+P:u.relativePath;s.push(` ${h} (${g})`)}s.push(`
4
+ Please consider open this file with the plugin installed.`)}}let n=new Set,c=()=>{let s=r.version;for(let l of o.values())for(let a of l.migrations){if(n.has(a)||s<a.minCore||a.maxCore&&s>a.maxCore)continue;if((r.plugins?.[l.id]?.version||0)===l.version)break;r=a.up(r),n.add(a)}};for(let s=e?.version||0;s<t;s++){let l=it[s];r=l(r),c()}return c(),I(r,o),r}var nt=["topbar.right","topbar.about_us.modal"],st=[],oo=[...nt,...st],at={},ne={};lt(at,ne);function lt(e,t){for(let[o,r]of Object.entries(e))t[r]||(t[r]=[]),t[r]?.push(o)}function*me(e){let{slot:t,plugins:o,supportedToDeprecatedSlots:r=ne}=e,i=r[t];for(let[n,c]of o.entries()){let s=c.ui;if(!s)continue;let l=s[t];if(l){yield[n,l];continue}if(i)for(let a of i){let p=c.ui?.[a];if(p){yield[n,p],console.warn(`Plugin ${c.id} used deprecated slot "${a}". Please update this plugin to use "${t}" instead.`);break}}}}import{FileCollection as Pe}from"file-collection";var fe={SDF:"sdf",MOL:"mol",NMRIUM:"nmrium",NMRIUM_ARCHIVE:"nmrium.zip",JSON:"json",JCAMP:"jcamp",DX:"dx",JDX:"jdx",JDF:"jdf",NMREDATA:"nmredata",SMILES:"smiles",SMI:"smi"};function A(e){return e.includes(".")?e.replace(/^.*\./,"").toLowerCase():""}function T(e,t={},o){let{data:r,...i}=e;if(!r)return e;let{spectra:n=[]}=r,{keep1D:c=!0,keep2D:s=!0,onlyReal:l}=t,a=l?"ft":t.dataSelection||"both",p=[];for(let m of n){if(!m.info){p.push(m);continue}let{isFid:u,dimension:f,name:d}=m.info;if(!F(f===1&&!c,d,o)&&!F(f===2&&!s,d,o)&&!F(u&&a==="ft",d,o)&&!F(!u&&a==="fid",d,o))if(l&&!u)if(m.info.isComplex=!1,ct(m)){let{rr:g}=m.data;p.push({...m,data:{rr:g}})}else{let{re:g,x:S}=m.data;p.push({...m,data:{re:g,x:S}})}else p.push(m)}return{data:{...r,spectra:p},...i}}function F(e,t,o){return e?(o?.warn(`Skipping ${t} because it didn't match the import filters.`),!0):!1}function ct(e){let{info:t}=e;return t?.dimension===2}function E(e){let{nmriumState:t,plugins:o,options:r}=e;for(let i of o.values()){let n=i.onReadProcess?.onProcessing;n&&n(t,r)}}async function L(e,t,o={}){let{selector:r,converter:i,logger:n}=o,c=[],s=[];for(let u of t.values()){let{onReadProcess:f}=u;f&&(f?.onFiles&&c.push(u),f?.supportedExtensions?.length&&f?.onFile&&s.push(u))}let l=await Promise.allSettled(c.map(u=>u.onReadProcess.onFiles(e,o))),a=[],p=await Promise.allSettled(e.files.flatMap(u=>{let f=A(u.name).toLowerCase();return s.flatMap(d=>{let{supportedExtensions:g,onFile:S}=d.onReadProcess;return g.includes(f)?(a.push({file:u,plugin:d}),S(u,{logger:n,selector:r,converter:i})):[]})})),m={spectra:[],molecules:[]};for(let u=0;u<l.length;u++){let f=l[u];switch(f.status){case"fulfilled":{let{spectra:d=[],molecules:g=[]}=f.value||{};m.spectra.push(...d),m.molecules.push(...g);break}case"rejected":{let d=f.reason,g=c[u];o.logger?.error(`Load file collection with plugin ${g.id}@${g.version} fails with: ${d}`);break}}}for(let u=0;u<p.length;u++){let f=p[u];switch(f.status){case"fulfilled":{let{spectra:d=[],molecules:g=[]}=f.value||{};m.spectra.push(...d),m.molecules.push(...g);break}case"rejected":{let d=f.reason,{file:g,plugin:S}=a[u];o.logger?.error(`Load file ${g.relativePath} with plugin ${S.id}@${S.version} fails with: ${d}`);break}}}return m}import{FileCollection as ye}from"file-collection";import{FileCollection as Se}from"file-collection";import de from"lodash.merge";import{xIsEquallySpaced as ut}from"ml-spectra-processing";async function z(e){let{input:t,spectraResult:o,unserializedSpectrum:r,options:i,plugins:n,migrator:c}=e,l=(await v({input:t,migrator:c,plugins:n,options:{...i,selector:r.selector}}))?.state?.data?.spectra??[],a=l.pop();if(a){o.push(ge(r,a));for(let p of l)o.push(ge(r,pt(p)))}}function ge(e,t){let{data:o,...r}=e;if(!t.selector?.root&&e.selector?.root&&(t.selector??=e.selector,t.selector.root=e.selector.root),"ranges"in t){let{data:i,...n}=t;return{...de(n,r),data:i}}else if("zones"in t){let{data:i,...n}=t;return{...de(n,r),data:i}}else return t}function pt(e){return{...e,id:x()}}function k(e){let{spectrum:t,spectraResult:o,logger:r}=e,{dimension:i}=t.info;if(i===1){if(!ut(t.data)){r?.error('The ".nmrium" file is corrupted; the X-axis values are not equally distant.');return}o.push(O(t))}else i===2&&o.push(M(t))}async function U(e){let{input:t,moleculesResult:o,unserializedMolecule:r,options:i,plugins:n,migrator:c}=e,{selector:s}=r,a=(await v({input:t,migrator:c,plugins:n,options:{...i,selector:s}}))?.state?.data?.molecules??[];for(let p of a)!p.selector?.root&&s?.root&&(p.selector??=s,p.selector.root=s.root),o.push({...r,...p})}function V(e){let{molecule:t,moleculesResult:o}=e;o.push(t)}async function j(e){let{nmriumObjectInput:t,options:o={},migrator:r,plugins:i,fromSourceOptions:n}=e,c=r(t),{data:s,...l}=c,a=new Se;if(!s)return{state:l,aggregator:a,containsNmrium:!0};let p={data:{...s,spectra:[],molecules:[]},...l},m=p.data,{sources:u=[],spectra:f,molecules:d}=m,g=await Promise.all(u.map(async P=>{let h=await Se.fromSource(P,{unzip:{zipExtensions:["zip","nmredata"]}},n);if(!P.baseURL)for(let R of P.entries)R.baseURL||(R.baseURL=n?.baseURL);return[P.id,h]})),S=new Map(g),y=[];for(let P of s.spectra){let h=P.selector?.root??"",R=S.get(h);if(!R){k({spectrum:P,spectraResult:f,logger:o.logger});continue}y.push(z({input:R,spectraResult:f,unserializedSpectrum:P,migrator:r,plugins:i,options:o}))}for(let P of s.molecules??[]){let h=P.selector?.root??"",R=S.get(h);if(!R){V({molecule:P,moleculesResult:d,logger:o.logger});continue}y.push(U({input:R,unserializedMolecule:P,moleculesResult:d,migrator:r,plugins:i,options:o}))}await Promise.allSettled(y);for(let[P,h]of S.entries())a.appendFileCollection(h,P);return{state:p,aggregator:a,containsNmrium:!0}}async function _(e){let{file:t,options:o={},migrator:r,plugins:i,fromSourceOptions:n}=e,c="byteLength"in t?t:await t.arrayBuffer(),s=ye.isZip(c)?await mt(c):new TextDecoder("utf-8").decode(c);return j({nmriumObjectInput:JSON.parse(s),plugins:i,migrator:r,options:o,fromSourceOptions:n})}async function mt(e){let t=await ye.fromZip(e);if(t.files.length===0)throw new Error("compressed nmrium file is corrupted");return t.files[0].text()}async function v(e){let{options:t={},input:o,migrator:r,plugins:i,fromSourceOptions:n}=e,{selectorRoot:c=x()}=t,s=gt(await ft(o),t.selector?.files),l=St(s);if(l)return await _({file:l,migrator:r,plugins:i,options:t,fromSourceOptions:n});let a=await L(s,i,t),p=T({version:14,data:a},t?.selector?.general,t.logger),{onLoadProcessing:m,experimentalFeatures:u}=t,f={...m,autoProcessing:m?.autoProcessing??!1,experimentalFeatures:u};E({nmriumState:p,plugins:i,options:f}),yt(p,c);let d=new Pe().appendFileCollection(s,c);return{state:p,aggregator:d,containsNmrium:!1}}function ft(e){return Array.isArray(e)?Promise.reject(new Error("For a set of fileCollectionItems pass a FileCollection instance")):dt(e)?Promise.resolve(e):new Pe().appendExtendedSource({...e,uuid:x()})}function dt(e){return typeof e=="object"&&"files"in e}function gt(e,t){if(!t)return e;let o=new Set(t);return e.filter(r=>o.has(r.relativePath))}function St(e){return e.files.find(t=>A(t.name).toLowerCase()===fe.NMRIUM)}function yt(e,t){for(let o of e.data?.spectra??[])o.selector?.root||(o.selector??={root:t},o.selector.root||=t);for(let o of e.data?.molecules??[])o.selector?.root||(o.selector??={root:t},o.selector.root||=t)}import{FileCollection as xt}from"file-collection";async function xe(e){let t={},o=[];for(let r of e.sources)switch(r.relativePath){case"META-INF/NMRIUM_ARCHIVE":t.archive=r;break;case"META-INF/VERSION":o.push(r.text().then(i=>{t.version=Number.parseInt(i,10)}));break;case"state.json":o.push(r.text().then(i=>{t.state=JSON.parse(i)}));break;default:}return await Promise.all(o),t}function he(e){if(!e.archive)throw new Error("Not a valid NMRium archive");if(typeof e.version!="number"||Number.isNaN(e.version))throw new Error("Not a valid NMRium archive, no version specified");if(e.version===0)throw new Error("NMRium Archive generated behind experimental flag are not supported.");if(!e.state)throw new Error("NMRium Archive corrupted, state.json is missing")}function be(e){return e.filter(t=>!Pt(t.relativePath))}function Pt(e){return e.startsWith("META-INF/")||e==="state.json"||e==="index.txt"}async function Ne(e){let{options:t,plugins:o,migrator:r}=e,i=await xt.fromIum(e.input),n=await xe(i);he(n);let c=be(i),s=r(n.state),l={...s,data:{...s.data,spectra:[],molecules:[]}},a=l.data.spectra,p=l.data.molecules,m=s.data?.spectra??[],u=s.data?.molecules??[],f=ht(i),d=[];for(let g of m)d.push(bt({subRoots:f,unserializedSpectrum:g,spectraResult:a,options:t,plugins:o,migrator:r}));for(let g of u)d.push(Nt({subRoots:f,unserializedMolecule:g,moleculesResult:p,options:t,plugins:o,migrator:r}));return await Promise.allSettled(d),{state:l,aggregator:c,containsNmrium:!0}}function ht(e){let t=new Map;return{get(o){let r=t.get(o);return r||(r=e.subroot(o),t.set(o,r)),r},[Symbol("debug")]:{ium:e,views:t}}}async function bt(e){let{subRoots:t}=e,{unserializedSpectrum:o,spectraResult:r}=e,{options:i,plugins:n,migrator:c}=e,{selector:s}=o,l=await Re({subRoots:t,selector:s});if(!l)return k({spectrum:o,spectraResult:r,logger:i?.logger});await z({input:l,unserializedSpectrum:o,spectraResult:r,options:i,plugins:n,migrator:c})}async function Nt(e){let{subRoots:t}=e,{unserializedMolecule:o,moleculesResult:r}=e,{options:i,plugins:n,migrator:c}=e,{selector:s}=o,l=await Re({subRoots:t,selector:s});if(!l)return V({molecule:o,moleculesResult:r,logger:i?.logger});await U({input:l,unserializedMolecule:o,moleculesResult:r,options:i,plugins:n,migrator:c})}async function Re(e){let{subRoots:t,selector:o}=e;if(!o)return;let{root:r}=o;if(r)return t.get(r)}import{FileCollection as Oe}from"file-collection";async function Ie(e){let{source:t,plugins:o,options:r={}}=e,{converter:i,...n}=r,{selectorRoot:c=x()}=r,s={...t,id:c},l={spectra:[],molecules:[]},a=await Oe.fromSource(s,{unzip:{zipExtensions:["zip","nmredata"]}}),{spectra:p=[],molecules:m=[]}=await L(a,o,{converter:{...i,bruker:{keepFiles:!0,...Reflect.get(i??{},"bruker")}},...n});l.spectra.push(...p),l.molecules.push(...m);for(let S of l.spectra)S.selector??={root:c},S.selector.root=c;for(let S of l.molecules)S.selector??={root:c},S.selector.root=c;l.sources??=[],l.sources.push(s);let u=T({version:14,data:l},r?.selector?.general),{onLoadProcessing:f}=n,d={filters:f?.filters,autoProcessing:f?.autoProcessing??!1,experimentalFeatures:r.experimentalFeatures};E({nmriumState:u,plugins:o,options:d});let g=new Oe().appendFileCollection(a,c);return{state:u,aggregator:g,containsNmrium:!1}}function D(e,t){let o={};for(let r in e)t.includes(r)||(o[r]=e[r]);return o}var Rt=["data","originalData","info","originalInfo","meta","customInfo"],Ot=["data","originalData","info","originalInfo","meta","customInfo"],It=["selector","originalData","originalInfo"];function ve(e,t,o={}){let{version:r,data:i}=e;if(i.actionType)return e;let n={version:r,plugins:e.plugins},{includeData:c,forceRawSpectra:s=[]}=o;c!=="noData"&&(n.data=vt({...i},c,s));let{includeSettings:l,includeView:a}=o;return l&&(n.settings=e.settings),a&&(n.view=e.view),I(n,t),n}function vt(e,t="rawData",o){let{spectra:r}=e;switch(t){case"dataSource":return Dt(e);case"selfContained":case"selfContainedExternalDatasource":return Mt(e,o);case"rawData":return{...D(e,["sources"]),spectra:r.map(De)};default:return e}}function Dt(e){let{spectra:t}=e;if(!e.sources)throw new Error("sources property should exists for dataSource serialization");return{...e,spectra:t.map(Ct)}}function Mt(e,t){let{spectra:o,sources:r,...i}=e;return{...i,spectra:o.map(n=>wt(n,t))}}function Ct(e){return D(e,Rt)}function wt(e,t){return!("selector"in e)||t?.includes(e.id)?De(e):D(e,Ot)}function De(e){let{data:t,info:o,originalData:r,originalInfo:i}=e,n=D(e,It);return n.data=r||t,n.info=i||o,n}import{FileCollection as At}from"file-collection";async function Me(e,t){let{state:o,aggregator:r,externalData:i="embedded",includeData:n=!0,includeSettings:c,includeView:s}=t,{spectra:l,molecules:a}=o.data,p=new At({filter:{ignoreDotfiles:!1}});return n&&p.appendFileCollection(r),p.toIum({includeData:i==="embedded",mimetype:"chemical/x-nmrium+zip",*getExtraFiles(m){yield{relativePath:"META-INF/NMRIUM_ARCHIVE",data:""},yield{relativePath:"META-INF/VERSION",data:"1"},yield{relativePath:"state.json",data:Ft(e,o,r,{externalData:i,includeData:n,includeView:s,includeSettings:c})},yield{relativePath:"index.txt",data:Tt({aggregator:r,spectra:l,molecules:a,index:m})}}})}function Ft(e,t,o,r){let{includeData:i,includeView:n,includeSettings:c,externalData:s="embedded"}=r,l="noData";i&&(l=s==="embedded"?"selfContained":"selfContainedExternalDatasource");let a=[];if(l!=="noData")for(let u of t.data?.spectra??[]){let f=u.selector?.root;f&&o.subroot(f).files.length>0||a.push(u.id)}let p=e(t,{includeData:l,includeView:n,includeSettings:c,forceRawSpectra:a}),m=JSON.stringify(p,(u,f)=>ArrayBuffer.isView(f)?Array.from(f):f,2);return new Blob([m],{type:"application/json"})}function Tt(e){let{aggregator:t,spectra:o,molecules:r,index:i}=e,n=new Map,c=new Map(i.sources.map(l=>[l.uuid,l]));for(let l of o){let a=l.selector?.root;a&&(n.has(a)||n.set(a,t.subroot(a)))}for(let l of r){let a=l.selector?.root;a&&(n.has(a)||n.set(a,t.subroot(a)))}let s=[];for(let[l,a]of n.entries()){let p=new Map(a.sources.map(u=>[u.uuid,u])),m=`data/${l}/`;s.push(m);for(let u of a.files){let f=c.get(u.sourceUUID),d=p.get(u.sourceUUID),g=f?.baseURL?.startsWith("ium:/")?"embedded":"linked",y=i.paths[u.sourceUUID]?.replace(m,""),P=u.relativePath.replace(d?.relativePath??"",""),h=y?y+P:u.relativePath;s.push(` ${h} (${g})`)}s.push(`
5
5
  `)}return s.join(`
6
- `)}var ne=class{version=13;#e=new Map;registerPlugin(t){if(this.#e.has(t.id)){console.warn(`Plugin ${t.id} is already registered. skip.`),console.debug("Plugin already registered:",this.#e.get(t.id)),console.debug("Plugin to register:",t);return}this.#e.set(t.id,t)}registerPlugins(t){for(let o of t)this.registerPlugin(o)}getPlugin(t){return this.#e.get(t)}migrate(t){return ue(t,this.version,this.#e)}read(t,o={},r){return v({input:t,options:o,fromSourceOptions:r,migrator:this.migrate.bind(this),plugins:this.#e})}readNMRiumArchive(t,o={}){return he({input:t,options:o,plugins:this.#e,migrator:this.migrate.bind(this)})}readNMRiumObject(t,o,r){return V({nmriumObjectInput:t,options:o,fromSourceOptions:r,plugins:this.#e,migrator:this.migrate.bind(this)})}readNMRiumFile(t,o={},r){return _({file:t,options:o,fromSourceOptions:r,plugins:this.#e,migrator:this.migrate.bind(this)})}readFromWebSource(t,o){return be({source:t,options:o,plugins:this.#e})}serializeNmriumState(t,o){return Re(t,this.#e,o)}serializeNmriumArchive(t){let o=this.serializeNmriumState.bind(this);return Ie(o,t)}serializePlugins(){let t={plugins:{}};return I(t,this.#e),t.plugins}slot(t){return pe({slot:t,plugins:this.#e})}};function Tt(e,t){if(t>13)return 0;let o=-1;for(let r=0;r<e.length;r++)if(e[r].version>t){o=r;break}return o}var ve=[{version:6,fun:C},{version:7,fun:A}];function Et(e){let{version:t}=e||{},o=Tt(ve,t);if(o===-1)return{...e,version:13};let r=ve.slice(o);for(let i of r)e=i.fun(e);return e}export{De as ANALYSIS_COLUMN_TYPES,Me as ANALYSIS_COLUMN_VALUES_KEYS,N as CURRENT_EXPORT_VERSION,Ae as EXTERNAL_API_KEYS,ne as NMRiumCore,Ze as defineNMRiumPlugin,Ye as formatSpectra,x as generateID,W as getOneIfArray,Et as migrateSettings,Ce as units};
6
+ `)}var se=class{version=14;#e=new Map;registerPlugin(t){if(this.#e.has(t.id)){console.warn(`Plugin ${t.id} is already registered. skip.`),console.debug("Plugin already registered:",this.#e.get(t.id)),console.debug("Plugin to register:",t);return}this.#e.set(t.id,t)}registerPlugins(t){for(let o of t)this.registerPlugin(o)}getPlugin(t){return this.#e.get(t)}migrate(t){return pe(t,this.version,this.#e)}read(t,o={},r){return v({input:t,options:o,fromSourceOptions:r,migrator:this.migrate.bind(this),plugins:this.#e})}readNMRiumArchive(t,o={}){return Ne({input:t,options:o,plugins:this.#e,migrator:this.migrate.bind(this)})}readNMRiumObject(t,o,r){return j({nmriumObjectInput:t,options:o,fromSourceOptions:r,plugins:this.#e,migrator:this.migrate.bind(this)})}readNMRiumFile(t,o={},r){return _({file:t,options:o,fromSourceOptions:r,plugins:this.#e,migrator:this.migrate.bind(this)})}readFromWebSource(t,o){return Ie({source:t,options:o,plugins:this.#e})}serializeNmriumState(t,o){return ve(t,this.#e,o)}serializeNmriumArchive(t){let o=this.serializeNmriumState.bind(this);return Me(o,t)}serializePlugins(){let t={plugins:{}};return I(t,this.#e),t.plugins}slot(t){return me({slot:t,plugins:this.#e})}};function Et(e,t){if(t>14)return 0;let o=-1;for(let r=0;r<e.length;r++)if(e[r].version>t){o=r;break}return o}var Ce=[{version:6,fun:C},{version:7,fun:w}];function Lt(e){let{version:t}=e||{},o=Et(Ce,t);if(o===-1)return{...e,version:14};let r=Ce.slice(o);for(let i of r)e=i.fun(e);return e}export{we as ANALYSIS_COLUMN_TYPES,Ae as ANALYSIS_COLUMN_VALUES_KEYS,b as CURRENT_EXPORT_VERSION,Te as EXTERNAL_API_KEYS,se as NMRiumCore,Je as defineNMRiumPlugin,Ge as formatSpectra,x as generateID,W as getOneIfArray,Lt as migrateSettings,Fe as units};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zakodium/nmrium-core",
3
- "version": "0.6.8",
3
+ "version": "0.7.1",
4
4
  "description": "The core of NMRium: types, state, state migration and plugin system.",
5
5
  "author": "Zakodium Sàrl",
6
6
  "license": "CC-BY-NC-SA-4.0",
@@ -47,5 +47,5 @@
47
47
  "volta": {
48
48
  "extends": "../../../package.json"
49
49
  },
50
- "gitHead": "f50e6395c4e57d9b01016e7138889a24b4b22ec3"
50
+ "gitHead": "176a331e9d92d157e0f7cbdc11bf37c7f334c4dd"
51
51
  }