@pennsieve-viz/tsviewer 1.0.3 → 1.0.31

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 (41) hide show
  1. package/dist/{BFLibraryButton-BIHTpeNO.cjs → BFLibraryButton-CnSdxNr1.cjs} +1 -1
  2. package/dist/{BFLibraryButton-cj0cYcEU.js → BFLibraryButton-Dec5fit3.js} +14 -14
  3. package/dist/{IconSelection-DPzESQva.js → IconSelection-C_zQHxVs.js} +3 -3
  4. package/dist/{IconSelection-Clsng0MV.cjs → IconSelection-CxtyAEya.cjs} +1 -1
  5. package/dist/TSAnnotationCanvas-BuYjJ340.cjs +1 -0
  6. package/dist/TSAnnotationCanvas-DV93mqhV.js +778 -0
  7. package/dist/{TSAnnotationModal-D36kPDem.cjs → TSAnnotationModal-Bvz6Hr6c.cjs} +1 -1
  8. package/dist/{TSAnnotationModal-QTRsd7x7.js → TSAnnotationModal-Crb5zX1P.js} +13 -13
  9. package/dist/{TSFilterModal-PeYsMpbr.cjs → TSFilterModal-BA7WXDk1.cjs} +1 -1
  10. package/dist/{TSFilterModal-Dpohnnn3.js → TSFilterModal-DdNCo0nH.js} +8 -8
  11. package/dist/{TSScrubber-C99OFl1F.js → TSScrubber-BsoGLy_L.js} +3 -3
  12. package/dist/{TSScrubber-CIfQ9P9Q.cjs → TSScrubber-KnkoGu88.cjs} +1 -1
  13. package/dist/{TSViewerCanvas-B2JwW053.js → TSViewerCanvas-ByhDLibl.js} +11 -11
  14. package/dist/{TSViewerCanvas-D7w29Dvz.cjs → TSViewerCanvas-D_i1FrqG.cjs} +2 -2
  15. package/dist/{TSViewerLayerWindow-DkDO3dZb.cjs → TSViewerLayerWindow-4ckQFmUZ.cjs} +1 -1
  16. package/dist/{TSViewerLayerWindow-BsV_pDGS.js → TSViewerLayerWindow-Cf4J_lK_.js} +6 -6
  17. package/dist/{TSViewerToolbar-Rsz0-ujg.cjs → TSViewerToolbar-BLOSD8fd.cjs} +1 -1
  18. package/dist/{TSViewerToolbar-DoSJEPgd.js → TSViewerToolbar-BxAiyYi7.js} +13 -13
  19. package/dist/{TsAnnotationDeleteDialog-GSMBqEkE.cjs → TsAnnotationDeleteDialog-B_ZIUOh2.cjs} +1 -1
  20. package/dist/{TsAnnotationDeleteDialog-NGmIj7Nr.js → TsAnnotationDeleteDialog-Dm0rbNQr.js} +6 -6
  21. package/dist/{base-CEBDkSsZ.cjs → base-BQSnEcNP.cjs} +1 -1
  22. package/dist/{base-B8HYDRlA.js → base-VCnLhxie.js} +9 -9
  23. package/dist/el-input-CwVmeiqs.cjs +1 -0
  24. package/dist/{el-input-v5gK8U8C.js → el-input-DQtvBLS6.js} +1664 -1676
  25. package/dist/{el-input-number-F_eDnZFO.cjs → el-input-number-Cxwc3-EL.cjs} +1 -1
  26. package/dist/{el-input-number-DSVzNAfT.js → el-input-number-DXCID3jJ.js} +6 -6
  27. package/dist/{el-overlay-4ljdPakB.js → el-overlay-BMUWCEw_.js} +14 -14
  28. package/dist/{el-overlay-DFtIA0N9.cjs → el-overlay-D192MFpl.cjs} +1 -1
  29. package/dist/{index-BJOVbX31.js → index-BAtTJnp_.js} +1 -1
  30. package/dist/{index-DmPnHGWj.js → index-C3ilckwx.js} +28 -27
  31. package/dist/{index-B7L4A5WQ.cjs → index-D8lvFC22.cjs} +1 -1
  32. package/dist/{index-2QS1iKBu.cjs → index-TDc5sP-n.cjs} +1 -1
  33. package/dist/index.cjs +1 -1
  34. package/dist/index.js +1 -1
  35. package/dist/{pathOr-Bcyi9PI-.js → pathOr-CC_5pAvC.js} +2 -2
  36. package/dist/{pathOr-CaQF9BY-.cjs → pathOr-D8CyYHmd.cjs} +1 -1
  37. package/dist/style.css +1 -1
  38. package/package.json +1 -1
  39. package/dist/TSAnnotationCanvas-CXAko3Ju.cjs +0 -1
  40. package/dist/TSAnnotationCanvas-Cx8ea7Mz.js +0 -730
  41. package/dist/el-input-DFAVTpkr.cjs +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),r=require("./index-B7L4A5WQ.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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),r=require("./index-D8lvFC22.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;
@@ -1,5 +1,5 @@
1
- import { openBlock as t, createElementBlock as s, normalizeClass as u, renderSlot as n, createCommentVNode as a, Fragment as i, createTextVNode as f, toDisplayString as l } from "vue";
2
- import { g as d } from "./index-DmPnHGWj.js";
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-C3ilckwx.js";
3
3
  const c = {
4
4
  name: "BfLibraryButton",
5
5
  props: {
@@ -43,7 +43,7 @@ const c = {
43
43
  class: "suffix"
44
44
  };
45
45
  function h(o, m, e, g, p, r) {
46
- return t(), s("button", {
46
+ return s(), t("button", {
47
47
  class: u(["bf-library-button", [
48
48
  e.type ? "bf-library-button--" + e.type : "",
49
49
  r.hasPrefixSlot ? "hasPrefix" : ""
@@ -52,18 +52,18 @@ function h(o, m, e, g, p, r) {
52
52
  autofocus: e.autofocus,
53
53
  type: e.type
54
54
  }, [
55
- r.hasPrefixSlot ? (t(), s("span", b, [
56
- n(o.$slots, "prefix", {}, void 0, !0)
57
- ])) : a("", !0),
58
- e.processing ? (t(), s(i, { key: 1 }, [
59
- e.processingText ? (t(), s(i, { key: 0 }, [
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
60
  f(l(e.processingText), 1)
61
- ], 64)) : n(o.$slots, "default", { key: 1 }, void 0, !0)
62
- ], 64)) : a("", !0),
63
- e.processing ? a("", !0) : n(o.$slots, "default", { key: 2 }, void 0, !0),
64
- r.hasSuffixSlot ? (t(), s("span", x, [
65
- n(o.$slots, "suffix", {}, void 0, !0)
66
- ])) : a("", !0)
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
67
  ], 10, y);
68
68
  }
69
69
  const B = /* @__PURE__ */ d(c, [["render", h], ["__scopeId", "data-v-a46bc988"]]);
@@ -1,5 +1,5 @@
1
- import { openBlock as o, createElementBlock as h, createElementVNode as n } from "vue";
2
- import { g as r } from "./index-DmPnHGWj.js";
1
+ import { createElementBlock as o, openBlock as h, createElementVNode as n } from "vue";
2
+ import { g as r } from "./index-C3ilckwx.js";
3
3
  const i = {
4
4
  name: "IconSelection",
5
5
  props: {
@@ -18,7 +18,7 @@ const i = {
18
18
  }
19
19
  }, l = ["width", "height", "fill"];
20
20
  function c(d, e, t, m, s, a) {
21
- return o(), h("svg", {
21
+ return h(), o("svg", {
22
22
  xmlns: "http://www.w3.org/2000/svg",
23
23
  width: t.width,
24
24
  height: t.height,
@@ -1 +1 @@
1
- "use strict";const t=require("vue"),o=require("./index-B7L4A5WQ.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;
1
+ "use strict";const t=require("vue"),o=require("./index-D8lvFC22.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 S=require("vue"),O=require("./index-D8lvFC22.cjs"),te=require("pinia"),ne=require("./TSViewerCanvas-D_i1FrqG.cjs"),j=require("./pathOr-D8CyYHmd.cjs"),oe=require("./_commonjsHelpers-DKOUU3wS.cjs"),H=(t,u)=>{let l;if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(t))return l=t.substring(1).split(""),l.length===3&&(l=[l[0],l[0],l[1],l[1],l[2],l[2]]),l="0x"+l.join(""),"rgba("+[l>>16&255,l>>8&255,l&255].join(",")+","+u+")";throw new Error("Bad Hex")},ae=t=>{t.sort((u,l)=>u.start<l.start?-1:u.start>l.start?1:0)},K=(t,u)=>{const l=(t==null?void 0:t.layer_id)||0;return O.defaultTo({},ne.find(O.propEq("id",l),u))},Q=(t,u,l,n=0,c=!1)=>{let h;return c?h=G(t,u,n,t.length-1,l):h=W(t,u,n,t.length-1,l),h===-1?h=0:h<0&&(h=-h-2),h},W=(t,u,l,n,c)=>{if(n<l){let m=n>=0?n:-n-2;if(m===-1)return m;const p=t[m].start;for(;m>=0&&t[m].start===p;)m--;return-m-2}const h=parseInt((l+n)/2);if(t[h].start>u)return W(t,u,l,h-1,c);if(t[h].start<u)return W(t,u,h+1,n,c);{let m=h;if(c){for(;m>=0&&t[m].start===u;)m--;m++}else{for(;m<t.length&&t[m].start===u;)m++;m--}return m}},G=(t,u,l,n,c)=>{if(n<l){let p=n>=0?n:-n-2;if(p===-1)return p;const $=t[p].start+t[p].duration;for(;p>=0&&t[p].start+t[p].duration===$;)p--;return-p-2}const h=parseInt((l+n)/2),m=t[h].start+t[h].duration;if(m>u)return G(t,u,l,h-1,c);if(m<u)return G(t,u,h+1,n,c);{let p=h;if(c){for(;p>=0&&t[p].start+t[p].duration===u;)p--;p++}else{for(;p<t.length&&t[p].start+t[p].duration===u;)p++;p--}return p}},Y=(t,u,l=0)=>u*(t+l);function ie(){const t=O.useViewerStore(),{viewerChannels:u,viewerAnnotations:l,viewerMontageScheme:n}=te.storeToRefs(t),c=S.ref([]),h=S.ref([]),m=T=>{const f=n.value!=="NOT_MONTAGED";let e=O.propOr("","id",T);if(f){const o=e.split("_");e=o.length?ne.head(o):e}return e},p=async(T,f,e,o,d)=>{var r,v;if(!((r=o==null?void 0:o.content)!=null&&r.id)){console.warn("[useAnnotationData] checkAnnotationRange called with invalid activeViewer, skipping");return}if(!((v=t.config)!=null&&v.apiUrl)){console.warn("[useAnnotationData] checkAnnotationRange called without apiUrl config, skipping");return}if(typeof T!="number"||typeof e.tsEnd!="number"){console.warn("[useAnnotationData] checkAnnotationRange called with invalid time range, skipping");return}const a=[];a.push({start:T,end:e.tsEnd});let i=0;for(let s=0;s<c.value.length;s++){const y=c.value[s];if(T>=y.start&&f<=y.end)return;if(a[0].start>f)break;if(y.start<=a[0].start&&y.end>=T)i=s+1,a[0].start=y.end;else if(y.start>a[0].start){i=s;break}}const g=l.value.reduce((s,y)=>s+y.annotations.length,0);if(a[0].start>=a[0].end&&g>0)return;const w=0;for(let s=i;s<c.value.length;s++)if(c.value[s].start>=a[w].start)if(a[w].end=c.value[s].start,c.value[s].end<f)a.push({start:c.value[s].end,end:e.tsEnd});else break;if(!(a[0].start>=a[0].end&&g>0)&&a.length>0){u.value.map(s=>m(s));for(const s of a){for(const y of l.value){if(!y.id){console.warn("Layer ID is undefined, skipping annotation request for layer:",y);continue}const L=Math.floor(s.end),F={id:o.content.id,start:Math.floor(s.start),end:L,layerId:y.id,limit:e.constants.LIMITANNFETCH};try{const b=await O.useToken(),R=`${t.config.apiUrl}/timeseries/${o.content.id}/layers/${y.id}/annotations?api_key=${b}`,I=Object.keys(F).map(P=>`&${P}=${F[P]}`).join(""),M=`${R}${I}`,N=await fetch(M,{method:"GET",headers:{"Content-type":"application/json"}});if(N.status>=400)throw new Error(N.status);const q=await N.json();await $(q,d)}catch(b){O.useHandleXhrError(b)}}c.value.push({start:Math.floor(s.start),end:Math.floor(s.end)})}c.value.sort((s,y)=>s.start<y.start?-1:s.start>y.start?1:0)}},$=async(T,f)=>{const e=O.propOr({},"linkedPackages",T);let o=j.pathOr([],["annotations","results"],T);if(o.length>=500){let a=0;for(const i of o)i.start>a&&(a=i.start);for(const i of c.value)if(i.end>a&&i.start<a){i.end=a;break}}const d=n.value!=="NOT_MONTAGED";if(o.length>0){const a=o.map(i=>{const g={name:"",id:i.id,label:i.label,description:i.description,start:i.start,duration:i.end-i.start,end:i.end,cStart:null,cEnd:null,selected:!1,channelIds:i.channelIds,allChannels:!1,layer_id:i.layerId,userId:i.userId};if(i.linkedPackage){const w=i.linkedPackage;g.linkedPackage=j.pathOr("",["content","id"],e[w]),g.linkedPackageDTO=e[w]}return(!d&&g.channelIds.length===u.value.length||d&&g.channelIds.length>u.value.length)&&(g.allChannels=!0),g});l.value.forEach(i=>{const g=i.annotations,w=a.filter(r=>i.id===r.layer_id);i.annotations=g.concat(w),t.updateLayer(i)})}f("annotationsReceived")};return{cachedAnnRange:c,annLayerInfo:h,checkAnnotationRange:p,findNextAnnotation:T=>{const f=t.getViewerActiveLayer(),e=Q(f.annotations,T,!1);return e<f.annotations.length?f.annotations[e].start>T?f.annotations[e]:f.annotations[e+1]||f.annotations[e]:f.annotations[e]},findPreviousAnnotation:T=>{const f=t.getViewerActiveLayer(),e=Q(f.annotations,T,!0);return f.annotations[e].start<T?f.annotations[e]:e>0?f.annotations[e-1]:f.annotations[e]},getChannelId:m}}function re(){const t=O.useViewerStore(),{viewerAnnotations:u,viewerChannels:l}=te.storeToRefs(t),n=S.ref([]),c=S.ref([]),h=S.ref(null),m=S.ref(["#FFFF4E"]),p=(e,o)=>{var g,w;const a=(((g=o.constants)==null?void 0:g.ANNOTATIONLABELHEIGHT)||20)/2|0,i=((w=o.constants)==null?void 0:w.XOFFSET)||0;for(const r of e){let v=r.start,s=r.duration;r.duration<0&&(v=r.start+r.duration,s=-r.duration);const y=i+(v-o.start)/o.rsPeriod;if(r.cStart=y|0,r.duration!==0){const L=i+(v+s-o.start)/o.rsPeriod;r.cEnd=L|0}else r.cEnd=r.cStart+o.cWidth/40|0;if(r.allChannels)r.allOffsets=[a],r.cY=a;else{r.allOffsets=[],r.minOffset=o.cHeight|0,r.maxOffset=0;const L=l.value;for(const F of r.channelIds){let b=null;for(const C of L)if(C.id===F&&C.visible){b=C.rowBaseline|0,b<r.minOffset&&(r.minOffset=b),b>r.maxOffset&&(r.maxOffset=b),r.allOffsets.push(b);break}}c.value.indexOf(r.minOffset)<0&&c.value.push(r.minOffset),r.cY=r.minOffset}}},$=(e,o,d,a)=>{var w,r;const i=((w=d.constants)==null?void 0:w.ANNOTATIONLABELHEIGHT)||20,g=i/2|0;e.setTransform(d.pixelRatio,0,0,d.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 v of o){const s=K(v,u.value);v.selected&&(e.save(),e.strokeStyle=s.selColor,e.fillStyle=s.bkColor,e.lineWidth=1);const y=Math.round(v.cStart)+.5,L=Math.round(v.cEnd)+.5;v.allChannels?v.duration===0?(e.beginPath(),e.moveTo(y+1,i),e.lineTo(y,a),e.stroke()):(e.fillRect(y,i,L-y,a-i),e.beginPath(),e.moveTo(y,i),e.lineTo(y,a),e.moveTo(L,i),e.lineTo(L,a),e.stroke()):((r=v==null?void 0:v.channelIds)==null?void 0:r.length)===1?v.duration===0&&(e.beginPath(),e.moveTo(y,v.minOffset+g),e.lineTo(y,v.minOffset+g+8),e.stroke()):v.duration===0?(e.beginPath(),e.moveTo(y,v.minOffset+g),e.lineTo(y,v.maxOffset-g),e.stroke()):(e.fillRect(y-1,v.minOffset+g,L-y+1,v.maxOffset-v.minOffset-i),e.beginPath(),e.moveTo(y,v.minOffset+g),e.lineTo(y,v.maxOffset-g),e.moveTo(L,v.minOffset+g),e.lineTo(L,v.maxOffset-g),e.stroke()),v.selected&&e.restore()}e.restore()},D=async(e,o,d,a,i,g)=>{var v;const w=((v=d.constants)==null?void 0:v.ANNOTATIONLABELHEIGHT)||20,r=w/2|0;e.setTransform(d.pixelRatio,0,0,d.pixelRatio,0,0),e.save(),e.lineWidth=2,e.font="14px sans-serif",e.textAlign="left";for(const s of o){const y=K(s,u.value);if(s===h.value&&a)continue;s.selected?(e.fillStyle=y.selColor||"rgba(51,204,102, 0.8)",e.strokeStyle="white"):(e.fillStyle=y.color||"rgba(51,204,102,0.8)",e.strokeStyle=s===h.value?"white":"rgba(255,255,255,0.8)");const L=Math.round(s.cStart)+1,F=Math.round(s.cEnd);let b=0;for(let I=0;I<s.allOffsets.length;I++)e.fillRect(L-1,s.allOffsets[I]-r,F-L+2,w),s.allOffsets[I]===s.minOffset&&(b=I);const C=s.allOffsets[b];if(["annSelect","annResize-left","annResize-right"].includes(i)&&g==="annotate"&&(e.beginPath(),s.duration!==0&&(e.moveTo(F-3,C-r+3),e.lineTo(F-3,C+r-3)),e.moveTo(L+3,C-r+3),e.lineTo(L+3,C+r-3),e.stroke()),F-L>s.label.length*8+10){e.fillStyle=m.value.indexOf(y.hexColor)>=0?"black":"white";const I=s.linkedPackage?L+30:L+10,M=s.linkedPackage?C+r-r/2:C+r-6;e.fillText(s.label,I,M)}const R=s.linkedPackageDTO;R&&F-L>=30&&await k(e,R,L,C,r,w)}e.restore()},k=async(e,o,d,a,i,g)=>{const w=j.pathOr({},["objects","view",1,"content"],o),r=O.propOr("","fileType",w),v=new Image;if(r==="PNG"){const{id:s,packageId:y}=w,L=t.config.apiUrl;try{const F=await O.useToken();v.src=`${L}/packages/${y}/files/${s}/presign/?api_key=${F}`,v.complete?e.drawImage(v,d,a-i,27,g):v.addEventListener("load",()=>{e.drawImage(v,d,a-i,27,g)},{once:!0})}catch(F){console.error("Error loading image:",F)}}else v.src=T(),e.drawImage(v,d+5,a-i,20,20)},T=e=>"/path/to/default/icon.png";return{renderAnn:n,hoverOffsets:c,focusedAnn:h,render:(e,o,d,a)=>{var s,y,L,F;if(!o){console.warn("TSAnnotationCanvas: annotationsCanvas prop is undefined or null");return}const i=o.getContext("2d"),g=d.getContext("2d");i.setTransform(e.pixelRatio,0,0,e.pixelRatio,0,0),g.setTransform(e.pixelRatio,0,0,e.pixelRatio,0,0),c.value=[(((s=e.constants)==null?void 0:s.ANNOTATIONLABELHEIGHT)||20)/2],i.clearRect(0,0,e.cWidth,e.cHeight),g.clearRect(0,0,e.cWidth,e.cHeight),n.value=[];const w=e.duration&&e.duration>0?e.duration:15e6,r=e.start||0,v=r+w;console.log("🎨 Annotation render debug:",{start:r,duration:w,end:v,layerCount:((y=u.value)==null?void 0:y.length)||0,totalAnnotations:((L=u.value)==null?void 0:L.reduce((b,C)=>{var R;return b+(((R=C.annotations)==null?void 0:R.length)||0)},0))||0});for(const b of u.value)if(b.visible&&((F=b.annotations)==null?void 0:F.length)>0){console.log(`🔍 Processing layer "${b.name}" with ${b.annotations.length} annotations`);const C=b.annotations.filter(R=>{const I=R.start,M=R.end||R.start+(R.duration||0),N=I<v&&M>r;return N&&console.log(` ✅ Including annotation "${R.label}": ${I} - ${M}`),N});console.log(` 📊 Found ${C.length} annotations in viewport`),C.length>0&&(C.sort((R,I)=>R.start-I.start),n.value.push(...C))}if(console.log(`🎯 Total annotations to render: ${n.value.length}`),n.value.length===0){console.log("⚠️ No annotations found in viewport");return}ae(n.value),p(n.value,e),$(i,n.value,e,a),D(g,n.value,e,!0,e.pointerMode,e.viewerActiveTool),h.value&&D(g,[h.value],e,!1,e.pointerMode,e.viewerActiveTool),console.log(`✅ Rendered ${n.value.length} annotations successfully`)},computeRenderOptions:p,renderAnnotationAreas:$,renderAnnotationLabels:D}}function se(t,u,l){const n=O.useViewerStore(),c=S.ref([0,0]),h=(e,o)=>{const a=((o==null?void 0:o.ANNOTATIONLABELHEIGHT)||20)/2;for(const i of l.value)if(e>=i-a&&e<=i+a)return!0;return!1},m=(e,o,d)=>{var g;const i=((d==null?void 0:d.ANNOTATIONLABELHEIGHT)||20)/2;for(let w=0;w<(((g=u.value)==null?void 0:g.length)||0);w++){const r=u.value[w];if(r.cStart<e&&r.cEnd>e){if(o>r.cY-i&&o<r.cY+i)return w}else if(r.cStart>e)break}return null},p=(e,o,d)=>{if(!d)return o;switch(o){case"annotate":return e<=d.cStart+10?"annResize-left":e>=d.cEnd-10&&d.duration>0?"annResize-right":"annSelect";case"pointer":return"annSelect";default:return o}};return{mouseDownPosition:c,shouldCheckAnnotationHover:h,findAnnotationAtPosition:m,determinePointerMode:p,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?(n.setActiveAnnotation(t.value),!0):!1,onMouseDown:(e,o,d)=>{t.value&&["annResize-left","annResize-right"].includes(d)&&(t.value.oldStart=t.value.start,t.value.oldDuration=t.value.duration,c.value=[e,o])},onMouseMove:(e,o,d,a,i)=>{let g=d;if(a&&c.value){const w=(e-c.value[0])*i.rsPeriod;switch(d){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=h(o,i.constants);if(g=i.viewerActiveTool,w){const r=m(e,o,i.constants);if(r!==null){const v=t.value,s=u.value[r];(!v||e<t.value.cStart||e>t.value.cEnd)&&(t.value=s),g=p(e,i.viewerActiveTool,t.value)}else t.value=null}else t.value=null,g=i.viewerActiveTool}return g},onMouseUp:(e,o)=>{if(t.value&&["annResize-left","annResize-right"].includes(e)){if(t.value.duration<0){const d=-t.value.duration,a=t.value.start-d;t.value.start=a,t.value.duration=d,t.value.end=a+d}n.setActiveAnnotation(t.value),o("updateAnnotation",t.value)}}}}var U={exports:{}},Z;function le(){if(Z)return U.exports;Z=1;function t(){}return t.prototype={on:function(u,l,n){var c=this.e||(this.e={});return(c[u]||(c[u]=[])).push({fn:l,ctx:n}),this},once:function(u,l,n){var c=this;function h(){c.off(u,h),l.apply(n,arguments)}return h._=l,this.on(u,h,n)},emit:function(u){var l=[].slice.call(arguments,1),n=((this.e||(this.e={}))[u]||[]).slice(),c=0,h=n.length;for(c;c<h;c++)n[c].fn.apply(n[c].ctx,l);return this},off:function(u,l){var n=this.e||(this.e={}),c=n[u],h=[];if(c&&l)for(var m=0,p=c.length;m<p;m++)c[m].fn!==l&&c[m].fn._!==l&&h.push(c[m]);return h.length?n[u]=h:delete n[u],this}},U.exports=t,U.exports.TinyEmitter=t,U.exports}var z,x;function ce(){if(x)return z;x=1;var t=le();return z=new t,z}var ue=ce();const _=oe.getDefaultExportFromCjs(ue),ee={$emit:(...t)=>_.emit(...t),$on:(...t)=>_.on(...t),$off:(...t)=>_.off(...t),$once:(...t)=>_.once(...t)};function de(){const t=O.useViewerStore(),u=S.ref([]),l=S.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"]),n=async(k,T)=>{const f=[];if(k.results.length===0)await c({name:"Default",color:"#18BA62",description:"Default Annotation Layer"},null,T);else{for(let e=0;e<k.results.length;e++){const o=k.results[e];let d=o.color||l.value[e%l.value.length];const a={id:o.id,name:o.name,description:o.description,visible:!0,selected:e===0,annotations:[],color:H(d,.7),hexColor:d,bkColor:H(d,.15),selColor:H(d,.9)};f.push(a)}t.setAnnotations(f),T("annLayersInitialized")}u.value=k.results},c=async(k,T,f)=>{try{const e=await O.useToken(),o=`${t.config.apiUrl}/timeseries/${T.content.id}/layers?api_key=${e}`,d=await O.useSendXhr(o,{method:"POST",body:{name:k.name,color:k.color,description:k.description||k.name}}),a={...d,annotations:[],hexColor:d.color,color:H(d.color,.7),bkColor:H(d.color,.15),selColor:H(d.color,.9),visible:!0,selected:!0};return t.createLayer(a),t.setActiveAnnotationLayer(a.id),ee.$emit("toast",{detail:{msg:`'${a.name}' Layer Created`}}),a}catch(e){throw O.useHandleXhrError(e),e}finally{f&&f("closeAnnotationLayerWindow")}};return{annLayerInfo:u,defaultColors:l,initializeLayers:n,createAnnotationLayer:c,updateLayerVisibility:(k,T)=>{console.log(`[useAnnotationLayers] Updating layer ${k} visibility to:`,T);const f=t.viewerAnnotations.find(e=>e.id===k);if(f){console.log("[useAnnotationLayers] Found layer:",f.name,"current visible:",f.visible),f.visible=T,t.updateLayer(f),console.log("[useAnnotationLayers] Updated layer:",f.name,"new visible:",f.visible);const e=t.viewerAnnotations.find(o=>o.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(f=>{f.selected=!1,t.updateLayer(f)});const T=t.viewerAnnotations.find(f=>f.id===k);T&&(T.selected=!0,t.updateLayer(T),t.setActiveAnnotationLayer(k))},deleteLayer:async(k,T)=>{try{const f=await O.useToken(),e=`${t.config.apiUrl}/timeseries/${T.content.id}/layers/${k}?api_key=${f}`;await O.useSendXhr(e,{method:"DELETE"}),t.removeLayer(k),ee.$emit("toast",{detail:{msg:"Layer deleted successfully"}})}catch(f){throw O.useHandleXhrError(f),f}},updateLayerColor:async(k,T,f)=>{try{const e=await O.useToken(),o=`${t.config.apiUrl}/timeseries/${f.content.id}/layers/${k}?api_key=${e}`,d=await O.useSendXhr(o,{method:"PUT",body:{color:T}}),a=t.viewerAnnotations.find(i=>i.id===k);return a&&(a.hexColor=T,a.color=H(T,.7),a.bkColor=H(T,.15),a.selColor=H(T,.9),t.updateLayer(a)),d}catch(e){throw O.useHandleXhrError(e),e}},loadLayers:async(k,T)=>{var f,e;if(!((f=k==null?void 0:k.content)!=null&&f.id))return console.warn("[useAnnotationLayers] loadLayers called with invalid activeViewer, skipping"),null;if(!((e=t.config)!=null&&e.apiUrl))return console.warn("[useAnnotationLayers] loadLayers called without apiUrl config, skipping"),null;try{const o=await O.useToken(),d=`${t.config.apiUrl}/timeseries/${k.content.id}/layers?api_key=${o}`,a=await O.useSendXhr(d);return await n(a,T),a}catch(o){throw O.useHandleXhrError(o),o}}}}const fe=["width","height"],ve={__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:l}){const n=t,c=l,h=S.ref(null),{checkAnnotationRange:m,findNextAnnotation:p,findPreviousAnnotation:$}=ie(),{renderAnn:D,hoverOffsets:k,focusedAnn:T,render:f}=re(),{resetFocusedAnnotation:e,selectFocusedAnnotation:o,onMouseDown:d,onMouseMove:a,onMouseUp:i}=se(T,D,k),{createAnnotationLayer:g,loadLayers:w}=de(),r=S.computed(()=>n.cHeight-20),v=S.computed(()=>({width:n.cWidth+"px",height:r.value+"px"})),s=()=>{f(n,n.annotationsCanvas,h.value,r.value)},y=(E,A)=>{d(E,A,n.pointerMode)},L=(E,A,X,B)=>a(E,A,X,B,n),F=()=>{i(n.pointerMode,c)},b=()=>{o()&&S.nextTick(()=>s())},C=async E=>{try{await g(E,n.activeViewer,c)}catch(A){console.error("Error creating layer:",A)}},R=E=>{var A;return((A=E==null?void 0:E.content)==null?void 0:A.id)!=null},I=()=>typeof n.start=="number"&&typeof n.tsEnd=="number"&&n.tsEnd>0,M=S.ref(!1),N=S.ref(null),q=async E=>{if(!R(E))return console.log("[TSAnnotationCanvas] Waiting for activeViewer to be ready..."),!1;if(N.value!==E.content.id&&(M.value=!1,N.value=E.content.id),M.value)return!0;console.log("[TSAnnotationCanvas] activeViewer ready, loading layers");try{const A=await w(E,c);return M.value=!!A,M.value}catch(A){return console.error("[TSAnnotationCanvas] Error loading layers:",A),!1}},P=async()=>{if(!M.value){console.log("[TSAnnotationCanvas] Layers not loaded yet, skipping annotation fetch");return}if(!I()){console.log("[TSAnnotationCanvas] Time range not ready yet, skipping annotation fetch");return}console.log("[TSAnnotationCanvas] Fetching annotations for time range:",{start:n.start,end:n.start+n.duration,tsEnd:n.tsEnd});try{await m(n.start,n.start+n.duration,n,n.activeViewer,c)}catch(E){console.error("[TSAnnotationCanvas] Error fetching annotations:",E)}};return S.watch(()=>n.activeViewer,async(E,A)=>{var B,V,J;if(((B=A==null?void 0:A.content)==null?void 0:B.id)===((V=E==null?void 0:E.content)==null?void 0:V.id)&&((J=A==null?void 0:A.content)==null?void 0:J.id)!=null)return;await q(E)&&await P()},{immediate:!0,deep:!0}),S.watch(()=>n.tsEnd,async(E,A)=>{typeof E=="number"&&E>0&&A!==E&&(console.log("[TSAnnotationCanvas] tsEnd became valid:",E),await P())}),S.onMounted(()=>{console.log("TSAnnotationCanvas mounted with props:",{constants:n.constants,annotationsCanvas:n.annotationsCanvas,viewerActiveTool:n.viewerActiveTool,activeViewerReady:R(n.activeViewer),timeRangeReady:I()})}),u({render:s,resetFocusedAnnotation:e,findNextAnnotation:p,findPreviousAnnotation:$,checkAnnotationRange:(E,A)=>m(E,A,n,n.activeViewer,c),selectFocusedAnn:b,createAnnotationLayer:C,onMouseDown:y,onMouseMove:L,onMouseUp:F}),(E,A)=>(S.openBlock(),S.createElementBlock("canvas",{id:"annLabelArea",ref_key:"annLabelArea",ref:h,class:"timeseries-annotation-canvas",width:S.unref(Y)(t.cWidth,t.pixelRatio,0),height:S.unref(Y)(r.value,t.pixelRatio,0),style:S.normalizeStyle(v.value)},null,12,fe))}},he=O._export_sfc(ve,[["__scopeId","data-v-e9cfe856"]]);exports.default=he;