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

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 (127) hide show
  1. package/dist/_chunks/EditorWorkerService.js +127 -0
  2. package/dist/_chunks/EditorWorkerService.js.map +1 -0
  3. package/dist/_chunks/SequenceEditor.js +733 -0
  4. package/dist/_chunks/SequenceEditor.js.map +1 -0
  5. package/dist/_chunks/SequenceEditorPageDrawer.js +425 -0
  6. package/dist/_chunks/SequenceEditorPageDrawer.js.map +1 -0
  7. package/dist/_chunks/comlink.js +228 -0
  8. package/dist/_chunks/comlink.js.map +1 -0
  9. package/dist/_chunks/react.js +11 -0
  10. package/dist/_chunks/react.js.map +1 -0
  11. package/dist/_chunks/sequenceEditorStore.js +174 -0
  12. package/dist/_chunks/sequenceEditorStore.js.map +1 -0
  13. package/dist/assets/index-Dn92arD_.js +8 -0
  14. package/dist/assets/index-Dn92arD_.js.map +1 -0
  15. package/dist/classes/services/EditorWorkerService/EditorWorkerService.d.ts +27 -0
  16. package/dist/classes/services/EditorWorkerService/index.js +2 -0
  17. package/dist/classes/services/SequenceEditorEventBusService/SequenceEditorEventBusService.d.ts +25 -0
  18. package/dist/classes/services/SequenceEditorEventBusService/index.js +16 -0
  19. package/dist/classes/services/SequenceEditorEventBusService/index.js.map +1 -0
  20. package/dist/classes/workers/EngineWorker/EngineWorker.d.ts +46 -0
  21. package/dist/classes/workers/EngineWorker/index.js +111 -0
  22. package/dist/classes/workers/EngineWorker/index.js.map +1 -0
  23. package/dist/components/app/App/App.d.ts +1 -0
  24. package/dist/components/app/App/index.js +21 -0
  25. package/dist/components/app/App/index.js.map +1 -0
  26. package/dist/components/pages/EmptyWorkspace.d.ts +3 -0
  27. package/dist/components/pages/SequenceEditorErrorPage/SequenceEditorErrorPage.d.ts +3 -0
  28. package/dist/components/pages/SequenceEditorErrorPage/index.js +12 -0
  29. package/dist/components/pages/SequenceEditorErrorPage/index.js.map +1 -0
  30. package/dist/components/pages/SequenceEditorMainPage/SequenceEditorMainPage.d.ts +1 -0
  31. package/dist/components/pages/SequenceEditorMainPage/index.js +61 -0
  32. package/dist/components/pages/SequenceEditorMainPage/index.js.map +1 -0
  33. package/dist/components/ui/SequenceEditor/SequenceEditor.d.ts +1 -0
  34. package/dist/components/ui/SequenceEditor/SequenceEditorGotoPositionDialog.d.ts +8 -0
  35. package/dist/components/ui/SequenceEditor/SequenceEditorStatusBar.d.ts +1 -0
  36. package/dist/components/ui/SequenceEditor/index.js +2 -0
  37. package/dist/components/ui/SequenceEditorPage/SequenceEditorPage.d.ts +5 -0
  38. package/dist/components/ui/SequenceEditorPage/index.js +15 -0
  39. package/dist/components/ui/SequenceEditorPage/index.js.map +1 -0
  40. package/dist/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawer.d.ts +1 -0
  41. package/dist/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawerColorForm.d.ts +7 -0
  42. package/dist/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawerKeyboardShortcuts.d.ts +1 -0
  43. package/dist/components/ui/SequenceEditorPageDrawer/index.js +2 -0
  44. package/dist/components/ui/SequenceEditorPageHeader/SequenceEditorPageHeader.d.ts +1 -0
  45. package/dist/components/ui/SequenceEditorPageHeader/index.js +60 -0
  46. package/dist/components/ui/SequenceEditorPageHeader/index.js.map +1 -0
  47. package/dist/components/ui/SequenceEditorSearchBar/SequenceEditorSearchBar.d.ts +1 -0
  48. package/dist/components/ui/SequenceEditorSearchBar/index.js +27 -0
  49. package/dist/components/ui/SequenceEditorSearchBar/index.js.map +1 -0
  50. package/dist/constants/editor.d.ts +4 -0
  51. package/dist/constants/editor.js +14 -0
  52. package/dist/constants/editor.js.map +1 -0
  53. package/dist/constants/index.js +4 -0
  54. package/dist/constants/keyboard.d.ts +10 -0
  55. package/dist/constants/keyboard.js +179 -0
  56. package/dist/constants/keyboard.js.map +1 -0
  57. package/dist/constants/palette.d.ts +15 -0
  58. package/dist/constants/palette.js +196 -0
  59. package/dist/constants/palette.js.map +1 -0
  60. package/dist/models/editor.d.ts +6 -0
  61. package/dist/models/editor.js +8 -0
  62. package/dist/models/editor.js.map +1 -0
  63. package/dist/models/model.d.ts +250 -0
  64. package/dist/models/model.js +10 -0
  65. package/dist/models/model.js.map +1 -0
  66. package/dist/models/palette.d.ts +61 -0
  67. package/dist/models/palette.js +10 -0
  68. package/dist/models/palette.js.map +1 -0
  69. package/dist/stores/sequenceEditorStore/index.js +2 -0
  70. package/dist/stores/sequenceEditorStore/sequenceEditorStore.d.ts +36 -0
  71. package/dist/utils/EditorUtil/EditorUtil.d.ts +96 -0
  72. package/dist/utils/EditorUtil/index.js +552 -0
  73. package/dist/utils/EditorUtil/index.js.map +1 -0
  74. package/dist/utils/EngineErrorUtil/EngineErrorUtil.d.ts +4 -0
  75. package/dist/utils/PaletteUtil/PaletteUtil.d.ts +6 -0
  76. package/dist/utils/PaletteUtil/index.js +19 -0
  77. package/dist/utils/PaletteUtil/index.js.map +1 -0
  78. package/package.json +47 -21
  79. package/.gitkeep +0 -0
  80. package/CHANGELOG.md +0 -37
  81. package/eslint.config.js +0 -16
  82. package/scripts/update-exports.js +0 -9
  83. package/src/classes/services/EditorWorkerService/EditorWorkerService.ts +0 -163
  84. package/src/classes/services/SequenceEditorEventBusService/SequenceEditorEventBusService.ts +0 -37
  85. package/src/classes/workers/EngineWorker/EngineWorker.ts +0 -196
  86. package/src/components/app/App/App.tsx +0 -22
  87. package/src/components/pages/EmptyWorkspace.tsx +0 -43
  88. package/src/components/pages/SequenceEditorErrorPage/SequenceEditorErrorPage.tsx +0 -16
  89. package/src/components/pages/SequenceEditorMainPage/SequenceEditorMainPage.tsx +0 -76
  90. package/src/components/ui/SequenceEditor/SequenceEditor.tsx +0 -896
  91. package/src/components/ui/SequenceEditor/SequenceEditorGotoPositionDialog.tsx +0 -108
  92. package/src/components/ui/SequenceEditor/SequenceEditorStatusBar.tsx +0 -72
  93. package/src/components/ui/SequenceEditorPage/SequenceEditorPage.tsx +0 -23
  94. package/src/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawer.tsx +0 -234
  95. package/src/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawerColorForm.tsx +0 -73
  96. package/src/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawerKeyboardShortcuts.tsx +0 -230
  97. package/src/components/ui/SequenceEditorPageHeader/SequenceEditorPageHeader.tsx +0 -71
  98. package/src/components/ui/SequenceEditorSearchBar/SequenceEditorSearchBar.tsx +0 -35
  99. package/src/constants/editor.ts +0 -15
  100. package/src/constants/keyboard.ts +0 -154
  101. package/src/constants/palette.ts +0 -227
  102. package/src/models/editor.ts +0 -6
  103. package/src/models/model.ts +0 -295
  104. package/src/models/palette.ts +0 -68
  105. package/src/stores/sequenceEditorStore/sequenceEditorStore.ts +0 -103
  106. package/src/utils/EditorUtil/EditorUtil.ts +0 -892
  107. package/src/utils/EngineErrorUtil/EngineErrorUtil.ts +0 -25
  108. package/src/utils/PaletteUtil/PaletteUtil.ts +0 -31
  109. package/tsconfig.build.json +0 -14
  110. package/tsconfig.json +0 -32
  111. package/vite.config.ts +0 -177
  112. /package/{src/classes/services/EditorWorkerService/index.ts → dist/classes/services/EditorWorkerService/index.d.ts} +0 -0
  113. /package/{src/classes/services/SequenceEditorEventBusService/index.ts → dist/classes/services/SequenceEditorEventBusService/index.d.ts} +0 -0
  114. /package/{src/classes/workers/EngineWorker/index.ts → dist/classes/workers/EngineWorker/index.d.ts} +0 -0
  115. /package/{src/components/app/App/index.ts → dist/components/app/App/index.d.ts} +0 -0
  116. /package/{src/components/pages/SequenceEditorErrorPage/index.ts → dist/components/pages/SequenceEditorErrorPage/index.d.ts} +0 -0
  117. /package/{src/components/pages/SequenceEditorMainPage/index.ts → dist/components/pages/SequenceEditorMainPage/index.d.ts} +0 -0
  118. /package/{src/components/ui/SequenceEditor/index.ts → dist/components/ui/SequenceEditor/index.d.ts} +0 -0
  119. /package/{src/components/ui/SequenceEditorPage/index.ts → dist/components/ui/SequenceEditorPage/index.d.ts} +0 -0
  120. /package/{src/components/ui/SequenceEditorPageDrawer/index.ts → dist/components/ui/SequenceEditorPageDrawer/index.d.ts} +0 -0
  121. /package/{src/components/ui/SequenceEditorPageHeader/index.ts → dist/components/ui/SequenceEditorPageHeader/index.d.ts} +0 -0
  122. /package/{src/components/ui/SequenceEditorSearchBar/index.ts → dist/components/ui/SequenceEditorSearchBar/index.d.ts} +0 -0
  123. /package/{src/constants/index.ts → dist/constants/index.d.ts} +0 -0
  124. /package/{src/models/index.ts → dist/models/index.d.ts} +0 -0
  125. /package/{src/stores/sequenceEditorStore/index.ts → dist/stores/sequenceEditorStore/index.d.ts} +0 -0
  126. /package/{src/utils/EditorUtil/index.ts → dist/utils/EditorUtil/index.d.ts} +0 -0
  127. /package/{src/utils/PaletteUtil/index.ts → dist/utils/PaletteUtil/index.d.ts} +0 -0
@@ -0,0 +1,733 @@
1
+ import { EDITOR_DIRECTION as e } from "../models/editor.js";
2
+ import { EDITOR_PATH_PROPERTIES_TYPE as t } from "../models/model.js";
3
+ import { DEFAULT_GRID_GEOMETRY as n, IUPAC_KEYS as r } from "../constants/editor.js";
4
+ import { SequenceEditorEventBusService as i } from "../classes/services/SequenceEditorEventBusService/index.js";
5
+ import { KEYBOARD_SHORTCUTS as a } from "../constants/keyboard.js";
6
+ import "../constants/index.js";
7
+ import { EditorUtil as o } from "../utils/EditorUtil/index.js";
8
+ import { t as s } from "./sequenceEditorStore.js";
9
+ import { t as c } from "./react.js";
10
+ import { SequenceEditorSearchBar as l } from "../components/ui/SequenceEditorSearchBar/index.js";
11
+ import { t as u } from "./EditorWorkerService.js";
12
+ import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
13
+ import { jsx as g, jsxs as _ } from "react/jsx-runtime";
14
+ import { Box as v, TextField as y, darken as b, useTheme as x } from "@mui/material";
15
+ import { Subject as S } from "@gen-epix/ui-core/classes/Subject";
16
+ import { DevicePixelRatioService as C } from "@gen-epix/ui-core/classes/services/DevicePixelRatioService";
17
+ import { KeyboardShortcutService as w } from "@gen-epix/ui-core/classes/services/KeyboardShortcutService";
18
+ import { withDialog as T } from "@gen-epix/ui-core-components/hoc/withDialog";
19
+ //#region ../../../../node_modules/.pnpm/use-debounce@10.1.1_react@19.3.0/node_modules/use-debounce/dist/index.module.js
20
+ function E(e, t, n, r) {
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();
22
+ h.current = e;
23
+ var y = typeof window < "u", b = !t && t !== 0 && y;
24
+ if (typeof e != "function") throw TypeError("Expected a function");
25
+ t = +t || 0;
26
+ var x = !!(n ||= {}).leading, S = !("trailing" in n) || !!n.trailing, C = !!n.flushOnExit && S, w = "maxWait" in n, T = "debounceOnServer" in n && !!n.debounceOnServer, E = w ? Math.max(+n.maxWait || 0, t) : null, D = p(function() {
27
+ var e = function(e) {
28
+ var t = l.current, n = u.current;
29
+ return l.current = u.current = null, o.current = e, s.current = s.current || e, d.current = h.current.apply(n, t);
30
+ }, n = function(e, t) {
31
+ b && cancelAnimationFrame(c.current), c.current = b ? requestAnimationFrame(e) : setTimeout(e, t);
32
+ }, f = function(e) {
33
+ if (!g.current) return !1;
34
+ var n = e - a.current;
35
+ return !a.current || n >= t || n < 0 || w && e - o.current >= E;
36
+ }, p = function(t) {
37
+ return c.current = null, S && l.current ? e(t) : (l.current = u.current = null, d.current);
38
+ }, m = function e() {
39
+ var r = Date.now();
40
+ if (x && s.current === o.current && D(), f(r)) return p(r);
41
+ if (g.current) {
42
+ var i = t - (r - a.current);
43
+ n(e, w ? Math.min(i, E - (r - o.current)) : i);
44
+ }
45
+ }, D = function() {
46
+ r && r({});
47
+ }, O = function() {
48
+ if (y || T) {
49
+ var r, s = Date.now(), p = f(s);
50
+ if (l.current = [].slice.call(arguments), u.current = i, a.current = s, C && !_.current && (_.current = function() {
51
+ globalThis.document?.visibilityState === "hidden" && v.current.flush();
52
+ }, (r = globalThis.document) == null || r.addEventListener == null || r.addEventListener("visibilitychange", _.current)), p) {
53
+ if (!c.current && g.current) return o.current = a.current, n(m, t), x ? e(a.current) : d.current;
54
+ if (w) return n(m, t), e(a.current);
55
+ }
56
+ return c.current || n(m, t), d.current;
57
+ }
58
+ };
59
+ return O.cancel = function() {
60
+ var e = c.current;
61
+ e && (b ? cancelAnimationFrame(c.current) : clearTimeout(c.current)), o.current = 0, l.current = a.current = u.current = c.current = null, e && r && r({});
62
+ }, O.isPending = function() {
63
+ return !!c.current;
64
+ }, O.flush = function() {
65
+ return c.current ? p(Date.now()) : d.current;
66
+ }, O;
67
+ }, [
68
+ x,
69
+ w,
70
+ t,
71
+ E,
72
+ S,
73
+ C,
74
+ b,
75
+ y,
76
+ T,
77
+ r
78
+ ]);
79
+ return v.current = D, f(function() {
80
+ return g.current = !0, function() {
81
+ var e;
82
+ C && v.current.flush(), _.current &&= ((e = globalThis.document) == null || e.removeEventListener == null || e.removeEventListener("visibilitychange", _.current), null), g.current = !1;
83
+ };
84
+ }, [C]), D;
85
+ }
86
+ //#endregion
87
+ //#region src/components/ui/SequenceEditor/SequenceEditorStatusBar.tsx
88
+ var D = () => {
89
+ let e = x(), t = c(s, (e) => e.latestMessage), n = c(s, (e) => e.meta), r = c(s, (e) => e.selection), i = p(() => o.getStatusBarSelectionStats(r, n), [n, r]);
90
+ return /* @__PURE__ */ g(v, {
91
+ sx: {
92
+ backgroundColor: b(e.palette.background.paper, .1),
93
+ borderTop: `1px solid ${b(e.palette.background.paper, .2)}`,
94
+ fontSize: e.typography.caption,
95
+ height: "100%",
96
+ width: "100%"
97
+ },
98
+ children: /* @__PURE__ */ _(v, {
99
+ sx: {
100
+ "& > div": {
101
+ alignItems: "center",
102
+ borderLeft: `1px solid ${b(e.palette.background.paper, .2)}`,
103
+ display: "flex",
104
+ paddingLeft: e.spacing(1)
105
+ },
106
+ "& > div:first-of-type": { borderLeft: "none" },
107
+ display: "grid",
108
+ gap: 4,
109
+ gridTemplateColumns: "1fr repeat(5, max-content)",
110
+ paddingLeft: e.spacing(1),
111
+ paddingRight: e.spacing(1)
112
+ },
113
+ children: [
114
+ /* @__PURE__ */ g(v, { children: t ?? "" }),
115
+ /* @__PURE__ */ g(v, { children: `Pos: ${i.pos}` }),
116
+ /* @__PURE__ */ g(v, { children: `Selected seqs: ${i.selectedSeqs}` }),
117
+ /* @__PURE__ */ g(v, { children: `Cols: ${i.cols}` }),
118
+ /* @__PURE__ */ g(v, { children: `Total selected chars: ${i.totalSelectedChars}` }),
119
+ /* @__PURE__ */ g(v, { children: `Alignment: ${n?.alignmentWidth ?? "0"} sequences ${n?.sequenceCount ?? "0"} pos.` })
120
+ ]
121
+ })
122
+ });
123
+ }, O = /^(?:\d+|,\d+|\d+,\d+)$/, ee = T(({ onActionsChange: e, onClose: t, onGotoPosition: n }) => {
124
+ let [r, i] = h(""), a = m(null), o = r === "" || O.test(r);
125
+ f(() => {
126
+ a.current?.focus();
127
+ }, []);
128
+ let s = d((e) => {
129
+ i(e.target.value);
130
+ }, []), c = d(() => {
131
+ if (!o) return;
132
+ let [e, i] = r.split(",");
133
+ n(e ? Number(e) : null, i ? Number(i) : null), t?.();
134
+ }, [
135
+ o,
136
+ t,
137
+ n,
138
+ r
139
+ ]), l = d((e) => {
140
+ e.key === "Enter" && (e.preventDefault(), c());
141
+ }, [c]);
142
+ return f(() => {
143
+ let n = [];
144
+ n.push({
145
+ color: "secondary",
146
+ label: "Close",
147
+ onClick: t,
148
+ variant: "outlined"
149
+ }), n.push({
150
+ color: "primary",
151
+ disabled: !o,
152
+ label: "Ok",
153
+ onClick: c,
154
+ variant: "contained"
155
+ }), e?.(n);
156
+ }, [
157
+ o,
158
+ e,
159
+ t,
160
+ c
161
+ ]), /* @__PURE__ */ g(y, {
162
+ error: !o,
163
+ fullWidth: !0,
164
+ helperText: "Use x, ,y, or x,y.",
165
+ inputRef: a,
166
+ label: "Position",
167
+ onChange: s,
168
+ onKeyDown: l,
169
+ placeholder: "x or ,y or x,y",
170
+ value: r
171
+ });
172
+ }, {
173
+ defaultTitle: "Goto position (x) or (,y) or (x,y)",
174
+ fullWidth: !0,
175
+ maxWidth: "xs",
176
+ testId: "SequenceEditorGotoPositionDialog"
177
+ }), k = () => {
178
+ let y = c(s, (e) => e.rawFasta), b = c(s, (e) => e.setLatestMessage), T = c(s, (e) => e.setMeta), O = c(s, (e) => e.setSelection), k = m(null), A = p(() => u.getInstance(), []), j = m(null), M = m(null), N = m(null), P = m(null), F = m(null), I = m(null), [L, te] = h({
179
+ height: 0,
180
+ width: 0
181
+ }), [ne, re] = h(() => C.getInstance().data), [ie, ae] = h(0), [oe, se] = h(0), R = p(() => new S({
182
+ scrollLeft: 0,
183
+ scrollTop: 0
184
+ }), []), ce = m(L), z = p(() => new S(null), []), B = p(() => new S(null), []), V = m(null), H = m(null), U = p(() => new S(n), []), W = p(() => new S(null), []), G = m(null), K = m(0), q = m(null), J = m(!1), Y = x(), X = d(() => {
185
+ let e = U.data, t = z.data;
186
+ if (!e || !t) return;
187
+ let n = e.labelWidth + e.cellWidth + t.alignmentWidth * e.cellWidth, r = e.rulerHeight + t.sequenceCount * e.cellHeight;
188
+ se(n), ae(r);
189
+ }, [U, z]), Z = d(async () => {
190
+ let e = await u.getInstance().getMetaData();
191
+ z.next(e);
192
+ }, [z]), Q = d(() => {
193
+ let e = U.data, t = z.data;
194
+ if (!t || !e) return;
195
+ let { scrollLeft: n, scrollTop: r } = R.data, { height: i, width: a } = ce.current, s = o.getVisibleGridRange({
196
+ geometry: e,
197
+ numCols: t.alignmentWidth,
198
+ numRows: t.sequenceCount,
199
+ scrollLeft: n,
200
+ scrollTop: r,
201
+ viewportHeight: i,
202
+ viewportWidth: a
203
+ });
204
+ B.next({
205
+ geometry: e,
206
+ scrollLeft: n,
207
+ scrollTop: r,
208
+ viewportHeight: i,
209
+ viewportWidth: a,
210
+ visibleGridRange: s
211
+ });
212
+ }, [
213
+ U,
214
+ z,
215
+ R,
216
+ B
217
+ ]), le = E((e, t) => {
218
+ te({
219
+ height: t,
220
+ width: e
221
+ });
222
+ }, 0, { trailing: !0 });
223
+ f(() => {
224
+ ce.current = L, Q();
225
+ }, [L, Q]);
226
+ let $ = L.width > 0 ? L.width / 2 : 120;
227
+ f(() => {
228
+ let e = [z.subscribe((e) => {
229
+ T(e);
230
+ }), W.subscribe((e) => {
231
+ O(e);
232
+ })];
233
+ return () => {
234
+ e.forEach((e) => e()), b(null), T(null), O(null);
235
+ };
236
+ }, [
237
+ z,
238
+ W,
239
+ b,
240
+ T,
241
+ O
242
+ ]), f(() => {
243
+ if (L.width <= 0) return;
244
+ let e = U.data;
245
+ e.labelWidth > $ && U.next({
246
+ ...e,
247
+ labelWidth: $
248
+ });
249
+ }, [
250
+ L.width,
251
+ U,
252
+ $
253
+ ]), f(() => {
254
+ let e = I.current;
255
+ if (!e) return;
256
+ let t = new ResizeObserver(([e]) => {
257
+ if (!e) return;
258
+ let t = Math.max(1, e.contentRect.height), n = Math.max(1, e.contentRect.width);
259
+ le(n, t);
260
+ });
261
+ return t.observe(e), () => t.disconnect();
262
+ }, [A, le]), f(() => {
263
+ (async () => {
264
+ V.current = null, H.current = null, R.next({
265
+ scrollLeft: 0,
266
+ scrollTop: 0
267
+ }), W.next(null), await A.initialize(), await A.loadFasta(y), await Z(), Q();
268
+ })().catch((e) => {
269
+ console.error(e);
270
+ });
271
+ }, [
272
+ A,
273
+ y,
274
+ R,
275
+ W,
276
+ Z,
277
+ Q
278
+ ]), f(() => {
279
+ let e = null, t = !0, n = null, r = null, i = async () => {
280
+ if (t && !J.current) {
281
+ J.current = !0;
282
+ try {
283
+ for (; t && q.current;) {
284
+ let i = q.current;
285
+ q.current = null;
286
+ let a = K.current;
287
+ if (!H.current || !o.isWithinGridRange({
288
+ cachedGridRange: H.current.range,
289
+ visibleGridRange: i.visibleGridRange.visible
290
+ })) {
291
+ let e = [];
292
+ for (let t = i.visibleGridRange.cache.startRow; t <= i.visibleGridRange.cache.endRow; t++) e.push(await A.name(t));
293
+ if (!t) return;
294
+ H.current = {
295
+ range: i.visibleGridRange.cache,
296
+ rowNames: e
297
+ };
298
+ }
299
+ if (!V.current || !o.isWithinGridRange({
300
+ cachedGridRange: V.current.range,
301
+ visibleGridRange: i.visibleGridRange.visible
302
+ })) {
303
+ let e = await u.getInstance().viewport({
304
+ endCol: i.visibleGridRange.cache.endCol,
305
+ endRow: i.visibleGridRange.cache.endRow,
306
+ startCol: i.visibleGridRange.cache.startCol,
307
+ startRow: i.visibleGridRange.cache.startRow
308
+ });
309
+ if (!t) return;
310
+ V.current = {
311
+ range: i.visibleGridRange.cache,
312
+ viewportResult: e
313
+ };
314
+ }
315
+ a === K.current && (e !== null && cancelAnimationFrame(e), e = requestAnimationFrame(() => {
316
+ t && a === K.current && j.current && s.getState().nucleotidePalette && V.current && z.data && H.current && (M.current = o.drawCanvas({
317
+ canvasElement: j.current,
318
+ devicePixelRatio: C.getInstance().data,
319
+ geometry: i.geometry,
320
+ meta: z.data,
321
+ palette: s.getState().nucleotidePalette,
322
+ rowNames: H.current.rowNames,
323
+ rowNamesStartRow: H.current.range.startRow,
324
+ scrollLeft: i.scrollLeft,
325
+ scrollTop: i.scrollTop,
326
+ searchResult: n,
327
+ searchResultHighlightedIndex: r,
328
+ selection: W.data,
329
+ viewport: V.current.viewportResult,
330
+ viewportHeight: i.viewportHeight,
331
+ viewportWidth: i.viewportWidth
332
+ }));
333
+ }));
334
+ }
335
+ } finally {
336
+ J.current = !1, t && q.current && i();
337
+ }
338
+ }
339
+ }, a = [s.subscribe((e, t) => {
340
+ let i = !1;
341
+ e.searchResult !== t.searchResult && (n = e.searchResult, i = !0), e.searchResultHighlightedIndex !== t.searchResultHighlightedIndex && (r = e.searchResultHighlightedIndex, o.scrollToSearchResult({
342
+ geometry: U.data,
343
+ scrollContainer: I.current,
344
+ searchResult: e.searchResult,
345
+ searchResultHighlightedIndex: e.searchResultHighlightedIndex
346
+ }), i = !0), i && Q();
347
+ }), B.subscribe((e) => {
348
+ e && (q.current = e, K.current += 1, i());
349
+ })];
350
+ return () => {
351
+ t = !1, q.current = null, e !== null && cancelAnimationFrame(e), K.current += 1, a.forEach((e) => e());
352
+ };
353
+ }, [
354
+ A,
355
+ U,
356
+ z,
357
+ W,
358
+ Q,
359
+ B
360
+ ]), f(() => {
361
+ let e = [
362
+ s.subscribe((e, t) => {
363
+ e.nucleotidePalette?.name !== t.nucleotidePalette?.name && Q();
364
+ }),
365
+ U.subscribe(() => {
366
+ X(), Q();
367
+ }),
368
+ R.subscribe(() => Q()),
369
+ z.subscribe((e) => {
370
+ e && (X(), Q());
371
+ }),
372
+ W.subscribe(() => Q()),
373
+ C.getInstance().subscribe((e) => {
374
+ re(e), X(), Q();
375
+ })
376
+ ];
377
+ return () => {
378
+ e.forEach((e) => e());
379
+ };
380
+ }, [
381
+ A,
382
+ U,
383
+ z,
384
+ R,
385
+ W,
386
+ X,
387
+ Q
388
+ ]), f(() => {
389
+ let e = (e) => {
390
+ let t = e.key.toUpperCase();
391
+ r.has(t) && (e.preventDefault(), i.getInstance().emit("onMutateSelection", t));
392
+ }, t = (e) => w.getInstance().registerShortcut({
393
+ callback: e.callback,
394
+ element: F.current,
395
+ ...e.shortcut
396
+ }), n = [
397
+ t(a.expandSelectionLeft),
398
+ t(a.expandSelectionRight),
399
+ t(a.expandSelectionUp),
400
+ t(a.expandSelectionDown),
401
+ t(a.moveSelectionLeft),
402
+ t(a.moveSelectionRight),
403
+ t(a.moveSelectionUp),
404
+ t(a.moveSelectionDown),
405
+ t(a.moveRowUp),
406
+ t(a.moveRowDown),
407
+ t(a.moveRowToStart),
408
+ t(a.moveRowToEnd),
409
+ t(a.moveCellLeft),
410
+ t(a.moveCellRight),
411
+ t(a.scrollToLineStart),
412
+ t(a.scrollToLineEnd),
413
+ t(a.scrollPageUp),
414
+ t(a.scrollPageDown),
415
+ t(a.insertGap),
416
+ t(a.deleteBackward),
417
+ t(a.deleteSelection),
418
+ t(a.deleteBase),
419
+ t(a.undo),
420
+ t(a.redo),
421
+ t(a.gotoPosition),
422
+ w.getInstance().registerShortcut({
423
+ callback: e,
424
+ element: F.current
425
+ }),
426
+ w.getInstance().registerShortcut({
427
+ callback: e,
428
+ element: F.current,
429
+ modifiers: [["Shift"]]
430
+ })
431
+ ];
432
+ return () => {
433
+ n.forEach((e) => e());
434
+ };
435
+ }, []), f(() => {
436
+ let t = async (e) => {
437
+ let { command: t, getSelectionPostCommand: n } = e;
438
+ try {
439
+ if (await t(), V.current = null, H.current = null, await Z(), Q(), n) {
440
+ let e = n();
441
+ W.next(e), G.current = e;
442
+ }
443
+ } catch (e) {
444
+ console.error("Failed to post command:", e);
445
+ }
446
+ }, n = async (e) => {
447
+ if (!z.data) return;
448
+ let n = o.getMutateArguments(W.data, z.data);
449
+ n && await t({ command: async () => {
450
+ for (let t = n.startCol; t <= n.endCol; t += 1) await A.mutate(n.rows, t, e);
451
+ } });
452
+ }, r = (e) => {
453
+ if (!z.data) return;
454
+ let t = o.getMovedSelection(W.data, e, z.data);
455
+ if (t) {
456
+ if (W.next(t), G.current) {
457
+ let t = o.getMovedSelection(G.current, e, z.data);
458
+ G.current = t;
459
+ } else G.current = t;
460
+ }
461
+ }, a = (e) => {
462
+ if (!z.data || !G.current || !W.data) return;
463
+ let t = o.getExpandedSelection(W.data, G.current, e, z.data);
464
+ t && W.next(t);
465
+ }, c = async (e) => {}, l = async (n) => {
466
+ if (!z.data) return;
467
+ let r = o.getRowsToMove(W.data, n, z.data);
468
+ r && await t({
469
+ command: async () => {
470
+ n === e.UP ? await A.moveRowsUp(r) : await A.moveRowsDown(r);
471
+ },
472
+ getSelectionPostCommand: () => o.getMovedSelection(W.data, n, z.data)
473
+ });
474
+ }, u = async (e) => {}, d = i.getInstance(), f = [
475
+ d.addEventListener("onSearch", async (e) => {
476
+ if (!e) return;
477
+ let t = await A.search(e, !1);
478
+ s.getState().setSearchResult(t);
479
+ }),
480
+ d.addEventListener("onExpandSelection", (e) => a(e)),
481
+ d.addEventListener("onGotoPosition", () => k.current?.open({})),
482
+ d.addEventListener("onMoveSelection", (e) => r(e)),
483
+ d.addEventListener("onMoveRows", (e) => {
484
+ l(e);
485
+ }),
486
+ d.addEventListener("onMoveRowsEnd", (e) => {
487
+ c(e);
488
+ }),
489
+ d.addEventListener("onMoveCells", (e) => {
490
+ u(e);
491
+ }),
492
+ d.addEventListener("onScrollToLineStart", () => {
493
+ let e = I.current;
494
+ e && (e.scrollLeft = 0);
495
+ }),
496
+ d.addEventListener("onScrollToLineEnd", () => {
497
+ let e = I.current;
498
+ e && (e.scrollLeft = e.scrollWidth - e.clientWidth);
499
+ }),
500
+ d.addEventListener("onScrollPageUp", () => {
501
+ let e = I.current;
502
+ e && (e.scrollTop = Math.max(0, e.scrollTop - e.clientHeight));
503
+ }),
504
+ d.addEventListener("onScrollPageDown", () => {
505
+ let e = I.current;
506
+ e && (e.scrollTop = Math.min(e.scrollHeight - e.clientHeight, e.scrollTop + e.clientHeight));
507
+ }),
508
+ d.addEventListener("onInsert", () => {
509
+ (async () => {
510
+ if (!z.data) return;
511
+ let n = o.getUpsertArguments(W.data, z.data);
512
+ n && await t({
513
+ command: async () => A.insert(n.rows, n.col),
514
+ getSelectionPostCommand: () => o.getPostUpsertSelection(W.data, e.RIGHT)
515
+ });
516
+ })();
517
+ }),
518
+ d.addEventListener("onDeleteBackward", () => {
519
+ (async () => {
520
+ if (!z.data) return;
521
+ let n = o.getUpsertArguments(W.data, z.data, -1);
522
+ n && await t({
523
+ command: async () => A.delete(n.rows, n.col),
524
+ getSelectionPostCommand: () => o.getPostUpsertSelection(W.data, e.LEFT)
525
+ });
526
+ })();
527
+ }),
528
+ d.addEventListener("onMutateSelection", (e) => {
529
+ n(e);
530
+ }),
531
+ d.addEventListener("onUndo", () => {
532
+ t({
533
+ command: async () => A.undo(),
534
+ getSelectionPostCommand: () => null
535
+ });
536
+ }),
537
+ d.addEventListener("onRedo", () => {
538
+ t({
539
+ command: async () => A.redo(),
540
+ getSelectionPostCommand: () => null
541
+ });
542
+ })
543
+ ];
544
+ return () => {
545
+ f.forEach((e) => e());
546
+ };
547
+ }, [
548
+ A,
549
+ W,
550
+ Z,
551
+ Q,
552
+ z
553
+ ]), f(() => {
554
+ Q();
555
+ }, [Q]);
556
+ let ue = d((e) => {
557
+ let t = e.currentTarget;
558
+ R.next({
559
+ scrollLeft: t.scrollLeft,
560
+ scrollTop: t.scrollTop
561
+ });
562
+ }, [R]), de = d((e) => {
563
+ F.current?.focus();
564
+ let n = e.currentTarget, r = n.getBoundingClientRect(), i = e.clientX >= r.left + n.clientWidth, a = e.clientY >= r.top + n.clientHeight;
565
+ if (i || a) return;
566
+ let s = j.current, c = M.current, l = C.getInstance().data;
567
+ if (!s || !c) return;
568
+ let u = o.getPathPropertiesFromCanvas({
569
+ canvas: s,
570
+ devicePixelRatio: l,
571
+ editorAssembly: c,
572
+ event: e.nativeEvent
573
+ });
574
+ if (u) {
575
+ if (u.type !== t.DIVIDER) {
576
+ if (u.type === t.LABEL && (e.metaKey || e.ctrlKey)) {
577
+ let t = W.data?.rows ?? [], n = t.includes(u.row) ? t.filter((e) => e !== u.row) : [...t, u.row].sort((e, t) => e - t);
578
+ if (e.preventDefault(), P.current = null, n.length === 0) {
579
+ W.next(null), G.current = null;
580
+ return;
581
+ }
582
+ W.next({ rows: n }), G.current = { rows: n };
583
+ return;
584
+ }
585
+ let n = o.getSelectionFromPathProperties({
586
+ endPath: u,
587
+ startPath: u
588
+ });
589
+ if (!n) return;
590
+ e.preventDefault(), P.current = u, W.next(n), G.current = n;
591
+ return;
592
+ }
593
+ e.preventDefault(), P.current = null, N.current = {
594
+ startLabelWidth: U.data.labelWidth,
595
+ startX: e.clientX
596
+ };
597
+ }
598
+ }, [U, W]), fe = d((e) => {
599
+ let n = j.current, r = F.current, i = C.getInstance().data, a = N.current;
600
+ if (!r || !n) return;
601
+ if (a) {
602
+ let t = Math.min($, Math.max(120, a.startLabelWidth + e.clientX - a.startX));
603
+ U.next({
604
+ ...U.data,
605
+ labelWidth: t
606
+ }), r.style.cursor = "col-resize";
607
+ return;
608
+ }
609
+ let s = P.current;
610
+ if (s) {
611
+ let t = M.current;
612
+ if (!t) return;
613
+ let r = o.getPathPropertiesFromCanvas({
614
+ canvas: n,
615
+ devicePixelRatio: i,
616
+ editorAssembly: t,
617
+ event: e.nativeEvent
618
+ });
619
+ if (!r) return;
620
+ let a = o.getSelectionFromPathProperties({
621
+ endPath: r,
622
+ startPath: s
623
+ });
624
+ a && (W.next(a), G.current = a);
625
+ return;
626
+ }
627
+ let c = M.current;
628
+ if (!c) return;
629
+ let l = o.getPathPropertiesFromCanvas({
630
+ canvas: n,
631
+ devicePixelRatio: i,
632
+ editorAssembly: c,
633
+ event: e.nativeEvent
634
+ });
635
+ if (!l) {
636
+ r.style.cursor = "default";
637
+ return;
638
+ }
639
+ l.type === t.DIVIDER ? r.style.cursor = "col-resize" : r.style.cursor = "default";
640
+ }, [
641
+ U,
642
+ $,
643
+ W
644
+ ]), pe = d(() => {
645
+ N.current = null, P.current = null;
646
+ }, []), me = d((e, t) => {
647
+ o.scrollToPosition({
648
+ geometry: U.data,
649
+ scrollContainer: I.current,
650
+ x: e,
651
+ y: t
652
+ });
653
+ }, [U]), he = Math.max(1, Math.floor(L.width * ne)), ge = Math.max(1, Math.floor(L.height * ne));
654
+ return /* @__PURE__ */ _(v, {
655
+ sx: {
656
+ display: "grid",
657
+ gridTemplateRows: "max-content auto",
658
+ height: "100%",
659
+ position: "relative",
660
+ width: "100%"
661
+ },
662
+ children: [
663
+ /* @__PURE__ */ g(l, {}),
664
+ /* @__PURE__ */ _(v, {
665
+ onMouseUp: pe,
666
+ ref: F,
667
+ sx: {
668
+ height: `calc(100% - ${Y.spacing(3)})`,
669
+ marginBottom: Y.spacing(3),
670
+ position: "relative",
671
+ width: "100%"
672
+ },
673
+ tabIndex: 0,
674
+ children: [
675
+ /* @__PURE__ */ g(v, {
676
+ onMouseDown: de,
677
+ onMouseMove: fe,
678
+ onScroll: ue,
679
+ ref: I,
680
+ sx: {
681
+ height: "100%",
682
+ overflowX: "scroll",
683
+ overflowY: "scroll",
684
+ position: "absolute",
685
+ width: "100%",
686
+ zIndex: 1
687
+ },
688
+ children: /* @__PURE__ */ g(v, { sx: {
689
+ height: `${Math.max(ie, L.height)}px`,
690
+ pointerEvents: "none",
691
+ width: `${Math.max(oe, L.width)}px`
692
+ } })
693
+ }),
694
+ /* @__PURE__ */ g("canvas", {
695
+ height: ge,
696
+ ref: j,
697
+ style: {
698
+ display: "block",
699
+ height: `${L.height}px`,
700
+ imageRendering: "pixelated",
701
+ left: 0,
702
+ pointerEvents: "auto",
703
+ position: "absolute",
704
+ top: 0,
705
+ width: `${L.width}px`,
706
+ zIndex: 0
707
+ },
708
+ width: he
709
+ }),
710
+ /* @__PURE__ */ g(v, {
711
+ sx: {
712
+ bottom: Y.spacing(-3),
713
+ height: Y.spacing(3),
714
+ left: 0,
715
+ position: "absolute",
716
+ width: "100%",
717
+ zIndex: 2
718
+ },
719
+ children: /* @__PURE__ */ g(D, {})
720
+ })
721
+ ]
722
+ }),
723
+ /* @__PURE__ */ g(ee, {
724
+ onGotoPosition: me,
725
+ ref: k
726
+ })
727
+ ]
728
+ });
729
+ };
730
+ //#endregion
731
+ export { k as t };
732
+
733
+ //# sourceMappingURL=SequenceEditor.js.map