@rivm-loculus-tools/sequence-editor 1.0.1 → 1.2.0

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 (44) hide show
  1. package/dist/_chunks/EngineErrorUtil.js +1 -2
  2. package/dist/_chunks/SequenceEditor.js +208 -177
  3. package/dist/_chunks/SequenceEditor.js.map +1 -1
  4. package/dist/_chunks/SequenceEditorEventBusService.js +2 -4
  5. package/dist/_chunks/SequenceEditorEventBusService.js.map +1 -1
  6. package/dist/_chunks/SequenceEditorPageDrawer.js +1 -2
  7. package/dist/_chunks/comlink.js +1 -2
  8. package/dist/_chunks/react.js +2 -3
  9. package/dist/_chunks/react.js.map +1 -1
  10. package/dist/_chunks/sequenceEditorStore.js +3 -5
  11. package/dist/_chunks/sequenceEditorStore.js.map +1 -1
  12. package/dist/assets/{index-B5Du4hQk.js → index-CtQs0yk0.js} +3 -3
  13. package/dist/assets/index-CtQs0yk0.js.map +1 -0
  14. package/dist/classes/services/EditorWorkerService/EditorWorkerService.d.ts +8 -3
  15. package/dist/classes/services/EditorWorkerService/index.js +27 -3
  16. package/dist/classes/services/EditorWorkerService/index.js.map +1 -1
  17. package/dist/classes/services/SequenceEditorEventBusService/SequenceEditorEventBusService.d.ts +2 -0
  18. package/dist/classes/workers/EngineWorker/EngineWorker.d.ts +8 -3
  19. package/dist/classes/workers/EngineWorker/index.js +29 -4
  20. package/dist/classes/workers/EngineWorker/index.js.map +1 -1
  21. package/dist/components/app/App/index.js +1 -2
  22. package/dist/components/ui/SequenceEditorPageHeader/index.js +70 -40
  23. package/dist/components/ui/SequenceEditorPageHeader/index.js.map +1 -1
  24. package/dist/components/ui/SequenceEditorSearchBar/index.js +1 -2
  25. package/dist/constants/editor.js +1 -2
  26. package/dist/constants/keyboard.js +1 -2
  27. package/dist/constants/palette.js +1 -2
  28. package/dist/models/config.models.d.ts +2 -0
  29. package/dist/models/editor.models.d.ts +27 -11
  30. package/dist/models/editor.models.js +1 -2
  31. package/dist/models/editor.models.js.map +1 -1
  32. package/dist/models/palette.models.js +1 -2
  33. package/dist/models/palette.models.js.map +1 -1
  34. package/dist/pages/SequenceEditorMainPage/index.js +19 -41
  35. package/dist/pages/SequenceEditorMainPage/index.js.map +1 -1
  36. package/dist/utils/EditorUtil/EditorUtil.d.ts +4 -2
  37. package/dist/utils/EditorUtil/index.js +97 -38
  38. package/dist/utils/EditorUtil/index.js.map +1 -1
  39. package/dist/utils/PaletteUtil/index.js +1 -2
  40. package/dist/utils/SequenceEditorStandardConfigUtil/SequenceEditorStandardConfigUtil.d.ts +2 -1
  41. package/dist/utils/SequenceEditorStandardConfigUtil/index.js +1 -3
  42. package/dist/utils/SequenceEditorStandardConfigUtil/index.js.map +1 -1
  43. package/package.json +17 -17
  44. package/dist/assets/index-B5Du4hQk.js.map +0 -1
@@ -14,9 +14,10 @@ import { container as b } from "tsyringe";
14
14
  import { jsx as x, jsxs as S } from "react/jsx-runtime";
15
15
  import { Subject as C } from "@gen-epix/ui-core/classes/Subject";
16
16
  import { DEVICE_PIXEL_RATIO_SERVICE_TOKEN as w, KEYBOARD_SHORTCUT_SERVICE_TOKEN as T } from "@rivm-loculus-tools/common-frontend/constants/config.constants";
17
- import { withDialog as E } from "@gen-epix/ui-core-components/hoc/withDialog";
18
- //#region ../../../../node_modules/.pnpm/use-debounce@10.1.1_react@19.3.0/node_modules/use-debounce/dist/index.module.js
19
- function D(e, t, n, r) {
17
+ import { ExportUtil as E } from "@rivm-loculus-tools/common-frontend/utils/ExportUtil";
18
+ import { withDialog as D } from "@gen-epix/ui-core-components/hoc/withDialog";
19
+ // ../../../../node_modules/.pnpm/use-debounce@10.1.1_react@19.3.1/node_modules/use-debounce/dist/index.module.js
20
+ function O(e, t, n, r) {
20
21
  var i = this, a = m(null), o = m(0), s = m(0), c = m(null), l = m([]), u = m(), d = m(), h = m(e), g = m(!0), _ = m(), v = m();
21
22
  h.current = e;
22
23
  var y = typeof window < "u", b = !t && t !== 0 && y;
@@ -82,9 +83,8 @@ function D(e, t, n, r) {
82
83
  };
83
84
  }, [C]), D;
84
85
  }
85
- //#endregion
86
- //#region src/components/ui/SequenceEditor/SequenceEditorStatusBar.tsx
87
- var O = () => {
86
+ // src/components/ui/SequenceEditor/SequenceEditorStatusBar.tsx
87
+ var ee = () => {
88
88
  let n = y(), r = t(e, (e) => e.latestMessage), i = t(e, (e) => e.meta), a = t(e, (e) => e.selection), o = p(() => c.getStatusBarSelectionStats(a, i), [i, a]);
89
89
  return /* @__PURE__ */ x(g, {
90
90
  sx: {
@@ -119,7 +119,7 @@ var O = () => {
119
119
  ]
120
120
  })
121
121
  });
122
- }, k = /^(?:\d+|,\d+|\d+,\d+)$/, ee = E(({ onActionsChange: e, onClose: t, onGotoPosition: n }) => {
122
+ }, k = /^(?:\d+|,\d+|\d+,\d+)$/, te = D(({ onActionsChange: e, onClose: t, onGotoPosition: n }) => {
123
123
  let [r, i] = h(""), a = m(null), o = r === "" || k.test(r);
124
124
  f(() => {
125
125
  a.current?.focus();
@@ -173,25 +173,25 @@ var O = () => {
173
173
  fullWidth: !0,
174
174
  maxWidth: "xs",
175
175
  testId: "SequenceEditorGotoPositionDialog"
176
- }), A = () => {
177
- let _ = t(e, (e) => e.rawFasta), v = t(e, (e) => e.setLatestMessage), E = t(e, (e) => e.setMeta), k = t(e, (e) => e.setSelection), A = m(null), j = p(() => b.resolve(l), []), M = m(null), N = m(null), P = m(null), F = m(null), I = m(null), L = m(null), [R, te] = h({
176
+ }), ne = () => {
177
+ let _ = t(e, (e) => e.rawFasta), v = t(e, (e) => e.setLatestMessage), D = t(e, (e) => e.setMeta), k = t(e, (e) => e.setSelection), ne = m(null), A = p(() => b.resolve(l), []), j = m(null), M = m(null), N = m(null), P = m(null), F = m(null), I = m(null), [L, re] = h({
178
178
  height: 0,
179
179
  width: 0
180
- }), [ne, re] = h(() => b.resolve(w).data), [ie, ae] = h(0), [oe, se] = h(0), z = p(() => new C({
180
+ }), [ie, ae] = h(() => b.resolve(w).data), [oe, se] = h(0), [ce, le] = h(0), R = p(() => new C({
181
181
  scrollLeft: 0,
182
182
  scrollTop: 0
183
- }), []), ce = m(R), B = p(() => new C(null), []), V = p(() => new C(null), []), H = m(null), U = m(null), W = p(() => new C(n), []), G = p(() => new C(null), []), K = m(null), q = m(0), J = m(null), le = m(!1), Y = y(), X = d(() => {
184
- let e = W.data, t = B.data;
183
+ }), []), ue = m(L), z = p(() => new C(null), []), B = p(() => new C(null), []), V = m(null), H = m(null), U = p(() => new C(n), []), W = p(() => new C(null), []), G = m(null), K = m(0), q = m(null), J = m(!1), Y = y(), X = d(() => {
184
+ let e = U.data, t = z.data;
185
185
  if (!e || !t) return;
186
186
  let n = e.labelWidth + e.cellWidth + t.alignmentWidth * e.cellWidth, r = e.rulerHeight + t.sequenceCount * e.cellHeight;
187
- se(n), ae(r);
188
- }, [W, B]), Z = d(async () => {
187
+ le(n), se(r);
188
+ }, [U, z]), Z = d(async () => {
189
189
  let e = await b.resolve(l).getMetaData();
190
- B.next(e);
191
- }, [B]), Q = d(() => {
192
- let e = W.data, t = B.data;
190
+ return z.next(e), e;
191
+ }, [z]), Q = d(() => {
192
+ let e = U.data, t = z.data;
193
193
  if (!t || !e) return;
194
- let { scrollLeft: n, scrollTop: r } = z.data, { height: i, width: a } = ce.current, o = c.getVisibleGridRange({
194
+ let { scrollLeft: n, scrollTop: r } = R.data, { height: i, width: a } = ue.current, o = c.getVisibleGridRange({
195
195
  geometry: e,
196
196
  numCols: t.alignmentWidth,
197
197
  numRows: t.sequenceCount,
@@ -200,7 +200,7 @@ var O = () => {
200
200
  viewportHeight: i,
201
201
  viewportWidth: a
202
202
  });
203
- V.next({
203
+ B.next({
204
204
  geometry: e,
205
205
  scrollLeft: n,
206
206
  scrollTop: r,
@@ -209,94 +209,94 @@ var O = () => {
209
209
  visibleGridRange: o
210
210
  });
211
211
  }, [
212
- W,
213
- B,
212
+ U,
214
213
  z,
215
- V
216
- ]), ue = D((e, t) => {
217
- te({
214
+ R,
215
+ B
216
+ ]), de = O((e, t) => {
217
+ re({
218
218
  height: t,
219
219
  width: e
220
220
  });
221
221
  }, 0, { trailing: !0 });
222
222
  f(() => {
223
- ce.current = R, Q();
224
- }, [R, Q]);
225
- let $ = R.width > 0 ? R.width / 2 : 120;
223
+ ue.current = L, Q();
224
+ }, [L, Q]);
225
+ let $ = L.width > 0 ? L.width / 2 : 120;
226
226
  f(() => {
227
- let e = [B.subscribe((e) => {
228
- E(e);
229
- }), G.subscribe((e) => {
227
+ let e = [z.subscribe((e) => {
228
+ D(e);
229
+ }), W.subscribe((e) => {
230
230
  k(e);
231
231
  })];
232
232
  return () => {
233
- e.forEach((e) => e()), v(null), E(null), k(null);
233
+ e.forEach((e) => e()), v(null), D(null), k(null);
234
234
  };
235
235
  }, [
236
- B,
237
- G,
236
+ z,
237
+ W,
238
238
  v,
239
- E,
239
+ D,
240
240
  k
241
241
  ]), f(() => {
242
- if (R.width <= 0) return;
243
- let e = W.data;
244
- e.labelWidth > $ && W.next({
242
+ if (L.width <= 0) return;
243
+ let e = U.data;
244
+ e.labelWidth > $ && U.next({
245
245
  ...e,
246
246
  labelWidth: $
247
247
  });
248
248
  }, [
249
- R.width,
250
- W,
249
+ L.width,
250
+ U,
251
251
  $
252
252
  ]), f(() => {
253
- let e = L.current;
253
+ let e = I.current;
254
254
  if (!e) return;
255
255
  let t = new ResizeObserver(([e]) => {
256
256
  if (!e) return;
257
257
  let t = Math.max(1, e.contentRect.height), n = Math.max(1, e.contentRect.width);
258
- ue(n, t);
258
+ de(n, t);
259
259
  });
260
260
  return t.observe(e), () => t.disconnect();
261
- }, [j, ue]), f(() => {
261
+ }, [A, de]), f(() => {
262
262
  (async () => {
263
- H.current = null, U.current = null, z.next({
263
+ V.current = null, H.current = null, R.next({
264
264
  scrollLeft: 0,
265
265
  scrollTop: 0
266
- }), G.next(null), await j.initialize(), await j.loadFasta(_), await Z(), Q();
266
+ }), W.next(null), await A.initialize(), await A.loadFasta(_), await Z(), Q();
267
267
  })().catch((e) => {
268
268
  console.error(e);
269
269
  });
270
270
  }, [
271
- j,
271
+ A,
272
272
  _,
273
- z,
274
- G,
273
+ R,
274
+ W,
275
275
  Z,
276
276
  Q
277
277
  ]), f(() => {
278
278
  let t = null, n = !0, r = null, i = null, a = async () => {
279
- if (n && !le.current) {
280
- le.current = !0;
279
+ if (n && !J.current) {
280
+ J.current = !0;
281
281
  try {
282
- for (; n && J.current;) {
283
- let a = J.current;
284
- J.current = null;
285
- let o = q.current;
286
- if (!U.current || !c.isWithinGridRange({
287
- cachedGridRange: U.current.range,
282
+ for (; n && q.current;) {
283
+ let a = q.current;
284
+ q.current = null;
285
+ let o = K.current;
286
+ if (!H.current || !c.isWithinGridRange({
287
+ cachedGridRange: H.current.range,
288
288
  visibleGridRange: a.visibleGridRange.visible
289
289
  })) {
290
290
  let e = [];
291
- for (let t = a.visibleGridRange.cache.startRow; t <= a.visibleGridRange.cache.endRow; t++) e.push(await j.name(t));
291
+ for (let t = a.visibleGridRange.cache.startRow; t <= a.visibleGridRange.cache.endRow; t++) e.push(await A.name(t));
292
292
  if (!n) return;
293
- U.current = {
293
+ H.current = {
294
294
  range: a.visibleGridRange.cache,
295
295
  rowNames: e
296
296
  };
297
297
  }
298
- if (!H.current || !c.isWithinGridRange({
299
- cachedGridRange: H.current.range,
298
+ if (!V.current || !c.isWithinGridRange({
299
+ cachedGridRange: V.current.range,
300
300
  visibleGridRange: a.visibleGridRange.visible
301
301
  })) {
302
302
  let e = await b.resolve(l).viewport({
@@ -306,82 +306,82 @@ var O = () => {
306
306
  startRow: a.visibleGridRange.cache.startRow
307
307
  });
308
308
  if (!n) return;
309
- H.current = {
309
+ V.current = {
310
310
  range: a.visibleGridRange.cache,
311
311
  viewportResult: e
312
312
  };
313
313
  }
314
- o === q.current && (t !== null && cancelAnimationFrame(t), t = requestAnimationFrame(() => {
315
- n && o === q.current && M.current && e.getState().nucleotidePalette && H.current && B.data && U.current && (N.current = c.drawCanvas({
316
- canvasElement: M.current,
314
+ o === K.current && (t !== null && cancelAnimationFrame(t), t = requestAnimationFrame(() => {
315
+ n && o === K.current && j.current && e.getState().nucleotidePalette && V.current && z.data && H.current && (M.current = c.drawCanvas({
316
+ canvasElement: j.current,
317
317
  devicePixelRatio: b.resolve(w).data,
318
318
  geometry: a.geometry,
319
- meta: B.data,
319
+ meta: z.data,
320
320
  palette: e.getState().nucleotidePalette,
321
- rowNames: U.current.rowNames,
322
- rowNamesStartRow: U.current.range.startRow,
321
+ rowNames: H.current.rowNames,
322
+ rowNamesStartRow: H.current.range.startRow,
323
323
  scrollLeft: a.scrollLeft,
324
324
  scrollTop: a.scrollTop,
325
325
  searchResult: r,
326
326
  searchResultHighlightedIndex: i,
327
- selection: G.data,
328
- viewport: H.current.viewportResult,
327
+ selection: W.data,
328
+ viewport: V.current.viewportResult,
329
329
  viewportHeight: a.viewportHeight,
330
330
  viewportWidth: a.viewportWidth
331
331
  }));
332
332
  }));
333
333
  }
334
334
  } finally {
335
- le.current = !1, n && J.current && a();
335
+ J.current = !1, n && q.current && a();
336
336
  }
337
337
  }
338
338
  }, o = [e.subscribe((e, t) => {
339
339
  let n = !1;
340
340
  e.searchResult !== t.searchResult && (r = e.searchResult, n = !0), e.searchResultHighlightedIndex !== t.searchResultHighlightedIndex && (i = e.searchResultHighlightedIndex, c.scrollToSearchResult({
341
- geometry: W.data,
342
- scrollContainer: L.current,
341
+ geometry: U.data,
342
+ scrollContainer: I.current,
343
343
  searchResult: e.searchResult,
344
344
  searchResultHighlightedIndex: e.searchResultHighlightedIndex
345
345
  }), n = !0), n && Q();
346
- }), V.subscribe((e) => {
347
- e && (J.current = e, q.current += 1, a());
346
+ }), B.subscribe((e) => {
347
+ e && (q.current = e, K.current += 1, a());
348
348
  })];
349
349
  return () => {
350
- n = !1, J.current = null, t !== null && cancelAnimationFrame(t), q.current += 1, o.forEach((e) => e());
350
+ n = !1, q.current = null, t !== null && cancelAnimationFrame(t), K.current += 1, o.forEach((e) => e());
351
351
  };
352
352
  }, [
353
- j,
353
+ A,
354
+ U,
355
+ z,
354
356
  W,
355
- B,
356
- G,
357
357
  Q,
358
- V
358
+ B
359
359
  ]), f(() => {
360
360
  let t = [
361
361
  e.subscribe((e, t) => {
362
362
  e.nucleotidePalette?.name !== t.nucleotidePalette?.name && Q();
363
363
  }),
364
- W.subscribe(() => {
364
+ U.subscribe(() => {
365
365
  X(), Q();
366
366
  }),
367
- z.subscribe(() => Q()),
368
- B.subscribe((e) => {
367
+ R.subscribe(() => Q()),
368
+ z.subscribe((e) => {
369
369
  e && (X(), Q());
370
370
  }),
371
- G.subscribe(() => Q()),
371
+ W.subscribe(() => Q()),
372
372
  b.resolve(w).subscribe((e) => {
373
- re(e), X(), Q();
373
+ ae(e), X(), Q();
374
374
  })
375
375
  ];
376
376
  return () => {
377
377
  t.forEach((e) => e());
378
378
  };
379
379
  }, [
380
- j,
381
- W,
382
- B,
380
+ A,
381
+ U,
383
382
  z,
384
- G,
383
+ R,
384
+ W,
385
385
  X,
386
386
  Q
387
387
  ]), f(() => {
@@ -390,7 +390,7 @@ var O = () => {
390
390
  r.has(t) && (e.preventDefault(), b.resolve(i).emit("onMutateSelection", t));
391
391
  }, t = (e) => b.resolve(T).registerShortcut({
392
392
  callback: e.callback,
393
- element: I.current,
393
+ element: F.current,
394
394
  ...e.shortcut
395
395
  }), n = [
396
396
  t(s.expandSelectionLeft),
@@ -420,11 +420,11 @@ var O = () => {
420
420
  t(s.gotoPosition),
421
421
  b.resolve(T).registerShortcut({
422
422
  callback: e,
423
- element: I.current
423
+ element: F.current
424
424
  }),
425
425
  b.resolve(T).registerShortcut({
426
426
  callback: e,
427
- element: I.current,
427
+ element: F.current,
428
428
  modifiers: [["Shift"]]
429
429
  })
430
430
  ];
@@ -435,49 +435,71 @@ var O = () => {
435
435
  let t = async (e) => {
436
436
  let { command: t, getSelectionPostCommand: n } = e;
437
437
  try {
438
- if (await t(), H.current = null, U.current = null, await Z(), Q(), n) {
439
- let e = n();
440
- G.next(e), K.current = e;
438
+ let e = z.data?.undoDepth;
439
+ await t(), V.current = null, H.current = null;
440
+ let r = await Z();
441
+ if (Q(), n) {
442
+ if (e !== void 0 && r?.undoDepth === e) return;
443
+ let t = n();
444
+ W.next(t), G.current = t;
441
445
  }
442
446
  } catch (e) {
443
447
  console.error("Failed to post command:", e);
444
448
  }
445
449
  }, n = async (e) => {
446
- if (!B.data) return;
447
- let n = c.getMutateArguments(G.data, B.data);
450
+ if (!z.data) return;
451
+ let n = c.getMutateArguments(W.data, z.data);
448
452
  n && await t({ command: async () => {
449
- for (let t = n.startCol; t <= n.endCol; t += 1) await j.mutate(n.rows, t, e);
453
+ await A.mutate(n.rows, n.columns, e);
450
454
  } });
451
455
  }, r = (e) => {
452
- if (!B.data) return;
453
- let t = c.getMovedSelection(G.data, e, B.data);
456
+ if (!z.data) return;
457
+ let t = c.getMovedSelection(W.data, e, z.data);
454
458
  if (t) {
455
- if (G.next(t), K.current) {
456
- let t = c.getMovedSelection(K.current, e, B.data);
457
- K.current = t;
458
- } else K.current = t;
459
+ if (W.next(t), G.current) {
460
+ let t = c.getMovedSelection(G.current, e, z.data);
461
+ G.current = t;
462
+ } else G.current = t;
459
463
  }
460
464
  }, o = (e) => {
461
- if (!B.data || !K.current || !G.data) return;
462
- let t = c.getExpandedSelection(G.data, K.current, e, B.data);
463
- t && G.next(t);
464
- }, s = async (e) => {}, l = async (e) => {
465
- if (!B.data) return;
466
- let n = c.getRowsToMove(G.data, e, B.data);
465
+ if (!z.data || !G.current || !W.data) return;
466
+ let t = c.getExpandedSelection(W.data, G.current, e, z.data);
467
+ t && W.next(t);
468
+ }, s = async (e) => {
469
+ if (!z.data) return;
470
+ let n = c.getRowsToMove(W.data, e, z.data);
471
+ n && await t({
472
+ command: async () => {
473
+ e === a.UP ? (await A.moveRowsToTop(n), I.current && (I.current.scrollTop = 0)) : (await A.moveRowsToBottom(n), I.current && (I.current.scrollTop = I.current.scrollHeight - I.current.clientHeight));
474
+ },
475
+ getSelectionPostCommand: () => c.getMovedRowsEndSelection(W.data, e, z.data)
476
+ });
477
+ }, l = async (e) => {
478
+ if (!z.data) return;
479
+ let n = c.getRowsToMove(W.data, e, z.data);
467
480
  n && await t({
468
481
  command: async () => {
469
- e === a.UP ? await j.moveRowsUp(n) : await j.moveRowsDown(n);
482
+ e === a.UP ? await A.moveRowsUp(n) : await A.moveRowsDown(n);
470
483
  },
471
- getSelectionPostCommand: () => c.getMovedSelection(G.data, e, B.data)
484
+ getSelectionPostCommand: () => c.getMovedRowsRelativeSelection(W.data, e, z.data)
472
485
  });
473
- }, u = async (e) => {}, d = b.resolve(i), f = [
486
+ }, u = async (e) => {
487
+ if (!z.data || e !== a.LEFT && e !== a.RIGHT || !W.data?.cells && (!W.data?.cols || W.data.cols.length === 0)) return;
488
+ let n = c.getMutateArguments(W.data, z.data);
489
+ n && n.columns.length !== 0 && n.rows.length !== 0 && await t({
490
+ command: async () => {
491
+ await A.moveHorizontal(n.rows, n.columns, e);
492
+ },
493
+ getSelectionPostCommand: () => c.getPostUpsertSelection(W.data, e)
494
+ });
495
+ }, d = b.resolve(i), f = [
474
496
  d.addEventListener("onSearch", async (t) => {
475
497
  if (!t) return;
476
- let n = await j.search(t, !0);
498
+ let n = await A.search(t, !0);
477
499
  e.getState().setSearchResult(n);
478
500
  }),
479
501
  d.addEventListener("onExpandSelection", (e) => o(e)),
480
- d.addEventListener("onGotoPosition", () => A.current?.open({})),
502
+ d.addEventListener("onGotoPosition", () => ne.current?.open({})),
481
503
  d.addEventListener("onMoveSelection", (e) => r(e)),
482
504
  d.addEventListener("onMoveRows", (e) => {
483
505
  l(e);
@@ -489,38 +511,38 @@ var O = () => {
489
511
  u(e);
490
512
  }),
491
513
  d.addEventListener("onScrollToLineStart", () => {
492
- let e = L.current;
514
+ let e = I.current;
493
515
  e && (e.scrollLeft = 0);
494
516
  }),
495
517
  d.addEventListener("onScrollToLineEnd", () => {
496
- let e = L.current;
518
+ let e = I.current;
497
519
  e && (e.scrollLeft = e.scrollWidth - e.clientWidth);
498
520
  }),
499
521
  d.addEventListener("onScrollPageUp", () => {
500
- let e = L.current;
522
+ let e = I.current;
501
523
  e && (e.scrollTop = Math.max(0, e.scrollTop - e.clientHeight));
502
524
  }),
503
525
  d.addEventListener("onScrollPageDown", () => {
504
- let e = L.current;
526
+ let e = I.current;
505
527
  e && (e.scrollTop = Math.min(e.scrollHeight - e.clientHeight, e.scrollTop + e.clientHeight));
506
528
  }),
507
529
  d.addEventListener("onInsert", () => {
508
530
  (async () => {
509
- if (!B.data) return;
510
- let e = c.getUpsertArguments(G.data, B.data);
531
+ if (!z.data) return;
532
+ let e = c.getUpsertArguments(W.data, z.data);
511
533
  e && await t({
512
- command: async () => j.insert(e.rows, e.col),
513
- getSelectionPostCommand: () => c.getPostUpsertSelection(G.data, a.RIGHT)
534
+ command: async () => A.insert(e.rows, e.col),
535
+ getSelectionPostCommand: () => c.getPostUpsertSelection(W.data, a.RIGHT)
514
536
  });
515
537
  })();
516
538
  }),
517
539
  d.addEventListener("onDeleteBackward", () => {
518
540
  (async () => {
519
- if (!B.data) return;
520
- let e = c.getUpsertArguments(G.data, B.data, -1);
541
+ if (!z.data) return;
542
+ let e = c.getUpsertArguments(W.data, z.data, -1);
521
543
  e && await t({
522
- command: async () => j.delete(e.rows, e.col),
523
- getSelectionPostCommand: () => c.getPostUpsertSelection(G.data, a.LEFT)
544
+ command: async () => A.delete(e.rows, e.col),
545
+ getSelectionPostCommand: () => c.getPostUpsertSelection(W.data, a.LEFT)
524
546
  });
525
547
  })();
526
548
  }),
@@ -529,40 +551,50 @@ var O = () => {
529
551
  }),
530
552
  d.addEventListener("onUndo", () => {
531
553
  t({
532
- command: async () => j.undo(),
554
+ command: async () => A.undo(),
533
555
  getSelectionPostCommand: () => null
534
556
  });
535
557
  }),
536
558
  d.addEventListener("onRedo", () => {
537
559
  t({
538
- command: async () => j.redo(),
560
+ command: async () => A.redo(),
539
561
  getSelectionPostCommand: () => null
540
562
  });
563
+ }),
564
+ d.addEventListener("onExportGappedFasta", async () => {
565
+ console.log("Exporting gapped fasta");
566
+ let e = await A.exportGappedFasta();
567
+ E.downloadFastaFile(e, "sequence.gapped.fasta");
568
+ }),
569
+ d.addEventListener("onExportUngappedFasta", async () => {
570
+ console.log("Exporting ungapped fasta");
571
+ let e = await A.exportUngappedFasta();
572
+ E.downloadFastaFile(e, "sequence.ungapped.fasta");
541
573
  })
542
574
  ];
543
575
  return () => {
544
576
  f.forEach((e) => e());
545
577
  };
546
578
  }, [
547
- j,
548
- G,
579
+ A,
580
+ W,
549
581
  Z,
550
582
  Q,
551
- B
583
+ z
552
584
  ]), f(() => {
553
585
  Q();
554
586
  }, [Q]);
555
- let de = d((e) => {
587
+ let fe = d((e) => {
556
588
  let t = e.currentTarget;
557
- z.next({
589
+ R.next({
558
590
  scrollLeft: t.scrollLeft,
559
591
  scrollTop: t.scrollTop
560
592
  });
561
- }, [z]), fe = d((e) => {
562
- I.current?.focus();
593
+ }, [R]), pe = d((e) => {
594
+ F.current?.focus();
563
595
  let t = e.currentTarget, n = t.getBoundingClientRect(), r = e.clientX >= n.left + t.clientWidth, i = e.clientY >= n.top + t.clientHeight;
564
596
  if (r || i) return;
565
- let a = M.current, s = N.current, l = b.resolve(w).data;
597
+ let a = j.current, s = M.current, l = b.resolve(w).data;
566
598
  if (!a || !s) return;
567
599
  let u = c.getPathPropertiesFromCanvas({
568
600
  canvas: a,
@@ -573,12 +605,12 @@ var O = () => {
573
605
  if (u) {
574
606
  if (u.type !== o.DIVIDER) {
575
607
  if (u.type === o.LABEL && (e.metaKey || e.ctrlKey)) {
576
- let t = G.data?.rows ?? [], n = t.includes(u.row) ? t.filter((e) => e !== u.row) : [...t, u.row].sort((e, t) => e - t);
577
- if (e.preventDefault(), F.current = null, n.length === 0) {
578
- G.next(null), K.current = null;
608
+ let t = W.data?.rows ?? [], n = t.includes(u.row) ? t.filter((e) => e !== u.row) : [...t, u.row].sort((e, t) => e - t);
609
+ if (e.preventDefault(), P.current = null, n.length === 0) {
610
+ W.next(null), G.current = null;
579
611
  return;
580
612
  }
581
- G.next({ rows: n }), K.current = { rows: n };
613
+ W.next({ rows: n }), G.current = { rows: n };
582
614
  return;
583
615
  }
584
616
  let t = c.getSelectionFromPathProperties({
@@ -586,26 +618,26 @@ var O = () => {
586
618
  startPath: u
587
619
  });
588
620
  if (!t) return;
589
- e.preventDefault(), F.current = u, G.next(t), K.current = t;
590
- } else e.preventDefault(), F.current = null, P.current = {
591
- startLabelWidth: W.data.labelWidth,
621
+ e.preventDefault(), P.current = u, W.next(t), G.current = t;
622
+ } else e.preventDefault(), P.current = null, N.current = {
623
+ startLabelWidth: U.data.labelWidth,
592
624
  startX: e.clientX
593
625
  };
594
626
  }
595
- }, [W, G]), pe = d((e) => {
596
- let t = M.current, n = I.current, r = b.resolve(w).data, i = P.current;
627
+ }, [U, W]), me = d((e) => {
628
+ let t = j.current, n = F.current, r = b.resolve(w).data, i = N.current;
597
629
  if (!n || !t) return;
598
630
  if (i) {
599
631
  let t = Math.min($, Math.max(120, i.startLabelWidth + e.clientX - i.startX));
600
- W.next({
601
- ...W.data,
632
+ U.next({
633
+ ...U.data,
602
634
  labelWidth: t
603
635
  }), n.style.cursor = "col-resize";
604
636
  return;
605
637
  }
606
- let a = F.current;
638
+ let a = P.current;
607
639
  if (a) {
608
- let n = N.current;
640
+ let n = M.current;
609
641
  if (!n) return;
610
642
  let i = c.getPathPropertiesFromCanvas({
611
643
  canvas: t,
@@ -618,10 +650,10 @@ var O = () => {
618
650
  endPath: i,
619
651
  startPath: a
620
652
  });
621
- o && (G.next(o), K.current = o);
653
+ o && (W.next(o), G.current = o);
622
654
  return;
623
655
  }
624
- let s = N.current;
656
+ let s = M.current;
625
657
  if (!s) return;
626
658
  let l = c.getPathPropertiesFromCanvas({
627
659
  canvas: t,
@@ -631,19 +663,19 @@ var O = () => {
631
663
  });
632
664
  l && l.type === o.DIVIDER ? n.style.cursor = "col-resize" : n.style.cursor = "default";
633
665
  }, [
634
- W,
666
+ U,
635
667
  $,
636
- G
637
- ]), me = d(() => {
638
- P.current = null, F.current = null;
639
- }, []), he = d((e, t) => {
668
+ W
669
+ ]), he = d(() => {
670
+ N.current = null, P.current = null;
671
+ }, []), ge = d((e, t) => {
640
672
  c.scrollToPosition({
641
- geometry: W.data,
642
- scrollContainer: L.current,
673
+ geometry: U.data,
674
+ scrollContainer: I.current,
643
675
  x: e,
644
676
  y: t
645
677
  });
646
- }, [W]), ge = Math.max(1, Math.floor(R.width * ne)), _e = Math.max(1, Math.floor(R.height * ne));
678
+ }, [U]), _e = Math.max(1, Math.floor(L.width * ie)), ve = Math.max(1, Math.floor(L.height * ie));
647
679
  return /* @__PURE__ */ S(g, {
648
680
  sx: {
649
681
  display: "grid",
@@ -655,8 +687,8 @@ var O = () => {
655
687
  children: [
656
688
  /* @__PURE__ */ x(u, {}),
657
689
  /* @__PURE__ */ S(g, {
658
- onMouseUp: me,
659
- ref: I,
690
+ onMouseUp: he,
691
+ ref: F,
660
692
  sx: {
661
693
  height: `calc(100% - ${Y.spacing(3)})`,
662
694
  marginBottom: Y.spacing(3),
@@ -666,10 +698,10 @@ var O = () => {
666
698
  tabIndex: 0,
667
699
  children: [
668
700
  /* @__PURE__ */ x(g, {
669
- onMouseDown: fe,
670
- onMouseMove: pe,
671
- onScroll: de,
672
- ref: L,
701
+ onMouseDown: pe,
702
+ onMouseMove: me,
703
+ onScroll: fe,
704
+ ref: I,
673
705
  sx: {
674
706
  height: "100%",
675
707
  overflowX: "scroll",
@@ -679,26 +711,26 @@ var O = () => {
679
711
  zIndex: 1
680
712
  },
681
713
  children: /* @__PURE__ */ x(g, { sx: {
682
- height: `${Math.max(ie, R.height)}px`,
714
+ height: `${Math.max(oe, L.height)}px`,
683
715
  pointerEvents: "none",
684
- width: `${Math.max(oe, R.width)}px`
716
+ width: `${Math.max(ce, L.width)}px`
685
717
  } })
686
718
  }),
687
719
  /* @__PURE__ */ x("canvas", {
688
- height: _e,
689
- ref: M,
720
+ height: ve,
721
+ ref: j,
690
722
  style: {
691
723
  display: "block",
692
- height: `${R.height}px`,
724
+ height: `${L.height}px`,
693
725
  imageRendering: "pixelated",
694
726
  left: 0,
695
727
  pointerEvents: "auto",
696
728
  position: "absolute",
697
729
  top: 0,
698
- width: `${R.width}px`,
730
+ width: `${L.width}px`,
699
731
  zIndex: 0
700
732
  },
701
- width: ge
733
+ width: _e
702
734
  }),
703
735
  /* @__PURE__ */ x(g, {
704
736
  sx: {
@@ -709,18 +741,17 @@ var O = () => {
709
741
  width: "100%",
710
742
  zIndex: 2
711
743
  },
712
- children: /* @__PURE__ */ x(O, {})
744
+ children: /* @__PURE__ */ x(ee, {})
713
745
  })
714
746
  ]
715
747
  }),
716
- /* @__PURE__ */ x(ee, {
717
- onGotoPosition: he,
718
- ref: A
748
+ /* @__PURE__ */ x(te, {
749
+ onGotoPosition: ge,
750
+ ref: ne
719
751
  })
720
752
  ]
721
753
  });
722
754
  };
723
- //#endregion
724
- export { A as t };
755
+ export { ne as t };
725
756
 
726
757
  //# sourceMappingURL=SequenceEditor.js.map