@pennsieve-viz/tsviewer 1.1.1 → 1.1.2

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 (35) hide show
  1. package/dist/{BFLibraryButton-zWDUe3E8.cjs → BFLibraryButton-ClRfrYOf.cjs} +1 -1
  2. package/dist/{BFLibraryButton-DEY9t1Is.js → BFLibraryButton-DzzWe3Ya.js} +1 -1
  3. package/dist/{IconSelection-IJR6hdts.js → IconSelection-Bnm4c-Az.js} +1 -1
  4. package/dist/{IconSelection-DsOecTVD.cjs → IconSelection-CYX2jlGW.cjs} +1 -1
  5. package/dist/TSAnnotationCanvas-BCu7PmSh.cjs +1 -0
  6. package/dist/TSAnnotationCanvas-Cua-lW6X.js +704 -0
  7. package/dist/{TSAnnotationModal-DpLHrHfV.js → TSAnnotationModal-7GxnJomu.js} +3 -3
  8. package/dist/{TSAnnotationModal-DkLaOB7u.cjs → TSAnnotationModal-BVDkiUQ1.cjs} +1 -1
  9. package/dist/{TSFilterModal-C1-o1zyF.js → TSFilterModal-1E2UWL8T.js} +3 -3
  10. package/dist/{TSFilterModal-DsVcUoIk.cjs → TSFilterModal-BVfwi0tb.cjs} +1 -1
  11. package/dist/TSScrubber-CBKcwuMb.js +374 -0
  12. package/dist/TSScrubber-DBWjIhSE.cjs +1 -0
  13. package/dist/{TSViewerCanvas-A6HgBZ4E.js → TSViewerCanvas-D_RaJ4Mj.js} +1865 -1931
  14. package/dist/TSViewerCanvas-gjfcQXDY.cjs +11 -0
  15. package/dist/{TSViewerLayerWindow-Dnij6c3F.js → TSViewerLayerWindow-COWXfHNB.js} +2 -2
  16. package/dist/{TSViewerLayerWindow-Cu8yQKRU.cjs → TSViewerLayerWindow-D5j3_B1E.cjs} +1 -1
  17. package/dist/{TSViewerToolbar-CO68rvXF.js → TSViewerToolbar-Cb2W7W6J.js} +1 -1
  18. package/dist/{TSViewerToolbar-_NqUlS08.cjs → TSViewerToolbar-ep_lZr6h.cjs} +1 -1
  19. package/dist/{TsAnnotationDeleteDialog-D9eQGzqE.js → TsAnnotationDeleteDialog-B9pQMYZo.js} +3 -3
  20. package/dist/{TsAnnotationDeleteDialog-fM5Y7SRB.cjs → TsAnnotationDeleteDialog-BRIgCXxU.cjs} +1 -1
  21. package/dist/index-BU6e_1Ww.js +1414 -0
  22. package/dist/index-C-i9Taq7.cjs +1 -0
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +1 -1
  25. package/dist/{pathOr-DKv8SMY9.cjs → pathOr-BQgOyNsu.cjs} +1 -1
  26. package/dist/{pathOr-kR7j_Y-C.js → pathOr-Dr8GvKXg.js} +1 -1
  27. package/dist/style.css +1 -1
  28. package/package.json +1 -1
  29. package/dist/TSAnnotationCanvas-B0b_EheO.js +0 -730
  30. package/dist/TSAnnotationCanvas-Bfxc75PD.cjs +0 -1
  31. package/dist/TSScrubber-9ABMW6b2.js +0 -377
  32. package/dist/TSScrubber-BlHHGh3F.cjs +0 -1
  33. package/dist/TSViewerCanvas-DBpG0Erk.cjs +0 -11
  34. package/dist/index-CMJlEiLT.cjs +0 -1
  35. package/dist/index-CgKUmS0K.js +0 -1459
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("vue"),b=require("./index-CMJlEiLT.cjs"),J=require("pinia"),K=require("./TSViewerCanvas-DBpG0Erk.cjs"),_=require("./pathOr-DKv8SMY9.cjs"),Q=require("./_commonjsHelpers-DKOUU3wS.cjs"),M=(t,o)=>{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(",")+","+o+")";throw new Error("Bad Hex")},Y=t=>{t.sort((o,c)=>o.start<c.start?-1:o.start>c.start?1:0)},j=(t,o)=>{const c=(t==null?void 0:t.layer_id)||0;return b.defaultTo({},K.find(b.propEq("id",c),o))},q=(t,o,c,a=0,f=!1)=>{let u;return f?u=U(t,o,a,t.length-1,c):u=V(t,o,a,t.length-1,c),u===-1?u=0:u<0&&(u=-u-2),u},V=(t,o,c,a,f)=>{if(a<c){let g=a>=0?a:-a-2;if(g===-1)return g;const T=t[g].start;for(;g>=0&&t[g].start===T;)g--;return-g-2}const u=parseInt((c+a)/2);if(t[u].start>o)return V(t,o,c,u-1,f);if(t[u].start<o)return V(t,o,u+1,a,f);{let g=u;if(f){for(;g>=0&&t[g].start===o;)g--;g++}else{for(;g<t.length&&t[g].start===o;)g++;g--}return g}},U=(t,o,c,a,f)=>{if(a<c){let T=a>=0?a:-a-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 u=parseInt((c+a)/2),g=t[u].start+t[u].duration;if(g>o)return U(t,o,c,u-1,f);if(g<o)return U(t,o,u+1,a,f);{let T=u;if(f){for(;T>=0&&t[T].start+t[T].duration===o;)T--;T++}else{for(;T<t.length&&t[T].start+t[T].duration===o;)T++;T--}return T}},z=(t,o,c=0)=>o*(t+c);function Z(t=null){const o=t||S.inject("viewerStore",null)||b.createViewerStore("default"),{viewerChannels:c,viewerAnnotations:a,viewerMontageScheme:f}=J.storeToRefs(o),u=S.ref([]),g=S.ref([]),T=w=>{const d=f.value!=="NOT_MONTAGED";let e=b.propOr("","id",w);if(d){const l=e.split("_");e=l.length?K.head(l):e}return e},I=async(w,d,e,l,v)=>{const r=[];r.push({start:w,end:e.tsEnd});let i=0;for(let n=0;n<u.value.length;n++){const s=u.value[n];if(w>=s.start&&d<=s.end)return;if(r[0].start>d)break;if(s.start<=r[0].start&&s.end>=w)i=n+1,r[0].start=s.end;else if(s.start>r[0].start){i=n;break}}const h=a.value.reduce((n,s)=>n+s.annotations.length,0);if(r[0].start>=r[0].end&&h>0)return;const y=0;for(let n=i;n<u.value.length;n++)if(u.value[n].start>=r[y].start)if(r[y].end=u.value[n].start,u.value[n].end<d)r.push({start:u.value[n].end,end:e.tsEnd});else break;if(!(r[0].start>=r[0].end&&h>0)&&r.length>0){c.value.map(n=>T(n));for(const n of r){for(const s of a.value){if(!s.id){console.warn("Layer ID is undefined, skipping annotation request for layer:",s);continue}const m=Math.floor(n.end),p={id:l.content.id,start:Math.floor(n.start),end:m,layerId:s.id,limit:e.constants.LIMITANNFETCH};try{const L=await b.useToken(),A=`${o.config.apiUrl}/timeseries/${l.content.id}/layers/${s.id}/annotations?api_key=${L}`,k=Object.keys(p).map(H=>`&${H}=${p[H]}`).join(""),E=`${A}${k}`,F=await fetch(E,{method:"GET",headers:{"Content-type":"application/json"}});if(F.status>=400)throw new Error(F.status);const N=await F.json();await R(N,v)}catch(L){b.useHandleXhrError(L)}}u.value.push({start:Math.floor(n.start),end:Math.floor(n.end)})}u.value.sort((n,s)=>n.start<s.start?-1:n.start>s.start?1:0)}},R=async(w,d)=>{const e=b.propOr({},"linkedPackages",w);let l=_.pathOr([],["annotations","results"],w);if(l.length>=500){let r=0;for(const i of l)i.start>r&&(r=i.start);for(const i of u.value)if(i.end>r&&i.start<r){i.end=r;break}}const v=f.value!=="NOT_MONTAGED";if(l.length>0){const r=l.map(i=>{const h={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 y=i.linkedPackage;h.linkedPackage=_.pathOr("",["content","id"],e[y]),h.linkedPackageDTO=e[y]}return(!v&&h.channelIds.length===c.value.length||v&&h.channelIds.length>c.value.length)&&(h.allChannels=!0),h});a.value.forEach(i=>{const h=i.annotations,y=r.filter(n=>i.id===n.layer_id);i.annotations=h.concat(y),o.updateLayer(i)})}d("annotationsReceived")};return{cachedAnnRange:u,annLayerInfo:g,checkAnnotationRange:I,findNextAnnotation:w=>{const d=o.getViewerActiveLayer(),e=q(d.annotations,w,!1);return e<d.annotations.length?d.annotations[e].start>w?d.annotations[e]:d.annotations[e+1]||d.annotations[e]:d.annotations[e]},findPreviousAnnotation:w=>{const d=o.getViewerActiveLayer(),e=q(d.annotations,w,!0);return d.annotations[e].start<w?d.annotations[e]:e>0?d.annotations[e-1]:d.annotations[e]},getChannelId:T}}function x(t=null){const o=t||S.inject("viewerStore",null)||b.createViewerStore("default"),{viewerAnnotations:c,viewerChannels:a}=J.storeToRefs(o),f=S.ref([]),u=S.ref([]),g=S.ref(null),T=S.ref(["#FFFF4E"]),I=(e,l)=>{var h,y;const r=(((h=l.constants)==null?void 0:h.ANNOTATIONLABELHEIGHT)||20)/2|0,i=((y=l.constants)==null?void 0:y.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 p=i+(s-l.start)/l.rsPeriod;if(n.cStart=p|0,n.duration!==0){const L=i+(s+m-l.start)/l.rsPeriod;n.cEnd=L|0}else n.cEnd=n.cStart+l.cWidth/40|0;if(n.allChannels)n.allOffsets=[r],n.cY=r;else{n.allOffsets=[],n.minOffset=l.cHeight|0,n.maxOffset=0;const L=a.value;for(const C of n.channelIds){let A=null;for(const k of L)if(k.id===C&&k.visible){A=k.rowBaseline|0,A<n.minOffset&&(n.minOffset=A),A>n.maxOffset&&(n.maxOffset=A),n.allOffsets.push(A);break}}u.value.indexOf(n.minOffset)<0&&u.value.push(n.minOffset),n.cY=n.minOffset}}},R=(e,l,v,r)=>{var y,n;const i=((y=v.constants)==null?void 0:y.ANNOTATIONLABELHEIGHT)||20,h=i/2|0;e.setTransform(v.pixelRatio,0,0,v.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 l){const m=j(s,c.value);s.selected&&(e.save(),e.strokeStyle=m.selColor,e.fillStyle=m.bkColor,e.lineWidth=1);const p=Math.round(s.cStart)+.5,L=Math.round(s.cEnd)+.5;s.allChannels?s.duration===0?(e.beginPath(),e.moveTo(p+1,i),e.lineTo(p,r),e.stroke()):(e.fillRect(p,i,L-p,r-i),e.beginPath(),e.moveTo(p,i),e.lineTo(p,r),e.moveTo(L,i),e.lineTo(L,r),e.stroke()):((n=s==null?void 0:s.channelIds)==null?void 0:n.length)===1?s.duration===0&&(e.beginPath(),e.moveTo(p,s.minOffset+h),e.lineTo(p,s.minOffset+h+8),e.stroke()):s.duration===0?(e.beginPath(),e.moveTo(p,s.minOffset+h),e.lineTo(p,s.maxOffset-h),e.stroke()):(e.fillRect(p-1,s.minOffset+h,L-p+1,s.maxOffset-s.minOffset-i),e.beginPath(),e.moveTo(p,s.minOffset+h),e.lineTo(p,s.maxOffset-h),e.moveTo(L,s.minOffset+h),e.lineTo(L,s.maxOffset-h),e.stroke()),s.selected&&e.restore()}e.restore()},$=async(e,l,v,r,i,h)=>{var s;const y=((s=v.constants)==null?void 0:s.ANNOTATIONLABELHEIGHT)||20,n=y/2|0;e.setTransform(v.pixelRatio,0,0,v.pixelRatio,0,0),e.save(),e.lineWidth=2,e.font="14px sans-serif",e.textAlign="left";for(const m of l){const p=j(m,c.value);if(m===g.value&&r)continue;m.selected?(e.fillStyle=p.selColor||"rgba(51,204,102, 0.8)",e.strokeStyle="white"):(e.fillStyle=p.color||"rgba(51,204,102,0.8)",e.strokeStyle=m===g.value?"white":"rgba(255,255,255,0.8)");const L=Math.round(m.cStart)+1,C=Math.round(m.cEnd);let A=0;for(let F=0;F<m.allOffsets.length;F++)e.fillRect(L-1,m.allOffsets[F]-n,C-L+2,y),m.allOffsets[F]===m.minOffset&&(A=F);const k=m.allOffsets[A];if(["annSelect","annResize-left","annResize-right"].includes(i)&&h==="annotate"&&(e.beginPath(),m.duration!==0&&(e.moveTo(C-3,k-n+3),e.lineTo(C-3,k+n-3)),e.moveTo(L+3,k-n+3),e.lineTo(L+3,k+n-3),e.stroke()),C-L>m.label.length*8+10){e.fillStyle=T.value.indexOf(p.hexColor)>=0?"black":"white";const F=m.linkedPackage?L+30:L+10,N=m.linkedPackage?k+n-n/2:k+n-6;e.fillText(m.label,F,N)}const E=m.linkedPackageDTO;E&&C-L>=30&&await O(e,E,L,k,n,y)}e.restore()},O=async(e,l,v,r,i,h)=>{const y=_.pathOr({},["objects","view",1,"content"],l),n=b.propOr("","fileType",y),s=new Image;if(n==="PNG"){const{id:m,packageId:p}=y,L=o.config.apiUrl;try{const C=await b.useToken();s.src=`${L}/packages/${p}/files/${m}/presign/?api_key=${C}`,s.complete?e.drawImage(s,v,r-i,27,h):s.addEventListener("load",()=>{e.drawImage(s,v,r-i,27,h)},{once:!0})}catch(C){console.error("Error loading image:",C)}}else s.src=w(),e.drawImage(s,v+5,r-i,20,20)},w=e=>"/path/to/default/icon.png";return{renderAnn:f,hoverOffsets:u,focusedAnn:g,render:(e,l,v,r)=>{var m,p,L,C;if(!l){console.warn("TSAnnotationCanvas: annotationsCanvas prop is undefined or null");return}const i=l.getContext("2d"),h=v.getContext("2d");i.setTransform(e.pixelRatio,0,0,e.pixelRatio,0,0),h.setTransform(e.pixelRatio,0,0,e.pixelRatio,0,0),u.value=[(((m=e.constants)==null?void 0:m.ANNOTATIONLABELHEIGHT)||20)/2],i.clearRect(0,0,e.cWidth,e.cHeight),h.clearRect(0,0,e.cWidth,e.cHeight),f.value=[];const y=e.duration&&e.duration>0?e.duration:15e6,n=e.start||0,s=n+y;console.log("🎨 Annotation render debug:",{start:n,duration:y,end:s,layerCount:((p=c.value)==null?void 0:p.length)||0,totalAnnotations:((L=c.value)==null?void 0:L.reduce((A,k)=>{var E;return A+(((E=k.annotations)==null?void 0:E.length)||0)},0))||0});for(const A of c.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 k=A.annotations.filter(E=>{const F=E.start,N=E.end||E.start+(E.duration||0),H=F<s&&N>n;return H&&console.log(` ✅ Including annotation "${E.label}": ${F} - ${N}`),H});console.log(` 📊 Found ${k.length} annotations in viewport`),k.length>0&&(k.sort((E,F)=>E.start-F.start),f.value.push(...k))}if(console.log(`🎯 Total annotations to render: ${f.value.length}`),f.value.length===0){console.log("⚠️ No annotations found in viewport");return}Y(f.value),I(f.value,e),R(i,f.value,e,r),$(h,f.value,e,!0,e.pointerMode,e.viewerActiveTool),g.value&&$(h,[g.value],e,!1,e.pointerMode,e.viewerActiveTool),console.log(`✅ Rendered ${f.value.length} annotations successfully`)},computeRenderOptions:I,renderAnnotationAreas:R,renderAnnotationLabels:$}}function ee(t,o,c,a=null){const f=a||S.inject("viewerStore",null)||b.createViewerStore("default"),u=S.ref([0,0]),g=(e,l)=>{const r=((l==null?void 0:l.ANNOTATIONLABELHEIGHT)||20)/2;for(const i of c.value)if(e>=i-r&&e<=i+r)return!0;return!1},T=(e,l,v)=>{var h;const i=((v==null?void 0:v.ANNOTATIONLABELHEIGHT)||20)/2;for(let y=0;y<(((h=o.value)==null?void 0:h.length)||0);y++){const n=o.value[y];if(n.cStart<e&&n.cEnd>e){if(l>n.cY-i&&l<n.cY+i)return y}else if(n.cStart>e)break}return null},I=(e,l,v)=>{if(!v)return l;switch(l){case"annotate":return e<=v.cStart+10?"annResize-left":e>=v.cEnd-10&&v.duration>0?"annResize-right":"annSelect";case"pointer":return"annSelect";default:return l}};return{mouseDownPosition:u,shouldCheckAnnotationHover:g,findAnnotationAtPosition:T,determinePointerMode:I,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?(f.setActiveAnnotation(t.value),!0):!1,onMouseDown:(e,l,v)=>{t.value&&["annResize-left","annResize-right"].includes(v)&&(t.value.oldStart=t.value.start,t.value.oldDuration=t.value.duration,u.value=[e,l])},onMouseMove:(e,l,v,r,i)=>{let h=v;if(r&&u.value){const y=(e-u.value[0])*i.rsPeriod;switch(v){case"annResize-left":t.value.oldDuration>0?(t.value.start=t.value.oldStart+y,t.value.duration=t.value.oldDuration-y,t.value.end=t.value.start+t.value.duration):t.value.start=t.value.oldStart+y;break;case"annResize-right":t.value.duration=t.value.oldDuration+y,t.value.end=t.value.start+t.value.duration;break}}else{const y=g(l,i.constants);if(h=i.viewerActiveTool,y){const n=T(e,l,i.constants);if(n!==null){const s=t.value,m=o.value[n];(!s||e<t.value.cStart||e>t.value.cEnd)&&(t.value=m),h=I(e,i.viewerActiveTool,t.value)}else t.value=null}else t.value=null,h=i.viewerActiveTool}return h},onMouseUp:(e,l)=>{if(t.value&&["annResize-left","annResize-right"].includes(e)){if(t.value.duration<0){const v=-t.value.duration,r=t.value.start-v;t.value.start=r,t.value.duration=v,t.value.end=r+v}f.setActiveAnnotation(t.value),l("updateAnnotation",t.value)}}}}var P={exports:{}},G;function te(){if(G)return P.exports;G=1;function t(){}return t.prototype={on:function(o,c,a){var f=this.e||(this.e={});return(f[o]||(f[o]=[])).push({fn:c,ctx:a}),this},once:function(o,c,a){var f=this;function u(){f.off(o,u),c.apply(a,arguments)}return u._=c,this.on(o,u,a)},emit:function(o){var c=[].slice.call(arguments,1),a=((this.e||(this.e={}))[o]||[]).slice(),f=0,u=a.length;for(f;f<u;f++)a[f].fn.apply(a[f].ctx,c);return this},off:function(o,c){var a=this.e||(this.e={}),f=a[o],u=[];if(f&&c)for(var g=0,T=f.length;g<T;g++)f[g].fn!==c&&f[g].fn._!==c&&u.push(f[g]);return u.length?a[o]=u:delete a[o],this}},P.exports=t,P.exports.TinyEmitter=t,P.exports}var B,W;function ne(){if(W)return B;W=1;var t=te();return B=new t,B}var oe=ne();const D=Q.getDefaultExportFromCjs(oe),X={$emit:(...t)=>D.emit(...t),$on:(...t)=>D.on(...t),$off:(...t)=>D.off(...t),$once:(...t)=>D.once(...t)};function ae(t=null){const o=t||S.inject("viewerStore",null)||b.createViewerStore("default"),c=S.ref([]),a=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"]),f=async(O,w)=>{const d=[];if(O.results.length===0)await u({name:"Default",color:"#18BA62",description:"Default Annotation Layer"},null,w);else{for(let e=0;e<O.results.length;e++){const l=O.results[e];let v=l.color||a.value[e%a.value.length];const r={id:l.id,name:l.name,description:l.description,visible:!0,selected:e===0,annotations:[],color:M(v,.7),hexColor:v,bkColor:M(v,.15),selColor:M(v,.9)};d.push(r)}o.setAnnotations(d),w("annLayersInitialized")}c.value=O.results},u=async(O,w,d)=>{try{const e=await b.useToken(),l=`${o.config.apiUrl}/timeseries/${w.content.id}/layers?api_key=${e}`,v=await b.useSendXhr(l,{method:"POST",body:{name:O.name,color:O.color,description:O.description||O.name}}),r={...v,annotations:[],hexColor:v.color,color:M(v.color,.7),bkColor:M(v.color,.15),selColor:M(v.color,.9),visible:!0,selected:!0};return o.createLayer(r),o.setActiveAnnotationLayer(r.id),X.$emit("toast",{detail:{msg:`'${r.name}' Layer Created`}}),r}catch(e){throw b.useHandleXhrError(e),e}finally{d&&d("closeAnnotationLayerWindow")}};return{annLayerInfo:c,defaultColors:a,initializeLayers:f,createAnnotationLayer:u,updateLayerVisibility:(O,w)=>{console.log(`[useAnnotationLayers] Updating layer ${O} visibility to:`,w);const d=o.viewerAnnotations.find(e=>e.id===O);if(d){console.log("[useAnnotationLayers] Found layer:",d.name,"current visible:",d.visible),d.visible=w,o.updateLayer(d),console.log("[useAnnotationLayers] Updated layer:",d.name,"new visible:",d.visible);const e=o.viewerAnnotations.find(l=>l.id===O);console.log("[useAnnotationLayers] Verification - layer visible is now:",e==null?void 0:e.visible)}else console.error("[useAnnotationLayers] Layer not found with ID:",O),console.log("[useAnnotationLayers] Available layers:",o.viewerAnnotations.map(e=>({id:e.id,name:e.name})))},selectLayer:O=>{o.viewerAnnotations.forEach(d=>{d.selected=!1,o.updateLayer(d)});const w=o.viewerAnnotations.find(d=>d.id===O);w&&(w.selected=!0,o.updateLayer(w),o.setActiveAnnotationLayer(O))},deleteLayer:async(O,w)=>{try{const d=await b.useToken(),e=`${o.config.apiUrl}/timeseries/${w.content.id}/layers/${O}?api_key=${d}`;await b.useSendXhr(e,{method:"DELETE"}),o.removeLayer(O),X.$emit("toast",{detail:{msg:"Layer deleted successfully"}})}catch(d){throw b.useHandleXhrError(d),d}},updateLayerColor:async(O,w,d)=>{try{const e=await b.useToken(),l=`${o.config.apiUrl}/timeseries/${d.content.id}/layers/${O}?api_key=${e}`,v=await b.useSendXhr(l,{method:"PUT",body:{color:w}}),r=o.viewerAnnotations.find(i=>i.id===O);return r&&(r.hexColor=w,r.color=M(w,.7),r.bkColor=M(w,.15),r.selColor=M(w,.9),o.updateLayer(r)),v}catch(e){throw b.useHandleXhrError(e),e}},loadLayers:async(O,w)=>{try{const d=await b.useToken(),e=`${o.config.apiUrl}/timeseries/${O.content.id}/layers?api_key=${d}`,l=await b.useSendXhr(e);return await f(l,w),l}catch(d){throw b.useHandleXhrError(d),d}}}}const ie=["width","height"],re={__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:o,emit:c}){const a=t,f=c,u=S.ref(null),{checkAnnotationRange:g,findNextAnnotation:T,findPreviousAnnotation:I}=Z(),{renderAnn:R,hoverOffsets:$,focusedAnn:O,render:w}=x(),{resetFocusedAnnotation:d,selectFocusedAnnotation:e,onMouseDown:l,onMouseMove:v,onMouseUp:r}=ee(O,R,$),{createAnnotationLayer:i,loadLayers:h}=ae(),y=S.computed(()=>a.cHeight-20),n=S.computed(()=>({width:a.cWidth+"px",height:y.value+"px"})),s=()=>{w(a,a.annotationsCanvas,u.value,y.value)},m=(k,E)=>{l(k,E,a.pointerMode)},p=(k,E,F,N)=>v(k,E,F,N,a),L=()=>{r(a.pointerMode,f)},C=()=>{e()&&S.nextTick(()=>s())},A=async k=>{try{await i(k,a.activeViewer,f)}catch(E){console.error("Error creating layer:",E)}};return S.watch(()=>a.activeViewer,async k=>{try{await h(k,f),await g(a.start,a.start+a.duration,a,k,f)}catch(E){console.error("Error loading annotations for new viewer:",E)}}),S.onMounted(async()=>{console.log("TSAnnotationCanvas mounted with props:",{constants:a.constants,annotationsCanvas:a.annotationsCanvas,viewerActiveTool:a.viewerActiveTool});try{await h(a.activeViewer,f),await g(a.start,a.start+a.duration,a,a.activeViewer,f)}catch(k){console.error("Error initializing annotations:",k)}}),o({render:s,resetFocusedAnnotation:d,findNextAnnotation:T,findPreviousAnnotation:I,checkAnnotationRange:(k,E)=>g(k,E,a,a.activeViewer,f),selectFocusedAnn:C,createAnnotationLayer:A,onMouseDown:m,onMouseMove:p,onMouseUp:L}),(k,E)=>(S.openBlock(),S.createElementBlock("canvas",{id:"annLabelArea",ref_key:"annLabelArea",ref:u,class:"timeseries-annotation-canvas",width:S.unref(z)(t.cWidth,t.pixelRatio,0),height:S.unref(z)(y.value,t.pixelRatio,0),style:S.normalizeStyle(n.value)},null,12,ie))}},se=b._export_sfc(re,[["__scopeId","data-v-41f7f1c2"]]);exports.default=se;
@@ -1,377 +0,0 @@
1
- import { inject as Ne, ref as v, computed as N, watch as U, nextTick as E, onMounted as Ie, createElementBlock as $e, openBlock as Ue, createElementVNode as x, toDisplayString as K, normalizeStyle as Q } from "vue";
2
- import { _ as ve, a as Se, b as Y, c as Ve, d as ge, e as Oe, f as je, k as Le, g as Xe, h as ze, u as de, i as fe, j as he } from "./index-CgKUmS0K.js";
3
- function me(g, c, l) {
4
- return function() {
5
- for (var t = [], p = 0, u = g, k = 0; k < c.length || p < arguments.length; ) {
6
- var W;
7
- k < c.length && (!ve(c[k]) || p >= arguments.length) ? W = c[k] : (W = arguments[p], p += 1), t[k] = W, ve(W) || (u -= 1), k += 1;
8
- }
9
- return u <= 0 ? l.apply(this, t) : Se(u, me(g, t, l));
10
- };
11
- }
12
- var Be = /* @__PURE__ */ Y(function(c, l) {
13
- return c === 1 ? Ve(l) : Se(c, me(c, [], l));
14
- });
15
- function He(g, c) {
16
- for (var l = 0, t = c.length, p = Array(t); l < t; )
17
- p[l] = g(c[l]), l += 1;
18
- return p;
19
- }
20
- var qe = /* @__PURE__ */ (function() {
21
- function g(c, l) {
22
- this.xf = l, this.f = c;
23
- }
24
- return g.prototype["@@transducer/init"] = ge.init, g.prototype["@@transducer/result"] = ge.result, g.prototype["@@transducer/step"] = function(c, l) {
25
- return this.xf["@@transducer/step"](c, this.f(l));
26
- }, g;
27
- })(), Fe = /* @__PURE__ */ Y(function(c, l) {
28
- return new qe(c, l);
29
- }), Ge = /* @__PURE__ */ Y(
30
- /* @__PURE__ */ Oe(["fantasy-land/map", "map"], Fe, function(c, l) {
31
- switch (Object.prototype.toString.call(l)) {
32
- case "[object Function]":
33
- return Be(l.length, function() {
34
- return c.call(this, l.apply(this, arguments));
35
- });
36
- case "[object Object]":
37
- return je(function(t, p) {
38
- return t[p] = c(l[p]), t;
39
- }, {}, Le(l));
40
- default:
41
- return He(c, l);
42
- }
43
- })
44
- );
45
- const Je = { class: "timeseries-scrubber" }, Ke = { class: "dateWrap" }, Qe = { class: "noselect" }, Ye = {
46
- id: "scrubber",
47
- noselect: ""
48
- }, Ze = ["width", "height"], et = ["width", "height"], tt = ["width", "height"], nt = {
49
- __name: "TSScrubber",
50
- props: {
51
- ts_start: Number,
52
- ts_end: Number,
53
- cWidth: Number,
54
- constants: Object,
55
- start: Number,
56
- duration: Number,
57
- cursorLoc: Number,
58
- labelWidth: Number,
59
- activeViewer: Object
60
- },
61
- emits: ["setStart"],
62
- setup(g, { expose: c, emit: l }) {
63
- const t = g, p = l, u = Ne("viewerStore", () => ze("default"), !0), k = v(null), W = v(null), H = v(null), w = v(null), d = v(1), Z = v(28), T = v(30), V = v(!1), I = v(""), O = v("point"), ee = v(null), D = v([]), _ = v([]), C = v([]), j = v(!1), te = v(0), ne = v(0), R = v(0), L = v(0), pe = N(() => oe(t.ts_start)), be = N(() => oe(t.ts_end)), _e = N(() => {
64
- if (I.value !== "")
65
- return I.value;
66
- if (t.start > 0) {
67
- const n = new Date(t.start / 1e3).toUTCString();
68
- return n.substring(0, n.length - 3);
69
- }
70
- return "";
71
- }), ae = N(() => ({
72
- width: t.labelWidth + t.cWidth - 8 + 5 + "px",
73
- height: "28px"
74
- })), we = N(() => ({
75
- width: t.labelWidth + t.cWidth - 8 + 5 + "px",
76
- height: "30px"
77
- })), Te = N(() => t.cWidth + t.labelWidth - 8 + 5), Ce = N(() => Math.floor((t.ts_end - t.ts_start) / t.cWidth));
78
- U(() => t.start, () => {
79
- A();
80
- }), U(() => t.duration, () => {
81
- A();
82
- }), U(() => t.cWidth, () => {
83
- A();
84
- }), U(() => t.activeViewer, (n, e) => {
85
- var a;
86
- n && n !== e && (console.log("TSScrubber: ActiveViewer changed, resetting component state"), j.value = !0, se(), (a = n.content) != null && a.id ? E(() => {
87
- B(), j.value = !1;
88
- }) : j.value = !1);
89
- }, { deep: !0 }), U(() => u.viewerChannels, (n, e) => {
90
- var a, r;
91
- n && n.length > 0 && !j.value && (!e || n.length !== e.length || ((a = n[0]) == null ? void 0 : a.id) !== ((r = e[0]) == null ? void 0 : r.id)) && (console.log("TSScrubber: Viewer channels changed, re-initializing segments"), z(), E(() => {
92
- ie();
93
- }));
94
- }, { deep: !0 }), U(() => u.viewerAnnotations, (n, e) => {
95
- var a;
96
- n && n !== e && !j.value ? (console.log("TSScrubber: Viewer annotations changed independently, re-fetching annotations"), E(() => {
97
- B();
98
- })) : n && n.length > 0 && !e && ((a = t.activeViewer) != null && a.content.id) && (console.log("TSScrubber: Annotation layers now available, fetching annotations"), E(() => {
99
- B();
100
- }));
101
- }, { deep: !0 });
102
- const se = () => {
103
- console.log("TSScrubber: Resetting component state"), D.value = [], z(), V.value = !1, I.value = "", O.value = "point", re();
104
- }, z = () => {
105
- console.log("TSScrubber: Resetting segment state"), C.value = new Array(5e3), C.value = C.value.fill(0, 0, 4999), _.value = [];
106
- }, re = () => {
107
- E(() => {
108
- [W.value, H.value, w.value].forEach((e) => {
109
- if (e) {
110
- const a = e.getContext("2d");
111
- a && a.clearRect(0, 0, e.width, e.height);
112
- }
113
- });
114
- });
115
- }, $ = (n, e, a) => e * (n + a), ye = () => {
116
- const n = w.value.getContext("2d"), e = window.devicePixelRatio || 1, a = n.webkitBackingStorePixelRatio || n.mozBackingStorePixelRatio || n.msBackingStorePixelRatio || n.oBackingStorePixelRatio || n.backingStorePixelRatio || 1;
117
- return e / a;
118
- }, oe = (n) => {
119
- if (n > 0)
120
- return n = n / 1e3, n = new Date(n), ("0" + n.getUTCHours()).slice(-2) + ":" + ("0" + n.getUTCMinutes()).slice(-2) + ":" + ("0" + n.getUTCSeconds()).slice(-2);
121
- }, xe = (n) => {
122
- if (V.value) {
123
- const a = (n.clientX - te.value) / t.cWidth * (t.ts_end - t.ts_start), r = ne.value + a;
124
- p("setStart", r);
125
- const s = new Date((a + t.ts_start) / 1e3);
126
- I.value = s.toUTCString();
127
- } else {
128
- const e = w.value.getBoundingClientRect(), a = n.clientX - e.left, r = R.value + L.value, s = O.value;
129
- a > R.value - 10 && a < r + 10 ? (O.value = "drag", w.value.setAttribute("dragme", !0), w.value.removeAttribute("resizeme")) : (O.value = "point", w.value.removeAttribute("dragme"), w.value.removeAttribute("resizeme"));
130
- const o = a / t.cWidth * (t.ts_end - t.ts_start) + t.ts_start, b = new Date(o / 1e3).toUTCString();
131
- I.value = b.substring(0, b.length - 3), s !== O.value && A();
132
- }
133
- }, ke = () => {
134
- V.value = !1;
135
- }, We = (n) => {
136
- V.value = !0;
137
- const e = w.value.getBoundingClientRect(), a = n.clientX - e.left;
138
- te.value = n.clientX;
139
- const r = a / Te.value * (t.ts_end - t.ts_start);
140
- p("setStart", r + t.ts_start), ne.value = r + t.ts_start;
141
- }, Re = () => {
142
- V.value = !1;
143
- }, Ae = () => {
144
- I.value = "";
145
- }, ie = () => {
146
- var a;
147
- if (!u.viewerChannels || u.viewerChannels.length === 0) {
148
- console.warn("TSScrubber: Cannot init segment spans - no viewer channels available");
149
- return;
150
- }
151
- if (!t.ts_start || !t.ts_end) {
152
- console.warn("TSScrubber: Cannot init segment spans - invalid time range");
153
- return;
154
- }
155
- if (!((a = u.config) != null && a.timeSeriesApi)) {
156
- console.warn("TSScrubber: Cannot init segment spans - no timeSeriesApi configured");
157
- return;
158
- }
159
- console.log(`TSScrubber: Initializing segment spans for ${u.viewerChannels.length} channels`), z();
160
- const n = Math.min(t.constants.SEGMENTSPAN, t.ts_end - t.ts_start), e = u.viewerChannels;
161
- for (let r = 0; r < e.length; r++)
162
- le(e[r].id, r, t.ts_start, t.ts_start + n, 0);
163
- }, le = async (n, e, a, r, s) => {
164
- var o;
165
- const i = t.constants.MAXRECURSION;
166
- if (!((o = u.config) != null && o.timeSeriesApi)) {
167
- console.warn("TSScrubber: Cannot request segment span - no timeSeriesApi configured");
168
- return;
169
- }
170
- if (!n) {
171
- console.warn("TSScrubber: Cannot request segment span - no channel ID provided");
172
- return;
173
- }
174
- try {
175
- const b = await de(), f = `${u.config.timeSeriesApi}/ts/retrieve/segments?session=${b}&channel=${n}&start=${a}&end=${r}`;
176
- console.log(`TSScrubber: Fetching segments for channel ${n} (${e})`);
177
- const S = await fe(f);
178
- if (!u.viewerChannels[e] || u.viewerChannels[e].id !== n) {
179
- console.warn("TSScrubber: Channel mismatch detected, ignoring segment response (likely package switched)");
180
- return;
181
- }
182
- let h = new Array(S.length * 2), m = 0;
183
- for (let M = 0; M < S.length; M++) {
184
- h[m] = S[M][0], h[m + 1] = S[M][1], m = m + 2;
185
- const J = Math.floor((S[M][0] - t.ts_start) / (t.ts_end - t.ts_start) * 5e3), De = Math.ceil((S[M][1] - t.ts_start) / (t.ts_end - t.ts_start) * 5e3);
186
- C.value.fill(1, J, De);
187
- }
188
- let y = 0, X = !1, G = 0;
189
- for (_.value = []; y < C.value.length - 1; ) {
190
- if (!C.value[y] && !X) {
191
- y++;
192
- continue;
193
- } else C.value[y] ? X || (G = y, X = !0) : (_.value = _.value.concat([G, y]), X = !1);
194
- y++;
195
- }
196
- X && (_.value = _.value.concat([G, y])), _.value = _.value.concat([5e3]);
197
- let Ee = h[0], P = u.viewerChannels[e];
198
- if (!P || P.id !== n) {
199
- console.warn("TSScrubber: Channel configuration mismatch, skipping update");
200
- return;
201
- }
202
- Ee < P.dataSegments[P.dataSegments.length - 1] && (h.shift(), h.shift()), P.dataSegments = P.dataSegments.concat(h.sort((M, J) => M - J)), u.updateChannelProperty(P.id, "dataSegments", P.dataSegments);
203
- let ue = r - a;
204
- a + ue < t.ts_end && s < i ? le(n, e, r, r + ue, s + 1) : F();
205
- } catch (b) {
206
- console.error(`TSScrubber: Error fetching segments for channel ${n}:`, b), he(b);
207
- }
208
- }, B = async () => {
209
- var e, a, r;
210
- const n = (e = t.activeViewer) == null ? void 0 : e.content.id;
211
- if (!n) {
212
- console.warn("TSScrubber: Cannot get annotations - no active viewer ID"), D.value = [];
213
- return;
214
- }
215
- if (!((a = u.config) != null && a.apiUrl)) {
216
- console.warn("TSScrubber: Cannot get annotations - no API URL configured"), D.value = [];
217
- return;
218
- }
219
- if (!u.viewerAnnotations || u.viewerAnnotations.length === 0) {
220
- console.log("TSScrubber: No annotation layers available, skipping annotation fetch"), D.value = [], A();
221
- return;
222
- }
223
- try {
224
- const s = await de(), i = Ge((h) => h.id, u.viewerAnnotations), o = t.ts_end;
225
- let f = `${u.config.apiUrl}/timeseries/${n}/annotations/window` + `?api_key=${s}&aggregation=count&start=${t.ts_start}&end=${t.ts_end}&period=${Ce.value}&mergePeriods=true`;
226
- for (let h in i)
227
- f = f + `&layerIds=${i[h]}`;
228
- console.log(`TSScrubber: Fetching annotations for viewer ${n}`);
229
- const S = await fe(f);
230
- ((r = t.activeViewer) == null ? void 0 : r.content.id) === n ? (D.value = S, A()) : console.log("TSScrubber: Ignoring annotation response - viewer changed during fetch");
231
- } catch (s) {
232
- console.error("TSScrubber: Error fetching annotations:", s), D.value = [], he(s), A();
233
- }
234
- }, A = () => {
235
- q(), ce(), F();
236
- }, q = () => {
237
- E(() => {
238
- const n = w.value;
239
- if (!n) {
240
- console.warn("iCanvas ref is missing, skipping render");
241
- return;
242
- }
243
- const e = n.getContext("2d");
244
- if (!e) {
245
- console.warn("2D context is not available");
246
- return;
247
- }
248
- e.setTransform(d.value, 0, 0, d.value, 0, 0), e.clearRect(0, 0, t.cWidth, T.value), R.value = (t.start - t.ts_start) / (t.ts_end - t.ts_start) * t.cWidth + 0.5 | 0, L.value = t.duration / (t.ts_end - t.ts_start) * t.cWidth + 0.5 | 0, e.fillStyle = "rgb(80,80,80)", e.strokeStyle = "rgb(80,80,80)", e.strokeRect(R.value + 0.5, 0.5, L.value, T.value - 1), e.fillRect(R.value - 2, T.value / 2 - 5 | 0, 2, 10), e.fillRect(R.value + L.value + 1, T.value / 2 - 5 | 0, 2, 10);
249
- const a = R.value + t.cursorLoc * L.value;
250
- a > R.value + 0.5 && (e.strokeStyle = "red", e.beginPath(), e.moveTo(a, 0), e.lineTo(a, T.value - 1), e.stroke());
251
- });
252
- }, F = () => {
253
- E(() => {
254
- const n = W.value;
255
- if (!n) {
256
- console.warn("segmentsCanvas ref is missing, skipping renderSegments");
257
- return;
258
- }
259
- const e = n.getContext("2d");
260
- if (!e) {
261
- console.warn("Unable to get 2D context for segmentsCanvas, skipping renderSegments");
262
- return;
263
- }
264
- e.setTransform(d.value, 0, 0, d.value, 0, 0), e.fillStyle = e.createPattern(ee.value, "repeat"), e.clearRect(0, 0, t.cWidth, T.value);
265
- for (let a = 1; a < _.value.length; a += 2) {
266
- const r = t.cWidth * _.value[a] / 5e3, s = t.cWidth * _.value[a + 1] / 5e3;
267
- e.fillRect(r, 2, s - r, T.value - 6);
268
- }
269
- });
270
- }, ce = () => {
271
- const n = H.value;
272
- if (!n) {
273
- console.warn("annotationCanvas ref is missing, skipping renderTimelimeLine");
274
- return;
275
- }
276
- const e = n.getContext("2d");
277
- if (!e) {
278
- console.warn("Unable to get 2D context for annotationCanvas, skipping renderTimelimeLine");
279
- return;
280
- }
281
- e.setTransform(d.value, 0, 0, d.value, 0, 0), e.clearRect(0, 0, t.cWidth, Z.value);
282
- const a = t.ts_start, r = t.ts_end, s = D.value;
283
- let i = 0;
284
- const o = 0, b = Math.floor((Z.value - 2) / Object.keys(s).length - o), f = u.viewerAnnotations;
285
- let S = "rgb(0,0,0)";
286
- for (const h in s)
287
- if (s.hasOwnProperty(h)) {
288
- for (let m = 0; m < f.length; m++)
289
- if (f[m].id === parseInt(h)) {
290
- i = m, S = f[m].color;
291
- break;
292
- }
293
- Pe(e, a, r, o, b, s[h], i, S);
294
- }
295
- }, Pe = (n, e, a, r, s, i, o, b) => {
296
- E(() => {
297
- n.setTransform(d.value, 0, 0, d.value, 0, 0), n.fillStyle = b;
298
- for (let f = 0; f < i.length; f++)
299
- if (i[f].value > 0) {
300
- const S = (i[f].start - e) / (a - e) * t.cWidth;
301
- let m = (i[f].end - e) / (a - e) * t.cWidth - S;
302
- m < 1 && (m = 1);
303
- const y = 1 + o * (s - 1 + r) + o;
304
- n.fillRect(S, y, m, s);
305
- }
306
- });
307
- }, Me = () => {
308
- const n = document.createElement("canvas"), e = n.getContext("2d", { antialias: !0 }), a = "rgb(220,220,220)", r = 5, s = r, i = r, o = 10;
309
- return n.width = s, n.height = i, e.fillStyle = a, e.beginPath(), e.moveTo(0, i * (1 / o)), e.lineTo(s * (1 / o), 0), e.lineTo(0, 0), e.lineTo(0, i * (1 / o)), e.fill(), e.beginPath(), e.moveTo(s, i * (1 / o)), e.lineTo(s * (1 / o), i), e.lineTo(0, i), e.lineTo(0, i * ((o - 1) / o)), e.lineTo(s * ((o - 1) / o), 0), e.lineTo(s, 0), e.lineTo(s, i * (1 / o)), e.fill(), e.beginPath(), e.moveTo(s, i * ((o - 1) / o)), e.lineTo(s * ((o - 1) / o), i), e.lineTo(s, i), e.lineTo(s, i * ((o - 1) / o)), e.fill(), n;
310
- };
311
- return Ie(() => {
312
- C.value = new Array(5e3), C.value = C.value.fill(0, 0, 4999), d.value = ye(), ee.value = Me(), q();
313
- }), c({
314
- getAnnotations: B,
315
- initSegmentSpans: ie,
316
- render: A,
317
- renderViewPort: q,
318
- renderSegments: F,
319
- renderTimelimeLine: ce,
320
- resetComponentState: se,
321
- resetSegmentState: z,
322
- clearCanvases: re
323
- }), (n, e) => (Ue(), $e("div", Je, [
324
- x("div", Ke, [
325
- x("div", null, K(pe.value), 1),
326
- x("div", null, K(_e.value), 1),
327
- x("div", null, K(be.value), 1)
328
- ]),
329
- x("div", Qe, [
330
- x("div", Ye, [
331
- x("div", {
332
- id: "canvasWrap",
333
- ref_key: "canvasWrap",
334
- ref: k
335
- }, [
336
- x("canvas", {
337
- id: "segmentsCanvas",
338
- class: "canvas",
339
- ref_key: "segmentsCanvas",
340
- ref: W,
341
- width: $(g.cWidth, d.value, 0),
342
- height: $(T.value - 2, d.value, 0),
343
- style: Q(ae.value)
344
- }, null, 12, Ze),
345
- x("canvas", {
346
- id: "annotationCanvas",
347
- class: "canvas",
348
- ref_key: "annotationCanvas",
349
- ref: H,
350
- width: $(g.cWidth, d.value, 0),
351
- height: $(T.value - 2, d.value, 0),
352
- style: Q(ae.value)
353
- }, null, 12, et),
354
- x("canvas", {
355
- id: "iCanvas",
356
- class: "canvas",
357
- ref_key: "iCanvas",
358
- ref: w,
359
- width: $(g.cWidth, d.value, 0),
360
- height: $(T.value, d.value, 0),
361
- onClick: e[0] || (e[0] = (...a) => n._onTap && n._onTap(...a)),
362
- onMousemove: xe,
363
- onMousedown: We,
364
- onMouseup: ke,
365
- onMouseenter: Re,
366
- onMouseout: Ae,
367
- style: Q(we.value)
368
- }, null, 44, tt)
369
- ], 512)
370
- ])
371
- ])
372
- ]));
373
- }
374
- }, rt = /* @__PURE__ */ Xe(nt, [["__scopeId", "data-v-e01e61cc"]]);
375
- export {
376
- rt as default
377
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("vue"),d=require("./index-CMJlEiLT.cjs");function se(g,u,c){return function(){for(var t=[],b=0,v=g,k=0;k<u.length||b<arguments.length;){var W;k<u.length&&(!d._isPlaceholder(u[k])||b>=arguments.length)?W=u[k]:(W=arguments[b],b+=1),t[k]=W,d._isPlaceholder(W)||(v-=1),k+=1}return v<=0?c.apply(this,t):d._arity(v,se(g,t,c))}}var Te=d._curry2(function(u,c){return u===1?d._curry1(c):d._arity(u,se(u,[],c))});function ye(g,u){for(var c=0,t=u.length,b=Array(t);c<t;)b[c]=g(u[c]),c+=1;return b}var Ce=(function(){function g(u,c){this.xf=c,this.f=u}return g.prototype["@@transducer/init"]=d._xfBase.init,g.prototype["@@transducer/result"]=d._xfBase.result,g.prototype["@@transducer/step"]=function(u,c){return this.xf["@@transducer/step"](u,this.f(c))},g})(),xe=d._curry2(function(u,c){return new Ce(u,c)}),ke=d._curry2(d._dispatchable(["fantasy-land/map","map"],xe,function(u,c){switch(Object.prototype.toString.call(c)){case"[object Function]":return Te(c.length,function(){return u.call(this,c.apply(this,arguments))});case"[object Object]":return d._reduce(function(t,b){return t[b]=u(c[b]),t},{},d.keys(c));default:return ye(u,c)}}));const We={class:"timeseries-scrubber"},Ee={class:"dateWrap"},Ne={class:"noselect"},Pe={id:"scrubber",noselect:""},Re=["width","height"],Ae=["width","height"],Me=["width","height"],Ve={__name:"TSScrubber",props:{ts_start:Number,ts_end:Number,cWidth:Number,constants:Object,start:Number,duration:Number,cursorLoc:Number,labelWidth:Number,activeViewer:Object},emits:["setStart"],setup(g,{expose:u,emit:c}){const t=g,b=c,v=a.inject("viewerStore",()=>d.createViewerStore("default"),!0),k=a.ref(null),W=a.ref(null),j=a.ref(null),T=a.ref(null),f=a.ref(1),F=a.ref(28),y=a.ref(30),D=a.ref(!1),M=a.ref(""),I=a.ref("point"),G=a.ref(null),A=a.ref([]),w=a.ref([]),C=a.ref([]),$=a.ref(!1),J=a.ref(0),K=a.ref(0),E=a.ref(0),U=a.ref(0),oe=a.computed(()=>ee(t.ts_start)),ie=a.computed(()=>ee(t.ts_end)),le=a.computed(()=>{if(M.value!=="")return M.value;if(t.start>0){const n=new Date(t.start/1e3).toUTCString();return n.substring(0,n.length-3)}return""}),Q=a.computed(()=>({width:t.labelWidth+t.cWidth-8+5+"px",height:"28px"})),ce=a.computed(()=>({width:t.labelWidth+t.cWidth-8+5+"px",height:"30px"})),ue=a.computed(()=>t.cWidth+t.labelWidth-8+5),ve=a.computed(()=>Math.floor((t.ts_end-t.ts_start)/t.cWidth));a.watch(()=>t.start,()=>{N()}),a.watch(()=>t.duration,()=>{N()}),a.watch(()=>t.cWidth,()=>{N()}),a.watch(()=>t.activeViewer,(n,e)=>{var r;n&&n!==e&&(console.log("TSScrubber: ActiveViewer changed, resetting component state"),$.value=!0,Y(),(r=n.content)!=null&&r.id?a.nextTick(()=>{z(),$.value=!1}):$.value=!1)},{deep:!0}),a.watch(()=>v.viewerChannels,(n,e)=>{var r,o;n&&n.length>0&&!$.value&&(!e||n.length!==e.length||((r=n[0])==null?void 0:r.id)!==((o=e[0])==null?void 0:o.id))&&(console.log("TSScrubber: Viewer channels changed, re-initializing segments"),X(),a.nextTick(()=>{te()}))},{deep:!0}),a.watch(()=>v.viewerAnnotations,(n,e)=>{var r;n&&n!==e&&!$.value?(console.log("TSScrubber: Viewer annotations changed independently, re-fetching annotations"),a.nextTick(()=>{z()})):n&&n.length>0&&!e&&((r=t.activeViewer)!=null&&r.content.id)&&(console.log("TSScrubber: Annotation layers now available, fetching annotations"),a.nextTick(()=>{z()}))},{deep:!0});const Y=()=>{console.log("TSScrubber: Resetting component state"),A.value=[],X(),D.value=!1,M.value="",I.value="point",Z()},X=()=>{console.log("TSScrubber: Resetting segment state"),C.value=new Array(5e3),C.value=C.value.fill(0,0,4999),w.value=[]},Z=()=>{a.nextTick(()=>{[W.value,j.value,T.value].forEach(e=>{if(e){const r=e.getContext("2d");r&&r.clearRect(0,0,e.width,e.height)}})})},V=(n,e,r)=>e*(n+r),de=()=>{const n=T.value.getContext("2d"),e=window.devicePixelRatio||1,r=n.webkitBackingStorePixelRatio||n.mozBackingStorePixelRatio||n.msBackingStorePixelRatio||n.oBackingStorePixelRatio||n.backingStorePixelRatio||1;return e/r},ee=n=>{if(n>0)return n=n/1e3,n=new Date(n),("0"+n.getUTCHours()).slice(-2)+":"+("0"+n.getUTCMinutes()).slice(-2)+":"+("0"+n.getUTCSeconds()).slice(-2)},ge=n=>{if(D.value){const r=(n.clientX-J.value)/t.cWidth*(t.ts_end-t.ts_start),o=K.value+r;b("setStart",o);const s=new Date((r+t.ts_start)/1e3);M.value=s.toUTCString()}else{const e=T.value.getBoundingClientRect(),r=n.clientX-e.left,o=E.value+U.value,s=I.value;r>E.value-10&&r<o+10?(I.value="drag",T.value.setAttribute("dragme",!0),T.value.removeAttribute("resizeme")):(I.value="point",T.value.removeAttribute("dragme"),T.value.removeAttribute("resizeme"));const i=r/t.cWidth*(t.ts_end-t.ts_start)+t.ts_start,_=new Date(i/1e3).toUTCString();M.value=_.substring(0,_.length-3),s!==I.value&&N()}},fe=()=>{D.value=!1},he=n=>{D.value=!0;const e=T.value.getBoundingClientRect(),r=n.clientX-e.left;J.value=n.clientX;const o=r/ue.value*(t.ts_end-t.ts_start);b("setStart",o+t.ts_start),K.value=o+t.ts_start},me=()=>{D.value=!1},Se=()=>{M.value=""},te=()=>{var r;if(!v.viewerChannels||v.viewerChannels.length===0){console.warn("TSScrubber: Cannot init segment spans - no viewer channels available");return}if(!t.ts_start||!t.ts_end){console.warn("TSScrubber: Cannot init segment spans - invalid time range");return}if(!((r=v.config)!=null&&r.timeSeriesApi)){console.warn("TSScrubber: Cannot init segment spans - no timeSeriesApi configured");return}console.log(`TSScrubber: Initializing segment spans for ${v.viewerChannels.length} channels`),X();const n=Math.min(t.constants.SEGMENTSPAN,t.ts_end-t.ts_start),e=v.viewerChannels;for(let o=0;o<e.length;o++)ne(e[o].id,o,t.ts_start,t.ts_start+n,0)},ne=async(n,e,r,o,s)=>{var i;const l=t.constants.MAXRECURSION;if(!((i=v.config)!=null&&i.timeSeriesApi)){console.warn("TSScrubber: Cannot request segment span - no timeSeriesApi configured");return}if(!n){console.warn("TSScrubber: Cannot request segment span - no channel ID provided");return}try{const _=await d.useToken(),h=`${v.config.timeSeriesApi}/ts/retrieve/segments?session=${_}&channel=${n}&start=${r}&end=${o}`;console.log(`TSScrubber: Fetching segments for channel ${n} (${e})`);const S=await d.useSendXhr(h);if(!v.viewerChannels[e]||v.viewerChannels[e].id!==n){console.warn("TSScrubber: Channel mismatch detected, ignoring segment response (likely package switched)");return}let m=new Array(S.length*2),p=0;for(let R=0;R<S.length;R++){m[p]=S[R][0],m[p+1]=S[R][1],p=p+2;const q=Math.floor((S[R][0]-t.ts_start)/(t.ts_end-t.ts_start)*5e3),we=Math.ceil((S[R][1]-t.ts_start)/(t.ts_end-t.ts_start)*5e3);C.value.fill(1,q,we)}let x=0,O=!1,L=0;for(w.value=[];x<C.value.length-1;){if(!C.value[x]&&!O){x++;continue}else C.value[x]?O||(L=x,O=!0):(w.value=w.value.concat([L,x]),O=!1);x++}O&&(w.value=w.value.concat([L,x])),w.value=w.value.concat([5e3]);let _e=m[0],P=v.viewerChannels[e];if(!P||P.id!==n){console.warn("TSScrubber: Channel configuration mismatch, skipping update");return}_e<P.dataSegments[P.dataSegments.length-1]&&(m.shift(),m.shift()),P.dataSegments=P.dataSegments.concat(m.sort((R,q)=>R-q)),v.updateChannelProperty(P.id,"dataSegments",P.dataSegments);let re=o-r;r+re<t.ts_end&&s<l?ne(n,e,o,o+re,s+1):H()}catch(_){console.error(`TSScrubber: Error fetching segments for channel ${n}:`,_),d.useHandleXhrError(_)}},z=async()=>{var e,r,o;const n=(e=t.activeViewer)==null?void 0:e.content.id;if(!n){console.warn("TSScrubber: Cannot get annotations - no active viewer ID"),A.value=[];return}if(!((r=v.config)!=null&&r.apiUrl)){console.warn("TSScrubber: Cannot get annotations - no API URL configured"),A.value=[];return}if(!v.viewerAnnotations||v.viewerAnnotations.length===0){console.log("TSScrubber: No annotation layers available, skipping annotation fetch"),A.value=[],N();return}try{const s=await d.useToken(),l=ke(m=>m.id,v.viewerAnnotations),i=t.ts_end;let h=`${v.config.apiUrl}/timeseries/${n}/annotations/window`+`?api_key=${s}&aggregation=count&start=${t.ts_start}&end=${t.ts_end}&period=${ve.value}&mergePeriods=true`;for(let m in l)h=h+`&layerIds=${l[m]}`;console.log(`TSScrubber: Fetching annotations for viewer ${n}`);const S=await d.useSendXhr(h);((o=t.activeViewer)==null?void 0:o.content.id)===n?(A.value=S,N()):console.log("TSScrubber: Ignoring annotation response - viewer changed during fetch")}catch(s){console.error("TSScrubber: Error fetching annotations:",s),A.value=[],d.useHandleXhrError(s),N()}},N=()=>{B(),ae(),H()},B=()=>{a.nextTick(()=>{const n=T.value;if(!n){console.warn("iCanvas ref is missing, skipping render");return}const e=n.getContext("2d");if(!e){console.warn("2D context is not available");return}e.setTransform(f.value,0,0,f.value,0,0),e.clearRect(0,0,t.cWidth,y.value),E.value=(t.start-t.ts_start)/(t.ts_end-t.ts_start)*t.cWidth+.5|0,U.value=t.duration/(t.ts_end-t.ts_start)*t.cWidth+.5|0,e.fillStyle="rgb(80,80,80)",e.strokeStyle="rgb(80,80,80)",e.strokeRect(E.value+.5,.5,U.value,y.value-1),e.fillRect(E.value-2,y.value/2-5|0,2,10),e.fillRect(E.value+U.value+1,y.value/2-5|0,2,10);const r=E.value+t.cursorLoc*U.value;r>E.value+.5&&(e.strokeStyle="red",e.beginPath(),e.moveTo(r,0),e.lineTo(r,y.value-1),e.stroke())})},H=()=>{a.nextTick(()=>{const n=W.value;if(!n){console.warn("segmentsCanvas ref is missing, skipping renderSegments");return}const e=n.getContext("2d");if(!e){console.warn("Unable to get 2D context for segmentsCanvas, skipping renderSegments");return}e.setTransform(f.value,0,0,f.value,0,0),e.fillStyle=e.createPattern(G.value,"repeat"),e.clearRect(0,0,t.cWidth,y.value);for(let r=1;r<w.value.length;r+=2){const o=t.cWidth*w.value[r]/5e3,s=t.cWidth*w.value[r+1]/5e3;e.fillRect(o,2,s-o,y.value-6)}})},ae=()=>{const n=j.value;if(!n){console.warn("annotationCanvas ref is missing, skipping renderTimelimeLine");return}const e=n.getContext("2d");if(!e){console.warn("Unable to get 2D context for annotationCanvas, skipping renderTimelimeLine");return}e.setTransform(f.value,0,0,f.value,0,0),e.clearRect(0,0,t.cWidth,F.value);const r=t.ts_start,o=t.ts_end,s=A.value;let l=0;const i=0,_=Math.floor((F.value-2)/Object.keys(s).length-i),h=v.viewerAnnotations;let S="rgb(0,0,0)";for(const m in s)if(s.hasOwnProperty(m)){for(let p=0;p<h.length;p++)if(h[p].id===parseInt(m)){l=p,S=h[p].color;break}pe(e,r,o,i,_,s[m],l,S)}},pe=(n,e,r,o,s,l,i,_)=>{a.nextTick(()=>{n.setTransform(f.value,0,0,f.value,0,0),n.fillStyle=_;for(let h=0;h<l.length;h++)if(l[h].value>0){const S=(l[h].start-e)/(r-e)*t.cWidth;let p=(l[h].end-e)/(r-e)*t.cWidth-S;p<1&&(p=1);const x=1+i*(s-1+o)+i;n.fillRect(S,x,p,s)}})},be=()=>{const n=document.createElement("canvas"),e=n.getContext("2d",{antialias:!0}),r="rgb(220,220,220)",o=5,s=o,l=o,i=10;return n.width=s,n.height=l,e.fillStyle=r,e.beginPath(),e.moveTo(0,l*(1/i)),e.lineTo(s*(1/i),0),e.lineTo(0,0),e.lineTo(0,l*(1/i)),e.fill(),e.beginPath(),e.moveTo(s,l*(1/i)),e.lineTo(s*(1/i),l),e.lineTo(0,l),e.lineTo(0,l*((i-1)/i)),e.lineTo(s*((i-1)/i),0),e.lineTo(s,0),e.lineTo(s,l*(1/i)),e.fill(),e.beginPath(),e.moveTo(s,l*((i-1)/i)),e.lineTo(s*((i-1)/i),l),e.lineTo(s,l),e.lineTo(s,l*((i-1)/i)),e.fill(),n};return a.onMounted(()=>{C.value=new Array(5e3),C.value=C.value.fill(0,0,4999),f.value=de(),G.value=be(),B()}),u({getAnnotations:z,initSegmentSpans:te,render:N,renderViewPort:B,renderSegments:H,renderTimelimeLine:ae,resetComponentState:Y,resetSegmentState:X,clearCanvases:Z}),(n,e)=>(a.openBlock(),a.createElementBlock("div",We,[a.createElementVNode("div",Ee,[a.createElementVNode("div",null,a.toDisplayString(oe.value),1),a.createElementVNode("div",null,a.toDisplayString(le.value),1),a.createElementVNode("div",null,a.toDisplayString(ie.value),1)]),a.createElementVNode("div",Ne,[a.createElementVNode("div",Pe,[a.createElementVNode("div",{id:"canvasWrap",ref_key:"canvasWrap",ref:k},[a.createElementVNode("canvas",{id:"segmentsCanvas",class:"canvas",ref_key:"segmentsCanvas",ref:W,width:V(g.cWidth,f.value,0),height:V(y.value-2,f.value,0),style:a.normalizeStyle(Q.value)},null,12,Re),a.createElementVNode("canvas",{id:"annotationCanvas",class:"canvas",ref_key:"annotationCanvas",ref:j,width:V(g.cWidth,f.value,0),height:V(y.value-2,f.value,0),style:a.normalizeStyle(Q.value)},null,12,Ae),a.createElementVNode("canvas",{id:"iCanvas",class:"canvas",ref_key:"iCanvas",ref:T,width:V(g.cWidth,f.value,0),height:V(y.value,f.value,0),onClick:e[0]||(e[0]=(...r)=>n._onTap&&n._onTap(...r)),onMousemove:ge,onMousedown:he,onMouseup:fe,onMouseenter:me,onMouseout:Se,style:a.normalizeStyle(ce.value)},null,44,Me)],512)])])]))}},De=d._export_sfc(Ve,[["__scopeId","data-v-e01e61cc"]]);exports.default=De;