@pennsieve-viz/tsviewer 1.0.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.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),r=require("./index-CGSfhm_E.cjs"),s={name:"BfLibraryButton",props:{type:{type:String,default:"button"},autofocus:Boolean,disabled:Boolean,processing:{type:Boolean,default:!1},processingText:{type:String,default:""}},computed:{hasPrefixSlot:function(){return!!this.$slots.prefix},hasSuffixSlot:function(){return!!this.$slots.suffix}},methods:{}},a=["disabled","autofocus","type"],l={key:0,class:"prefix"},c={key:3,class:"suffix"};function u(o,d,t,f,y,n){return e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["bf-library-button",[t.type?"bf-library-button--"+t.type:"",n.hasPrefixSlot?"hasPrefix":""]]),disabled:t.disabled||t.processing,autofocus:t.autofocus,type:t.type},[n.hasPrefixSlot?(e.openBlock(),e.createElementBlock("span",l,[e.renderSlot(o.$slots,"prefix",{},void 0,!0)])):e.createCommentVNode("",!0),t.processing?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[t.processingText?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(t.processingText),1)],64)):e.renderSlot(o.$slots,"default",{key:1},void 0,!0)],64)):e.createCommentVNode("",!0),t.processing?e.createCommentVNode("",!0):e.renderSlot(o.$slots,"default",{key:2},void 0,!0),n.hasSuffixSlot?(e.openBlock(),e.createElementBlock("span",c,[e.renderSlot(o.$slots,"suffix",{},void 0,!0)])):e.createCommentVNode("",!0)],10,a)}const i=r._export_sfc(s,[["render",u],["__scopeId","data-v-a46bc988"]]);exports.default=i;
@@ -0,0 +1,72 @@
1
+ import { createElementBlock as t, openBlock as s, normalizeClass as u, createCommentVNode as n, renderSlot as a, Fragment as i, createTextVNode as f, toDisplayString as l } from "vue";
2
+ import { g as d } from "./index-Cexzl5Xu.js";
3
+ const c = {
4
+ name: "BfLibraryButton",
5
+ props: {
6
+ type: {
7
+ type: String,
8
+ default: "button"
9
+ },
10
+ autofocus: Boolean,
11
+ disabled: Boolean,
12
+ processing: {
13
+ type: Boolean,
14
+ default: !1
15
+ },
16
+ processingText: {
17
+ type: String,
18
+ default: ""
19
+ }
20
+ },
21
+ computed: {
22
+ hasPrefixSlot: function() {
23
+ return !!this.$slots.prefix;
24
+ },
25
+ hasSuffixSlot: function() {
26
+ return !!this.$slots.suffix;
27
+ }
28
+ },
29
+ methods: {
30
+ /**
31
+ * On click
32
+ * @param {Object} evt
33
+ */
34
+ // handleClick(evt) {
35
+ // // this.$emit('click', evt)
36
+ // }
37
+ }
38
+ }, y = ["disabled", "autofocus", "type"], b = {
39
+ key: 0,
40
+ class: "prefix"
41
+ }, x = {
42
+ key: 3,
43
+ class: "suffix"
44
+ };
45
+ function h(o, m, e, g, p, r) {
46
+ return s(), t("button", {
47
+ class: u(["bf-library-button", [
48
+ e.type ? "bf-library-button--" + e.type : "",
49
+ r.hasPrefixSlot ? "hasPrefix" : ""
50
+ ]]),
51
+ disabled: e.disabled || e.processing,
52
+ autofocus: e.autofocus,
53
+ type: e.type
54
+ }, [
55
+ r.hasPrefixSlot ? (s(), t("span", b, [
56
+ a(o.$slots, "prefix", {}, void 0, !0)
57
+ ])) : n("", !0),
58
+ e.processing ? (s(), t(i, { key: 1 }, [
59
+ e.processingText ? (s(), t(i, { key: 0 }, [
60
+ f(l(e.processingText), 1)
61
+ ], 64)) : a(o.$slots, "default", { key: 1 }, void 0, !0)
62
+ ], 64)) : n("", !0),
63
+ e.processing ? n("", !0) : a(o.$slots, "default", { key: 2 }, void 0, !0),
64
+ r.hasSuffixSlot ? (s(), t("span", x, [
65
+ a(o.$slots, "suffix", {}, void 0, !0)
66
+ ])) : n("", !0)
67
+ ], 10, y);
68
+ }
69
+ const B = /* @__PURE__ */ d(c, [["render", h], ["__scopeId", "data-v-a46bc988"]]);
70
+ export {
71
+ B as default
72
+ };
@@ -0,0 +1,37 @@
1
+ import { createElementBlock as o, openBlock as h, createElementVNode as n } from "vue";
2
+ import { g as r } from "./index-Cexzl5Xu.js";
3
+ const i = {
4
+ name: "IconSelection",
5
+ props: {
6
+ width: {
7
+ type: Number,
8
+ default: 16
9
+ },
10
+ height: {
11
+ type: Number,
12
+ default: 16
13
+ },
14
+ color: {
15
+ type: String,
16
+ default: "currentColor"
17
+ }
18
+ }
19
+ }, l = ["width", "height", "fill"];
20
+ function c(d, e, t, m, s, a) {
21
+ return h(), o("svg", {
22
+ xmlns: "http://www.w3.org/2000/svg",
23
+ width: t.width,
24
+ height: t.height,
25
+ fill: t.color,
26
+ viewBox: "0 0 24 24"
27
+ }, [...e[0] || (e[0] = [
28
+ n("path", {
29
+ pid: "0",
30
+ d: "M16 10V7h-4V4H4v10h4v3h4v3h8V10zM6 12V6h4v1H8v5zm4 3V9h4v1h-2v5zm8 3h-4v-6h4z"
31
+ }, null, -1)
32
+ ])], 8, l);
33
+ }
34
+ const v = /* @__PURE__ */ r(i, [["render", c]]);
35
+ export {
36
+ v as I
37
+ };
@@ -0,0 +1 @@
1
+ "use strict";const t=require("vue"),o=require("./index-CGSfhm_E.cjs"),i={name:"IconSelection",props:{width:{type:Number,default:16},height:{type:Number,default:16},color:{type:String,default:"currentColor"}}},h=["width","height","fill"];function c(l,n,e,d,s,u){return t.openBlock(),t.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",width:e.width,height:e.height,fill:e.color,viewBox:"0 0 24 24"},[...n[0]||(n[0]=[t.createElementVNode("path",{pid:"0",d:"M16 10V7h-4V4H4v10h4v3h4v3h8V10zM6 12V6h4v1H8v5zm4 3V9h4v1h-2v5zm8 3h-4v-6h4z"},null,-1)])],8,h)}const r=o._export_sfc(i,[["render",c]]);exports.IconSelection=r;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("vue"),b=require("./index-CGSfhm_E.cjs"),J=require("pinia"),U=require("./TSViewerCanvas-Jbu-Kh9F.cjs"),B=require("./pathOr-D0158Gk1.cjs"),M=(t,u)=>{let c;if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(t))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(",")+","+u+")";throw new Error("Bad Hex")},K=t=>{t.sort((u,c)=>u.start<c.start?-1:u.start>c.start?1:0)},z=(t,u)=>{const c=(t==null?void 0:t.layer_id)||0;return b.defaultTo({},U.find(b.propEq("id",c),u))},q=(t,u,c,o=0,l=!1)=>{let v;return l?v=V(t,u,o,t.length-1,c):v=_(t,u,o,t.length-1,c),v===-1?v=0:v<0&&(v=-v-2),v},_=(t,u,c,o,l)=>{if(o<c){let y=o>=0?o:-o-2;if(y===-1)return y;const T=t[y].start;for(;y>=0&&t[y].start===T;)y--;return-y-2}const v=parseInt((c+o)/2);if(t[v].start>u)return _(t,u,c,v-1,l);if(t[v].start<u)return _(t,u,v+1,o,l);{let y=v;if(l){for(;y>=0&&t[y].start===u;)y--;y++}else{for(;y<t.length&&t[y].start===u;)y++;y--}return y}},V=(t,u,c,o,l)=>{if(o<c){let T=o>=0?o:-o-2;if(T===-1)return T;const I=t[T].start+t[T].duration;for(;T>=0&&t[T].start+t[T].duration===I;)T--;return-T-2}const v=parseInt((c+o)/2),y=t[v].start+t[v].duration;if(y>u)return V(t,u,c,v-1,l);if(y<u)return V(t,u,v+1,o,l);{let T=v;if(l){for(;T>=0&&t[T].start+t[T].duration===u;)T--;T++}else{for(;T<t.length&&t[T].start+t[T].duration===u;)T++;T--}return T}},j=(t,u,c=0)=>u*(t+c);function Q(){const t=b.useViewerStore(),{viewerChannels:u,viewerAnnotations:c,viewerMontageScheme:o}=J.storeToRefs(t),l=F.ref([]),v=F.ref([]),y=g=>{const d=o.value!=="NOT_MONTAGED";let e=b.propOr("","id",g);if(d){const r=e.split("_");e=r.length?U.head(r):e}return e},T=async(g,d,e,r,f)=>{const i=[];i.push({start:g,end:e.tsEnd});let a=0;for(let n=0;n<l.value.length;n++){const s=l.value[n];if(g>=s.start&&d<=s.end)return;if(i[0].start>d)break;if(s.start<=i[0].start&&s.end>=g)a=n+1,i[0].start=s.end;else if(s.start>i[0].start){a=n;break}}const h=c.value.reduce((n,s)=>n+s.annotations.length,0);if(i[0].start>=i[0].end&&h>0)return;const w=0;for(let n=a;n<l.value.length;n++)if(l.value[n].start>=i[w].start)if(i[w].end=l.value[n].start,l.value[n].end<d)i.push({start:l.value[n].end,end:e.tsEnd});else break;if(!(i[0].start>=i[0].end&&h>0)&&i.length>0){u.value.map(n=>y(n));for(const n of i){for(const s of c.value){if(!s.id){console.warn("Layer ID is undefined, skipping annotation request for layer:",s);continue}const m=Math.floor(n.end),L={id:r.content.id,start:Math.floor(n.start),end:m,layerId:s.id,limit:e.constants.LIMITANNFETCH};try{const O=await b.useToken(),A=`${t.config.apiUrl}/timeseries/${r.content.id}/layers/${s.id}/annotations?api_key=${O}`,S=Object.keys(L).map(N=>`&${N}=${L[N]}`).join(""),E=`${A}${S}`,p=await fetch(E,{method:"GET",headers:{"Content-type":"application/json"}});if(p.status>=400)throw new Error(p.status);const $=await p.json();await I($,f)}catch(O){b.useHandleXhrError(O)}}l.value.push({start:Math.floor(n.start),end:Math.floor(n.end)})}l.value.sort((n,s)=>n.start<s.start?-1:n.start>s.start?1:0)}},I=async(g,d)=>{const e=b.propOr({},"linkedPackages",g);let r=B.pathOr([],["annotations","results"],g);if(r.length>=500){let i=0;for(const a of r)a.start>i&&(i=a.start);for(const a of l.value)if(a.end>i&&a.start<i){a.end=i;break}}const f=o.value!=="NOT_MONTAGED";if(r.length>0){const i=r.map(a=>{const h={name:"",id:a.id,label:a.label,description:a.description,start:a.start,duration:a.end-a.start,end:a.end,cStart:null,cEnd:null,selected:!1,channelIds:a.channelIds,allChannels:!1,layer_id:a.layerId,userId:a.userId};if(a.linkedPackage){const w=a.linkedPackage;h.linkedPackage=B.pathOr("",["content","id"],e[w]),h.linkedPackageDTO=e[w]}return(!f&&h.channelIds.length===u.value.length||f&&h.channelIds.length>u.value.length)&&(h.allChannels=!0),h});c.value.forEach(a=>{const h=a.annotations,w=i.filter(n=>a.id===n.layer_id);a.annotations=h.concat(w),t.updateLayer(a)})}d("annotationsReceived")};return{cachedAnnRange:l,annLayerInfo:v,checkAnnotationRange:T,findNextAnnotation:g=>{const d=t.getViewerActiveLayer(),e=q(d.annotations,g,!1);return e<d.annotations.length?d.annotations[e].start>g?d.annotations[e]:d.annotations[e+1]||d.annotations[e]:d.annotations[e]},findPreviousAnnotation:g=>{const d=t.getViewerActiveLayer(),e=q(d.annotations,g,!0);return d.annotations[e].start<g?d.annotations[e]:e>0?d.annotations[e-1]:d.annotations[e]},getChannelId:y}}function Y(){const t=b.useViewerStore(),{viewerAnnotations:u,viewerChannels:c}=J.storeToRefs(t),o=F.ref([]),l=F.ref([]),v=F.ref(null),y=F.ref(["#FFFF4E"]),T=(e,r)=>{var h,w;const i=(((h=r.constants)==null?void 0:h.ANNOTATIONLABELHEIGHT)||20)/2|0,a=((w=r.constants)==null?void 0:w.XOFFSET)||0;for(const n of e){let s=n.start,m=n.duration;n.duration<0&&(s=n.start+n.duration,m=-n.duration);const L=a+(s-r.start)/r.rsPeriod;if(n.cStart=L|0,n.duration!==0){const O=a+(s+m-r.start)/r.rsPeriod;n.cEnd=O|0}else n.cEnd=n.cStart+r.cWidth/40|0;if(n.allChannels)n.allOffsets=[i],n.cY=i;else{n.allOffsets=[],n.minOffset=r.cHeight|0,n.maxOffset=0;const O=c.value;for(const C of n.channelIds){let A=null;for(const S of O)if(S.id===C&&S.visible){A=S.rowBaseline|0,A<n.minOffset&&(n.minOffset=A),A>n.maxOffset&&(n.maxOffset=A),n.allOffsets.push(A);break}}l.value.indexOf(n.minOffset)<0&&l.value.push(n.minOffset),n.cY=n.minOffset}}},I=(e,r,f,i)=>{var w,n;const a=((w=f.constants)==null?void 0:w.ANNOTATIONLABELHEIGHT)||20,h=a/2|0;e.setTransform(f.pixelRatio,0,0,f.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)";for(const s of r){const m=z(s,u.value);s.selected&&(e.save(),e.strokeStyle=m.selColor,e.fillStyle=m.bkColor,e.lineWidth=1);const L=Math.round(s.cStart)+.5,O=Math.round(s.cEnd)+.5;s.allChannels?s.duration===0?(e.beginPath(),e.moveTo(L+1,a),e.lineTo(L,i),e.stroke()):(e.fillRect(L,a,O-L,i-a),e.beginPath(),e.moveTo(L,a),e.lineTo(L,i),e.moveTo(O,a),e.lineTo(O,i),e.stroke()):((n=s==null?void 0:s.channelIds)==null?void 0:n.length)===1?s.duration===0&&(e.beginPath(),e.moveTo(L,s.minOffset+h),e.lineTo(L,s.minOffset+h+8),e.stroke()):s.duration===0?(e.beginPath(),e.moveTo(L,s.minOffset+h),e.lineTo(L,s.maxOffset-h),e.stroke()):(e.fillRect(L-1,s.minOffset+h,O-L+1,s.maxOffset-s.minOffset-a),e.beginPath(),e.moveTo(L,s.minOffset+h),e.lineTo(L,s.maxOffset-h),e.moveTo(O,s.minOffset+h),e.lineTo(O,s.maxOffset-h),e.stroke()),s.selected&&e.restore()}e.restore()},R=async(e,r,f,i,a,h)=>{var s;const w=((s=f.constants)==null?void 0:s.ANNOTATIONLABELHEIGHT)||20,n=w/2|0;e.setTransform(f.pixelRatio,0,0,f.pixelRatio,0,0),e.save(),e.lineWidth=2,e.font="14px sans-serif",e.textAlign="left";for(const m of r){const L=z(m,u.value);if(m===v.value&&i)continue;m.selected?(e.fillStyle=L.selColor||"rgba(51,204,102, 0.8)",e.strokeStyle="white"):(e.fillStyle=L.color||"rgba(51,204,102,0.8)",e.strokeStyle=m===v.value?"white":"rgba(255,255,255,0.8)");const O=Math.round(m.cStart)+1,C=Math.round(m.cEnd);let A=0;for(let p=0;p<m.allOffsets.length;p++)e.fillRect(O-1,m.allOffsets[p]-n,C-O+2,w),m.allOffsets[p]===m.minOffset&&(A=p);const S=m.allOffsets[A];if(["annSelect","annResize-left","annResize-right"].includes(a)&&h==="annotate"&&(e.beginPath(),m.duration!==0&&(e.moveTo(C-3,S-n+3),e.lineTo(C-3,S+n-3)),e.moveTo(O+3,S-n+3),e.lineTo(O+3,S+n-3),e.stroke()),C-O>m.label.length*8+10){e.fillStyle=y.value.indexOf(L.hexColor)>=0?"black":"white";const p=m.linkedPackage?O+30:O+10,$=m.linkedPackage?S+n-n/2:S+n-6;e.fillText(m.label,p,$)}const E=m.linkedPackageDTO;E&&C-O>=30&&await k(e,E,O,S,n,w)}e.restore()},k=async(e,r,f,i,a,h)=>{const w=B.pathOr({},["objects","view",1,"content"],r),n=b.propOr("","fileType",w),s=new Image;if(n==="PNG"){const{id:m,packageId:L}=w,O=t.config.apiUrl;try{const C=await b.useToken();s.src=`${O}/packages/${L}/files/${m}/presign/?api_key=${C}`,s.complete?e.drawImage(s,f,i-a,27,h):s.addEventListener("load",()=>{e.drawImage(s,f,i-a,27,h)},{once:!0})}catch(C){console.error("Error loading image:",C)}}else s.src=g(),e.drawImage(s,f+5,i-a,20,20)},g=e=>"/path/to/default/icon.png";return{renderAnn:o,hoverOffsets:l,focusedAnn:v,render:(e,r,f,i)=>{var m,L,O,C;if(!r){console.warn("TSAnnotationCanvas: annotationsCanvas prop is undefined or null");return}const a=r.getContext("2d"),h=f.getContext("2d");a.setTransform(e.pixelRatio,0,0,e.pixelRatio,0,0),h.setTransform(e.pixelRatio,0,0,e.pixelRatio,0,0),l.value=[(((m=e.constants)==null?void 0:m.ANNOTATIONLABELHEIGHT)||20)/2],a.clearRect(0,0,e.cWidth,e.cHeight),h.clearRect(0,0,e.cWidth,e.cHeight),o.value=[];const w=e.duration&&e.duration>0?e.duration:15e6,n=e.start||0,s=n+w;console.log("🎨 Annotation render debug:",{start:n,duration:w,end:s,layerCount:((L=u.value)==null?void 0:L.length)||0,totalAnnotations:((O=u.value)==null?void 0:O.reduce((A,S)=>{var E;return A+(((E=S.annotations)==null?void 0:E.length)||0)},0))||0});for(const A of u.value)if(A.visible&&((C=A.annotations)==null?void 0:C.length)>0){console.log(`🔍 Processing layer "${A.name}" with ${A.annotations.length} annotations`);const S=A.annotations.filter(E=>{const p=E.start,$=E.end||E.start+(E.duration||0),N=p<s&&$>n;return N&&console.log(` ✅ Including annotation "${E.label}": ${p} - ${$}`),N});console.log(` 📊 Found ${S.length} annotations in viewport`),S.length>0&&(S.sort((E,p)=>E.start-p.start),o.value.push(...S))}if(console.log(`🎯 Total annotations to render: ${o.value.length}`),o.value.length===0){console.log("⚠️ No annotations found in viewport");return}K(o.value),T(o.value,e),I(a,o.value,e,i),R(h,o.value,e,!0,e.pointerMode,e.viewerActiveTool),v.value&&R(h,[v.value],e,!1,e.pointerMode,e.viewerActiveTool),console.log(`✅ Rendered ${o.value.length} annotations successfully`)},computeRenderOptions:T,renderAnnotationAreas:I,renderAnnotationLabels:R}}function Z(t,u,c){const o=b.useViewerStore(),l=F.ref([0,0]),v=(e,r)=>{const i=((r==null?void 0:r.ANNOTATIONLABELHEIGHT)||20)/2;for(const a of c.value)if(e>=a-i&&e<=a+i)return!0;return!1},y=(e,r,f)=>{var h;const a=((f==null?void 0:f.ANNOTATIONLABELHEIGHT)||20)/2;for(let w=0;w<(((h=u.value)==null?void 0:h.length)||0);w++){const n=u.value[w];if(n.cStart<e&&n.cEnd>e){if(r>n.cY-a&&r<n.cY+a)return w}else if(n.cStart>e)break}return null},T=(e,r,f)=>{if(!f)return r;switch(r){case"annotate":return e<=f.cStart+10?"annResize-left":e>=f.cEnd-10&&f.duration>0?"annResize-right":"annSelect";case"pointer":return"annSelect";default:return r}};return{mouseDownPosition:l,shouldCheckAnnotationHover:v,findAnnotationAtPosition:y,determinePointerMode:T,resetFocusedAnnotation:()=>{var e;((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)},selectFocusedAnnotation:()=>t.value?(o.setActiveAnnotation(t.value),!0):!1,onMouseDown:(e,r,f)=>{t.value&&["annResize-left","annResize-right"].includes(f)&&(t.value.oldStart=t.value.start,t.value.oldDuration=t.value.duration,l.value=[e,r])},onMouseMove:(e,r,f,i,a)=>{let h=f;if(i&&l.value){const w=(e-l.value[0])*a.rsPeriod;switch(f){case"annResize-left":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;break;case"annResize-right":t.value.duration=t.value.oldDuration+w,t.value.end=t.value.start+t.value.duration;break}}else{const w=v(r,a.constants);if(h=a.viewerActiveTool,w){const n=y(e,r,a.constants);if(n!==null){const s=t.value,m=u.value[n];(!s||e<t.value.cStart||e>t.value.cEnd)&&(t.value=m),h=T(e,a.viewerActiveTool,t.value)}else t.value=null}else t.value=null,h=a.viewerActiveTool}return h},onMouseUp:(e,r)=>{if(t.value&&["annResize-left","annResize-right"].includes(e)){if(t.value.duration<0){const f=-t.value.duration,i=t.value.start-f;t.value.start=i,t.value.duration=f,t.value.end=i+f}o.setActiveAnnotation(t.value),r("updateAnnotation",t.value)}}}}var H={exports:{}},G;function x(){if(G)return H.exports;G=1;function t(){}return t.prototype={on:function(u,c,o){var l=this.e||(this.e={});return(l[u]||(l[u]=[])).push({fn:c,ctx:o}),this},once:function(u,c,o){var l=this;function v(){l.off(u,v),c.apply(o,arguments)}return v._=c,this.on(u,v,o)},emit:function(u){var c=[].slice.call(arguments,1),o=((this.e||(this.e={}))[u]||[]).slice(),l=0,v=o.length;for(l;l<v;l++)o[l].fn.apply(o[l].ctx,c);return this},off:function(u,c){var o=this.e||(this.e={}),l=o[u],v=[];if(l&&c)for(var y=0,T=l.length;y<T;y++)l[y].fn!==c&&l[y].fn._!==c&&v.push(l[y]);return v.length?o[u]=v:delete o[u],this}},H.exports=t,H.exports.TinyEmitter=t,H.exports}var D,W;function ee(){if(W)return D;W=1;var t=x();return D=new t,D}var te=ee();const P=U.getDefaultExportFromCjs(te),X={$emit:(...t)=>P.emit(...t),$on:(...t)=>P.on(...t),$off:(...t)=>P.off(...t),$once:(...t)=>P.once(...t)};function ne(){const t=b.useViewerStore(),u=F.ref([]),c=F.ref(["#18BA62","#FFBC27","#E94B4B","#0D4EFF","#FF4FFF","#50FFFF","#FFFF4E","#512BAF","#8A6ECF","#389BAD","#187D46","#B12800","#0C2475","#FF5321","#FF99CC","#DCC180","#FF6C21","#000000","#9B9B9B","#00FF00","#FA8072","#808000","#A0522D","#2760FF"]),o=async(k,g)=>{const d=[];if(k.results.length===0)await l({name:"Default",color:"#18BA62",description:"Default Annotation Layer"},null,g);else{for(let e=0;e<k.results.length;e++){const r=k.results[e];let f=r.color||c.value[e%c.value.length];const i={id:r.id,name:r.name,description:r.description,visible:!0,selected:e===0,annotations:[],color:M(f,.7),hexColor:f,bkColor:M(f,.15),selColor:M(f,.9)};d.push(i)}t.setAnnotations(d),g("annLayersInitialized")}u.value=k.results},l=async(k,g,d)=>{try{const e=await b.useToken(),r=`${t.config.apiUrl}/timeseries/${g.content.id}/layers?api_key=${e}`,f=await b.useSendXhr(r,{method:"POST",body:{name:k.name,color:k.color,description:k.description||k.name}}),i={...f,annotations:[],hexColor:f.color,color:M(f.color,.7),bkColor:M(f.color,.15),selColor:M(f.color,.9),visible:!0,selected:!0};return t.createLayer(i),t.setActiveAnnotationLayer(i.id),X.$emit("toast",{detail:{msg:`'${i.name}' Layer Created`}}),i}catch(e){throw b.useHandleXhrError(e),e}finally{d&&d("closeAnnotationLayerWindow")}};return{annLayerInfo:u,defaultColors:c,initializeLayers:o,createAnnotationLayer:l,updateLayerVisibility:(k,g)=>{console.log(`[useAnnotationLayers] Updating layer ${k} visibility to:`,g);const d=t.viewerAnnotations.find(e=>e.id===k);if(d){console.log("[useAnnotationLayers] Found layer:",d.name,"current visible:",d.visible),d.visible=g,t.updateLayer(d),console.log("[useAnnotationLayers] Updated layer:",d.name,"new visible:",d.visible);const e=t.viewerAnnotations.find(r=>r.id===k);console.log("[useAnnotationLayers] Verification - layer visible is now:",e==null?void 0:e.visible)}else console.error("[useAnnotationLayers] Layer not found with ID:",k),console.log("[useAnnotationLayers] Available layers:",t.viewerAnnotations.map(e=>({id:e.id,name:e.name})))},selectLayer:k=>{t.viewerAnnotations.forEach(d=>{d.selected=!1,t.updateLayer(d)});const g=t.viewerAnnotations.find(d=>d.id===k);g&&(g.selected=!0,t.updateLayer(g),t.setActiveAnnotationLayer(k))},deleteLayer:async(k,g)=>{try{const d=await b.useToken(),e=`${t.config.apiUrl}/timeseries/${g.content.id}/layers/${k}?api_key=${d}`;await b.useSendXhr(e,{method:"DELETE"}),t.removeLayer(k),X.$emit("toast",{detail:{msg:"Layer deleted successfully"}})}catch(d){throw b.useHandleXhrError(d),d}},updateLayerColor:async(k,g,d)=>{try{const e=await b.useToken(),r=`${t.config.apiUrl}/timeseries/${d.content.id}/layers/${k}?api_key=${e}`,f=await b.useSendXhr(r,{method:"PUT",body:{color:g}}),i=t.viewerAnnotations.find(a=>a.id===k);return i&&(i.hexColor=g,i.color=M(g,.7),i.bkColor=M(g,.15),i.selColor=M(g,.9),t.updateLayer(i)),f}catch(e){throw b.useHandleXhrError(e),e}},loadLayers:async(k,g)=>{try{const d=await b.useToken(),e=`${t.config.apiUrl}/timeseries/${k.content.id}/layers?api_key=${d}`,r=await b.useSendXhr(e);return await o(r,g),r}catch(d){throw b.useHandleXhrError(d),d}}}}const oe=["width","height"],ae={__name:"TSAnnotationCanvas",props:{cWidth:{type:Number,default:0},cHeight:Number,start:Number,duration:Number,tsEnd:Number,rsPeriod:Number,pixelRatio:Number,constants:{type:Object,default:()=>({ANNOTATIONLABELHEIGHT:20,XOFFSET:0,LIMITANNFETCH:500})},pointerMode:String,annotationsCanvas:[HTMLCanvasElement,Object],activeViewer:{type:Object,required:!0},viewerActiveTool:String},emits:["annLayersInitialized","annotationsReceived","closeAnnotationLayerWindow","updateAnnotation"],setup(t,{expose:u,emit:c}){const o=t,l=c,v=F.ref(null),{checkAnnotationRange:y,findNextAnnotation:T,findPreviousAnnotation:I}=Q(),{renderAnn:R,hoverOffsets:k,focusedAnn:g,render:d}=Y(),{resetFocusedAnnotation:e,selectFocusedAnnotation:r,onMouseDown:f,onMouseMove:i,onMouseUp:a}=Z(g,R,k),{createAnnotationLayer:h,loadLayers:w}=ne(),n=F.computed(()=>o.cHeight-20),s=F.computed(()=>({width:o.cWidth+"px",height:n.value+"px"})),m=()=>{d(o,o.annotationsCanvas,v.value,n.value)},L=(E,p)=>{f(E,p,o.pointerMode)},O=(E,p,$,N)=>i(E,p,$,N,o),C=()=>{a(o.pointerMode,l)},A=()=>{r()&&F.nextTick(()=>m())},S=async E=>{try{await h(E,o.activeViewer,l)}catch(p){console.error("Error creating layer:",p)}};return F.watch(()=>o.activeViewer,async E=>{try{await w(E,l),await y(o.start,o.start+o.duration,o,E,l)}catch(p){console.error("Error loading annotations for new viewer:",p)}}),F.onMounted(async()=>{console.log("TSAnnotationCanvas mounted with props:",{constants:o.constants,annotationsCanvas:o.annotationsCanvas,viewerActiveTool:o.viewerActiveTool});try{await w(o.activeViewer,l),await y(o.start,o.start+o.duration,o,o.activeViewer,l)}catch(E){console.error("Error initializing annotations:",E)}}),u({render:m,resetFocusedAnnotation:e,findNextAnnotation:T,findPreviousAnnotation:I,checkAnnotationRange:(E,p)=>y(E,p,o,o.activeViewer,l),selectFocusedAnn:A,createAnnotationLayer:S,onMouseDown:L,onMouseMove:O,onMouseUp:C}),(E,p)=>(F.openBlock(),F.createElementBlock("canvas",{id:"annLabelArea",ref_key:"annLabelArea",ref:v,class:"timeseries-annotation-canvas",width:F.unref(j)(t.cWidth,t.pixelRatio,0),height:F.unref(j)(n.value,t.pixelRatio,0),style:F.normalizeStyle(s.value)},null,12,oe))}},ie=b._export_sfc(ae,[["__scopeId","data-v-41f7f1c2"]]);exports.default=ie;