tsviewer 1.0.26 → 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.
@@ -0,0 +1,902 @@
1
+ import { ref as p, computed as b, defineAsyncComponent as x, watch as oe, nextTick as $, onMounted as On, onBeforeUnmount as bn, createElementBlock as ve, openBlock as re, normalizeClass as fe, createVNode as G, createElementVNode as Q, createBlock as En, createCommentVNode as Ln, unref as q, Fragment as Nn, renderList as Dn, toDisplayString as Oe } from "vue";
2
+ import { defineStore as Pn, storeToRefs as Mn } from "pinia";
3
+ function y(n) {
4
+ return n != null && typeof n == "object" && n["@@functional/placeholder"] === !0;
5
+ }
6
+ function C(n) {
7
+ return function e(o) {
8
+ return arguments.length === 0 || y(o) ? e : n.apply(this, arguments);
9
+ };
10
+ }
11
+ function _(n) {
12
+ return function e(o, a) {
13
+ switch (arguments.length) {
14
+ case 0:
15
+ return e;
16
+ case 1:
17
+ return y(o) ? e : C(function(u) {
18
+ return n(o, u);
19
+ });
20
+ default:
21
+ return y(o) && y(a) ? e : y(o) ? C(function(u) {
22
+ return n(u, a);
23
+ }) : y(a) ? C(function(u) {
24
+ return n(o, u);
25
+ }) : n(o, a);
26
+ }
27
+ };
28
+ }
29
+ function Ve(n) {
30
+ return function e(o, a, u) {
31
+ switch (arguments.length) {
32
+ case 0:
33
+ return e;
34
+ case 1:
35
+ return y(o) ? e : _(function(d, h) {
36
+ return n(o, d, h);
37
+ });
38
+ case 2:
39
+ return y(o) && y(a) ? e : y(o) ? _(function(d, h) {
40
+ return n(d, a, h);
41
+ }) : y(a) ? _(function(d, h) {
42
+ return n(o, d, h);
43
+ }) : C(function(d) {
44
+ return n(o, a, d);
45
+ });
46
+ default:
47
+ return y(o) && y(a) && y(u) ? e : y(o) && y(a) ? _(function(d, h) {
48
+ return n(d, h, u);
49
+ }) : y(o) && y(u) ? _(function(d, h) {
50
+ return n(d, a, h);
51
+ }) : y(a) && y(u) ? _(function(d, h) {
52
+ return n(o, d, h);
53
+ }) : y(o) ? C(function(d) {
54
+ return n(d, a, u);
55
+ }) : y(a) ? C(function(d) {
56
+ return n(o, d, u);
57
+ }) : y(u) ? C(function(d) {
58
+ return n(o, a, d);
59
+ }) : n(o, a, u);
60
+ }
61
+ };
62
+ }
63
+ const je = Array.isArray || function(e) {
64
+ return e != null && e.length >= 0 && Object.prototype.toString.call(e) === "[object Array]";
65
+ };
66
+ function Rn(n) {
67
+ return n != null && typeof n["@@transducer/step"] == "function";
68
+ }
69
+ function Un(n, e, o) {
70
+ return function() {
71
+ if (arguments.length === 0)
72
+ return o();
73
+ var a = arguments[arguments.length - 1];
74
+ if (!je(a)) {
75
+ for (var u = 0; u < n.length; ) {
76
+ if (typeof a[n[u]] == "function")
77
+ return a[n[u]].apply(a, Array.prototype.slice.call(arguments, 0, -1));
78
+ u += 1;
79
+ }
80
+ if (Rn(a)) {
81
+ var d = e.apply(null, Array.prototype.slice.call(arguments, 0, -1));
82
+ return d(a);
83
+ }
84
+ }
85
+ return o.apply(this, arguments);
86
+ };
87
+ }
88
+ function Vn(n) {
89
+ return n && n["@@transducer/reduced"] ? n : {
90
+ "@@transducer/value": n,
91
+ "@@transducer/reduced": !0
92
+ };
93
+ }
94
+ const jn = {
95
+ init: function() {
96
+ return this.xf["@@transducer/init"]();
97
+ },
98
+ result: function(n) {
99
+ return this.xf["@@transducer/result"](n);
100
+ }
101
+ };
102
+ function ke(n) {
103
+ return Object.prototype.toString.call(n) === "[object String]";
104
+ }
105
+ function ae(n, e) {
106
+ return Object.prototype.hasOwnProperty.call(e, n);
107
+ }
108
+ var be = Object.prototype.toString, Fe = /* @__PURE__ */ function() {
109
+ return be.call(arguments) === "[object Arguments]" ? function(e) {
110
+ return be.call(e) === "[object Arguments]";
111
+ } : function(e) {
112
+ return ae("callee", e);
113
+ };
114
+ }(), kn = !/* @__PURE__ */ {
115
+ toString: null
116
+ }.propertyIsEnumerable("toString"), Ee = ["constructor", "valueOf", "isPrototypeOf", "toString", "propertyIsEnumerable", "hasOwnProperty", "toLocaleString"], Le = /* @__PURE__ */ function() {
117
+ return arguments.propertyIsEnumerable("length");
118
+ }(), Fn = function(e, o) {
119
+ for (var a = 0; a < e.length; ) {
120
+ if (e[a] === o)
121
+ return !0;
122
+ a += 1;
123
+ }
124
+ return !1;
125
+ }, Ne = /* @__PURE__ */ C(typeof Object.keys == "function" && !Le ? function(e) {
126
+ return Object(e) !== e ? [] : Object.keys(e);
127
+ } : function(e) {
128
+ if (Object(e) !== e)
129
+ return [];
130
+ var o, a, u = [], d = Le && Fe(e);
131
+ for (o in e)
132
+ ae(o, e) && (!d || o !== "length") && (u[u.length] = o);
133
+ if (kn)
134
+ for (a = Ee.length - 1; a >= 0; )
135
+ o = Ee[a], ae(o, e) && !Fn(u, o) && (u[u.length] = o), a -= 1;
136
+ return u;
137
+ });
138
+ const Wn = Number.isInteger || function(e) {
139
+ return e << 0 === e;
140
+ };
141
+ var xn = /* @__PURE__ */ _(function(e, o) {
142
+ var a = e < 0 ? o.length + e : e;
143
+ return ke(o) ? o.charAt(a) : o[a];
144
+ }), We = /* @__PURE__ */ _(function(e, o) {
145
+ if (o != null)
146
+ return Wn(e) ? xn(e, o) : o[e];
147
+ }), De = /* @__PURE__ */ C(function(e) {
148
+ return e === null ? "Null" : e === void 0 ? "Undefined" : Object.prototype.toString.call(e).slice(8, -1);
149
+ });
150
+ function Pe(n) {
151
+ for (var e = [], o; !(o = n.next()).done; )
152
+ e.push(o.value);
153
+ return e;
154
+ }
155
+ function Me(n, e, o) {
156
+ for (var a = 0, u = o.length; a < u; ) {
157
+ if (n(e, o[a]))
158
+ return !0;
159
+ a += 1;
160
+ }
161
+ return !1;
162
+ }
163
+ function qn(n) {
164
+ var e = String(n).match(/^function (\w*)/);
165
+ return e == null ? "" : e[1];
166
+ }
167
+ function Bn(n, e) {
168
+ return n === e ? n !== 0 || 1 / n === 1 / e : n !== n && e !== e;
169
+ }
170
+ const pe = typeof Object.is == "function" ? Object.is : Bn;
171
+ function Re(n, e, o, a) {
172
+ var u = Pe(n), d = Pe(e);
173
+ function h(c, O) {
174
+ return ge(c, O, o.slice(), a.slice());
175
+ }
176
+ return !Me(function(c, O) {
177
+ return !Me(h, O, c);
178
+ }, d, u);
179
+ }
180
+ function ge(n, e, o, a) {
181
+ if (pe(n, e))
182
+ return !0;
183
+ var u = De(n);
184
+ if (u !== De(e))
185
+ return !1;
186
+ if (typeof n["fantasy-land/equals"] == "function" || typeof e["fantasy-land/equals"] == "function")
187
+ return typeof n["fantasy-land/equals"] == "function" && n["fantasy-land/equals"](e) && typeof e["fantasy-land/equals"] == "function" && e["fantasy-land/equals"](n);
188
+ if (typeof n.equals == "function" || typeof e.equals == "function")
189
+ return typeof n.equals == "function" && n.equals(e) && typeof e.equals == "function" && e.equals(n);
190
+ switch (u) {
191
+ case "Arguments":
192
+ case "Array":
193
+ case "Object":
194
+ if (typeof n.constructor == "function" && qn(n.constructor) === "Promise")
195
+ return n === e;
196
+ break;
197
+ case "Boolean":
198
+ case "Number":
199
+ case "String":
200
+ if (!(typeof n == typeof e && pe(n.valueOf(), e.valueOf())))
201
+ return !1;
202
+ break;
203
+ case "Date":
204
+ if (!pe(n.valueOf(), e.valueOf()))
205
+ return !1;
206
+ break;
207
+ case "Error":
208
+ return n.name === e.name && n.message === e.message;
209
+ case "RegExp":
210
+ if (!(n.source === e.source && n.global === e.global && n.ignoreCase === e.ignoreCase && n.multiline === e.multiline && n.sticky === e.sticky && n.unicode === e.unicode))
211
+ return !1;
212
+ break;
213
+ }
214
+ for (var d = o.length - 1; d >= 0; ) {
215
+ if (o[d] === n)
216
+ return a[d] === e;
217
+ d -= 1;
218
+ }
219
+ switch (u) {
220
+ case "Map":
221
+ return n.size !== e.size ? !1 : Re(n.entries(), e.entries(), o.concat([n]), a.concat([e]));
222
+ case "Set":
223
+ return n.size !== e.size ? !1 : Re(n.values(), e.values(), o.concat([n]), a.concat([e]));
224
+ case "Arguments":
225
+ case "Array":
226
+ case "Object":
227
+ case "Boolean":
228
+ case "Number":
229
+ case "String":
230
+ case "Date":
231
+ case "Error":
232
+ case "RegExp":
233
+ case "Int8Array":
234
+ case "Uint8Array":
235
+ case "Uint8ClampedArray":
236
+ case "Int16Array":
237
+ case "Uint16Array":
238
+ case "Int32Array":
239
+ case "Uint32Array":
240
+ case "Float32Array":
241
+ case "Float64Array":
242
+ case "ArrayBuffer":
243
+ break;
244
+ default:
245
+ return !1;
246
+ }
247
+ var h = Ne(n);
248
+ if (h.length !== Ne(e).length)
249
+ return !1;
250
+ var c = o.concat([n]), O = a.concat([e]);
251
+ for (d = h.length - 1; d >= 0; ) {
252
+ var m = h[d];
253
+ if (!(ae(m, e) && ge(e[m], n[m], c, O)))
254
+ return !1;
255
+ d -= 1;
256
+ }
257
+ return !0;
258
+ }
259
+ var xe = /* @__PURE__ */ _(function(e, o) {
260
+ return ge(e, o, [], []);
261
+ });
262
+ function zn(n) {
263
+ return Object.prototype.toString.call(n) === "[object Object]";
264
+ }
265
+ var $n = /* @__PURE__ */ _(function(e, o) {
266
+ return o == null || o !== o ? e : o;
267
+ });
268
+ function Gn(n) {
269
+ var e = Object.prototype.toString.call(n);
270
+ return e === "[object Uint8ClampedArray]" || e === "[object Int8Array]" || e === "[object Uint8Array]" || e === "[object Int16Array]" || e === "[object Uint16Array]" || e === "[object Int32Array]" || e === "[object Uint32Array]" || e === "[object Float32Array]" || e === "[object Float64Array]" || e === "[object BigInt64Array]" || e === "[object BigUint64Array]";
271
+ }
272
+ var Xn = /* @__PURE__ */ C(function(e) {
273
+ return e != null && typeof e["fantasy-land/empty"] == "function" ? e["fantasy-land/empty"]() : e != null && e.constructor != null && typeof e.constructor["fantasy-land/empty"] == "function" ? e.constructor["fantasy-land/empty"]() : e != null && typeof e.empty == "function" ? e.empty() : e != null && e.constructor != null && typeof e.constructor.empty == "function" ? e.constructor.empty() : je(e) ? [] : ke(e) ? "" : zn(e) ? {} : Fe(e) ? /* @__PURE__ */ function() {
274
+ return arguments;
275
+ }() : Gn(e) ? e.constructor.from("") : void 0;
276
+ }), Zn = /* @__PURE__ */ function() {
277
+ function n(e, o) {
278
+ this.xf = o, this.f = e, this.idx = -1, this.found = !1;
279
+ }
280
+ return n.prototype["@@transducer/init"] = jn.init, n.prototype["@@transducer/result"] = function(e) {
281
+ return this.found || (e = this.xf["@@transducer/step"](e, -1)), this.xf["@@transducer/result"](e);
282
+ }, n.prototype["@@transducer/step"] = function(e, o) {
283
+ return this.idx += 1, this.f(o) && (this.found = !0, e = Vn(this.xf["@@transducer/step"](e, this.idx))), e;
284
+ }, n;
285
+ }(), Hn = /* @__PURE__ */ _(function(e, o) {
286
+ return new Zn(e, o);
287
+ }), D = /* @__PURE__ */ _(
288
+ /* @__PURE__ */ Un([], Hn, function(e, o) {
289
+ for (var a = 0, u = o.length; a < u; ) {
290
+ if (e(o[a]))
291
+ return a;
292
+ a += 1;
293
+ }
294
+ return -1;
295
+ })
296
+ ), Kn = /* @__PURE__ */ C(function(e) {
297
+ return e != null && xe(e, Xn(e));
298
+ }), P = /* @__PURE__ */ Ve(function(e, o, a) {
299
+ return xe(o, We(e, a));
300
+ }), Ue = /* @__PURE__ */ Ve(function(e, o, a) {
301
+ return $n(e, We(o, a));
302
+ });
303
+ const qe = "https://api.pennsieve.net", Be = "https://api2.pennsieve.net", ze = "wss://api.pennsieve.net/streaming/ts/query", $e = "https://api.pennsieve.net/streaming", Yn = {
304
+ apiUrl: qe,
305
+ api2Url: Be,
306
+ timeSeriesUrl: ze,
307
+ timeSeriesApi: $e
308
+ }, Jn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
309
+ __proto__: null,
310
+ api2Url: Be,
311
+ apiUrl: qe,
312
+ default: Yn,
313
+ timeSeriesApi: $e,
314
+ timeSeriesUrl: ze
315
+ }, Symbol.toStringTag, { value: "Module" })), Qn = Pn("tsviewer", () => {
316
+ const n = Jn, e = p([]), o = p("NOT_MONTAGED"), a = p({}), u = p([]), d = p(null), h = p(null);
317
+ p({});
318
+ const c = p([]), O = p({}), m = p({}), M = p("POINTER"), E = b(() => (r) => u.value.find((i) => i.name === r)), X = b(() => e.value.filter((r) => r.selected)), ie = b(() => () => {
319
+ const r = c.value.find((i) => i.selected);
320
+ return r || (console.warn("No active layer found, available layers:", c.value), c.value.length > 0 ? c.value[0] : null);
321
+ }), se = () => {
322
+ let r = !1;
323
+ return c.value.forEach((i, v) => {
324
+ !i.id && i.id !== 0 && (console.error(`Layer at index ${v} missing ID:`, i), r = !0), i.annotations || (console.warn(`Layer at index ${v} missing annotations array:`, i), i.annotations = []);
325
+ }), r && console.error("Annotation layer validation failed. Layers:", c.value), !r;
326
+ }, le = b(() => (r) => c.value.flatMap((v) => v.annotations || []).find((v) => v.id === r)), ue = (r) => {
327
+ e.value = r;
328
+ }, he = (r) => {
329
+ o.value = r;
330
+ }, R = (r) => {
331
+ a.value = r;
332
+ }, L = (r) => {
333
+ u.value = r;
334
+ }, Z = (r) => {
335
+ d.value = r;
336
+ }, g = (r) => {
337
+ h.value = r;
338
+ }, ee = (r) => {
339
+ const i = r.map((v) => (!v.id && v.id !== 0 && (console.warn("Annotation layer missing ID:", v), v.id = Math.random().toString(36).substr(2, 9)), v.annotations || (v.annotations = []), v.name || (v.name = `Layer ${v.id}`), v));
340
+ c.value = i, console.log("Set annotations with validated structure:", i);
341
+ }, ce = (r) => {
342
+ if (!r && r !== 0) {
343
+ console.error("setActiveAnnotationLayer called with invalid layerId:", r);
344
+ return;
345
+ }
346
+ O.value = r, c.value.forEach((v) => v.selected = !1);
347
+ const i = D(P("id", r), c.value);
348
+ i >= 0 ? (c.value[i].selected = !0, console.log("Successfully set active layer:", c.value[i])) : console.error("Layer with ID not found:", r, "Available layers:", c.value);
349
+ }, S = (r) => {
350
+ if (c.value.forEach(
351
+ (i) => {
352
+ var v;
353
+ return (v = i.annotations) == null ? void 0 : v.forEach((T) => T.selected = !1);
354
+ }
355
+ ), r.id) {
356
+ const i = D(P("id", r.layer_id), c.value);
357
+ if (i >= 0) {
358
+ const v = D(P("id", r.id), c.value[i].annotations);
359
+ v >= 0 && (c.value[i].annotations[v].selected = !0);
360
+ }
361
+ }
362
+ m.value = r;
363
+ }, N = (r) => {
364
+ M.value = r;
365
+ }, k = (r) => {
366
+ if (!r.id && r.id !== 0) {
367
+ console.error("Cannot create layer without ID:", r);
368
+ return;
369
+ }
370
+ const i = {
371
+ id: r.id,
372
+ name: r.name || `Layer ${r.id}`,
373
+ description: r.description || "",
374
+ visible: r.visible !== void 0 ? r.visible : !0,
375
+ selected: r.selected || !1,
376
+ annotations: r.annotations || [],
377
+ color: r.color,
378
+ hexColor: r.hexColor,
379
+ bkColor: r.bkColor,
380
+ selColor: r.selColor,
381
+ userId: r.userId,
382
+ ...r
383
+ // Spread any additional properties
384
+ };
385
+ c.value.push(i), console.log("Created layer with validated structure:", i);
386
+ }, F = (r) => {
387
+ const i = D(P("id", r.id), c.value);
388
+ if (i >= 0) {
389
+ const v = Object.assign(c.value[i], r);
390
+ c.value[i] = v;
391
+ }
392
+ }, A = (r) => {
393
+ const i = D(P("id", r.id), c.value);
394
+ i >= 0 && c.value.splice(i, 1);
395
+ }, I = (r) => {
396
+ const i = D(P("id", r.layer_id), c.value);
397
+ i >= 0 && (c.value[i].annotations || (c.value[i].annotations = []), c.value[i].annotations.push(r), S(r));
398
+ }, W = (r) => {
399
+ const i = D(P("id", r.layer_id), c.value);
400
+ if (i >= 0) {
401
+ const v = c.value[i].annotations, T = D(P("id", r.id), v);
402
+ T >= 0 && (v[T] = r);
403
+ }
404
+ }, B = (r) => {
405
+ const i = D(P("id", r.layer_id), c.value);
406
+ if (i >= 0) {
407
+ const v = c.value[i].annotations, T = D(P("id", r.id), v);
408
+ T >= 0 && v.splice(T, 1);
409
+ }
410
+ }, U = (r, i, v) => {
411
+ const T = e.value.find((te) => te.id === r);
412
+ T && (T[i] = v);
413
+ };
414
+ return {
415
+ // State
416
+ viewerChannels: e,
417
+ viewerMontageScheme: o,
418
+ customMontageMap: a,
419
+ workspaceMontages: u,
420
+ viewerErrors: d,
421
+ needsRerender: h,
422
+ viewerAnnotations: c,
423
+ activeAnnotationLayer: O,
424
+ activeAnnotation: m,
425
+ viewerActiveTool: M,
426
+ config: n,
427
+ // Getters
428
+ getMontageMessageByName: E,
429
+ viewerSelectedChannels: X,
430
+ getViewerActiveLayer: ie,
431
+ getAnnotationById: le,
432
+ // Actions
433
+ setChannels: ue,
434
+ setViewerMontageScheme: he,
435
+ setCustomMontageMap: R,
436
+ setWorkspaceMontages: L,
437
+ setViewerErrors: Z,
438
+ setAnnotations: ee,
439
+ setActiveAnnotationLayer: ce,
440
+ setActiveAnnotation: S,
441
+ setActiveTool: N,
442
+ createLayer: k,
443
+ updateLayer: F,
444
+ deleteLayer: A,
445
+ createAnnotation: I,
446
+ updateAnnotation: W,
447
+ deleteAnnotation: B,
448
+ updateChannelProperty: U,
449
+ updateChannelVisibility: (r, i) => {
450
+ U(r, "visible", i);
451
+ },
452
+ updateChannelSelection: (r, i) => {
453
+ U(r, "selected", i);
454
+ },
455
+ updateChannelFilter: (r, i) => {
456
+ U(r, "filter", i);
457
+ },
458
+ validateAnnotationLayers: se,
459
+ resetViewer: () => {
460
+ e.value = [], o.value = "NOT_MONTAGED", a.value = {}, u.value = [], d.value = null, c.value = [], O.value = {}, m.value = {}, M.value = "POINTER";
461
+ },
462
+ triggerRerender: (r) => {
463
+ g({
464
+ timestamp: Date.now(),
465
+ cause: r
466
+ });
467
+ },
468
+ resetRerenderTrigger: () => {
469
+ h.value = null;
470
+ }
471
+ };
472
+ }), et = (n, e) => {
473
+ const o = n.__vccOpts || n;
474
+ for (const [a, u] of e)
475
+ o[a] = u;
476
+ return o;
477
+ }, nt = { id: "channelCanvas" }, tt = ["data-id"], ot = ["hidden"], rt = ["hidden"], at = {
478
+ __name: "TSViewer",
479
+ props: {
480
+ pkg: {
481
+ type: Object,
482
+ default: () => {
483
+ }
484
+ },
485
+ isPreview: {
486
+ type: Boolean,
487
+ default: !1
488
+ },
489
+ sidePanelOpen: {
490
+ type: Boolean,
491
+ default: !1
492
+ }
493
+ },
494
+ setup(n, { expose: e }) {
495
+ const o = x(() => import("./TSScrubber-BZo4SyGm.mjs")), a = x(() => import("./TSViewerCanvas-CeGKq-zQ.mjs").then((t) => t.T)), u = x(() => import("./TSViewerToolbar-CQ4uNXil.mjs")), d = x(() => import("./TSFilterModal-DjKgP7Y2.mjs")), h = x(() => import("./TSAnnotationModal-BKwEWORY.mjs")), c = x(() => import("./TsAnnotationDeleteDialog-CoPkyAmW.mjs")), O = x(() => import("./TSViewerLayerWindow-laXtlKCp.mjs")), m = {
496
+ TIMEUNIT: "microSeconds",
497
+ // Basis for time
498
+ XOFFSET: 0,
499
+ // X-offset of graph in canvas
500
+ XGRIDSPACING: 1e6,
501
+ // Time in microseconds between vertical lines
502
+ NRPXPERLABEL: 150,
503
+ // Number of pixels per label on x-axis
504
+ USEREALTIME: !0,
505
+ // If true than interpret timepoints as UTC microseconds.
506
+ DEFAULTDPI: 96,
507
+ // Default pixels per inch
508
+ ANNOTATIONLABELHEIGHT: 20,
509
+ // Height of annotation label
510
+ ROUNDDATAPIXELS: !1,
511
+ // If true, canvas point will be rounded to integer pixels for faster render (faster)
512
+ MINMAXPOLYGON: !0,
513
+ // If true, then polygon is rendered thru minMax values, otherwise vertical lines (faster)
514
+ PAGESIZEDIVIDER: 0.5,
515
+ // Number of pages that span the current canvas.
516
+ PREFETCHPAGES: 5,
517
+ // Number of pages to read ahead of view.
518
+ LIMITANNFETCH: 500,
519
+ // Maximum number of annotations that are fetched per request
520
+ USEMEDIAN: !1,
521
+ // Use Median instead of mean for centering channels
522
+ CURSOROFFSET: 5,
523
+ // Offset of cursor canvas
524
+ SEGMENTSPAN: 12096e8,
525
+ // One week of gap-data is returned per request.
526
+ MAXRECURSION: 20,
527
+ // Maximum recursion depth of gap-data requests (max 2 years)
528
+ MAXDURATION: 6e8,
529
+ // Maximum duration window (5min)
530
+ INITDURATION: 15e6
531
+ // Initial duration window (15sec)
532
+ }, M = n, E = Qn(), { viewerChannels: X, needsRerender: ie } = Mn(E), {
533
+ addAnnotation: se,
534
+ updateAnnotation: le,
535
+ removeAnnotation: ue,
536
+ getChannelId: he
537
+ } = useTsAnnotation(), R = p(null), L = p(null), Z = p(null), g = p(null), ee = p(null), ce = p(null), S = p(null), N = p(null), k = p(0), F = p(0), A = p(0), I = p(0), W = p(0), B = p(0), U = p(0), V = p(1), H = p(1 / 10), j = p(!1), ne = p(!1), de = p(null), K = p(!1), r = b(() => M.pkg), i = b(() => M.sidePanelOpen), v = b(() => E.config), T = b(() => X.value.map((t) => ({
538
+ ...t,
539
+ selected: !!t.selected
540
+ }))), te = b(() => T.value.filter((t) => t.visible)), ye = b(() => {
541
+ let t = !1;
542
+ return B.value / me.value < 30 && (t = !0), t;
543
+ }), me = b(() => te.value.length), Y = async () => {
544
+ if (console.log("onresize..."), !R.value)
545
+ return;
546
+ const t = document.getElementById("ts_viewer");
547
+ if (!t)
548
+ return;
549
+ const l = window.getComputedStyle(t, null), s = parseInt(l.getPropertyValue("height")), f = M.isPreview ? 0 : 100;
550
+ k.value = s - f, await $(), F.value = R.value.offsetWidth;
551
+ const w = Z.value;
552
+ w && (U.value = w.clientWidth, W.value = F.value - w.clientWidth - 16, B.value = k.value - 40);
553
+ };
554
+ oe(() => r.value, async (t, l) => {
555
+ var s, f, w;
556
+ (s = L.value) != null && s.resetComponentState && L.value.resetComponentState(), t && t.channels && t.channels.length > 0 && Te(), _e(), await $(), (f = L.value) != null && f.initSegmentSpans && L.value.initSegmentSpans(), (w = L.value) != null && w.getAnnotations && L.value.getAnnotations();
557
+ }, { immediate: !1, deep: !0 }), oe(i, () => {
558
+ R.value && Y();
559
+ }, { immediate: !1 }), oe(me, (t, l) => {
560
+ l !== void 0 && t !== l && (console.log(`Number of visible channels changed from ${l} to ${t}`), setTimeout(() => {
561
+ var s;
562
+ Y(), (s = g.value) != null && s.renderAll && g.value.renderAll();
563
+ }, 20));
564
+ });
565
+ const Ae = (t) => {
566
+ store.dispatch("viewerModule/setActiveAnnotation", t).then(() => {
567
+ g.value.renderAnnotationCanvas(), j.value = !0;
568
+ });
569
+ };
570
+ oe(ie, (t) => {
571
+ t && (console.log(`TSViewer: Re-rendering due to: ${t.cause} (${t.timestamp})`), $(() => {
572
+ var l;
573
+ t.cause === "channel-visibility" ? setTimeout(() => {
574
+ var s;
575
+ Y(), (s = g.value) != null && s.renderAll && g.value.renderAll();
576
+ }, 10) : (l = g.value) != null && l.renderAll && g.value.renderAll();
577
+ }), E.resetRerenderTrigger(null));
578
+ }, { deep: !0 });
579
+ const Ge = (t) => {
580
+ Ae(t);
581
+ }, Xe = async (t) => {
582
+ if (console.log("📍 TSViewer: onCreateUpdateAnnotation received:", t), !t || Object.keys(t).length === 0) {
583
+ console.error("🚨 TSViewer: Received empty annotation!");
584
+ return;
585
+ }
586
+ if (!t.layer_id) {
587
+ console.error("🚨 TSViewer: annotation.layer_id is missing!", t);
588
+ return;
589
+ }
590
+ j.value = !1;
591
+ try {
592
+ t.id ? (console.log("📍 TSViewer: Updating annotation via composable"), await le(t), Ze()) : (console.log("📍 TSViewer: Creating annotation via composable"), await se(t), Qe()), console.log("📍 TSViewer: Annotation operation completed successfully");
593
+ } catch (l) {
594
+ console.error("📍 TSViewer: Error creating/updating annotation:", l), j.value = !0;
595
+ }
596
+ }, Ze = () => {
597
+ g.value.renderAnnotationCanvas();
598
+ }, He = (t) => {
599
+ de.value = t, K.value = !0;
600
+ }, Ke = async (t) => {
601
+ K.value = !1;
602
+ try {
603
+ await ue(t), Ye(), console.log("📍 TSViewer: Annotation deleted successfully");
604
+ } catch (l) {
605
+ console.error("📍 TSViewer: Error deleting annotation:", l);
606
+ }
607
+ }, Ye = () => {
608
+ g.value.renderAnnotationCanvas();
609
+ }, Je = (t, l, s, f, w, J) => {
610
+ if (console.log("📍 TSViewer: onAddAnnotation called with:", {
611
+ startTime: t,
612
+ duration: l,
613
+ allChannels: s,
614
+ label: f,
615
+ description: w,
616
+ layer: J
617
+ }), !J || !J.id) {
618
+ console.error("Invalid layer provided to onAddAnnotation:", J);
619
+ return;
620
+ }
621
+ const Tn = E.viewerSelectedChannels || [], _n = s ? [] : Tn.map((Cn) => Cn.id), Ce = {
622
+ id: null,
623
+ label: f || "Event",
624
+ description: w || "",
625
+ start: Math.floor(t),
626
+ end: Math.floor(t + l),
627
+ duration: Math.floor(l),
628
+ channelIds: _n,
629
+ allChannels: s,
630
+ layer_id: J.id,
631
+ selected: !0,
632
+ userId: null
633
+ };
634
+ console.log("📍 TSViewer: Created annotation object:", Ce), E.setActiveAnnotation(Ce), console.log("📍 TSViewer: Store now contains:", E.activeAnnotation), j.value = !0, console.log("📍 TSViewer: Modal opened with annotation data");
635
+ }, Qe = () => {
636
+ g.value.renderAnnotationCanvas();
637
+ }, en = (t) => {
638
+ g.value.createAnnotationLayer(t);
639
+ }, we = () => {
640
+ ne.value = !1;
641
+ }, nn = () => {
642
+ g.value.resetFocusedAnnotation(), g.value.renderAnnotationCanvas(), j.value = !1;
643
+ }, tn = () => {
644
+ filterWindowOpen.value = !1;
645
+ }, on = (t) => {
646
+ t.stopPropagation(), t.preventDefault();
647
+ const l = t.detail.sourceEvent.metaKey;
648
+ Se({ channelId: t.currentTarget.dataset.id, append: l }), g.value.renderAll();
649
+ }, rn = () => {
650
+ A.value = g.value.getNextAnnotation();
651
+ }, an = () => {
652
+ A.value = g.value.getPreviousAnnotation();
653
+ }, sn = (t) => {
654
+ Ie(t * 1e6);
655
+ }, ln = () => {
656
+ V.value = V.value * 1.25;
657
+ }, un = () => {
658
+ V.value = V.value * 0.8;
659
+ }, cn = () => {
660
+ L.value.getAnnotations();
661
+ }, dn = () => {
662
+ }, vn = () => {
663
+ console.log("Page forward triggered from toolbar");
664
+ const t = Math.max(
665
+ A.value - 3 / 4 * I.value,
666
+ S.value
667
+ );
668
+ z(t), $(() => {
669
+ var l;
670
+ (l = g.value) == null || l.renderAll();
671
+ });
672
+ }, fn = () => {
673
+ console.log("Page forward triggered from toolbar");
674
+ const t = Math.min(
675
+ A.value + 3 / 4 * I.value,
676
+ N.value - I.value
677
+ );
678
+ console.log(`Moving from ${A.value} to ${t}`), z(t), $(() => {
679
+ var l, s;
680
+ (l = g.value) != null && l.invalidate && g.value.invalidate(), (s = g.value) != null && s.renderAll && g.value.renderAll();
681
+ });
682
+ }, pn = (t) => {
683
+ let l = g.value.rsPeriod;
684
+ z(t.annotation.start - (H.value * W.value - m.CURSOROFFSET) * l), $(() => {
685
+ var s;
686
+ (s = g.value) == null || s.renderAll();
687
+ });
688
+ }, Se = (t) => {
689
+ const l = X.value.map((s) => {
690
+ const f = s.selected;
691
+ return t.append === !1 && (s.selected = !1), t.channelId === s.id && (s.selected = !f), s;
692
+ });
693
+ E.setChannels(l);
694
+ }, gn = (t, l) => {
695
+ const s = X.value.map((f) => (l === !1 && (f.selected = !1), f.id in t && (f.selected = !0), f));
696
+ E.setChannels(s);
697
+ }, z = (t) => {
698
+ A.value = t;
699
+ }, hn = (t) => {
700
+ H.value = t;
701
+ }, yn = (t) => {
702
+ V.value = t;
703
+ }, Ie = (t) => {
704
+ t > m.MAXDURATION ? I.value = m.MAXDURATION : I.value = t;
705
+ }, mn = (t, l, s) => (m.DEFAULTDPI * window.devicePixelRatio / (l * s) / 25.4).toFixed(1) + " " + t.unit + "/mm", Te = () => {
706
+ var l;
707
+ const t = (l = r.value) == null ? void 0 : l.channels;
708
+ if (console.log("🔄 initTimeRange called with channels:", (t == null ? void 0 : t.length) || 0), t && t.length > 0) {
709
+ S.value = t[0].content.start, N.value = t[0].content.end;
710
+ for (let f = 1; f < t.length; f++)
711
+ t[f].content.start < S.value && (S.value = t[f].content.start), t[f].content.end > N.value && (N.value = t[f].content.end);
712
+ const s = A.value;
713
+ A.value = S.value, console.log("📅 Time range initialized:", {
714
+ ts_start: S.value,
715
+ ts_end: N.value,
716
+ oldStart: s,
717
+ newStart: A.value,
718
+ duration: I.value,
719
+ startDate: new Date(S.value / 1e3).toISOString(),
720
+ endDate: new Date(N.value / 1e3).toISOString()
721
+ });
722
+ } else
723
+ console.warn("⚠️ initTimeRange: No channels found in activeViewer");
724
+ }, An = () => {
725
+ Te();
726
+ }, wn = (t) => {
727
+ ne.value = !0;
728
+ }, Sn = (t) => {
729
+ const l = Ue([], "channels", t), s = Ue("", "filter", t), f = ee.value;
730
+ f.onChannels = l, Kn(s) ? (f.input0 = NaN, f.input1 = NaN, f.selectedFilter = null, f.selectedNotch = null) : (f.input0 = s.input0, f.input1 = s.input1), filterWindowOpen.value = !0;
731
+ }, In = (t) => {
732
+ g.value.setFilters(t);
733
+ }, _e = () => {
734
+ var t, l;
735
+ (t = g.value) == null || t.initViewerCanvas(), (l = g.value) == null || l.renderAll();
736
+ };
737
+ return On(() => {
738
+ An();
739
+ const t = document.getElementById("ts_viewer");
740
+ if (!t) {
741
+ console.warn("ts_viewer element not found");
742
+ return;
743
+ }
744
+ var l = window.getComputedStyle(t, null);
745
+ const s = parseInt(l.getPropertyValue("height")), f = M.isPreview ? 0 : 100;
746
+ k.value = s - f, R.value && (F.value = R.value.offsetWidth), window.addEventListener("resize", Y);
747
+ const w = Z.value;
748
+ w && (U.value = w.clientWidth, W.value = F.value - w.clientWidth - 5 - 10, B.value = k.value - 88), I.value = m.INITDURATION, _e();
749
+ }), bn(() => {
750
+ window.removeEventListener("resize", Y);
751
+ }), e({
752
+ openEditAnnotationDialog: Ae,
753
+ confirmDeleteAnnotation: He,
754
+ selectAnnotation: pn,
755
+ selectChannel: Se,
756
+ selectChannels: gn,
757
+ openLayerWindow: wn,
758
+ openFilterWindow: Sn,
759
+ setTimeseriesFilters: In
760
+ }), (t, l) => (re(), ve("div", {
761
+ id: "ts_viewer",
762
+ ref_key: "ts_viewer",
763
+ ref: R,
764
+ class: fe([n.isPreview ? "timeseries-viewer preview" : "timeseries-viewer"])
765
+ }, [
766
+ G(q(o), {
767
+ ref_key: "scrubber",
768
+ ref: L,
769
+ ts_start: S.value,
770
+ ts_end: N.value,
771
+ "c-width": W.value,
772
+ "label-width": U.value,
773
+ "cursor-loc": H.value,
774
+ start: A.value,
775
+ duration: I.value,
776
+ constants: m,
777
+ config: v.value,
778
+ "active-viewer": r.value,
779
+ onSetStart: z
780
+ }, null, 8, ["ts_start", "ts_end", "c-width", "label-width", "cursor-loc", "start", "duration", "config", "active-viewer"]),
781
+ Q("div", nt, [
782
+ Q("div", {
783
+ id: "channelLabels",
784
+ ref_key: "channelLabels",
785
+ ref: Z
786
+ }, [
787
+ (re(!0), ve(Nn, null, Dn(te.value, (s) => (re(), ve("div", {
788
+ key: s.displayName,
789
+ class: "chLabelWrap",
790
+ "data-id": s.id,
791
+ onTap: on
792
+ }, [
793
+ Q("div", {
794
+ class: fe([s.selected ? "labelDiv selected" : "labelDiv"])
795
+ }, Oe(s.displayName), 3),
796
+ Q("div", {
797
+ class: fe(["chLabelIndWrap", [s.selected ? "selected" : ""]]),
798
+ hidden: ye.value
799
+ }, [
800
+ Q("div", {
801
+ class: "chLabelInd",
802
+ hidden: ye.value
803
+ }, Oe(mn(s, V.value, s.rowScale)), 9, rt)
804
+ ], 10, ot)
805
+ ], 40, tt))), 128))
806
+ ], 512),
807
+ G(q(a), {
808
+ ref_key: "viewerCanvas",
809
+ ref: g,
810
+ window_height: k.value,
811
+ window_width: F.value,
812
+ duration: I.value,
813
+ start: A.value,
814
+ "c-width": W.value,
815
+ "c-height": B.value,
816
+ constants: m,
817
+ "ts-start": S.value,
818
+ "ts-end": N.value,
819
+ "cursor-loc": H.value,
820
+ "global-zoom-mult": V.value,
821
+ "active-viewer": r.value,
822
+ config: v.value,
823
+ onSetStart: z,
824
+ onSetCursor: hn,
825
+ onSetGlobalZoom: yn,
826
+ onSetDuration: Ie,
827
+ onChannelsInitialized: dn,
828
+ onAnnLayersInitialized: cn,
829
+ onCloseAnnotationLayerWindow: we,
830
+ onAddAnnotation: Je,
831
+ onUpdateAnnotation: Ge
832
+ }, null, 8, ["window_height", "window_width", "duration", "start", "c-width", "c-height", "ts-start", "ts-end", "cursor-loc", "global-zoom-mult", "active-viewer", "config"])
833
+ ]),
834
+ n.isPreview ? Ln("", !0) : (re(), En(q(u), {
835
+ key: 0,
836
+ constants: m,
837
+ duration: I.value,
838
+ start: A.value,
839
+ onPageBack: vn,
840
+ onPageForward: fn,
841
+ onIncrementZoom: ln,
842
+ onDecrementZoom: un,
843
+ onUpdateDuration: sn,
844
+ onNextAnnotation: rn,
845
+ onPreviousAnnotation: an,
846
+ onSetStart: z
847
+ }, null, 8, ["duration", "start"])),
848
+ G(q(d), {
849
+ ref_key: "filterWindow",
850
+ ref: ee,
851
+ visible: t.filterWindowOpen,
852
+ "onUpdate:visible": l[0] || (l[0] = (s) => t.filterWindowOpen = s),
853
+ onCloseWindow: tn
854
+ }, null, 8, ["visible"]),
855
+ G(q(h), {
856
+ ref_key: "annotationModal",
857
+ ref: ce,
858
+ visible: j.value,
859
+ "onUpdate:visible": l[1] || (l[1] = (s) => j.value = s),
860
+ onCloseWindow: nn,
861
+ onCreateUpdateAnnotation: Xe
862
+ }, null, 8, ["visible"]),
863
+ G(q(c), {
864
+ visible: K.value,
865
+ "delete-annotation": de.value,
866
+ "onUpdate:visible": l[2] || (l[2] = (s) => K.value = s),
867
+ onDelete: Ke
868
+ }, null, 8, ["visible", "delete-annotation"]),
869
+ G(q(O), {
870
+ visible: ne.value,
871
+ onCloseWindow: we,
872
+ onCreateLayer: en
873
+ }, null, 8, ["visible"])
874
+ ], 2));
875
+ }
876
+ }, it = /* @__PURE__ */ et(at, [["__scopeId", "data-v-75a20a2f"]]), ut = {
877
+ install(n) {
878
+ n.component("TSViewer", it);
879
+ }
880
+ };
881
+ export {
882
+ it as T,
883
+ y as _,
884
+ _ as a,
885
+ C as b,
886
+ jn as c,
887
+ Un as d,
888
+ et as e,
889
+ Vn as f,
890
+ P as g,
891
+ $n as h,
892
+ je as i,
893
+ ke as j,
894
+ Ne as k,
895
+ Ve as l,
896
+ We as m,
897
+ xn as n,
898
+ Wn as o,
899
+ Ue as p,
900
+ ut as q,
901
+ Qn as u
902
+ };