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