@pennsieve-viz/tsviewer 1.0.31 → 1.1.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 (33) hide show
  1. package/dist/{BFLibraryButton-Dec5fit3.js → BFLibraryButton-CjW78KwZ.js} +1 -1
  2. package/dist/{BFLibraryButton-CnSdxNr1.cjs → BFLibraryButton-DGI5G53e.cjs} +1 -1
  3. package/dist/{IconSelection-CxtyAEya.cjs → IconSelection-BJc1giuT.cjs} +1 -1
  4. package/dist/{IconSelection-C_zQHxVs.js → IconSelection-ChXlHpsu.js} +1 -1
  5. package/dist/TSAnnotationCanvas-CfyqYTnB.js +730 -0
  6. package/dist/TSAnnotationCanvas-DhskkXWf.cjs +1 -0
  7. package/dist/{TSAnnotationModal-Bvz6Hr6c.cjs → TSAnnotationModal-Bde2b3U0.cjs} +1 -1
  8. package/dist/{TSAnnotationModal-Crb5zX1P.js → TSAnnotationModal-KX-_Afb3.js} +42 -42
  9. package/dist/{TSFilterModal-DdNCo0nH.js → TSFilterModal-BMSEMK8Y.js} +3 -3
  10. package/dist/{TSFilterModal-BA7WXDk1.cjs → TSFilterModal-RgvcihE6.cjs} +1 -1
  11. package/dist/TSScrubber-C90JS4pD.cjs +1 -0
  12. package/dist/{TSScrubber-BsoGLy_L.js → TSScrubber-DqCc3Zp7.js} +39 -39
  13. package/dist/{TSViewerCanvas-ByhDLibl.js → TSViewerCanvas-3TTYdC6T.js} +13 -13
  14. package/dist/{TSViewerCanvas-D_i1FrqG.cjs → TSViewerCanvas-BUlYMq9z.cjs} +2 -2
  15. package/dist/{TSViewerLayerWindow-Cf4J_lK_.js → TSViewerLayerWindow-B94J9tDk.js} +2 -2
  16. package/dist/{TSViewerLayerWindow-4ckQFmUZ.cjs → TSViewerLayerWindow-C5Va7dH9.cjs} +1 -1
  17. package/dist/{TSViewerToolbar-BLOSD8fd.cjs → TSViewerToolbar-B1q33g4K.cjs} +1 -1
  18. package/dist/{TSViewerToolbar-BxAiyYi7.js → TSViewerToolbar-ECRy1rzk.js} +6 -6
  19. package/dist/{TsAnnotationDeleteDialog-Dm0rbNQr.js → TsAnnotationDeleteDialog-3aMg8Pa_.js} +3 -3
  20. package/dist/{TsAnnotationDeleteDialog-B_ZIUOh2.cjs → TsAnnotationDeleteDialog-O-NFN0pa.cjs} +1 -1
  21. package/dist/index-B-qad683.cjs +1 -0
  22. package/dist/index-ZGQLYYRT.js +1459 -0
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +7 -3
  25. package/dist/{pathOr-D8CyYHmd.cjs → pathOr-BHBhJmTE.cjs} +1 -1
  26. package/dist/{pathOr-CC_5pAvC.js → pathOr-Byg6zMXz.js} +1 -1
  27. package/dist/style.css +1 -1
  28. package/package.json +1 -1
  29. package/dist/TSAnnotationCanvas-BuYjJ340.cjs +0 -1
  30. package/dist/TSAnnotationCanvas-DV93mqhV.js +0 -778
  31. package/dist/TSScrubber-KnkoGu88.cjs +0 -1
  32. package/dist/index-C3ilckwx.js +0 -1318
  33. package/dist/index-D8lvFC22.cjs +0 -1
@@ -0,0 +1,730 @@
1
+ import { inject as U, ref as C, computed as J, watch as ne, onMounted as oe, createElementBlock as ae, openBlock as ie, normalizeStyle as re, unref as K, nextTick as se } from "vue";
2
+ import { o as le, m as ce, h as V, p as j, u as N, j as P, i as D, g as ue } from "./index-ZGQLYYRT.js";
3
+ import { storeToRefs as te } from "pinia";
4
+ import { f as de, h as fe } from "./TSViewerCanvas-3TTYdC6T.js";
5
+ import { p as G } from "./pathOr-Byg6zMXz.js";
6
+ import { g as ve } from "./_commonjsHelpers-DaMA6jEr.js";
7
+ const I = (t, o) => {
8
+ let c;
9
+ if (/^#([A-Fa-f0-9]{3}){1,2}$/.test(t))
10
+ return c = t.substring(1).split(""), c.length === 3 && (c = [c[0], c[0], c[1], c[1], c[2], c[2]]), c = "0x" + c.join(""), "rgba(" + [c >> 16 & 255, c >> 8 & 255, c & 255].join(",") + "," + o + ")";
11
+ throw new Error("Bad Hex");
12
+ }, he = (t) => {
13
+ t.sort((o, c) => o.start < c.start ? -1 : o.start > c.start ? 1 : 0);
14
+ }, Q = (t, o) => {
15
+ const c = (t == null ? void 0 : t.layer_id) || 0;
16
+ return le({}, de(ce("id", c), o));
17
+ }, Y = (t, o, c, a = 0, f = !1) => {
18
+ let u;
19
+ return f ? u = q(t, o, a, t.length - 1, c) : u = W(t, o, a, t.length - 1, c), u === -1 ? u = 0 : u < 0 && (u = -u - 2), u;
20
+ }, W = (t, o, c, a, f) => {
21
+ if (a < c) {
22
+ let g = a >= 0 ? a : -a - 2;
23
+ if (g === -1) return g;
24
+ const m = t[g].start;
25
+ for (; g >= 0 && t[g].start === m; )
26
+ g--;
27
+ return -g - 2;
28
+ }
29
+ const u = parseInt((c + a) / 2);
30
+ if (t[u].start > o)
31
+ return W(t, o, c, u - 1, f);
32
+ if (t[u].start < o)
33
+ return W(t, o, u + 1, a, f);
34
+ {
35
+ let g = u;
36
+ if (f) {
37
+ for (; g >= 0 && t[g].start === o; )
38
+ g--;
39
+ g++;
40
+ } else {
41
+ for (; g < t.length && t[g].start === o; )
42
+ g++;
43
+ g--;
44
+ }
45
+ return g;
46
+ }
47
+ }, q = (t, o, c, a, f) => {
48
+ if (a < c) {
49
+ let m = a >= 0 ? a : -a - 2;
50
+ if (m === -1) return m;
51
+ const F = t[m].start + t[m].duration;
52
+ for (; m >= 0 && t[m].start + t[m].duration === F; )
53
+ m--;
54
+ return -m - 2;
55
+ }
56
+ const u = parseInt((c + a) / 2), g = t[u].start + t[u].duration;
57
+ if (g > o)
58
+ return q(t, o, c, u - 1, f);
59
+ if (g < o)
60
+ return q(t, o, u + 1, a, f);
61
+ {
62
+ let m = u;
63
+ if (f) {
64
+ for (; m >= 0 && t[m].start + t[m].duration === o; )
65
+ m--;
66
+ m++;
67
+ } else {
68
+ for (; m < t.length && t[m].start + t[m].duration === o; )
69
+ m++;
70
+ m--;
71
+ }
72
+ return m;
73
+ }
74
+ }, Z = (t, o, c = 0) => o * (t + c);
75
+ function ge(t = null) {
76
+ const o = t || U("viewerStore", null) || V("default"), { viewerChannels: c, viewerAnnotations: a, viewerMontageScheme: f } = te(o), u = C([]), g = C([]), m = (y) => {
77
+ const d = f.value !== "NOT_MONTAGED";
78
+ let e = j("", "id", y);
79
+ if (d) {
80
+ const l = e.split("_");
81
+ e = l.length ? fe(l) : e;
82
+ }
83
+ return e;
84
+ }, F = async (y, d, e, l, v) => {
85
+ const r = [];
86
+ r.push({ start: y, end: e.tsEnd });
87
+ let i = 0;
88
+ for (let n = 0; n < u.value.length; n++) {
89
+ const s = u.value[n];
90
+ if (y >= s.start && d <= s.end)
91
+ return;
92
+ if (r[0].start > d)
93
+ break;
94
+ if (s.start <= r[0].start && s.end >= y)
95
+ i = n + 1, r[0].start = s.end;
96
+ else if (s.start > r[0].start) {
97
+ i = n;
98
+ break;
99
+ }
100
+ }
101
+ const h = a.value.reduce((n, s) => n + s.annotations.length, 0);
102
+ if (r[0].start >= r[0].end && h > 0)
103
+ return;
104
+ const w = 0;
105
+ for (let n = i; n < u.value.length; n++)
106
+ if (u.value[n].start >= r[w].start)
107
+ if (r[w].end = u.value[n].start, u.value[n].end < d)
108
+ r.push({ start: u.value[n].end, end: e.tsEnd });
109
+ else
110
+ break;
111
+ if (!(r[0].start >= r[0].end && h > 0) && r.length > 0) {
112
+ c.value.map((n) => m(n));
113
+ for (const n of r) {
114
+ for (const s of a.value) {
115
+ if (!s.id) {
116
+ console.warn("Layer ID is undefined, skipping annotation request for layer:", s);
117
+ continue;
118
+ }
119
+ const T = Math.floor(n.end), p = {
120
+ id: l.content.id,
121
+ start: Math.floor(n.start),
122
+ end: T,
123
+ layerId: s.id,
124
+ limit: e.constants.LIMITANNFETCH
125
+ };
126
+ try {
127
+ const O = await N(), b = `${o.config.apiUrl}/timeseries/${l.content.id}/layers/${s.id}/annotations?api_key=${O}`, L = Object.keys(p).map((H) => `&${H}=${p[H]}`).join(""), E = `${b}${L}`, A = await fetch(E, {
128
+ method: "GET",
129
+ headers: { "Content-type": "application/json" }
130
+ });
131
+ if (A.status >= 400)
132
+ throw new Error(A.status);
133
+ const $ = await A.json();
134
+ await M($, v);
135
+ } catch (O) {
136
+ P(O);
137
+ }
138
+ }
139
+ u.value.push({
140
+ start: Math.floor(n.start),
141
+ end: Math.floor(n.end)
142
+ });
143
+ }
144
+ u.value.sort((n, s) => n.start < s.start ? -1 : n.start > s.start ? 1 : 0);
145
+ }
146
+ }, M = async (y, d) => {
147
+ const e = j({}, "linkedPackages", y);
148
+ let l = G([], ["annotations", "results"], y);
149
+ if (l.length >= 500) {
150
+ let r = 0;
151
+ for (const i of l)
152
+ i.start > r && (r = i.start);
153
+ for (const i of u.value)
154
+ if (i.end > r && i.start < r) {
155
+ i.end = r;
156
+ break;
157
+ }
158
+ }
159
+ const v = f.value !== "NOT_MONTAGED";
160
+ if (l.length > 0) {
161
+ const r = l.map((i) => {
162
+ const h = {
163
+ name: "",
164
+ id: i.id,
165
+ label: i.label,
166
+ description: i.description,
167
+ start: i.start,
168
+ duration: i.end - i.start,
169
+ end: i.end,
170
+ cStart: null,
171
+ cEnd: null,
172
+ selected: !1,
173
+ channelIds: i.channelIds,
174
+ allChannels: !1,
175
+ layer_id: i.layerId,
176
+ userId: i.userId
177
+ };
178
+ if (i.linkedPackage) {
179
+ const w = i.linkedPackage;
180
+ h.linkedPackage = G("", ["content", "id"], e[w]), h.linkedPackageDTO = e[w];
181
+ }
182
+ return (!v && h.channelIds.length === c.value.length || v && h.channelIds.length > c.value.length) && (h.allChannels = !0), h;
183
+ });
184
+ a.value.forEach((i) => {
185
+ const h = i.annotations, w = r.filter((n) => i.id === n.layer_id);
186
+ i.annotations = h.concat(w), o.updateLayer(i);
187
+ });
188
+ }
189
+ d("annotationsReceived");
190
+ };
191
+ return {
192
+ cachedAnnRange: u,
193
+ annLayerInfo: g,
194
+ checkAnnotationRange: F,
195
+ findNextAnnotation: (y) => {
196
+ const d = o.getViewerActiveLayer(), e = Y(d.annotations, y, !1);
197
+ return e < d.annotations.length ? d.annotations[e].start > y ? d.annotations[e] : d.annotations[e + 1] || d.annotations[e] : d.annotations[e];
198
+ },
199
+ findPreviousAnnotation: (y) => {
200
+ const d = o.getViewerActiveLayer(), e = Y(d.annotations, y, !0);
201
+ return d.annotations[e].start < y ? d.annotations[e] : e > 0 ? d.annotations[e - 1] : d.annotations[e];
202
+ },
203
+ getChannelId: m
204
+ };
205
+ }
206
+ function ye(t = null) {
207
+ const o = t || U("viewerStore", null) || V("default"), { viewerAnnotations: c, viewerChannels: a } = te(o), f = C([]), u = C([]), g = C(null), m = C(["#FFFF4E"]), F = (e, l) => {
208
+ var h, w;
209
+ const r = (((h = l.constants) == null ? void 0 : h.ANNOTATIONLABELHEIGHT) || 20) / 2 | 0, i = ((w = l.constants) == null ? void 0 : w.XOFFSET) || 0;
210
+ for (const n of e) {
211
+ let s = n.start, T = n.duration;
212
+ n.duration < 0 && (s = n.start + n.duration, T = -n.duration);
213
+ const p = i + (s - l.start) / l.rsPeriod;
214
+ if (n.cStart = p | 0, n.duration !== 0) {
215
+ const O = i + (s + T - l.start) / l.rsPeriod;
216
+ n.cEnd = O | 0;
217
+ } else
218
+ n.cEnd = n.cStart + l.cWidth / 40 | 0;
219
+ if (n.allChannels)
220
+ n.allOffsets = [r], n.cY = r;
221
+ else {
222
+ n.allOffsets = [], n.minOffset = l.cHeight | 0, n.maxOffset = 0;
223
+ const O = a.value;
224
+ for (const S of n.channelIds) {
225
+ let b = null;
226
+ for (const L of O)
227
+ if (L.id === S && L.visible) {
228
+ b = L.rowBaseline | 0, b < n.minOffset && (n.minOffset = b), b > n.maxOffset && (n.maxOffset = b), n.allOffsets.push(b);
229
+ break;
230
+ }
231
+ }
232
+ u.value.indexOf(n.minOffset) < 0 && u.value.push(n.minOffset), n.cY = n.minOffset;
233
+ }
234
+ }
235
+ }, M = (e, l, v, r) => {
236
+ var w, n;
237
+ const i = ((w = v.constants) == null ? void 0 : w.ANNOTATIONLABELHEIGHT) || 20, h = i / 2 | 0;
238
+ e.setTransform(v.pixelRatio, 0, 0, v.pixelRatio, 0, 0), e.save(), e.lineWidth = 1, e.setLineDash([8, 5]), e.strokeStyle = "rgba(0,0,0, 0.6)", e.fillStyle = "rgba(0,0,0,0.05)";
239
+ for (const s of l) {
240
+ const T = Q(s, c.value);
241
+ s.selected && (e.save(), e.strokeStyle = T.selColor, e.fillStyle = T.bkColor, e.lineWidth = 1);
242
+ const p = Math.round(s.cStart) + 0.5, O = Math.round(s.cEnd) + 0.5;
243
+ s.allChannels ? s.duration === 0 ? (e.beginPath(), e.moveTo(p + 1, i), e.lineTo(p, r), e.stroke()) : (e.fillRect(p, i, O - p, r - i), e.beginPath(), e.moveTo(p, i), e.lineTo(p, r), e.moveTo(O, i), e.lineTo(O, r), e.stroke()) : ((n = s == null ? void 0 : s.channelIds) == null ? void 0 : n.length) === 1 ? s.duration === 0 && (e.beginPath(), e.moveTo(p, s.minOffset + h), e.lineTo(p, s.minOffset + h + 8), e.stroke()) : s.duration === 0 ? (e.beginPath(), e.moveTo(p, s.minOffset + h), e.lineTo(p, s.maxOffset - h), e.stroke()) : (e.fillRect(
244
+ p - 1,
245
+ s.minOffset + h,
246
+ O - p + 1,
247
+ s.maxOffset - s.minOffset - i
248
+ ), e.beginPath(), e.moveTo(p, s.minOffset + h), e.lineTo(p, s.maxOffset - h), e.moveTo(O, s.minOffset + h), e.lineTo(O, s.maxOffset - h), e.stroke()), s.selected && e.restore();
249
+ }
250
+ e.restore();
251
+ }, R = async (e, l, v, r, i, h) => {
252
+ var s;
253
+ const w = ((s = v.constants) == null ? void 0 : s.ANNOTATIONLABELHEIGHT) || 20, n = w / 2 | 0;
254
+ e.setTransform(v.pixelRatio, 0, 0, v.pixelRatio, 0, 0), e.save(), e.lineWidth = 2, e.font = "14px sans-serif", e.textAlign = "left";
255
+ for (const T of l) {
256
+ const p = Q(T, c.value);
257
+ if (T === g.value && r)
258
+ continue;
259
+ T.selected ? (e.fillStyle = p.selColor || "rgba(51,204,102, 0.8)", e.strokeStyle = "white") : (e.fillStyle = p.color || "rgba(51,204,102,0.8)", e.strokeStyle = T === g.value ? "white" : "rgba(255,255,255,0.8)");
260
+ const O = Math.round(T.cStart) + 1, S = Math.round(T.cEnd);
261
+ let b = 0;
262
+ for (let A = 0; A < T.allOffsets.length; A++)
263
+ e.fillRect(
264
+ O - 1,
265
+ T.allOffsets[A] - n,
266
+ S - O + 2,
267
+ w
268
+ ), T.allOffsets[A] === T.minOffset && (b = A);
269
+ const L = T.allOffsets[b];
270
+ if (["annSelect", "annResize-left", "annResize-right"].includes(i) && h === "annotate" && (e.beginPath(), T.duration !== 0 && (e.moveTo(S - 3, L - n + 3), e.lineTo(S - 3, L + n - 3)), e.moveTo(O + 3, L - n + 3), e.lineTo(O + 3, L + n - 3), e.stroke()), S - O > T.label.length * 8 + 10) {
271
+ e.fillStyle = m.value.indexOf(p.hexColor) >= 0 ? "black" : "white";
272
+ const A = T.linkedPackage ? O + 30 : O + 10, $ = T.linkedPackage ? L + n - n / 2 : L + n - 6;
273
+ e.fillText(T.label, A, $);
274
+ }
275
+ const E = T.linkedPackageDTO;
276
+ E && S - O >= 30 && await k(e, E, O, L, n, w);
277
+ }
278
+ e.restore();
279
+ }, k = async (e, l, v, r, i, h) => {
280
+ const w = G({}, ["objects", "view", 1, "content"], l), n = j("", "fileType", w), s = new Image();
281
+ if (n === "PNG") {
282
+ const { id: T, packageId: p } = w, O = o.config.apiUrl;
283
+ try {
284
+ const S = await N();
285
+ s.src = `${O}/packages/${p}/files/${T}/presign/?api_key=${S}`, s.complete ? e.drawImage(s, v, r - i, 27, h) : s.addEventListener("load", () => {
286
+ e.drawImage(s, v, r - i, 27, h);
287
+ }, { once: !0 });
288
+ } catch (S) {
289
+ console.error("Error loading image:", S);
290
+ }
291
+ } else
292
+ s.src = y(), e.drawImage(s, v + 5, r - i, 20, 20);
293
+ }, y = (e) => "/path/to/default/icon.png";
294
+ return {
295
+ renderAnn: f,
296
+ hoverOffsets: u,
297
+ focusedAnn: g,
298
+ render: (e, l, v, r) => {
299
+ var T, p, O, S;
300
+ if (!l) {
301
+ console.warn("TSAnnotationCanvas: annotationsCanvas prop is undefined or null");
302
+ return;
303
+ }
304
+ const i = l.getContext("2d"), h = v.getContext("2d");
305
+ i.setTransform(e.pixelRatio, 0, 0, e.pixelRatio, 0, 0), h.setTransform(e.pixelRatio, 0, 0, e.pixelRatio, 0, 0), u.value = [(((T = e.constants) == null ? void 0 : T.ANNOTATIONLABELHEIGHT) || 20) / 2], i.clearRect(0, 0, e.cWidth, e.cHeight), h.clearRect(0, 0, e.cWidth, e.cHeight), f.value = [];
306
+ const w = e.duration && e.duration > 0 ? e.duration : 15e6, n = e.start || 0, s = n + w;
307
+ console.log("🎨 Annotation render debug:", {
308
+ start: n,
309
+ duration: w,
310
+ end: s,
311
+ layerCount: ((p = c.value) == null ? void 0 : p.length) || 0,
312
+ totalAnnotations: ((O = c.value) == null ? void 0 : O.reduce((b, L) => {
313
+ var E;
314
+ return b + (((E = L.annotations) == null ? void 0 : E.length) || 0);
315
+ }, 0)) || 0
316
+ });
317
+ for (const b of c.value)
318
+ if (b.visible && ((S = b.annotations) == null ? void 0 : S.length) > 0) {
319
+ console.log(`🔍 Processing layer "${b.name}" with ${b.annotations.length} annotations`);
320
+ const L = b.annotations.filter((E) => {
321
+ const A = E.start, $ = E.end || E.start + (E.duration || 0), H = A < s && $ > n;
322
+ return H && console.log(` ✅ Including annotation "${E.label}": ${A} - ${$}`), H;
323
+ });
324
+ console.log(` 📊 Found ${L.length} annotations in viewport`), L.length > 0 && (L.sort((E, A) => E.start - A.start), f.value.push(...L));
325
+ }
326
+ if (console.log(`🎯 Total annotations to render: ${f.value.length}`), f.value.length === 0) {
327
+ console.log("⚠️ No annotations found in viewport");
328
+ return;
329
+ }
330
+ he(f.value), F(f.value, e), M(i, f.value, e, r), R(h, f.value, e, !0, e.pointerMode, e.viewerActiveTool), g.value && R(h, [g.value], e, !1, e.pointerMode, e.viewerActiveTool), console.log(`✅ Rendered ${f.value.length} annotations successfully`);
331
+ },
332
+ computeRenderOptions: F,
333
+ renderAnnotationAreas: M,
334
+ renderAnnotationLabels: R
335
+ };
336
+ }
337
+ function we(t, o, c, a = null) {
338
+ const f = a || U("viewerStore", null) || V("default"), u = C([0, 0]), g = (e, l) => {
339
+ const r = ((l == null ? void 0 : l.ANNOTATIONLABELHEIGHT) || 20) / 2;
340
+ for (const i of c.value)
341
+ if (e >= i - r && e <= i + r)
342
+ return !0;
343
+ return !1;
344
+ }, m = (e, l, v) => {
345
+ var h;
346
+ const i = ((v == null ? void 0 : v.ANNOTATIONLABELHEIGHT) || 20) / 2;
347
+ for (let w = 0; w < (((h = o.value) == null ? void 0 : h.length) || 0); w++) {
348
+ const n = o.value[w];
349
+ if (n.cStart < e && n.cEnd > e) {
350
+ if (l > n.cY - i && l < n.cY + i)
351
+ return w;
352
+ } else if (n.cStart > e)
353
+ break;
354
+ }
355
+ return null;
356
+ }, F = (e, l, v) => {
357
+ if (!v) return l;
358
+ switch (l) {
359
+ case "annotate":
360
+ return e <= v.cStart + 10 ? "annResize-left" : e >= v.cEnd - 10 && v.duration > 0 ? "annResize-right" : "annSelect";
361
+ case "pointer":
362
+ return "annSelect";
363
+ default:
364
+ return l;
365
+ }
366
+ };
367
+ return {
368
+ mouseDownPosition: u,
369
+ shouldCheckAnnotationHover: g,
370
+ findAnnotationAtPosition: m,
371
+ determinePointerMode: F,
372
+ resetFocusedAnnotation: () => {
373
+ var e;
374
+ ((e = t.value) == null ? void 0 : e.oldStart) !== void 0 && (t.value.start = t.value.oldStart, t.value.duration = t.value.oldDuration, t.value.end = t.value.start + t.value.duration);
375
+ },
376
+ selectFocusedAnnotation: () => t.value ? (f.setActiveAnnotation(t.value), !0) : !1,
377
+ onMouseDown: (e, l, v) => {
378
+ t.value && ["annResize-left", "annResize-right"].includes(v) && (t.value.oldStart = t.value.start, t.value.oldDuration = t.value.duration, u.value = [e, l]);
379
+ },
380
+ onMouseMove: (e, l, v, r, i) => {
381
+ let h = v;
382
+ if (r && u.value) {
383
+ const w = (e - u.value[0]) * i.rsPeriod;
384
+ switch (v) {
385
+ case "annResize-left":
386
+ t.value.oldDuration > 0 ? (t.value.start = t.value.oldStart + w, t.value.duration = t.value.oldDuration - w, t.value.end = t.value.start + t.value.duration) : t.value.start = t.value.oldStart + w;
387
+ break;
388
+ case "annResize-right":
389
+ t.value.duration = t.value.oldDuration + w, t.value.end = t.value.start + t.value.duration;
390
+ break;
391
+ }
392
+ } else {
393
+ const w = g(l, i.constants);
394
+ if (h = i.viewerActiveTool, w) {
395
+ const n = m(e, l, i.constants);
396
+ if (n !== null) {
397
+ const s = t.value, T = o.value[n];
398
+ (!s || e < t.value.cStart || e > t.value.cEnd) && (t.value = T), h = F(e, i.viewerActiveTool, t.value);
399
+ } else
400
+ t.value = null;
401
+ } else
402
+ t.value = null, h = i.viewerActiveTool;
403
+ }
404
+ return h;
405
+ },
406
+ onMouseUp: (e, l) => {
407
+ if (t.value && ["annResize-left", "annResize-right"].includes(e)) {
408
+ if (t.value.duration < 0) {
409
+ const v = -t.value.duration, r = t.value.start - v;
410
+ t.value.start = r, t.value.duration = v, t.value.end = r + v;
411
+ }
412
+ f.setActiveAnnotation(t.value), l("updateAnnotation", t.value);
413
+ }
414
+ }
415
+ };
416
+ }
417
+ var B = { exports: {} }, X;
418
+ function me() {
419
+ if (X) return B.exports;
420
+ X = 1;
421
+ function t() {
422
+ }
423
+ return t.prototype = {
424
+ on: function(o, c, a) {
425
+ var f = this.e || (this.e = {});
426
+ return (f[o] || (f[o] = [])).push({
427
+ fn: c,
428
+ ctx: a
429
+ }), this;
430
+ },
431
+ once: function(o, c, a) {
432
+ var f = this;
433
+ function u() {
434
+ f.off(o, u), c.apply(a, arguments);
435
+ }
436
+ return u._ = c, this.on(o, u, a);
437
+ },
438
+ emit: function(o) {
439
+ var c = [].slice.call(arguments, 1), a = ((this.e || (this.e = {}))[o] || []).slice(), f = 0, u = a.length;
440
+ for (f; f < u; f++)
441
+ a[f].fn.apply(a[f].ctx, c);
442
+ return this;
443
+ },
444
+ off: function(o, c) {
445
+ var a = this.e || (this.e = {}), f = a[o], u = [];
446
+ if (f && c)
447
+ for (var g = 0, m = f.length; g < m; g++)
448
+ f[g].fn !== c && f[g].fn._ !== c && u.push(f[g]);
449
+ return u.length ? a[o] = u : delete a[o], this;
450
+ }
451
+ }, B.exports = t, B.exports.TinyEmitter = t, B.exports;
452
+ }
453
+ var z, x;
454
+ function Te() {
455
+ if (x) return z;
456
+ x = 1;
457
+ var t = me();
458
+ return z = new t(), z;
459
+ }
460
+ var Le = Te();
461
+ const _ = /* @__PURE__ */ ve(Le), ee = {
462
+ $emit: (...t) => _.emit(...t),
463
+ $on: (...t) => _.on(...t),
464
+ $off: (...t) => _.off(...t),
465
+ $once: (...t) => _.once(...t)
466
+ };
467
+ function ke(t = null) {
468
+ const o = t || U("viewerStore", null) || V("default"), c = C([]), a = C([
469
+ "#18BA62",
470
+ "#FFBC27",
471
+ "#E94B4B",
472
+ "#0D4EFF",
473
+ "#FF4FFF",
474
+ "#50FFFF",
475
+ "#FFFF4E",
476
+ "#512BAF",
477
+ "#8A6ECF",
478
+ "#389BAD",
479
+ "#187D46",
480
+ "#B12800",
481
+ "#0C2475",
482
+ "#FF5321",
483
+ "#FF99CC",
484
+ "#DCC180",
485
+ "#FF6C21",
486
+ "#000000",
487
+ "#9B9B9B",
488
+ "#00FF00",
489
+ "#FA8072",
490
+ "#808000",
491
+ "#A0522D",
492
+ "#2760FF"
493
+ ]), f = async (k, y) => {
494
+ const d = [];
495
+ if (k.results.length === 0)
496
+ await u({
497
+ name: "Default",
498
+ color: "#18BA62",
499
+ description: "Default Annotation Layer"
500
+ }, null, y);
501
+ else {
502
+ for (let e = 0; e < k.results.length; e++) {
503
+ const l = k.results[e];
504
+ let v = l.color || a.value[e % a.value.length];
505
+ const r = {
506
+ id: l.id,
507
+ name: l.name,
508
+ description: l.description,
509
+ visible: !0,
510
+ selected: e === 0,
511
+ // First layer is selected by default
512
+ annotations: [],
513
+ color: I(v, 0.7),
514
+ hexColor: v,
515
+ bkColor: I(v, 0.15),
516
+ selColor: I(v, 0.9)
517
+ };
518
+ d.push(r);
519
+ }
520
+ o.setAnnotations(d), y("annLayersInitialized");
521
+ }
522
+ c.value = k.results;
523
+ }, u = async (k, y, d) => {
524
+ try {
525
+ const e = await N(), l = `${o.config.apiUrl}/timeseries/${y.content.id}/layers?api_key=${e}`, v = await D(l, {
526
+ method: "POST",
527
+ body: {
528
+ name: k.name,
529
+ color: k.color,
530
+ description: k.description || k.name
531
+ }
532
+ }), r = {
533
+ ...v,
534
+ annotations: [],
535
+ hexColor: v.color,
536
+ color: I(v.color, 0.7),
537
+ bkColor: I(v.color, 0.15),
538
+ selColor: I(v.color, 0.9),
539
+ visible: !0,
540
+ selected: !0
541
+ };
542
+ return o.createLayer(r), o.setActiveAnnotationLayer(r.id), ee.$emit("toast", {
543
+ detail: {
544
+ msg: `'${r.name}' Layer Created`
545
+ }
546
+ }), r;
547
+ } catch (e) {
548
+ throw P(e), e;
549
+ } finally {
550
+ d && d("closeAnnotationLayerWindow");
551
+ }
552
+ };
553
+ return {
554
+ annLayerInfo: c,
555
+ defaultColors: a,
556
+ initializeLayers: f,
557
+ createAnnotationLayer: u,
558
+ updateLayerVisibility: (k, y) => {
559
+ console.log(`[useAnnotationLayers] Updating layer ${k} visibility to:`, y);
560
+ const d = o.viewerAnnotations.find((e) => e.id === k);
561
+ if (d) {
562
+ console.log("[useAnnotationLayers] Found layer:", d.name, "current visible:", d.visible), d.visible = y, o.updateLayer(d), console.log("[useAnnotationLayers] Updated layer:", d.name, "new visible:", d.visible);
563
+ const e = o.viewerAnnotations.find((l) => l.id === k);
564
+ console.log("[useAnnotationLayers] Verification - layer visible is now:", e == null ? void 0 : e.visible);
565
+ } else
566
+ console.error("[useAnnotationLayers] Layer not found with ID:", k), console.log("[useAnnotationLayers] Available layers:", o.viewerAnnotations.map((e) => ({ id: e.id, name: e.name })));
567
+ },
568
+ selectLayer: (k) => {
569
+ o.viewerAnnotations.forEach((d) => {
570
+ d.selected = !1, o.updateLayer(d);
571
+ });
572
+ const y = o.viewerAnnotations.find((d) => d.id === k);
573
+ y && (y.selected = !0, o.updateLayer(y), o.setActiveAnnotationLayer(k));
574
+ },
575
+ deleteLayer: async (k, y) => {
576
+ try {
577
+ const d = await N(), e = `${o.config.apiUrl}/timeseries/${y.content.id}/layers/${k}?api_key=${d}`;
578
+ await D(e, { method: "DELETE" }), o.removeLayer(k), ee.$emit("toast", {
579
+ detail: {
580
+ msg: "Layer deleted successfully"
581
+ }
582
+ });
583
+ } catch (d) {
584
+ throw P(d), d;
585
+ }
586
+ },
587
+ updateLayerColor: async (k, y, d) => {
588
+ try {
589
+ const e = await N(), l = `${o.config.apiUrl}/timeseries/${d.content.id}/layers/${k}?api_key=${e}`, v = await D(l, {
590
+ method: "PUT",
591
+ body: { color: y }
592
+ }), r = o.viewerAnnotations.find((i) => i.id === k);
593
+ return r && (r.hexColor = y, r.color = I(y, 0.7), r.bkColor = I(y, 0.15), r.selColor = I(y, 0.9), o.updateLayer(r)), v;
594
+ } catch (e) {
595
+ throw P(e), e;
596
+ }
597
+ },
598
+ loadLayers: async (k, y) => {
599
+ try {
600
+ const d = await N(), e = `${o.config.apiUrl}/timeseries/${k.content.id}/layers?api_key=${d}`, l = await D(e);
601
+ return await f(l, y), l;
602
+ } catch (d) {
603
+ throw P(d), d;
604
+ }
605
+ }
606
+ };
607
+ }
608
+ const Oe = ["width", "height"], pe = {
609
+ __name: "TSAnnotationCanvas",
610
+ props: {
611
+ cWidth: { type: Number, default: 0 },
612
+ cHeight: Number,
613
+ start: Number,
614
+ duration: Number,
615
+ tsEnd: Number,
616
+ rsPeriod: Number,
617
+ pixelRatio: Number,
618
+ constants: {
619
+ type: Object,
620
+ default: () => ({
621
+ ANNOTATIONLABELHEIGHT: 20,
622
+ XOFFSET: 0,
623
+ LIMITANNFETCH: 500
624
+ })
625
+ },
626
+ pointerMode: String,
627
+ annotationsCanvas: [HTMLCanvasElement, Object],
628
+ activeViewer: { type: Object, required: !0 },
629
+ viewerActiveTool: String
630
+ },
631
+ emits: [
632
+ "annLayersInitialized",
633
+ "annotationsReceived",
634
+ "closeAnnotationLayerWindow",
635
+ "updateAnnotation"
636
+ ],
637
+ setup(t, { expose: o, emit: c }) {
638
+ const a = t, f = c, u = C(null), {
639
+ checkAnnotationRange: g,
640
+ findNextAnnotation: m,
641
+ findPreviousAnnotation: F
642
+ } = ge(), {
643
+ renderAnn: M,
644
+ hoverOffsets: R,
645
+ focusedAnn: k,
646
+ render: y
647
+ } = ye(), {
648
+ resetFocusedAnnotation: d,
649
+ selectFocusedAnnotation: e,
650
+ onMouseDown: l,
651
+ onMouseMove: v,
652
+ onMouseUp: r
653
+ } = we(k, M, R), {
654
+ createAnnotationLayer: i,
655
+ loadLayers: h
656
+ } = ke(), w = J(() => a.cHeight - 20), n = J(() => ({
657
+ width: a.cWidth + "px",
658
+ height: w.value + "px"
659
+ })), s = () => {
660
+ y(a, a.annotationsCanvas, u.value, w.value);
661
+ }, T = (L, E) => {
662
+ l(L, E, a.pointerMode);
663
+ }, p = (L, E, A, $) => v(L, E, A, $, a), O = () => {
664
+ r(a.pointerMode, f);
665
+ }, S = () => {
666
+ e() && se(() => s());
667
+ }, b = async (L) => {
668
+ try {
669
+ await i(L, a.activeViewer, f);
670
+ } catch (E) {
671
+ console.error("Error creating layer:", E);
672
+ }
673
+ };
674
+ return ne(
675
+ () => a.activeViewer,
676
+ async (L) => {
677
+ try {
678
+ await h(L, f), await g(
679
+ a.start,
680
+ a.start + a.duration,
681
+ a,
682
+ L,
683
+ f
684
+ );
685
+ } catch (E) {
686
+ console.error("Error loading annotations for new viewer:", E);
687
+ }
688
+ }
689
+ ), oe(async () => {
690
+ console.log("TSAnnotationCanvas mounted with props:", {
691
+ constants: a.constants,
692
+ annotationsCanvas: a.annotationsCanvas,
693
+ viewerActiveTool: a.viewerActiveTool
694
+ });
695
+ try {
696
+ await h(a.activeViewer, f), await g(
697
+ a.start,
698
+ a.start + a.duration,
699
+ a,
700
+ a.activeViewer,
701
+ f
702
+ );
703
+ } catch (L) {
704
+ console.error("Error initializing annotations:", L);
705
+ }
706
+ }), o({
707
+ render: s,
708
+ resetFocusedAnnotation: d,
709
+ findNextAnnotation: m,
710
+ findPreviousAnnotation: F,
711
+ checkAnnotationRange: (L, E) => g(L, E, a, a.activeViewer, f),
712
+ selectFocusedAnn: S,
713
+ createAnnotationLayer: b,
714
+ onMouseDown: T,
715
+ onMouseMove: p,
716
+ onMouseUp: O
717
+ }), (L, E) => (ie(), ae("canvas", {
718
+ id: "annLabelArea",
719
+ ref_key: "annLabelArea",
720
+ ref: u,
721
+ class: "timeseries-annotation-canvas",
722
+ width: K(Z)(t.cWidth, t.pixelRatio, 0),
723
+ height: K(Z)(w.value, t.pixelRatio, 0),
724
+ style: re(n.value)
725
+ }, null, 12, Oe));
726
+ }
727
+ }, Ie = /* @__PURE__ */ ue(pe, [["__scopeId", "data-v-41f7f1c2"]]);
728
+ export {
729
+ Ie as default
730
+ };