@pennsieve-viz/tsviewer 1.0.0 → 1.0.1
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-BiLkvU6m.cjs → BFLibraryButton-BI_luZjc.cjs} +1 -1
- package/dist/{BFLibraryButton-C6aAhW1T.js → BFLibraryButton-BP-P5nDS.js} +1 -1
- package/dist/{IconSelection-DGTELjPb.cjs → IconSelection-B3B4x81f.cjs} +1 -1
- package/dist/{IconSelection-Bud2XLOy.js → IconSelection-DkGAJih_.js} +1 -1
- package/dist/{TSAnnotationCanvas-CMZHn8mY.js → TSAnnotationCanvas-CPNo-Z2t.js} +6 -5
- package/dist/TSAnnotationCanvas-Cq5fLEeQ.cjs +1 -0
- package/dist/TSAnnotationModal-BfpdK288.js +4429 -0
- package/dist/TSAnnotationModal-BvPKePsi.cjs +1 -0
- package/dist/{TSFilterModal-BtLOK_nq.js → TSFilterModal-BUuabfh0.js} +59 -55
- package/dist/TSFilterModal-DXfg6Vbt.cjs +1 -0
- package/dist/{TSScrubber-CTjzX-Xq.js → TSScrubber-BWay2z2E.js} +1 -1
- package/dist/{TSScrubber-DAnIUBuC.cjs → TSScrubber-DuOBdGF2.cjs} +1 -1
- package/dist/TSViewerCanvas-BDAfmQM_.cjs +11 -0
- package/dist/{TSViewerCanvas-DkKV70m8.js → TSViewerCanvas-DjV4CQ2G.js} +205 -209
- package/dist/{TSViewerLayerWindow-zI_48DIx.js → TSViewerLayerWindow-BuXB_NVG.js} +39 -36
- package/dist/TSViewerLayerWindow-C40On1cL.cjs +1 -0
- package/dist/TSViewerToolbar-CGLoEe3Z.cjs +1 -0
- package/dist/{TSViewerToolbar-BMZIlD4q.js → TSViewerToolbar-gOCiS_4U.js} +92 -88
- package/dist/{TsAnnotationDeleteDialog-Iwpo79Pe.js → TsAnnotationDeleteDialog-C3P2teV8.js} +82 -80
- package/dist/TsAnnotationDeleteDialog-Dr6JB0ms.cjs +1 -0
- package/dist/_commonjsHelpers-DKOUU3wS.cjs +1 -0
- package/dist/_commonjsHelpers-DaMA6jEr.js +8 -0
- package/dist/base-C3K_VdPK.cjs +12 -0
- package/dist/base-Dd-o8fN6.js +1413 -0
- package/dist/el-button-B3mito7d.cjs +1 -0
- package/dist/el-button-DVykS1Of.js +769 -0
- package/dist/el-input-BQKTli-S.cjs +1 -0
- package/dist/el-input-BxM2cCbI.js +4667 -0
- package/dist/el-input-number-8Z4UFuyU.cjs +1 -0
- package/dist/el-input-number-DtWxZ2F-.js +265 -0
- package/dist/el-overlay-BJQNirx2.cjs +1 -0
- package/dist/el-overlay-DfCO_8B5.js +517 -0
- package/dist/{index-CGSfhm_E.cjs → index-CW1sKrzq.cjs} +1 -1
- package/dist/index-CiwHOd9w.cjs +1 -0
- package/dist/index-CtMh8Ff9.js +22 -0
- package/dist/{index-Cexzl5Xu.js → index-D41jNOo7.js} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{pathOr-Do2dduwx.js → pathOr-CSuna3IF.js} +1 -1
- package/dist/{pathOr-D0158Gk1.cjs → pathOr-DWeJPuhG.cjs} +1 -1
- package/dist/style.css +1 -1
- package/package.json +4 -4
- package/dist/TSAnnotationCanvas-C3-VI46n.cjs +0 -1
- package/dist/TSAnnotationModal-BcqWVXP_.js +0 -199
- package/dist/TSAnnotationModal-DskdoFo4.cjs +0 -1
- package/dist/TSFilterModal-DEOWfIi6.cjs +0 -1
- package/dist/TSViewerCanvas-Jbu-Kh9F.cjs +0 -11
- package/dist/TSViewerLayerWindow-wHkjTl6e.cjs +0 -1
- package/dist/TSViewerToolbar-C6yy7GJr.cjs +0 -1
- package/dist/TsAnnotationDeleteDialog-Be3AJIyo.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("vue"),d=require("./index-CGSfhm_E.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=d.useViewerStore(),k=a.ref(null),W=a.ref(null),B=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,B.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,j=0;for(w.value=[];x<C.value.length-1;){if(!C.value[x]&&!O){x++;continue}else C.value[x]?O||(j=x,O=!0):(w.value=w.value.concat([j,x]),O=!1);x++}O&&(w.value=w.value.concat([j,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):L()}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=()=>{H(),ae(),L()},H=()=>{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())})},L=()=>{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=B.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(),H()}),u({getAnnotations:z,initSegmentSpans:te,render:N,renderViewPort:H,renderSegments:L,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:B,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-8618a902"]]);exports.default=De;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("vue"),d=require("./index-CW1sKrzq.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=d.useViewerStore(),k=a.ref(null),W=a.ref(null),B=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,B.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,j=0;for(w.value=[];x<C.value.length-1;){if(!C.value[x]&&!O){x++;continue}else C.value[x]?O||(j=x,O=!0):(w.value=w.value.concat([j,x]),O=!1);x++}O&&(w.value=w.value.concat([j,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):L()}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=()=>{H(),ae(),L()},H=()=>{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())})},L=()=>{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=B.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(),H()}),u({getAnnotations:z,initSegmentSpans:te,render:N,renderViewPort:H,renderSegments:L,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:B,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-8618a902"]]);exports.default=De;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";const vue=require("vue"),pinia=require("pinia"),index=require("./index-CW1sKrzq.cjs"),_commonjsHelpers=require("./_commonjsHelpers-DKOUU3wS.cjs");var head=index.nth(0),XFind=(function(){function f(c,v){this.xf=v,this.f=c,this.found=!1}return f.prototype["@@transducer/init"]=index._xfBase.init,f.prototype["@@transducer/result"]=function(c){return this.found||(c=this.xf["@@transducer/step"](c,void 0)),this.xf["@@transducer/result"](c)},f.prototype["@@transducer/step"]=function(c,v){return this.f(v)&&(this.found=!0,c=index._reduced(this.xf["@@transducer/step"](c,v))),c},f})(),_xfind=index._curry2(function(c,v){return new XFind(c,v)}),find=index._curry2(index._dispatchable(["find"],_xfind,function(c,v){for(var l=0,o=v.length;l<o;){if(c(v[l]))return v[l];l+=1}})),src={exports:{}},indexLight={exports:{}},indexMinimal={},minimal={},aspromise,hasRequiredAspromise;function requireAspromise(){if(hasRequiredAspromise)return aspromise;hasRequiredAspromise=1,aspromise=f;function f(c,v){for(var l=new Array(arguments.length-1),o=0,i=2,e=!0;i<arguments.length;)l[o++]=arguments[i++];return new Promise(function(t,n){l[o]=function(s){if(e)if(e=!1,s)n(s);else{for(var u=new Array(arguments.length-1),a=0;a<u.length;)u[a++]=arguments[a];t.apply(null,u)}};try{c.apply(v||null,l)}catch(d){e&&(e=!1,n(d))}})}return aspromise}var base64={},hasRequiredBase64;function requireBase64(){return hasRequiredBase64||(hasRequiredBase64=1,(function(f){var c=f;c.length=function(r){var t=r.length;if(!t)return 0;for(var n=0;--t%4>1&&r.charAt(t)==="=";)++n;return Math.ceil(r.length*3)/4-n};for(var v=new Array(64),l=new Array(123),o=0;o<64;)l[v[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;c.encode=function(r,t,n){for(var d=null,s=[],u=0,a=0,h;t<n;){var m=r[t++];switch(a){case 0:s[u++]=v[m>>2],h=(m&3)<<4,a=1;break;case 1:s[u++]=v[h|m>>4],h=(m&15)<<2,a=2;break;case 2:s[u++]=v[h|m>>6],s[u++]=v[m&63],a=0;break}u>8191&&((d||(d=[])).push(String.fromCharCode.apply(String,s)),u=0)}return a&&(s[u++]=v[h],s[u++]=61,a===1&&(s[u++]=61)),d?(u&&d.push(String.fromCharCode.apply(String,s.slice(0,u))),d.join("")):String.fromCharCode.apply(String,s.slice(0,u))};var i="invalid encoding";c.decode=function(r,t,n){for(var d=n,s=0,u,a=0;a<r.length;){var h=r.charCodeAt(a++);if(h===61&&s>1)break;if((h=l[h])===void 0)throw Error(i);switch(s){case 0:u=h,s=1;break;case 1:t[n++]=u<<2|(h&48)>>4,u=h,s=2;break;case 2:t[n++]=(u&15)<<4|(h&60)>>2,u=h,s=3;break;case 3:t[n++]=(u&3)<<6|h,s=0;break}}if(s===1)throw Error(i);return n-d},c.test=function(r){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(r)}})(base64)),base64}var eventemitter,hasRequiredEventemitter;function requireEventemitter(){if(hasRequiredEventemitter)return eventemitter;hasRequiredEventemitter=1,eventemitter=f;function f(){this._listeners={}}return f.prototype.on=function(v,l,o){return(this._listeners[v]||(this._listeners[v]=[])).push({fn:l,ctx:o||this}),this},f.prototype.off=function(v,l){if(v===void 0)this._listeners={};else if(l===void 0)this._listeners[v]=[];else for(var o=this._listeners[v],i=0;i<o.length;)o[i].fn===l?o.splice(i,1):++i;return this},f.prototype.emit=function(v){var l=this._listeners[v];if(l){for(var o=[],i=1;i<arguments.length;)o.push(arguments[i++]);for(i=0;i<l.length;)l[i].fn.apply(l[i++].ctx,o)}return this},eventemitter}var float,hasRequiredFloat;function requireFloat(){if(hasRequiredFloat)return float;hasRequiredFloat=1,float=f(f);function f(i){return typeof Float32Array<"u"?(function(){var e=new Float32Array([-0]),r=new Uint8Array(e.buffer),t=r[3]===128;function n(a,h,m){e[0]=a,h[m]=r[0],h[m+1]=r[1],h[m+2]=r[2],h[m+3]=r[3]}function d(a,h,m){e[0]=a,h[m]=r[3],h[m+1]=r[2],h[m+2]=r[1],h[m+3]=r[0]}i.writeFloatLE=t?n:d,i.writeFloatBE=t?d:n;function s(a,h){return r[0]=a[h],r[1]=a[h+1],r[2]=a[h+2],r[3]=a[h+3],e[0]}function u(a,h){return r[3]=a[h],r[2]=a[h+1],r[1]=a[h+2],r[0]=a[h+3],e[0]}i.readFloatLE=t?s:u,i.readFloatBE=t?u:s})():(function(){function e(t,n,d,s){var u=n<0?1:0;if(u&&(n=-n),n===0)t(1/n>0?0:2147483648,d,s);else if(isNaN(n))t(2143289344,d,s);else if(n>34028234663852886e22)t((u<<31|2139095040)>>>0,d,s);else if(n<11754943508222875e-54)t((u<<31|Math.round(n/1401298464324817e-60))>>>0,d,s);else{var a=Math.floor(Math.log(n)/Math.LN2),h=Math.round(n*Math.pow(2,-a)*8388608)&8388607;t((u<<31|a+127<<23|h)>>>0,d,s)}}i.writeFloatLE=e.bind(null,c),i.writeFloatBE=e.bind(null,v);function r(t,n,d){var s=t(n,d),u=(s>>31)*2+1,a=s>>>23&255,h=s&8388607;return a===255?h?NaN:u*(1/0):a===0?u*1401298464324817e-60*h:u*Math.pow(2,a-150)*(h+8388608)}i.readFloatLE=r.bind(null,l),i.readFloatBE=r.bind(null,o)})(),typeof Float64Array<"u"?(function(){var e=new Float64Array([-0]),r=new Uint8Array(e.buffer),t=r[7]===128;function n(a,h,m){e[0]=a,h[m]=r[0],h[m+1]=r[1],h[m+2]=r[2],h[m+3]=r[3],h[m+4]=r[4],h[m+5]=r[5],h[m+6]=r[6],h[m+7]=r[7]}function d(a,h,m){e[0]=a,h[m]=r[7],h[m+1]=r[6],h[m+2]=r[5],h[m+3]=r[4],h[m+4]=r[3],h[m+5]=r[2],h[m+6]=r[1],h[m+7]=r[0]}i.writeDoubleLE=t?n:d,i.writeDoubleBE=t?d:n;function s(a,h){return r[0]=a[h],r[1]=a[h+1],r[2]=a[h+2],r[3]=a[h+3],r[4]=a[h+4],r[5]=a[h+5],r[6]=a[h+6],r[7]=a[h+7],e[0]}function u(a,h){return r[7]=a[h],r[6]=a[h+1],r[5]=a[h+2],r[4]=a[h+3],r[3]=a[h+4],r[2]=a[h+5],r[1]=a[h+6],r[0]=a[h+7],e[0]}i.readDoubleLE=t?s:u,i.readDoubleBE=t?u:s})():(function(){function e(t,n,d,s,u,a){var h=s<0?1:0;if(h&&(s=-s),s===0)t(0,u,a+n),t(1/s>0?0:2147483648,u,a+d);else if(isNaN(s))t(0,u,a+n),t(2146959360,u,a+d);else if(s>17976931348623157e292)t(0,u,a+n),t((h<<31|2146435072)>>>0,u,a+d);else{var m;if(s<22250738585072014e-324)m=s/5e-324,t(m>>>0,u,a+n),t((h<<31|m/4294967296)>>>0,u,a+d);else{var R=Math.floor(Math.log(s)/Math.LN2);R===1024&&(R=1023),m=s*Math.pow(2,-R),t(m*4503599627370496>>>0,u,a+n),t((h<<31|R+1023<<20|m*1048576&1048575)>>>0,u,a+d)}}}i.writeDoubleLE=e.bind(null,c,0,4),i.writeDoubleBE=e.bind(null,v,4,0);function r(t,n,d,s,u){var a=t(s,u+n),h=t(s,u+d),m=(h>>31)*2+1,R=h>>>20&2047,g=4294967296*(h&1048575)+a;return R===2047?g?NaN:m*(1/0):R===0?m*5e-324*g:m*Math.pow(2,R-1075)*(g+4503599627370496)}i.readDoubleLE=r.bind(null,l,0,4),i.readDoubleBE=r.bind(null,o,4,0)})(),i}function c(i,e,r){e[r]=i&255,e[r+1]=i>>>8&255,e[r+2]=i>>>16&255,e[r+3]=i>>>24}function v(i,e,r){e[r]=i>>>24,e[r+1]=i>>>16&255,e[r+2]=i>>>8&255,e[r+3]=i&255}function l(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16|i[e+3]<<24)>>>0}function o(i,e){return(i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3])>>>0}return float}var inquire_1,hasRequiredInquire;function requireInquire(){if(hasRequiredInquire)return inquire_1;hasRequiredInquire=1,inquire_1=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(f){}return null}return inquire_1}var utf8={},hasRequiredUtf8;function requireUtf8(){return hasRequiredUtf8||(hasRequiredUtf8=1,(function(f){var c=f;c.length=function(l){for(var o=0,i=0,e=0;e<l.length;++e)i=l.charCodeAt(e),i<128?o+=1:i<2048?o+=2:(i&64512)===55296&&(l.charCodeAt(e+1)&64512)===56320?(++e,o+=4):o+=3;return o},c.read=function(l,o,i){var e=i-o;if(e<1)return"";for(var r=null,t=[],n=0,d;o<i;)d=l[o++],d<128?t[n++]=d:d>191&&d<224?t[n++]=(d&31)<<6|l[o++]&63:d>239&&d<365?(d=((d&7)<<18|(l[o++]&63)<<12|(l[o++]&63)<<6|l[o++]&63)-65536,t[n++]=55296+(d>>10),t[n++]=56320+(d&1023)):t[n++]=(d&15)<<12|(l[o++]&63)<<6|l[o++]&63,n>8191&&((r||(r=[])).push(String.fromCharCode.apply(String,t)),n=0);return r?(n&&r.push(String.fromCharCode.apply(String,t.slice(0,n))),r.join("")):String.fromCharCode.apply(String,t.slice(0,n))},c.write=function(l,o,i){for(var e=i,r,t,n=0;n<l.length;++n)r=l.charCodeAt(n),r<128?o[i++]=r:r<2048?(o[i++]=r>>6|192,o[i++]=r&63|128):(r&64512)===55296&&((t=l.charCodeAt(n+1))&64512)===56320?(r=65536+((r&1023)<<10)+(t&1023),++n,o[i++]=r>>18|240,o[i++]=r>>12&63|128,o[i++]=r>>6&63|128,o[i++]=r&63|128):(o[i++]=r>>12|224,o[i++]=r>>6&63|128,o[i++]=r&63|128);return i-e}})(utf8)),utf8}var pool_1,hasRequiredPool;function requirePool(){if(hasRequiredPool)return pool_1;hasRequiredPool=1,pool_1=f;function f(c,v,l){var o=l||8192,i=o>>>1,e=null,r=o;return function(n){if(n<1||n>i)return c(n);r+n>o&&(e=c(o),r=0);var d=v.call(e,r,r+=n);return r&7&&(r=(r|7)+1),d}}return pool_1}var longbits,hasRequiredLongbits;function requireLongbits(){if(hasRequiredLongbits)return longbits;hasRequiredLongbits=1,longbits=c;var f=requireMinimal();function c(i,e){this.lo=i>>>0,this.hi=e>>>0}var v=c.zero=new c(0,0);v.toNumber=function(){return 0},v.zzEncode=v.zzDecode=function(){return this},v.length=function(){return 1};var l=c.zeroHash="\0\0\0\0\0\0\0\0";c.fromNumber=function(e){if(e===0)return v;var r=e<0;r&&(e=-e);var t=e>>>0,n=(e-t)/4294967296>>>0;return r&&(n=~n>>>0,t=~t>>>0,++t>4294967295&&(t=0,++n>4294967295&&(n=0))),new c(t,n)},c.from=function(e){if(typeof e=="number")return c.fromNumber(e);if(f.isString(e))if(f.Long)e=f.Long.fromString(e);else return c.fromNumber(parseInt(e,10));return e.low||e.high?new c(e.low>>>0,e.high>>>0):v},c.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var r=~this.lo+1>>>0,t=~this.hi>>>0;return r||(t=t+1>>>0),-(r+t*4294967296)}return this.lo+this.hi*4294967296},c.prototype.toLong=function(e){return f.Long?new f.Long(this.lo|0,this.hi|0,!!e):{low:this.lo|0,high:this.hi|0,unsigned:!!e}};var o=String.prototype.charCodeAt;return c.fromHash=function(e){return e===l?v:new c((o.call(e,0)|o.call(e,1)<<8|o.call(e,2)<<16|o.call(e,3)<<24)>>>0,(o.call(e,4)|o.call(e,5)<<8|o.call(e,6)<<16|o.call(e,7)<<24)>>>0)},c.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},c.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},c.prototype.zzDecode=function(){var e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},c.prototype.length=function(){var e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,t=this.hi>>>24;return t===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:t<128?9:10},longbits}var hasRequiredMinimal;function requireMinimal(){return hasRequiredMinimal||(hasRequiredMinimal=1,(function(f){var c=f;c.asPromise=requireAspromise(),c.base64=requireBase64(),c.EventEmitter=requireEventemitter(),c.float=requireFloat(),c.inquire=requireInquire(),c.utf8=requireUtf8(),c.pool=requirePool(),c.LongBits=requireLongbits(),c.isNode=!!(typeof _commonjsHelpers.commonjsGlobal<"u"&&_commonjsHelpers.commonjsGlobal&&_commonjsHelpers.commonjsGlobal.process&&_commonjsHelpers.commonjsGlobal.process.versions&&_commonjsHelpers.commonjsGlobal.process.versions.node),c.global=c.isNode&&_commonjsHelpers.commonjsGlobal||typeof window<"u"&&window||typeof self<"u"&&self||minimal,c.emptyArray=Object.freeze?Object.freeze([]):[],c.emptyObject=Object.freeze?Object.freeze({}):{},c.isInteger=Number.isInteger||function(i){return typeof i=="number"&&isFinite(i)&&Math.floor(i)===i},c.isString=function(i){return typeof i=="string"||i instanceof String},c.isObject=function(i){return i&&typeof i=="object"},c.isset=c.isSet=function(i,e){var r=i[e];return r!=null&&i.hasOwnProperty(e)?typeof r!="object"||(Array.isArray(r)?r.length:Object.keys(r).length)>0:!1},c.Buffer=(function(){try{var o=c.inquire("buffer").Buffer;return o.prototype.utf8Write?o:null}catch{return null}})(),c._Buffer_from=null,c._Buffer_allocUnsafe=null,c.newBuffer=function(i){return typeof i=="number"?c.Buffer?c._Buffer_allocUnsafe(i):new c.Array(i):c.Buffer?c._Buffer_from(i):typeof Uint8Array>"u"?i:new Uint8Array(i)},c.Array=typeof Uint8Array<"u"?Uint8Array:Array,c.Long=c.global.dcodeIO&&c.global.dcodeIO.Long||c.global.Long||c.inquire("long"),c.key2Re=/^true|false|0|1$/,c.key32Re=/^-?(?:0|[1-9][0-9]*)$/,c.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,c.longToHash=function(i){return i?c.LongBits.from(i).toHash():c.LongBits.zeroHash},c.longFromHash=function(i,e){var r=c.LongBits.fromHash(i);return c.Long?c.Long.fromBits(r.lo,r.hi,e):r.toNumber(!!e)};function v(o,i,e){for(var r=Object.keys(i),t=0;t<r.length;++t)(o[r[t]]===void 0||!e)&&(o[r[t]]=i[r[t]]);return o}c.merge=v,c.lcFirst=function(i){return i.charAt(0).toLowerCase()+i.substring(1)};function l(o){function i(e,r){if(!(this instanceof i))return new i(e,r);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,i):Object.defineProperty(this,"stack",{value:new Error().stack||""}),r&&v(this,r)}return i.prototype=Object.create(Error.prototype,{constructor:{value:i,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return o},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),i}c.newError=l,c.ProtocolError=l("ProtocolError"),c.oneOfGetter=function(i){for(var e={},r=0;r<i.length;++r)e[i[r]]=1;return function(){for(var t=Object.keys(this),n=t.length-1;n>-1;--n)if(e[t[n]]===1&&this[t[n]]!==void 0&&this[t[n]]!==null)return t[n]}},c.oneOfSetter=function(i){return function(e){for(var r=0;r<i.length;++r)i[r]!==e&&delete this[i[r]]}},c.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},c._configure=function(){var o=c.Buffer;if(!o){c._Buffer_from=c._Buffer_allocUnsafe=null;return}c._Buffer_from=o.from!==Uint8Array.from&&o.from||function(e,r){return new o(e,r)},c._Buffer_allocUnsafe=o.allocUnsafe||function(e){return new o(e)}}})(minimal)),minimal}var writer,hasRequiredWriter;function requireWriter(){if(hasRequiredWriter)return writer;hasRequiredWriter=1,writer=t;var f=requireMinimal(),c,v=f.LongBits,l=f.base64,o=f.utf8;function i(R,g,y){this.fn=R,this.len=g,this.next=void 0,this.val=y}function e(){}function r(R){this.head=R.head,this.tail=R.tail,this.len=R.len,this.next=R.states}function t(){this.len=0,this.head=new i(e,0,0),this.tail=this.head,this.states=null}var n=function(){return f.Buffer?function(){return(t.create=function(){return new c})()}:function(){return new t}};t.create=n(),t.alloc=function(g){return new f.Array(g)},f.Array!==Array&&(t.alloc=f.pool(t.alloc,f.Array.prototype.subarray)),t.prototype._push=function(g,y,O){return this.tail=this.tail.next=new i(g,y,O),this.len+=y,this};function d(R,g,y){g[y]=R&255}function s(R,g,y){for(;R>127;)g[y++]=R&127|128,R>>>=7;g[y]=R}function u(R,g){this.len=R,this.next=void 0,this.val=g}u.prototype=Object.create(i.prototype),u.prototype.fn=s,t.prototype.uint32=function(g){return this.len+=(this.tail=this.tail.next=new u((g=g>>>0)<128?1:g<16384?2:g<2097152?3:g<268435456?4:5,g)).len,this},t.prototype.int32=function(g){return g<0?this._push(a,10,v.fromNumber(g)):this.uint32(g)},t.prototype.sint32=function(g){return this.uint32((g<<1^g>>31)>>>0)};function a(R,g,y){for(;R.hi;)g[y++]=R.lo&127|128,R.lo=(R.lo>>>7|R.hi<<25)>>>0,R.hi>>>=7;for(;R.lo>127;)g[y++]=R.lo&127|128,R.lo=R.lo>>>7;g[y++]=R.lo}t.prototype.uint64=function(g){var y=v.from(g);return this._push(a,y.length(),y)},t.prototype.int64=t.prototype.uint64,t.prototype.sint64=function(g){var y=v.from(g).zzEncode();return this._push(a,y.length(),y)},t.prototype.bool=function(g){return this._push(d,1,g?1:0)};function h(R,g,y){g[y]=R&255,g[y+1]=R>>>8&255,g[y+2]=R>>>16&255,g[y+3]=R>>>24}t.prototype.fixed32=function(g){return this._push(h,4,g>>>0)},t.prototype.sfixed32=t.prototype.fixed32,t.prototype.fixed64=function(g){var y=v.from(g);return this._push(h,4,y.lo)._push(h,4,y.hi)},t.prototype.sfixed64=t.prototype.fixed64,t.prototype.float=function(g){return this._push(f.float.writeFloatLE,4,g)},t.prototype.double=function(g){return this._push(f.float.writeDoubleLE,8,g)};var m=f.Array.prototype.set?function(g,y,O){y.set(g,O)}:function(g,y,O){for(var b=0;b<g.length;++b)y[O+b]=g[b]};return t.prototype.bytes=function(g){var y=g.length>>>0;if(!y)return this._push(d,1,0);if(f.isString(g)){var O=t.alloc(y=l.length(g));l.decode(g,O,0),g=O}return this.uint32(y)._push(m,y,g)},t.prototype.string=function(g){var y=o.length(g);return y?this.uint32(y)._push(o.write,y,g):this._push(d,1,0)},t.prototype.fork=function(){return this.states=new r(this),this.head=this.tail=new i(e,0,0),this.len=0,this},t.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new i(e,0,0),this.len=0),this},t.prototype.ldelim=function(){var g=this.head,y=this.tail,O=this.len;return this.reset().uint32(O),O&&(this.tail.next=g.next,this.tail=y,this.len+=O),this},t.prototype.finish=function(){for(var g=this.head.next,y=this.constructor.alloc(this.len),O=0;g;)g.fn(g.val,y,O),O+=g.len,g=g.next;return y},t._configure=function(R){c=R,t.create=n(),c._configure()},writer}var writer_buffer,hasRequiredWriter_buffer;function requireWriter_buffer(){if(hasRequiredWriter_buffer)return writer_buffer;hasRequiredWriter_buffer=1,writer_buffer=v;var f=requireWriter();(v.prototype=Object.create(f.prototype)).constructor=v;var c=requireMinimal();function v(){f.call(this)}v._configure=function(){v.alloc=c._Buffer_allocUnsafe,v.writeBytesBuffer=c.Buffer&&c.Buffer.prototype instanceof Uint8Array&&c.Buffer.prototype.set.name==="set"?function(i,e,r){e.set(i,r)}:function(i,e,r){if(i.copy)i.copy(e,r,0,i.length);else for(var t=0;t<i.length;)e[r++]=i[t++]}},v.prototype.bytes=function(i){c.isString(i)&&(i=c._Buffer_from(i,"base64"));var e=i.length>>>0;return this.uint32(e),e&&this._push(v.writeBytesBuffer,e,i),this};function l(o,i,e){o.length<40?c.utf8.write(o,i,e):i.utf8Write?i.utf8Write(o,e):i.write(o,e)}return v.prototype.string=function(i){var e=c.Buffer.byteLength(i);return this.uint32(e),e&&this._push(l,e,i),this},v._configure(),writer_buffer}var reader,hasRequiredReader;function requireReader(){if(hasRequiredReader)return reader;hasRequiredReader=1,reader=i;var f=requireMinimal(),c,v=f.LongBits,l=f.utf8;function o(s,u){return RangeError("index out of range: "+s.pos+" + "+(u||1)+" > "+s.len)}function i(s){this.buf=s,this.pos=0,this.len=s.length}var e=typeof Uint8Array<"u"?function(u){if(u instanceof Uint8Array||Array.isArray(u))return new i(u);throw Error("illegal buffer")}:function(u){if(Array.isArray(u))return new i(u);throw Error("illegal buffer")},r=function(){return f.Buffer?function(a){return(i.create=function(m){return f.Buffer.isBuffer(m)?new c(m):e(m)})(a)}:e};i.create=r(),i.prototype._slice=f.Array.prototype.subarray||f.Array.prototype.slice,i.prototype.uint32=(function(){var u=4294967295;return function(){if(u=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(u=(u|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(u=(u|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(u=(u|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(u=(u|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return u;if((this.pos+=5)>this.len)throw this.pos=this.len,o(this,10);return u}})(),i.prototype.int32=function(){return this.uint32()|0},i.prototype.sint32=function(){var u=this.uint32();return u>>>1^-(u&1)|0};function t(){var s=new v(0,0),u=0;if(this.len-this.pos>4){for(;u<4;++u)if(s.lo=(s.lo|(this.buf[this.pos]&127)<<u*7)>>>0,this.buf[this.pos++]<128)return s;if(s.lo=(s.lo|(this.buf[this.pos]&127)<<28)>>>0,s.hi=(s.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return s;u=0}else{for(;u<3;++u){if(this.pos>=this.len)throw o(this);if(s.lo=(s.lo|(this.buf[this.pos]&127)<<u*7)>>>0,this.buf[this.pos++]<128)return s}return s.lo=(s.lo|(this.buf[this.pos++]&127)<<u*7)>>>0,s}if(this.len-this.pos>4){for(;u<5;++u)if(s.hi=(s.hi|(this.buf[this.pos]&127)<<u*7+3)>>>0,this.buf[this.pos++]<128)return s}else for(;u<5;++u){if(this.pos>=this.len)throw o(this);if(s.hi=(s.hi|(this.buf[this.pos]&127)<<u*7+3)>>>0,this.buf[this.pos++]<128)return s}throw Error("invalid varint encoding")}i.prototype.bool=function(){return this.uint32()!==0};function n(s,u){return(s[u-4]|s[u-3]<<8|s[u-2]<<16|s[u-1]<<24)>>>0}i.prototype.fixed32=function(){if(this.pos+4>this.len)throw o(this,4);return n(this.buf,this.pos+=4)},i.prototype.sfixed32=function(){if(this.pos+4>this.len)throw o(this,4);return n(this.buf,this.pos+=4)|0};function d(){if(this.pos+8>this.len)throw o(this,8);return new v(n(this.buf,this.pos+=4),n(this.buf,this.pos+=4))}return i.prototype.float=function(){if(this.pos+4>this.len)throw o(this,4);var u=f.float.readFloatLE(this.buf,this.pos);return this.pos+=4,u},i.prototype.double=function(){if(this.pos+8>this.len)throw o(this,4);var u=f.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,u},i.prototype.bytes=function(){var u=this.uint32(),a=this.pos,h=this.pos+u;if(h>this.len)throw o(this,u);if(this.pos+=u,Array.isArray(this.buf))return this.buf.slice(a,h);if(a===h){var m=f.Buffer;return m?m.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,a,h)},i.prototype.string=function(){var u=this.bytes();return l.read(u,0,u.length)},i.prototype.skip=function(u){if(typeof u=="number"){if(this.pos+u>this.len)throw o(this,u);this.pos+=u}else do if(this.pos>=this.len)throw o(this);while(this.buf[this.pos++]&128);return this},i.prototype.skipType=function(s){switch(s){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(s=this.uint32()&7)!==4;)this.skipType(s);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+s+" at offset "+this.pos)}return this},i._configure=function(s){c=s,i.create=r(),c._configure();var u=f.Long?"toLong":"toNumber";f.merge(i.prototype,{int64:function(){return t.call(this)[u](!1)},uint64:function(){return t.call(this)[u](!0)},sint64:function(){return t.call(this).zzDecode()[u](!1)},fixed64:function(){return d.call(this)[u](!0)},sfixed64:function(){return d.call(this)[u](!1)}})},reader}var reader_buffer,hasRequiredReader_buffer;function requireReader_buffer(){if(hasRequiredReader_buffer)return reader_buffer;hasRequiredReader_buffer=1,reader_buffer=v;var f=requireReader();(v.prototype=Object.create(f.prototype)).constructor=v;var c=requireMinimal();function v(l){f.call(this,l)}return v._configure=function(){c.Buffer&&(v.prototype._slice=c.Buffer.prototype.slice)},v.prototype.string=function(){var o=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+o,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+o,this.len))},v._configure(),reader_buffer}var rpc={},service$1,hasRequiredService$1;function requireService$1(){if(hasRequiredService$1)return service$1;hasRequiredService$1=1,service$1=c;var f=requireMinimal();(c.prototype=Object.create(f.EventEmitter.prototype)).constructor=c;function c(v,l,o){if(typeof v!="function")throw TypeError("rpcImpl must be a function");f.EventEmitter.call(this),this.rpcImpl=v,this.requestDelimited=!!l,this.responseDelimited=!!o}return c.prototype.rpcCall=function v(l,o,i,e,r){if(!e)throw TypeError("request must be specified");var t=this;if(!r)return f.asPromise(v,t,l,o,i,e);if(!t.rpcImpl){setTimeout(function(){r(Error("already ended"))},0);return}try{return t.rpcImpl(l,o[t.requestDelimited?"encodeDelimited":"encode"](e).finish(),function(d,s){if(d)return t.emit("error",d,l),r(d);if(s===null){t.end(!0);return}if(!(s instanceof i))try{s=i[t.responseDelimited?"decodeDelimited":"decode"](s)}catch(u){return t.emit("error",u,l),r(u)}return t.emit("data",s,l),r(null,s)})}catch(n){t.emit("error",n,l),setTimeout(function(){r(n)},0);return}},c.prototype.end=function(l){return this.rpcImpl&&(l||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this},service$1}var hasRequiredRpc;function requireRpc(){return hasRequiredRpc||(hasRequiredRpc=1,(function(f){var c=f;c.Service=requireService$1()})(rpc)),rpc}var roots,hasRequiredRoots;function requireRoots(){return hasRequiredRoots||(hasRequiredRoots=1,roots={}),roots}var hasRequiredIndexMinimal;function requireIndexMinimal(){return hasRequiredIndexMinimal||(hasRequiredIndexMinimal=1,(function(f){var c=f;c.build="minimal",c.Writer=requireWriter(),c.BufferWriter=requireWriter_buffer(),c.Reader=requireReader(),c.BufferReader=requireReader_buffer(),c.util=requireMinimal(),c.rpc=requireRpc(),c.roots=requireRoots(),c.configure=v;function v(){c.util._configure(),c.Writer._configure(c.BufferWriter),c.Reader._configure(c.BufferReader)}v()})(indexMinimal)),indexMinimal}var types={},util={exports:{}},codegen_1,hasRequiredCodegen;function requireCodegen(){if(hasRequiredCodegen)return codegen_1;hasRequiredCodegen=1,codegen_1=f;function f(c,v){typeof c=="string"&&(v=c,c=void 0);var l=[];function o(e){if(typeof e!="string"){var r=i();if(f.verbose&&console.log("codegen: "+r),r="return "+r,e){for(var t=Object.keys(e),n=new Array(t.length+1),d=new Array(t.length),s=0;s<t.length;)n[s]=t[s],d[s]=e[t[s++]];return n[s]=r,Function.apply(null,n).apply(null,d)}return Function(r)()}for(var u=new Array(arguments.length-1),a=0;a<u.length;)u[a]=arguments[++a];if(a=0,e=e.replace(/%([%dfijs])/g,function(m,R){var g=u[a++];switch(R){case"d":case"f":return String(Number(g));case"i":return String(Math.floor(g));case"j":return JSON.stringify(g);case"s":return String(g)}return"%"}),a!==u.length)throw Error("parameter count mismatch");return l.push(e),o}function i(e){return"function "+(e||v||"")+"("+(c&&c.join(",")||"")+`){
|
|
2
|
+
`+l.join(`
|
|
3
|
+
`)+`
|
|
4
|
+
}`}return o.toString=i,o}return f.verbose=!1,codegen_1}var fetch_1,hasRequiredFetch;function requireFetch(){if(hasRequiredFetch)return fetch_1;hasRequiredFetch=1,fetch_1=l;var f=requireAspromise(),c=requireInquire(),v=c("fs");function l(o,i,e){return typeof i=="function"?(e=i,i={}):i||(i={}),e?!i.xhr&&v&&v.readFile?v.readFile(o,function(t,n){return t&&typeof XMLHttpRequest<"u"?l.xhr(o,i,e):t?e(t):e(null,i.binary?n:n.toString("utf8"))}):l.xhr(o,i,e):f(l,this,o,i)}return l.xhr=function(i,e,r){var t=new XMLHttpRequest;t.onreadystatechange=function(){if(t.readyState===4){if(t.status!==0&&t.status!==200)return r(Error("status "+t.status));if(e.binary){var d=t.response;if(!d){d=[];for(var s=0;s<t.responseText.length;++s)d.push(t.responseText.charCodeAt(s)&255)}return r(null,typeof Uint8Array<"u"?new Uint8Array(d):d)}return r(null,t.responseText)}},e.binary&&("overrideMimeType"in t&&t.overrideMimeType("text/plain; charset=x-user-defined"),t.responseType="arraybuffer"),t.open("GET",i),t.send()},fetch_1}var path={},hasRequiredPath;function requirePath(){return hasRequiredPath||(hasRequiredPath=1,(function(f){var c=f,v=c.isAbsolute=function(i){return/^(?:\/|\w+:)/.test(i)},l=c.normalize=function(i){i=i.replace(/\\/g,"/").replace(/\/{2,}/g,"/");var e=i.split("/"),r=v(i),t="";r&&(t=e.shift()+"/");for(var n=0;n<e.length;)e[n]===".."?n>0&&e[n-1]!==".."?e.splice(--n,2):r?e.splice(n,1):++n:e[n]==="."?e.splice(n,1):++n;return t+e.join("/")};c.resolve=function(i,e,r){return r||(e=l(e)),v(e)?e:(r||(i=l(i)),(i=i.replace(/(?:\/|^)[^/]+$/,"")).length?l(i+"/"+e):e)}})(path)),path}var namespace,hasRequiredNamespace;function requireNamespace(){if(hasRequiredNamespace)return namespace;hasRequiredNamespace=1,namespace=t;var f=requireObject();((t.prototype=Object.create(f.prototype)).constructor=t).className="Namespace";var c=requireField(),v=requireUtil(),l=requireOneof(),o,i,e;t.fromJSON=function(s,u){return new t(s,u.options).addJSON(u.nested)};function r(d,s){if(d&&d.length){for(var u={},a=0;a<d.length;++a)u[d[a].name]=d[a].toJSON(s);return u}}t.arrayToJSON=r,t.isReservedId=function(s,u){if(s){for(var a=0;a<s.length;++a)if(typeof s[a]!="string"&&s[a][0]<=u&&s[a][1]>u)return!0}return!1},t.isReservedName=function(s,u){if(s){for(var a=0;a<s.length;++a)if(s[a]===u)return!0}return!1};function t(d,s){f.call(this,d,s),this.nested=void 0,this._nestedArray=null,this._lookupCache={},this._needsRecursiveFeatureResolution=!0,this._needsRecursiveResolve=!0}function n(d){d._nestedArray=null,d._lookupCache={};for(var s=d;s=s.parent;)s._lookupCache={};return d}return Object.defineProperty(t.prototype,"nestedArray",{get:function(){return this._nestedArray||(this._nestedArray=v.toArray(this.nested))}}),t.prototype.toJSON=function(s){return v.toObject(["options",this.options,"nested",r(this.nestedArray,s)])},t.prototype.addJSON=function(s){var u=this;if(s)for(var a=Object.keys(s),h=0,m;h<a.length;++h)m=s[a[h]],u.add((m.fields!==void 0?o.fromJSON:m.values!==void 0?e.fromJSON:m.methods!==void 0?i.fromJSON:m.id!==void 0?c.fromJSON:t.fromJSON)(a[h],m));return this},t.prototype.get=function(s){return this.nested&&this.nested[s]||null},t.prototype.getEnum=function(s){if(this.nested&&this.nested[s]instanceof e)return this.nested[s].values;throw Error("no such enum: "+s)},t.prototype.add=function(s){if(!(s instanceof c&&s.extend!==void 0||s instanceof o||s instanceof l||s instanceof e||s instanceof i||s instanceof t))throw TypeError("object must be a valid nested object");if(!this.nested)this.nested={};else{var u=this.get(s.name);if(u)if(u instanceof t&&s instanceof t&&!(u instanceof o||u instanceof i)){for(var a=u.nestedArray,h=0;h<a.length;++h)s.add(a[h]);this.remove(u),this.nested||(this.nested={}),s.setOptions(u.options,!0)}else throw Error("duplicate name '"+s.name+"' in "+this)}this.nested[s.name]=s,this instanceof o||this instanceof i||this instanceof e||this instanceof c||s._edition||(s._edition=s._defaultEdition),this._needsRecursiveFeatureResolution=!0,this._needsRecursiveResolve=!0;for(var m=this;m=m.parent;)m._needsRecursiveFeatureResolution=!0,m._needsRecursiveResolve=!0;return s.onAdd(this),n(this)},t.prototype.remove=function(s){if(!(s instanceof f))throw TypeError("object must be a ReflectionObject");if(s.parent!==this)throw Error(s+" is not a member of "+this);return delete this.nested[s.name],Object.keys(this.nested).length||(this.nested=void 0),s.onRemove(this),n(this)},t.prototype.define=function(s,u){if(v.isString(s))s=s.split(".");else if(!Array.isArray(s))throw TypeError("illegal path");if(s&&s.length&&s[0]==="")throw Error("path must be relative");for(var a=this;s.length>0;){var h=s.shift();if(a.nested&&a.nested[h]){if(a=a.nested[h],!(a instanceof t))throw Error("path conflicts with non-namespace objects")}else a.add(a=new t(h))}return u&&a.addJSON(u),a},t.prototype.resolveAll=function(){if(!this._needsRecursiveResolve)return this;this._resolveFeaturesRecursive(this._edition);var s=this.nestedArray,u=0;for(this.resolve();u<s.length;)s[u]instanceof t?s[u++].resolveAll():s[u++].resolve();return this._needsRecursiveResolve=!1,this},t.prototype._resolveFeaturesRecursive=function(s){return this._needsRecursiveFeatureResolution?(this._needsRecursiveFeatureResolution=!1,s=this._edition||s,f.prototype._resolveFeaturesRecursive.call(this,s),this.nestedArray.forEach(u=>{u._resolveFeaturesRecursive(s)}),this):this},t.prototype.lookup=function(s,u,a){if(typeof u=="boolean"?(a=u,u=void 0):u&&!Array.isArray(u)&&(u=[u]),v.isString(s)&&s.length){if(s===".")return this.root;s=s.split(".")}else if(!s.length)return this;var h=s.join(".");if(s[0]==="")return this.root.lookup(s.slice(1),u);var m=this.root._fullyQualifiedObjects&&this.root._fullyQualifiedObjects["."+h];if(m&&(!u||u.indexOf(m.constructor)>-1)||(m=this._lookupImpl(s,h),m&&(!u||u.indexOf(m.constructor)>-1)))return m;if(a)return null;for(var R=this;R.parent;){if(m=R.parent._lookupImpl(s,h),m&&(!u||u.indexOf(m.constructor)>-1))return m;R=R.parent}return null},t.prototype._lookupImpl=function(s,u){if(Object.prototype.hasOwnProperty.call(this._lookupCache,u))return this._lookupCache[u];var a=this.get(s[0]),h=null;if(a)s.length===1?h=a:a instanceof t&&(s=s.slice(1),h=a._lookupImpl(s,s.join(".")));else for(var m=0;m<this.nestedArray.length;++m)this._nestedArray[m]instanceof t&&(a=this._nestedArray[m]._lookupImpl(s,u))&&(h=a);return this._lookupCache[u]=h,h},t.prototype.lookupType=function(s){var u=this.lookup(s,[o]);if(!u)throw Error("no such type: "+s);return u},t.prototype.lookupEnum=function(s){var u=this.lookup(s,[e]);if(!u)throw Error("no such Enum '"+s+"' in "+this);return u},t.prototype.lookupTypeOrEnum=function(s){var u=this.lookup(s,[o,e]);if(!u)throw Error("no such Type or Enum '"+s+"' in "+this);return u},t.prototype.lookupService=function(s){var u=this.lookup(s,[i]);if(!u)throw Error("no such Service '"+s+"' in "+this);return u},t._configure=function(d,s,u){o=d,i=s,e=u},namespace}var mapfield,hasRequiredMapfield;function requireMapfield(){if(hasRequiredMapfield)return mapfield;hasRequiredMapfield=1,mapfield=l;var f=requireField();((l.prototype=Object.create(f.prototype)).constructor=l).className="MapField";var c=requireTypes(),v=requireUtil();function l(o,i,e,r,t,n){if(f.call(this,o,i,r,void 0,void 0,t,n),!v.isString(e))throw TypeError("keyType must be a string");this.keyType=e,this.resolvedKeyType=null,this.map=!0}return l.fromJSON=function(i,e){return new l(i,e.id,e.keyType,e.type,e.options,e.comment)},l.prototype.toJSON=function(i){var e=i?!!i.keepComments:!1;return v.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",e?this.comment:void 0])},l.prototype.resolve=function(){if(this.resolved)return this;if(c.mapKey[this.keyType]===void 0)throw Error("invalid key type: "+this.keyType);return f.prototype.resolve.call(this)},l.d=function(i,e,r){return typeof r=="function"?r=v.decorateType(r).name:r&&typeof r=="object"&&(r=v.decorateEnum(r).name),function(n,d){v.decorateType(n.constructor).add(new l(d,i,e,r))}},mapfield}var method,hasRequiredMethod;function requireMethod(){if(hasRequiredMethod)return method;hasRequiredMethod=1,method=v;var f=requireObject();((v.prototype=Object.create(f.prototype)).constructor=v).className="Method";var c=requireUtil();function v(l,o,i,e,r,t,n,d,s){if(c.isObject(r)?(n=r,r=t=void 0):c.isObject(t)&&(n=t,t=void 0),!(o===void 0||c.isString(o)))throw TypeError("type must be a string");if(!c.isString(i))throw TypeError("requestType must be a string");if(!c.isString(e))throw TypeError("responseType must be a string");f.call(this,l,n),this.type=o||"rpc",this.requestType=i,this.requestStream=r?!0:void 0,this.responseType=e,this.responseStream=t?!0:void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=d,this.parsedOptions=s}return v.fromJSON=function(o,i){return new v(o,i.type,i.requestType,i.responseType,i.requestStream,i.responseStream,i.options,i.comment,i.parsedOptions)},v.prototype.toJSON=function(o){var i=o?!!o.keepComments:!1;return c.toObject(["type",this.type!=="rpc"&&this.type||void 0,"requestType",this.requestType,"requestStream",this.requestStream,"responseType",this.responseType,"responseStream",this.responseStream,"options",this.options,"comment",i?this.comment:void 0,"parsedOptions",this.parsedOptions])},v.prototype.resolve=function(){return this.resolved?this:(this.resolvedRequestType=this.parent.lookupType(this.requestType),this.resolvedResponseType=this.parent.lookupType(this.responseType),f.prototype.resolve.call(this))},method}var service,hasRequiredService;function requireService(){if(hasRequiredService)return service;hasRequiredService=1,service=o;var f=requireNamespace();((o.prototype=Object.create(f.prototype)).constructor=o).className="Service";var c=requireMethod(),v=requireUtil(),l=requireRpc();function o(e,r){f.call(this,e,r),this.methods={},this._methodsArray=null}o.fromJSON=function(r,t){var n=new o(r,t.options);if(t.methods)for(var d=Object.keys(t.methods),s=0;s<d.length;++s)n.add(c.fromJSON(d[s],t.methods[d[s]]));return t.nested&&n.addJSON(t.nested),t.edition&&(n._edition=t.edition),n.comment=t.comment,n._defaultEdition="proto3",n},o.prototype.toJSON=function(r){var t=f.prototype.toJSON.call(this,r),n=r?!!r.keepComments:!1;return v.toObject(["edition",this._editionToJSON(),"options",t&&t.options||void 0,"methods",f.arrayToJSON(this.methodsArray,r)||{},"nested",t&&t.nested||void 0,"comment",n?this.comment:void 0])},Object.defineProperty(o.prototype,"methodsArray",{get:function(){return this._methodsArray||(this._methodsArray=v.toArray(this.methods))}});function i(e){return e._methodsArray=null,e}return o.prototype.get=function(r){return this.methods[r]||f.prototype.get.call(this,r)},o.prototype.resolveAll=function(){if(!this._needsRecursiveResolve)return this;f.prototype.resolve.call(this);for(var r=this.methodsArray,t=0;t<r.length;++t)r[t].resolve();return this},o.prototype._resolveFeaturesRecursive=function(r){return this._needsRecursiveFeatureResolution?(r=this._edition||r,f.prototype._resolveFeaturesRecursive.call(this,r),this.methodsArray.forEach(t=>{t._resolveFeaturesRecursive(r)}),this):this},o.prototype.add=function(r){if(this.get(r.name))throw Error("duplicate name '"+r.name+"' in "+this);return r instanceof c?(this.methods[r.name]=r,r.parent=this,i(this)):f.prototype.add.call(this,r)},o.prototype.remove=function(r){if(r instanceof c){if(this.methods[r.name]!==r)throw Error(r+" is not a member of "+this);return delete this.methods[r.name],r.parent=null,i(this)}return f.prototype.remove.call(this,r)},o.prototype.create=function(r,t,n){for(var d=new l.Service(r,t,n),s=0,u;s<this.methodsArray.length;++s){var a=v.lcFirst((u=this._methodsArray[s]).resolve().name).replace(/[^$\w_]/g,"");d[a]=v.codegen(["r","c"],v.isReserved(a)?a+"_":a)("return this.rpcCall(m,q,s,r,c)")({m:u,q:u.resolvedRequestType.ctor,s:u.resolvedResponseType.ctor})}return d},service}var message,hasRequiredMessage;function requireMessage(){if(hasRequiredMessage)return message;hasRequiredMessage=1,message=c;var f=requireMinimal();function c(v){if(v)for(var l=Object.keys(v),o=0;o<l.length;++o)this[l[o]]=v[l[o]]}return c.create=function(l){return this.$type.create(l)},c.encode=function(l,o){return this.$type.encode(l,o)},c.encodeDelimited=function(l,o){return this.$type.encodeDelimited(l,o)},c.decode=function(l){return this.$type.decode(l)},c.decodeDelimited=function(l){return this.$type.decodeDelimited(l)},c.verify=function(l){return this.$type.verify(l)},c.fromObject=function(l){return this.$type.fromObject(l)},c.toObject=function(l,o){return this.$type.toObject(l,o)},c.prototype.toJSON=function(){return this.$type.toObject(this,f.toJSONOptions)},message}var decoder_1,hasRequiredDecoder;function requireDecoder(){if(hasRequiredDecoder)return decoder_1;hasRequiredDecoder=1,decoder_1=o;var f=require_enum(),c=requireTypes(),v=requireUtil();function l(i){return"missing required '"+i.name+"'"}function o(i){for(var e=v.codegen(["r","l","e"],i.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(i.fieldsArray.filter(function(u){return u.map}).length?",k,value":""))("while(r.pos<c){")("var t=r.uint32()")("if(t===e)")("break")("switch(t>>>3){"),r=0;r<i.fieldsArray.length;++r){var t=i._fieldsArray[r].resolve(),n=t.resolvedType instanceof f?"int32":t.type,d="m"+v.safeProp(t.name);e("case %i: {",t.id),t.map?(e("if(%s===util.emptyObject)",d)("%s={}",d)("var c2 = r.uint32()+r.pos"),c.defaults[t.keyType]!==void 0?e("k=%j",c.defaults[t.keyType]):e("k=null"),c.defaults[n]!==void 0?e("value=%j",c.defaults[n]):e("value=null"),e("while(r.pos<c2){")("var tag2=r.uint32()")("switch(tag2>>>3){")("case 1: k=r.%s(); break",t.keyType)("case 2:"),c.basic[n]===void 0?e("value=types[%i].decode(r,r.uint32())",r):e("value=r.%s()",n),e("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),c.long[t.keyType]!==void 0?e('%s[typeof k==="object"?util.longToHash(k):k]=value',d):e("%s[k]=value",d)):t.repeated?(e("if(!(%s&&%s.length))",d,d)("%s=[]",d),c.packed[n]!==void 0&&e("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos<c2)")("%s.push(r.%s())",d,n)("}else"),c.basic[n]===void 0?e(t.delimited?"%s.push(types[%i].decode(r,undefined,((t&~7)|4)))":"%s.push(types[%i].decode(r,r.uint32()))",d,r):e("%s.push(r.%s())",d,n)):c.basic[n]===void 0?e(t.delimited?"%s=types[%i].decode(r,undefined,((t&~7)|4))":"%s=types[%i].decode(r,r.uint32())",d,r):e("%s=r.%s()",d,n),e("break")("}")}for(e("default:")("r.skipType(t&7)")("break")("}")("}"),r=0;r<i._fieldsArray.length;++r){var s=i._fieldsArray[r];s.required&&e("if(!m.hasOwnProperty(%j))",s.name)("throw util.ProtocolError(%j,{instance:m})",l(s))}return e("return m")}return decoder_1}var verifier_1,hasRequiredVerifier;function requireVerifier(){if(hasRequiredVerifier)return verifier_1;hasRequiredVerifier=1,verifier_1=i;var f=require_enum(),c=requireUtil();function v(e,r){return e.name+": "+r+(e.repeated&&r!=="array"?"[]":e.map&&r!=="object"?"{k:"+e.keyType+"}":"")+" expected"}function l(e,r,t,n){if(r.resolvedType)if(r.resolvedType instanceof f){e("switch(%s){",n)("default:")("return%j",v(r,"enum value"));for(var d=Object.keys(r.resolvedType.values),s=0;s<d.length;++s)e("case %i:",r.resolvedType.values[d[s]]);e("break")("}")}else e("{")("var e=types[%i].verify(%s);",t,n)("if(e)")("return%j+e",r.name+".")("}");else switch(r.type){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":e("if(!util.isInteger(%s))",n)("return%j",v(r,"integer"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":e("if(!util.isInteger(%s)&&!(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))",n,n,n,n)("return%j",v(r,"integer|Long"));break;case"float":case"double":e('if(typeof %s!=="number")',n)("return%j",v(r,"number"));break;case"bool":e('if(typeof %s!=="boolean")',n)("return%j",v(r,"boolean"));break;case"string":e("if(!util.isString(%s))",n)("return%j",v(r,"string"));break;case"bytes":e('if(!(%s&&typeof %s.length==="number"||util.isString(%s)))',n,n,n)("return%j",v(r,"buffer"));break}return e}function o(e,r,t){switch(r.keyType){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":e("if(!util.key32Re.test(%s))",t)("return%j",v(r,"integer key"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":e("if(!util.key64Re.test(%s))",t)("return%j",v(r,"integer|Long key"));break;case"bool":e("if(!util.key2Re.test(%s))",t)("return%j",v(r,"boolean key"));break}return e}function i(e){var r=c.codegen(["m"],e.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),t=e.oneofsArray,n={};t.length&&r("var p={}");for(var d=0;d<e.fieldsArray.length;++d){var s=e._fieldsArray[d].resolve(),u="m"+c.safeProp(s.name);if(s.optional&&r("if(%s!=null&&m.hasOwnProperty(%j)){",u,s.name),s.map)r("if(!util.isObject(%s))",u)("return%j",v(s,"object"))("var k=Object.keys(%s)",u)("for(var i=0;i<k.length;++i){"),o(r,s,"k[i]"),l(r,s,d,u+"[k[i]]")("}");else if(s.repeated)r("if(!Array.isArray(%s))",u)("return%j",v(s,"array"))("for(var i=0;i<%s.length;++i){",u),l(r,s,d,u+"[i]")("}");else{if(s.partOf){var a=c.safeProp(s.partOf.name);n[s.partOf.name]===1&&r("if(p%s===1)",a)("return%j",s.partOf.name+": multiple values"),n[s.partOf.name]=1,r("p%s=1",a)}l(r,s,d,u)}s.optional&&r("}")}return r("return null")}return verifier_1}var converter={},hasRequiredConverter;function requireConverter(){return hasRequiredConverter||(hasRequiredConverter=1,(function(f){var c=f,v=require_enum(),l=requireUtil();function o(e,r,t,n){var d=!1;if(r.resolvedType)if(r.resolvedType instanceof v){e("switch(d%s){",n);for(var s=r.resolvedType.values,u=Object.keys(s),a=0;a<u.length;++a)s[u[a]]===r.typeDefault&&!d&&(e("default:")('if(typeof(d%s)==="number"){m%s=d%s;break}',n,n,n),r.repeated||e("break"),d=!0),e("case%j:",u[a])("case %i:",s[u[a]])("m%s=%j",n,s[u[a]])("break");e("}")}else e('if(typeof d%s!=="object")',n)("throw TypeError(%j)",r.fullName+": object expected")("m%s=types[%i].fromObject(d%s)",n,t,n);else{var h=!1;switch(r.type){case"double":case"float":e("m%s=Number(d%s)",n,n);break;case"uint32":case"fixed32":e("m%s=d%s>>>0",n,n);break;case"int32":case"sint32":case"sfixed32":e("m%s=d%s|0",n,n);break;case"uint64":h=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",n,n,h)('else if(typeof d%s==="string")',n)("m%s=parseInt(d%s,10)",n,n)('else if(typeof d%s==="number")',n)("m%s=d%s",n,n)('else if(typeof d%s==="object")',n)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",n,n,n,h?"true":"");break;case"bytes":e('if(typeof d%s==="string")',n)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",n,n,n)("else if(d%s.length >= 0)",n)("m%s=d%s",n,n);break;case"string":e("m%s=String(d%s)",n,n);break;case"bool":e("m%s=Boolean(d%s)",n,n);break}}return e}c.fromObject=function(r){var t=r.fieldsArray,n=l.codegen(["d"],r.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!t.length)return n("return new this.ctor");n("var m=new this.ctor");for(var d=0;d<t.length;++d){var s=t[d].resolve(),u=l.safeProp(s.name);s.map?(n("if(d%s){",u)('if(typeof d%s!=="object")',u)("throw TypeError(%j)",s.fullName+": object expected")("m%s={}",u)("for(var ks=Object.keys(d%s),i=0;i<ks.length;++i){",u),o(n,s,d,u+"[ks[i]]")("}")("}")):s.repeated?(n("if(d%s){",u)("if(!Array.isArray(d%s))",u)("throw TypeError(%j)",s.fullName+": array expected")("m%s=[]",u)("for(var i=0;i<d%s.length;++i){",u),o(n,s,d,u+"[i]")("}")("}")):(s.resolvedType instanceof v||n("if(d%s!=null){",u),o(n,s,d,u),s.resolvedType instanceof v||n("}"))}return n("return m")};function i(e,r,t,n){if(r.resolvedType)r.resolvedType instanceof v?e("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",n,t,n,n,t,n,n):e("d%s=types[%i].toObject(m%s,o)",n,t,n);else{var d=!1;switch(r.type){case"double":case"float":e("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",n,n,n,n);break;case"uint64":d=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e('if(typeof m%s==="number")',n)("d%s=o.longs===String?String(m%s):m%s",n,n,n)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",n,n,n,n,d?"true":"",n);break;case"bytes":e("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",n,n,n,n,n);break;default:e("d%s=m%s",n,n);break}}return e}c.toObject=function(r){var t=r.fieldsArray.slice().sort(l.compareFieldsById);if(!t.length)return l.codegen()("return {}");for(var n=l.codegen(["m","o"],r.name+"$toObject")("if(!o)")("o={}")("var d={}"),d=[],s=[],u=[],a=0;a<t.length;++a)t[a].partOf||(t[a].resolve().repeated?d:t[a].map?s:u).push(t[a]);if(d.length){for(n("if(o.arrays||o.defaults){"),a=0;a<d.length;++a)n("d%s=[]",l.safeProp(d[a].name));n("}")}if(s.length){for(n("if(o.objects||o.defaults){"),a=0;a<s.length;++a)n("d%s={}",l.safeProp(s[a].name));n("}")}if(u.length){for(n("if(o.defaults){"),a=0;a<u.length;++a){var h=u[a],m=l.safeProp(h.name);if(h.resolvedType instanceof v)n("d%s=o.enums===String?%j:%j",m,h.resolvedType.valuesById[h.typeDefault],h.typeDefault);else if(h.long)n("if(util.Long){")("var n=new util.Long(%i,%i,%j)",h.typeDefault.low,h.typeDefault.high,h.typeDefault.unsigned)("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n",m)("}else")("d%s=o.longs===String?%j:%i",m,h.typeDefault.toString(),h.typeDefault.toNumber());else if(h.bytes){var R="["+Array.prototype.slice.call(h.typeDefault).join(",")+"]";n("if(o.bytes===String)d%s=%j",m,String.fromCharCode.apply(String,h.typeDefault))("else{")("d%s=%s",m,R)("if(o.bytes!==Array)d%s=util.newBuffer(d%s)",m,m)("}")}else n("d%s=%j",m,h.typeDefault)}n("}")}var g=!1;for(a=0;a<t.length;++a){var h=t[a],y=r._fieldsArray.indexOf(h),m=l.safeProp(h.name);h.map?(g||(g=!0,n("var ks2")),n("if(m%s&&(ks2=Object.keys(m%s)).length){",m,m)("d%s={}",m)("for(var j=0;j<ks2.length;++j){"),i(n,h,y,m+"[ks2[j]]")("}")):h.repeated?(n("if(m%s&&m%s.length){",m,m)("d%s=[]",m)("for(var j=0;j<m%s.length;++j){",m),i(n,h,y,m+"[j]")("}")):(n("if(m%s!=null&&m.hasOwnProperty(%j)){",m,h.name),i(n,h,y,m),h.partOf&&n("if(o.oneofs)")("d%s=%j",l.safeProp(h.partOf.name),h.name)),n("}")}return n("return d")}})(converter)),converter}var wrappers={},hasRequiredWrappers;function requireWrappers(){return hasRequiredWrappers||(hasRequiredWrappers=1,(function(f){var c=f,v=requireMessage();c[".google.protobuf.Any"]={fromObject:function(l){if(l&&l["@type"]){var o=l["@type"].substring(l["@type"].lastIndexOf("/")+1),i=this.lookup(o);if(i){var e=l["@type"].charAt(0)==="."?l["@type"].slice(1):l["@type"];return e.indexOf("/")===-1&&(e="/"+e),this.create({type_url:e,value:i.encode(i.fromObject(l)).finish()})}}return this.fromObject(l)},toObject:function(l,o){var i="type.googleapis.com/",e="",r="";if(o&&o.json&&l.type_url&&l.value){r=l.type_url.substring(l.type_url.lastIndexOf("/")+1),e=l.type_url.substring(0,l.type_url.lastIndexOf("/")+1);var t=this.lookup(r);t&&(l=t.decode(l.value))}if(!(l instanceof this.ctor)&&l instanceof v){var n=l.$type.toObject(l,o),d=l.$type.fullName[0]==="."?l.$type.fullName.slice(1):l.$type.fullName;return e===""&&(e=i),r=e+d,n["@type"]=r,n}return this.toObject(l,o)}}})(wrappers)),wrappers}var type,hasRequiredType;function requireType(){if(hasRequiredType)return type;hasRequiredType=1,type=m;var f=requireNamespace();((m.prototype=Object.create(f.prototype)).constructor=m).className="Type";var c=require_enum(),v=requireOneof(),l=requireField(),o=requireMapfield(),i=requireService(),e=requireMessage(),r=requireReader(),t=requireWriter(),n=requireUtil(),d=requireEncoder(),s=requireDecoder(),u=requireVerifier(),a=requireConverter(),h=requireWrappers();function m(g,y){f.call(this,g,y),this.fields={},this.oneofs=void 0,this.extensions=void 0,this.reserved=void 0,this.group=void 0,this._fieldsById=null,this._fieldsArray=null,this._oneofsArray=null,this._ctor=null}Object.defineProperties(m.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var g=Object.keys(this.fields),y=0;y<g.length;++y){var O=this.fields[g[y]],b=O.id;if(this._fieldsById[b])throw Error("duplicate id "+b+" in "+this);this._fieldsById[b]=O}return this._fieldsById}},fieldsArray:{get:function(){return this._fieldsArray||(this._fieldsArray=n.toArray(this.fields))}},oneofsArray:{get:function(){return this._oneofsArray||(this._oneofsArray=n.toArray(this.oneofs))}},ctor:{get:function(){return this._ctor||(this.ctor=m.generateConstructor(this)())},set:function(g){var y=g.prototype;y instanceof e||((g.prototype=new e).constructor=g,n.merge(g.prototype,y)),g.$type=g.prototype.$type=this,n.merge(g,e,!0),this._ctor=g;for(var O=0;O<this.fieldsArray.length;++O)this._fieldsArray[O].resolve();var b={};for(O=0;O<this.oneofsArray.length;++O)b[this._oneofsArray[O].resolve().name]={get:n.oneOfGetter(this._oneofsArray[O].oneof),set:n.oneOfSetter(this._oneofsArray[O].oneof)};O&&Object.defineProperties(g.prototype,b)}}}),m.generateConstructor=function(y){for(var O=n.codegen(["p"],y.name),b=0,k;b<y.fieldsArray.length;++b)(k=y._fieldsArray[b]).map?O("this%s={}",n.safeProp(k.name)):k.repeated&&O("this%s=[]",n.safeProp(k.name));return O("if(p)for(var ks=Object.keys(p),i=0;i<ks.length;++i)if(p[ks[i]]!=null)")("this[ks[i]]=p[ks[i]]")};function R(g){return g._fieldsById=g._fieldsArray=g._oneofsArray=null,delete g.encode,delete g.decode,delete g.verify,g}return m.fromJSON=function(y,O){var b=new m(y,O.options);b.extensions=O.extensions,b.reserved=O.reserved;for(var k=Object.keys(O.fields),I=0;I<k.length;++I)b.add((typeof O.fields[k[I]].keyType<"u"?o.fromJSON:l.fromJSON)(k[I],O.fields[k[I]]));if(O.oneofs)for(k=Object.keys(O.oneofs),I=0;I<k.length;++I)b.add(v.fromJSON(k[I],O.oneofs[k[I]]));if(O.nested)for(k=Object.keys(O.nested),I=0;I<k.length;++I){var M=O.nested[k[I]];b.add((M.id!==void 0?l.fromJSON:M.fields!==void 0?m.fromJSON:M.values!==void 0?c.fromJSON:M.methods!==void 0?i.fromJSON:f.fromJSON)(k[I],M))}return O.extensions&&O.extensions.length&&(b.extensions=O.extensions),O.reserved&&O.reserved.length&&(b.reserved=O.reserved),O.group&&(b.group=!0),O.comment&&(b.comment=O.comment),O.edition&&(b._edition=O.edition),b._defaultEdition="proto3",b},m.prototype.toJSON=function(y){var O=f.prototype.toJSON.call(this,y),b=y?!!y.keepComments:!1;return n.toObject(["edition",this._editionToJSON(),"options",O&&O.options||void 0,"oneofs",f.arrayToJSON(this.oneofsArray,y),"fields",f.arrayToJSON(this.fieldsArray.filter(function(k){return!k.declaringField}),y)||{},"extensions",this.extensions&&this.extensions.length?this.extensions:void 0,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"group",this.group||void 0,"nested",O&&O.nested||void 0,"comment",b?this.comment:void 0])},m.prototype.resolveAll=function(){if(!this._needsRecursiveResolve)return this;f.prototype.resolveAll.call(this);var y=this.oneofsArray;for(b=0;b<y.length;)y[b++].resolve();for(var O=this.fieldsArray,b=0;b<O.length;)O[b++].resolve();return this},m.prototype._resolveFeaturesRecursive=function(y){return this._needsRecursiveFeatureResolution?(y=this._edition||y,f.prototype._resolveFeaturesRecursive.call(this,y),this.oneofsArray.forEach(O=>{O._resolveFeatures(y)}),this.fieldsArray.forEach(O=>{O._resolveFeatures(y)}),this):this},m.prototype.get=function(y){return this.fields[y]||this.oneofs&&this.oneofs[y]||this.nested&&this.nested[y]||null},m.prototype.add=function(y){if(this.get(y.name))throw Error("duplicate name '"+y.name+"' in "+this);if(y instanceof l&&y.extend===void 0){if(this._fieldsById?this._fieldsById[y.id]:this.fieldsById[y.id])throw Error("duplicate id "+y.id+" in "+this);if(this.isReservedId(y.id))throw Error("id "+y.id+" is reserved in "+this);if(this.isReservedName(y.name))throw Error("name '"+y.name+"' is reserved in "+this);return y.parent&&y.parent.remove(y),this.fields[y.name]=y,y.message=this,y.onAdd(this),R(this)}return y instanceof v?(this.oneofs||(this.oneofs={}),this.oneofs[y.name]=y,y.onAdd(this),R(this)):f.prototype.add.call(this,y)},m.prototype.remove=function(y){if(y instanceof l&&y.extend===void 0){if(!this.fields||this.fields[y.name]!==y)throw Error(y+" is not a member of "+this);return delete this.fields[y.name],y.parent=null,y.onRemove(this),R(this)}if(y instanceof v){if(!this.oneofs||this.oneofs[y.name]!==y)throw Error(y+" is not a member of "+this);return delete this.oneofs[y.name],y.parent=null,y.onRemove(this),R(this)}return f.prototype.remove.call(this,y)},m.prototype.isReservedId=function(y){return f.isReservedId(this.reserved,y)},m.prototype.isReservedName=function(y){return f.isReservedName(this.reserved,y)},m.prototype.create=function(y){return new this.ctor(y)},m.prototype.setup=function(){for(var y=this.fullName,O=[],b=0;b<this.fieldsArray.length;++b)O.push(this._fieldsArray[b].resolve().resolvedType);this.encode=d(this)({Writer:t,types:O,util:n}),this.decode=s(this)({Reader:r,types:O,util:n}),this.verify=u(this)({types:O,util:n}),this.fromObject=a.fromObject(this)({types:O,util:n}),this.toObject=a.toObject(this)({types:O,util:n});var k=h[y];if(k){var I=Object.create(this);I.fromObject=this.fromObject,this.fromObject=k.fromObject.bind(I),I.toObject=this.toObject,this.toObject=k.toObject.bind(I)}return this},m.prototype.encode=function(y,O){return this.setup().encode(y,O)},m.prototype.encodeDelimited=function(y,O){return this.encode(y,O&&O.len?O.fork():O).ldelim()},m.prototype.decode=function(y,O){return this.setup().decode(y,O)},m.prototype.decodeDelimited=function(y){return y instanceof r||(y=r.create(y)),this.decode(y,y.uint32())},m.prototype.verify=function(y){return this.setup().verify(y)},m.prototype.fromObject=function(y){return this.setup().fromObject(y)},m.prototype.toObject=function(y,O){return this.setup().toObject(y,O)},m.d=function(y){return function(b){n.decorateType(b,y)}},type}var root,hasRequiredRoot;function requireRoot(){if(hasRequiredRoot)return root;hasRequiredRoot=1,root=t;var f=requireNamespace();((t.prototype=Object.create(f.prototype)).constructor=t).className="Root";var c=requireField(),v=require_enum(),l=requireOneof(),o=requireUtil(),i,e,r;function t(u){f.call(this,"",u),this.deferred=[],this.files=[],this._edition="proto2",this._fullyQualifiedObjects={}}t.fromJSON=function(a,h){return h||(h=new t),a.options&&h.setOptions(a.options),h.addJSON(a.nested).resolveAll()},t.prototype.resolvePath=o.path.resolve,t.prototype.fetch=o.fetch;function n(){}t.prototype.load=function u(a,h,m){typeof h=="function"&&(m=h,h=void 0);var R=this;if(!m)return o.asPromise(u,R,a,h);var g=m===n;function y(V,N){if(m){if(g)throw V;N&&N.resolveAll();var w=m;m=null,w(V,N)}}function O(V){var N=V.lastIndexOf("google/protobuf/");if(N>-1){var w=V.substring(N);if(w in r)return w}return null}function b(V,N){try{if(o.isString(N)&&N.charAt(0)==="{"&&(N=JSON.parse(N)),!o.isString(N))R.setOptions(N.options).addJSON(N.nested);else{e.filename=V;var w=e(N,R,h),x,C=0;if(w.imports)for(;C<w.imports.length;++C)(x=O(w.imports[C])||R.resolvePath(V,w.imports[C]))&&k(x);if(w.weakImports)for(C=0;C<w.weakImports.length;++C)(x=O(w.weakImports[C])||R.resolvePath(V,w.weakImports[C]))&&k(x,!0)}}catch(A){y(A)}!g&&!I&&y(null,R)}function k(V,N){if(V=O(V)||V,!(R.files.indexOf(V)>-1)){if(R.files.push(V),V in r){g?b(V,r[V]):(++I,setTimeout(function(){--I,b(V,r[V])}));return}if(g){var w;try{w=o.fs.readFileSync(V).toString("utf8")}catch(x){N||y(x);return}b(V,w)}else++I,R.fetch(V,function(x,C){if(--I,!!m){if(x){N?I||y(null,R):y(x);return}b(V,C)}})}}var I=0;o.isString(a)&&(a=[a]);for(var M=0,j;M<a.length;++M)(j=R.resolvePath("",a[M]))&&k(j);return g?(R.resolveAll(),R):(I||y(null,R),R)},t.prototype.loadSync=function(a,h){if(!o.isNode)throw Error("not supported");return this.load(a,h,n)},t.prototype.resolveAll=function(){if(!this._needsRecursiveResolve)return this;if(this.deferred.length)throw Error("unresolvable extensions: "+this.deferred.map(function(a){return"'extend "+a.extend+"' in "+a.parent.fullName}).join(", "));return f.prototype.resolveAll.call(this)};var d=/^[A-Z]/;function s(u,a){var h=a.parent.lookup(a.extend);if(h){var m=new c(a.fullName,a.id,a.type,a.rule,void 0,a.options);return h.get(m.name)||(m.declaringField=a,a.extensionField=m,h.add(m)),!0}return!1}return t.prototype._handleAdd=function(a){if(a instanceof c)a.extend!==void 0&&!a.extensionField&&(s(this,a)||this.deferred.push(a));else if(a instanceof v)d.test(a.name)&&(a.parent[a.name]=a.values);else if(!(a instanceof l)){if(a instanceof i)for(var h=0;h<this.deferred.length;)s(this,this.deferred[h])?this.deferred.splice(h,1):++h;for(var m=0;m<a.nestedArray.length;++m)this._handleAdd(a._nestedArray[m]);d.test(a.name)&&(a.parent[a.name]=a)}(a instanceof i||a instanceof v||a instanceof c)&&(this._fullyQualifiedObjects[a.fullName]=a)},t.prototype._handleRemove=function(a){if(a instanceof c){if(a.extend!==void 0)if(a.extensionField)a.extensionField.parent.remove(a.extensionField),a.extensionField=null;else{var h=this.deferred.indexOf(a);h>-1&&this.deferred.splice(h,1)}}else if(a instanceof v)d.test(a.name)&&delete a.parent[a.name];else if(a instanceof f){for(var m=0;m<a.nestedArray.length;++m)this._handleRemove(a._nestedArray[m]);d.test(a.name)&&delete a.parent[a.name]}delete this._fullyQualifiedObjects[a.fullName]},t._configure=function(u,a,h){i=u,e=a,r=h},root}var hasRequiredUtil;function requireUtil(){if(hasRequiredUtil)return util.exports;hasRequiredUtil=1;var f=util.exports=requireMinimal(),c=requireRoots(),v,l;f.codegen=requireCodegen(),f.fetch=requireFetch(),f.path=requirePath(),f.fs=f.inquire("fs"),f.toArray=function(n){if(n){for(var d=Object.keys(n),s=new Array(d.length),u=0;u<d.length;)s[u]=n[d[u++]];return s}return[]},f.toObject=function(n){for(var d={},s=0;s<n.length;){var u=n[s++],a=n[s++];a!==void 0&&(d[u]=a)}return d};var o=/\\/g,i=/"/g;f.isReserved=function(n){return/^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(n)},f.safeProp=function(n){return!/^[$\w_]+$/.test(n)||f.isReserved(n)?'["'+n.replace(o,"\\\\").replace(i,'\\"')+'"]':"."+n},f.ucFirst=function(n){return n.charAt(0).toUpperCase()+n.substring(1)};var e=/_([a-z])/g;f.camelCase=function(n){return n.substring(0,1)+n.substring(1).replace(e,function(d,s){return s.toUpperCase()})},f.compareFieldsById=function(n,d){return n.id-d.id},f.decorateType=function(n,d){if(n.$type)return d&&n.$type.name!==d&&(f.decorateRoot.remove(n.$type),n.$type.name=d,f.decorateRoot.add(n.$type)),n.$type;v||(v=requireType());var s=new v(d||n.name);return f.decorateRoot.add(s),s.ctor=n,Object.defineProperty(n,"$type",{value:s,enumerable:!1}),Object.defineProperty(n.prototype,"$type",{value:s,enumerable:!1}),s};var r=0;return f.decorateEnum=function(n){if(n.$type)return n.$type;l||(l=require_enum());var d=new l("Enum"+r++,n);return f.decorateRoot.add(d),Object.defineProperty(n,"$type",{value:d,enumerable:!1}),d},f.setProperty=function(n,d,s,u){function a(h,m,R){var g=m.shift();if(g==="__proto__"||g==="prototype")return h;if(m.length>0)h[g]=a(h[g]||{},m,R);else{var y=h[g];if(y&&u)return h;y&&(R=[].concat(y).concat(R)),h[g]=R}return h}if(typeof n!="object")throw TypeError("dst must be an object");if(!d)throw TypeError("path must be specified");return d=d.split("."),a(n,d,s)},Object.defineProperty(f,"decorateRoot",{get:function(){return c.decorated||(c.decorated=new(requireRoot()))}}),util.exports}var hasRequiredTypes;function requireTypes(){return hasRequiredTypes||(hasRequiredTypes=1,(function(f){var c=f,v=requireUtil(),l=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function o(i,e){var r=0,t={};for(e|=0;r<i.length;)t[l[r+e]]=i[r++];return t}c.basic=o([1,5,0,0,0,5,5,0,0,0,1,1,0,2,2]),c.defaults=o([0,0,0,0,0,0,0,0,0,0,0,0,!1,"",v.emptyArray,null]),c.long=o([0,0,0,1,1],7),c.mapKey=o([0,0,0,5,5,0,0,0,1,1,0,2],2),c.packed=o([1,5,0,0,0,5,5,0,0,0,1,1,0])})(types)),types}var field,hasRequiredField;function requireField(){if(hasRequiredField)return field;hasRequiredField=1,field=e;var f=requireObject();((e.prototype=Object.create(f.prototype)).constructor=e).className="Field";var c=require_enum(),v=requireTypes(),l=requireUtil(),o,i=/^required|optional|repeated$/;e.fromJSON=function(t,n){var d=new e(t,n.id,n.type,n.rule,n.extend,n.options,n.comment);return n.edition&&(d._edition=n.edition),d._defaultEdition="proto3",d};function e(r,t,n,d,s,u,a){if(l.isObject(d)?(a=s,u=d,d=s=void 0):l.isObject(s)&&(a=u,u=s,s=void 0),f.call(this,r,u),!l.isInteger(t)||t<0)throw TypeError("id must be a non-negative integer");if(!l.isString(n))throw TypeError("type must be a string");if(d!==void 0&&!i.test(d=d.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(s!==void 0&&!l.isString(s))throw TypeError("extend must be a string");d==="proto3_optional"&&(d="optional"),this.rule=d&&d!=="optional"?d:void 0,this.type=n,this.id=t,this.extend=s||void 0,this.repeated=d==="repeated",this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=l.Long?v.long[n]!==void 0:!1,this.bytes=n==="bytes",this.resolvedType=null,this.extensionField=null,this.declaringField=null,this.comment=a}return Object.defineProperty(e.prototype,"required",{get:function(){return this._features.field_presence==="LEGACY_REQUIRED"}}),Object.defineProperty(e.prototype,"optional",{get:function(){return!this.required}}),Object.defineProperty(e.prototype,"delimited",{get:function(){return this.resolvedType instanceof o&&this._features.message_encoding==="DELIMITED"}}),Object.defineProperty(e.prototype,"packed",{get:function(){return this._features.repeated_field_encoding==="PACKED"}}),Object.defineProperty(e.prototype,"hasPresence",{get:function(){return this.repeated||this.map?!1:this.partOf||this.declaringField||this.extensionField||this._features.field_presence!=="IMPLICIT"}}),e.prototype.setOption=function(t,n,d){return f.prototype.setOption.call(this,t,n,d)},e.prototype.toJSON=function(t){var n=t?!!t.keepComments:!1;return l.toObject(["edition",this._editionToJSON(),"rule",this.rule!=="optional"&&this.rule||void 0,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",n?this.comment:void 0])},e.prototype.resolve=function(){if(this.resolved)return this;if((this.typeDefault=v.defaults[this.type])===void 0?(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.resolvedType instanceof o?this.typeDefault=null:this.typeDefault=this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]):this.options&&this.options.proto3_optional&&(this.typeDefault=null),this.options&&this.options.default!=null&&(this.typeDefault=this.options.default,this.resolvedType instanceof c&&typeof this.typeDefault=="string"&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&(this.options.packed!==void 0&&this.resolvedType&&!(this.resolvedType instanceof c)&&delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=l.Long.fromNumber(this.typeDefault,this.type.charAt(0)==="u"),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&typeof this.typeDefault=="string"){var t;l.base64.test(this.typeDefault)?l.base64.decode(this.typeDefault,t=l.newBuffer(l.base64.length(this.typeDefault)),0):l.utf8.write(this.typeDefault,t=l.newBuffer(l.utf8.length(this.typeDefault)),0),this.typeDefault=t}return this.map?this.defaultValue=l.emptyObject:this.repeated?this.defaultValue=l.emptyArray:this.defaultValue=this.typeDefault,this.parent instanceof o&&(this.parent.ctor.prototype[this.name]=this.defaultValue),f.prototype.resolve.call(this)},e.prototype._inferLegacyProtoFeatures=function(t){if(t!=="proto2"&&t!=="proto3")return{};var n={};if(this.rule==="required"&&(n.field_presence="LEGACY_REQUIRED"),this.parent&&v.defaults[this.type]===void 0){var d=this.parent.get(this.type.split(".").pop());d&&d instanceof o&&d.group&&(n.message_encoding="DELIMITED")}return this.getOption("packed")===!0?n.repeated_field_encoding="PACKED":this.getOption("packed")===!1&&(n.repeated_field_encoding="EXPANDED"),n},e.prototype._resolveFeatures=function(t){return f.prototype._resolveFeatures.call(this,this._edition||t)},e.d=function(t,n,d,s){return typeof n=="function"?n=l.decorateType(n).name:n&&typeof n=="object"&&(n=l.decorateEnum(n).name),function(a,h){l.decorateType(a.constructor).add(new e(h,t,n,d,{default:s}))}},e._configure=function(t){o=t},field}var oneof,hasRequiredOneof;function requireOneof(){if(hasRequiredOneof)return oneof;hasRequiredOneof=1,oneof=l;var f=requireObject();((l.prototype=Object.create(f.prototype)).constructor=l).className="OneOf";var c=requireField(),v=requireUtil();function l(i,e,r,t){if(Array.isArray(e)||(r=e,e=void 0),f.call(this,i,r),!(e===void 0||Array.isArray(e)))throw TypeError("fieldNames must be an Array");this.oneof=e||[],this.fieldsArray=[],this.comment=t}l.fromJSON=function(e,r){return new l(e,r.oneof,r.options,r.comment)},l.prototype.toJSON=function(e){var r=e?!!e.keepComments:!1;return v.toObject(["options",this.options,"oneof",this.oneof,"comment",r?this.comment:void 0])};function o(i){if(i.parent)for(var e=0;e<i.fieldsArray.length;++e)i.fieldsArray[e].parent||i.parent.add(i.fieldsArray[e])}return l.prototype.add=function(e){if(!(e instanceof c))throw TypeError("field must be a Field");return e.parent&&e.parent!==this.parent&&e.parent.remove(e),this.oneof.push(e.name),this.fieldsArray.push(e),e.partOf=this,o(this),this},l.prototype.remove=function(e){if(!(e instanceof c))throw TypeError("field must be a Field");var r=this.fieldsArray.indexOf(e);if(r<0)throw Error(e+" is not a member of "+this);return this.fieldsArray.splice(r,1),r=this.oneof.indexOf(e.name),r>-1&&this.oneof.splice(r,1),e.partOf=null,this},l.prototype.onAdd=function(e){f.prototype.onAdd.call(this,e);for(var r=this,t=0;t<this.oneof.length;++t){var n=e.get(this.oneof[t]);n&&!n.partOf&&(n.partOf=r,r.fieldsArray.push(n))}o(this)},l.prototype.onRemove=function(e){for(var r=0,t;r<this.fieldsArray.length;++r)(t=this.fieldsArray[r]).parent&&t.parent.remove(t);f.prototype.onRemove.call(this,e)},Object.defineProperty(l.prototype,"isProto3Optional",{get:function(){if(this.fieldsArray==null||this.fieldsArray.length!==1)return!1;var i=this.fieldsArray[0];return i.options!=null&&i.options.proto3_optional===!0}}),l.d=function(){for(var e=new Array(arguments.length),r=0;r<arguments.length;)e[r]=arguments[r++];return function(n,d){v.decorateType(n.constructor).add(new l(d,e)),Object.defineProperty(n,d,{get:v.oneOfGetter(e),set:v.oneOfSetter(e)})}},oneof}var object,hasRequiredObject;function requireObject(){if(hasRequiredObject)return object;hasRequiredObject=1,object=e,e.className="ReflectionObject";const f=requireOneof();var c=requireUtil(),v,l={enum_type:"OPEN",field_presence:"EXPLICIT",json_format:"ALLOW",message_encoding:"LENGTH_PREFIXED",repeated_field_encoding:"PACKED",utf8_validation:"VERIFY"},o={enum_type:"CLOSED",field_presence:"EXPLICIT",json_format:"LEGACY_BEST_EFFORT",message_encoding:"LENGTH_PREFIXED",repeated_field_encoding:"EXPANDED",utf8_validation:"NONE"},i={enum_type:"OPEN",field_presence:"IMPLICIT",json_format:"ALLOW",message_encoding:"LENGTH_PREFIXED",repeated_field_encoding:"PACKED",utf8_validation:"VERIFY"};function e(r,t){if(!c.isString(r))throw TypeError("name must be a string");if(t&&!c.isObject(t))throw TypeError("options must be an object");this.options=t,this.parsedOptions=null,this.name=r,this._edition=null,this._defaultEdition="proto2",this._features={},this._featuresResolved=!1,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}return Object.defineProperties(e.prototype,{root:{get:function(){for(var r=this;r.parent!==null;)r=r.parent;return r}},fullName:{get:function(){for(var r=[this.name],t=this.parent;t;)r.unshift(t.name),t=t.parent;return r.join(".")}}}),e.prototype.toJSON=function(){throw Error()},e.prototype.onAdd=function(t){this.parent&&this.parent!==t&&this.parent.remove(this),this.parent=t,this.resolved=!1;var n=t.root;n instanceof v&&n._handleAdd(this)},e.prototype.onRemove=function(t){var n=t.root;n instanceof v&&n._handleRemove(this),this.parent=null,this.resolved=!1},e.prototype.resolve=function(){return this.resolved?this:(this.root instanceof v&&(this.resolved=!0),this)},e.prototype._resolveFeaturesRecursive=function(t){return this._resolveFeatures(this._edition||t)},e.prototype._resolveFeatures=function(t){if(!this._featuresResolved){var n={};if(!t)throw new Error("Unknown edition for "+this.fullName);var d=Object.assign(this.options?Object.assign({},this.options.features):{},this._inferLegacyProtoFeatures(t));if(this._edition){if(t==="proto2")n=Object.assign({},o);else if(t==="proto3")n=Object.assign({},i);else if(t==="2023")n=Object.assign({},l);else throw new Error("Unknown edition: "+t);this._features=Object.assign(n,d||{}),this._featuresResolved=!0;return}if(this.partOf instanceof f){var s=Object.assign({},this.partOf._features);this._features=Object.assign(s,d||{})}else if(!this.declaringField)if(this.parent){var u=Object.assign({},this.parent._features);this._features=Object.assign(u,d||{})}else throw new Error("Unable to find a parent for "+this.fullName);this.extensionField&&(this.extensionField._features=this._features),this._featuresResolved=!0}},e.prototype._inferLegacyProtoFeatures=function(){return{}},e.prototype.getOption=function(t){if(this.options)return this.options[t]},e.prototype.setOption=function(t,n,d){return this.options||(this.options={}),/^features\./.test(t)?c.setProperty(this.options,t,n,d):(!d||this.options[t]===void 0)&&(this.getOption(t)!==n&&(this.resolved=!1),this.options[t]=n),this},e.prototype.setParsedOption=function(t,n,d){this.parsedOptions||(this.parsedOptions=[]);var s=this.parsedOptions;if(d){var u=s.find(function(m){return Object.prototype.hasOwnProperty.call(m,t)});if(u){var a=u[t];c.setProperty(a,d,n)}else u={},u[t]=c.setProperty({},d,n),s.push(u)}else{var h={};h[t]=n,s.push(h)}return this},e.prototype.setOptions=function(t,n){if(t)for(var d=Object.keys(t),s=0;s<d.length;++s)this.setOption(d[s],t[d[s]],n);return this},e.prototype.toString=function(){var t=this.constructor.className,n=this.fullName;return n.length?t+" "+n:t},e.prototype._editionToJSON=function(){if(!(!this._edition||this._edition==="proto3"))return this._edition},e._configure=function(r){v=r},object}var _enum,hasRequired_enum;function require_enum(){if(hasRequired_enum)return _enum;hasRequired_enum=1,_enum=l;var f=requireObject();((l.prototype=Object.create(f.prototype)).constructor=l).className="Enum";var c=requireNamespace(),v=requireUtil();function l(o,i,e,r,t,n){if(f.call(this,o,e),i&&typeof i!="object")throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=r,this.comments=t||{},this.valuesOptions=n,this._valuesFeatures={},this.reserved=void 0,i)for(var d=Object.keys(i),s=0;s<d.length;++s)typeof i[d[s]]=="number"&&(this.valuesById[this.values[d[s]]=i[d[s]]]=d[s])}return l.prototype._resolveFeatures=function(i){return i=this._edition||i,f.prototype._resolveFeatures.call(this,i),Object.keys(this.values).forEach(e=>{var r=Object.assign({},this._features);this._valuesFeatures[e]=Object.assign(r,this.valuesOptions&&this.valuesOptions[e]&&this.valuesOptions[e].features)}),this},l.fromJSON=function(i,e){var r=new l(i,e.values,e.options,e.comment,e.comments);return r.reserved=e.reserved,e.edition&&(r._edition=e.edition),r._defaultEdition="proto3",r},l.prototype.toJSON=function(i){var e=i?!!i.keepComments:!1;return v.toObject(["edition",this._editionToJSON(),"options",this.options,"valuesOptions",this.valuesOptions,"values",this.values,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"comment",e?this.comment:void 0,"comments",e?this.comments:void 0])},l.prototype.add=function(i,e,r,t){if(!v.isString(i))throw TypeError("name must be a string");if(!v.isInteger(e))throw TypeError("id must be an integer");if(this.values[i]!==void 0)throw Error("duplicate name '"+i+"' in "+this);if(this.isReservedId(e))throw Error("id "+e+" is reserved in "+this);if(this.isReservedName(i))throw Error("name '"+i+"' is reserved in "+this);if(this.valuesById[e]!==void 0){if(!(this.options&&this.options.allow_alias))throw Error("duplicate id "+e+" in "+this);this.values[i]=e}else this.valuesById[this.values[i]=e]=i;return t&&(this.valuesOptions===void 0&&(this.valuesOptions={}),this.valuesOptions[i]=t||null),this.comments[i]=r||null,this},l.prototype.remove=function(i){if(!v.isString(i))throw TypeError("name must be a string");var e=this.values[i];if(e==null)throw Error("name '"+i+"' does not exist in "+this);return delete this.valuesById[e],delete this.values[i],delete this.comments[i],this.valuesOptions&&delete this.valuesOptions[i],this},l.prototype.isReservedId=function(i){return c.isReservedId(this.reserved,i)},l.prototype.isReservedName=function(i){return c.isReservedName(this.reserved,i)},_enum}var encoder_1,hasRequiredEncoder;function requireEncoder(){if(hasRequiredEncoder)return encoder_1;hasRequiredEncoder=1,encoder_1=o;var f=require_enum(),c=requireTypes(),v=requireUtil();function l(i,e,r,t){return e.delimited?i("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",r,t,(e.id<<3|3)>>>0,(e.id<<3|4)>>>0):i("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",r,t,(e.id<<3|2)>>>0)}function o(i){for(var e=v.codegen(["m","w"],i.name+"$encode")("if(!w)")("w=Writer.create()"),r,t,n=i.fieldsArray.slice().sort(v.compareFieldsById),r=0;r<n.length;++r){var d=n[r].resolve(),s=i._fieldsArray.indexOf(d),u=d.resolvedType instanceof f?"int32":d.type,a=c.basic[u];t="m"+v.safeProp(d.name),d.map?(e("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){",t,d.name)("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){",t)("w.uint32(%i).fork().uint32(%i).%s(ks[i])",(d.id<<3|2)>>>0,8|c.mapKey[d.keyType],d.keyType),a===void 0?e("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",s,t):e(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|a,u,t),e("}")("}")):d.repeated?(e("if(%s!=null&&%s.length){",t,t),d.packed&&c.packed[u]!==void 0?e("w.uint32(%i).fork()",(d.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",t)("w.%s(%s[i])",u,t)("w.ldelim()"):(e("for(var i=0;i<%s.length;++i)",t),a===void 0?l(e,d,s,t+"[i]"):e("w.uint32(%i).%s(%s[i])",(d.id<<3|a)>>>0,u,t)),e("}")):(d.optional&&e("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",t,d.name),a===void 0?l(e,d,s,t):e("w.uint32(%i).%s(%s)",(d.id<<3|a)>>>0,u,t))}return e("return w")}return encoder_1}var hasRequiredIndexLight;function requireIndexLight(){if(hasRequiredIndexLight)return indexLight.exports;hasRequiredIndexLight=1;var f=indexLight.exports=requireIndexMinimal();f.build="light";function c(l,o,i){return typeof o=="function"?(i=o,o=new f.Root):o||(o=new f.Root),o.load(l,i)}f.load=c;function v(l,o){return o||(o=new f.Root),o.loadSync(l)}return f.loadSync=v,f.encoder=requireEncoder(),f.decoder=requireDecoder(),f.verifier=requireVerifier(),f.converter=requireConverter(),f.ReflectionObject=requireObject(),f.Namespace=requireNamespace(),f.Root=requireRoot(),f.Enum=require_enum(),f.Type=requireType(),f.Field=requireField(),f.OneOf=requireOneof(),f.MapField=requireMapfield(),f.Service=requireService(),f.Method=requireMethod(),f.Message=requireMessage(),f.wrappers=requireWrappers(),f.types=requireTypes(),f.util=requireUtil(),f.ReflectionObject._configure(f.Root),f.Namespace._configure(f.Type,f.Service,f.Enum),f.Root._configure(f.Type),f.Field._configure(f.Type),indexLight.exports}var tokenize_1,hasRequiredTokenize;function requireTokenize(){if(hasRequiredTokenize)return tokenize_1;hasRequiredTokenize=1,tokenize_1=d;var f=/[\s{}=;:[\],'"()<>]/g,c=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,v=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,l=/^ *[*/]+ */,o=/^\s*\*?\/*/,i=/\n/g,e=/\s/,r=/\\(.?)/g,t={0:"\0",r:"\r",n:`
|
|
5
|
+
`,t:" "};function n(s){return s.replace(r,function(u,a){switch(a){case"\\":case"":return a;default:return t[a]||""}})}d.unescape=n;function d(s,u){s=s.toString();var a=0,h=s.length,m=1,R=0,g={},y=[],O=null;function b(_){return Error("illegal "+_+" (line "+m+")")}function k(){var _=O==="'"?v:c;_.lastIndex=a-1;var F=_.exec(s);if(!F)throw b("string");return a=_.lastIndex,w(O),O=null,n(F[1])}function I(_){return s.charAt(_)}function M(_,F,L){var D={type:s.charAt(_++),lineEmpty:!1,leading:L},B;u?B=2:B=3;var J=_-B,z;do if(--J<0||(z=s.charAt(J))===`
|
|
6
|
+
`){D.lineEmpty=!0;break}while(z===" "||z===" ");for(var W=s.substring(_,F).split(i),K=0;K<W.length;++K)W[K]=W[K].replace(u?o:l,"").trim();D.text=W.join(`
|
|
7
|
+
`).trim(),g[m]=D,R=m}function j(_){var F=V(_),L=s.substring(_,F),D=/^\s*\/\//.test(L);return D}function V(_){for(var F=_;F<h&&I(F)!==`
|
|
8
|
+
`;)F++;return F}function N(){if(y.length>0)return y.shift();if(O)return k();var _,F,L,D,B,J=a===0;do{if(a===h)return null;for(_=!1;e.test(L=I(a));)if(L===`
|
|
9
|
+
`&&(J=!0,++m),++a===h)return null;if(I(a)==="/"){if(++a===h)throw b("comment");if(I(a)==="/")if(u){if(D=a,B=!1,j(a-1)){B=!0;do if(a=V(a),a===h||(a++,!J))break;while(j(a))}else a=Math.min(h,V(a)+1);B&&(M(D,a,J),J=!0),m++,_=!0}else{for(B=I(D=a+1)==="/";I(++a)!==`
|
|
10
|
+
`;)if(a===h)return null;++a,B&&(M(D,a-1,J),J=!0),++m,_=!0}else if((L=I(a))==="*"){D=a+1,B=u||I(D)==="*";do{if(L===`
|
|
11
|
+
`&&++m,++a===h)throw b("comment");F=L,L=I(a)}while(F!=="*"||L!=="/");++a,B&&(M(D,a-2,J),J=!0),_=!0}else return"/"}}while(_);var z=a;f.lastIndex=0;var W=f.test(I(z++));if(!W)for(;z<h&&!f.test(I(z));)++z;var K=s.substring(a,a=z);return(K==='"'||K==="'")&&(O=K),K}function w(_){y.push(_)}function x(){if(!y.length){var _=N();if(_===null)return null;w(_)}return y[0]}function C(_,F){var L=x(),D=L===_;if(D)return N(),!0;if(!F)throw b("token '"+L+"', '"+_+"' expected");return!1}function A(_){var F=null,L;return _===void 0?(L=g[m-1],delete g[m-1],L&&(u||L.type==="*"||L.lineEmpty)&&(F=L.leading?L.text:null)):(R<_&&x(),L=g[_],delete g[_],L&&!L.lineEmpty&&(u||L.type==="/")&&(F=L.leading?null:L.text)),F}return Object.defineProperty({next:N,peek:x,push:w,skip:C,cmnt:A},"line",{get:function(){return m}})}return tokenize_1}var parse_1,hasRequiredParse;function requireParse(){if(hasRequiredParse)return parse_1;hasRequiredParse=1,parse_1=k,k.filename=null,k.defaults={keepCase:!1};var f=requireTokenize(),c=requireRoot(),v=requireType(),l=requireField(),o=requireMapfield(),i=requireOneof(),e=require_enum(),r=requireService(),t=requireMethod(),n=requireObject(),d=requireTypes(),s=requireUtil(),u=/^[1-9][0-9]*$/,a=/^-?[1-9][0-9]*$/,h=/^0[x][0-9a-fA-F]+$/,m=/^-?0[x][0-9a-fA-F]+$/,R=/^0[0-7]+$/,g=/^-?0[0-7]+$/,y=/^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,O=/^[a-zA-Z_][a-zA-Z_0-9]*$/,b=/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/;function k(I,M,j){M instanceof c||(j=M,M=new c),j||(j=k.defaults);var V=j.preferTrailingComment||!1,N=f(I,j.alternateCommentMode||!1),w=N.next,x=N.push,C=N.peek,A=N.skip,_=N.cmnt,F=!0,L,D,B,J="proto2",z=M,W=[],K={},X=j.keepCase?function(P){return P}:s.camelCase;function ce(){W.forEach(P=>{P._edition=J,Object.keys(K).forEach(E=>{P.getOption(E)===void 0&&P.setOption(E,K[E],!0)})})}function U(P,E,p){var S=k.filename;return p||(k.filename=null),Error("illegal "+(E||"token")+" '"+P+"' ("+(S?S+", ":"")+"line "+N.line+")")}function ne(){var P=[],E;do{if((E=w())!=='"'&&E!=="'")throw U(E);P.push(w()),A(E),E=C()}while(E==='"'||E==="'");return P.join("")}function fe(P){var E=w();switch(E){case"'":case'"':return x(E),ne();case"true":case"TRUE":return!0;case"false":case"FALSE":return!1}try{return ue(E,!0)}catch{if(b.test(E))return E;throw U(E,"value")}}function se(P,E){var p,S;do if(E&&((p=C())==='"'||p==="'")){var q=ne();if(P.push(q),J>=2023)throw U(q,"id")}else try{P.push([S=me(w()),A("to",!0)?me(w()):S])}catch($){if(E&&b.test(p)&&J>=2023)P.push(p);else throw $}while(A(",",!0));var T={options:void 0};T.setOption=function($,Y){this.options===void 0&&(this.options={}),this.options[$]=Y},pe(T,function(Y){if(Y==="option")de(T,Y),A(";");else throw U(Y)},function(){_e(T)})}function ue(P,E){var p=1;switch(P.charAt(0)==="-"&&(p=-1,P=P.substring(1)),P){case"inf":case"INF":case"Inf":return p*(1/0);case"nan":case"NAN":case"Nan":case"NaN":return NaN;case"0":return 0}if(u.test(P))return p*parseInt(P,10);if(h.test(P))return p*parseInt(P,16);if(R.test(P))return p*parseInt(P,8);if(y.test(P))return p*parseFloat(P);throw U(P,"number",E)}function me(P,E){switch(P){case"max":case"MAX":case"Max":return 536870911;case"0":return 0}if(!E&&P.charAt(0)==="-")throw U(P,"id");if(a.test(P))return parseInt(P,10);if(m.test(P))return parseInt(P,16);if(g.test(P))return parseInt(P,8);throw U(P,"id")}function oe(){if(L!==void 0)throw U("package");if(L=w(),!b.test(L))throw U(L,"name");z=z.define(L),A(";")}function he(){var P=C(),E;switch(P){case"weak":E=B||(B=[]),w();break;case"public":w();default:E=D||(D=[]);break}P=ne(),A(";"),E.push(P)}function be(){if(A("="),J=ne(),J<2023)throw U(J,"syntax");A(";")}function Se(){if(A("="),J=ne(),!["2023"].includes(J))throw U(J,"edition");A(";")}function Re(P,E){switch(E){case"option":return de(P,E),A(";"),!0;case"message":return Oe(P,E),!0;case"enum":return ge(P,E),!0;case"service":return xe(P,E),!0;case"extend":return Ee(P,E),!0}return!1}function pe(P,E,p){var S=N.line;if(P&&(typeof P.comment!="string"&&(P.comment=_()),P.filename=k.filename),A("{",!0)){for(var q;(q=w())!=="}";)E(q);A(";",!0)}else p&&p(),A(";"),P&&(typeof P.comment!="string"||V)&&(P.comment=_(S)||P.comment)}function Oe(P,E){if(!O.test(E=w()))throw U(E,"type name");var p=new v(E);pe(p,function(q){if(!Re(p,q))switch(q){case"map":Te(p);break;case"required":if(J!=="proto2")throw U(q);case"repeated":ae(p,q);break;case"optional":if(J==="proto3")ae(p,"proto3_optional");else{if(J!=="proto2")throw U(q);ae(p,"optional")}break;case"oneof":we(p,q);break;case"extensions":se(p.extensions||(p.extensions=[]));break;case"reserved":se(p.reserved||(p.reserved=[]),!0);break;default:if(J==="proto2"||!b.test(q))throw U(q);x(q),ae(p,"optional");break}}),P.add(p),P===z&&W.push(p)}function ae(P,E,p){var S=w();if(S==="group"){qe(P,E);return}for(;S.endsWith(".")||C().startsWith(".");)S+=w();if(!b.test(S))throw U(S,"type");var q=w();if(!O.test(q))throw U(q,"name");q=X(q),A("=");var T=new l(q,me(w()),S,E,p);if(pe(T,function(Z){if(Z==="option")de(T,Z),A(";");else throw U(Z)},function(){_e(T)}),E==="proto3_optional"){var $=new i("_"+q);T.setOption("proto3_optional",!0),$.add(T),P.add($)}else P.add(T);P===z&&W.push(T)}function qe(P,E){if(J>=2023)throw U("group");var p=w();if(!O.test(p))throw U(p,"name");var S=s.lcFirst(p);p===S&&(p=s.ucFirst(p)),A("=");var q=me(w()),T=new v(p);T.group=!0;var $=new l(S,q,p,E);$.filename=k.filename,pe(T,function(Z){switch(Z){case"option":de(T,Z),A(";");break;case"required":case"repeated":ae(T,Z);break;case"optional":J==="proto3"?ae(T,"proto3_optional"):ae(T,"optional");break;case"message":Oe(T,Z);break;case"enum":ge(T,Z);break;case"reserved":se(T.reserved||(T.reserved=[]),!0);break;default:throw U(Z)}}),P.add(T).add($)}function Te(P){A("<");var E=w();if(d.mapKey[E]===void 0)throw U(E,"type");A(",");var p=w();if(!b.test(p))throw U(p,"type");A(">");var S=w();if(!O.test(S))throw U(S,"name");A("=");var q=new o(X(S),me(w()),E,p);pe(q,function($){if($==="option")de(q,$),A(";");else throw U($)},function(){_e(q)}),P.add(q)}function we(P,E){if(!O.test(E=w()))throw U(E,"name");var p=new i(X(E));pe(p,function(q){q==="option"?(de(p,q),A(";")):(x(q),ae(p,"optional"))}),P.add(p)}function ge(P,E){if(!O.test(E=w()))throw U(E,"name");var p=new e(E);pe(p,function(q){switch(q){case"option":de(p,q),A(";");break;case"reserved":se(p.reserved||(p.reserved=[]),!0),p.reserved===void 0&&(p.reserved=[]);break;default:ye(p,q)}}),P.add(p),P===z&&W.push(p)}function ye(P,E){if(!O.test(E))throw U(E,"name");A("=");var p=me(w(),!0),S={options:void 0};S.getOption=function(q){return this.options[q]},S.setOption=function(q,T){n.prototype.setOption.call(S,q,T)},S.setParsedOption=function(){},pe(S,function(T){if(T==="option")de(S,T),A(";");else throw U(T)},function(){_e(S)}),P.add(E,p,S.comment,S.parsedOptions||S.options)}function de(P,E){var p,S,q=!0;for(E==="option"&&(E=w());E!=="=";){if(E==="("){var T=w();A(")"),E="("+T+")"}if(q){if(q=!1,E.includes(".")&&!E.includes("(")){var $=E.split(".");p=$[0]+".",E=$[1];continue}p=E}else S=S?S+=E:E;E=w()}var Y=S?p.concat(S):p,Z=Ae(P,Y);S=S&&S[0]==="."?S.slice(1):S,p=p&&p[p.length-1]==="."?p.slice(0,-1):p,ke(P,p,Z,S)}function Ae(P,E){if(A("{",!0)){for(var p={};!A("}",!0);){if(!O.test(ie=w()))throw U(ie,"name");if(ie===null)throw U(ie,"end of input");var S,q=ie;if(A(":",!0),C()==="{")S=Ae(P,E+"."+ie);else if(C()==="["){S=[];var T;if(A("[",!0)){do T=fe(),S.push(T);while(A(",",!0));A("]"),typeof T<"u"&&le(P,E+"."+ie,T)}}else S=fe(),le(P,E+"."+ie,S);var $=p[q];$&&(S=[].concat($).concat(S)),p[q]=S,A(",",!0),A(";",!0)}return p}var Y=fe();return le(P,E,Y),Y}function le(P,E,p){if(z===P&&/^features\./.test(E)){K[E]=p;return}P.setOption&&P.setOption(E,p)}function ke(P,E,p,S){P.setParsedOption&&P.setParsedOption(E,p,S)}function _e(P){if(A("[",!0)){do de(P,"option");while(A(",",!0));A("]")}return P}function xe(P,E){if(!O.test(E=w()))throw U(E,"service name");var p=new r(E);pe(p,function(q){if(!Re(p,q))if(q==="rpc")Ce(p,q);else throw U(q)}),P.add(p),P===z&&W.push(p)}function Ce(P,E){var p=_(),S=E;if(!O.test(E=w()))throw U(E,"name");var q=E,T,$,Y,Z;if(A("("),A("stream",!0)&&($=!0),!b.test(E=w())||(T=E,A(")"),A("returns"),A("("),A("stream",!0)&&(Z=!0),!b.test(E=w())))throw U(E);Y=E,A(")");var G=new t(q,S,T,Y,$,Z);G.comment=p,pe(G,function(Q){if(Q==="option")de(G,Q),A(";");else throw U(Q)}),P.add(G)}function Ee(P,E){if(!b.test(E=w()))throw U(E,"reference");var p=E;pe(null,function(q){switch(q){case"required":case"repeated":ae(P,q,p);break;case"optional":J==="proto3"?ae(P,"proto3_optional",p):ae(P,"optional",p);break;default:if(J==="proto2"||!b.test(q))throw U(q);x(q),ae(P,"optional",p);break}})}for(var ie;(ie=w())!==null;)switch(ie){case"package":if(!F)throw U(ie);oe();break;case"import":if(!F)throw U(ie);he();break;case"syntax":if(!F)throw U(ie);be();break;case"edition":if(!F)throw U(ie);Se();break;case"option":de(z,ie),A(";",!0);break;default:if(Re(z,ie)){F=!1;continue}throw U(ie)}return ce(),k.filename=null,{package:L,imports:D,weakImports:B,root:M}}return parse_1}var common_1,hasRequiredCommon;function requireCommon(){if(hasRequiredCommon)return common_1;hasRequiredCommon=1,common_1=c;var f=/\/|\./;function c(l,o){f.test(l)||(l="google/protobuf/"+l+".proto",o={nested:{google:{nested:{protobuf:{nested:o}}}}}),c[l]=o}c("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}});var v;return c("duration",{Duration:v={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}}),c("timestamp",{Timestamp:v}),c("empty",{Empty:{fields:{}}}),c("struct",{Struct:{fields:{fields:{keyType:"string",type:"Value",id:1}}},Value:{oneofs:{kind:{oneof:["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},fields:{nullValue:{type:"NullValue",id:1},numberValue:{type:"double",id:2},stringValue:{type:"string",id:3},boolValue:{type:"bool",id:4},structValue:{type:"Struct",id:5},listValue:{type:"ListValue",id:6}}},NullValue:{values:{NULL_VALUE:0}},ListValue:{fields:{values:{rule:"repeated",type:"Value",id:1}}}}),c("wrappers",{DoubleValue:{fields:{value:{type:"double",id:1}}},FloatValue:{fields:{value:{type:"float",id:1}}},Int64Value:{fields:{value:{type:"int64",id:1}}},UInt64Value:{fields:{value:{type:"uint64",id:1}}},Int32Value:{fields:{value:{type:"int32",id:1}}},UInt32Value:{fields:{value:{type:"uint32",id:1}}},BoolValue:{fields:{value:{type:"bool",id:1}}},StringValue:{fields:{value:{type:"string",id:1}}},BytesValue:{fields:{value:{type:"bytes",id:1}}}}),c("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}}),c.get=function(o){return c[o]||null},common_1}var hasRequiredSrc;function requireSrc(){if(hasRequiredSrc)return src.exports;hasRequiredSrc=1;var f=src.exports=requireIndexLight();return f.build="full",f.tokenize=requireTokenize(),f.parse=requireParse(),f.common=requireCommon(),f.Root._configure(f.Type,f.parse,f.common),src.exports}var protobufjs,hasRequiredProtobufjs;function requireProtobufjs(){return hasRequiredProtobufjs||(hasRequiredProtobufjs=1,protobufjs=requireSrc()),protobufjs}var protobufjsExports=requireProtobufjs();const protobuf=_commonjsHelpers.getDefaultExportFromCjs(protobufjsExports),useWebSocket=()=>{const f=vue.ref(null),c=vue.ref("disconnected"),v=vue.ref(!0),l={nested:{Event:{fields:{source:{type:"string",id:1},pageStart:{type:"uint64",id:2},pageEnd:{type:"uint64",id:3},samplePeriod:{type:"double",id:4},pointsPerEvent:{type:"uint64",id:5},isResampled:{type:"bool",id:6},data:{rule:"repeated",type:"double",id:7},times:{rule:"repeated",type:"uint64",id:8},spikeGroup:{rule:"repeated",type:"uint32",id:9}}},Instruction:{fields:{command:{type:"string",id:1},argument:{type:"string",id:2}}},Segment:{fields:{startTs:{type:"uint64",id:1},source:{type:"string",id:2},lastUsed:{type:"uint64",id:3},unit:{type:"string",id:4},samplePeriod:{type:"double",id:5},requestedSamplePeriod:{type:"double",id:6},pageStart:{type:"uint64",id:7},isMinMax:{type:"bool",id:8},unitM:{type:"uint64",id:9},segmentType:{type:"string",id:10},nrPoints:{type:"uint64",id:11},data:{rule:"repeated",type:"double",id:12},pageEnd:{type:"uint64",id:13},channelName:{type:"string",id:14}}},IngestSegment:{fields:{channelId:{type:"string",id:1},startTime:{type:"uint64",id:2},samplePeriod:{type:"double",id:3},data:{rule:"repeated",type:"double",id:4}}},TimeSeriesMessage:{fields:{segment:{type:"Segment",id:3},event:{rule:"repeated",type:"Event",id:4},instruction:{type:"Instruction",id:5},ingestSegment:{type:"IngestSegment",id:6},totalResponses:{type:"uint64",id:7},responseSequenceId:{type:"uint64",id:8}}}}},i=protobuf.Root.fromJSON(l).TimeSeriesMessage;let e=null,r=null,t=null,n=null,d=null,s=null,u=!1,a=null;const h=(_,F=2e3)=>new Promise(L=>{if(!_||_.readyState===WebSocket.CLOSED){L();return}const D=Date.now(),B=()=>{_.readyState===WebSocket.CLOSED||Date.now()-D>F?L():setTimeout(B,50)};B()}),m=async()=>{if(f.value){const _=f.value;console.log("🔌 Disconnecting WebSocket (state:",_.readyState,")"),f.value=null,c.value="disconnected",(_.readyState===WebSocket.OPEN||_.readyState===WebSocket.CONNECTING)&&(_.close(),await h(_))}a=null},R=async(_,F,L)=>{if(a&&(console.log("🔄 Waiting for previous connection to finish..."),await a),f.value){const D=f.value.readyState;(D===WebSocket.CONNECTING||D===WebSocket.OPEN||D===WebSocket.CLOSING)&&(console.log(`🔄 Disconnecting existing WebSocket (state: ${D})`),await m(),await new Promise(B=>setTimeout(B,100)))}console.log("setting packageId to: "+F),s=F,v.value=!0,a=new Promise(async(D,B)=>{try{const J=L||await index.useToken(),z=_+"?session="+J+"&package="+s,W=new WebSocket(z);f.value=W,W.onopen=()=>{console.log("🔗 WebSocket opened for package:",s),g(),D(W)},W.onclose=()=>{console.log("🔌 WebSocket closed for package:",s),y(),D(null)},W.onmessage=O,W.onerror=K=>{console.error("WebSocket error:",K),c.value="disconnected",B(K)},setTimeout(()=>{W.readyState===WebSocket.CONNECTING&&(W.close(),B(new Error("WebSocket connection timeout")))},1e4)}catch(J){console.error("Failed to create WebSocket:",J),B(J)}});try{await a}catch(D){console.error("WebSocket connection failed:",D),a=null}},g=()=>{if(c.value="connected",v.value){if(console.log("📡 Sending initialization messages for package:",s),d&&(console.log("🧹 Clearing channel filters"),d()),s){const _={montage:"NOT_MONTAGED",packageId:s};console.log("🎛️ Sending montage reset:",_),f.value.send(JSON.stringify(_))}v.value=!1}},y=()=>{console.log("📡 WebSocket connection closed"),c.value="disconnected"},O=_=>{if(typeof _.data=="string"){let L={};try{L=JSON.parse(_.data)}catch{n==null||n({error:"JSON Parse Error"});return}L.channelDetails?t==null||t(L.channelDetails):L.error&&(n==null||n(L));return}const F=new FileReader;F.addEventListener("loadend",function(L){const D=L.target.result,B=new Uint8Array(D),J=i.decode(B),z=J.segment;if(J.event&&J.event.length>0&&J.event[0].pageStart){const W=J.event[0],K=[[],[]],X=W.times.length/2;let ce=0;for(let se=0;se<X;se++)K[0].push(W.times[ce]),K[1].push(W.times[ce+1]),ce+=2;let U=new Array(3),ne=0;for(;ne<3;)U[ne]=new Float32Array(K[0].length),ne++;const fe={chId:W.source,lastUsed:0,unit:"uV",samplePeriod:W.samplePeriod,pageStart:W.pageStart,pageEnd:W.pageEnd,startTs:W.pageStart,isMinMax:W.isResampled,unitM:1,type:"Neural",nrPoints:X,parsedData:K,cData:U};r==null||r({pageStart:W.pageStart,data:fe,type:"Neural",nrResponses:J.totalResponses})}if(z!==null){let W=null;z.isMinMax?W=z.data.length/2:W=z.data.length;const K=new Array(3),X=z.startTs;let ce=0,U=0,ne=0;for(;ne<3;)K[ne]=new Float64Array(W),ne++;if(z.isMinMax){let oe=0;for(let he=0;he<W;he++){let be=-z.data[oe],Se=-z.data[oe+1];K[0][he]=X+he*z.samplePeriod,K[1][he]=be,K[2][he]=Se,isNaN(be)||(U++,ce+=be+(Se-be)/2),oe+=2}}else for(let oe=0;oe<W;oe++){let he=-z.data[oe];K[0][oe]=X+oe*z.samplePeriod,K[1][oe]=he,isNaN(he)||(U++,ce+=he)}let fe=0;if(u){const oe=Array.prototype.slice.call(K[1]).sort();fe=oe[Math.round(oe.length/2)]}let se=new Array(3),ue=0;for(;ue<3;)se[ue]=new Float32Array(K[0].length),ue++;const me={chId:z.source,lastUsed:z.lastUsed,unit:z.unit,samplePeriod:z.samplePeriod,pageStart:z.pageStart,pageEnd:z.pageEnd,startTs:X,isMinMax:z.isMinMax,unitM:z.unitM,type:z.segmentType,nrPoints:W,cData:se,parsedData:K,median:fe,sumElem:ce,nrValidPoints:U,name:z.channelName,label:z.channelName};me.nrPoints>0?e==null||e({pageStart:z.pageStart,data:me,type:z.segmentType,nrResponses:J.totalResponses}):e==null||e({pageStart:z.pageStart,data:me,nrResponses:J.totalResponses,type:"gap"})}}),F.readAsArrayBuffer(_.data)},b=_=>f.value&&f.value.readyState===1?(f.value.send(JSON.stringify(_)),!0):!1,k=_=>{let F;switch(_){case"NOT_MONTAGED":F={montage:"NOT_MONTAGED",packageId:s};break;default:F={montage:"CUSTOM_MONTAGE",packageId:s,montageMap:_}}b(F)},I=_=>{f.value&&f.value.readyState===1?f.value.send(JSON.stringify(_)):setTimeout(()=>I(_),200)},M=()=>{if(f.value&&f.value.readyState===1){const _={requestType:"DumpBufferRequest"};return f.value.send(JSON.stringify(_)),!0}return console.warn("⚠️ Cannot send dump buffer request - WebSocket not connected"),!1},j=_=>{e=_},V=_=>{r=_},N=_=>{t=_},w=_=>{n=_};vue.onUnmounted(async()=>{await m()});const x=_=>{d=_},C=_=>{s=_},A=_=>{u=_};return{websocket:vue.readonly(f),connectionStatus:vue.readonly(c),openWebsocket:R,send:b,sendMontageMessage:k,sendFilterMessage:I,sendDumpBufferRequest:M,disconnect:m,setClearChannelsCallback:x,setPackageId:C,setUseMedian:A,onSegment:j,onEvent:V,onChannelDetails:N,onError:w}},useCanvasRenderer=()=>{const f=vue.ref(null),c=vue.ref(null),v=(r,t,n)=>t*(r+n),l=(r=1)=>r,o=(r,t,n,d,s,u,a=!1)=>{const h=c.value;if(!h){console.warn("blurArea ref is missing, skipping renderData");return}const m=h.getContext("2d");if(!m){console.warn("Unable to get 2D context for blurArea, skipping renderData");return}m.setTransform(u,0,0,u,0,0),m.fillStyle="rgb(220,220,220)";const R=f.value;if(!R){console.warn("plotArea ref is missing, skipping drawing.");return}const g=R.getContext("2d");if(!g){console.warn("Unable to get 2D context for plotArea, skipping drawing.");return}g.setTransform(u,0,0,u,0,0),g.clearRect(0,0,d.cWidth,d.cHeight),m.clearRect(0,0,d.cWidth,d.cHeight);const y=t.reduce((O,b)=>b.visible?O+1:O,0);i(t,d.pHeight,y),g.save();for(let O in r.channels)if(r.channels.hasOwnProperty(O)){const b=r.channels[O];let k=null;if(k=t.find(_=>_.id===b.id),!k||!k.visible)continue;const I=d.start,M=d.rsPeriod,j=n.XOFFSET,V=Math.min(Math.round(d.cHeight/r.channels.length-2),10);for(let _=0;_<k.dataSegments.length;_+=2){if(k.dataSegments[_+1]<I){console.log("skipping something");continue}if(k.dataSegments[_]>I+d.duration){console.log("breaking something");break}let F=Math.floor(j+(k.dataSegments[_]-I)/M),L=Math.floor(j+(k.dataSegments[_+1]-I)/M),D=Math.floor(k.rowBaseline-V/2);m.fillRect(F,D,L-F,V)}e(k,b,d,n,s,a);const N=b.blocks.length;let w="Continuous";N&&(w=b.blocks[0].type),k.hover?k.selected?(g.strokeStyle="rgba(39,96,255,0.70)",g.fillStyle="rgba(39,96,255,0.70)"):(g.strokeStyle="rgba(39,96,255,0.60)",g.fillStyle="rgba(39,96,255,0.60)"):k.selected?(g.strokeStyle="rgb(249,162,58)",g.fillStyle="rgb(3249,162,58)"):w==="Neural"?g.strokeStyle="rgb(249,162,58)":(g.strokeStyle="black",g.fillStyle="black");let x=null,C=!0,A=1e6*(1/k.sf);for(let _=0;_<N;_++){const F=b.blocks[_];if(F.nrPoints===0){console.log("zero points");continue}const L=F.cData,D=F.nrPoints,B=L[0],J=L[1],z=L[2];let W=F.renderStartIndex,K=F.renderEndIndex;switch(m.clearRect(Math.floor(B[W]),Math.floor(k.rowBaseline-V/2),Math.ceil(B[K]-B[W]+2),V+1),F.type){case"Continuous":case"realtime":if(F.isMinMax){if(F.samplePeriod/A<3&&(C=!1),C){g.beginPath(),_>0&&B[W]<x.x+3?g.moveTo(x.x,x.y):g.moveTo(B[W],J[W]);for(let X=W;X<K+1;X++)g.lineTo(B[X],J[X]);for(let X=K-1;X>=W;X--)g.lineTo(B[X],z[X]);_>0&&B[W]<x.x+3&&g.lineTo(x.x,x.y2),g.closePath(),g.fill()}else{g.beginPath();for(let X=W;X<K+1;X++)g.lineTo(B[X],J[X]),g.lineTo(B[X],z[X]),g.moveTo(B[X],J[X]);g.stroke()}g.beginPath(),g.moveTo(B[W],J[W]);for(let X=W;X<K+1;X++)g.lineTo(B[X],J[X]);g.stroke()}else{_===0?(g.beginPath(),g.moveTo(B[W],J[W])):B[W]>x.x+2&&g.moveTo(B[W],J[W]);for(let X=W;X<K+1;X++)g.lineTo(B[X],J[X]);_===N-1&&g.stroke()}break;case"Neural":g.beginPath();for(let X=0;X<D;X++)g.moveTo(B[X],J[X]),g.lineTo(B[X],z[X]);g.stroke();break}x={x:B[D-1],y:J[D-1],y2:z[D-1]}}}g.restore()},i=(r,t,n)=>{const d=r.map(function(h,m){return{index:m,value:h.rank}});d.sort(function(h,m){return+(h.value>m.value)||+(h.value===m.value)-1});const s=d.map(function(h){return h.index}),u=(t+20)/n;let a=0;for(let h=0;h<s.length;h++){const m=r[s[h]];m.visible?(m.rowBaseline=.5*u+a*u,a++):m.rowBaseline=null}},e=(r,t,n,d,s,u)=>{let a=t.blocks.length;switch(r.type){case"UNIT":if(!u)for(let m=0;m<a;m++){const R=t.blocks[m],g=R.cData,y=R.parsedData,O=d.XOFFSET,b=R.parsedData[0].length,k=g[0],I=g[1],M=g[2],j=y[0],V=r.rowBaseline|0,N=n.start,w=n.rsPeriod,x=n.cHeight/(2*(n.nrVisibleChannels+1))|0;for(let C=0;C<b;C++)k[C]=O+(j[C]-N)/w,I[C]=V-x,M[C]=V+x}break;case"CONTINUOUS":let h=0;if(!u){t.mean=0,t.median=0;for(let m=0;m<a;m++){const R=t.blocks[m];R.nrValidPoints>0&&(t.mean=(R.sumElem+h*t.mean)/(h+R.nrValidPoints),t.median=(R.median+h*t.median)/(h+R.nrValidPoints),h+=R.nrValidPoints)}}for(let m=0;m<a;m++){const R=t.blocks[m];let g=Math.floor((n.start-R.startTs)/R.samplePeriod);R.renderStartIndex=g>0?g:0;let y=Math.floor((n.start+n.duration-(R.startTs+R.nrPoints*R.samplePeriod))/R.samplePeriod);R.renderEndIndex=y>=0?R.nrPoints-1:R.nrPoints+y;const O=R.cData,b=R.parsedData,k=s*r.rowScale,I=d.XOFFSET,M=R.parsedData[0].length,j=O[0],V=O[1],N=O[2],w=b[0],x=b[1],C=b[2],A=r.rowBaseline;let _=0;d.USEMEDIAN?_=t.median:_=t.mean;const F=n.rsPeriod,L=n.start;for(let D=0;D<M;D++)j[D]=I+(w[D]-L)/F,V[D]=A-(x[D]-_)*k,R.isMinMax&&(x[D]===C[D]?N[D]=V[D]+1:N[D]=A-(C[D]-_)*k)}break}};return{plotCanvasRef:f,blurCanvasRef:c,initializeCanvases:l,renderData:o,computeChannelViews:i,getPointCoords:e,cpCanvasScaler:v}},useTimeSeriesData=()=>{const f=vue.ref([]),c=vue.ref(new Map),v=vue.reactive({start:0,duration:0,channels:[]}),l=vue.ref(!1),o=vue.ref(0),i=vue.ref(null),e=vue.ref(1),r=15e6,t=3,n=(b,k,I,M)=>{M||(M=0);let j=d(b,k,M,b.length-1,I);return j===-1?j=0:j<0&&(j=-j-2),j},d=(b,k,I,M,j)=>{if(M<I){let N;if(M>=0?N=M:N=-M-2,N===-1)return N;const w=b[N].pageStart;for(;N>=0&&b[N].pageStart===w;)N--;return N++,-N-2}const V=parseInt((I+M)/2);if(b[V].pageStart>k)return d(b,k,I,V-1,j);if(b[V].pageStart<k)return d(b,k,V+1,M,j);{let N=V;if(j){for(;N>=0&&b[N].pageStart===k;)N--;N++}else{for(;N<b.length&&b[N].pageStart===k;)N++;N--}return N}},s=(b,k,I)=>{if(!b)return Promise.resolve();const M=[];if(b.length>0){const j=[];for(let V=0;V<b.length;V++){const N=b[V].content,x={id:I?I(N):N.id,serverId:N.serverId,label:N.name,displayName:N.displayName,type:N.channelType,segments:[],start:N.start,end:N.end,sampleFreq:N.rate,unit:N.unit,gaps:[],dataSegments:[]},C=x.label.split("<->",3),A=C[0];let _=C.length>1?parseFloat(C[1]):0;_=isNaN(_)?C[1]:_,j.push({id:x.id,serverId:x.serverId,type:x.type,label:x.label,displayName:x.displayName,label_split:C,label_prefix:A,label_value:_,dataSegments:[],rank:V,visible:!0,plotAgainst:null,rowBaseline:null,rowScale:1,rowAdjust:0,selected:!1,hover:!1,unit:N.unit,sf:N.rate,filter:{},hideFilter:!0,isEditing:!1}),M.push(x)}k&&k.setChannels(j)}return u(M),f.value=M,o.value=b.length,l.value=!0,Promise.resolve()},u=b=>{var k,I;if(b.length===0){i.value=null;return}i.value=((I=(k=b[0])==null?void 0:k.gaps)==null?void 0:I[0])||null},a=b=>{let k=null;const I=b.data.chId||b.data.source,M=b.data.label||b.data.name;if(k=f.value.find(j=>j.serverId===I&&j.label===M),!k){console.error("❌ NO EXACT MATCH - rejecting to prevent data corruption:",{serverResponseId:I,serverResponseName:M,availableChannels:f.value.map(j=>({id:j.id,serverId:j.serverId,label:j.label,matches:{serverId:j.serverId===I,label:j.label===M}}))});return}switch(b.type){case"gap":case"Neural":case"Continuous":let j=!1,V=k&&k.segments;if(V&&b.type!=="gap"&&(j=!0,V.length>0)){let w=n(V,b.data.startTs,!0,0);for(;V[w]&&V[w].pageStart===b.data.pageStart;){if(V[w].startTs===b.data.startTs){j=!1;break}w++}}let N=c.value.get(b.data.pageStart);if(N){let w=N.counter.get(k.id);if(isNaN(w)&&(w=b.nrResponses||1,N.counter.set(k.id,w)),w>0&&(w=w-1,N.counter.set(k.id,w)),w===0){let x=!0;for(let[C,A]of N.counter.entries())if(A>0||isNaN(A)){x=!1;break}x&&c.value.delete(b.data.pageStart)}}j&&(V.push(b.data),V.sort((w,x)=>w.startTs<x.startTs?-1:w.startTs>x.startTs?1:0));break}},h=()=>{i.value=[],c.value.clear();for(let b=0;b<f.value.length;b++)f.value[b].segments=[];for(let b=0;b<v.channels.length;b++)v.channels[b].blocks=[]},m=b=>{let k=0,I=0,M=v.channels;for(let V=0;V<M.length;V++){let N=M[V].blocks;for(let w=0;w<N.length;w++)N[w].type==="Continuous"&&(k+=R(N[w].parsedData[1]),I++)}const j=k/I;return!isNaN(j)&&b?b/M.length/(2*j):1},R=b=>{const k=g(b),I=b.map(function(V){const N=V-k;return N*N}),M=g(I);return Math.sqrt(M)},g=b=>b.reduce(function(M,j){return M+j},0)/b.length;return{chData:f,requestedPages:c,viewData:v,channelsReady:l,autoScale:o,globalGaps:i,pageSize:r,prefetchPages:t,currentRequestedSamplePeriod:e,initChannels:s,computeSummary:u,dataCallback:a,invalidate:h,autoScaleViewData:m,segmIndexOf:n,updateCurrentRequestedSamplePeriod:b=>{e.value=Math.ceil(b)},isDataCurrentForViewport:b=>b&&b.startTs&&b.startTs>0,standardDeviation:R,average:g}},useDataRequests=()=>{const f=vue.ref([]),c=vue.ref([]),v=vue.ref(null),l=vue.ref(!1),o=vue.ref(null),i=vue.ref(0),e=vue.ref(0);let r=null;const t=(y,O)=>{r=function(){var k,I;if(c.value.length>0){const j=((k=O.value)==null?void 0:k.size)||0;j<5?y([c.value[0]])?c.value.splice(0,1):(console.warn("❌ Prefetch request failed"),clearInterval(v.value),l.value=!1):console.log("🚫 Prefetch blocked - too many pending pages:",{current:j,max:5,pendingPageStarts:Array.from(((I=O.value)==null?void 0:I.keys())||[])})}else console.log("✅ No more prefetch requests, stopping prefetch timer"),clearInterval(v.value),l.value=!1}},n=(y,O,b,k,I,M,j,V,N,w)=>{k.start=O,k.duration=b;const x=[];for(let C=0;C<k.channels.length;C++){const A=w?w(k.channels[C]):k.channels[C].id;x.push(A)}for(let C=0;C<y.length;C++){const A=y[C],_=w?w(A):A.id;x.indexOf(_)<0&&k.channels.push({id:_,mean:null,firstRenderedIndex:0,lastRenderedIndex:0,blocks:[]})}return d(y,O,b,k,I,M,j,V,N,w)},d=(y,O,b,k,I,M,j,V,N,w)=>{f.value=[];let C=!1;(i.value!==O||e.value!==b)&&(c.value=[],C=!0),i.value=O,e.value=b;const A=[];for(let _=0;_<k.channels.length;_++)A.push(k.channels[_]);for(let _=0;_<y.length;_++){let F=!1;const L=y[_],D=L.segments,B=w?w(L):L.id,J=A.findIndex(ne=>(w?w(ne):ne.id)===B);if(J===-1)continue;const z=k.channels[J];if(!z)continue;z.blocks=[];let W=Math.floor(O/15e6)*15e6;W<0&&(W=0);let K=0,X=0;D.length>0&&(K=N(D,W,!0,0));let ce=O+b+M.PREFETCHPAGES*15e6;ce>V&&(ce=V);let U;for(D.length>0&&(U=D[K]);W<ce||F;){F=!1;let ne=!1;if(U&&(ne=W>=U.pageStart&&W<=U.pageEnd),ne){let fe=U.startTs<O+b;X+=1,W+=15e6,fe&&z.blocks.push(U);const se=U.pageStart;U=D[K+X],U&&se===U.pageStart&&(F=!0)}else{if(I.get(W)){if(W+=15e6,U&&W>=U.pageEnd)for(;U&&U.pageEnd<W&&(X+=1,U=D[K+X],!!U););continue}let fe=W<O+b,se=!1;if(fe){for(let ue in c.value)if(c.value[ue].start===W){c.value.splice(ue,1);break}for(let ue in f.value)f.value[ue].start===W&&(f.value[ue].channels.push(L),se=!0);se||f.value.push({channels:[L],start:W,duration:15e6,isInViewport:!0,pixelWidth:Math.ceil(j)})}else if(C){for(let ue in c.value)c.value[ue].start===W&&(c.value[ue].channels.push(L),se=!0);se||c.value.push({channels:[L],start:W,duration:15e6,isInViewport:!1,pixelWidth:Math.ceil(j)})}if(W+=15e6,U&&W>=U.pageEnd)for(;U&&U.pageEnd<W&&(X+=1,U=D[K+X],!!U););}}z.blocks.sort(s)}return{asyncRequests:f.value,asyncPreRequests:c.value}},s=(y,O)=>y.startTs<O.startTs?-1:y.startTs>O.startTs?1:0,u=(y,O=0,b,k,I,M,j,V)=>{if(y.length===0)return console.log("⚠️ No requests to send"),!1;const N=V;for(let w=0;w<y.length;w++){let x;w===0?x=y[O]:w===O?x=y[0]:x=y[w];let C=x.start+x.duration;C>N&&(C=N);const A=b;if(A&&A.readyState===1){const _=x.channels.map(z=>{const W=z.serverId||z.id,K=z.label||z.name;return{id:W,name:K}}),F={session:k,minMax:!0,startTime:x.start,endTime:C,packageId:I.content.id,pixelWidth:x.pixelWidth,virtualChannels:_},L=JSON.stringify(F);A.send(L);const D=x.channels.length,B=new Map;for(let z=0;z<D;z++){const W=x.channels[z].id;B.set(W,NaN)}const J={count:D,counter:B,subPageCount:NaN,ts:Date.now(),inViewport:x.isInViewport,channels:x.channels.map(z=>({id:z.id,serverId:z.serverId,label:z.label}))};j.set(x.start,J)}else return console.error("❌ WebSocket not ready for sending requests:",{readyState:A==null?void 0:A.readyState,wsExists:!!A}),!1}return f.value=[],!0},a=()=>{c.value.length>0&&(l.value||(v.value=setInterval(r,150),l.value=!0))},h=()=>{v.value&&(clearInterval(v.value),v.value=null),l.value=!1},m=()=>{const y=f.value.length,O=c.value.length;f.value=[],c.value=[],i.value=0,e.value=0,h(),console.log("🧹 Cleared requests:",{asyncRequests:y,preRequests:O})},R=()=>{const y=f.value.slice();return f.value=[],y},g=(y,O,b)=>{const k=[];return y.forEach(function(I,M){if(!isNaN(I.subPageCount)){const j=[];I.counter.forEach(function(V,N){!isNaN(V)&&V>0&&j.push(N)}),j.length>0&&k.push({channels:j,start:M,duration:O,isInViewport:!0,pixelWidth:Math.ceil(b)})}}),y.clear(),k};return vue.onUnmounted(()=>{h()}),{aSyncRequests:vue.readonly(f),aSyncPreRequests:vue.readonly(c),isPrefetching:vue.readonly(l),lastViewPageRequest:vue.readonly(o),initializePrefetch:t,generatePoints:n,requestData:d,requestDataFromServer:u,startPrefetching:a,stopPrefetching:h,clearRequests:m,getViewportRequests:R,reRequestPages:g}},useChannelProcessing=(f,c,v,l)=>{const o=vue.reactive({totalChannels:0,processedChannels:0,montageChannels:0,errors:0,lastProcessingTime:0}),i=vue.ref(new Map),e=vue.ref(new Map),r=vue.computed(()=>c.value!=="NOT_MONTAGED"),t=vue.computed(()=>!r.value||!v.value?null:v.value.find(w=>w.name===c.value)),n=vue.computed(()=>{var w;return((w=t.value)==null?void 0:w.channelPairs)||{}});vue.watch(c,()=>{i.value.clear(),e.value.clear()});const d=w=>w?index.propOr("","id",w):"",s=w=>w?index.propOr("","serverId",w)||index.propOr("","id",w):"",u=w=>index.propOr("","id",w),a=w=>{if(!w)return"";let x=index.propOr("","id",w);if(r.value&&typeof x=="string"){const C=x.split("_");x=C.length>1?head(C):x}return x},h=(w,x,C=null)=>{var L,D;const A=C||c.value,_=`${w}_${x}_${A}`;if(e.value.has(_))return e.value.get(_);let F=`${w}-${x}`;if(A!=="NOT_MONTAGED"){const B=(L=v.value)==null?void 0:L.find(J=>J.name===A);if(B!=null&&B.channelPairs)for(const J of Object.keys(B.channelPairs)){const z=B.channelPairs[J];if(((D=z.channels)==null?void 0:D.length)===2&&z.channels[0]===w&&z.channels[1]===x){F=z.name||F;break}}}return e.value.set(_,F),F},m=w=>{if(!Array.isArray(w))return console.warn("Invalid channel details provided:",w),[];const x=performance.now();o.totalChannels=w.length,o.processedChannels=0,o.errors=0;const C=w.map(({id:A,name:_})=>{var F;try{const L=R(A);if(!L)return console.warn(`❌ Base channel not found for ID: ${A}, available base channels:`,((F=f.value)==null?void 0:F.map(B=>({id:B==null?void 0:B.id,name:B==null?void 0:B.name})))||[]),o.errors++,null;const D=g(A,_,L);return o.processedChannels++,r.value&&o.montageChannels++,D}catch(L){return console.error(`❌ Error processing channel ${A}:`,L),o.errors++,null}}).filter(Boolean);return o.lastProcessingTime=performance.now()-x,C},R=w=>{var C;if(i.value.has(w))return i.value.get(w);const x=(C=f.value)==null?void 0:C.find(A=>(A==null?void 0:A.id)===w);return x&&i.value.set(w,x),x},g=(w,x,C)=>{let A=x;const _=w;let F=w;if(r.value){F=`${w}_${x}`;const D=x.split("<->",2);D.length===2&&(A=h(D[0],D[1]),console.log("🎭 Montage display name created:",{originalName:x,channelParts:D,displayName:A}))}return{content:{id:F,serverId:_,name:x,channelType:C.channelType,label:x,displayName:A,unit:C.unit,rate:C.rate,start:C.start,end:C.end,montageScheme:r.value?c.value:"NOT_MONTAGED",isMontaged:r.value,baseChannelId:w},properties:C.properties||[]}},y=w=>{var A,_;if(w==="NOT_MONTAGED")return{montage:"NOT_MONTAGED",packageId:(A=l.value)==null?void 0:A.id,montageMap:[]};const x=v.value.find(F=>F.name===w);if(!x)return console.warn("Montage not found:",w),null;const C=x.channelPairs.map(F=>F.channels);return{montage:"CUSTOM_MONTAGE",packageId:(_=l.value)==null?void 0:_.content.id,montageMap:C}},O=w=>{const x=[];if(!w)return x.push("Channel configuration is null or undefined"),{isValid:!1,errors:x};const C=["id","label","type","unit","rate"];for(const _ of C)w[_]||x.push(`Missing required field: ${_}`);w.rate&&(typeof w.rate!="number"||w.rate<=0)&&x.push("Sample rate must be a positive number"),w.start&&w.end&&w.start>=w.end&&x.push("Channel start time must be less than end time");const A=["CONTINUOUS","UNIT","Neural"];return w.type&&!A.includes(w.type)&&x.push(`Invalid channel type: ${w.type}. Must be one of: ${A.join(", ")}`),{isValid:x.length===0,errors:x}},b=w=>w.sort((x,C)=>{const A=x.label||"",_=C.label||"",F=A.split("<->",3),L=_.split("<->",3);if(F.length>2||L.length>2)return A.localeCompare(_);const D=F[0]||"",B=L[0]||"";if(D===B&&F.length>1&&L.length>1){const J=parseFloat(F[1]),z=parseFloat(L[1]);return!isNaN(J)&&!isNaN(z)?J-z:F[1].localeCompare(L[1])}return D.localeCompare(B)}),k=(w,x=0)=>{const C=w.content,A=C.label.split("<->",3),_=A[0]||"",F=A.length>1?isNaN(parseFloat(A[1]))?A[1]:parseFloat(A[1]):0;return{id:C.id,serverId:C.serverId,type:C.channelType,label:C.label,displayName:C.displayName,labelParts:A,labelPrefix:_,labelValue:F,dataSegments:[],rank:x,visible:!0,plotAgainst:null,rowBaseline:null,rowScale:1,rowAdjust:0,selected:!1,hover:!1,unit:C.unit,sf:C.rate,filter:{},hideFilter:!0,isEditing:!1,montageScheme:C.montageScheme||"NOT_MONTAGED",isMontaged:C.isMontaged||!1,baseChannelId:C.baseChannelId}},I=(w,x={})=>{const{channelType:C=null,visible:A=null,montageScheme:_=null,labelPattern:F=null,sampleRate:L=null}=x;return w.filter(D=>!(C&&D.type!==C||A!==null&&D.visible!==A||_&&D.montageScheme!==_||F&&!new RegExp(F,"i").test(D.label)||L&&D.sf!==L))},M=(w,x="type")=>{const C={};return w.forEach(A=>{let _;switch(x){case"type":_=A.type;break;case"montage":_=A.montageScheme||"NOT_MONTAGED";break;case"prefix":_=A.labelPrefix;break;case"sampleRate":_=A.sf;break;case"unit":_=A.unit;break;default:_="all"}C[_]||(C[_]=[]),C[_].push(A)}),C},j=()=>{var w;return{...o,cacheSize:i.value.size,montageCacheSize:e.value.size,isViewingMontage:r.value,currentMontageScheme:c.value,availableMontages:((w=v.value)==null?void 0:w.map(x=>x.name))||[]}},V=()=>{i.value.clear(),e.value.clear(),Object.assign(o,{totalChannels:0,processedChannels:0,montageChannels:0,errors:0,lastProcessingTime:0})},N=async w=>{const x=[];for(const C of w)try{const A=await C();x.push({success:!0,result:A})}catch(A){x.push({success:!1,error:A.message}),o.errors++}return x};return{processingStats:vue.readonly(o),isViewingMontage:r,currentMontage:t,montageChannelPairs:n,getChannelId:d,getBaseChannelId:a,getServerChannelId:s,getRawChannelId:u,getDisplayName:h,processChannelData:m,createMontagePayload:y,createChannelConfig:k,validateChannelConfig:O,sortChannelConfigurations:b,filterChannels:I,groupChannels:M,findBaseChannel:R,createVirtualChannel:g,getProcessingStats:j,clearCaches:V,batchProcessChannels:N}};function createThrottle(f,c,v={}){let l,o,i,e=null,r=0;const{leading:t=!0,trailing:n=!0}=v,d=function(){r=t===!1?0:Date.now(),e=null,i=f.apply(l,o),e||(l=o=null)},s=function(){const u=Date.now();!r&&t===!1&&(r=u);const a=c-(u-r);return l=this,o=arguments,a<=0||a>c?(e&&(clearTimeout(e),e=null),r=u,i=f.apply(l,o),e||(l=o=null)):!e&&n!==!1&&(e=setTimeout(d,a)),i};return s.cancel=function(){clearTimeout(e),r=0,e=l=o=null},s}const _hoisted_1$1={class:"timeseries-plot-canvas"},_hoisted_2$1=["width","height"],_hoisted_3$1=["width","height"],_sfc_main$1={__name:"TSPlotCanvas",props:{cHeight:{type:Number,required:!0},cWidth:{type:Number,required:!0},start:{type:Number,required:!0},duration:{type:Number,required:!0},constants:{type:Object,required:!0},rsPeriod:{type:Number,required:!0},ts_start:{type:Number,required:!0},ts_end:{type:Number,required:!0},globalZoomMult:{type:Number,required:!0},activeViewer:{type:Object,required:!0}},emits:["channelsInitialized","setGlobalZoom"],setup(f,{expose:c,emit:v}){const l=f,o=v,i=vue.computed(()=>l.activeViewer||{}),e=vue.computed(()=>{var T;return((T=i.value)==null?void 0:T.channels)||[]}),r=index.useViewerStore(),{viewerChannels:t,viewerMontageScheme:n,workspaceMontages:d}=pinia.storeToRefs(r),{websocket:s,connectionStatus:u,openWebsocket:a,send:h,sendFilterMessage:m,sendDumpBufferRequest:R,disconnect:g,setClearChannelsCallback:y,onSegment:O,onEvent:b,onChannelDetails:k,onError:I}=useWebSocket(),{plotCanvasRef:M,blurCanvasRef:j,initializeCanvases:V,renderData:N,cpCanvasScaler:w}=useCanvasRenderer(),x=vue.ref(1),C=vue.ref(!1),{chData:A,requestedPages:_,viewData:F,channelsReady:L,autoScale:D,initChannels:B,dataCallback:J,invalidate:z,autoScaleViewData:W,segmIndexOf:K,updateCurrentRequestedSamplePeriod:X,currentRequestedSamplePeriod:ce,isDataCurrentForViewport:U}=useTimeSeriesData(),{aSyncRequests:ne,aSyncPreRequests:fe,isPrefetching:se,initializePrefetch:ue,generatePoints:me,requestDataFromServer:oe,startPrefetching:he,clearRequests:be}=useDataRequests(),{getChannelId:Se,processChannelData:Re,createMontagePayload:pe}=useChannelProcessing(e,n,d,i),Oe=vue.ref({totalRequests:0,successfulRequests:0,failedRequests:0,montageRequests:0,singleChannelRequests:0,lastPrefetchTime:null,averageResponseTime:0}),ae=vue.ref(null),qe=vue.ref(null),Te=vue.ref(null),we=vue.ref(0),ge=vue.computed(()=>x.value*l.cWidth),ye=vue.computed(()=>w(l.cHeight,x.value,0)),de=vue.computed(()=>l.cHeight-20),Ae=vue.computed(()=>({width:l.cWidth+"px",height:de.value+"px"})),le=vue.reactive({start:l.start,duration:l.duration,cWidth:l.cWidth,cHeight:l.cHeight,pHeight:de.value,rsPeriod:l.rsPeriod,nrVisibleChannels:0}),ke=vue.computed(()=>l.rsPeriod>0?l.rsPeriod:le.duration>0&&le.cWidth>0?le.duration/le.cWidth:(console.warn("⚠️ Using fallback rsPeriod = 1"),1));vue.watch(ke,T=>{T>0&&X(T)},{immediate:!0});const _e=()=>{var T;try{if(!L.value){console.log("⏳ Render skipped - channels not ready");return}le.nrVisibleChannels=((T=t.value)==null?void 0:T.reduce((Z,G)=>G.visible?Z+1:Z,0))||0;let $=0,Y=0;if(F.channels.forEach((Z,G)=>{const H=Z.blocks||[],Q=H.reduce((te,ee)=>te+(ee.nrPoints||0),0);H.length>0&&(Y++,$+=H.length)}),Y===0)return;N(F,t.value||[],l.constants,le,l.globalZoomMult,x.value)}catch($){console.error("💥 ERROR in renderDataInternal:",$),console.error("💥 Stack trace:",$.stack)}},xe=vue.ref(),Ce=()=>{xe.value=setInterval(()=>{var Y,Z;if(!L.value)return;const T={timestamp:new Date().toISOString(),requestedPagesSize:_.value.size,isPrefetching:se.value,pendingAsyncRequests:ne.value.length,pendingPreRequests:fe.value.length,currentMontage:n.value,channelCount:((Y=t.value)==null?void 0:Y.length)||0,visibleChannelCount:((Z=t.value)==null?void 0:Z.filter(G=>G.visible).length)||0,connectionStatus:u.value,requestedPages:Array.from(_.value.entries()).map(([G,H])=>{var Q;return{pageStart:G,channelCount:H.count,inViewport:H.inViewport,age:Date.now()-H.ts,channels:((Q=H.channels)==null?void 0:Q.map(te=>te.id))||Array.from(H.counter.keys())}})},$=T.requestedPages.filter(G=>G.age>1e4);$.length>0&&console.warn("⚠️ Detected stuck requests:",$),T.pendingPreRequests>0&&!T.isPrefetching&&console.warn("⚠️ Prefetch is blocked with pending requests:",{pendingPreRequests:T.pendingPreRequests,requestedPagesSize:T.requestedPagesSize})},5e3)},Ee=async()=>{if(!t.value)return;const T=A.value.filter(ee=>{const ve=t.value.find(re=>re.id===ee.id);return ve&&ve.visible}),$=ke.value,Y=me(T,l.start,l.duration,F,_.value,l.constants,$,l.ts_end,K,Se),Z=Math.ceil($);let G=!1,H="";if(ae.value!==null&&Z!==ae.value&&(G=!0,H=`rsPeriod changed: ${ae.value} → ${Z} (resolution change)`),qe.value!==null){const ee=Math.abs(l.start-qe.value),ve=Math.max(l.duration,Te.value||l.duration);ee>ve*2&&(G=!0,H=`Large time jump: ${ee} > ${ve*2} (${(ee/ve).toFixed(1)}x window)`)}const Q=15;if(_.value.size>Q&&(G=!0,H=`Too many pending requests: ${_.value.size} > ${Q}`),we.value>=5&&(G=!0,H=`High stale data rate: ${we.value} consecutive stale segments`),G&&!C.value){C.value=!0,console.log("🚨 Dumping server buffer before new requests:",H);try{R()&&(_.value.clear(),be(),we.value=0,await new Promise(ee=>setTimeout(ee,50)))}finally{C.value=!1}}else if(G&&C.value){console.log("⏭️ Skipping duplicate dump request (already in progress)");return}ae.value=Z,qe.value=l.start,Te.value=l.duration;const te=await index.useToken();Y.asyncRequests.length>0&&oe(Y.asyncRequests,0,s.value,te,i.value,$,_.value,l.ts_end),Y.asyncPreRequests.length>0&&he()},ie=()=>{Ee(),_e()},P=()=>{Ee(),D.value===0?(D.value--,E()):_e()},E=()=>{const T=W(l.cHeight);T&&!isNaN(T)&&o("setGlobalZoom",T),_e()},p=createThrottle(P,250,{leading:!1}),S=createThrottle(()=>ie(),50);vue.watch(()=>l.rsPeriod,(T,$)=>{T>0&&X(T),z(),_.value.clear()}),vue.watch(()=>l.duration,(T,$)=>{z()}),vue.watch(()=>n.value,T=>{if(s.value&&s.value.readyState===1){console.log("🔄 Montage changing to:",T),_.value.clear(),be(),z(),we.value=0,ae.value=null,qe.value=null,Te.value=null,L.value=!1;const $=pe(T);console.log("📡 Sending montage payload:",$),$&&h($)}}),vue.watch(()=>[l.start,l.duration,l.cWidth,l.cHeight,l.rsPeriod],()=>{le.start=l.start,le.duration=l.duration,le.cWidth=l.cWidth,le.cHeight=l.cHeight,le.pHeight=de.value,le.rsPeriod=l.rsPeriod}),O(T=>{T.pageStart>=l.start+l.duration&&(Oe.value.totalRequests++,n.value!=="NOT_MONTAGED"?Oe.value.montageRequests++:Oe.value.singleChannelRequests++),J(T),T.pageStart<l.start+l.duration&&p()}),b(T=>{if(!U(T.data)){we.value++;return}we.value=0,J(T),T.pageStart<l.start+l.duration&&p()}),k(T=>{const $=Re(T);B($,r,Se).then(()=>{z(),ie(),o("channelsInitialized")})}),I(T=>{r.setViewerErrors(T)});const q=async()=>{var Y,Z,G;const T=ke.value;X(T),y(()=>{var H;if((H=t.value)!=null&&H.length){const te={channelFiltersToClear:t.value.map(ee=>ee.id)};m(te)}});const $=await index.useToken();if(ue(H=>{const Q=ke.value;return oe(H,0,s.value,$,i.value,Q,_.value,l.ts_end)},_),(Y=i.value)!=null&&Y.content.id)try{console.log("🔄 Opening WebSocket connection for package:",i.value.content.id),await a(r.config.timeseriesDiscoverApi,i.value.content.id,$),console.log("✅ WebSocket connection established"),Ce()}catch(H){console.error("❌ Failed to establish WebSocket connection:",H);return}console.log("🚀 TSPlotCanvas mounted with config:",{activeViewerId:(Z=i.value)==null?void 0:Z.content.id,initialMontage:n.value,baseChannelCount:((G=e.value)==null?void 0:G.length)||0,viewport:{start:l.start,duration:l.duration,width:l.cWidth,height:l.cHeight,rsPeriod:l.rsPeriod}})};return vue.onMounted(async()=>{x.value=1,V(x.value),q()}),vue.onUnmounted(()=>{clearInterval(xe.value),_.value.size>0&&R(),r.resetViewer(),be(),g(),p.cancel&&p.cancel(),S.cancel&&S.cancel()}),c({renderAll:ie,invalidate:z,throttledDataRender:S,sendFilterMessage:m,viewData:F,requestedPages:_,chData:A,viewerChannels:t,currentRequestedSamplePeriod:ce,initPlotCanvas:q}),(T,$)=>(vue.openBlock(),vue.createElementBlock("div",_hoisted_1$1,[vue.createElementVNode("canvas",{ref_key:"blurCanvasRef",ref:j,class:"canvas",width:ge.value,height:ye.value,style:vue.normalizeStyle(Ae.value)},null,12,_hoisted_2$1),vue.renderSlot(T.$slots,"axisCanvas",{},void 0,!0),vue.renderSlot(T.$slots,"annCanvas",{},void 0,!0),vue.createElementVNode("canvas",{ref_key:"plotCanvasRef",ref:M,class:"canvas",width:ge.value,height:ye.value,style:vue.normalizeStyle(Ae.value)},null,12,_hoisted_3$1)]))}},TSPlotCanvas=index._export_sfc(_sfc_main$1,[["__scopeId","data-v-4be24234"]]),_hoisted_1={class:"timeseries-viewer-canvas"},_hoisted_2={id:"canvasWrapper"},_hoisted_3=["width","height"],_hoisted_4=["width","height"],_hoisted_5=["width","height"],_hoisted_6=["width","height"],_sfc_main={__name:"TSViewerCanvas",props:{windowHeight:Number,windowWidth:Number,duration:Number,start:Number,cHeight:Number,cWidth:Number,globalZoomMult:Number,constants:Object,tsStart:Number,tsEnd:Number,cursorLoc:Number,activeViewer:{type:Object,required:!0}},emits:["setDuration","setGlobalZoom","setStart","addAnnotation","updateAnnotation","closeAnnotationLayerWindow","channelsInitialized","annLayersInitialized"],setup(f,{expose:c,emit:v}){const l=vue.defineAsyncComponent(()=>Promise.resolve().then(()=>require("./TSAnnotationCanvas-Cq5fLEeQ.cjs"))),o=f,i=v,e=index.useViewerStore(),{viewerChannels:r,viewerAnnotations:t,viewerActiveTool:n,viewerSelectedChannels:d}=pinia.storeToRefs(e),s=vue.ref(null),u=vue.ref(null),a=vue.ref(null),h=vue.ref(null),m=vue.ref(null),R=vue.ref(null);vue.reactive({});const g=vue.ref(0),y=vue.ref(0),O=vue.ref(0),b=vue.ref(1),k=vue.ref(!1),I=vue.ref(!1),M=vue.ref("pointer");vue.ref(!1);const j=vue.reactive({x:0,y:0}),V=vue.ref(0),N=vue.ref(["Event","Artifact","Seizure","Mark","Stim On","Stim Off","Start","Stop"]),w=vue.ref(0),x=vue.ref(null),C=vue.ref(0),A=vue.ref(!0),_=()=>{if(t.value.length>0){if(!t.value.some(S=>S.selected)){console.log("No layer selected, selecting first layer:",t.value[0]);const S=t.value[0];S&&S.id?e.setActiveAnnotationLayer(S.id):console.error("First layer has no ID:",S)}}else console.warn("No annotation layers available - waiting for layers to load"),setTimeout(()=>{t.value.length>0&&_()},500)},F=p=>{if(console.log("TSViewerCanvas: setActiveTool called with:",p),p){const S="set"+p.charAt(0).toUpperCase()+p.slice(1),q=L[S];typeof q=="function"&&q()}},L={setPan:()=>{console.log("Pan tool activated")},setPointer:()=>{console.log("Pointer tool activated")},setAnnotate:()=>{console.log("Annotate tool activated"),_()}},D=vue.computed(()=>r.value.filter(p=>p.visible).length),B=vue.computed(()=>o.cHeight-20),J=vue.computed(()=>o.cWidth+o.constants.CURSOROFFSET);vue.computed(()=>u.value);const z=vue.computed(()=>({width:o.cWidth+"px",height:o.cHeight+"px"})),W=vue.computed(()=>({width:o.cWidth+"px",height:B.value+"px"})),K=vue.computed(()=>({width:J.value+"px",height:o.cHeight+"px"}));vue.watch(()=>o.cHeight,()=>{Te()}),vue.watch(()=>o.cWidth,()=>{Te()}),vue.watch(()=>o.start,()=>{ye()}),vue.watch(()=>o.duration,()=>{var p;(p=s.value)==null||p.invalidate(),we(o.cWidth,o.duration),ye()}),vue.watch(()=>o.globalZoomMult,()=>{vue.nextTick(()=>{var p;(p=s.value)==null||p.throttledDataRender()})}),vue.watch(n,p=>{p&&(F(p),!k.value&&!["annResize-left","annResize-right","annSelect"].includes(M.value)&&(M.value=p))},{immediate:!0}),vue.watch(t,p=>{p.length>0&&n.value==="annotate"&&_()},{immediate:!0}),vue.watch(M,()=>{console.log(M);const p=R.value;if(p){switch(p.removeAttribute("col_resize"),p.removeAttribute("active"),p.removeAttribute("point"),M.value){case"cursor_hover":p.removeAttribute("point"),p.setAttribute("cursor_hover",!0);break;case"annResize-left":case"annResize-right":p.setAttribute("col_resize",!0);break;case"annSelect":p.setAttribute("active",!0);break;case"pan":case"pan":break;case"pointer":case"annotate":p.setAttribute("point",!0);break;default:p.removeAttribute("point"),p.removeAttribute("cursor_hover");break}vue.nextTick(()=>{Ae()})}});const X=()=>{var p;(p=m.value)==null||p.resetFocusedAnnotation()},ce=p=>{var S;(S=m.value)==null||S.createAnnotationLayer(p)},U=()=>{var q;let p=(o.cursorLoc*o.cWidth-o.constants.CURSOROFFSET)*g.value;return((q=m.value)==null?void 0:q.findNextAnnotation(o.start+p)).start-p},ne=()=>{var q;let p=(o.cursorLoc*o.cWidth-o.constants.CURSOROFFSET)*g.value;return((q=m.value)==null?void 0:q.findPreviousAnnotation(o.start+p)).start-p},fe=p=>{i("updateAnnotation",p)},se=()=>{i("closeAnnotationLayerWindow")},ue=()=>{ye(100)},me=()=>{console.log("Annotation layers initialized, ensuring active layer for annotate tool"),n.value==="annotate"&&_(),i("annLayersInitialized")},oe=p=>{i("setGlobalZoom",p)},he=()=>{i("channelsInitialized")},be=p=>{p.stopPropagation(),p.preventDefault(),p.shiftKey?Math.abs(p.deltaY)>Math.abs(p.deltaX)&&(p.deltaY>0?i("setDuration",o.duration*1.1):i("setDuration",o.duration/1.1)):Math.abs(p.deltaY)>Math.abs(p.deltaX)&&(p.deltaY>0?i("setGlobalZoom",o.globalZoomMult*1.2):i("setGlobalZoom",o.globalZoomMult/1.2))},Se=p=>{var S,q;switch(console.log("TSViewerCanvas: _onMouseUp called with pointerMode:",M.value,"viewerActiveTool:",n.value),I.value=!1,k.value=!1,M.value){case"pointer":Re();const T=p.metaKey,$=p.clientY-R.value.getBoundingClientRect().top,Y=j.y-R.value.getBoundingClientRect().top,Z=r.value.map(re=>(T===!1&&(re.selected=!1),(re.rowBaseline>Y&&re.rowBaseline<$||re.rowBaseline<Y&&re.rowBaseline>$)&&(re.selected=!0),re));e.setChannels(Z),ye();break;case"annSelect":Re(),(S=m.value)==null||S.selectFocusedAnn();break;case"annotate":_();let G=null,H=null;for(let re=0;re<t.value.length;re++)if(t.value[re].selected){G=re,H=t.value[re];break}if(console.log("Creating annotation - curLIndex:",G,"available layers:",t.value.length),console.log("Selected layer details:",H),G===null||!H||!H.id)if(console.error("No valid selected annotation layer found for annotation creation",{curLIndex:G,selectedLayer:H,allLayers:t.value}),t.value.length>0&&t.value[0].id)e.setActiveAnnotationLayer(t.value[0].id),H=t.value[0],G=0,console.log("Fallback: Selected first layer:",H);else{console.error("No layers available with valid IDs");return}const Q=d,te=Q.length===r.value.length||Q.length===0,ee=(p.clientX-j.x)*g.value,ve=V.value+(j.x-R.value.getBoundingClientRect().left)*g.value;if(console.log("Creating annotation with:",{startTime:ve,duration:ee,allChannels:te,selectedChannels:Q.length,layer:H.name,layerId:H.id,pointerMode:M.value}),Math.abs(ee)>1e3){const re={name:"",id:null,label:N.value[w.value],description:"",start:ve,duration:ee,end:ve+ee,cStart:null,cEnd:null,selected:!0,channelIds:Q,allChannels:te,layer_id:H.id,userId:null};console.log("📍 STEP 1 - TSViewerCanvas created:",re),e.setActiveAnnotation(re),console.log("📍 STEP 1 - Store now has:",e.activeAnnotation),i("addAnnotation",ve,ee,te,re.label,re.description,H);break}else console.log("Annotation duration too small, not creating annotation");break;case"annResize-left":case"annResize-right":(q=m.value)==null||q.onMouseUp();break}},Re=()=>{R.value.getContext("2d").clearRect(0,0,o.cWidth,o.cHeight)},pe=p=>{var q;console.log("TSViewerCanvas: _onMouseDown called with pointerMode:",M.value,"viewerActiveTool:",n.value),k.value=!0,V.value=o.start;const S=R.value.getBoundingClientRect();switch(j.x=p.clientX,j.y=p.clientY,n.value==="annotate"&&!["annResize-left","annResize-right","annSelect"].includes(M.value)&&(console.log("Setting pointerMode to annotate for annotation creation"),M.value="annotate"),M.value){case"annResize-left":case"annResize-right":I.value=!0,(q=m.value)==null||q.onMouseDown(p.clientX-S.left,p.clientY-S.top);break}},Oe=()=>{k.value=!1},ae=p=>{p.buttons===1?k.value=!0:k.value=!1},qe=p=>{var $,Y,Z,G;p.preventDefault(),p.stopPropagation();const S=R.value.getBoundingClientRect(),q=p.clientY-S.top,T=p.clientX-S.left;switch(n.value){case"pan":if(k.value){const H=V.value-(p.clientX-j.x)*g.value;i("setStart",H)}else{const H=($=m.value)==null?void 0:$.onMouseMove(T,q,M.value,k.value);M.value=H||"pan"}break;case"pointer":if(k.value)_e(p.clientX,p.clientY);else{const H=(Y=m.value)==null?void 0:Y.onMouseMove(T,q,M.value,k.value);M.value=H||"pointer"}break;case"annotate":if(k.value&&M.value==="annotate")Ce(p.clientX);else if(k.value&&["annResize-left","annResize-right"].includes(M.value)){const H=(Z=m.value)==null?void 0:Z.onMouseMove(T,q,M.value,k.value);M.value=H||M.value,ye()}else{const H=(G=m.value)==null?void 0:G.onMouseMove(T,q,M.value,k.value);H?(console.log("TSViewerCanvas: annCanvas.onMouseMove returned:",H),M.value=H):M.value="annotate"}break}},Te=()=>{we(o.cWidth,o.duration),ye(25)},we=(p,S)=>{const q=g.value,T=S/p;T!==q&&(O.value=Date.now(),g.value=T,y.value=Math.floor(S/o.constants.PAGESIZEDIVIDER))},ge=(p,S,q)=>S*(p+q),ye=(p=0,S=!0)=>{(!x.value||p!==C.value||A.value!==S)&&(x.value=de(le,p,{leading:S}),C.value=p,A.value=S),x.value()},de=(p,S,q={})=>{let T,$,Y,Z=null,G=0;const H=function(){G=q.leading===!1?0:Date.now(),Z=null,Y=p.apply(T,$),Z||(T=$=null)};return function(){const Q=Date.now();!G&&q.leading===!1&&(G=Q);const te=S-(Q-G);return T=this,$=arguments,te<=0||te>S?(Z&&(clearTimeout(Z),Z=null),G=Q,Y=p.apply(T,$),Z||(T=$=null)):!Z&&q.trailing!==!1&&(Z=setTimeout(H,te)),Y}},Ae=()=>{var p;Re(),(p=m.value)==null||p.render()},le=()=>{vue.nextTick(()=>{var p,S;ke(),xe(),(p=s.value)==null||p.renderAll(),(S=m.value)==null||S.render()})},ke=()=>{const S=u.value.getContext("2d");S.setTransform(b.value,0,0,b.value,0,0),S.clearRect(0,0,o.cWidth,o.cHeight),S.stroke(),S.beginPath(),S.lineWidth=1,S.moveTo(o.constants.XOFFSET+.5,.5),S.lineTo(o.constants.XOFFSET+.5,B.value+.5),S.lineTo(o.cWidth+.5,B.value+.5),S.stroke();let q=B.value/(2*D.value)+.5<<1>>1;S.lineWidth=.5;for(let G=0;G<D.value;G++)S.beginPath(),S.moveTo(o.constants.XOFFSET-2,q),S.lineTo(o.constants.XOFFSET+2,q),S.stroke(),q+=B.value/D.value;const T=o.constants.XGRIDSPACING*Math.ceil(o.duration/1e8),$=Math.ceil(o.duration/T)+1,Y=Math.ceil(o.constants.NRPXPERLABEL/(T/g.value)),Z=(T-o.start%T)%T;for(let G=0;G<$;G++){let H=o.start+Z+G*T;if(H>o.tsEnd)break;const Q=H-o.start,te=o.constants.XOFFSET+Q/g.value,ee=Math.round(te);if(ee>1&&(S.save(),S.beginPath(),S.lineWidth=.5,S.strokeStyle="rgb(235,235,235)",S.moveTo(ee+.5,.5),S.lineTo(ee+.5,B.value-.5),S.stroke(),S.restore(),((H/T+T/10)%Y|0)===1||Y===1)){S.beginPath(),S.lineWidth=1,S.moveTo(ee+.5,B.value-3),S.lineTo(ee+.5,B.value+3),S.stroke();const re=new Date(H/1e3);S.font="12px sans-serif",S.fillStyle="rgb(150,150,150)",S.fillText(P(re),ee-20.5,o.cHeight-.2)}}},_e=(p,S)=>{const q=R.value,T=q.getContext("2d");T.setTransform(b.value,0,0,b.value,0,0),T.clearRect(0,0,o.cWidth,o.cHeight),T.beginPath(),T.lineWidth=2,T.strokeStyle="#295eff",T.setLineDash([5,5,15,5]);const $=p-q.getBoundingClientRect().left,Y=S-q.getBoundingClientRect().top;T.rect($,Y,-p+j.x,-S+j.y),T.stroke()},xe=()=>{const S=h.value.getContext("2d");S.setTransform(b.value,0,0,b.value,0,0),S.clearRect(0,0,o.cWidth+o.constants.CURSOROFFSET,o.cHeight),S.save(),S.beginPath(),S.fillStyle="red";const q=o.cursorLoc*o.cWidth;q>o.constants.CURSOROFFSET?(S.strokeStyle="red",S.moveTo(q,0),S.lineTo(q,B.value),S.stroke()):S.moveTo(q,B.value),S.beginPath(),S.lineTo(q-5,B.value+8),S.lineTo(q+5,B.value+8),S.lineTo(q,B.value),S.fill(),S.restore()},Ce=p=>{const S=R.value,q=S.getContext("2d");q.setTransform(b.value,0,0,b.value,0,0);const T=o.constants.ANNOTATIONLABELHEIGHT,$=T/2|0;let Y=null;for(let Q=0;Q<t.value.length;Q++)if(t.value[Q].selected){Y=Q;break}if(Y===null)return;q.save(),q.clearRect(0,0,o.cWidth,o.cHeight),q.lineWidth=1;const Z=selectedChannels.length===r.value.length||selectedChannels.length===0,G=p-S.getBoundingClientRect().left,H=-p+j.x;if(Z){q.fillStyle="rgba(0,0,0,0.1)",q.fillRect(G,0,H,B.value),q.fillStyle=t.value[Y].color,q.strokeStyle=q.fillStyle;let Q=G-1,te=H+2;H<0&&(Q=G+1,te=H-2),q.fillRect(Q,0,te,T),q.setLineDash([5,5,5,5]),q.beginPath(),q.moveTo(G,T),q.lineTo(G,B.value),q.stroke(),q.beginPath(),q.moveTo(G+H,T),q.lineTo(G+H,B.value),q.stroke()}else{let Q=o.cHeight|0,te=0;const ee=r.value;q.fillStyle=t.value[Y].color,q.strokeStyle=q.fillStyle;let ve=G-1,re=H+2;H<0&&(ve=G+1,re=H-2);for(let Ne=0;Ne<ee.length;Ne++){const Ie=ee[Ne];if(Ie.selected&&Ie.visible){const Pe=Ie.rowBaseline|0;Pe<Q&&(Q=Pe),Pe>te&&(te=Pe),q.fillRect(ve,Pe-$,re,T)}}q.fillStyle="rgba(0,0,0,0.1)",q.setLineDash([5,5,5,5]),q.fillRect(G-1,Q+$,H+2,te-Q-T),q.beginPath(),q.moveTo(G,Q+$),q.lineTo(G,te-$),q.moveTo(G+H,Q+$),q.lineTo(G+H,te-$),q.stroke()}q.restore()},Ee=()=>{var p;(p=s.value)==null||p.initPlotCanvas()},ie=()=>{let p=R.value.getContext("2d"),S=window.devicePixelRatio||1,q=p.webkitBackingStorePixelRatio||p.mozBackingStorePixelRatio||p.msBackingStorePixelRatio||p.oBackingStorePixelRatio||p.backingStorePixelRatio||1;return S/q},P=p=>("0"+p.getUTCHours()).slice(-2)+":"+("0"+p.getUTCMinutes()).slice(-2)+":"+("0"+p.getUTCSeconds()).slice(-2),E=p=>{var $,Y;let S=parseFloat(p.input0),q=parseFloat(p.input1),T={};switch(p.filterType){case"clear":T={channelFiltersToClear:p.selChannels};break;case"bandpass":let Z=(S+q)/2,G=Math.abs((q-S)/2);T={filter:p.filterType,filterParameters:[4,Z,G],channels:p.selChannels};break;case"highpass":T={filter:p.filterType,filterParameters:[4,S],channels:p.selChannels};break;case"lowpass":T={filter:p.filterType,filterParameters:[4,S],channels:p.selChannels};break;case"bandstop":let H=10;const Q=p.notchFreq;T={filter:p.filterType,filterParameters:[4,Q,H],channels:p.selChannels};break;default:return}($=s.value)==null||$.sendFilterMessage(T);for(let Z=0;Z<p.selChannels.length;Z++){let G=p.selChannels[Z],H=find(index.propEq("id",G),r.value);p.filterType==="clear"?H.filter={}:H.filter={type:p.filterType,input0:S,input1:q,notchFreq:p.notchFreq}}(Y=s.value)==null||Y.invalidate(),ye()};return vue.onMounted(()=>{b.value=ie()}),c({rsPeriod:g,resetFocusedAnnotation:X,createAnnotationLayer:ce,getNextAnnotation:U,getPreviousAnnotation:ne,setFilters:E,setActiveTool:F,renderAll:ye,renderAnnotationCanvas:Ae,initViewerCanvas:Ee}),(p,S)=>(vue.openBlock(),vue.createElementBlock("div",_hoisted_1,[vue.createElementVNode("div",_hoisted_2,[vue.createVNode(TSPlotCanvas,{ref_key:"plotCanvas",ref:s,"c-width":f.cWidth,"c-height":f.cHeight,start:f.start,ts_start:f.tsStart,ts_end:f.tsEnd,duration:f.duration,constants:f.constants,"rs-period":g.value,"global-zoom-mult":f.globalZoomMult,"active-viewer":f.activeViewer,onChannelsInitialized:he,onSetGlobalZoom:oe},{axisCanvas:vue.withCtx(()=>[vue.createElementVNode("canvas",{id:"axisArea",ref_key:"axisArea",ref:u,class:"canvas",width:ge(f.cWidth,b.value,0),height:ge(f.cHeight,b.value,0),style:vue.normalizeStyle(z.value)},null,12,_hoisted_3)]),annCanvas:vue.withCtx(()=>[vue.createElementVNode("canvas",{id:"annArea",ref_key:"annArea",ref:a,class:"canvas",width:ge(f.cWidth,b.value,0),height:ge(B.value,b.value,0),style:vue.normalizeStyle(W.value)},null,12,_hoisted_4)]),_:1},8,["c-width","c-height","start","ts_start","ts_end","duration","constants","rs-period","global-zoom-mult","active-viewer"]),vue.createElementVNode("canvas",{id:"cursorArea",ref_key:"cursorArea",ref:h,class:"canvas",width:ge(f.cWidth+5,b.value,0),height:ge(f.cHeight,b.value,0),style:vue.normalizeStyle(K.value)},null,12,_hoisted_5),vue.createVNode(vue.unref(l),{ref_key:"annCanvas",ref:m,"c-width":f.cWidth,"c-height":f.cHeight,constants:f.constants,"annotations-canvas":a.value,"pixel-ratio":b.value,"rs-period":g.value,start:f.start,duration:f.duration,"ts-end":f.tsEnd,"pointer-mode":M.value,"viewer-active-tool":vue.unref(n),"active-viewer":f.activeViewer,onAnnLayersInitialized:me,onAnnotationsReceived:ue,onCloseAnnotationLayerWindow:se,onUpdateAnnotation:fe},null,8,["c-width","c-height","constants","annotations-canvas","pixel-ratio","rs-period","start","duration","ts-end","pointer-mode","viewer-active-tool","active-viewer"]),vue.createElementVNode("canvas",{id:"iArea",ref_key:"iArea",ref:R,class:"canvas",width:ge(f.cWidth,b.value,0),height:ge(f.cHeight,b.value,0),style:vue.normalizeStyle(z.value),tabindex:"-1",onWheel:be,onMousemove:qe,onMousedown:pe,onMouseup:Se,onMouseout:Oe,onMouseenter:ae},null,44,_hoisted_6)])]))}},TSViewerCanvas=index._export_sfc(_sfc_main,[["__scopeId","data-v-c902180d"]]),TSViewerCanvas$1=Object.freeze(Object.defineProperty({__proto__:null,default:TSViewerCanvas},Symbol.toStringTag,{value:"Module"}));exports.TSViewerCanvas=TSViewerCanvas$1;exports.find=find;exports.head=head;
|