@pennsieve-viz/tsviewer 1.1.8 → 1.1.11
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/{BFLibraryButton-C4Qf41ZT.js → BFLibraryButton-Dyws9SHi.js} +1 -1
- package/dist/{BFLibraryButton-C6YzWgSm.cjs → BFLibraryButton-xRreF1qz.cjs} +1 -1
- package/dist/{IconSelection-BfKnIyCb.js → IconSelection-BXkQ-HI2.js} +1 -1
- package/dist/{IconSelection-BLdXAFk4.cjs → IconSelection-Cu7rNGza.cjs} +1 -1
- package/dist/TSAnnotationCanvas-DT1-oLwQ.cjs +1 -0
- package/dist/TSAnnotationCanvas-vq4ZhQlM.js +664 -0
- package/dist/{TSAnnotationModal-BBy9rkSA.js → TSAnnotationModal-BIihkWMN.js} +26 -27
- package/dist/TSAnnotationModal-yiS6Inu7.cjs +1 -0
- package/dist/TSFilterModal-B9DK2z2R.cjs +1 -0
- package/dist/{TSFilterModal-kDMqmLS2.js → TSFilterModal-Bg3Vl8ld.js} +27 -25
- package/dist/TSScrubber-CRfsVW3j.cjs +1 -0
- package/dist/{TSScrubber-BjZdeFW5.js → TSScrubber-Dz4oujge.js} +86 -89
- package/dist/TSViewerCanvas-5xGT95ay.cjs +11 -0
- package/dist/{TSViewerCanvas-BuVBKlJg.js → TSViewerCanvas-B-uFOBba.js} +1820 -1818
- package/dist/{TSViewerLayerWindow-CU931eio.js → TSViewerLayerWindow-Ch0_2TBh.js} +2 -2
- package/dist/{TSViewerLayerWindow-Dl2HBUyy.cjs → TSViewerLayerWindow-yUINAqI2.cjs} +1 -1
- package/dist/{TSViewerToolbar-DzRRLMAi.js → TSViewerToolbar-BzM9uh9P.js} +23 -24
- package/dist/{TSViewerToolbar-O0RTcnw4.cjs → TSViewerToolbar-WhD8V4Ex.cjs} +1 -1
- package/dist/{TsAnnotationDeleteDialog--CeuCWdi.js → TsAnnotationDeleteDialog-2EHUvGW1.js} +9 -10
- package/dist/TsAnnotationDeleteDialog-CLRHSeYL.cjs +1 -0
- package/dist/index-CQTgJYdx.cjs +1 -0
- package/dist/index-qrig8S0H.js +1533 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/TSAnnotationCanvas-CSMTQ0aZ.cjs +0 -1
- package/dist/TSAnnotationCanvas-R9hz-n3c.js +0 -729
- package/dist/TSAnnotationModal-BO85lGbd.cjs +0 -1
- package/dist/TSFilterModal-CFDnl3ES.cjs +0 -1
- package/dist/TSScrubber-BXvg3kEO.cjs +0 -1
- package/dist/TSViewerCanvas-DtBpcQRc.cjs +0 -11
- package/dist/TsAnnotationDeleteDialog-CPmqoXC4.cjs +0 -1
- package/dist/_commonjsHelpers-DKOUU3wS.cjs +0 -1
- package/dist/_commonjsHelpers-DaMA6jEr.js +0 -8
- package/dist/index-Cy2YDlTe.js +0 -1418
- package/dist/index-D6kWXmu_.cjs +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
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-
|
|
2
|
+
import { g as d } from "./index-qrig8S0H.js";
|
|
3
3
|
const c = {
|
|
4
4
|
name: "BfLibraryButton",
|
|
5
5
|
props: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),r=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),r=require("./index-CQTgJYdx.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 +1 @@
|
|
|
1
|
-
"use strict";const t=require("vue"),o=require("./index-
|
|
1
|
+
"use strict";const t=require("vue"),o=require("./index-CQTgJYdx.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 b=require("vue"),S=require("./index-CQTgJYdx.cjs"),j=require("pinia"),z=require("./TSViewerCanvas-5xGT95ay.cjs"),A=(t,s)=>{let h;if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(t))return h=t.substring(1).split(""),h.length===3&&(h=[h[0],h[0],h[1],h[1],h[2],h[2]]),h="0x"+h.join(""),"rgba("+[h>>16&255,h>>8&255,h&255].join(",")+","+s+")";throw new Error("Bad Hex")},G=t=>{t.sort((s,h)=>s.start<h.start?-1:s.start>h.start?1:0)},B=(t,s)=>{const h=(t==null?void 0:t.layer_id)||0;return S.defaultTo({},z.find(S.propEq("id",h),s))},_=(t,s,h,c=0,y=!1)=>{let d;return y?d=D(t,s,c,t.length-1,h):d=P(t,s,c,t.length-1,h),d===-1?d=0:d<0&&(d=-d-2),d},P=(t,s,h,c,y)=>{if(c<h){let T=c>=0?c:-c-2;if(T===-1)return T;const k=t[T].start;for(;T>=0&&t[T].start===k;)T--;return-T-2}const d=parseInt((h+c)/2);if(t[d].start>s)return P(t,s,h,d-1,y);if(t[d].start<s)return P(t,s,d+1,c,y);{let T=d;if(y){for(;T>=0&&t[T].start===s;)T--;T++}else{for(;T<t.length&&t[T].start===s;)T++;T--}return T}},D=(t,s,h,c,y)=>{if(c<h){let k=c>=0?c:-c-2;if(k===-1)return k;const M=t[k].start+t[k].duration;for(;k>=0&&t[k].start+t[k].duration===M;)k--;return-k-2}const d=parseInt((h+c)/2),T=t[d].start+t[d].duration;if(T>s)return D(t,s,h,d-1,y);if(T<s)return D(t,s,d+1,c,y);{let k=d;if(y){for(;k>=0&&t[k].start+t[k].duration===s;)k--;k++}else{for(;k<t.length&&t[k].start+t[k].duration===s;)k++;k--}return k}},U=(t,s,h=0)=>s*(t+h);function W(t=null){const s=t||b.inject("viewerStore",null)||S.createViewerStore("default"),{viewerChannels:h,viewerAnnotations:c,viewerMontageScheme:y}=j.storeToRefs(s),d=b.ref([]),T=b.ref([]),k=v=>{const u=y.value!=="NOT_MONTAGED";let e=S.propOr("","id",v);if(u){const a=e.split("_");e=a.length?z.head(a):e}return e},M=async(v,u,e,a,l)=>{const i=[];i.push({start:v,end:e.tsEnd});let o=0;for(let n=0;n<d.value.length;n++){const r=d.value[n];if(v>=r.start&&u<=r.end)return;if(i[0].start>u)break;if(r.start<=i[0].start&&r.end>=v)o=n+1,i[0].start=r.end;else if(r.start>i[0].start){o=n;break}}const f=c.value.reduce((n,r)=>n+r.annotations.length,0);if(i[0].start>=i[0].end&&f>0)return;const g=0;for(let n=o;n<d.value.length;n++)if(d.value[n].start>=i[g].start)if(i[g].end=d.value[n].start,d.value[n].end<u)i.push({start:d.value[n].end,end:e.tsEnd});else break;if(!(i[0].start>=i[0].end&&f>0)&&i.length>0){h.value.map(n=>k(n));for(const n of i){for(const r of c.value){if(!r.id){console.warn("Layer ID is undefined, skipping annotation request for layer:",r);continue}const w=Math.floor(n.end),E={id:a.content.id,start:Math.floor(n.start),end:w,layerId:r.id,limit:e.constants.LIMITANNFETCH};try{const m=await S.useToken(),p=`${s.config.apiUrl}/timeseries/${a.content.id}/layers/${r.id}/annotations?api_key=${m}`,L=Object.keys(E).map($=>`&${$}=${E[$]}`).join(""),C=`${p}${L}`,I=await fetch(C,{method:"GET",headers:{"Content-type":"application/json"}});if(I.status>=400)throw new Error(I.status);const H=await I.json();await R(H,l)}catch(m){S.useHandleXhrError(m)}}d.value.push({start:Math.floor(n.start),end:Math.floor(n.end)})}d.value.sort((n,r)=>n.start<r.start?-1:n.start>r.start?1:0)}},R=async(v,u)=>{const e=S.propOr({},"linkedPackages",v);let a=S.pathOr([],["annotations","results"],v);if(a.length>=500){let i=0;for(const o of a)o.start>i&&(i=o.start);for(const o of d.value)if(o.end>i&&o.start<i){o.end=i;break}}const l=y.value!=="NOT_MONTAGED";if(a.length>0){const i=a.map(o=>{const f={name:"",id:o.id,label:o.label,description:o.description,start:o.start,duration:o.end-o.start,end:o.end,cStart:null,cEnd:null,selected:!1,channelIds:o.channelIds,allChannels:!1,layer_id:o.layerId,userId:o.userId};if(o.linkedPackage){const g=o.linkedPackage;f.linkedPackage=S.pathOr("",["content","id"],e[g]),f.linkedPackageDTO=e[g]}return(!l&&f.channelIds.length===h.value.length||l&&f.channelIds.length>h.value.length)&&(f.allChannels=!0),f});c.value.forEach(o=>{const f=o.annotations,g=i.filter(n=>o.id===n.layer_id);o.annotations=f.concat(g),s.updateLayer(o)})}u("annotationsReceived")};return{cachedAnnRange:d,annLayerInfo:T,checkAnnotationRange:M,findNextAnnotation:v=>{const u=s.getViewerActiveLayer(),e=_(u.annotations,v,!1);return e<u.annotations.length?u.annotations[e].start>v?u.annotations[e]:u.annotations[e+1]||u.annotations[e]:u.annotations[e]},findPreviousAnnotation:v=>{const u=s.getViewerActiveLayer(),e=_(u.annotations,v,!0);return u.annotations[e].start<v?u.annotations[e]:e>0?u.annotations[e-1]:u.annotations[e]},getChannelId:k}}function q(t=null){const s=t||b.inject("viewerStore",null)||S.createViewerStore("default"),{viewerAnnotations:h,viewerChannels:c}=j.storeToRefs(s),y=b.ref([]),d=b.ref([]),T=b.ref(null),k=b.ref(["#FFFF4E"]),M=(e,a)=>{var f,g;const i=(((f=a.constants)==null?void 0:f.ANNOTATIONLABELHEIGHT)||20)/2|0,o=((g=a.constants)==null?void 0:g.XOFFSET)||0;for(const n of e){let r=n.start,w=n.duration;n.duration<0&&(r=n.start+n.duration,w=-n.duration);const E=o+(r-a.start)/a.rsPeriod;if(n.cStart=E|0,n.duration!==0){const m=o+(r+w-a.start)/a.rsPeriod;n.cEnd=m|0}else n.cEnd=n.cStart+a.cWidth/40|0;if(n.allChannels)n.allOffsets=[i],n.cY=i;else{n.allOffsets=[],n.minOffset=a.cHeight|0,n.maxOffset=0;const m=c.value;for(const F of n.channelIds){let p=null;for(const L of m)if(L.id===F&&L.visible){p=L.rowBaseline|0,p<n.minOffset&&(n.minOffset=p),p>n.maxOffset&&(n.maxOffset=p),n.allOffsets.push(p);break}}d.value.indexOf(n.minOffset)<0&&d.value.push(n.minOffset),n.cY=n.minOffset}}},R=(e,a,l,i)=>{var g,n;const o=((g=l.constants)==null?void 0:g.ANNOTATIONLABELHEIGHT)||20,f=o/2|0;e.setTransform(l.pixelRatio,0,0,l.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 r of a){const w=B(r,h.value);r.selected&&(e.save(),e.strokeStyle=w.selColor,e.fillStyle=w.bkColor,e.lineWidth=1);const E=Math.round(r.cStart)+.5,m=Math.round(r.cEnd)+.5;r.allChannels?r.duration===0?(e.beginPath(),e.moveTo(E+1,o),e.lineTo(E,i),e.stroke()):(e.fillRect(E,o,m-E,i-o),e.beginPath(),e.moveTo(E,o),e.lineTo(E,i),e.moveTo(m,o),e.lineTo(m,i),e.stroke()):((n=r==null?void 0:r.channelIds)==null?void 0:n.length)===1?r.duration===0&&(e.beginPath(),e.moveTo(E,r.minOffset+f),e.lineTo(E,r.minOffset+f+8),e.stroke()):r.duration===0?(e.beginPath(),e.moveTo(E,r.minOffset+f),e.lineTo(E,r.maxOffset-f),e.stroke()):(e.fillRect(E-1,r.minOffset+f,m-E+1,r.maxOffset-r.minOffset-o),e.beginPath(),e.moveTo(E,r.minOffset+f),e.lineTo(E,r.maxOffset-f),e.moveTo(m,r.minOffset+f),e.lineTo(m,r.maxOffset-f),e.stroke()),r.selected&&e.restore()}e.restore()},N=async(e,a,l,i,o,f)=>{var r;const g=((r=l.constants)==null?void 0:r.ANNOTATIONLABELHEIGHT)||20,n=g/2|0;e.setTransform(l.pixelRatio,0,0,l.pixelRatio,0,0),e.save(),e.lineWidth=2,e.font="14px sans-serif",e.textAlign="left";for(const w of a){const E=B(w,h.value);if(w===T.value&&i)continue;w.selected?(e.fillStyle=E.selColor||"rgba(51,204,102, 0.8)",e.strokeStyle="white"):(e.fillStyle=E.color||"rgba(51,204,102,0.8)",e.strokeStyle=w===T.value?"white":"rgba(255,255,255,0.8)");const m=Math.round(w.cStart)+1,F=Math.round(w.cEnd);let p=0;for(let I=0;I<w.allOffsets.length;I++)e.fillRect(m-1,w.allOffsets[I]-n,F-m+2,g),w.allOffsets[I]===w.minOffset&&(p=I);const L=w.allOffsets[p];if(["annSelect","annResize-left","annResize-right"].includes(o)&&f==="annotate"&&(e.beginPath(),w.duration!==0&&(e.moveTo(F-3,L-n+3),e.lineTo(F-3,L+n-3)),e.moveTo(m+3,L-n+3),e.lineTo(m+3,L+n-3),e.stroke()),F-m>w.label.length*8+10){e.fillStyle=k.value.indexOf(E.hexColor)>=0?"black":"white";const I=w.linkedPackage?m+30:m+10,H=w.linkedPackage?L+n-n/2:L+n-6;e.fillText(w.label,I,H)}const C=w.linkedPackageDTO;C&&F-m>=30&&await O(e,C,m,L,n,g)}e.restore()},O=async(e,a,l,i,o,f)=>{const g=S.pathOr({},["objects","view",1,"content"],a),n=S.propOr("","fileType",g),r=new Image;if(n==="PNG"){const{id:w,packageId:E}=g,m=s.config.apiUrl;try{const F=await S.useToken();r.src=`${m}/packages/${E}/files/${w}/presign/?api_key=${F}`,r.complete?e.drawImage(r,l,i-o,27,f):r.addEventListener("load",()=>{e.drawImage(r,l,i-o,27,f)},{once:!0})}catch(F){console.error("Error loading image:",F)}}else r.src=v(),e.drawImage(r,l+5,i-o,20,20)},v=e=>"/path/to/default/icon.png";return{renderAnn:y,hoverOffsets:d,focusedAnn:T,render:(e,a,l,i)=>{var w,E;if(!a){console.warn("TSAnnotationCanvas: annotationsCanvas prop is undefined or null");return}const o=a.getContext("2d"),f=l.getContext("2d");o.setTransform(e.pixelRatio,0,0,e.pixelRatio,0,0),f.setTransform(e.pixelRatio,0,0,e.pixelRatio,0,0),d.value=[(((w=e.constants)==null?void 0:w.ANNOTATIONLABELHEIGHT)||20)/2],o.clearRect(0,0,e.cWidth,e.cHeight),f.clearRect(0,0,e.cWidth,e.cHeight),y.value=[];const g=e.duration&&e.duration>0?e.duration:15e6,n=e.start||0,r=n+g;for(const m of h.value)if(m.visible&&((E=m.annotations)==null?void 0:E.length)>0){const F=m.annotations.filter(p=>{const L=p.start,C=p.end||p.start+(p.duration||0);return L<r&&C>n});F.length>0&&(F.sort((p,L)=>p.start-L.start),y.value.push(...F))}y.value.length!==0&&(G(y.value),M(y.value,e),R(o,y.value,e,i),N(f,y.value,e,!0,e.pointerMode,e.viewerActiveTool),T.value&&N(f,[T.value],e,!1,e.pointerMode,e.viewerActiveTool))},computeRenderOptions:M,renderAnnotationAreas:R,renderAnnotationLabels:N}}function X(t,s,h,c=null){const y=c||b.inject("viewerStore",null)||S.createViewerStore("default"),d=b.ref([0,0]),T=(e,a)=>{const i=((a==null?void 0:a.ANNOTATIONLABELHEIGHT)||20)/2;for(const o of h.value)if(e>=o-i&&e<=o+i)return!0;return!1},k=(e,a,l)=>{var f;const o=((l==null?void 0:l.ANNOTATIONLABELHEIGHT)||20)/2;for(let g=0;g<(((f=s.value)==null?void 0:f.length)||0);g++){const n=s.value[g];if(n.cStart<e&&n.cEnd>e){if(a>n.cY-o&&a<n.cY+o)return g}else if(n.cStart>e)break}return null},M=(e,a,l)=>{if(!l)return a;switch(a){case"annotate":return e<=l.cStart+10?"annResize-left":e>=l.cEnd-10&&l.duration>0?"annResize-right":"annSelect";case"pointer":return"annSelect";default:return a}};return{mouseDownPosition:d,shouldCheckAnnotationHover:T,findAnnotationAtPosition:k,determinePointerMode:M,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?(y.setActiveAnnotation(t.value),!0):!1,onMouseDown:(e,a,l)=>{t.value&&["annResize-left","annResize-right"].includes(l)&&(t.value.oldStart=t.value.start,t.value.oldDuration=t.value.duration,d.value=[e,a])},onMouseMove:(e,a,l,i,o)=>{let f=l;if(i&&d.value){const g=(e-d.value[0])*o.rsPeriod;switch(l){case"annResize-left":t.value.oldDuration>0?(t.value.start=t.value.oldStart+g,t.value.duration=t.value.oldDuration-g,t.value.end=t.value.start+t.value.duration):t.value.start=t.value.oldStart+g;break;case"annResize-right":t.value.duration=t.value.oldDuration+g,t.value.end=t.value.start+t.value.duration;break}}else{const g=T(a,o.constants);if(f=o.viewerActiveTool,g){const n=k(e,a,o.constants);if(n!==null){const r=t.value,w=s.value[n];(!r||e<t.value.cStart||e>t.value.cEnd)&&(t.value=w),f=M(e,o.viewerActiveTool,t.value)}else t.value=null}else t.value=null,f=o.viewerActiveTool}return f},onMouseUp:(e,a)=>{if(t.value&&["annResize-left","annResize-right"].includes(e)){if(t.value.duration<0){const l=-t.value.duration,i=t.value.start-l;t.value.start=i,t.value.duration=l,t.value.end=i+l}y.setActiveAnnotation(t.value),a("updateAnnotation",t.value)}}}}function J(t=null){const s=t||b.inject("viewerStore",null)||S.createViewerStore("default"),h=b.ref([]),c=b.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"]),y=async(O,v)=>{const u=[];if(O.results.length===0)await d({name:"Default",color:"#18BA62",description:"Default Annotation Layer"},null,v);else{for(let e=0;e<O.results.length;e++){const a=O.results[e];let l=a.color||c.value[e%c.value.length];const i={id:a.id,name:a.name,description:a.description,visible:!0,selected:e===0,annotations:[],color:A(l,.7),hexColor:l,bkColor:A(l,.15),selColor:A(l,.9)};u.push(i)}s.setAnnotations(u),v("annLayersInitialized")}h.value=O.results},d=async(O,v,u)=>{var e;if(!((e=v==null?void 0:v.content)!=null&&e.id))return null;try{const a=await S.useToken(),l=`${s.config.apiUrl}/timeseries/${v.content.id}/layers?api_key=${a}`,i=await S.useSendXhr(l,{method:"POST",body:{name:O.name,color:O.color,description:O.description||O.name}}),o={...i,annotations:[],hexColor:i.color,color:A(i.color,.7),bkColor:A(i.color,.15),selColor:A(i.color,.9),visible:!0,selected:!0};return s.createLayer(o),s.setActiveAnnotationLayer(o.id),S.EventBus.$emit("toast",{detail:{msg:`'${o.name}' Layer Created`}}),o}catch(a){throw S.useHandleXhrError(a),a}finally{u&&u("closeAnnotationLayerWindow")}};return{annLayerInfo:h,defaultColors:c,initializeLayers:y,createAnnotationLayer:d,updateLayerVisibility:(O,v)=>{const u=s.viewerAnnotations.find(e=>e.id===O);u&&(u.visible=v,s.updateLayer(u))},selectLayer:O=>{s.viewerAnnotations.forEach(u=>{u.selected=!1,s.updateLayer(u)});const v=s.viewerAnnotations.find(u=>u.id===O);v&&(v.selected=!0,s.updateLayer(v),s.setActiveAnnotationLayer(O))},deleteLayer:async(O,v)=>{var u;if(!((u=v==null?void 0:v.content)!=null&&u.id))return null;try{const e=await S.useToken(),a=`${s.config.apiUrl}/timeseries/${v.content.id}/layers/${O}?api_key=${e}`;await S.useSendXhr(a,{method:"DELETE"}),s.removeLayer(O),S.EventBus.$emit("toast",{detail:{msg:"Layer deleted successfully"}})}catch(e){throw S.useHandleXhrError(e),e}},updateLayerColor:async(O,v,u)=>{var e;if(!((e=u==null?void 0:u.content)!=null&&e.id))return null;try{const a=await S.useToken(),l=`${s.config.apiUrl}/timeseries/${u.content.id}/layers/${O}?api_key=${a}`,i=await S.useSendXhr(l,{method:"PUT",body:{color:v}}),o=s.viewerAnnotations.find(f=>f.id===O);return o&&(o.hexColor=v,o.color=A(v,.7),o.bkColor=A(v,.15),o.selColor=A(v,.9),s.updateLayer(o)),i}catch(a){throw S.useHandleXhrError(a),a}},loadLayers:async(O,v)=>{var u;if(!((u=O==null?void 0:O.content)!=null&&u.id))return null;try{const e=await S.useToken(),a=`${s.config.apiUrl}/timeseries/${O.content.id}/layers?api_key=${e}`,l=await S.useSendXhr(a);return await y(l,v),l}catch(e){throw S.useHandleXhrError(e),e}}}}const K=["width","height"],Q={__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:s,emit:h}){const c=t,y=h,d=b.ref(null),{checkAnnotationRange:T,findNextAnnotation:k,findPreviousAnnotation:M}=W(),{renderAnn:R,hoverOffsets:N,focusedAnn:O,render:v}=q(),{resetFocusedAnnotation:u,selectFocusedAnnotation:e,onMouseDown:a,onMouseMove:l,onMouseUp:i}=X(O,R,N),{createAnnotationLayer:o,loadLayers:f}=J(),g=b.computed(()=>c.cHeight-20),n=b.computed(()=>({width:c.cWidth+"px",height:g.value+"px"})),r=()=>{v(c,c.annotationsCanvas,d.value,g.value)},w=(L,C)=>{a(L,C,c.pointerMode)},E=(L,C,I,H)=>l(L,C,I,H,c),m=()=>{i(c.pointerMode,y)},F=()=>{e()&&(y("updateAnnotation",O.value),b.nextTick(()=>r()))},p=async L=>{try{await o(L,c.activeViewer,y)}catch(C){console.error("Error creating layer:",C)}};return b.watch(()=>c.activeViewer,async L=>{try{await f(L,y),await T(c.start,c.start+c.duration,c,L,y)}catch(C){console.error("Error loading annotations for new viewer:",C)}}),b.onMounted(async()=>{try{await f(c.activeViewer,y),await T(c.start,c.start+c.duration,c,c.activeViewer,y)}catch(L){console.error("Error initializing annotations:",L)}}),s({render:r,resetFocusedAnnotation:u,findNextAnnotation:k,findPreviousAnnotation:M,checkAnnotationRange:(L,C)=>T(L,C,c,c.activeViewer,y),selectFocusedAnn:F,createAnnotationLayer:p,onMouseDown:w,onMouseMove:E,onMouseUp:m}),(L,C)=>(b.openBlock(),b.createElementBlock("canvas",{id:"annLabelArea",ref_key:"annLabelArea",ref:d,class:"timeseries-annotation-canvas",width:b.unref(U)(t.cWidth,t.pixelRatio,0),height:b.unref(U)(g.value,t.pixelRatio,0),style:b.normalizeStyle(n.value)},null,12,K))}},Y=S._export_sfc(Q,[["__scopeId","data-v-12912242"]]);exports.default=Y;
|