@rivm-loculus-tools/sequence-editor 0.1.4 → 0.1.5

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.
Files changed (144) hide show
  1. package/dist/_chunks/Box.js +6737 -0
  2. package/dist/_chunks/Box.js.map +1 -0
  3. package/dist/_chunks/Close.js +7 -0
  4. package/dist/_chunks/Close.js.map +1 -0
  5. package/dist/_chunks/EditorWorkerService.js +126 -0
  6. package/dist/_chunks/EditorWorkerService.js.map +1 -0
  7. package/dist/_chunks/KeyboardArrowDown.js +1023 -0
  8. package/dist/_chunks/KeyboardArrowDown.js.map +1 -0
  9. package/dist/_chunks/Redo.js +2559 -0
  10. package/dist/_chunks/Redo.js.map +1 -0
  11. package/dist/_chunks/SequenceEditor.js +860 -0
  12. package/dist/_chunks/SequenceEditor.js.map +1 -0
  13. package/dist/_chunks/SequenceEditorEventBusService.js +102 -0
  14. package/dist/_chunks/SequenceEditorEventBusService.js.map +1 -0
  15. package/dist/_chunks/SequenceEditorMainPage.js +552 -0
  16. package/dist/_chunks/SequenceEditorMainPage.js.map +1 -0
  17. package/dist/_chunks/SequenceEditorPageDrawer.js +49842 -0
  18. package/dist/_chunks/SequenceEditorPageDrawer.js.map +1 -0
  19. package/dist/_chunks/SequenceEditorPageHeader.js +236 -0
  20. package/dist/_chunks/SequenceEditorPageHeader.js.map +1 -0
  21. package/dist/_chunks/SequenceEditorSearchBar.js +143 -0
  22. package/dist/_chunks/SequenceEditorSearchBar.js.map +1 -0
  23. package/dist/_chunks/TestIdUtil.js +4695 -0
  24. package/dist/_chunks/TestIdUtil.js.map +1 -0
  25. package/dist/_chunks/TextField.js +3083 -0
  26. package/dist/_chunks/TextField.js.map +1 -0
  27. package/dist/_chunks/rolldown-runtime.js +13 -0
  28. package/dist/_chunks/sequenceEditorStore.js +407 -0
  29. package/dist/_chunks/sequenceEditorStore.js.map +1 -0
  30. package/dist/_chunks/sequence_editor.js +517 -0
  31. package/dist/_chunks/sequence_editor.js.map +1 -0
  32. package/dist/_chunks/withDialog.js +289 -0
  33. package/dist/_chunks/withDialog.js.map +1 -0
  34. package/dist/assets/index-C5rc-pJV.js +8 -0
  35. package/dist/assets/index-C5rc-pJV.js.map +1 -0
  36. package/dist/classes/services/EditorWorkerService/EditorWorkerService.d.ts +27 -0
  37. package/dist/classes/services/EditorWorkerService/index.js +2 -0
  38. package/dist/classes/services/SequenceEditorEventBusService/SequenceEditorEventBusService.d.ts +25 -0
  39. package/dist/classes/services/SequenceEditorEventBusService/index.js +2 -0
  40. package/dist/classes/workers/EngineWorker/EngineWorker.d.ts +46 -0
  41. package/dist/classes/workers/EngineWorker/index.js +110 -0
  42. package/dist/classes/workers/EngineWorker/index.js.map +1 -0
  43. package/dist/components/app/App/App.d.ts +1 -0
  44. package/dist/components/app/App/index.js +957 -0
  45. package/dist/components/app/App/index.js.map +1 -0
  46. package/dist/components/pages/EmptyWorkspace.d.ts +3 -0
  47. package/dist/components/pages/SequenceEditorErrorPage/SequenceEditorErrorPage.d.ts +3 -0
  48. package/dist/components/pages/SequenceEditorErrorPage/index.js +12 -0
  49. package/dist/components/pages/SequenceEditorErrorPage/index.js.map +1 -0
  50. package/dist/components/pages/SequenceEditorMainPage/SequenceEditorMainPage.d.ts +1 -0
  51. package/dist/components/pages/SequenceEditorMainPage/index.js +2 -0
  52. package/dist/components/ui/SequenceEditor/SequenceEditor.d.ts +1 -0
  53. package/dist/components/ui/SequenceEditor/SequenceEditorGotoPositionDialog.d.ts +8 -0
  54. package/dist/components/ui/SequenceEditor/SequenceEditorStatusBar.d.ts +1 -0
  55. package/dist/components/ui/SequenceEditor/index.js +2 -0
  56. package/dist/components/ui/SequenceEditorPage/SequenceEditorPage.d.ts +5 -0
  57. package/dist/components/ui/SequenceEditorPage/index.js +15 -0
  58. package/dist/components/ui/SequenceEditorPage/index.js.map +1 -0
  59. package/dist/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawer.d.ts +1 -0
  60. package/dist/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawerColorForm.d.ts +7 -0
  61. package/dist/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawerKeyboardShortcuts.d.ts +1 -0
  62. package/dist/components/ui/SequenceEditorPageDrawer/index.js +2 -0
  63. package/dist/components/ui/SequenceEditorPageHeader/SequenceEditorPageHeader.d.ts +1 -0
  64. package/dist/components/ui/SequenceEditorPageHeader/index.js +2 -0
  65. package/dist/components/ui/SequenceEditorSearchBar/SequenceEditorSearchBar.d.ts +1 -0
  66. package/dist/components/ui/SequenceEditorSearchBar/index.js +2 -0
  67. package/dist/constants/editor.d.ts +4 -0
  68. package/dist/constants/editor.js +14 -0
  69. package/dist/constants/editor.js.map +1 -0
  70. package/dist/constants/index.js +4 -0
  71. package/dist/constants/keyboard.d.ts +10 -0
  72. package/dist/constants/keyboard.js +179 -0
  73. package/dist/constants/keyboard.js.map +1 -0
  74. package/dist/constants/palette.d.ts +15 -0
  75. package/dist/constants/palette.js +196 -0
  76. package/dist/constants/palette.js.map +1 -0
  77. package/dist/models/editor.d.ts +6 -0
  78. package/dist/models/editor.js +8 -0
  79. package/dist/models/editor.js.map +1 -0
  80. package/dist/models/model.d.ts +250 -0
  81. package/dist/models/model.js +10 -0
  82. package/dist/models/model.js.map +1 -0
  83. package/dist/models/palette.d.ts +61 -0
  84. package/dist/models/palette.js +10 -0
  85. package/dist/models/palette.js.map +1 -0
  86. package/dist/stores/sequenceEditorStore/index.js +2 -0
  87. package/dist/stores/sequenceEditorStore/sequenceEditorStore.d.ts +36 -0
  88. package/dist/utils/EditorUtil/EditorUtil.d.ts +96 -0
  89. package/dist/utils/EditorUtil/index.js +544 -0
  90. package/dist/utils/EditorUtil/index.js.map +1 -0
  91. package/dist/utils/EngineErrorUtil/EngineErrorUtil.d.ts +4 -0
  92. package/dist/utils/PaletteUtil/PaletteUtil.d.ts +6 -0
  93. package/dist/utils/PaletteUtil/index.js +19 -0
  94. package/dist/utils/PaletteUtil/index.js.map +1 -0
  95. package/package.json +5 -2
  96. package/.gitkeep +0 -0
  97. package/CHANGELOG.md +0 -37
  98. package/eslint.config.js +0 -16
  99. package/scripts/update-exports.js +0 -9
  100. package/src/classes/services/EditorWorkerService/EditorWorkerService.ts +0 -163
  101. package/src/classes/services/SequenceEditorEventBusService/SequenceEditorEventBusService.ts +0 -37
  102. package/src/classes/workers/EngineWorker/EngineWorker.ts +0 -196
  103. package/src/components/app/App/App.tsx +0 -22
  104. package/src/components/pages/EmptyWorkspace.tsx +0 -43
  105. package/src/components/pages/SequenceEditorErrorPage/SequenceEditorErrorPage.tsx +0 -16
  106. package/src/components/pages/SequenceEditorMainPage/SequenceEditorMainPage.tsx +0 -76
  107. package/src/components/ui/SequenceEditor/SequenceEditor.tsx +0 -896
  108. package/src/components/ui/SequenceEditor/SequenceEditorGotoPositionDialog.tsx +0 -108
  109. package/src/components/ui/SequenceEditor/SequenceEditorStatusBar.tsx +0 -72
  110. package/src/components/ui/SequenceEditorPage/SequenceEditorPage.tsx +0 -23
  111. package/src/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawer.tsx +0 -234
  112. package/src/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawerColorForm.tsx +0 -73
  113. package/src/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawerKeyboardShortcuts.tsx +0 -230
  114. package/src/components/ui/SequenceEditorPageHeader/SequenceEditorPageHeader.tsx +0 -71
  115. package/src/components/ui/SequenceEditorSearchBar/SequenceEditorSearchBar.tsx +0 -35
  116. package/src/constants/editor.ts +0 -15
  117. package/src/constants/keyboard.ts +0 -154
  118. package/src/constants/palette.ts +0 -227
  119. package/src/models/editor.ts +0 -6
  120. package/src/models/model.ts +0 -295
  121. package/src/models/palette.ts +0 -68
  122. package/src/stores/sequenceEditorStore/sequenceEditorStore.ts +0 -103
  123. package/src/utils/EditorUtil/EditorUtil.ts +0 -892
  124. package/src/utils/EngineErrorUtil/EngineErrorUtil.ts +0 -25
  125. package/src/utils/PaletteUtil/PaletteUtil.ts +0 -31
  126. package/tsconfig.build.json +0 -14
  127. package/tsconfig.json +0 -32
  128. package/vite.config.ts +0 -177
  129. /package/{src/classes/services/EditorWorkerService/index.ts → dist/classes/services/EditorWorkerService/index.d.ts} +0 -0
  130. /package/{src/classes/services/SequenceEditorEventBusService/index.ts → dist/classes/services/SequenceEditorEventBusService/index.d.ts} +0 -0
  131. /package/{src/classes/workers/EngineWorker/index.ts → dist/classes/workers/EngineWorker/index.d.ts} +0 -0
  132. /package/{src/components/app/App/index.ts → dist/components/app/App/index.d.ts} +0 -0
  133. /package/{src/components/pages/SequenceEditorErrorPage/index.ts → dist/components/pages/SequenceEditorErrorPage/index.d.ts} +0 -0
  134. /package/{src/components/pages/SequenceEditorMainPage/index.ts → dist/components/pages/SequenceEditorMainPage/index.d.ts} +0 -0
  135. /package/{src/components/ui/SequenceEditor/index.ts → dist/components/ui/SequenceEditor/index.d.ts} +0 -0
  136. /package/{src/components/ui/SequenceEditorPage/index.ts → dist/components/ui/SequenceEditorPage/index.d.ts} +0 -0
  137. /package/{src/components/ui/SequenceEditorPageDrawer/index.ts → dist/components/ui/SequenceEditorPageDrawer/index.d.ts} +0 -0
  138. /package/{src/components/ui/SequenceEditorPageHeader/index.ts → dist/components/ui/SequenceEditorPageHeader/index.d.ts} +0 -0
  139. /package/{src/components/ui/SequenceEditorSearchBar/index.ts → dist/components/ui/SequenceEditorSearchBar/index.d.ts} +0 -0
  140. /package/{src/constants/index.ts → dist/constants/index.d.ts} +0 -0
  141. /package/{src/models/index.ts → dist/models/index.d.ts} +0 -0
  142. /package/{src/stores/sequenceEditorStore/index.ts → dist/stores/sequenceEditorStore/index.d.ts} +0 -0
  143. /package/{src/utils/EditorUtil/index.ts → dist/utils/EditorUtil/index.d.ts} +0 -0
  144. /package/{src/utils/PaletteUtil/index.ts → dist/utils/PaletteUtil/index.d.ts} +0 -0
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, i, o, s) => {
3
+ if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
4
+ get: ((e) => i[e]).bind(null, d),
5
+ enumerable: !(s = n(i, d)) || s.enumerable
6
+ });
7
+ return e;
8
+ }, c = (n, r, o) => (o = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule || !a.call(n, "default") ? t(o, "default", {
9
+ value: n,
10
+ enumerable: !0
11
+ }) : o, n));
12
+ //#endregion
13
+ export { c as n, o as t };
@@ -0,0 +1,407 @@
1
+ import { ALI_VIEW_DEFAULT_AMINO_ACID_PALETTE as e, ALI_VIEW_DEFAULT_NUCLEOTIDE_PALETTE as t } from "../constants/palette.js";
2
+ import "../constants/index.js";
3
+ //#region ../../../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_react@19.3.0_use-sync-external-store@1.7.0_react@19.3.0_/node_modules/zustand/esm/vanilla.mjs
4
+ var n = (e) => {
5
+ let t, n = /* @__PURE__ */ new Set(), r = (e, r) => {
6
+ let i = typeof e == "function" ? e(t) : e;
7
+ if (!Object.is(i, t)) {
8
+ let e = t;
9
+ t = r ?? (typeof i != "object" || !i) ? i : Object.assign({}, t, i), n.forEach((n) => n(t, e));
10
+ }
11
+ }, i = () => t, a = {
12
+ setState: r,
13
+ getState: i,
14
+ getInitialState: () => o,
15
+ subscribe: (e) => (n.add(e), () => n.delete(e))
16
+ }, o = t = e(r, i, a);
17
+ return a;
18
+ }, r = ((e) => e ? n(e) : n);
19
+ //#endregion
20
+ //#region ../../../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_react@19.3.0_use-sync-external-store@1.7.0_react@19.3.0_/node_modules/zustand/esm/middleware.mjs
21
+ function i(e, t) {
22
+ let n;
23
+ try {
24
+ n = e();
25
+ } catch {
26
+ return;
27
+ }
28
+ return {
29
+ getItem: (e) => {
30
+ let r = (e) => e === null ? null : JSON.parse(e, t?.reviver), i = n.getItem(e) ?? null;
31
+ return i instanceof Promise ? i.then(r) : r(i);
32
+ },
33
+ setItem: (e, r) => n.setItem(e, JSON.stringify(r, t?.replacer)),
34
+ removeItem: (e) => n.removeItem(e)
35
+ };
36
+ }
37
+ var a = (e) => (t) => {
38
+ try {
39
+ let n = e(t);
40
+ return n instanceof Promise ? n : {
41
+ then(e) {
42
+ return a(e)(n);
43
+ },
44
+ catch(e) {
45
+ return this;
46
+ }
47
+ };
48
+ } catch (e) {
49
+ return {
50
+ then(e) {
51
+ return this;
52
+ },
53
+ catch(t) {
54
+ return a(t)(e);
55
+ }
56
+ };
57
+ }
58
+ }, o = (e, t) => (n, r, o) => {
59
+ let s = {
60
+ storage: i(() => window.localStorage),
61
+ partialize: (e) => e,
62
+ version: 0,
63
+ merge: (e, t) => ({
64
+ ...t,
65
+ ...e
66
+ }),
67
+ ...t
68
+ }, c = !1, l = 0, u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), f = s.storage;
69
+ if (!f) return e((...e) => {
70
+ console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`), n(...e);
71
+ }, r, o);
72
+ let p = () => {
73
+ let e = s.partialize({ ...r() });
74
+ return f.setItem(s.name, {
75
+ state: e,
76
+ version: s.version
77
+ });
78
+ }, m = o.setState;
79
+ o.setState = (e, t) => (m(e, t), p());
80
+ let h = e((...e) => (n(...e), p()), r, o);
81
+ o.getInitialState = () => h;
82
+ let g, _ = () => {
83
+ if (!f) return;
84
+ let e = ++l;
85
+ c = !1, u.forEach((e) => e(r() ?? h));
86
+ let t = s.onRehydrateStorage?.call(s, r() ?? h) || void 0;
87
+ return a(f.getItem.bind(f))(s.name).then((e) => {
88
+ if (e) {
89
+ if (typeof e.version == "number" && e.version !== s.version) {
90
+ if (s.migrate) {
91
+ let t = s.migrate(e.state, e.version);
92
+ return t instanceof Promise ? t.then((e) => [!0, e]) : [!0, t];
93
+ }
94
+ console.error("State loaded from storage couldn't be migrated since no migrate function was provided");
95
+ } else return [!1, e.state];
96
+ }
97
+ return [!1, void 0];
98
+ }).then((t) => {
99
+ if (e !== l) return;
100
+ let [i, a] = t;
101
+ if (g = s.merge(a, r() ?? h), n(g, !0), i) return p();
102
+ }).then(() => {
103
+ e === l && (t?.(r(), void 0), g = r(), c = !0, d.forEach((e) => e(g)));
104
+ }).catch((n) => {
105
+ e === l && t?.(void 0, n);
106
+ });
107
+ };
108
+ return o.persist = {
109
+ setOptions: (e) => {
110
+ s = {
111
+ ...s,
112
+ ...e
113
+ }, e.storage && (f = e.storage);
114
+ },
115
+ clearStorage: () => {
116
+ ++l, f?.removeItem(s.name);
117
+ },
118
+ getOptions: () => s,
119
+ rehydrate: () => _(),
120
+ hasHydrated: () => c,
121
+ onHydrate: (e) => (u.add(e), () => {
122
+ u.delete(e);
123
+ }),
124
+ onFinishHydration: (e) => (d.add(e), () => {
125
+ d.delete(e);
126
+ })
127
+ }, s.skipHydration || _(), g || h;
128
+ }, s = /* @__PURE__ */ function(e) {
129
+ return e.ERROR = "ERROR", e.IDLE = "IDLE", e.LOADING = "LOADING", e.SUCCESS = "SUCCESS", e;
130
+ }({}), c = class e {
131
+ static parseFasta(t) {
132
+ if (!t?.trim()) return e.createErrorResult("The FASTA input is empty.");
133
+ let n = t.split(/\r?\n/), r = [], i = "", a = [], o = () => {
134
+ if (i) {
135
+ let t = a.join("").replace(/\s/g, "").toUpperCase();
136
+ if (!t.length) return e.createErrorResult(`FASTA record "${i}" has no sequence.`);
137
+ let n = i.split(/[|\t]/)[0].trim().replace(/[():;,']/g, "_");
138
+ r.push({
139
+ accessionVersion: n,
140
+ header: i,
141
+ id: n,
142
+ length: t.length,
143
+ sequence: t
144
+ });
145
+ }
146
+ return null;
147
+ };
148
+ for (let t of n) {
149
+ let n = t.trim();
150
+ if (n) {
151
+ if (n.startsWith(">")) {
152
+ let t = o();
153
+ if (t) return t;
154
+ if (i = n.slice(1).trim(), !i) return e.createErrorResult("Every FASTA record needs a non-empty header.");
155
+ a = [];
156
+ } else {
157
+ if (!i) return e.createErrorResult("FASTA sequence data appeared before its first header.");
158
+ a.push(n);
159
+ }
160
+ }
161
+ }
162
+ let s = o();
163
+ if (s) return s;
164
+ if (r.length === 0) return e.createErrorResult("No FASTA records were found.");
165
+ let c = r[0].length, l = r.filter((e) => e.length !== c).map((e) => ({
166
+ id: e.id,
167
+ length: e.length
168
+ })), u = l.length === 0;
169
+ return {
170
+ expectedLength: c,
171
+ invalidSequences: u ? void 0 : l,
172
+ isAligned: u,
173
+ sequences: r
174
+ };
175
+ }
176
+ static stripFastaHeaders(e) {
177
+ return e.split("\n").map((e) => e.startsWith(">") ? `>${e.substring(1).trim().split(/[|\t]/)[0].trim().replace(/[():;,']/g, "_")}` : e).join("\n");
178
+ }
179
+ static createErrorResult(e) {
180
+ return {
181
+ error: e,
182
+ expectedLength: 0,
183
+ isAligned: !1,
184
+ sequences: []
185
+ };
186
+ }
187
+ }, l = class e {
188
+ static findBestMatchingColumn = (t, n, r) => {
189
+ let i = e.getMatchCounts(t, n, r), a = null, o = -1;
190
+ if (!t || !n || !r || r.length === 0) return {
191
+ bestColumn: null,
192
+ matchCounts: {}
193
+ };
194
+ let s = [
195
+ "displayname",
196
+ "accessionversion",
197
+ "accession",
198
+ "sampleid",
199
+ "sample_id",
200
+ "id",
201
+ "strain",
202
+ "isolate",
203
+ "submissionid",
204
+ "name"
205
+ ];
206
+ for (let e of t) {
207
+ if (!n[e]) continue;
208
+ let t = i[e];
209
+ if (t > o) o = t, a = e;
210
+ else if (t === o && t > 0 && a) {
211
+ let t = s.indexOf(a.toLowerCase()), n = s.indexOf(e.toLowerCase());
212
+ n !== -1 && (t === -1 || n < t) && (a = e);
213
+ }
214
+ }
215
+ if (o <= 0) {
216
+ for (let e of s) {
217
+ let n = t.find((t) => t.toLowerCase() === e);
218
+ if (n) {
219
+ a = n;
220
+ break;
221
+ }
222
+ }
223
+ !a && t.length > 0 && (a = t[0]);
224
+ }
225
+ return {
226
+ bestColumn: a,
227
+ matchCounts: i
228
+ };
229
+ };
230
+ static getHighlightedIds(e, t, n, r = null) {
231
+ let i = e.trim().toLowerCase();
232
+ if (!i) return [];
233
+ let a = /* @__PURE__ */ new Set();
234
+ return t.forEach((e) => {
235
+ e.toLowerCase().includes(i) && a.add(e);
236
+ }), n.forEach((e) => {
237
+ let t = r && e[r] || e.displayName || e.accessionVersion || e.accession || e.id || e.submissionId || e.SampleID;
238
+ t && Object.values(e).some((e) => typeof e == "string" && e.toLowerCase().includes(i)) && a.add(t);
239
+ }), Array.from(a);
240
+ }
241
+ static getMatchCounts = (e, t, n) => {
242
+ let r = {};
243
+ if (!e || !t || !n || n.length === 0) return r;
244
+ for (let i of e) {
245
+ let e = t[i];
246
+ if (!e) continue;
247
+ let a = 0;
248
+ for (let t of n) e[t] && a++;
249
+ r[i] = a;
250
+ }
251
+ return r;
252
+ };
253
+ static getRecordForSample = (e, t, n) => {
254
+ if (e && t) {
255
+ if (n && e.recordsByColumn?.[n]) {
256
+ let r = e.recordsByColumn[n][t];
257
+ if (r) return r;
258
+ }
259
+ if (e.recordsByColumn?.displayName?.[t]) return e.recordsByColumn.displayName[t];
260
+ if (e.recordsByColumn?.accessionVersion?.[t]) return e.recordsByColumn.accessionVersion[t];
261
+ if (e.recordsByAccession[t]) return e.recordsByAccession[t];
262
+ if (e.recordsBySampleId[t]) return e.recordsBySampleId[t];
263
+ if (e.recordsByColumn) for (let n of Object.keys(e.recordsByColumn)) {
264
+ let r = e.recordsByColumn[n][t];
265
+ if (r) return r;
266
+ }
267
+ }
268
+ };
269
+ static parseTsv = (e) => {
270
+ if (!e?.trim()) return {
271
+ columns: [],
272
+ error: "Empty metadata content provided.",
273
+ records: [],
274
+ recordsByAccession: {},
275
+ recordsByColumn: {},
276
+ recordsBySampleId: {}
277
+ };
278
+ let t = e.trim().split("\n");
279
+ if (t.length < 2) return {
280
+ columns: [],
281
+ error: "Metadata file must contain at least a header row and one data row.",
282
+ records: [],
283
+ recordsByAccession: {},
284
+ recordsByColumn: {},
285
+ recordsBySampleId: {}
286
+ };
287
+ let n = t[0].trim(), r = " ";
288
+ !n.includes(" ") && n.includes(",") && (r = ",");
289
+ let i = n.split(r).map((e) => e.trim().replace(/^["']|["']$/g, "")).filter((e) => e.length > 0), a = [], o = {}, s = {}, c = {};
290
+ i.forEach((e) => {
291
+ c[e] = {};
292
+ });
293
+ for (let e = 1; e < t.length; e++) {
294
+ let n = t[e].trim();
295
+ if (!n) continue;
296
+ let l = n.split(r).map((e) => e.trim().replace(/^["']|["']$/g, "")), u = {};
297
+ i.forEach((e, t) => {
298
+ let n = l[t] ?? "";
299
+ u[e] = n, n && (c[e][n] = u);
300
+ }), a.push(u);
301
+ let d = u.displayName || u.accessionVersion || u.accession || u.id || u.submissionId || u.strain || u.isolate || u.name;
302
+ d && (o[d] = u);
303
+ let f = u.SampleID || u.sampleId || u.sample_id || u.specimenCollectorSampleId || u.id;
304
+ f && (s[f] = u);
305
+ }
306
+ return {
307
+ columns: i,
308
+ records: a,
309
+ recordsByAccession: o,
310
+ recordsByColumn: c,
311
+ recordsBySampleId: s
312
+ };
313
+ };
314
+ }, u = () => ({
315
+ columnMatchCounts: {},
316
+ loadingError: null,
317
+ loadingStatus: s.IDLE,
318
+ matchKeyField: null,
319
+ parsedFasta: null,
320
+ parsedMetadata: null,
321
+ rawFasta: "",
322
+ rawMetadata: ""
323
+ }), d = (e) => {
324
+ let { get: t, set: n } = e, r = (e) => n(e);
325
+ return {
326
+ resetDataset: () => r(u()),
327
+ setColumnMatchCounts: (e) => r({ columnMatchCounts: e }),
328
+ setData: async (e, n) => {
329
+ let i = c.parseFasta(e);
330
+ if (i.error) throw r({
331
+ loadingError: i.error,
332
+ loadingStatus: s.ERROR
333
+ }), Error(i.error);
334
+ r({
335
+ parsedFasta: i,
336
+ rawFasta: e
337
+ });
338
+ let a;
339
+ if (n) {
340
+ if (a = l.parseTsv(n), a.error) throw r({
341
+ loadingError: a.error,
342
+ loadingStatus: s.ERROR
343
+ }), Error(a.error);
344
+ r({
345
+ parsedMetadata: a,
346
+ rawMetadata: n
347
+ });
348
+ let e = i.sequences.map((e) => e.id), { bestColumn: o, matchCounts: c } = l.findBestMatchingColumn(a.columns, a.recordsByColumn, e);
349
+ t().setColumnMatchCounts(c), t().setMatchKeyField(o);
350
+ }
351
+ return r({
352
+ loadingError: null,
353
+ loadingStatus: s.SUCCESS
354
+ }), Promise.resolve({
355
+ fastaResult: i,
356
+ metadataResult: a
357
+ });
358
+ },
359
+ setLoadingStatus: (e) => r({ loadingStatus: e }),
360
+ setMatchKeyField: (e) => r({ matchKeyField: e })
361
+ };
362
+ }, f = () => ({
363
+ ...u(),
364
+ aminoAcidPalette: e,
365
+ latestMessage: null,
366
+ meta: null,
367
+ nucleotidePalette: t,
368
+ searchQuery: "",
369
+ searchResult: null,
370
+ searchResultHighlightedIndex: null,
371
+ selection: null
372
+ }), p = r()(o((e, t) => {
373
+ let n = f(), r = d({
374
+ get: t,
375
+ set: e
376
+ });
377
+ return {
378
+ ...n,
379
+ ...r,
380
+ setAminoAcidPalette: (t) => e({ aminoAcidPalette: t }),
381
+ setLatestMessage: (t) => e({ latestMessage: t }),
382
+ setMeta: (t) => e({ meta: t }),
383
+ setNucleotidePalette: (t) => e({ nucleotidePalette: t }),
384
+ setSearchQuery: (n) => {
385
+ let { setSearchResult: r, setSearchResultHighlightedIndex: i } = t();
386
+ e({ searchQuery: n }), n || (i(null), r(null));
387
+ },
388
+ setSearchResult: (n) => {
389
+ let { setSearchResultHighlightedIndex: r } = t();
390
+ e({ searchResult: n }), r(null);
391
+ },
392
+ setSearchResultHighlightedIndex: (t) => e({ searchResultHighlightedIndex: t }),
393
+ setSelection: (t) => e({ selection: t })
394
+ };
395
+ }, {
396
+ name: "LOCULUS-SEQUENCE-EDITOR-Configuration",
397
+ partialize: (e) => ({
398
+ aminoAcidPalette: e.aminoAcidPalette,
399
+ nucleotidePalette: e.nucleotidePalette
400
+ }),
401
+ storage: i(() => localStorage),
402
+ version: 1
403
+ }));
404
+ //#endregion
405
+ export { s as n, p as t };
406
+
407
+ //# sourceMappingURL=sequenceEditorStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sequenceEditorStore.js","names":[],"sources":["../../../../../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_react@19.3.0_use-sync-external-store@1.7.0_react@19.3.0_/node_modules/zustand/esm/vanilla.mjs","../../../../../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_react@19.3.0_use-sync-external-store@1.7.0_react@19.3.0_/node_modules/zustand/esm/middleware.mjs","../../../../../common/frontend/src/models/fasta.ts","../../../../../common/frontend/src/utils/FastaUtil/FastaUtil.ts","../../../../../common/frontend/src/utils/MetaDataUtil/MetaDataUtil.ts","../../../../../common/frontend/src/stores/fastaDataStore/fastaDataStore.ts","../../src/stores/sequenceEditorStore/sequenceEditorStore.ts"],"sourcesContent":["const createStoreImpl = (createState) => {\n let state;\n const listeners = /* @__PURE__ */ new Set();\n const setState = (partial, replace) => {\n const nextState = typeof partial === \"function\" ? partial(state) : partial;\n if (!Object.is(nextState, state)) {\n const previousState = state;\n state = (replace != null ? replace : typeof nextState !== \"object\" || nextState === null) ? nextState : Object.assign({}, state, nextState);\n listeners.forEach((listener) => listener(state, previousState));\n }\n };\n const getState = () => state;\n const getInitialState = () => initialState;\n const subscribe = (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n };\n const api = { setState, getState, getInitialState, subscribe };\n const initialState = state = createState(setState, getState, api);\n return api;\n};\nconst createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);\n\nexport { createStore };\n","const reduxImpl = (reducer, initial) => (set, _get, api) => {\n api.dispatch = (action) => {\n set((state) => reducer(state, action), false, action);\n return action;\n };\n api.dispatchFromDevtools = true;\n return { dispatch: (...args) => api.dispatch(...args), ...initial };\n};\nconst redux = reduxImpl;\n\nconst shouldDispatchFromDevtools = (api) => !!api.dispatchFromDevtools && typeof api.dispatch === \"function\";\nconst trackedConnections = /* @__PURE__ */ new Map();\nconst getTrackedConnectionState = (name) => {\n const api = trackedConnections.get(name);\n if (!api) return {};\n return Object.fromEntries(\n Object.entries(api.stores).map(([key, api2]) => [key, api2.getState()])\n );\n};\nconst extractConnectionInformation = (store, extensionConnector, options) => {\n if (store === void 0) {\n return {\n type: \"untracked\",\n connection: extensionConnector.connect(options)\n };\n }\n const existingConnection = trackedConnections.get(options.name);\n if (existingConnection) {\n return { type: \"tracked\", store, ...existingConnection };\n }\n const newConnection = {\n connection: extensionConnector.connect(options),\n stores: {}\n };\n trackedConnections.set(options.name, newConnection);\n return { type: \"tracked\", store, ...newConnection };\n};\nconst removeStoreFromTrackedConnections = (name, store) => {\n if (store === void 0) return;\n const connectionInfo = trackedConnections.get(name);\n if (!connectionInfo) return;\n delete connectionInfo.stores[store];\n if (Object.keys(connectionInfo.stores).length === 0) {\n trackedConnections.delete(name);\n }\n};\nconst v8StackLineRe = /^at (?:new |async )?(.+?) \\(/;\nconst geckoStackLineRe = /^([^@]+)@/;\nfunction findCallerName(stack) {\n var _a, _b, _c;\n if (!stack) return void 0;\n const traceLines = stack.split(\"\\n\");\n const apiSetStateLineIndex = traceLines.findIndex(\n (traceLine) => traceLine.includes(\"api.setState\")\n );\n if (apiSetStateLineIndex < 0) return void 0;\n const callerLine = ((_a = traceLines[apiSetStateLineIndex + 1]) == null ? void 0 : _a.trim()) || \"\";\n return ((_b = v8StackLineRe.exec(callerLine)) == null ? void 0 : _b[1]) || ((_c = geckoStackLineRe.exec(callerLine)) == null ? void 0 : _c[1]);\n}\nconst devtoolsImpl = (fn, devtoolsOptions = {}) => (set, get, api) => {\n const { enabled, anonymousActionType, store, ...options } = devtoolsOptions;\n let extensionConnector;\n try {\n extensionConnector = (enabled != null ? enabled : (import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") && window.__REDUX_DEVTOOLS_EXTENSION__;\n } catch (e) {\n }\n if (!extensionConnector) {\n return fn(set, get, api);\n }\n const { connection, ...connectionInformation } = extractConnectionInformation(store, extensionConnector, options);\n let isRecording = true;\n api.setState = ((state, replace, nameOrAction) => {\n const r = set(state, replace);\n if (!isRecording) return r;\n const action = nameOrAction === void 0 ? {\n type: anonymousActionType || findCallerName(new Error().stack) || \"anonymous\"\n } : typeof nameOrAction === \"string\" ? { type: nameOrAction } : nameOrAction;\n if (store === void 0) {\n connection == null ? void 0 : connection.send(action, get());\n return r;\n }\n connection == null ? void 0 : connection.send(\n {\n ...action,\n type: `${store}/${action.type}`\n },\n {\n ...getTrackedConnectionState(options.name),\n [store]: api.getState()\n }\n );\n return r;\n });\n api.devtools = {\n cleanup: () => {\n if (connection && typeof connection.unsubscribe === \"function\") {\n connection.unsubscribe();\n }\n removeStoreFromTrackedConnections(options.name, store);\n }\n };\n const setStateFromDevtools = (...a) => {\n const originalIsRecording = isRecording;\n isRecording = false;\n set(...a);\n isRecording = originalIsRecording;\n };\n const initialState = fn(api.setState, get, api);\n if (connectionInformation.type === \"untracked\") {\n connection == null ? void 0 : connection.init(initialState);\n } else {\n connectionInformation.stores[connectionInformation.store] = api;\n connection == null ? void 0 : connection.init(\n Object.fromEntries(\n Object.entries(connectionInformation.stores).map(([key, store2]) => [\n key,\n key === connectionInformation.store ? initialState : store2.getState()\n ])\n )\n );\n }\n if (shouldDispatchFromDevtools(api)) {\n let didWarnAboutReservedActionType = false;\n const originalDispatch = api.dispatch;\n api.dispatch = (...args) => {\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\" && args[0].type === \"__setState\" && !didWarnAboutReservedActionType) {\n console.warn(\n '[zustand devtools middleware] \"__setState\" action type is reserved to set state from the devtools. Avoid using it.'\n );\n didWarnAboutReservedActionType = true;\n }\n originalDispatch(...args);\n };\n }\n connection.subscribe((message) => {\n var _a;\n switch (message.type) {\n case \"ACTION\":\n if (typeof message.payload !== \"string\") {\n console.error(\n \"[zustand devtools middleware] Unsupported action format\"\n );\n return;\n }\n return parseJsonThen(\n message.payload,\n (action) => {\n if (action.type === \"__setState\") {\n if (store === void 0) {\n setStateFromDevtools(action.state);\n return;\n }\n if (Object.keys(action.state).length !== 1) {\n console.error(\n `\n [zustand devtools middleware] Unsupported __setState action format.\n When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),\n and value of this only key should be a state object. Example: { \"type\": \"__setState\", \"state\": { \"abc123Store\": { \"foo\": \"bar\" } } }\n `\n );\n }\n const stateFromDevtools = action.state[store];\n if (stateFromDevtools === void 0 || stateFromDevtools === null) {\n return;\n }\n if (JSON.stringify(api.getState()) !== JSON.stringify(stateFromDevtools)) {\n setStateFromDevtools(stateFromDevtools);\n }\n return;\n }\n if (shouldDispatchFromDevtools(api)) {\n api.dispatch(action);\n }\n }\n );\n case \"DISPATCH\":\n switch (message.payload.type) {\n case \"RESET\":\n setStateFromDevtools(initialState);\n if (store === void 0) {\n return connection == null ? void 0 : connection.init(api.getState());\n }\n return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n case \"COMMIT\":\n if (store === void 0) {\n connection == null ? void 0 : connection.init(api.getState());\n return;\n }\n return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n case \"ROLLBACK\":\n return parseJsonThen(message.state, (state) => {\n if (store === void 0) {\n setStateFromDevtools(state);\n connection == null ? void 0 : connection.init(api.getState());\n return;\n }\n setStateFromDevtools(state[store]);\n connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n });\n case \"JUMP_TO_STATE\":\n case \"JUMP_TO_ACTION\":\n return parseJsonThen(message.state, (state) => {\n if (store === void 0) {\n setStateFromDevtools(state);\n return;\n }\n if (JSON.stringify(api.getState()) !== JSON.stringify(state[store])) {\n setStateFromDevtools(state[store]);\n }\n });\n case \"IMPORT_STATE\": {\n const { nextLiftedState } = message.payload;\n const lastComputedState = (_a = nextLiftedState.computedStates.slice(-1)[0]) == null ? void 0 : _a.state;\n if (!lastComputedState) return;\n if (store === void 0) {\n setStateFromDevtools(lastComputedState);\n } else {\n setStateFromDevtools(lastComputedState[store]);\n }\n connection == null ? void 0 : connection.send(\n null,\n // FIXME no-any\n nextLiftedState\n );\n return;\n }\n case \"PAUSE_RECORDING\":\n return isRecording = !isRecording;\n }\n return;\n }\n });\n return initialState;\n};\nconst devtools = devtoolsImpl;\nconst parseJsonThen = (stringified, fn) => {\n let parsed;\n try {\n parsed = JSON.parse(stringified);\n } catch (e) {\n console.error(\n \"[zustand devtools middleware] Could not parse the received json\",\n e\n );\n }\n if (parsed !== void 0) fn(parsed);\n};\n\nconst subscribeWithSelectorImpl = (fn) => (set, get, api) => {\n const origSubscribe = api.subscribe;\n api.subscribe = ((selector, optListener, options) => {\n let listener = selector;\n if (optListener) {\n const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is;\n let currentSlice = selector(api.getState());\n listener = (state) => {\n const nextSlice = selector(state);\n if (!equalityFn(currentSlice, nextSlice)) {\n const previousSlice = currentSlice;\n optListener(currentSlice = nextSlice, previousSlice);\n }\n };\n if (options == null ? void 0 : options.fireImmediately) {\n optListener(currentSlice, currentSlice);\n }\n }\n return origSubscribe(listener);\n });\n const initialState = fn(set, get, api);\n return initialState;\n};\nconst subscribeWithSelector = subscribeWithSelectorImpl;\n\nfunction combine(initialState, create) {\n return (...args) => Object.assign({}, initialState, create(...args));\n}\n\nfunction createJSONStorage(getStorage, options) {\n let storage;\n try {\n storage = getStorage();\n } catch (e) {\n return;\n }\n const persistStorage = {\n getItem: (name) => {\n var _a;\n const parse = (str2) => {\n if (str2 === null) {\n return null;\n }\n return JSON.parse(str2, options == null ? void 0 : options.reviver);\n };\n const str = (_a = storage.getItem(name)) != null ? _a : null;\n if (str instanceof Promise) {\n return str.then(parse);\n }\n return parse(str);\n },\n setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue, options == null ? void 0 : options.replacer)),\n removeItem: (name) => storage.removeItem(name)\n };\n return persistStorage;\n}\nconst toThenable = (fn) => (input) => {\n try {\n const result = fn(input);\n if (result instanceof Promise) {\n return result;\n }\n return {\n then(onFulfilled) {\n return toThenable(onFulfilled)(result);\n },\n catch(_onRejected) {\n return this;\n }\n };\n } catch (e) {\n return {\n then(_onFulfilled) {\n return this;\n },\n catch(onRejected) {\n return toThenable(onRejected)(e);\n }\n };\n }\n};\nconst persistImpl = (config, baseOptions) => (set, get, api) => {\n let options = {\n storage: createJSONStorage(() => window.localStorage),\n partialize: (state) => state,\n version: 0,\n merge: (persistedState, currentState) => ({\n ...currentState,\n ...persistedState\n }),\n ...baseOptions\n };\n let hasHydrated = false;\n let hydrationVersion = 0;\n const hydrationListeners = /* @__PURE__ */ new Set();\n const finishHydrationListeners = /* @__PURE__ */ new Set();\n let storage = options.storage;\n if (!storage) {\n return config(\n (...args) => {\n console.warn(\n `[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`\n );\n set(...args);\n },\n get,\n api\n );\n }\n const setItem = () => {\n const state = options.partialize({ ...get() });\n return storage.setItem(options.name, {\n state,\n version: options.version\n });\n };\n const savedSetState = api.setState;\n api.setState = (state, replace) => {\n savedSetState(state, replace);\n return setItem();\n };\n const configResult = config(\n (...args) => {\n set(...args);\n return setItem();\n },\n get,\n api\n );\n api.getInitialState = () => configResult;\n let stateFromStorage;\n const hydrate = () => {\n var _a, _b;\n if (!storage) return;\n const currentVersion = ++hydrationVersion;\n hasHydrated = false;\n hydrationListeners.forEach((cb) => {\n var _a2;\n return cb((_a2 = get()) != null ? _a2 : configResult);\n });\n const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a = get()) != null ? _a : configResult)) || void 0;\n return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {\n if (deserializedStorageValue) {\n if (typeof deserializedStorageValue.version === \"number\" && deserializedStorageValue.version !== options.version) {\n if (options.migrate) {\n const migration = options.migrate(\n deserializedStorageValue.state,\n deserializedStorageValue.version\n );\n if (migration instanceof Promise) {\n return migration.then((result) => [true, result]);\n }\n return [true, migration];\n }\n console.error(\n `State loaded from storage couldn't be migrated since no migrate function was provided`\n );\n } else {\n return [false, deserializedStorageValue.state];\n }\n }\n return [false, void 0];\n }).then((migrationResult) => {\n var _a2;\n if (currentVersion !== hydrationVersion) {\n return;\n }\n const [migrated, migratedState] = migrationResult;\n stateFromStorage = options.merge(\n migratedState,\n (_a2 = get()) != null ? _a2 : configResult\n );\n set(stateFromStorage, true);\n if (migrated) {\n return setItem();\n }\n }).then(() => {\n if (currentVersion !== hydrationVersion) {\n return;\n }\n postRehydrationCallback == null ? void 0 : postRehydrationCallback(get(), void 0);\n stateFromStorage = get();\n hasHydrated = true;\n finishHydrationListeners.forEach((cb) => cb(stateFromStorage));\n }).catch((e) => {\n if (currentVersion !== hydrationVersion) {\n return;\n }\n postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);\n });\n };\n api.persist = {\n setOptions: (newOptions) => {\n options = {\n ...options,\n ...newOptions\n };\n if (newOptions.storage) {\n storage = newOptions.storage;\n }\n },\n clearStorage: () => {\n ++hydrationVersion;\n storage == null ? void 0 : storage.removeItem(options.name);\n },\n getOptions: () => options,\n rehydrate: () => hydrate(),\n hasHydrated: () => hasHydrated,\n onHydrate: (cb) => {\n hydrationListeners.add(cb);\n return () => {\n hydrationListeners.delete(cb);\n };\n },\n onFinishHydration: (cb) => {\n finishHydrationListeners.add(cb);\n return () => {\n finishHydrationListeners.delete(cb);\n };\n }\n };\n if (!options.skipHydration) {\n hydrate();\n }\n return stateFromStorage || configResult;\n};\nconst persist = persistImpl;\n\nfunction ssrSafe(config, isSSR = typeof window === \"undefined\") {\n return (set, get, api) => {\n if (!isSSR) {\n return config(set, get, api);\n }\n const ssrSet = () => {\n throw new Error(\"Cannot set state of Zustand store in SSR\");\n };\n api.setState = ssrSet;\n return config(ssrSet, get, api);\n };\n}\n\nexport { combine, createJSONStorage, devtools, persist, redux, subscribeWithSelector, ssrSafe as unstable_ssrSafe };\n","export enum LOADING_STATUS {\n ERROR = 'ERROR',\n IDLE = 'IDLE',\n LOADING = 'LOADING',\n SUCCESS = 'SUCCESS',\n}\n\nexport type FastaParseResult = {\n error?: string;\n expectedLength: number;\n invalidSequences?: { id: string; length: number }[];\n isAligned: boolean;\n sequences: FastaSequence[];\n};\n\nexport type FastaSequence = {\n accessionVersion: string;\n header: string;\n id: string;\n length: number;\n sequence: string;\n};\n","import type {\n FastaParseResult,\n FastaSequence,\n} from '../../models/fasta';\n\nexport class FastaUtil {\n public static parseFasta(content: string): FastaParseResult {\n if (!content?.trim()) {\n return FastaUtil.createErrorResult('The FASTA input is empty.');\n }\n\n const lines = content.split(/\\r?\\n/);\n const sequences: FastaSequence[] = [];\n let currentHeader = '';\n let currentSeqParts: string[] = [];\n\n const commitSequence = (): FastaParseResult | null => {\n if (currentHeader) {\n const fullSeq = currentSeqParts.join('').replace(/\\s/g, '').toUpperCase();\n if (!fullSeq.length) {\n return FastaUtil.createErrorResult(`FASTA record \"${currentHeader}\" has no sequence.`);\n }\n\n // Extract ID: part before pipe or tab, sanitized for Newick compatibility\n const firstPart = currentHeader.split(/[|\\t]/)[0].trim();\n const safeId = firstPart.replace(/[():;,']/g, '_');\n\n sequences.push({\n accessionVersion: safeId,\n header: currentHeader,\n id: safeId,\n length: fullSeq.length,\n sequence: fullSeq,\n });\n }\n return null;\n };\n\n for (const sourceLine of lines) {\n const line = sourceLine.trim();\n if (!line) {\n continue;\n }\n\n if (line.startsWith('>')) {\n const error = commitSequence();\n if (error) {\n return error;\n }\n currentHeader = line.slice(1).trim();\n if (!currentHeader) {\n return FastaUtil.createErrorResult('Every FASTA record needs a non-empty header.');\n }\n currentSeqParts = [];\n } else {\n if (!currentHeader) {\n return FastaUtil.createErrorResult('FASTA sequence data appeared before its first header.');\n }\n currentSeqParts.push(line);\n }\n }\n const error = commitSequence();\n if (error) {\n return error;\n }\n\n if (sequences.length === 0) {\n return FastaUtil.createErrorResult('No FASTA records were found.');\n }\n\n // Pre-alignment validation: verify all sequence lengths are equal\n const firstLength = sequences[0].length;\n const invalidSequences = sequences.filter((s) => s.length !== firstLength).map((s) => ({ id: s.id, length: s.length }));\n\n const isAligned = invalidSequences.length === 0;\n\n return {\n expectedLength: firstLength,\n invalidSequences: isAligned ? undefined : invalidSequences,\n isAligned,\n sequences,\n };\n }\n\n public static stripFastaHeaders(fastaContent: string): string {\n const lines = fastaContent.split('\\n');\n const strippedLines = lines.map((line) => {\n if (line.startsWith('>')) {\n const cleanHeader = line.substring(1).trim();\n const firstPart = cleanHeader.split(/[|\\t]/)[0].trim();\n const safeId = firstPart.replace(/[():;,']/g, '_');\n return `>${safeId}`;\n }\n return line;\n });\n return strippedLines.join('\\n');\n }\n\n\n private static createErrorResult(error: string): FastaParseResult {\n return {\n error,\n expectedLength: 0,\n isAligned: false,\n sequences: [],\n };\n }\n\n}\n","import type {\n MetadataParseResult,\n MetadataRecord,\n} from '../../models/metadata';\n\nexport class MetaDataUtil {\n /**\n * Compute the best matching metadata column for the given FASTA sequence IDs.\n */\n public static findBestMatchingColumn = (\n columns: string[],\n recordsByColumn: Record<string, Record<string, MetadataRecord>>,\n fastaIds: string[],\n ): { bestColumn: null | string; matchCounts: Record<string, number> } => {\n const matchCounts = MetaDataUtil.getMatchCounts(columns, recordsByColumn, fastaIds);\n let bestColumn: null | string = null;\n let maxMatches = -1;\n\n if (!columns || !recordsByColumn || !fastaIds || fastaIds.length === 0) {\n return { bestColumn: null, matchCounts: {} };\n }\n\n const prioritizedKeys = [\n 'displayname',\n 'accessionversion',\n 'accession',\n 'sampleid',\n 'sample_id',\n 'id',\n 'strain',\n 'isolate',\n 'submissionid',\n 'name',\n ];\n\n for (const col of columns) {\n const colDict = recordsByColumn[col];\n if (!colDict) {\n continue;\n }\n\n const count = matchCounts[col];\n\n if (count > maxMatches) {\n maxMatches = count;\n bestColumn = col;\n } else if (count === maxMatches && count > 0 && bestColumn) {\n // Tie-breaker: prioritize standard ID column names\n const currentPriority = prioritizedKeys.indexOf(bestColumn.toLowerCase());\n const newPriority = prioritizedKeys.indexOf(col.toLowerCase());\n if (newPriority !== -1 && (currentPriority === -1 || newPriority < currentPriority)) {\n bestColumn = col;\n }\n }\n }\n\n if (maxMatches <= 0) {\n // If no matches, default to highest priority known ID column if available\n for (const pKey of prioritizedKeys) {\n const found = columns.find((c) => c.toLowerCase() === pKey);\n if (found) {\n bestColumn = found;\n break;\n }\n }\n if (!bestColumn && columns.length > 0) {\n bestColumn = columns[0];\n }\n }\n\n return { bestColumn, matchCounts };\n };\n\n public static getHighlightedIds(query: string, allAccessions: string[], metadataRecords: MetadataRecord[], matchKeyField: null | string = null): string[] {\n const trimmed = query.trim().toLowerCase();\n if (!trimmed) {\n return [];\n }\n\n const matched = new Set<string>();\n\n // Check accession names / fasta IDs\n allAccessions.forEach((acc) => {\n if (acc.toLowerCase().includes(trimmed)) {\n matched.add(acc);\n }\n });\n\n // Check metadata records\n metadataRecords.forEach((rec) => {\n const acc =\n (matchKeyField && rec[matchKeyField]) ||\n rec.displayName ||\n rec.accessionVersion ||\n rec.accession ||\n rec.id ||\n rec.submissionId ||\n rec.SampleID;\n if (acc) {\n const matchesAnyField = Object.values(rec).some(\n (val) => typeof val === 'string' && val.toLowerCase().includes(trimmed),\n );\n if (matchesAnyField) {\n matched.add(acc);\n }\n }\n });\n\n return Array.from(matched);\n }\n /**\n * Count FASTA sequence ID matches for each metadata column.\n */\n public static getMatchCounts = (\n columns: string[],\n recordsByColumn: Record<string, Record<string, MetadataRecord>>,\n fastaIds: string[],\n ): Record<string, number> => {\n const matchCounts: Record<string, number> = {};\n\n if (!columns || !recordsByColumn || !fastaIds || fastaIds.length === 0) {\n return matchCounts;\n }\n\n for (const col of columns) {\n const colDict = recordsByColumn[col];\n if (!colDict) {\n continue;\n }\n\n let count = 0;\n for (const id of fastaIds) {\n if (colDict[id]) {\n count++;\n }\n }\n matchCounts[col] = count;\n }\n\n return matchCounts;\n };\n\n /**\n * Retrieve metadata record for a given sample/node name with fallback strategies.\n */\n public static readonly getRecordForSample = (\n metadata: MetadataParseResult | null | undefined,\n sampleId: string,\n matchKeyField?: null | string,\n ): MetadataRecord | undefined => {\n if (!metadata || !sampleId) {\n return undefined;\n }\n\n // 1. If matchKeyField is specified and exists, check it first\n if (matchKeyField && metadata.recordsByColumn?.[matchKeyField]) {\n const rec = metadata.recordsByColumn[matchKeyField][sampleId];\n if (rec) {\n return rec;\n }\n }\n\n // 2. Check displayName\n if (metadata.recordsByColumn?.['displayName']?.[sampleId]) {\n return metadata.recordsByColumn['displayName'][sampleId];\n }\n\n // 3. Check accessionVersion\n if (metadata.recordsByColumn?.['accessionVersion']?.[sampleId]) {\n return metadata.recordsByColumn['accessionVersion'][sampleId];\n }\n\n // 4. Check accession maps\n if (metadata.recordsByAccession[sampleId]) {\n return metadata.recordsByAccession[sampleId];\n }\n if (metadata.recordsBySampleId[sampleId]) {\n return metadata.recordsBySampleId[sampleId];\n }\n\n // 5. Broad search through all indexed columns\n if (metadata.recordsByColumn) {\n for (const col of Object.keys(metadata.recordsByColumn)) {\n const match = metadata.recordsByColumn[col][sampleId];\n if (match) {\n return match;\n }\n }\n }\n\n return undefined;\n };\n\n public static parseTsv = (content: string): MetadataParseResult => {\n if (!content?.trim()) {\n return {\n columns: [],\n error: 'Empty metadata content provided.',\n records: [],\n recordsByAccession: {},\n recordsByColumn: {},\n recordsBySampleId: {},\n };\n }\n\n const lines = content.trim().split('\\n');\n if (lines.length < 2) {\n return {\n columns: [],\n error: 'Metadata file must contain at least a header row and one data row.',\n records: [],\n recordsByAccession: {},\n recordsByColumn: {},\n recordsBySampleId: {},\n };\n }\n\n // Parse header row\n const headerLine = lines[0].trim();\n let delimiter = '\\t';\n if (!headerLine.includes('\\t') && headerLine.includes(',')) {\n delimiter = ',';\n }\n const columns = headerLine\n .split(delimiter)\n .map((col) => col.trim().replace(/^[\"']|[\"']$/g, ''))\n .filter((c) => c.length > 0);\n\n const records: MetadataRecord[] = [];\n const recordsByAccession: Record<string, MetadataRecord> = {};\n const recordsBySampleId: Record<string, MetadataRecord> = {};\n const recordsByColumn: Record<string, Record<string, MetadataRecord>> = {};\n\n columns.forEach((col) => {\n recordsByColumn[col] = {};\n });\n\n for (let i = 1; i < lines.length; i++) {\n const line = lines[i].trim();\n if (!line) {\n continue;\n }\n\n const values = line.split(delimiter).map((val) => val.trim().replace(/^[\"']|[\"']$/g, ''));\n const record: MetadataRecord = {};\n\n columns.forEach((col, colIdx) => {\n const val = values[colIdx] ?? '';\n record[col] = val;\n if (val) {\n recordsByColumn[col][val] = record;\n }\n });\n\n records.push(record);\n\n // Index by potential ID keys\n const accessionKey =\n record.displayName ||\n record.accessionVersion ||\n record.accession ||\n record.id ||\n record.submissionId ||\n record.strain ||\n record.isolate ||\n record.name;\n\n if (accessionKey) {\n recordsByAccession[accessionKey] = record;\n }\n\n const sampleIdKey =\n record.SampleID ||\n record.sampleId ||\n record.sample_id ||\n record.specimenCollectorSampleId ||\n record.id;\n\n if (sampleIdKey) {\n recordsBySampleId[sampleIdKey] = record;\n }\n }\n\n return {\n columns,\n records,\n recordsByAccession,\n recordsByColumn,\n recordsBySampleId,\n };\n };\n}\n","import type { StoreApi } from 'zustand';\n\nimport type { FastaParseResult } from '../../models/fasta';\nimport { LOADING_STATUS } from '../../models/fasta';\nimport type { MetadataParseResult } from '../../models/metadata';\nimport { FastaUtil } from '../../utils/FastaUtil';\nimport { MetaDataUtil } from '../../utils/MetaDataUtil';\n\nexport type FastaDataStore = FastaDataStoreActions & FastaDataStoreState;\n\nexport interface FastaDataStoreActions {\n resetDataset: () => void;\n setColumnMatchCounts: (counts: Record<string, number>) => void;\n setData: (fasta: string, tsv?: string) => Promise<{ fastaResult: FastaParseResult; metadataResult?: MetadataParseResult }>;\n setLoadingStatus: (status: LOADING_STATUS) => void;\n setMatchKeyField: (field: null | string) => void;\n}\n\nexport interface FastaDataStoreState {\n columnMatchCounts: Record<string, number>;\n loadingError: null | string;\n loadingStatus: LOADING_STATUS;\n matchKeyField: null | string;\n parsedFasta: FastaParseResult | null;\n parsedMetadata: MetadataParseResult | null;\n rawFasta: string;\n rawMetadata: string;\n}\n\nexport const createFastaDataStoreInitialState = (): FastaDataStoreState => ({\n columnMatchCounts: {},\n loadingError: null,\n loadingStatus: LOADING_STATUS.IDLE,\n matchKeyField: null,\n parsedFasta: null,\n parsedMetadata: null,\n rawFasta: '',\n rawMetadata: '',\n});\n\n\ntype Get<T extends FastaDataStore> = StoreApi<T>['getState'];\ntype Set<T extends FastaDataStore> = StoreApi<T>['setState'];\n\nexport const createFastaDataStoreActions = <T extends FastaDataStore>(kwArgs: { get: Get<T>; set: Set<T> }): FastaDataStoreActions => {\n const { get, set } = kwArgs;\n const setBaseState = (partial: Partial<FastaDataStoreState>) => set(partial as Partial<T>);\n\n return {\n resetDataset: () => setBaseState(createFastaDataStoreInitialState()),\n setColumnMatchCounts: (counts: Record<string, number>) => setBaseState({ columnMatchCounts: counts }),\n setData: async (fasta: string, tsv?: string) => {\n const parsedFasta = FastaUtil.parseFasta(fasta);\n\n if (parsedFasta.error) {\n setBaseState({\n loadingError: parsedFasta.error,\n loadingStatus: LOADING_STATUS.ERROR,\n });\n throw new Error(parsedFasta.error);\n }\n\n setBaseState({\n parsedFasta,\n rawFasta: fasta,\n });\n\n let parsedMetadata: MetadataParseResult | undefined;\n if (tsv) {\n parsedMetadata = MetaDataUtil.parseTsv(tsv);\n if (parsedMetadata.error) {\n setBaseState({\n loadingError: parsedMetadata.error,\n loadingStatus: LOADING_STATUS.ERROR,\n });\n throw new Error(parsedMetadata.error);\n }\n\n setBaseState({\n parsedMetadata,\n rawMetadata: tsv,\n });\n\n const fastaIds = parsedFasta.sequences.map((s) => s.id);\n const { bestColumn, matchCounts } = MetaDataUtil.findBestMatchingColumn(\n parsedMetadata.columns,\n parsedMetadata.recordsByColumn,\n fastaIds,\n );\n get().setColumnMatchCounts(matchCounts);\n get().setMatchKeyField(bestColumn);\n }\n\n setBaseState({\n loadingError: null,\n loadingStatus: LOADING_STATUS.SUCCESS,\n });\n return Promise.resolve({ fastaResult: parsedFasta, metadataResult: parsedMetadata });\n },\n setLoadingStatus: (status: LOADING_STATUS) => setBaseState({ loadingStatus: status }),\n setMatchKeyField: (field: null | string) => setBaseState({ matchKeyField: field }),\n };\n};\n","import { createStore } from 'zustand';\nimport {\n createJSONStorage,\n persist,\n} from 'zustand/middleware';\nimport type {\n FastaDataStoreActions,\n FastaDataStoreState,\n} from '@rivm-loculus-tools/common-frontend/stores/fastaDataStore';\nimport {\n createFastaDataStoreActions,\n createFastaDataStoreInitialState,\n} from '@rivm-loculus-tools/common-frontend/stores/fastaDataStore';\n\nimport type {\n AminoAcidPalette,\n EditorSelection,\n EngineMeta,\n EngineSearchResult,\n NucleotidePalette,\n} from '../../models';\nimport {\n ALI_VIEW_DEFAULT_AMINO_ACID_PALETTE,\n ALI_VIEW_DEFAULT_NUCLEOTIDE_PALETTE,\n} from '../../constants';\n\nexport type SequenceEditorStore = SequenceEditorStoreActions & SequenceEditorStoreState;\n\nexport interface SequenceEditorStoreActions extends FastaDataStoreActions {\n setAminoAcidPalette: (palette: AminoAcidPalette) => void;\n setLatestMessage: (message: null | string) => void;\n setMeta: (meta: EngineMeta | null) => void;\n setNucleotidePalette: (palette: NucleotidePalette) => void;\n setSearchQuery: (query: string) => void;\n setSearchResult: (results: EngineSearchResult | null) => void;\n setSearchResultHighlightedIndex: (index: null | number) => void;\n setSelection: (selection: EditorSelection | null) => void;\n}\n\nexport interface SequenceEditorStoreState extends FastaDataStoreState {\n aminoAcidPalette: AminoAcidPalette;\n latestMessage: null | string;\n meta: EngineMeta | null;\n nucleotidePalette: NucleotidePalette;\n searchQuery: string;\n searchResult: EngineSearchResult | null;\n searchResultHighlightedIndex: null | number;\n selection: EditorSelection | null;\n}\n\nconst createSequenceEditorStoreInitialState = (): SequenceEditorStoreState => ({\n ...createFastaDataStoreInitialState(),\n aminoAcidPalette: ALI_VIEW_DEFAULT_AMINO_ACID_PALETTE,\n latestMessage: null,\n meta: null,\n nucleotidePalette: ALI_VIEW_DEFAULT_NUCLEOTIDE_PALETTE,\n searchQuery: '',\n searchResult: null,\n searchResultHighlightedIndex: null,\n selection: null,\n});\n\nexport const sequenceEditorStore = createStore<SequenceEditorStore>()(\n persist(\n (set, get) => {\n const initialState = createSequenceEditorStoreInitialState();\n const fastaDataStoreActions = createFastaDataStoreActions({ get, set });\n\n return {\n ...initialState,\n ...fastaDataStoreActions,\n setAminoAcidPalette: (palette: AminoAcidPalette) => set({ aminoAcidPalette: palette }),\n setLatestMessage: (message: null | string) => set({ latestMessage: message }),\n setMeta: (meta: EngineMeta | null) => set({ meta }),\n setNucleotidePalette: (palette: NucleotidePalette) => set({ nucleotidePalette: palette }),\n setSearchQuery: (query: string) => {\n const { setSearchResult, setSearchResultHighlightedIndex: setSearchResultsHighlightedIndex } = get();\n set({ searchQuery: query });\n if (!query) {\n setSearchResultsHighlightedIndex(null);\n setSearchResult(null);\n }\n },\n setSearchResult: (results: EngineSearchResult | null) => {\n const { setSearchResultHighlightedIndex: setSearchResultsHighlightedIndex } = get();\n set({ searchResult: results });\n setSearchResultsHighlightedIndex(null);\n },\n setSearchResultHighlightedIndex: (index: null | number) => set({ searchResultHighlightedIndex: index }),\n setSelection: (selection: EditorSelection | null) => set({ selection }),\n };\n },\n {\n name: 'LOCULUS-SEQUENCE-EDITOR-Configuration',\n partialize: (state) => ({\n aminoAcidPalette: state.aminoAcidPalette,\n nucleotidePalette: state.nucleotidePalette,\n }),\n storage: createJSONStorage(() => localStorage),\n version: 1,\n },\n ),\n);\n"],"x_google_ignoreList":[0,1],"mappings":";;;AAAA,IAAM,KAAmB,MAAgB;CACvC,IAAI,GACE,oBAA4B,IAAI,IAAI,GACpC,KAAY,GAAS,MAAY;EACrC,IAAM,IAAY,OAAO,KAAY,aAAa,EAAQ,CAAK,IAAI;EACnE,IAAI,C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