tsviewer 1.0.31 → 1.0.32

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.
@@ -1,4 +1,4 @@
1
- import { b as i, n as o, q as h, r as s, o as f } from "./index-BXlfFRwy.mjs";
1
+ import { b as i, n as o, q as h, r as s, o as f } from "./index-BPrTaCv-.mjs";
2
2
  var v = /* @__PURE__ */ i(function(r, a) {
3
3
  return r.map(function(n) {
4
4
  for (var t = a, e = 0, u; e < n.length; ) {
@@ -1,4 +1,4 @@
1
- import { T as s, s as a, u as o } from "./index-BXlfFRwy.mjs";
1
+ import { T as s, s as a, u as o } from "./index-BPrTaCv-.mjs";
2
2
  export {
3
3
  s as TSViewer,
4
4
  a as default,
@@ -1,4 +1,4 @@
1
- (function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("pinia"),require("aws-amplify/auth")):typeof define=="function"&&define.amd?define(["exports","vue","pinia","aws-amplify/auth"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.tsviewer={},e.Vue,e.Pinia,e.Amplify.Auth))})(this,function(exports,vue,pinia,auth){"use strict";function _isPlaceholder(e){return e!=null&&typeof e=="object"&&e["@@functional/placeholder"]===!0}function _curry1(e){return function t(n){return arguments.length===0||_isPlaceholder(n)?t:e.apply(this,arguments)}}function _curry2(e){return function t(n,r){switch(arguments.length){case 0:return t;case 1:return _isPlaceholder(n)?t:_curry1(function(a){return e(n,a)});default:return _isPlaceholder(n)&&_isPlaceholder(r)?t:_isPlaceholder(n)?_curry1(function(a){return e(a,r)}):_isPlaceholder(r)?_curry1(function(a){return e(n,a)}):e(n,r)}}}function _concat(e,t){e=e||[],t=t||[];var n,r=e.length,a=t.length,s=[];for(n=0;n<r;)s[s.length]=e[n],n+=1;for(n=0;n<a;)s[s.length]=t[n],n+=1;return s}function _arity(e,t){switch(e){case 0:return function(){return t.apply(this,arguments)};case 1:return function(n){return t.apply(this,arguments)};case 2:return function(n,r){return t.apply(this,arguments)};case 3:return function(n,r,a){return t.apply(this,arguments)};case 4:return function(n,r,a,s){return t.apply(this,arguments)};case 5:return function(n,r,a,s,o){return t.apply(this,arguments)};case 6:return function(n,r,a,s,o,i){return t.apply(this,arguments)};case 7:return function(n,r,a,s,o,i,u){return t.apply(this,arguments)};case 8:return function(n,r,a,s,o,i,u,l){return t.apply(this,arguments)};case 9:return function(n,r,a,s,o,i,u,l,v){return t.apply(this,arguments)};case 10:return function(n,r,a,s,o,i,u,l,v,d){return t.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}function _curryN(e,t,n){return function(){for(var r=[],a=0,s=e,o=0;o<t.length||a<arguments.length;){var i;o<t.length&&(!_isPlaceholder(t[o])||a>=arguments.length)?i=t[o]:(i=arguments[a],a+=1),r[o]=i,_isPlaceholder(i)||(s-=1),o+=1}return s<=0?n.apply(this,r):_arity(s,_curryN(e,r,n))}}var curryN=_curry2(function(t,n){return t===1?_curry1(n):_arity(t,_curryN(t,[],n))});function _curry3(e){return function t(n,r,a){switch(arguments.length){case 0:return t;case 1:return _isPlaceholder(n)?t:_curry2(function(s,o){return e(n,s,o)});case 2:return _isPlaceholder(n)&&_isPlaceholder(r)?t:_isPlaceholder(n)?_curry2(function(s,o){return e(s,r,o)}):_isPlaceholder(r)?_curry2(function(s,o){return e(n,s,o)}):_curry1(function(s){return e(n,r,s)});default:return _isPlaceholder(n)&&_isPlaceholder(r)&&_isPlaceholder(a)?t:_isPlaceholder(n)&&_isPlaceholder(r)?_curry2(function(s,o){return e(s,o,a)}):_isPlaceholder(n)&&_isPlaceholder(a)?_curry2(function(s,o){return e(s,r,o)}):_isPlaceholder(r)&&_isPlaceholder(a)?_curry2(function(s,o){return e(n,s,o)}):_isPlaceholder(n)?_curry1(function(s){return e(s,r,a)}):_isPlaceholder(r)?_curry1(function(s){return e(n,s,a)}):_isPlaceholder(a)?_curry1(function(s){return e(n,r,s)}):e(n,r,a)}}}const _isArray=Array.isArray||function(t){return t!=null&&t.length>=0&&Object.prototype.toString.call(t)==="[object Array]"};function _isTransformer(e){return e!=null&&typeof e["@@transducer/step"]=="function"}function _dispatchable(e,t,n){return function(){if(arguments.length===0)return n();var r=arguments[arguments.length-1];if(!_isArray(r)){for(var a=0;a<e.length;){if(typeof r[e[a]]=="function")return r[e[a]].apply(r,Array.prototype.slice.call(arguments,0,-1));a+=1}if(_isTransformer(r)){var s=t.apply(null,Array.prototype.slice.call(arguments,0,-1));return s(r)}}return n.apply(this,arguments)}}function _reduced(e){return e&&e["@@transducer/reduced"]?e:{"@@transducer/value":e,"@@transducer/reduced":!0}}const _xfBase={init:function(){return this.xf["@@transducer/init"]()},result:function(e){return this.xf["@@transducer/result"](e)}};function _map(e,t){for(var n=0,r=t.length,a=Array(r);n<r;)a[n]=e(t[n]),n+=1;return a}function _isString$1(e){return Object.prototype.toString.call(e)==="[object String]"}var _isArrayLike=_curry1(function(t){return _isArray(t)?!0:!t||typeof t!="object"||_isString$1(t)?!1:t.length===0?!0:t.length>0?t.hasOwnProperty(0)&&t.hasOwnProperty(t.length-1):!1}),XWrap=function(){function e(t){this.f=t}return e.prototype["@@transducer/init"]=function(){throw new Error("init not implemented on XWrap")},e.prototype["@@transducer/result"]=function(t){return t},e.prototype["@@transducer/step"]=function(t,n){return this.f(t,n)},e}();function _xwrap(e){return new XWrap(e)}var bind=_curry2(function(t,n){return _arity(t.length,function(){return t.apply(n,arguments)})});function _arrayReduce(e,t,n){for(var r=0,a=n.length;r<a;){if(t=e["@@transducer/step"](t,n[r]),t&&t["@@transducer/reduced"]){t=t["@@transducer/value"];break}r+=1}return e["@@transducer/result"](t)}function _iterableReduce(e,t,n){for(var r=n.next();!r.done;){if(t=e["@@transducer/step"](t,r.value),t&&t["@@transducer/reduced"]){t=t["@@transducer/value"];break}r=n.next()}return e["@@transducer/result"](t)}function _methodReduce(e,t,n,r){return e["@@transducer/result"](n[r](bind(e["@@transducer/step"],e),t))}var symIterator=typeof Symbol<"u"?Symbol.iterator:"@@iterator";function _reduce(e,t,n){if(typeof e=="function"&&(e=_xwrap(e)),_isArrayLike(n))return _arrayReduce(e,t,n);if(typeof n["fantasy-land/reduce"]=="function")return _methodReduce(e,t,n,"fantasy-land/reduce");if(n[symIterator]!=null)return _iterableReduce(e,t,n[symIterator]());if(typeof n.next=="function")return _iterableReduce(e,t,n);if(typeof n.reduce=="function")return _methodReduce(e,t,n,"reduce");throw new TypeError("reduce: list must be array or iterable")}var XMap=function(){function e(t,n){this.xf=n,this.f=t}return e.prototype["@@transducer/init"]=_xfBase.init,e.prototype["@@transducer/result"]=_xfBase.result,e.prototype["@@transducer/step"]=function(t,n){return this.xf["@@transducer/step"](t,this.f(n))},e}(),_xmap=_curry2(function(t,n){return new XMap(t,n)});function _has(e,t){return Object.prototype.hasOwnProperty.call(t,e)}var toString$1=Object.prototype.toString,_isArguments=function(){return toString$1.call(arguments)==="[object Arguments]"?function(t){return toString$1.call(t)==="[object Arguments]"}:function(t){return _has("callee",t)}}(),hasEnumBug=!{toString:null}.propertyIsEnumerable("toString"),nonEnumerableProps=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],hasArgsEnumBug=function(){return arguments.propertyIsEnumerable("length")}(),contains=function(t,n){for(var r=0;r<t.length;){if(t[r]===n)return!0;r+=1}return!1},keys$1=_curry1(typeof Object.keys=="function"&&!hasArgsEnumBug?function(t){return Object(t)!==t?[]:Object.keys(t)}:function(t){if(Object(t)!==t)return[];var n,r,a=[],s=hasArgsEnumBug&&_isArguments(t);for(n in t)_has(n,t)&&(!s||n!=="length")&&(a[a.length]=n);if(hasEnumBug)for(r=nonEnumerableProps.length-1;r>=0;)n=nonEnumerableProps[r],_has(n,t)&&!contains(a,n)&&(a[a.length]=n),r-=1;return a}),map=_curry2(_dispatchable(["fantasy-land/map","map"],_xmap,function(t,n){switch(Object.prototype.toString.call(n)){case"[object Function]":return curryN(n.length,function(){return t.call(this,n.apply(this,arguments))});case"[object Object]":return _reduce(function(r,a){return r[a]=t(n[a]),r},{},keys$1(n));default:return _map(t,n)}}));const _isInteger=Number.isInteger||function(t){return t<<0===t};var nth=_curry2(function(t,n){var r=t<0?n.length+t:t;return _isString$1(n)?n.charAt(r):n[r]}),prop=_curry2(function(t,n){if(n!=null)return _isInteger(t)?nth(t,n):n[t]}),reduce=_curry3(_reduce),type$1=_curry1(function(t){return t===null?"Null":t===void 0?"Undefined":Object.prototype.toString.call(t).slice(8,-1)});function _pipe(e,t){return function(){return t.call(this,e.apply(this,arguments))}}function _checkForMethod(e,t){return function(){var n=arguments.length;if(n===0)return t();var r=arguments[n-1];return _isArray(r)||typeof r[e]!="function"?t.apply(this,arguments):r[e].apply(r,Array.prototype.slice.call(arguments,0,n-1))}}var slice=_curry3(_checkForMethod("slice",function(t,n,r){return Array.prototype.slice.call(r,t,n)})),tail=_curry1(_checkForMethod("tail",slice(1,1/0)));function pipe(){if(arguments.length===0)throw new Error("pipe requires at least one argument");return _arity(arguments[0].length,reduce(_pipe,arguments[0],tail(arguments)))}var reverse=_curry1(function(t){return _isString$1(t)?t.split("").reverse().join(""):Array.prototype.slice.call(t,0).reverse()});function compose(){if(arguments.length===0)throw new Error("compose requires at least one argument");return pipe.apply(this,reverse(arguments))}var head=nth(0);function _arrayFromIterator(e){for(var t=[],n;!(n=e.next()).done;)t.push(n.value);return t}function _includesWith(e,t,n){for(var r=0,a=n.length;r<a;){if(e(t,n[r]))return!0;r+=1}return!1}function _functionName(e){var t=String(e).match(/^function (\w*)/);return t==null?"":t[1]}function _objectIs(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}const _objectIs$1=typeof Object.is=="function"?Object.is:_objectIs;function _uniqContentEquals(e,t,n,r){var a=_arrayFromIterator(e),s=_arrayFromIterator(t);function o(i,u){return _equals(i,u,n.slice(),r.slice())}return!_includesWith(function(i,u){return!_includesWith(o,u,i)},s,a)}function _equals(e,t,n,r){if(_objectIs$1(e,t))return!0;var a=type$1(e);if(a!==type$1(t))return!1;if(typeof e["fantasy-land/equals"]=="function"||typeof t["fantasy-land/equals"]=="function")return typeof e["fantasy-land/equals"]=="function"&&e["fantasy-land/equals"](t)&&typeof t["fantasy-land/equals"]=="function"&&t["fantasy-land/equals"](e);if(typeof e.equals=="function"||typeof t.equals=="function")return typeof e.equals=="function"&&e.equals(t)&&typeof t.equals=="function"&&t.equals(e);switch(a){case"Arguments":case"Array":case"Object":if(typeof e.constructor=="function"&&_functionName(e.constructor)==="Promise")return e===t;break;case"Boolean":case"Number":case"String":if(!(typeof e==typeof t&&_objectIs$1(e.valueOf(),t.valueOf())))return!1;break;case"Date":if(!_objectIs$1(e.valueOf(),t.valueOf()))return!1;break;case"Error":return e.name===t.name&&e.message===t.message;case"RegExp":if(!(e.source===t.source&&e.global===t.global&&e.ignoreCase===t.ignoreCase&&e.multiline===t.multiline&&e.sticky===t.sticky&&e.unicode===t.unicode))return!1;break}for(var s=n.length-1;s>=0;){if(n[s]===e)return r[s]===t;s-=1}switch(a){case"Map":return e.size!==t.size?!1:_uniqContentEquals(e.entries(),t.entries(),n.concat([e]),r.concat([t]));case"Set":return e.size!==t.size?!1:_uniqContentEquals(e.values(),t.values(),n.concat([e]),r.concat([t]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var o=keys$1(e);if(o.length!==keys$1(t).length)return!1;var i=n.concat([e]),u=r.concat([t]);for(s=o.length-1;s>=0;){var l=o[s];if(!(_has(l,t)&&_equals(t[l],e[l],i,u)))return!1;s-=1}return!0}var equals=_curry2(function(t,n){return _equals(t,n,[],[])});function _isObject(e){return Object.prototype.toString.call(e)==="[object Object]"}var defaultTo=_curry2(function(t,n){return n==null||n!==n?t:n});function _isTypedArray(e){var t=Object.prototype.toString.call(e);return t==="[object Uint8ClampedArray]"||t==="[object Int8Array]"||t==="[object Uint8Array]"||t==="[object Int16Array]"||t==="[object Uint16Array]"||t==="[object Int32Array]"||t==="[object Uint32Array]"||t==="[object Float32Array]"||t==="[object Float64Array]"||t==="[object BigInt64Array]"||t==="[object BigUint64Array]"}var empty=_curry1(function(t){return t!=null&&typeof t["fantasy-land/empty"]=="function"?t["fantasy-land/empty"]():t!=null&&t.constructor!=null&&typeof t.constructor["fantasy-land/empty"]=="function"?t.constructor["fantasy-land/empty"]():t!=null&&typeof t.empty=="function"?t.empty():t!=null&&t.constructor!=null&&typeof t.constructor.empty=="function"?t.constructor.empty():_isArray(t)?[]:_isString$1(t)?"":_isObject(t)?{}:_isArguments(t)?function(){return arguments}():_isTypedArray(t)?t.constructor.from(""):void 0}),XFind=function(){function e(t,n){this.xf=n,this.f=t,this.found=!1}return e.prototype["@@transducer/init"]=_xfBase.init,e.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,void 0)),this.xf["@@transducer/result"](t)},e.prototype["@@transducer/step"]=function(t,n){return this.f(n)&&(this.found=!0,t=_reduced(this.xf["@@transducer/step"](t,n))),t},e}(),_xfind=_curry2(function(t,n){return new XFind(t,n)}),find=_curry2(_dispatchable(["find"],_xfind,function(t,n){for(var r=0,a=n.length;r<a;){if(t(n[r]))return n[r];r+=1}})),XFindIndex=function(){function e(t,n){this.xf=n,this.f=t,this.idx=-1,this.found=!1}return e.prototype["@@transducer/init"]=_xfBase.init,e.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,-1)),this.xf["@@transducer/result"](t)},e.prototype["@@transducer/step"]=function(t,n){return this.idx+=1,this.f(n)&&(this.found=!0,t=_reduced(this.xf["@@transducer/step"](t,this.idx))),t},e}(),_xfindIndex=_curry2(function(t,n){return new XFindIndex(t,n)}),findIndex=_curry2(_dispatchable([],_xfindIndex,function(t,n){for(var r=0,a=n.length;r<a;){if(t(n[r]))return r;r+=1}return-1})),isEmpty$1=_curry1(function(t){return t!=null&&equals(t,empty(t))}),paths=_curry2(function(t,n){return t.map(function(r){for(var a=n,s=0,o;s<r.length;){if(a==null)return;o=r[s],a=_isInteger(o)?nth(o,a):a[o],s+=1}return a})}),path$1=_curry2(function(t,n){return paths([t],n)[0]}),pathOr=_curry3(function(t,n,r){return defaultTo(t,path$1(n,r))}),propEq=_curry3(function(t,n,r){return equals(n,prop(t,r))}),propOr=_curry3(function(t,n,r){return defaultTo(t,prop(n,r))}),tryCatch=_curry2(function(t,n){return _arity(t.length,function(){try{return t.apply(this,arguments)}catch(r){return n.apply(this,_concat([r],arguments))}})});const apiUrl="https://api.pennsieve.net",api2Url="https://api2.pennsieve.net",timeSeriesUrl="wss://api.pennsieve.net/streaming/discover/ts/query",timeSeriesPublicUrl="wss://api.pennsieve.net/streaming/discover/ts/query",timeSeriesApi="https://api.pennsieve.net/streaming",site={apiUrl,api2Url,timeSeriesUrl,timeSeriesPublicUrl,timeSeriesApi},site$1=Object.freeze(Object.defineProperty({__proto__:null,api2Url,apiUrl,default:site,timeSeriesApi,timeSeriesPublicUrl,timeSeriesUrl},Symbol.toStringTag,{value:"Module"}));async function useToken(){try{return auth.fetchAuthSession().then(e=>{var t;return(t=e==null?void 0:e.tokens)==null?void 0:t.accessToken.toString()})}catch(e){console.error(e)}}const useChannelDataRequest=()=>({openConnection:async(t,n,r)=>await new Promise((o,i)=>{const u=t+"?session="+r+"&package="+n;console.log("Opening WebSocket connection to:",u);let l=null;const v=new WebSocket(u);v.onopen=()=>{console.log("🔗 WebSocket opened for package:",n);const d={montage:"NOT_MONTAGED",packageId:n};console.log("🎛️ Sending message payload"),v.send(JSON.stringify(d))},v.onclose=()=>{console.log("🔌 WebSocket closed for package:",n),l&&l.channelDetails?(console.log("Channel details received:",l.channelDetails),o({res:l.channelDetails,status:"websocket closed"})):(console.warn("No channel details received"),o({res:null,status:"websocket closed without data"}))},v.onmessage=d=>{console.log("WebSocket message received:",d.data),l=JSON.parse(d.data),v.close()},v.onerror=d=>{console.error("WebSocket error:",d),i(d)}})}),useViewerStore=pinia.defineStore("tsviewer",()=>{const e=site$1,t=vue.ref([]),n=vue.ref("NOT_MONTAGED"),r=vue.ref({}),a=vue.ref([]),s=vue.ref(null),o=vue.ref(null),i=vue.ref({}),u=vue.ref([]),l=vue.ref({}),v=vue.ref({}),d=vue.ref("POINTER"),{openConnection:f}=useChannelDataRequest(),c=vue.computed(()=>_e=>a.value.find(ze=>ze.name===_e)),p=vue.computed(()=>t.value.filter(_e=>_e.selected)),h=vue.computed(()=>()=>{const _e=u.value.find(ze=>ze.selected);return _e||(console.warn("No active layer found, available layers:",u.value),u.value.length>0?u.value[0]:null)}),y=()=>{let _e=!1;return u.value.forEach((ze,Et)=>{!ze.id&&ze.id!==0&&(console.error(`Layer at index ${Et} missing ID:`,ze),_e=!0),ze.annotations||(console.warn(`Layer at index ${Et} missing annotations array:`,ze),ze.annotations=[])}),_e&&console.error("Annotation layer validation failed. Layers:",u.value),!_e},m=vue.computed(()=>_e=>u.value.flatMap(Et=>Et.annotations||[]).find(Et=>Et.id===_e)),_=_e=>{i.value=_e},b=_e=>{t.value=_e},g=_e=>{n.value=_e},w=_e=>{r.value=_e},k=_e=>{a.value=_e},A=_e=>{s.value=_e},$=_e=>{o.value=_e},M=async _e=>{const ze=_e.packageId,Et=await useToken();let Cn=e.timeSeriesPublicUrl,kn=null;kn=await f(Cn,ze,Et),_({channels:kn.res,content:{id:ze}})},F=()=>_e=>{var Et;return((Et=_e==null?void 0:_e.content)==null?void 0:Et.state)==="READY"},O=_e=>{const ze=_e.map(Et=>(!Et.id&&Et.id!==0&&(console.warn("Annotation layer missing ID:",Et),Et.id=Math.random().toString(36).substr(2,9)),Et.annotations||(Et.annotations=[]),Et.name||(Et.name=`Layer ${Et.id}`),Et));u.value=ze,console.log("Set annotations with validated structure:",ze)},D=_e=>{if(!_e&&_e!==0){console.error("setActiveAnnotationLayer called with invalid layerId:",_e);return}l.value=_e,u.value.forEach(Et=>Et.selected=!1);const ze=findIndex(propEq("id",_e),u.value);ze>=0?(u.value[ze].selected=!0,console.log("Successfully set active layer:",u.value[ze])):console.error("Layer with ID not found:",_e,"Available layers:",u.value)},j=_e=>{if(u.value.forEach(ze=>{var Et;return(Et=ze.annotations)==null?void 0:Et.forEach(Cn=>Cn.selected=!1)}),_e.id){const ze=findIndex(propEq("id",_e.layer_id),u.value);if(ze>=0){const Et=findIndex(propEq("id",_e.id),u.value[ze].annotations);Et>=0&&(u.value[ze].annotations[Et].selected=!0)}}v.value=_e},z=_e=>{d.value=_e},T=_e=>{if(!_e.id&&_e.id!==0){console.error("Cannot create layer without ID:",_e);return}const ze={id:_e.id,name:_e.name||`Layer ${_e.id}`,description:_e.description||"",visible:_e.visible!==void 0?_e.visible:!0,selected:_e.selected||!1,annotations:_e.annotations||[],color:_e.color,hexColor:_e.hexColor,bkColor:_e.bkColor,selColor:_e.selColor,userId:_e.userId,..._e};u.value.push(ze),console.log("Created layer with validated structure:",ze)},L=_e=>{const ze=findIndex(propEq("id",_e.id),u.value);if(ze>=0){const Et=Object.assign(u.value[ze],_e);u.value[ze]=Et}},ie=_e=>{const ze=findIndex(propEq("id",_e.id),u.value);ze>=0&&u.value.splice(ze,1)},x=_e=>{const ze=findIndex(propEq("id",_e.layer_id),u.value);ze>=0&&(u.value[ze].annotations||(u.value[ze].annotations=[]),u.value[ze].annotations.push(_e),j(_e))},V=_e=>{const ze=findIndex(propEq("id",_e.layer_id),u.value);if(ze>=0){const Et=u.value[ze].annotations,Cn=findIndex(propEq("id",_e.id),Et);Cn>=0&&(Et[Cn]=_e)}},le=_e=>{const ze=findIndex(propEq("id",_e.layer_id),u.value);if(ze>=0){const Et=u.value[ze].annotations,Cn=findIndex(propEq("id",_e.id),Et);Cn>=0&&Et.splice(Cn,1)}},Y=(_e,ze,Et)=>{const Cn=t.value.find(kn=>kn.id===_e);Cn&&(Cn[ze]=Et)};return{viewerChannels:t,viewerMontageScheme:n,customMontageMap:r,workspaceMontages:a,viewerErrors:s,needsRerender:o,viewerAnnotations:u,activeAnnotationLayer:l,activeAnnotation:v,activeViewer:i,viewerActiveTool:d,config:e,getMontageMessageByName:c,viewerSelectedChannels:p,getViewerActiveLayer:h,getAnnotationById:m,setChannels:b,setViewerMontageScheme:g,setCustomMontageMap:w,setWorkspaceMontages:k,setViewerErrors:A,setAnnotations:O,setActiveAnnotationLayer:D,setActiveAnnotation:j,setActiveTool:z,createLayer:T,updateLayer:L,deleteLayer:ie,createAnnotation:x,updateAnnotation:V,deleteAnnotation:le,updateChannelProperty:Y,updateChannelVisibility:(_e,ze)=>{Y(_e,"visible",ze)},updateChannelSelection:(_e,ze)=>{Y(_e,"selected",ze)},updateChannelFilter:(_e,ze)=>{Y(_e,"filter",ze)},validateAnnotationLayers:y,resetViewer:()=>{t.value=[],n.value="NOT_MONTAGED",r.value={},a.value=[],s.value=null,u.value=[],l.value={},v.value={},d.value="POINTER",i.value={}},triggerRerender:_e=>{$({timestamp:Date.now(),cause:_e})},resetRerenderTrigger:()=>{o.value=null},isTSFileProcessed:F,fetchAndSetActiveViewer:M,setActiveViewer:_}});function useHandleLogout(e){if(useRoute().name==="docs-login")return;defaultTo(!1,prop("shouldShowToast",e));const n=defaultTo(!1,prop("shouldRedirect",e));this.clearState(),n&&this.$route.fullPath}const _isString=e=>Object.prototype.toString.call(e)==="[object String]",_trimValues=e=>{Object.keys(e).forEach(t=>{_isString(e[t])&&(e[t]=e[t].trim())})};function useSendXhr(e,t){if(!e)return Promise.reject({status:400,message:"Url is missing!"});const n=propOr("GET","method",t),r=propOr({},"header",t),a=Object.assign({},{"Content-type":"application/json"},r),s=prop("body",t);let o={headers:a,method:n};if(s){typeof s=="object"&&_trimValues(s);const i=JSON.stringify(s);o=Object.assign({},o,{body:i})}return fetch(e,o).then(i=>i.status>=400?Promise.reject(i):i.json().catch(()=>i))}function useHandleXhrError(e){const t=prop("status",e);let n;if(t===void 0){console.log(e);return}else n=e.status;if(n===400&&e.body)e.body.getReader().read().then(({done:r,value:a})=>{const s=a instanceof Uint8Array?String.fromCharCode.apply(null,a):a;compose(defaultTo(s),tryCatch(compose(prop("message"),JSON.parse),(o,i)=>i))(s)});else if(n===401)return useHandleLogout()}function useTsAnnotation(){const e=useViewerStore(),{viewerChannels:t,viewerAnnotations:n}=pinia.storeToRefs(e),r=u=>u.id||"",a=u=>{u.sort(function(v,d){return v.start<d.start?-1:v.start>d.start?1:0})};return{viewerChannels:t,viewerAnnotations:n,addAnnotation:async(u=null)=>{const l=u||activeAnnotation.value;if(console.log("🔧 useTsAnnotation: addAnnotation called with:",l),!l||!l.layer_id)throw new TypeError("Missing annotation data or layer_id",l);if(l.id)throw new TypeError("Trying to create an annotation that already exists",l.id);let v=l.start,d=l.duration||l.end-l.start;const f=l.label,c=l.description,p=l.layer_id;if(!f)throw new Error("Annotation label is required");if(v==null)throw new Error("Annotation start time is required");d<0&&(d=-d,v=v-d);let h=[];if(console.log("🔧 useTsAnnotation: Processing channelIds...",{hasChannelIds:l.channelIds&&Array.isArray(l.channelIds),allChannels:l.allChannels,providedChannelIds:l.channelIds,availableChannels:t.value.length}),l.allChannels){console.log("🔧 useTsAnnotation: allChannels=true, adding all visible channels");const b=e.activeViewer.value.channels;for(let g=0;g<b.length;g++){const k=b[g].content.id;h.push(k),console.log("🔧 useTsAnnotation: Added channel ID:",k)}}else if(l.channelIds&&Array.isArray(l.channelIds)&&l.channelIds.length>0)h=l.channelIds,console.log("🔧 useTsAnnotation: Using provided channelIds:",h);else{console.log("🔧 useTsAnnotation: Computing from selected channels");for(let b=0;b<t.value.length;b++){const g=t.value[b];if(g.selected&&g.visible){const w=r(g);h.push(w),console.log("🔧 useTsAnnotation: Added selected channel ID:",w)}}}console.log("🔧 useTsAnnotation: Final channelIds:",h);const y={label:f,name:f,description:c||"",start:Math.floor(v),end:Math.floor(v+d),channelIds:h};console.log("🔧 useTsAnnotation: API payload:",y);const m=e.activeViewer.value.content.id,_=`${e.config.apiUrl}/timeseries/${m}/layers/${p}/annotations`;console.log("🔧 useTsAnnotation: API URL:",_);try{const b=await useToken(),g=await fetch(`${_}?api_key=${b}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(y)});if(!g.ok){const $=await g.text();throw new Error(`HTTP ${g.status}: ${$}`)}const w=await g.json();console.log("🔧 useTsAnnotation: API success:",w);const k={name:"",id:w.id,label:w.label,description:w.description,start:w.start,duration:w.end-w.start,end:w.end,cStart:null,cEnd:null,selected:!0,channelIds:w.channelIds||h,allChannels:h.length===0||h.length>=t.value.length,layer_id:p,userId:w.userId};w.linkedPackage&&(k.linkedPackage=w.linkedPackage);let A=0;for(let $=0;$<n.value.length;$++)if(n.value[$].id===p){A=$;break}return e.createAnnotation(k),n.value[A]&&n.value[A].annotations&&a(n.value[A].annotations),k}catch(b){throw console.error("🔧 useTsAnnotation: Error creating annotation:",b),useHandleXhrError(b),b}},updateAnnotation:async(u=null)=>{const l=u||activeAnnotation.value;if(console.log("🔧 useTsAnnotation: updateAnnotation called with:",l),!l.id)throw new TypeError("Trying to update an annotation that doesn't exist on server",l.id);if(!l.layer_id)throw new TypeError("Missing layer_id for annotation update",l);let v=l.start,d=l.duration||l.end-l.start;d<0&&(d=-d,v=v-d);const f={label:l.label,description:l.description||"",start:Math.floor(v),end:Math.floor(v+d),channelIds:l.channelIds||[]};console.log("🔧 useTsAnnotation: Update API payload:",f);const c=e.activeViewer.value.content.id,p=`${e.config.apiUrl}/timeseries/${c}/layers/${l.layer_id}/annotations/${l.id}`;console.log("🔧 useTsAnnotation: Update API URL:",p);try{const h=await useToken(),y=await fetch(`${p}?api_key=${h}`,{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(f)});if(!y.ok){const b=await y.text();throw new Error(`HTTP ${y.status}: ${b}`)}const m=await y.json();console.log("🔧 useTsAnnotation: Update API success:",m);const _={...l,...m,duration:m.end-m.start};return e.updateAnnotation(_),m}catch(h){throw console.error("🔧 useTsAnnotation: Error updating annotation:",h),useHandleXhrError(h),h}},removeAnnotation:async u=>{if(!u||!u.id)throw new TypeError("Invalid annotation for deletion",u);let l="";if(u.layer?l=u.layer.id:l=u.layer_id,!l)throw new TypeError("Missing layer_id for annotation deletion",u);const v=e.activeViewer.value.content.id,d=`${e.config.apiUrl}/timeseries/${v}/layers/${l}/annotations/${u.id}`;console.log("🔧 useTsAnnotation: Delete API URL:",d);try{const f=await useToken(),c=await fetch(`${d}?api_key=${f}`,{method:"DELETE",headers:{Accept:"application/json"}});if(!c.ok){const p=await c.text();throw new Error(`HTTP ${c.status}: ${p}`)}return console.log("🔧 useTsAnnotation: Delete API success"),e.deleteAnnotation(u),!0}catch(f){throw console.error("🔧 useTsAnnotation: Error deleting annotation:",f),useHandleXhrError(f),f}},sortAnns:a,getChannelId:r}}const _export_sfc$1=(e,t)=>{const n=e.__vccOpts||e;for(const[r,a]of t)n[r]=a;return n},_hoisted_1$m={id:"channelCanvas"},_hoisted_2$a=["data-id"],_hoisted_3$9=["hidden"],_hoisted_4$6=["hidden"],_sfc_main$W={__name:"TSViewer",props:{pkg:{type:Object,default:()=>{}},isPreview:{type:Boolean,default:!1},sidePanelOpen:{type:Boolean,default:!1}},setup(e,{expose:t}){const n=vue.defineAsyncComponent(()=>Promise.resolve().then(()=>TSScrubber$1)),r=vue.defineAsyncComponent(()=>Promise.resolve().then(()=>TSViewerCanvas$1)),a=vue.defineAsyncComponent(()=>Promise.resolve().then(()=>TSViewerToolbar$1)),s=vue.defineAsyncComponent(()=>Promise.resolve().then(()=>TSFilterModal$1)),o=vue.defineAsyncComponent(()=>Promise.resolve().then(()=>TSAnnotationModal$1)),i=vue.defineAsyncComponent(()=>Promise.resolve().then(()=>TsAnnotationDeleteDialog$1)),u=vue.defineAsyncComponent(()=>Promise.resolve().then(()=>TSViewerLayerWindow$1)),l={TIMEUNIT:"microSeconds",XOFFSET:0,XGRIDSPACING:1e6,NRPXPERLABEL:150,USEREALTIME:!0,DEFAULTDPI:96,ANNOTATIONLABELHEIGHT:20,ROUNDDATAPIXELS:!1,MINMAXPOLYGON:!0,PAGESIZEDIVIDER:.5,PREFETCHPAGES:5,LIMITANNFETCH:500,USEMEDIAN:!1,CURSOROFFSET:5,SEGMENTSPAN:12096e8,MAXRECURSION:20,MAXDURATION:6e8,INITDURATION:15e6},v=e,d=useViewerStore(),{viewerChannels:f,needsRerender:c}=pinia.storeToRefs(d),{addAnnotation:p,updateAnnotation:h,removeAnnotation:y}=useTsAnnotation(),m=vue.ref(null),_=vue.ref(null),b=vue.ref(null),g=vue.ref(null),w=vue.ref(null),k=vue.ref(null),A=vue.ref(null),$=vue.ref(null),M=vue.ref(0),F=vue.ref(0),O=vue.ref(0),D=vue.ref(0),j=vue.ref(0),z=vue.ref(0),T=vue.ref(0),L=vue.ref(1),ie=vue.ref(1/10),x=vue.ref(!1),V=vue.ref(!1),le=vue.ref(null),Y=vue.ref(!1),re=vue.ref(!1),he=vue.computed(()=>d.activeViewer),Ce=vue.computed(()=>f.value.map(ue=>({...ue,selected:!!ue.selected}))),$e=vue.computed(()=>Ce.value.filter(ue=>ue.visible)),Ne=vue.computed(()=>{let ue=!1;return z.value/Pt.value<30&&(ue=!0),ue}),Pt=vue.computed(()=>$e.value.length),_e=async()=>{if(console.log("onresize..."),!m.value)return;const ue=document.getElementById("ts_viewer");if(!ue)return;const Fe=window.getComputedStyle(ue,null),Ve=parseInt(Fe.getPropertyValue("height")),bn=v.isPreview?0:100;M.value=Ve-bn,await vue.nextTick(),F.value=m.value.offsetWidth;const Ln=b.value;Ln&&(T.value=Ln.clientWidth,j.value=F.value-Ln.clientWidth-16,z.value=M.value-40)};vue.watch(()=>he.value,async(ue,Fe)=>{var Ve,bn,Ln;(Ve=_.value)!=null&&Ve.resetComponentState&&_.value.resetComponentState(),ue&&ue.channels&&ue.channels.length>0&&At(),On(),await vue.nextTick(),(bn=_.value)!=null&&bn.initSegmentSpans&&_.value.initSegmentSpans(),(Ln=_.value)!=null&&Ln.getAnnotations&&_.value.getAnnotations()},{immediate:!1,deep:!0}),vue.watch(Pt,(ue,Fe)=>{Fe!==void 0&&ue!==Fe&&(console.log(`Number of visible channels changed from ${Fe} to ${ue}`),setTimeout(()=>{var Ve;_e(),(Ve=g.value)!=null&&Ve.renderAll&&g.value.renderAll()},20))});const ze=ue=>{store.dispatch("viewerModule/setActiveAnnotation",ue).then(()=>{g.value.renderAnnotationCanvas(),x.value=!0})};vue.watch(c,ue=>{ue&&(console.log(`TSViewer: Re-rendering due to: ${ue.cause} (${ue.timestamp})`),vue.nextTick(()=>{var Fe;ue.cause==="channel-visibility"?setTimeout(()=>{var Ve;_e(),(Ve=g.value)!=null&&Ve.renderAll&&g.value.renderAll()},10):(Fe=g.value)!=null&&Fe.renderAll&&g.value.renderAll()}),d.resetRerenderTrigger(null))},{deep:!0});const Et=ue=>{ze(ue)},Cn=async ue=>{if(console.log("📍 TSViewer: onCreateUpdateAnnotation received:",ue),!ue||Object.keys(ue).length===0){console.error("🚨 TSViewer: Received empty annotation!");return}if(!ue.layer_id){console.error("🚨 TSViewer: annotation.layer_id is missing!",ue);return}x.value=!1;try{ue.id?(console.log("📍 TSViewer: Updating annotation via composable"),await h(ue),kn()):(console.log("📍 TSViewer: Creating annotation via composable"),await p(ue),xe()),console.log("📍 TSViewer: Annotation operation completed successfully")}catch(Fe){console.error("📍 TSViewer: Error creating/updating annotation:",Fe),x.value=!0}},kn=()=>{g.value.renderAnnotationCanvas()},In=ue=>{le.value=ue,Y.value=!0},Dn=async ue=>{Y.value=!1;try{await y(ue),Mn(),console.log("📍 TSViewer: Annotation deleted successfully")}catch(Fe){console.error("📍 TSViewer: Error deleting annotation:",Fe)}},Mn=()=>{g.value.renderAnnotationCanvas()},Ue=(ue,Fe,Ve,bn,Ln,jn)=>{if(console.log("📍 TSViewer: onAddAnnotation called with:",{startTime:ue,duration:Fe,allChannels:Ve,label:bn,description:Ln,layer:jn}),!jn||!jn.id){console.error("Invalid layer provided to onAddAnnotation:",jn);return}const Hn=d.viewerSelectedChannels||[],Gn=Ve?[]:Hn.map(Zn=>Zn.id),Jn={id:null,label:bn||"Event",description:Ln||"",start:Math.floor(ue),end:Math.floor(ue+Fe),duration:Math.floor(Fe),channelIds:Gn,allChannels:Ve,layer_id:jn.id,selected:!0,userId:null};console.log("📍 TSViewer: Created annotation object:",Jn),d.setActiveAnnotation(Jn),console.log("📍 TSViewer: Store now contains:",d.activeAnnotation),x.value=!0,console.log("📍 TSViewer: Modal opened with annotation data")},xe=()=>{g.value.renderAnnotationCanvas()},Dt=ue=>{g.value.createAnnotationLayer(ue)},kt=()=>{V.value=!1},_n=()=>{g.value.resetFocusedAnnotation(),g.value.renderAnnotationCanvas(),x.value=!1},Sn=()=>{re.value=!1},Tn=ue=>{ue.stopPropagation(),ue.preventDefault();const Fe=ue.detail.sourceEvent.metaKey;$n({channelId:ue.currentTarget.dataset.id,append:Fe}),g.value.renderAll()},An=()=>{O.value=g.value.getNextAnnotation()},qe=()=>{O.value=g.value.getPreviousAnnotation()},vn=ue=>{de(ue*1e6)},Nn=()=>{L.value=L.value*1.25},Pn=()=>{L.value=L.value*.8},xn=()=>{_.value.getAnnotations()},Bn=()=>{},Rn=()=>{console.log("Page forward triggered from toolbar");const ue=Math.max(O.value-3/4*D.value,A.value);pe(ue),vue.nextTick(()=>{var Fe;(Fe=g.value)==null||Fe.renderAll()})},qn=()=>{console.log("Page forward triggered from toolbar");const ue=Math.min(O.value+3/4*D.value,$.value-D.value);console.log(`Moving from ${O.value} to ${ue}`),pe(ue),vue.nextTick(()=>{var Fe,Ve;(Fe=g.value)!=null&&Fe.invalidate&&g.value.invalidate(),(Ve=g.value)!=null&&Ve.renderAll&&g.value.renderAll()})},Fn=ue=>{let Fe=g.value.rsPeriod;pe(ue.annotation.start-(ie.value*j.value-l.CURSOROFFSET)*Fe),vue.nextTick(()=>{var Ve;(Ve=g.value)==null||Ve.renderAll()})},$n=ue=>{const Fe=f.value.map(Ve=>{const bn=Ve.selected;return ue.append===!1&&(Ve.selected=!1),ue.channelId===Ve.id&&(Ve.selected=!bn),Ve});d.setChannels(Fe)},oe=(ue,Fe)=>{const Ve=f.value.map(bn=>(Fe===!1&&(bn.selected=!1),bn.id in ue&&(bn.selected=!0),bn));d.setChannels(Ve)},pe=ue=>{O.value=ue},S=ue=>{ie.value=ue},ae=ue=>{L.value=ue},de=ue=>{ue>l.MAXDURATION?D.value=l.MAXDURATION:D.value=ue},Oe=(ue,Fe,Ve)=>(l.DEFAULTDPI*window.devicePixelRatio/(Fe*Ve)/25.4).toFixed(1)+" "+ue.unit+"/mm",At=()=>{var Fe;const ue=(Fe=he.value)==null?void 0:Fe.channels;if(console.log("🔄 initTimeRange called with channels:",(ue==null?void 0:ue.length)||0),ue&&ue.length>0){A.value=ue[0].start,$.value=ue[0].end;for(let bn=1;bn<ue.length;bn++)ue[bn].start<A.value&&(A.value=ue[bn].start),ue[bn].end>$.value&&($.value=ue[bn].end);const Ve=O.value;O.value=A.value,console.log("📅 Time range initialized:",{ts_start:A.value,ts_end:$.value,oldStart:Ve,newStart:O.value,duration:D.value,startDate:new Date(A.value/1e3).toISOString(),endDate:new Date($.value/1e3).toISOString()})}else console.warn("⚠️ initTimeRange: No channels found in activeViewer")},En=()=>{At()},wn=ue=>{V.value=!0},hn=ue=>{const Fe=propOr([],"channels",ue),Ve=propOr("","filter",ue),bn=w.value;bn.onChannels=Fe,isEmpty$1(Ve)?(bn.input0=NaN,bn.input1=NaN,bn.selectedFilter=null,bn.selectedNotch=null):(bn.input0=Ve.input0,bn.input1=Ve.input1),re.value=!0},Lt=ue=>{g.value.setFilters(ue)},On=()=>{var ue,Fe;(ue=g.value)==null||ue.initViewerCanvas(),(Fe=g.value)==null||Fe.renderAll()};return vue.onMounted(()=>{En();const ue=document.getElementById("ts_viewer");if(!ue){console.warn("ts_viewer element not found");return}var Fe=window.getComputedStyle(ue,null);const Ve=parseInt(Fe.getPropertyValue("height")),bn=v.isPreview?0:100;M.value=Ve-bn,m.value&&(F.value=m.value.offsetWidth),window.addEventListener("resize",_e);const Ln=b.value;Ln&&(T.value=Ln.clientWidth,j.value=F.value-Ln.clientWidth-5-10,z.value=M.value-88),D.value=l.INITDURATION,On()}),vue.onBeforeUnmount(()=>{window.removeEventListener("resize",_e)}),t({openEditAnnotationDialog:ze,confirmDeleteAnnotation:In,selectAnnotation:Fn,selectChannel:$n,selectChannels:oe,openLayerWindow:wn,openFilterWindow:hn,setTimeseriesFilters:Lt}),(ue,Fe)=>(vue.openBlock(),vue.createElementBlock("div",{id:"ts_viewer",ref_key:"ts_viewer",ref:m,class:vue.normalizeClass([e.isPreview?"timeseries-viewer preview":"timeseries-viewer"])},[vue.createVNode(vue.unref(n),{ref_key:"scrubber",ref:_,ts_start:A.value,ts_end:$.value,"c-width":j.value,"label-width":T.value,"cursor-loc":ie.value,start:O.value,duration:D.value,constants:l,"active-viewer":he.value,onSetStart:pe},null,8,["ts_start","ts_end","c-width","label-width","cursor-loc","start","duration","active-viewer"]),vue.createElementVNode("div",_hoisted_1$m,[vue.createElementVNode("div",{id:"channelLabels",ref_key:"channelLabels",ref:b},[(vue.openBlock(!0),vue.createElementBlock(vue.Fragment,null,vue.renderList($e.value,Ve=>(vue.openBlock(),vue.createElementBlock("div",{key:Ve.displayName,class:"chLabelWrap","data-id":Ve.id,onTap:Tn},[vue.createElementVNode("div",{class:vue.normalizeClass([Ve.selected?"labelDiv selected":"labelDiv"])},vue.toDisplayString(Ve.displayName),3),vue.createElementVNode("div",{class:vue.normalizeClass(["chLabelIndWrap",[Ve.selected?"selected":""]]),hidden:Ne.value},[vue.createElementVNode("div",{class:"chLabelInd",hidden:Ne.value},vue.toDisplayString(Oe(Ve,L.value,Ve.rowScale)),9,_hoisted_4$6)],10,_hoisted_3$9)],40,_hoisted_2$a))),128))],512),vue.createVNode(vue.unref(r),{ref_key:"viewerCanvas",ref:g,window_height:M.value,window_width:F.value,duration:D.value,start:O.value,"c-width":j.value,"c-height":z.value,constants:l,"ts-start":A.value,"ts-end":$.value,"cursor-loc":ie.value,"global-zoom-mult":L.value,"active-viewer":he.value,onSetStart:pe,onSetCursor:S,onSetGlobalZoom:ae,onSetDuration:de,onChannelsInitialized:Bn,onAnnLayersInitialized:xn,onCloseAnnotationLayerWindow:kt,onAddAnnotation:Ue,onUpdateAnnotation:Et},null,8,["window_height","window_width","duration","start","c-width","c-height","ts-start","ts-end","cursor-loc","global-zoom-mult","active-viewer"])]),e.isPreview?vue.createCommentVNode("",!0):(vue.openBlock(),vue.createBlock(vue.unref(a),{key:0,constants:l,duration:D.value,start:O.value,onPageBack:Rn,onPageForward:qn,onIncrementZoom:Nn,onDecrementZoom:Pn,onUpdateDuration:vn,onNextAnnotation:An,onPreviousAnnotation:qe,onSetStart:pe},null,8,["duration","start"])),vue.createVNode(vue.unref(s),{ref_key:"filterWindow",ref:w,visible:re.value,"onUpdate:visible":Fe[0]||(Fe[0]=Ve=>re.value=Ve),onCloseWindow:Sn},null,8,["visible"]),vue.createVNode(vue.unref(o),{ref_key:"annotationModal",ref:k,visible:x.value,"onUpdate:visible":Fe[1]||(Fe[1]=Ve=>x.value=Ve),onCloseWindow:_n,onCreateUpdateAnnotation:Cn},null,8,["visible"]),vue.createVNode(vue.unref(i),{visible:Y.value,"delete-annotation":le.value,"onUpdate:visible":Fe[2]||(Fe[2]=Ve=>Y.value=Ve),onDelete:Dn},null,8,["visible","delete-annotation"]),vue.createVNode(vue.unref(u),{visible:V.value,onCloseWindow:kt,onCreateLayer:Dt},null,8,["visible"])],2))}},TSViewer=_export_sfc$1(_sfc_main$W,[["__scopeId","data-v-d5eda6cd"]]),index={install(e){e.component("TSViewer",TSViewer)}},_hoisted_1$l={class:"timeseries-scrubber"},_hoisted_2$9={class:"dateWrap"},_hoisted_3$8={class:"noselect"},_hoisted_4$5={id:"scrubber",noselect:""},_hoisted_5$4=["width","height"],_hoisted_6$4=["width","height"],_hoisted_7$3=["width","height"],_sfc_main$V={__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(e,{expose:t,emit:n}){const r=e,a=n,s=useViewerStore(),o=vue.ref(null),i=vue.ref(null),u=vue.ref(null),l=vue.ref(null),v=vue.ref(1),d=vue.ref(28),f=vue.ref(30),c=vue.ref(!1),p=vue.ref(""),h=vue.ref("point"),y=vue.ref(null),m=vue.ref([]),_=vue.ref([]),b=vue.ref([]),g=vue.ref(!1),w=vue.ref(0),k=vue.ref(0),A=vue.ref(0),$=vue.ref(0),M=vue.computed(()=>Y(r.ts_start)),F=vue.computed(()=>Y(r.ts_end)),O=vue.computed(()=>{if(p.value!=="")return p.value;if(r.start>0){const Ue=new Date(r.start/1e3).toUTCString();return Ue.substring(0,Ue.length-3)}return""}),D=vue.computed(()=>({width:r.labelWidth+r.cWidth-8+5+"px",height:"28px"})),j=vue.computed(()=>({width:r.labelWidth+r.cWidth-8+5+"px",height:"30px"})),z=vue.computed(()=>r.cWidth+r.labelWidth-8+5),T=vue.computed(()=>Math.floor((r.ts_end-r.ts_start)/r.cWidth));vue.watch(()=>r.start,()=>{Et()}),vue.watch(()=>r.duration,()=>{Et()}),vue.watch(()=>r.cWidth,()=>{Et()}),vue.watch(()=>r.activeViewer,(Ue,xe)=>{var Dt;Ue&&Ue!==xe&&(console.log("TSScrubber: ActiveViewer changed, resetting component state"),g.value=!0,L(),(Dt=Ue.content)!=null&&Dt.id?vue.nextTick(()=>{ze(),g.value=!1}):g.value=!1)},{deep:!0}),vue.watch(()=>s.viewerChannels,(Ue,xe)=>{var Dt,kt;Ue&&Ue.length>0&&!g.value&&(!xe||Ue.length!==xe.length||((Dt=Ue[0])==null?void 0:Dt.id)!==((kt=xe[0])==null?void 0:kt.id))&&(console.log("TSScrubber: Viewer channels changed, re-initializing segments"),ie(),vue.nextTick(()=>{Pt()}))},{deep:!0}),vue.watch(()=>s.viewerAnnotations,(Ue,xe)=>{var Dt;Ue&&Ue!==xe&&!g.value?(console.log("TSScrubber: Viewer annotations changed independently, re-fetching annotations"),vue.nextTick(()=>{ze()})):Ue&&Ue.length>0&&!xe&&((Dt=r.activeViewer)!=null&&Dt.content.id)&&(console.log("TSScrubber: Annotation layers now available, fetching annotations"),vue.nextTick(()=>{ze()}))},{deep:!0});const L=()=>{console.log("TSScrubber: Resetting component state"),m.value=[],ie(),c.value=!1,p.value="",h.value="point",x()},ie=()=>{console.log("TSScrubber: Resetting segment state"),b.value=new Array(5e3),b.value=b.value.fill(0,0,4999),_.value=[]},x=()=>{vue.nextTick(()=>{[i.value,u.value,l.value].forEach(xe=>{if(xe){const Dt=xe.getContext("2d");Dt&&Dt.clearRect(0,0,xe.width,xe.height)}})})},V=(Ue,xe,Dt)=>xe*(Ue+Dt),le=()=>{const Ue=l.value.getContext("2d"),xe=window.devicePixelRatio||1,Dt=Ue.webkitBackingStorePixelRatio||Ue.mozBackingStorePixelRatio||Ue.msBackingStorePixelRatio||Ue.oBackingStorePixelRatio||Ue.backingStorePixelRatio||1;return xe/Dt},Y=Ue=>{if(Ue>0)return Ue=Ue/1e3,Ue=new Date(Ue),("0"+Ue.getUTCHours()).slice(-2)+":"+("0"+Ue.getUTCMinutes()).slice(-2)+":"+("0"+Ue.getUTCSeconds()).slice(-2)},re=Ue=>{if(c.value){const Dt=(Ue.clientX-w.value)/r.cWidth*(r.ts_end-r.ts_start),kt=k.value+Dt;a("setStart",kt);const _n=new Date((Dt+r.ts_start)/1e3);p.value=_n.toUTCString()}else{const xe=l.value.getBoundingClientRect(),Dt=Ue.clientX-xe.left,kt=A.value+$.value,_n=h.value;Dt>A.value-10&&Dt<kt+10?(h.value="drag",l.value.setAttribute("dragme",!0),l.value.removeAttribute("resizeme")):(h.value="point",l.value.removeAttribute("dragme"),l.value.removeAttribute("resizeme"));const Tn=Dt/r.cWidth*(r.ts_end-r.ts_start)+r.ts_start,An=new Date(Tn/1e3).toUTCString();p.value=An.substring(0,An.length-3),_n!==h.value&&Et()}},he=()=>{c.value=!1},Ce=Ue=>{c.value=!0;const xe=l.value.getBoundingClientRect(),Dt=Ue.clientX-xe.left;w.value=Ue.clientX;const kt=Dt/z.value*(r.ts_end-r.ts_start);a("setStart",kt+r.ts_start),k.value=kt+r.ts_start},$e=()=>{c.value=!1},Ne=()=>{p.value=""},Pt=()=>{var Dt;if(!s.viewerChannels||s.viewerChannels.length===0){console.warn("TSScrubber: Cannot init segment spans - no viewer channels available");return}if(!r.ts_start||!r.ts_end){console.warn("TSScrubber: Cannot init segment spans - invalid time range");return}if(!((Dt=s.config)!=null&&Dt.timeSeriesApi)){console.warn("TSScrubber: Cannot init segment spans - no timeSeriesApi configured");return}console.log(`TSScrubber: Initializing segment spans for ${s.viewerChannels.length} channels`),ie();const Ue=Math.min(r.constants.SEGMENTSPAN,r.ts_end-r.ts_start),xe=s.viewerChannels;for(let kt=0;kt<xe.length;kt++)_e(xe[kt].id,kt,r.ts_start,r.ts_start+Ue,0)},_e=async(Ue,xe,Dt,kt,_n)=>{var Tn;const Sn=r.constants.MAXRECURSION;if(!((Tn=s.config)!=null&&Tn.timeSeriesApi)){console.warn("TSScrubber: Cannot request segment span - no timeSeriesApi configured");return}if(!Ue){console.warn("TSScrubber: Cannot request segment span - no channel ID provided");return}try{const An=await useToken(),qe=`${s.config.timeSeriesApi}/ts/retrieve/segments?session=${An}&channel=${Ue}&start=${Dt}&end=${kt}`;console.log(`TSScrubber: Fetching segments for channel ${Ue} (${xe})`);const vn=await useSendXhr(qe);if(!s.viewerChannels[xe]||s.viewerChannels[xe].id!==Ue){console.warn("TSScrubber: Channel mismatch detected, ignoring segment response (likely package switched)");return}let Nn=new Array(vn.length*2),Pn=0;for(let oe=0;oe<vn.length;oe++){Nn[Pn]=vn[oe][0],Nn[Pn+1]=vn[oe][1],Pn=Pn+2;const pe=Math.floor((vn[oe][0]-r.ts_start)/(r.ts_end-r.ts_start)*5e3),S=Math.ceil((vn[oe][1]-r.ts_start)/(r.ts_end-r.ts_start)*5e3);b.value.fill(1,pe,S)}let xn=0,Bn=!1,Rn=0;for(_.value=[];xn<b.value.length-1;){if(!b.value[xn]&&!Bn){xn++;continue}else b.value[xn]?Bn||(Rn=xn,Bn=!0):(_.value=_.value.concat([Rn,xn]),Bn=!1);xn++}Bn&&(_.value=_.value.concat([Rn,xn])),_.value=_.value.concat([5e3]);let qn=Nn[0],Fn=s.viewerChannels[xe];if(!Fn||Fn.id!==Ue){console.warn("TSScrubber: Channel configuration mismatch, skipping update");return}qn<Fn.dataSegments[Fn.dataSegments.length-1]&&(Nn.shift(),Nn.shift()),Fn.dataSegments=Fn.dataSegments.concat(Nn.sort((oe,pe)=>oe-pe)),s.updateChannelProperty(Fn.id,"dataSegments",Fn.dataSegments);let $n=kt-Dt;Dt+$n<r.ts_end&&_n<Sn?_e(Ue,xe,kt,kt+$n,_n+1):kn()}catch(An){console.error(`TSScrubber: Error fetching segments for channel ${Ue}:`,An),useHandleXhrError(An)}},ze=async()=>{var xe,Dt,kt;const Ue=(xe=r.activeViewer)==null?void 0:xe.content.id;if(!Ue){console.warn("TSScrubber: Cannot get annotations - no active viewer ID"),m.value=[];return}if(!((Dt=s.config)!=null&&Dt.apiUrl)){console.warn("TSScrubber: Cannot get annotations - no API URL configured"),m.value=[];return}if(!s.viewerAnnotations||s.viewerAnnotations.length===0){console.log("TSScrubber: No annotation layers available, skipping annotation fetch"),m.value=[],Et();return}try{const _n=await useToken(),Sn=map(Nn=>Nn.id,s.viewerAnnotations),Tn=r.ts_end;let qe=`${s.config.apiUrl}/timeseries/${Ue}/annotations/window`+`?api_key=${_n}&aggregation=count&start=${r.ts_start}&end=${r.ts_end}&period=${T.value}&mergePeriods=true`;for(let Nn in Sn)qe=qe+`&layerIds=${Sn[Nn]}`;console.log(`TSScrubber: Fetching annotations for viewer ${Ue}`);const vn=await useSendXhr(qe);((kt=r.activeViewer)==null?void 0:kt.content.id)===Ue?(m.value=vn,Et()):console.log("TSScrubber: Ignoring annotation response - viewer changed during fetch")}catch(_n){console.error("TSScrubber: Error fetching annotations:",_n),m.value=[],useHandleXhrError(_n),Et()}},Et=()=>{Cn(),In(),kn()},Cn=()=>{vue.nextTick(()=>{const Ue=l.value;if(!Ue){console.warn("iCanvas ref is missing, skipping render");return}const xe=Ue.getContext("2d");if(!xe){console.warn("2D context is not available");return}xe.setTransform(v.value,0,0,v.value,0,0),xe.clearRect(0,0,r.cWidth,f.value),A.value=(r.start-r.ts_start)/(r.ts_end-r.ts_start)*r.cWidth+.5|0,$.value=r.duration/(r.ts_end-r.ts_start)*r.cWidth+.5|0,xe.fillStyle="rgb(80,80,80)",xe.strokeStyle="rgb(80,80,80)",xe.strokeRect(A.value+.5,.5,$.value,f.value-1),xe.fillRect(A.value-2,f.value/2-5|0,2,10),xe.fillRect(A.value+$.value+1,f.value/2-5|0,2,10);const Dt=A.value+r.cursorLoc*$.value;Dt>A.value+.5&&(xe.strokeStyle="red",xe.beginPath(),xe.moveTo(Dt,0),xe.lineTo(Dt,f.value-1),xe.stroke())})},kn=()=>{vue.nextTick(()=>{const Ue=i.value;if(!Ue){console.warn("segmentsCanvas ref is missing, skipping renderSegments");return}const xe=Ue.getContext("2d");if(!xe){console.warn("Unable to get 2D context for segmentsCanvas, skipping renderSegments");return}xe.setTransform(v.value,0,0,v.value,0,0),xe.fillStyle=xe.createPattern(y.value,"repeat"),xe.clearRect(0,0,r.cWidth,f.value);for(let Dt=1;Dt<_.value.length;Dt+=2){const kt=r.cWidth*_.value[Dt]/5e3,_n=r.cWidth*_.value[Dt+1]/5e3;xe.fillRect(kt,2,_n-kt,f.value-6)}})},In=()=>{const Ue=u.value;if(!Ue){console.warn("annotationCanvas ref is missing, skipping renderTimelimeLine");return}const xe=Ue.getContext("2d");if(!xe){console.warn("Unable to get 2D context for annotationCanvas, skipping renderTimelimeLine");return}xe.setTransform(v.value,0,0,v.value,0,0),xe.clearRect(0,0,r.cWidth,d.value);const Dt=r.ts_start,kt=r.ts_end,_n=m.value;let Sn=0;const Tn=0,An=Math.floor((d.value-2)/Object.keys(_n).length-Tn),qe=s.viewerAnnotations;let vn="rgb(0,0,0)";for(const Nn in _n)if(_n.hasOwnProperty(Nn)){for(let Pn=0;Pn<qe.length;Pn++)if(qe[Pn].id===parseInt(Nn)){Sn=Pn,vn=qe[Pn].color;break}Dn(xe,Dt,kt,Tn,An,_n[Nn],Sn,vn)}},Dn=(Ue,xe,Dt,kt,_n,Sn,Tn,An)=>{vue.nextTick(()=>{Ue.setTransform(v.value,0,0,v.value,0,0),Ue.fillStyle=An;for(let qe=0;qe<Sn.length;qe++)if(Sn[qe].value>0){const vn=(Sn[qe].start-xe)/(Dt-xe)*r.cWidth;let Pn=(Sn[qe].end-xe)/(Dt-xe)*r.cWidth-vn;Pn<1&&(Pn=1);const xn=1+Tn*(_n-1+kt)+Tn;Ue.fillRect(vn,xn,Pn,_n)}})},Mn=()=>{const Ue=document.createElement("canvas"),xe=Ue.getContext("2d",{antialias:!0}),Dt="rgb(220,220,220)",kt=5,_n=kt,Sn=kt,Tn=10;return Ue.width=_n,Ue.height=Sn,xe.fillStyle=Dt,xe.beginPath(),xe.moveTo(0,Sn*(1/Tn)),xe.lineTo(_n*(1/Tn),0),xe.lineTo(0,0),xe.lineTo(0,Sn*(1/Tn)),xe.fill(),xe.beginPath(),xe.moveTo(_n,Sn*(1/Tn)),xe.lineTo(_n*(1/Tn),Sn),xe.lineTo(0,Sn),xe.lineTo(0,Sn*((Tn-1)/Tn)),xe.lineTo(_n*((Tn-1)/Tn),0),xe.lineTo(_n,0),xe.lineTo(_n,Sn*(1/Tn)),xe.fill(),xe.beginPath(),xe.moveTo(_n,Sn*((Tn-1)/Tn)),xe.lineTo(_n*((Tn-1)/Tn),Sn),xe.lineTo(_n,Sn),xe.lineTo(_n,Sn*((Tn-1)/Tn)),xe.fill(),Ue};return vue.onMounted(()=>{b.value=new Array(5e3),b.value=b.value.fill(0,0,4999),v.value=le(),y.value=Mn(),Cn()}),t({getAnnotations:ze,initSegmentSpans:Pt,render:Et,renderViewPort:Cn,renderSegments:kn,renderTimelimeLine:In,resetComponentState:L,resetSegmentState:ie,clearCanvases:x}),(Ue,xe)=>(vue.openBlock(),vue.createElementBlock("div",_hoisted_1$l,[vue.createElementVNode("div",_hoisted_2$9,[vue.createElementVNode("div",null,vue.toDisplayString(M.value),1),vue.createElementVNode("div",null,vue.toDisplayString(O.value),1),vue.createElementVNode("div",null,vue.toDisplayString(F.value),1)]),vue.createElementVNode("div",_hoisted_3$8,[vue.createElementVNode("div",_hoisted_4$5,[vue.createElementVNode("div",{id:"canvasWrap",ref_key:"canvasWrap",ref:o},[vue.createElementVNode("canvas",{id:"segmentsCanvas",class:"canvas",ref_key:"segmentsCanvas",ref:i,width:V(e.cWidth,v.value,0),height:V(f.value-2,v.value,0),style:vue.normalizeStyle(D.value)},null,12,_hoisted_5$4),vue.createElementVNode("canvas",{id:"annotationCanvas",class:"canvas",ref_key:"annotationCanvas",ref:u,width:V(e.cWidth,v.value,0),height:V(f.value-2,v.value,0),style:vue.normalizeStyle(D.value)},null,12,_hoisted_6$4),vue.createElementVNode("canvas",{id:"iCanvas",class:"canvas",ref_key:"iCanvas",ref:l,width:V(e.cWidth,v.value,0),height:V(f.value,v.value,0),onClick:xe[0]||(xe[0]=(...Dt)=>Ue._onTap&&Ue._onTap(...Dt)),onMousemove:re,onMousedown:Ce,onMouseup:he,onMouseenter:$e,onMouseout:Ne,style:vue.normalizeStyle(j.value)},null,44,_hoisted_7$3)],512)])])]))}},TSScrubber=_export_sfc$1(_sfc_main$V,[["__scopeId","data-v-8618a902"]]),TSScrubber$1=Object.freeze(Object.defineProperty({__proto__:null,default:TSScrubber},Symbol.toStringTag,{value:"Module"}));var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var src={exports:{}},indexLight={exports:{}},indexMinimal={},minimal={},aspromise,hasRequiredAspromise;function requireAspromise(){if(hasRequiredAspromise)return aspromise;hasRequiredAspromise=1,aspromise=e;function e(t,n){for(var r=new Array(arguments.length-1),a=0,s=2,o=!0;s<arguments.length;)r[a++]=arguments[s++];return new Promise(function(u,l){r[a]=function(d){if(o)if(o=!1,d)l(d);else{for(var f=new Array(arguments.length-1),c=0;c<f.length;)f[c++]=arguments[c];u.apply(null,f)}};try{t.apply(n||null,r)}catch(v){o&&(o=!1,l(v))}})}return aspromise}var base64={},hasRequiredBase64;function requireBase64(){return hasRequiredBase64||(hasRequiredBase64=1,function(e){var t=e;t.length=function(i){var u=i.length;if(!u)return 0;for(var l=0;--u%4>1&&i.charAt(u)==="=";)++l;return Math.ceil(i.length*3)/4-l};for(var n=new Array(64),r=new Array(123),a=0;a<64;)r[n[a]=a<26?a+65:a<52?a+71:a<62?a-4:a-59|43]=a++;t.encode=function(i,u,l){for(var v=null,d=[],f=0,c=0,p;u<l;){var h=i[u++];switch(c){case 0:d[f++]=n[h>>2],p=(h&3)<<4,c=1;break;case 1:d[f++]=n[p|h>>4],p=(h&15)<<2,c=2;break;case 2:d[f++]=n[p|h>>6],d[f++]=n[h&63],c=0;break}f>8191&&((v||(v=[])).push(String.fromCharCode.apply(String,d)),f=0)}return c&&(d[f++]=n[p],d[f++]=61,c===1&&(d[f++]=61)),v?(f&&v.push(String.fromCharCode.apply(String,d.slice(0,f))),v.join("")):String.fromCharCode.apply(String,d.slice(0,f))};var s="invalid encoding";t.decode=function(i,u,l){for(var v=l,d=0,f,c=0;c<i.length;){var p=i.charCodeAt(c++);if(p===61&&d>1)break;if((p=r[p])===void 0)throw Error(s);switch(d){case 0:f=p,d=1;break;case 1:u[l++]=f<<2|(p&48)>>4,f=p,d=2;break;case 2:u[l++]=(f&15)<<4|(p&60)>>2,f=p,d=3;break;case 3:u[l++]=(f&3)<<6|p,d=0;break}}if(d===1)throw Error(s);return l-v},t.test=function(i){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(i)}}(base64)),base64}var eventemitter,hasRequiredEventemitter;function requireEventemitter(){if(hasRequiredEventemitter)return eventemitter;hasRequiredEventemitter=1,eventemitter=e;function e(){this._listeners={}}return e.prototype.on=function(n,r,a){return(this._listeners[n]||(this._listeners[n]=[])).push({fn:r,ctx:a||this}),this},e.prototype.off=function(n,r){if(n===void 0)this._listeners={};else if(r===void 0)this._listeners[n]=[];else for(var a=this._listeners[n],s=0;s<a.length;)a[s].fn===r?a.splice(s,1):++s;return this},e.prototype.emit=function(n){var r=this._listeners[n];if(r){for(var a=[],s=1;s<arguments.length;)a.push(arguments[s++]);for(s=0;s<r.length;)r[s].fn.apply(r[s++].ctx,a)}return this},eventemitter}var float,hasRequiredFloat;function requireFloat(){if(hasRequiredFloat)return float;hasRequiredFloat=1,float=e(e);function e(s){return typeof Float32Array<"u"?function(){var o=new Float32Array([-0]),i=new Uint8Array(o.buffer),u=i[3]===128;function l(c,p,h){o[0]=c,p[h]=i[0],p[h+1]=i[1],p[h+2]=i[2],p[h+3]=i[3]}function v(c,p,h){o[0]=c,p[h]=i[3],p[h+1]=i[2],p[h+2]=i[1],p[h+3]=i[0]}s.writeFloatLE=u?l:v,s.writeFloatBE=u?v:l;function d(c,p){return i[0]=c[p],i[1]=c[p+1],i[2]=c[p+2],i[3]=c[p+3],o[0]}function f(c,p){return i[3]=c[p],i[2]=c[p+1],i[1]=c[p+2],i[0]=c[p+3],o[0]}s.readFloatLE=u?d:f,s.readFloatBE=u?f:d}():function(){function o(u,l,v,d){var f=l<0?1:0;if(f&&(l=-l),l===0)u(1/l>0?0:2147483648,v,d);else if(isNaN(l))u(2143289344,v,d);else if(l>34028234663852886e22)u((f<<31|2139095040)>>>0,v,d);else if(l<11754943508222875e-54)u((f<<31|Math.round(l/1401298464324817e-60))>>>0,v,d);else{var c=Math.floor(Math.log(l)/Math.LN2),p=Math.round(l*Math.pow(2,-c)*8388608)&8388607;u((f<<31|c+127<<23|p)>>>0,v,d)}}s.writeFloatLE=o.bind(null,t),s.writeFloatBE=o.bind(null,n);function i(u,l,v){var d=u(l,v),f=(d>>31)*2+1,c=d>>>23&255,p=d&8388607;return c===255?p?NaN:f*(1/0):c===0?f*1401298464324817e-60*p:f*Math.pow(2,c-150)*(p+8388608)}s.readFloatLE=i.bind(null,r),s.readFloatBE=i.bind(null,a)}(),typeof Float64Array<"u"?function(){var o=new Float64Array([-0]),i=new Uint8Array(o.buffer),u=i[7]===128;function l(c,p,h){o[0]=c,p[h]=i[0],p[h+1]=i[1],p[h+2]=i[2],p[h+3]=i[3],p[h+4]=i[4],p[h+5]=i[5],p[h+6]=i[6],p[h+7]=i[7]}function v(c,p,h){o[0]=c,p[h]=i[7],p[h+1]=i[6],p[h+2]=i[5],p[h+3]=i[4],p[h+4]=i[3],p[h+5]=i[2],p[h+6]=i[1],p[h+7]=i[0]}s.writeDoubleLE=u?l:v,s.writeDoubleBE=u?v:l;function d(c,p){return i[0]=c[p],i[1]=c[p+1],i[2]=c[p+2],i[3]=c[p+3],i[4]=c[p+4],i[5]=c[p+5],i[6]=c[p+6],i[7]=c[p+7],o[0]}function f(c,p){return i[7]=c[p],i[6]=c[p+1],i[5]=c[p+2],i[4]=c[p+3],i[3]=c[p+4],i[2]=c[p+5],i[1]=c[p+6],i[0]=c[p+7],o[0]}s.readDoubleLE=u?d:f,s.readDoubleBE=u?f:d}():function(){function o(u,l,v,d,f,c){var p=d<0?1:0;if(p&&(d=-d),d===0)u(0,f,c+l),u(1/d>0?0:2147483648,f,c+v);else if(isNaN(d))u(0,f,c+l),u(2146959360,f,c+v);else if(d>17976931348623157e292)u(0,f,c+l),u((p<<31|2146435072)>>>0,f,c+v);else{var h;if(d<22250738585072014e-324)h=d/5e-324,u(h>>>0,f,c+l),u((p<<31|h/4294967296)>>>0,f,c+v);else{var y=Math.floor(Math.log(d)/Math.LN2);y===1024&&(y=1023),h=d*Math.pow(2,-y),u(h*4503599627370496>>>0,f,c+l),u((p<<31|y+1023<<20|h*1048576&1048575)>>>0,f,c+v)}}}s.writeDoubleLE=o.bind(null,t,0,4),s.writeDoubleBE=o.bind(null,n,4,0);function i(u,l,v,d,f){var c=u(d,f+l),p=u(d,f+v),h=(p>>31)*2+1,y=p>>>20&2047,m=4294967296*(p&1048575)+c;return y===2047?m?NaN:h*(1/0):y===0?h*5e-324*m:h*Math.pow(2,y-1075)*(m+4503599627370496)}s.readDoubleLE=i.bind(null,r,0,4),s.readDoubleBE=i.bind(null,a,4,0)}(),s}function t(s,o,i){o[i]=s&255,o[i+1]=s>>>8&255,o[i+2]=s>>>16&255,o[i+3]=s>>>24}function n(s,o,i){o[i]=s>>>24,o[i+1]=s>>>16&255,o[i+2]=s>>>8&255,o[i+3]=s&255}function r(s,o){return(s[o]|s[o+1]<<8|s[o+2]<<16|s[o+3]<<24)>>>0}function a(s,o){return(s[o]<<24|s[o+1]<<16|s[o+2]<<8|s[o+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(e){}return null}return inquire_1}var utf8={},hasRequiredUtf8;function requireUtf8(){return hasRequiredUtf8||(hasRequiredUtf8=1,function(e){var t=e;t.length=function(r){for(var a=0,s=0,o=0;o<r.length;++o)s=r.charCodeAt(o),s<128?a+=1:s<2048?a+=2:(s&64512)===55296&&(r.charCodeAt(o+1)&64512)===56320?(++o,a+=4):a+=3;return a},t.read=function(r,a,s){var o=s-a;if(o<1)return"";for(var i=null,u=[],l=0,v;a<s;)v=r[a++],v<128?u[l++]=v:v>191&&v<224?u[l++]=(v&31)<<6|r[a++]&63:v>239&&v<365?(v=((v&7)<<18|(r[a++]&63)<<12|(r[a++]&63)<<6|r[a++]&63)-65536,u[l++]=55296+(v>>10),u[l++]=56320+(v&1023)):u[l++]=(v&15)<<12|(r[a++]&63)<<6|r[a++]&63,l>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,u)),l=0);return i?(l&&i.push(String.fromCharCode.apply(String,u.slice(0,l))),i.join("")):String.fromCharCode.apply(String,u.slice(0,l))},t.write=function(r,a,s){for(var o=s,i,u,l=0;l<r.length;++l)i=r.charCodeAt(l),i<128?a[s++]=i:i<2048?(a[s++]=i>>6|192,a[s++]=i&63|128):(i&64512)===55296&&((u=r.charCodeAt(l+1))&64512)===56320?(i=65536+((i&1023)<<10)+(u&1023),++l,a[s++]=i>>18|240,a[s++]=i>>12&63|128,a[s++]=i>>6&63|128,a[s++]=i&63|128):(a[s++]=i>>12|224,a[s++]=i>>6&63|128,a[s++]=i&63|128);return s-o}}(utf8)),utf8}var pool_1,hasRequiredPool;function requirePool(){if(hasRequiredPool)return pool_1;hasRequiredPool=1,pool_1=e;function e(t,n,r){var a=r||8192,s=a>>>1,o=null,i=a;return function(l){if(l<1||l>s)return t(l);i+l>a&&(o=t(a),i=0);var v=n.call(o,i,i+=l);return i&7&&(i=(i|7)+1),v}}return pool_1}var longbits,hasRequiredLongbits;function requireLongbits(){if(hasRequiredLongbits)return longbits;hasRequiredLongbits=1,longbits=t;var e=requireMinimal();function t(s,o){this.lo=s>>>0,this.hi=o>>>0}var n=t.zero=new t(0,0);n.toNumber=function(){return 0},n.zzEncode=n.zzDecode=function(){return this},n.length=function(){return 1};var r=t.zeroHash="\0\0\0\0\0\0\0\0";t.fromNumber=function(o){if(o===0)return n;var i=o<0;i&&(o=-o);var u=o>>>0,l=(o-u)/4294967296>>>0;return i&&(l=~l>>>0,u=~u>>>0,++u>4294967295&&(u=0,++l>4294967295&&(l=0))),new t(u,l)},t.from=function(o){if(typeof o=="number")return t.fromNumber(o);if(e.isString(o))if(e.Long)o=e.Long.fromString(o);else return t.fromNumber(parseInt(o,10));return o.low||o.high?new t(o.low>>>0,o.high>>>0):n},t.prototype.toNumber=function(o){if(!o&&this.hi>>>31){var i=~this.lo+1>>>0,u=~this.hi>>>0;return i||(u=u+1>>>0),-(i+u*4294967296)}return this.lo+this.hi*4294967296},t.prototype.toLong=function(o){return e.Long?new e.Long(this.lo|0,this.hi|0,!!o):{low:this.lo|0,high:this.hi|0,unsigned:!!o}};var a=String.prototype.charCodeAt;return t.fromHash=function(o){return o===r?n:new t((a.call(o,0)|a.call(o,1)<<8|a.call(o,2)<<16|a.call(o,3)<<24)>>>0,(a.call(o,4)|a.call(o,5)<<8|a.call(o,6)<<16|a.call(o,7)<<24)>>>0)},t.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)},t.prototype.zzEncode=function(){var o=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^o)>>>0,this.lo=(this.lo<<1^o)>>>0,this},t.prototype.zzDecode=function(){var o=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^o)>>>0,this.hi=(this.hi>>>1^o)>>>0,this},t.prototype.length=function(){var o=this.lo,i=(this.lo>>>28|this.hi<<4)>>>0,u=this.hi>>>24;return u===0?i===0?o<16384?o<128?1:2:o<2097152?3:4:i<16384?i<128?5:6:i<2097152?7:8:u<128?9:10},longbits}var hasRequiredMinimal;function requireMinimal(){return hasRequiredMinimal||(hasRequiredMinimal=1,function(e){var t=e;t.asPromise=requireAspromise(),t.base64=requireBase64(),t.EventEmitter=requireEventemitter(),t.float=requireFloat(),t.inquire=requireInquire(),t.utf8=requireUtf8(),t.pool=requirePool(),t.LongBits=requireLongbits(),t.isNode=!!(typeof commonjsGlobal<"u"&&commonjsGlobal&&commonjsGlobal.process&&commonjsGlobal.process.versions&&commonjsGlobal.process.versions.node),t.global=t.isNode&&commonjsGlobal||typeof window<"u"&&window||typeof self<"u"&&self||minimal,t.emptyArray=Object.freeze?Object.freeze([]):[],t.emptyObject=Object.freeze?Object.freeze({}):{},t.isInteger=Number.isInteger||function(s){return typeof s=="number"&&isFinite(s)&&Math.floor(s)===s},t.isString=function(s){return typeof s=="string"||s instanceof String},t.isObject=function(s){return s&&typeof s=="object"},t.isset=t.isSet=function(s,o){var i=s[o];return i!=null&&s.hasOwnProperty(o)?typeof i!="object"||(Array.isArray(i)?i.length:Object.keys(i).length)>0:!1},t.Buffer=function(){try{var a=t.inquire("buffer").Buffer;return a.prototype.utf8Write?a:null}catch{return null}}(),t._Buffer_from=null,t._Buffer_allocUnsafe=null,t.newBuffer=function(s){return typeof s=="number"?t.Buffer?t._Buffer_allocUnsafe(s):new t.Array(s):t.Buffer?t._Buffer_from(s):typeof Uint8Array>"u"?s:new Uint8Array(s)},t.Array=typeof Uint8Array<"u"?Uint8Array:Array,t.Long=t.global.dcodeIO&&t.global.dcodeIO.Long||t.global.Long||t.inquire("long"),t.key2Re=/^true|false|0|1$/,t.key32Re=/^-?(?:0|[1-9][0-9]*)$/,t.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,t.longToHash=function(s){return s?t.LongBits.from(s).toHash():t.LongBits.zeroHash},t.longFromHash=function(s,o){var i=t.LongBits.fromHash(s);return t.Long?t.Long.fromBits(i.lo,i.hi,o):i.toNumber(!!o)};function n(a,s,o){for(var i=Object.keys(s),u=0;u<i.length;++u)(a[i[u]]===void 0||!o)&&(a[i[u]]=s[i[u]]);return a}t.merge=n,t.lcFirst=function(s){return s.charAt(0).toLowerCase()+s.substring(1)};function r(a){function s(o,i){if(!(this instanceof s))return new s(o,i);Object.defineProperty(this,"message",{get:function(){return o}}),Error.captureStackTrace?Error.captureStackTrace(this,s):Object.defineProperty(this,"stack",{value:new Error().stack||""}),i&&n(this,i)}return s.prototype=Object.create(Error.prototype,{constructor:{value:s,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return a},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),s}t.newError=r,t.ProtocolError=r("ProtocolError"),t.oneOfGetter=function(s){for(var o={},i=0;i<s.length;++i)o[s[i]]=1;return function(){for(var u=Object.keys(this),l=u.length-1;l>-1;--l)if(o[u[l]]===1&&this[u[l]]!==void 0&&this[u[l]]!==null)return u[l]}},t.oneOfSetter=function(s){return function(o){for(var i=0;i<s.length;++i)s[i]!==o&&delete this[s[i]]}},t.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},t._configure=function(){var a=t.Buffer;if(!a){t._Buffer_from=t._Buffer_allocUnsafe=null;return}t._Buffer_from=a.from!==Uint8Array.from&&a.from||function(o,i){return new a(o,i)},t._Buffer_allocUnsafe=a.allocUnsafe||function(o){return new a(o)}}}(minimal)),minimal}var writer,hasRequiredWriter;function requireWriter(){if(hasRequiredWriter)return writer;hasRequiredWriter=1,writer=u;var e=requireMinimal(),t,n=e.LongBits,r=e.base64,a=e.utf8;function s(y,m,_){this.fn=y,this.len=m,this.next=void 0,this.val=_}function o(){}function i(y){this.head=y.head,this.tail=y.tail,this.len=y.len,this.next=y.states}function u(){this.len=0,this.head=new s(o,0,0),this.tail=this.head,this.states=null}var l=function(){return e.Buffer?function(){return(u.create=function(){return new t})()}:function(){return new u}};u.create=l(),u.alloc=function(m){return new e.Array(m)},e.Array!==Array&&(u.alloc=e.pool(u.alloc,e.Array.prototype.subarray)),u.prototype._push=function(m,_,b){return this.tail=this.tail.next=new s(m,_,b),this.len+=_,this};function v(y,m,_){m[_]=y&255}function d(y,m,_){for(;y>127;)m[_++]=y&127|128,y>>>=7;m[_]=y}function f(y,m){this.len=y,this.next=void 0,this.val=m}f.prototype=Object.create(s.prototype),f.prototype.fn=d,u.prototype.uint32=function(m){return this.len+=(this.tail=this.tail.next=new f((m=m>>>0)<128?1:m<16384?2:m<2097152?3:m<268435456?4:5,m)).len,this},u.prototype.int32=function(m){return m<0?this._push(c,10,n.fromNumber(m)):this.uint32(m)},u.prototype.sint32=function(m){return this.uint32((m<<1^m>>31)>>>0)};function c(y,m,_){for(;y.hi;)m[_++]=y.lo&127|128,y.lo=(y.lo>>>7|y.hi<<25)>>>0,y.hi>>>=7;for(;y.lo>127;)m[_++]=y.lo&127|128,y.lo=y.lo>>>7;m[_++]=y.lo}u.prototype.uint64=function(m){var _=n.from(m);return this._push(c,_.length(),_)},u.prototype.int64=u.prototype.uint64,u.prototype.sint64=function(m){var _=n.from(m).zzEncode();return this._push(c,_.length(),_)},u.prototype.bool=function(m){return this._push(v,1,m?1:0)};function p(y,m,_){m[_]=y&255,m[_+1]=y>>>8&255,m[_+2]=y>>>16&255,m[_+3]=y>>>24}u.prototype.fixed32=function(m){return this._push(p,4,m>>>0)},u.prototype.sfixed32=u.prototype.fixed32,u.prototype.fixed64=function(m){var _=n.from(m);return this._push(p,4,_.lo)._push(p,4,_.hi)},u.prototype.sfixed64=u.prototype.fixed64,u.prototype.float=function(m){return this._push(e.float.writeFloatLE,4,m)},u.prototype.double=function(m){return this._push(e.float.writeDoubleLE,8,m)};var h=e.Array.prototype.set?function(m,_,b){_.set(m,b)}:function(m,_,b){for(var g=0;g<m.length;++g)_[b+g]=m[g]};return u.prototype.bytes=function(m){var _=m.length>>>0;if(!_)return this._push(v,1,0);if(e.isString(m)){var b=u.alloc(_=r.length(m));r.decode(m,b,0),m=b}return this.uint32(_)._push(h,_,m)},u.prototype.string=function(m){var _=a.length(m);return _?this.uint32(_)._push(a.write,_,m):this._push(v,1,0)},u.prototype.fork=function(){return this.states=new i(this),this.head=this.tail=new s(o,0,0),this.len=0,this},u.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 s(o,0,0),this.len=0),this},u.prototype.ldelim=function(){var m=this.head,_=this.tail,b=this.len;return this.reset().uint32(b),b&&(this.tail.next=m.next,this.tail=_,this.len+=b),this},u.prototype.finish=function(){for(var m=this.head.next,_=this.constructor.alloc(this.len),b=0;m;)m.fn(m.val,_,b),b+=m.len,m=m.next;return _},u._configure=function(y){t=y,u.create=l(),t._configure()},writer}var writer_buffer,hasRequiredWriter_buffer;function requireWriter_buffer(){if(hasRequiredWriter_buffer)return writer_buffer;hasRequiredWriter_buffer=1,writer_buffer=n;var e=requireWriter();(n.prototype=Object.create(e.prototype)).constructor=n;var t=requireMinimal();function n(){e.call(this)}n._configure=function(){n.alloc=t._Buffer_allocUnsafe,n.writeBytesBuffer=t.Buffer&&t.Buffer.prototype instanceof Uint8Array&&t.Buffer.prototype.set.name==="set"?function(s,o,i){o.set(s,i)}:function(s,o,i){if(s.copy)s.copy(o,i,0,s.length);else for(var u=0;u<s.length;)o[i++]=s[u++]}},n.prototype.bytes=function(s){t.isString(s)&&(s=t._Buffer_from(s,"base64"));var o=s.length>>>0;return this.uint32(o),o&&this._push(n.writeBytesBuffer,o,s),this};function r(a,s,o){a.length<40?t.utf8.write(a,s,o):s.utf8Write?s.utf8Write(a,o):s.write(a,o)}return n.prototype.string=function(s){var o=t.Buffer.byteLength(s);return this.uint32(o),o&&this._push(r,o,s),this},n._configure(),writer_buffer}var reader,hasRequiredReader;function requireReader(){if(hasRequiredReader)return reader;hasRequiredReader=1,reader=s;var e=requireMinimal(),t,n=e.LongBits,r=e.utf8;function a(d,f){return RangeError("index out of range: "+d.pos+" + "+(f||1)+" > "+d.len)}function s(d){this.buf=d,this.pos=0,this.len=d.length}var o=typeof Uint8Array<"u"?function(f){if(f instanceof Uint8Array||Array.isArray(f))return new s(f);throw Error("illegal buffer")}:function(f){if(Array.isArray(f))return new s(f);throw Error("illegal buffer")},i=function(){return e.Buffer?function(c){return(s.create=function(h){return e.Buffer.isBuffer(h)?new t(h):o(h)})(c)}:o};s.create=i(),s.prototype._slice=e.Array.prototype.subarray||e.Array.prototype.slice,s.prototype.uint32=function(){var f=4294967295;return function(){if(f=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(f=(f|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(f=(f|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(f=(f|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(f=(f|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return f;if((this.pos+=5)>this.len)throw this.pos=this.len,a(this,10);return f}}(),s.prototype.int32=function(){return this.uint32()|0},s.prototype.sint32=function(){var f=this.uint32();return f>>>1^-(f&1)|0};function u(){var d=new n(0,0),f=0;if(this.len-this.pos>4){for(;f<4;++f)if(d.lo=(d.lo|(this.buf[this.pos]&127)<<f*7)>>>0,this.buf[this.pos++]<128)return d;if(d.lo=(d.lo|(this.buf[this.pos]&127)<<28)>>>0,d.hi=(d.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return d;f=0}else{for(;f<3;++f){if(this.pos>=this.len)throw a(this);if(d.lo=(d.lo|(this.buf[this.pos]&127)<<f*7)>>>0,this.buf[this.pos++]<128)return d}return d.lo=(d.lo|(this.buf[this.pos++]&127)<<f*7)>>>0,d}if(this.len-this.pos>4){for(;f<5;++f)if(d.hi=(d.hi|(this.buf[this.pos]&127)<<f*7+3)>>>0,this.buf[this.pos++]<128)return d}else for(;f<5;++f){if(this.pos>=this.len)throw a(this);if(d.hi=(d.hi|(this.buf[this.pos]&127)<<f*7+3)>>>0,this.buf[this.pos++]<128)return d}throw Error("invalid varint encoding")}s.prototype.bool=function(){return this.uint32()!==0};function l(d,f){return(d[f-4]|d[f-3]<<8|d[f-2]<<16|d[f-1]<<24)>>>0}s.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return l(this.buf,this.pos+=4)},s.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return l(this.buf,this.pos+=4)|0};function v(){if(this.pos+8>this.len)throw a(this,8);return new n(l(this.buf,this.pos+=4),l(this.buf,this.pos+=4))}return s.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var f=e.float.readFloatLE(this.buf,this.pos);return this.pos+=4,f},s.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var f=e.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,f},s.prototype.bytes=function(){var f=this.uint32(),c=this.pos,p=this.pos+f;if(p>this.len)throw a(this,f);if(this.pos+=f,Array.isArray(this.buf))return this.buf.slice(c,p);if(c===p){var h=e.Buffer;return h?h.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,c,p)},s.prototype.string=function(){var f=this.bytes();return r.read(f,0,f.length)},s.prototype.skip=function(f){if(typeof f=="number"){if(this.pos+f>this.len)throw a(this,f);this.pos+=f}else do if(this.pos>=this.len)throw a(this);while(this.buf[this.pos++]&128);return this},s.prototype.skipType=function(d){switch(d){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(d=this.uint32()&7)!==4;)this.skipType(d);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+d+" at offset "+this.pos)}return this},s._configure=function(d){t=d,s.create=i(),t._configure();var f=e.Long?"toLong":"toNumber";e.merge(s.prototype,{int64:function(){return u.call(this)[f](!1)},uint64:function(){return u.call(this)[f](!0)},sint64:function(){return u.call(this).zzDecode()[f](!1)},fixed64:function(){return v.call(this)[f](!0)},sfixed64:function(){return v.call(this)[f](!1)}})},reader}var reader_buffer,hasRequiredReader_buffer;function requireReader_buffer(){if(hasRequiredReader_buffer)return reader_buffer;hasRequiredReader_buffer=1,reader_buffer=n;var e=requireReader();(n.prototype=Object.create(e.prototype)).constructor=n;var t=requireMinimal();function n(r){e.call(this,r)}return n._configure=function(){t.Buffer&&(n.prototype._slice=t.Buffer.prototype.slice)},n.prototype.string=function(){var a=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+a,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+a,this.len))},n._configure(),reader_buffer}var rpc={},service$1,hasRequiredService$1;function requireService$1(){if(hasRequiredService$1)return service$1;hasRequiredService$1=1,service$1=t;var e=requireMinimal();(t.prototype=Object.create(e.EventEmitter.prototype)).constructor=t;function t(n,r,a){if(typeof n!="function")throw TypeError("rpcImpl must be a function");e.EventEmitter.call(this),this.rpcImpl=n,this.requestDelimited=!!r,this.responseDelimited=!!a}return t.prototype.rpcCall=function n(r,a,s,o,i){if(!o)throw TypeError("request must be specified");var u=this;if(!i)return e.asPromise(n,u,r,a,s,o);if(!u.rpcImpl){setTimeout(function(){i(Error("already ended"))},0);return}try{return u.rpcImpl(r,a[u.requestDelimited?"encodeDelimited":"encode"](o).finish(),function(v,d){if(v)return u.emit("error",v,r),i(v);if(d===null){u.end(!0);return}if(!(d instanceof s))try{d=s[u.responseDelimited?"decodeDelimited":"decode"](d)}catch(f){return u.emit("error",f,r),i(f)}return u.emit("data",d,r),i(null,d)})}catch(l){u.emit("error",l,r),setTimeout(function(){i(l)},0);return}},t.prototype.end=function(r){return this.rpcImpl&&(r||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this},service$1}var hasRequiredRpc;function requireRpc(){return hasRequiredRpc||(hasRequiredRpc=1,function(e){var t=e;t.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(e){var t=e;t.build="minimal",t.Writer=requireWriter(),t.BufferWriter=requireWriter_buffer(),t.Reader=requireReader(),t.BufferReader=requireReader_buffer(),t.util=requireMinimal(),t.rpc=requireRpc(),t.roots=requireRoots(),t.configure=n;function n(){t.util._configure(),t.Writer._configure(t.BufferWriter),t.Reader._configure(t.BufferReader)}n()}(indexMinimal)),indexMinimal}var types={},util={exports:{}},codegen_1,hasRequiredCodegen;function requireCodegen(){if(hasRequiredCodegen)return codegen_1;hasRequiredCodegen=1,codegen_1=e;function e(t,n){typeof t=="string"&&(n=t,t=void 0);var r=[];function a(o){if(typeof o!="string"){var i=s();if(e.verbose&&console.log("codegen: "+i),i="return "+i,o){for(var u=Object.keys(o),l=new Array(u.length+1),v=new Array(u.length),d=0;d<u.length;)l[d]=u[d],v[d]=o[u[d++]];return l[d]=i,Function.apply(null,l).apply(null,v)}return Function(i)()}for(var f=new Array(arguments.length-1),c=0;c<f.length;)f[c]=arguments[++c];if(c=0,o=o.replace(/%([%dfijs])/g,function(h,y){var m=f[c++];switch(y){case"d":case"f":return String(Number(m));case"i":return String(Math.floor(m));case"j":return JSON.stringify(m);case"s":return String(m)}return"%"}),c!==f.length)throw Error("parameter count mismatch");return r.push(o),a}function s(o){return"function "+(o||n||"")+"("+(t&&t.join(",")||"")+`){
1
+ (function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("pinia"),require("aws-amplify/auth")):typeof define=="function"&&define.amd?define(["exports","vue","pinia","aws-amplify/auth"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.tsviewer={},e.Vue,e.Pinia,e.Amplify.Auth))})(this,function(exports,vue,pinia,auth){"use strict";function _isPlaceholder(e){return e!=null&&typeof e=="object"&&e["@@functional/placeholder"]===!0}function _curry1(e){return function t(n){return arguments.length===0||_isPlaceholder(n)?t:e.apply(this,arguments)}}function _curry2(e){return function t(n,r){switch(arguments.length){case 0:return t;case 1:return _isPlaceholder(n)?t:_curry1(function(a){return e(n,a)});default:return _isPlaceholder(n)&&_isPlaceholder(r)?t:_isPlaceholder(n)?_curry1(function(a){return e(a,r)}):_isPlaceholder(r)?_curry1(function(a){return e(n,a)}):e(n,r)}}}function _concat(e,t){e=e||[],t=t||[];var n,r=e.length,a=t.length,s=[];for(n=0;n<r;)s[s.length]=e[n],n+=1;for(n=0;n<a;)s[s.length]=t[n],n+=1;return s}function _arity(e,t){switch(e){case 0:return function(){return t.apply(this,arguments)};case 1:return function(n){return t.apply(this,arguments)};case 2:return function(n,r){return t.apply(this,arguments)};case 3:return function(n,r,a){return t.apply(this,arguments)};case 4:return function(n,r,a,s){return t.apply(this,arguments)};case 5:return function(n,r,a,s,o){return t.apply(this,arguments)};case 6:return function(n,r,a,s,o,i){return t.apply(this,arguments)};case 7:return function(n,r,a,s,o,i,u){return t.apply(this,arguments)};case 8:return function(n,r,a,s,o,i,u,l){return t.apply(this,arguments)};case 9:return function(n,r,a,s,o,i,u,l,v){return t.apply(this,arguments)};case 10:return function(n,r,a,s,o,i,u,l,v,d){return t.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}function _curryN(e,t,n){return function(){for(var r=[],a=0,s=e,o=0;o<t.length||a<arguments.length;){var i;o<t.length&&(!_isPlaceholder(t[o])||a>=arguments.length)?i=t[o]:(i=arguments[a],a+=1),r[o]=i,_isPlaceholder(i)||(s-=1),o+=1}return s<=0?n.apply(this,r):_arity(s,_curryN(e,r,n))}}var curryN=_curry2(function(t,n){return t===1?_curry1(n):_arity(t,_curryN(t,[],n))});function _curry3(e){return function t(n,r,a){switch(arguments.length){case 0:return t;case 1:return _isPlaceholder(n)?t:_curry2(function(s,o){return e(n,s,o)});case 2:return _isPlaceholder(n)&&_isPlaceholder(r)?t:_isPlaceholder(n)?_curry2(function(s,o){return e(s,r,o)}):_isPlaceholder(r)?_curry2(function(s,o){return e(n,s,o)}):_curry1(function(s){return e(n,r,s)});default:return _isPlaceholder(n)&&_isPlaceholder(r)&&_isPlaceholder(a)?t:_isPlaceholder(n)&&_isPlaceholder(r)?_curry2(function(s,o){return e(s,o,a)}):_isPlaceholder(n)&&_isPlaceholder(a)?_curry2(function(s,o){return e(s,r,o)}):_isPlaceholder(r)&&_isPlaceholder(a)?_curry2(function(s,o){return e(n,s,o)}):_isPlaceholder(n)?_curry1(function(s){return e(s,r,a)}):_isPlaceholder(r)?_curry1(function(s){return e(n,s,a)}):_isPlaceholder(a)?_curry1(function(s){return e(n,r,s)}):e(n,r,a)}}}const _isArray=Array.isArray||function(t){return t!=null&&t.length>=0&&Object.prototype.toString.call(t)==="[object Array]"};function _isTransformer(e){return e!=null&&typeof e["@@transducer/step"]=="function"}function _dispatchable(e,t,n){return function(){if(arguments.length===0)return n();var r=arguments[arguments.length-1];if(!_isArray(r)){for(var a=0;a<e.length;){if(typeof r[e[a]]=="function")return r[e[a]].apply(r,Array.prototype.slice.call(arguments,0,-1));a+=1}if(_isTransformer(r)){var s=t.apply(null,Array.prototype.slice.call(arguments,0,-1));return s(r)}}return n.apply(this,arguments)}}function _reduced(e){return e&&e["@@transducer/reduced"]?e:{"@@transducer/value":e,"@@transducer/reduced":!0}}const _xfBase={init:function(){return this.xf["@@transducer/init"]()},result:function(e){return this.xf["@@transducer/result"](e)}};function _map(e,t){for(var n=0,r=t.length,a=Array(r);n<r;)a[n]=e(t[n]),n+=1;return a}function _isString$1(e){return Object.prototype.toString.call(e)==="[object String]"}var _isArrayLike=_curry1(function(t){return _isArray(t)?!0:!t||typeof t!="object"||_isString$1(t)?!1:t.length===0?!0:t.length>0?t.hasOwnProperty(0)&&t.hasOwnProperty(t.length-1):!1}),XWrap=function(){function e(t){this.f=t}return e.prototype["@@transducer/init"]=function(){throw new Error("init not implemented on XWrap")},e.prototype["@@transducer/result"]=function(t){return t},e.prototype["@@transducer/step"]=function(t,n){return this.f(t,n)},e}();function _xwrap(e){return new XWrap(e)}var bind=_curry2(function(t,n){return _arity(t.length,function(){return t.apply(n,arguments)})});function _arrayReduce(e,t,n){for(var r=0,a=n.length;r<a;){if(t=e["@@transducer/step"](t,n[r]),t&&t["@@transducer/reduced"]){t=t["@@transducer/value"];break}r+=1}return e["@@transducer/result"](t)}function _iterableReduce(e,t,n){for(var r=n.next();!r.done;){if(t=e["@@transducer/step"](t,r.value),t&&t["@@transducer/reduced"]){t=t["@@transducer/value"];break}r=n.next()}return e["@@transducer/result"](t)}function _methodReduce(e,t,n,r){return e["@@transducer/result"](n[r](bind(e["@@transducer/step"],e),t))}var symIterator=typeof Symbol<"u"?Symbol.iterator:"@@iterator";function _reduce(e,t,n){if(typeof e=="function"&&(e=_xwrap(e)),_isArrayLike(n))return _arrayReduce(e,t,n);if(typeof n["fantasy-land/reduce"]=="function")return _methodReduce(e,t,n,"fantasy-land/reduce");if(n[symIterator]!=null)return _iterableReduce(e,t,n[symIterator]());if(typeof n.next=="function")return _iterableReduce(e,t,n);if(typeof n.reduce=="function")return _methodReduce(e,t,n,"reduce");throw new TypeError("reduce: list must be array or iterable")}var XMap=function(){function e(t,n){this.xf=n,this.f=t}return e.prototype["@@transducer/init"]=_xfBase.init,e.prototype["@@transducer/result"]=_xfBase.result,e.prototype["@@transducer/step"]=function(t,n){return this.xf["@@transducer/step"](t,this.f(n))},e}(),_xmap=_curry2(function(t,n){return new XMap(t,n)});function _has(e,t){return Object.prototype.hasOwnProperty.call(t,e)}var toString$1=Object.prototype.toString,_isArguments=function(){return toString$1.call(arguments)==="[object Arguments]"?function(t){return toString$1.call(t)==="[object Arguments]"}:function(t){return _has("callee",t)}}(),hasEnumBug=!{toString:null}.propertyIsEnumerable("toString"),nonEnumerableProps=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],hasArgsEnumBug=function(){return arguments.propertyIsEnumerable("length")}(),contains=function(t,n){for(var r=0;r<t.length;){if(t[r]===n)return!0;r+=1}return!1},keys$1=_curry1(typeof Object.keys=="function"&&!hasArgsEnumBug?function(t){return Object(t)!==t?[]:Object.keys(t)}:function(t){if(Object(t)!==t)return[];var n,r,a=[],s=hasArgsEnumBug&&_isArguments(t);for(n in t)_has(n,t)&&(!s||n!=="length")&&(a[a.length]=n);if(hasEnumBug)for(r=nonEnumerableProps.length-1;r>=0;)n=nonEnumerableProps[r],_has(n,t)&&!contains(a,n)&&(a[a.length]=n),r-=1;return a}),map=_curry2(_dispatchable(["fantasy-land/map","map"],_xmap,function(t,n){switch(Object.prototype.toString.call(n)){case"[object Function]":return curryN(n.length,function(){return t.call(this,n.apply(this,arguments))});case"[object Object]":return _reduce(function(r,a){return r[a]=t(n[a]),r},{},keys$1(n));default:return _map(t,n)}}));const _isInteger=Number.isInteger||function(t){return t<<0===t};var nth=_curry2(function(t,n){var r=t<0?n.length+t:t;return _isString$1(n)?n.charAt(r):n[r]}),prop=_curry2(function(t,n){if(n!=null)return _isInteger(t)?nth(t,n):n[t]}),reduce=_curry3(_reduce),type$1=_curry1(function(t){return t===null?"Null":t===void 0?"Undefined":Object.prototype.toString.call(t).slice(8,-1)});function _pipe(e,t){return function(){return t.call(this,e.apply(this,arguments))}}function _checkForMethod(e,t){return function(){var n=arguments.length;if(n===0)return t();var r=arguments[n-1];return _isArray(r)||typeof r[e]!="function"?t.apply(this,arguments):r[e].apply(r,Array.prototype.slice.call(arguments,0,n-1))}}var slice=_curry3(_checkForMethod("slice",function(t,n,r){return Array.prototype.slice.call(r,t,n)})),tail=_curry1(_checkForMethod("tail",slice(1,1/0)));function pipe(){if(arguments.length===0)throw new Error("pipe requires at least one argument");return _arity(arguments[0].length,reduce(_pipe,arguments[0],tail(arguments)))}var reverse=_curry1(function(t){return _isString$1(t)?t.split("").reverse().join(""):Array.prototype.slice.call(t,0).reverse()});function compose(){if(arguments.length===0)throw new Error("compose requires at least one argument");return pipe.apply(this,reverse(arguments))}var head=nth(0);function _arrayFromIterator(e){for(var t=[],n;!(n=e.next()).done;)t.push(n.value);return t}function _includesWith(e,t,n){for(var r=0,a=n.length;r<a;){if(e(t,n[r]))return!0;r+=1}return!1}function _functionName(e){var t=String(e).match(/^function (\w*)/);return t==null?"":t[1]}function _objectIs(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}const _objectIs$1=typeof Object.is=="function"?Object.is:_objectIs;function _uniqContentEquals(e,t,n,r){var a=_arrayFromIterator(e),s=_arrayFromIterator(t);function o(i,u){return _equals(i,u,n.slice(),r.slice())}return!_includesWith(function(i,u){return!_includesWith(o,u,i)},s,a)}function _equals(e,t,n,r){if(_objectIs$1(e,t))return!0;var a=type$1(e);if(a!==type$1(t))return!1;if(typeof e["fantasy-land/equals"]=="function"||typeof t["fantasy-land/equals"]=="function")return typeof e["fantasy-land/equals"]=="function"&&e["fantasy-land/equals"](t)&&typeof t["fantasy-land/equals"]=="function"&&t["fantasy-land/equals"](e);if(typeof e.equals=="function"||typeof t.equals=="function")return typeof e.equals=="function"&&e.equals(t)&&typeof t.equals=="function"&&t.equals(e);switch(a){case"Arguments":case"Array":case"Object":if(typeof e.constructor=="function"&&_functionName(e.constructor)==="Promise")return e===t;break;case"Boolean":case"Number":case"String":if(!(typeof e==typeof t&&_objectIs$1(e.valueOf(),t.valueOf())))return!1;break;case"Date":if(!_objectIs$1(e.valueOf(),t.valueOf()))return!1;break;case"Error":return e.name===t.name&&e.message===t.message;case"RegExp":if(!(e.source===t.source&&e.global===t.global&&e.ignoreCase===t.ignoreCase&&e.multiline===t.multiline&&e.sticky===t.sticky&&e.unicode===t.unicode))return!1;break}for(var s=n.length-1;s>=0;){if(n[s]===e)return r[s]===t;s-=1}switch(a){case"Map":return e.size!==t.size?!1:_uniqContentEquals(e.entries(),t.entries(),n.concat([e]),r.concat([t]));case"Set":return e.size!==t.size?!1:_uniqContentEquals(e.values(),t.values(),n.concat([e]),r.concat([t]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var o=keys$1(e);if(o.length!==keys$1(t).length)return!1;var i=n.concat([e]),u=r.concat([t]);for(s=o.length-1;s>=0;){var l=o[s];if(!(_has(l,t)&&_equals(t[l],e[l],i,u)))return!1;s-=1}return!0}var equals=_curry2(function(t,n){return _equals(t,n,[],[])});function _isObject(e){return Object.prototype.toString.call(e)==="[object Object]"}var defaultTo=_curry2(function(t,n){return n==null||n!==n?t:n});function _isTypedArray(e){var t=Object.prototype.toString.call(e);return t==="[object Uint8ClampedArray]"||t==="[object Int8Array]"||t==="[object Uint8Array]"||t==="[object Int16Array]"||t==="[object Uint16Array]"||t==="[object Int32Array]"||t==="[object Uint32Array]"||t==="[object Float32Array]"||t==="[object Float64Array]"||t==="[object BigInt64Array]"||t==="[object BigUint64Array]"}var empty=_curry1(function(t){return t!=null&&typeof t["fantasy-land/empty"]=="function"?t["fantasy-land/empty"]():t!=null&&t.constructor!=null&&typeof t.constructor["fantasy-land/empty"]=="function"?t.constructor["fantasy-land/empty"]():t!=null&&typeof t.empty=="function"?t.empty():t!=null&&t.constructor!=null&&typeof t.constructor.empty=="function"?t.constructor.empty():_isArray(t)?[]:_isString$1(t)?"":_isObject(t)?{}:_isArguments(t)?function(){return arguments}():_isTypedArray(t)?t.constructor.from(""):void 0}),XFind=function(){function e(t,n){this.xf=n,this.f=t,this.found=!1}return e.prototype["@@transducer/init"]=_xfBase.init,e.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,void 0)),this.xf["@@transducer/result"](t)},e.prototype["@@transducer/step"]=function(t,n){return this.f(n)&&(this.found=!0,t=_reduced(this.xf["@@transducer/step"](t,n))),t},e}(),_xfind=_curry2(function(t,n){return new XFind(t,n)}),find=_curry2(_dispatchable(["find"],_xfind,function(t,n){for(var r=0,a=n.length;r<a;){if(t(n[r]))return n[r];r+=1}})),XFindIndex=function(){function e(t,n){this.xf=n,this.f=t,this.idx=-1,this.found=!1}return e.prototype["@@transducer/init"]=_xfBase.init,e.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,-1)),this.xf["@@transducer/result"](t)},e.prototype["@@transducer/step"]=function(t,n){return this.idx+=1,this.f(n)&&(this.found=!0,t=_reduced(this.xf["@@transducer/step"](t,this.idx))),t},e}(),_xfindIndex=_curry2(function(t,n){return new XFindIndex(t,n)}),findIndex=_curry2(_dispatchable([],_xfindIndex,function(t,n){for(var r=0,a=n.length;r<a;){if(t(n[r]))return r;r+=1}return-1})),isEmpty$1=_curry1(function(t){return t!=null&&equals(t,empty(t))}),paths=_curry2(function(t,n){return t.map(function(r){for(var a=n,s=0,o;s<r.length;){if(a==null)return;o=r[s],a=_isInteger(o)?nth(o,a):a[o],s+=1}return a})}),path$1=_curry2(function(t,n){return paths([t],n)[0]}),pathOr=_curry3(function(t,n,r){return defaultTo(t,path$1(n,r))}),propEq=_curry3(function(t,n,r){return equals(n,prop(t,r))}),propOr=_curry3(function(t,n,r){return defaultTo(t,prop(n,r))}),tryCatch=_curry2(function(t,n){return _arity(t.length,function(){try{return t.apply(this,arguments)}catch(r){return n.apply(this,_concat([r],arguments))}})});const pennsieveApiUrl="https://api.pennsieve.io",pennsieveApiUrlDev="https://api.pennsieve.net",pennsieveApi2Url="https://api2.pennsieve.io",pennsieveApi2UrlDev="https://api2.pennsieve.net",timeSeriesPublicUrl="wss://api.pennsieve.io/streaming/discover/ts/query",timeSeriesPublicUrlDev="wss://api.pennsieve.net/streaming/discover/ts/query",timeSeriesApi="https://api.pennsieve.io/streaming",timeSeriesApiDev="https://api.pennsieve.net/streaming",site={pennsieveApiUrl,pennsieveApiUrlDev,pennsieveApi2Url,pennsieveApi2UrlDev,timeSeriesPublicUrl,timeSeriesPublicUrlDev,timeSeriesApi,timeSeriesApiDev},site$1=Object.freeze(Object.defineProperty({__proto__:null,default:site,pennsieveApi2Url,pennsieveApi2UrlDev,pennsieveApiUrl,pennsieveApiUrlDev,timeSeriesApi,timeSeriesApiDev,timeSeriesPublicUrl,timeSeriesPublicUrlDev},Symbol.toStringTag,{value:"Module"}));async function useToken(){try{return auth.fetchAuthSession().then(e=>{var t;return(t=e==null?void 0:e.tokens)==null?void 0:t.accessToken.toString()})}catch(e){console.error(e)}}const useChannelDataRequest=()=>({openConnection:async(t,n,r)=>await new Promise((o,i)=>{const u=t+"?session="+r+"&package="+n;console.log("Opening WebSocket connection to:",u);let l=null;const v=new WebSocket(u);v.onopen=()=>{console.log("🔗 WebSocket opened for package:",n);const d={montage:"NOT_MONTAGED",packageId:n};console.log("🎛️ Sending message payload"),v.send(JSON.stringify(d))},v.onclose=()=>{console.log("🔌 WebSocket closed for package:",n),l&&l.channelDetails?o({res:l.channelDetails,status:"websocket closed"}):(console.warn("No channel details received"),o({res:null,status:"websocket closed without data"}))},v.onmessage=d=>{console.log("WebSocket message received:",d.data),l=JSON.parse(d.data),v.close()},v.onerror=d=>{console.error("WebSocket error:",d),i(d)}})}),useViewerStore=pinia.defineStore("tsviewer",()=>{const e=site$1,t=vue.ref([]),n=vue.ref("NOT_MONTAGED"),r=vue.ref({}),a=vue.ref([]),s=vue.ref(null),o=vue.ref(null),i=vue.ref({}),u=vue.ref([]),l=vue.ref({}),v=vue.ref({}),d=vue.ref("POINTER"),{openConnection:f}=useChannelDataRequest(),c=vue.computed(()=>_e=>a.value.find(ze=>ze.name===_e)),p=vue.computed(()=>t.value.filter(_e=>_e.selected)),h=vue.computed(()=>()=>{const _e=u.value.find(ze=>ze.selected);return _e||(console.warn("No active layer found, available layers:",u.value),u.value.length>0?u.value[0]:null)}),y=()=>{let _e=!1;return u.value.forEach((ze,Et)=>{!ze.id&&ze.id!==0&&(console.error(`Layer at index ${Et} missing ID:`,ze),_e=!0),ze.annotations||(console.warn(`Layer at index ${Et} missing annotations array:`,ze),ze.annotations=[])}),_e&&console.error("Annotation layer validation failed. Layers:",u.value),!_e},m=vue.computed(()=>_e=>u.value.flatMap(Et=>Et.annotations||[]).find(Et=>Et.id===_e)),_=_e=>{i.value=_e},b=_e=>{t.value=_e},g=_e=>{n.value=_e},w=_e=>{r.value=_e},k=_e=>{a.value=_e},A=_e=>{s.value=_e},$=_e=>{o.value=_e},M=async _e=>{const ze=_e.packageId,Et=await useToken();let Cn=e.timeSeriesPublicUrl,kn=null;kn=await f(Cn,ze,Et),_({channels:kn.res,content:{id:ze}})},F=()=>_e=>{var Et;return((Et=_e==null?void 0:_e.content)==null?void 0:Et.state)==="READY"},O=_e=>{const ze=_e.map(Et=>(!Et.id&&Et.id!==0&&(console.warn("Annotation layer missing ID:",Et),Et.id=Math.random().toString(36).substr(2,9)),Et.annotations||(Et.annotations=[]),Et.name||(Et.name=`Layer ${Et.id}`),Et));u.value=ze,console.log("Set annotations with validated structure:",ze)},D=_e=>{if(!_e&&_e!==0){console.error("setActiveAnnotationLayer called with invalid layerId:",_e);return}l.value=_e,u.value.forEach(Et=>Et.selected=!1);const ze=findIndex(propEq("id",_e),u.value);ze>=0?(u.value[ze].selected=!0,console.log("Successfully set active layer:",u.value[ze])):console.error("Layer with ID not found:",_e,"Available layers:",u.value)},j=_e=>{if(u.value.forEach(ze=>{var Et;return(Et=ze.annotations)==null?void 0:Et.forEach(Cn=>Cn.selected=!1)}),_e.id){const ze=findIndex(propEq("id",_e.layer_id),u.value);if(ze>=0){const Et=findIndex(propEq("id",_e.id),u.value[ze].annotations);Et>=0&&(u.value[ze].annotations[Et].selected=!0)}}v.value=_e},z=_e=>{d.value=_e},T=_e=>{if(!_e.id&&_e.id!==0){console.error("Cannot create layer without ID:",_e);return}const ze={id:_e.id,name:_e.name||`Layer ${_e.id}`,description:_e.description||"",visible:_e.visible!==void 0?_e.visible:!0,selected:_e.selected||!1,annotations:_e.annotations||[],color:_e.color,hexColor:_e.hexColor,bkColor:_e.bkColor,selColor:_e.selColor,userId:_e.userId,..._e};u.value.push(ze),console.log("Created layer with validated structure:",ze)},L=_e=>{const ze=findIndex(propEq("id",_e.id),u.value);if(ze>=0){const Et=Object.assign(u.value[ze],_e);u.value[ze]=Et}},ie=_e=>{const ze=findIndex(propEq("id",_e.id),u.value);ze>=0&&u.value.splice(ze,1)},x=_e=>{const ze=findIndex(propEq("id",_e.layer_id),u.value);ze>=0&&(u.value[ze].annotations||(u.value[ze].annotations=[]),u.value[ze].annotations.push(_e),j(_e))},V=_e=>{const ze=findIndex(propEq("id",_e.layer_id),u.value);if(ze>=0){const Et=u.value[ze].annotations,Cn=findIndex(propEq("id",_e.id),Et);Cn>=0&&(Et[Cn]=_e)}},le=_e=>{const ze=findIndex(propEq("id",_e.layer_id),u.value);if(ze>=0){const Et=u.value[ze].annotations,Cn=findIndex(propEq("id",_e.id),Et);Cn>=0&&Et.splice(Cn,1)}},Y=(_e,ze,Et)=>{const Cn=t.value.find(kn=>kn.id===_e);Cn&&(Cn[ze]=Et)};return{viewerChannels:t,viewerMontageScheme:n,customMontageMap:r,workspaceMontages:a,viewerErrors:s,needsRerender:o,viewerAnnotations:u,activeAnnotationLayer:l,activeAnnotation:v,activeViewer:i,viewerActiveTool:d,config:e,getMontageMessageByName:c,viewerSelectedChannels:p,getViewerActiveLayer:h,getAnnotationById:m,setChannels:b,setViewerMontageScheme:g,setCustomMontageMap:w,setWorkspaceMontages:k,setViewerErrors:A,setAnnotations:O,setActiveAnnotationLayer:D,setActiveAnnotation:j,setActiveTool:z,createLayer:T,updateLayer:L,deleteLayer:ie,createAnnotation:x,updateAnnotation:V,deleteAnnotation:le,updateChannelProperty:Y,updateChannelVisibility:(_e,ze)=>{Y(_e,"visible",ze)},updateChannelSelection:(_e,ze)=>{Y(_e,"selected",ze)},updateChannelFilter:(_e,ze)=>{Y(_e,"filter",ze)},validateAnnotationLayers:y,resetViewer:()=>{t.value=[],n.value="NOT_MONTAGED",r.value={},a.value=[],s.value=null,u.value=[],l.value={},v.value={},d.value="POINTER",i.value={}},triggerRerender:_e=>{$({timestamp:Date.now(),cause:_e})},resetRerenderTrigger:()=>{o.value=null},isTSFileProcessed:F,fetchAndSetActiveViewer:M,setActiveViewer:_}});function useHandleLogout(e){if(useRoute().name==="docs-login")return;defaultTo(!1,prop("shouldShowToast",e));const n=defaultTo(!1,prop("shouldRedirect",e));this.clearState(),n&&this.$route.fullPath}const _isString=e=>Object.prototype.toString.call(e)==="[object String]",_trimValues=e=>{Object.keys(e).forEach(t=>{_isString(e[t])&&(e[t]=e[t].trim())})};function useSendXhr(e,t){if(!e)return Promise.reject({status:400,message:"Url is missing!"});const n=propOr("GET","method",t),r=propOr({},"header",t),a=Object.assign({},{"Content-type":"application/json"},r),s=prop("body",t);let o={headers:a,method:n};if(s){typeof s=="object"&&_trimValues(s);const i=JSON.stringify(s);o=Object.assign({},o,{body:i})}return fetch(e,o).then(i=>i.status>=400?Promise.reject(i):i.json().catch(()=>i))}function useHandleXhrError(e){const t=prop("status",e);let n;if(t===void 0){console.log(e);return}else n=e.status;if(n===400&&e.body)e.body.getReader().read().then(({done:r,value:a})=>{const s=a instanceof Uint8Array?String.fromCharCode.apply(null,a):a;compose(defaultTo(s),tryCatch(compose(prop("message"),JSON.parse),(o,i)=>i))(s)});else if(n===401)return useHandleLogout()}function useTsAnnotation(){const e=useViewerStore(),{viewerChannels:t,viewerAnnotations:n}=pinia.storeToRefs(e),r=u=>u.id||"",a=u=>{u.sort(function(v,d){return v.start<d.start?-1:v.start>d.start?1:0})};return{viewerChannels:t,viewerAnnotations:n,addAnnotation:async(u=null)=>{const l=u||activeAnnotation.value;if(console.log("🔧 useTsAnnotation: addAnnotation called with:",l),!l||!l.layer_id)throw new TypeError("Missing annotation data or layer_id",l);if(l.id)throw new TypeError("Trying to create an annotation that already exists",l.id);let v=l.start,d=l.duration||l.end-l.start;const f=l.label,c=l.description,p=l.layer_id;if(!f)throw new Error("Annotation label is required");if(v==null)throw new Error("Annotation start time is required");d<0&&(d=-d,v=v-d);let h=[];if(console.log("🔧 useTsAnnotation: Processing channelIds...",{hasChannelIds:l.channelIds&&Array.isArray(l.channelIds),allChannels:l.allChannels,providedChannelIds:l.channelIds,availableChannels:t.value.length}),l.allChannels){console.log("🔧 useTsAnnotation: allChannels=true, adding all visible channels");const b=e.activeViewer.value.channels;for(let g=0;g<b.length;g++){const k=b[g].content.id;h.push(k),console.log("🔧 useTsAnnotation: Added channel ID:",k)}}else if(l.channelIds&&Array.isArray(l.channelIds)&&l.channelIds.length>0)h=l.channelIds,console.log("🔧 useTsAnnotation: Using provided channelIds:",h);else{console.log("🔧 useTsAnnotation: Computing from selected channels");for(let b=0;b<t.value.length;b++){const g=t.value[b];if(g.selected&&g.visible){const w=r(g);h.push(w),console.log("🔧 useTsAnnotation: Added selected channel ID:",w)}}}console.log("🔧 useTsAnnotation: Final channelIds:",h);const y={label:f,name:f,description:c||"",start:Math.floor(v),end:Math.floor(v+d),channelIds:h};console.log("🔧 useTsAnnotation: API payload:",y);const m=e.activeViewer.value.content.id,_=`${e.config.apiUrl}/timeseries/${m}/layers/${p}/annotations`;console.log("🔧 useTsAnnotation: API URL:",_);try{const b=await useToken(),g=await fetch(`${_}?api_key=${b}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(y)});if(!g.ok){const $=await g.text();throw new Error(`HTTP ${g.status}: ${$}`)}const w=await g.json();console.log("🔧 useTsAnnotation: API success:",w);const k={name:"",id:w.id,label:w.label,description:w.description,start:w.start,duration:w.end-w.start,end:w.end,cStart:null,cEnd:null,selected:!0,channelIds:w.channelIds||h,allChannels:h.length===0||h.length>=t.value.length,layer_id:p,userId:w.userId};w.linkedPackage&&(k.linkedPackage=w.linkedPackage);let A=0;for(let $=0;$<n.value.length;$++)if(n.value[$].id===p){A=$;break}return e.createAnnotation(k),n.value[A]&&n.value[A].annotations&&a(n.value[A].annotations),k}catch(b){throw console.error("🔧 useTsAnnotation: Error creating annotation:",b),useHandleXhrError(b),b}},updateAnnotation:async(u=null)=>{const l=u||activeAnnotation.value;if(console.log("🔧 useTsAnnotation: updateAnnotation called with:",l),!l.id)throw new TypeError("Trying to update an annotation that doesn't exist on server",l.id);if(!l.layer_id)throw new TypeError("Missing layer_id for annotation update",l);let v=l.start,d=l.duration||l.end-l.start;d<0&&(d=-d,v=v-d);const f={label:l.label,description:l.description||"",start:Math.floor(v),end:Math.floor(v+d),channelIds:l.channelIds||[]};console.log("🔧 useTsAnnotation: Update API payload:",f);const c=e.activeViewer.value.content.id,p=`${e.config.apiUrl}/timeseries/${c}/layers/${l.layer_id}/annotations/${l.id}`;console.log("🔧 useTsAnnotation: Update API URL:",p);try{const h=await useToken(),y=await fetch(`${p}?api_key=${h}`,{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(f)});if(!y.ok){const b=await y.text();throw new Error(`HTTP ${y.status}: ${b}`)}const m=await y.json();console.log("🔧 useTsAnnotation: Update API success:",m);const _={...l,...m,duration:m.end-m.start};return e.updateAnnotation(_),m}catch(h){throw console.error("🔧 useTsAnnotation: Error updating annotation:",h),useHandleXhrError(h),h}},removeAnnotation:async u=>{if(!u||!u.id)throw new TypeError("Invalid annotation for deletion",u);let l="";if(u.layer?l=u.layer.id:l=u.layer_id,!l)throw new TypeError("Missing layer_id for annotation deletion",u);const v=e.activeViewer.value.content.id,d=`${e.config.apiUrl}/timeseries/${v}/layers/${l}/annotations/${u.id}`;console.log("🔧 useTsAnnotation: Delete API URL:",d);try{const f=await useToken(),c=await fetch(`${d}?api_key=${f}`,{method:"DELETE",headers:{Accept:"application/json"}});if(!c.ok){const p=await c.text();throw new Error(`HTTP ${c.status}: ${p}`)}return console.log("🔧 useTsAnnotation: Delete API success"),e.deleteAnnotation(u),!0}catch(f){throw console.error("🔧 useTsAnnotation: Error deleting annotation:",f),useHandleXhrError(f),f}},sortAnns:a,getChannelId:r}}const _export_sfc$1=(e,t)=>{const n=e.__vccOpts||e;for(const[r,a]of t)n[r]=a;return n},_hoisted_1$m={id:"channelCanvas"},_hoisted_2$a=["data-id"],_hoisted_3$9=["hidden"],_hoisted_4$6=["hidden"],_sfc_main$W={__name:"TSViewer",props:{pkg:{type:Object,default:()=>{}},isPreview:{type:Boolean,default:!1},sidePanelOpen:{type:Boolean,default:!1}},setup(e,{expose:t}){const n=vue.defineAsyncComponent(()=>Promise.resolve().then(()=>TSScrubber$1)),r=vue.defineAsyncComponent(()=>Promise.resolve().then(()=>TSViewerCanvas$1)),a=vue.defineAsyncComponent(()=>Promise.resolve().then(()=>TSViewerToolbar$1)),s=vue.defineAsyncComponent(()=>Promise.resolve().then(()=>TSFilterModal$1)),o=vue.defineAsyncComponent(()=>Promise.resolve().then(()=>TSAnnotationModal$1)),i=vue.defineAsyncComponent(()=>Promise.resolve().then(()=>TsAnnotationDeleteDialog$1)),u=vue.defineAsyncComponent(()=>Promise.resolve().then(()=>TSViewerLayerWindow$1)),l={TIMEUNIT:"microSeconds",XOFFSET:0,XGRIDSPACING:1e6,NRPXPERLABEL:150,USEREALTIME:!0,DEFAULTDPI:96,ANNOTATIONLABELHEIGHT:20,ROUNDDATAPIXELS:!1,MINMAXPOLYGON:!0,PAGESIZEDIVIDER:.5,PREFETCHPAGES:5,LIMITANNFETCH:500,USEMEDIAN:!1,CURSOROFFSET:5,SEGMENTSPAN:12096e8,MAXRECURSION:20,MAXDURATION:6e8,INITDURATION:15e6},v=e,d=useViewerStore(),{viewerChannels:f,needsRerender:c}=pinia.storeToRefs(d),{addAnnotation:p,updateAnnotation:h,removeAnnotation:y}=useTsAnnotation(),m=vue.ref(null),_=vue.ref(null),b=vue.ref(null),g=vue.ref(null),w=vue.ref(null),k=vue.ref(null),A=vue.ref(null),$=vue.ref(null),M=vue.ref(0),F=vue.ref(0),O=vue.ref(0),D=vue.ref(0),j=vue.ref(0),z=vue.ref(0),T=vue.ref(0),L=vue.ref(1),ie=vue.ref(1/10),x=vue.ref(!1),V=vue.ref(!1),le=vue.ref(null),Y=vue.ref(!1),re=vue.ref(!1),he=vue.computed(()=>d.activeViewer),Ce=vue.computed(()=>f.value.map(ue=>({...ue,selected:!!ue.selected}))),$e=vue.computed(()=>Ce.value.filter(ue=>ue.visible)),Ne=vue.computed(()=>{let ue=!1;return z.value/Pt.value<30&&(ue=!0),ue}),Pt=vue.computed(()=>$e.value.length),_e=async()=>{if(console.log("onresize..."),!m.value)return;const ue=document.getElementById("ts_viewer");if(!ue)return;const Fe=window.getComputedStyle(ue,null),Ve=parseInt(Fe.getPropertyValue("height")),bn=v.isPreview?0:100;M.value=Ve-bn,await vue.nextTick(),F.value=m.value.offsetWidth;const Ln=b.value;Ln&&(T.value=Ln.clientWidth,j.value=F.value-Ln.clientWidth-16,z.value=M.value-40)};vue.watch(()=>he.value,async(ue,Fe)=>{var Ve,bn,Ln;(Ve=_.value)!=null&&Ve.resetComponentState&&_.value.resetComponentState(),ue&&ue.channels&&ue.channels.length>0&&At(),On(),await vue.nextTick(),(bn=_.value)!=null&&bn.initSegmentSpans&&_.value.initSegmentSpans(),(Ln=_.value)!=null&&Ln.getAnnotations&&_.value.getAnnotations()},{immediate:!1,deep:!0}),vue.watch(Pt,(ue,Fe)=>{Fe!==void 0&&ue!==Fe&&(console.log(`Number of visible channels changed from ${Fe} to ${ue}`),setTimeout(()=>{var Ve;_e(),(Ve=g.value)!=null&&Ve.renderAll&&g.value.renderAll()},20))});const ze=ue=>{store.dispatch("viewerModule/setActiveAnnotation",ue).then(()=>{g.value.renderAnnotationCanvas(),x.value=!0})};vue.watch(c,ue=>{ue&&(console.log(`TSViewer: Re-rendering due to: ${ue.cause} (${ue.timestamp})`),vue.nextTick(()=>{var Fe;ue.cause==="channel-visibility"?setTimeout(()=>{var Ve;_e(),(Ve=g.value)!=null&&Ve.renderAll&&g.value.renderAll()},10):(Fe=g.value)!=null&&Fe.renderAll&&g.value.renderAll()}),d.resetRerenderTrigger(null))},{deep:!0});const Et=ue=>{ze(ue)},Cn=async ue=>{if(console.log("📍 TSViewer: onCreateUpdateAnnotation received:",ue),!ue||Object.keys(ue).length===0){console.error("🚨 TSViewer: Received empty annotation!");return}if(!ue.layer_id){console.error("🚨 TSViewer: annotation.layer_id is missing!",ue);return}x.value=!1;try{ue.id?(console.log("📍 TSViewer: Updating annotation via composable"),await h(ue),kn()):(console.log("📍 TSViewer: Creating annotation via composable"),await p(ue),xe()),console.log("📍 TSViewer: Annotation operation completed successfully")}catch(Fe){console.error("📍 TSViewer: Error creating/updating annotation:",Fe),x.value=!0}},kn=()=>{g.value.renderAnnotationCanvas()},In=ue=>{le.value=ue,Y.value=!0},Dn=async ue=>{Y.value=!1;try{await y(ue),Mn(),console.log("📍 TSViewer: Annotation deleted successfully")}catch(Fe){console.error("📍 TSViewer: Error deleting annotation:",Fe)}},Mn=()=>{g.value.renderAnnotationCanvas()},Ue=(ue,Fe,Ve,bn,Ln,jn)=>{if(console.log("📍 TSViewer: onAddAnnotation called with:",{startTime:ue,duration:Fe,allChannels:Ve,label:bn,description:Ln,layer:jn}),!jn||!jn.id){console.error("Invalid layer provided to onAddAnnotation:",jn);return}const Hn=d.viewerSelectedChannels||[],Gn=Ve?[]:Hn.map(Zn=>Zn.id),Jn={id:null,label:bn||"Event",description:Ln||"",start:Math.floor(ue),end:Math.floor(ue+Fe),duration:Math.floor(Fe),channelIds:Gn,allChannels:Ve,layer_id:jn.id,selected:!0,userId:null};console.log("📍 TSViewer: Created annotation object:",Jn),d.setActiveAnnotation(Jn),console.log("📍 TSViewer: Store now contains:",d.activeAnnotation),x.value=!0,console.log("📍 TSViewer: Modal opened with annotation data")},xe=()=>{g.value.renderAnnotationCanvas()},Dt=ue=>{g.value.createAnnotationLayer(ue)},kt=()=>{V.value=!1},_n=()=>{g.value.resetFocusedAnnotation(),g.value.renderAnnotationCanvas(),x.value=!1},Sn=()=>{re.value=!1},Tn=ue=>{ue.stopPropagation(),ue.preventDefault();const Fe=ue.detail.sourceEvent.metaKey;$n({channelId:ue.currentTarget.dataset.id,append:Fe}),g.value.renderAll()},An=()=>{O.value=g.value.getNextAnnotation()},qe=()=>{O.value=g.value.getPreviousAnnotation()},vn=ue=>{de(ue*1e6)},Nn=()=>{L.value=L.value*1.25},Pn=()=>{L.value=L.value*.8},xn=()=>{_.value.getAnnotations()},Bn=()=>{},Rn=()=>{console.log("Page forward triggered from toolbar");const ue=Math.max(O.value-3/4*D.value,A.value);pe(ue),vue.nextTick(()=>{var Fe;(Fe=g.value)==null||Fe.renderAll()})},qn=()=>{console.log("Page forward triggered from toolbar");const ue=Math.min(O.value+3/4*D.value,$.value-D.value);console.log(`Moving from ${O.value} to ${ue}`),pe(ue),vue.nextTick(()=>{var Fe,Ve;(Fe=g.value)!=null&&Fe.invalidate&&g.value.invalidate(),(Ve=g.value)!=null&&Ve.renderAll&&g.value.renderAll()})},Fn=ue=>{let Fe=g.value.rsPeriod;pe(ue.annotation.start-(ie.value*j.value-l.CURSOROFFSET)*Fe),vue.nextTick(()=>{var Ve;(Ve=g.value)==null||Ve.renderAll()})},$n=ue=>{const Fe=f.value.map(Ve=>{const bn=Ve.selected;return ue.append===!1&&(Ve.selected=!1),ue.channelId===Ve.id&&(Ve.selected=!bn),Ve});d.setChannels(Fe)},oe=(ue,Fe)=>{const Ve=f.value.map(bn=>(Fe===!1&&(bn.selected=!1),bn.id in ue&&(bn.selected=!0),bn));d.setChannels(Ve)},pe=ue=>{O.value=ue},S=ue=>{ie.value=ue},ae=ue=>{L.value=ue},de=ue=>{ue>l.MAXDURATION?D.value=l.MAXDURATION:D.value=ue},Oe=(ue,Fe,Ve)=>(l.DEFAULTDPI*window.devicePixelRatio/(Fe*Ve)/25.4).toFixed(1)+" "+ue.unit+"/mm",At=()=>{var Fe;const ue=(Fe=he.value)==null?void 0:Fe.channels;if(console.log("🔄 initTimeRange called with channels:",(ue==null?void 0:ue.length)||0),ue&&ue.length>0){A.value=ue[0].start,$.value=ue[0].end;for(let bn=1;bn<ue.length;bn++)ue[bn].start<A.value&&(A.value=ue[bn].start),ue[bn].end>$.value&&($.value=ue[bn].end);const Ve=O.value;O.value=A.value,console.log("📅 Time range initialized:",{ts_start:A.value,ts_end:$.value,oldStart:Ve,newStart:O.value,duration:D.value,startDate:new Date(A.value/1e3).toISOString(),endDate:new Date($.value/1e3).toISOString()})}else console.warn("⚠️ initTimeRange: No channels found in activeViewer")},En=()=>{At()},wn=ue=>{V.value=!0},hn=ue=>{const Fe=propOr([],"channels",ue),Ve=propOr("","filter",ue),bn=w.value;bn.onChannels=Fe,isEmpty$1(Ve)?(bn.input0=NaN,bn.input1=NaN,bn.selectedFilter=null,bn.selectedNotch=null):(bn.input0=Ve.input0,bn.input1=Ve.input1),re.value=!0},Lt=ue=>{g.value.setFilters(ue)},On=()=>{var ue,Fe;(ue=g.value)==null||ue.initViewerCanvas(),(Fe=g.value)==null||Fe.renderAll()};return vue.onMounted(()=>{En();const ue=document.getElementById("ts_viewer");if(!ue){console.warn("ts_viewer element not found");return}var Fe=window.getComputedStyle(ue,null);const Ve=parseInt(Fe.getPropertyValue("height")),bn=v.isPreview?0:100;M.value=Ve-bn,m.value&&(F.value=m.value.offsetWidth),window.addEventListener("resize",_e);const Ln=b.value;Ln&&(T.value=Ln.clientWidth,j.value=F.value-Ln.clientWidth-5-10,z.value=M.value-88),D.value=l.INITDURATION,On()}),vue.onBeforeUnmount(()=>{window.removeEventListener("resize",_e)}),t({openEditAnnotationDialog:ze,confirmDeleteAnnotation:In,selectAnnotation:Fn,selectChannel:$n,selectChannels:oe,openLayerWindow:wn,openFilterWindow:hn,setTimeseriesFilters:Lt}),(ue,Fe)=>(vue.openBlock(),vue.createElementBlock("div",{id:"ts_viewer",ref_key:"ts_viewer",ref:m,class:vue.normalizeClass([e.isPreview?"timeseries-viewer preview":"timeseries-viewer"])},[vue.createVNode(vue.unref(n),{ref_key:"scrubber",ref:_,ts_start:A.value,ts_end:$.value,"c-width":j.value,"label-width":T.value,"cursor-loc":ie.value,start:O.value,duration:D.value,constants:l,"active-viewer":he.value,onSetStart:pe},null,8,["ts_start","ts_end","c-width","label-width","cursor-loc","start","duration","active-viewer"]),vue.createElementVNode("div",_hoisted_1$m,[vue.createElementVNode("div",{id:"channelLabels",ref_key:"channelLabels",ref:b},[(vue.openBlock(!0),vue.createElementBlock(vue.Fragment,null,vue.renderList($e.value,Ve=>(vue.openBlock(),vue.createElementBlock("div",{key:Ve.displayName,class:"chLabelWrap","data-id":Ve.id,onTap:Tn},[vue.createElementVNode("div",{class:vue.normalizeClass([Ve.selected?"labelDiv selected":"labelDiv"])},vue.toDisplayString(Ve.displayName),3),vue.createElementVNode("div",{class:vue.normalizeClass(["chLabelIndWrap",[Ve.selected?"selected":""]]),hidden:Ne.value},[vue.createElementVNode("div",{class:"chLabelInd",hidden:Ne.value},vue.toDisplayString(Oe(Ve,L.value,Ve.rowScale)),9,_hoisted_4$6)],10,_hoisted_3$9)],40,_hoisted_2$a))),128))],512),vue.createVNode(vue.unref(r),{ref_key:"viewerCanvas",ref:g,window_height:M.value,window_width:F.value,duration:D.value,start:O.value,"c-width":j.value,"c-height":z.value,constants:l,"ts-start":A.value,"ts-end":$.value,"cursor-loc":ie.value,"global-zoom-mult":L.value,"active-viewer":he.value,onSetStart:pe,onSetCursor:S,onSetGlobalZoom:ae,onSetDuration:de,onChannelsInitialized:Bn,onAnnLayersInitialized:xn,onCloseAnnotationLayerWindow:kt,onAddAnnotation:Ue,onUpdateAnnotation:Et},null,8,["window_height","window_width","duration","start","c-width","c-height","ts-start","ts-end","cursor-loc","global-zoom-mult","active-viewer"])]),e.isPreview?vue.createCommentVNode("",!0):(vue.openBlock(),vue.createBlock(vue.unref(a),{key:0,constants:l,duration:D.value,start:O.value,onPageBack:Rn,onPageForward:qn,onIncrementZoom:Nn,onDecrementZoom:Pn,onUpdateDuration:vn,onNextAnnotation:An,onPreviousAnnotation:qe,onSetStart:pe},null,8,["duration","start"])),vue.createVNode(vue.unref(s),{ref_key:"filterWindow",ref:w,visible:re.value,"onUpdate:visible":Fe[0]||(Fe[0]=Ve=>re.value=Ve),onCloseWindow:Sn},null,8,["visible"]),vue.createVNode(vue.unref(o),{ref_key:"annotationModal",ref:k,visible:x.value,"onUpdate:visible":Fe[1]||(Fe[1]=Ve=>x.value=Ve),onCloseWindow:_n,onCreateUpdateAnnotation:Cn},null,8,["visible"]),vue.createVNode(vue.unref(i),{visible:Y.value,"delete-annotation":le.value,"onUpdate:visible":Fe[2]||(Fe[2]=Ve=>Y.value=Ve),onDelete:Dn},null,8,["visible","delete-annotation"]),vue.createVNode(vue.unref(u),{visible:V.value,onCloseWindow:kt,onCreateLayer:Dt},null,8,["visible"])],2))}},TSViewer=_export_sfc$1(_sfc_main$W,[["__scopeId","data-v-d5eda6cd"]]),index={install(e){e.component("TSViewer",TSViewer)}},_hoisted_1$l={class:"timeseries-scrubber"},_hoisted_2$9={class:"dateWrap"},_hoisted_3$8={class:"noselect"},_hoisted_4$5={id:"scrubber",noselect:""},_hoisted_5$4=["width","height"],_hoisted_6$4=["width","height"],_hoisted_7$3=["width","height"],_sfc_main$V={__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(e,{expose:t,emit:n}){const r=e,a=n,s=useViewerStore(),o=vue.ref(null),i=vue.ref(null),u=vue.ref(null),l=vue.ref(null),v=vue.ref(1),d=vue.ref(28),f=vue.ref(30),c=vue.ref(!1),p=vue.ref(""),h=vue.ref("point"),y=vue.ref(null),m=vue.ref([]),_=vue.ref([]),b=vue.ref([]),g=vue.ref(!1),w=vue.ref(0),k=vue.ref(0),A=vue.ref(0),$=vue.ref(0),M=vue.computed(()=>Y(r.ts_start)),F=vue.computed(()=>Y(r.ts_end)),O=vue.computed(()=>{if(p.value!=="")return p.value;if(r.start>0){const Ue=new Date(r.start/1e3).toUTCString();return Ue.substring(0,Ue.length-3)}return""}),D=vue.computed(()=>({width:r.labelWidth+r.cWidth-8+5+"px",height:"28px"})),j=vue.computed(()=>({width:r.labelWidth+r.cWidth-8+5+"px",height:"30px"})),z=vue.computed(()=>r.cWidth+r.labelWidth-8+5),T=vue.computed(()=>Math.floor((r.ts_end-r.ts_start)/r.cWidth));vue.watch(()=>r.start,()=>{Et()}),vue.watch(()=>r.duration,()=>{Et()}),vue.watch(()=>r.cWidth,()=>{Et()}),vue.watch(()=>r.activeViewer,(Ue,xe)=>{var Dt;Ue&&Ue!==xe&&(console.log("TSScrubber: ActiveViewer changed, resetting component state"),g.value=!0,L(),(Dt=Ue.content)!=null&&Dt.id?vue.nextTick(()=>{ze(),g.value=!1}):g.value=!1)},{deep:!0}),vue.watch(()=>s.viewerChannels,(Ue,xe)=>{var Dt,kt;Ue&&Ue.length>0&&!g.value&&(!xe||Ue.length!==xe.length||((Dt=Ue[0])==null?void 0:Dt.id)!==((kt=xe[0])==null?void 0:kt.id))&&(console.log("TSScrubber: Viewer channels changed, re-initializing segments"),ie(),vue.nextTick(()=>{Pt()}))},{deep:!0}),vue.watch(()=>s.viewerAnnotations,(Ue,xe)=>{var Dt;Ue&&Ue!==xe&&!g.value?(console.log("TSScrubber: Viewer annotations changed independently, re-fetching annotations"),vue.nextTick(()=>{ze()})):Ue&&Ue.length>0&&!xe&&((Dt=r.activeViewer)!=null&&Dt.content.id)&&(console.log("TSScrubber: Annotation layers now available, fetching annotations"),vue.nextTick(()=>{ze()}))},{deep:!0});const L=()=>{console.log("TSScrubber: Resetting component state"),m.value=[],ie(),c.value=!1,p.value="",h.value="point",x()},ie=()=>{console.log("TSScrubber: Resetting segment state"),b.value=new Array(5e3),b.value=b.value.fill(0,0,4999),_.value=[]},x=()=>{vue.nextTick(()=>{[i.value,u.value,l.value].forEach(xe=>{if(xe){const Dt=xe.getContext("2d");Dt&&Dt.clearRect(0,0,xe.width,xe.height)}})})},V=(Ue,xe,Dt)=>xe*(Ue+Dt),le=()=>{const Ue=l.value.getContext("2d"),xe=window.devicePixelRatio||1,Dt=Ue.webkitBackingStorePixelRatio||Ue.mozBackingStorePixelRatio||Ue.msBackingStorePixelRatio||Ue.oBackingStorePixelRatio||Ue.backingStorePixelRatio||1;return xe/Dt},Y=Ue=>{if(Ue>0)return Ue=Ue/1e3,Ue=new Date(Ue),("0"+Ue.getUTCHours()).slice(-2)+":"+("0"+Ue.getUTCMinutes()).slice(-2)+":"+("0"+Ue.getUTCSeconds()).slice(-2)},re=Ue=>{if(c.value){const Dt=(Ue.clientX-w.value)/r.cWidth*(r.ts_end-r.ts_start),kt=k.value+Dt;a("setStart",kt);const _n=new Date((Dt+r.ts_start)/1e3);p.value=_n.toUTCString()}else{const xe=l.value.getBoundingClientRect(),Dt=Ue.clientX-xe.left,kt=A.value+$.value,_n=h.value;Dt>A.value-10&&Dt<kt+10?(h.value="drag",l.value.setAttribute("dragme",!0),l.value.removeAttribute("resizeme")):(h.value="point",l.value.removeAttribute("dragme"),l.value.removeAttribute("resizeme"));const Tn=Dt/r.cWidth*(r.ts_end-r.ts_start)+r.ts_start,An=new Date(Tn/1e3).toUTCString();p.value=An.substring(0,An.length-3),_n!==h.value&&Et()}},he=()=>{c.value=!1},Ce=Ue=>{c.value=!0;const xe=l.value.getBoundingClientRect(),Dt=Ue.clientX-xe.left;w.value=Ue.clientX;const kt=Dt/z.value*(r.ts_end-r.ts_start);a("setStart",kt+r.ts_start),k.value=kt+r.ts_start},$e=()=>{c.value=!1},Ne=()=>{p.value=""},Pt=()=>{var Dt;if(!s.viewerChannels||s.viewerChannels.length===0){console.warn("TSScrubber: Cannot init segment spans - no viewer channels available");return}if(!r.ts_start||!r.ts_end){console.warn("TSScrubber: Cannot init segment spans - invalid time range");return}if(!((Dt=s.config)!=null&&Dt.timeSeriesApi)){console.warn("TSScrubber: Cannot init segment spans - no timeSeriesApi configured");return}console.log(`TSScrubber: Initializing segment spans for ${s.viewerChannels.length} channels`),ie();const Ue=Math.min(r.constants.SEGMENTSPAN,r.ts_end-r.ts_start),xe=s.viewerChannels;for(let kt=0;kt<xe.length;kt++)_e(xe[kt].id,kt,r.ts_start,r.ts_start+Ue,0)},_e=async(Ue,xe,Dt,kt,_n)=>{var Tn;const Sn=r.constants.MAXRECURSION;if(!((Tn=s.config)!=null&&Tn.timeSeriesApi)){console.warn("TSScrubber: Cannot request segment span - no timeSeriesApi configured");return}if(!Ue){console.warn("TSScrubber: Cannot request segment span - no channel ID provided");return}try{const An=await useToken(),qe=`${s.config.timeSeriesApi}/ts/retrieve/segments?session=${An}&channel=${Ue}&start=${Dt}&end=${kt}`;console.log(`TSScrubber: Fetching segments for channel ${Ue} (${xe})`);const vn=await useSendXhr(qe);if(!s.viewerChannels[xe]||s.viewerChannels[xe].id!==Ue){console.warn("TSScrubber: Channel mismatch detected, ignoring segment response (likely package switched)");return}let Nn=new Array(vn.length*2),Pn=0;for(let oe=0;oe<vn.length;oe++){Nn[Pn]=vn[oe][0],Nn[Pn+1]=vn[oe][1],Pn=Pn+2;const pe=Math.floor((vn[oe][0]-r.ts_start)/(r.ts_end-r.ts_start)*5e3),S=Math.ceil((vn[oe][1]-r.ts_start)/(r.ts_end-r.ts_start)*5e3);b.value.fill(1,pe,S)}let xn=0,Bn=!1,Rn=0;for(_.value=[];xn<b.value.length-1;){if(!b.value[xn]&&!Bn){xn++;continue}else b.value[xn]?Bn||(Rn=xn,Bn=!0):(_.value=_.value.concat([Rn,xn]),Bn=!1);xn++}Bn&&(_.value=_.value.concat([Rn,xn])),_.value=_.value.concat([5e3]);let qn=Nn[0],Fn=s.viewerChannels[xe];if(!Fn||Fn.id!==Ue){console.warn("TSScrubber: Channel configuration mismatch, skipping update");return}qn<Fn.dataSegments[Fn.dataSegments.length-1]&&(Nn.shift(),Nn.shift()),Fn.dataSegments=Fn.dataSegments.concat(Nn.sort((oe,pe)=>oe-pe)),s.updateChannelProperty(Fn.id,"dataSegments",Fn.dataSegments);let $n=kt-Dt;Dt+$n<r.ts_end&&_n<Sn?_e(Ue,xe,kt,kt+$n,_n+1):kn()}catch(An){console.error(`TSScrubber: Error fetching segments for channel ${Ue}:`,An),useHandleXhrError(An)}},ze=async()=>{var xe,Dt,kt;const Ue=(xe=r.activeViewer)==null?void 0:xe.content.id;if(!Ue){console.warn("TSScrubber: Cannot get annotations - no active viewer ID"),m.value=[];return}if(!((Dt=s.config)!=null&&Dt.apiUrl)){console.warn("TSScrubber: Cannot get annotations - no API URL configured"),m.value=[];return}if(!s.viewerAnnotations||s.viewerAnnotations.length===0){console.log("TSScrubber: No annotation layers available, skipping annotation fetch"),m.value=[],Et();return}try{const _n=await useToken(),Sn=map(Nn=>Nn.id,s.viewerAnnotations),Tn=r.ts_end;let qe=`${s.config.apiUrl}/timeseries/${Ue}/annotations/window`+`?api_key=${_n}&aggregation=count&start=${r.ts_start}&end=${r.ts_end}&period=${T.value}&mergePeriods=true`;for(let Nn in Sn)qe=qe+`&layerIds=${Sn[Nn]}`;console.log(`TSScrubber: Fetching annotations for viewer ${Ue}`);const vn=await useSendXhr(qe);((kt=r.activeViewer)==null?void 0:kt.content.id)===Ue?(m.value=vn,Et()):console.log("TSScrubber: Ignoring annotation response - viewer changed during fetch")}catch(_n){console.error("TSScrubber: Error fetching annotations:",_n),m.value=[],useHandleXhrError(_n),Et()}},Et=()=>{Cn(),In(),kn()},Cn=()=>{vue.nextTick(()=>{const Ue=l.value;if(!Ue){console.warn("iCanvas ref is missing, skipping render");return}const xe=Ue.getContext("2d");if(!xe){console.warn("2D context is not available");return}xe.setTransform(v.value,0,0,v.value,0,0),xe.clearRect(0,0,r.cWidth,f.value),A.value=(r.start-r.ts_start)/(r.ts_end-r.ts_start)*r.cWidth+.5|0,$.value=r.duration/(r.ts_end-r.ts_start)*r.cWidth+.5|0,xe.fillStyle="rgb(80,80,80)",xe.strokeStyle="rgb(80,80,80)",xe.strokeRect(A.value+.5,.5,$.value,f.value-1),xe.fillRect(A.value-2,f.value/2-5|0,2,10),xe.fillRect(A.value+$.value+1,f.value/2-5|0,2,10);const Dt=A.value+r.cursorLoc*$.value;Dt>A.value+.5&&(xe.strokeStyle="red",xe.beginPath(),xe.moveTo(Dt,0),xe.lineTo(Dt,f.value-1),xe.stroke())})},kn=()=>{vue.nextTick(()=>{const Ue=i.value;if(!Ue){console.warn("segmentsCanvas ref is missing, skipping renderSegments");return}const xe=Ue.getContext("2d");if(!xe){console.warn("Unable to get 2D context for segmentsCanvas, skipping renderSegments");return}xe.setTransform(v.value,0,0,v.value,0,0),xe.fillStyle=xe.createPattern(y.value,"repeat"),xe.clearRect(0,0,r.cWidth,f.value);for(let Dt=1;Dt<_.value.length;Dt+=2){const kt=r.cWidth*_.value[Dt]/5e3,_n=r.cWidth*_.value[Dt+1]/5e3;xe.fillRect(kt,2,_n-kt,f.value-6)}})},In=()=>{const Ue=u.value;if(!Ue){console.warn("annotationCanvas ref is missing, skipping renderTimelimeLine");return}const xe=Ue.getContext("2d");if(!xe){console.warn("Unable to get 2D context for annotationCanvas, skipping renderTimelimeLine");return}xe.setTransform(v.value,0,0,v.value,0,0),xe.clearRect(0,0,r.cWidth,d.value);const Dt=r.ts_start,kt=r.ts_end,_n=m.value;let Sn=0;const Tn=0,An=Math.floor((d.value-2)/Object.keys(_n).length-Tn),qe=s.viewerAnnotations;let vn="rgb(0,0,0)";for(const Nn in _n)if(_n.hasOwnProperty(Nn)){for(let Pn=0;Pn<qe.length;Pn++)if(qe[Pn].id===parseInt(Nn)){Sn=Pn,vn=qe[Pn].color;break}Dn(xe,Dt,kt,Tn,An,_n[Nn],Sn,vn)}},Dn=(Ue,xe,Dt,kt,_n,Sn,Tn,An)=>{vue.nextTick(()=>{Ue.setTransform(v.value,0,0,v.value,0,0),Ue.fillStyle=An;for(let qe=0;qe<Sn.length;qe++)if(Sn[qe].value>0){const vn=(Sn[qe].start-xe)/(Dt-xe)*r.cWidth;let Pn=(Sn[qe].end-xe)/(Dt-xe)*r.cWidth-vn;Pn<1&&(Pn=1);const xn=1+Tn*(_n-1+kt)+Tn;Ue.fillRect(vn,xn,Pn,_n)}})},Mn=()=>{const Ue=document.createElement("canvas"),xe=Ue.getContext("2d",{antialias:!0}),Dt="rgb(220,220,220)",kt=5,_n=kt,Sn=kt,Tn=10;return Ue.width=_n,Ue.height=Sn,xe.fillStyle=Dt,xe.beginPath(),xe.moveTo(0,Sn*(1/Tn)),xe.lineTo(_n*(1/Tn),0),xe.lineTo(0,0),xe.lineTo(0,Sn*(1/Tn)),xe.fill(),xe.beginPath(),xe.moveTo(_n,Sn*(1/Tn)),xe.lineTo(_n*(1/Tn),Sn),xe.lineTo(0,Sn),xe.lineTo(0,Sn*((Tn-1)/Tn)),xe.lineTo(_n*((Tn-1)/Tn),0),xe.lineTo(_n,0),xe.lineTo(_n,Sn*(1/Tn)),xe.fill(),xe.beginPath(),xe.moveTo(_n,Sn*((Tn-1)/Tn)),xe.lineTo(_n*((Tn-1)/Tn),Sn),xe.lineTo(_n,Sn),xe.lineTo(_n,Sn*((Tn-1)/Tn)),xe.fill(),Ue};return vue.onMounted(()=>{b.value=new Array(5e3),b.value=b.value.fill(0,0,4999),v.value=le(),y.value=Mn(),Cn()}),t({getAnnotations:ze,initSegmentSpans:Pt,render:Et,renderViewPort:Cn,renderSegments:kn,renderTimelimeLine:In,resetComponentState:L,resetSegmentState:ie,clearCanvases:x}),(Ue,xe)=>(vue.openBlock(),vue.createElementBlock("div",_hoisted_1$l,[vue.createElementVNode("div",_hoisted_2$9,[vue.createElementVNode("div",null,vue.toDisplayString(M.value),1),vue.createElementVNode("div",null,vue.toDisplayString(O.value),1),vue.createElementVNode("div",null,vue.toDisplayString(F.value),1)]),vue.createElementVNode("div",_hoisted_3$8,[vue.createElementVNode("div",_hoisted_4$5,[vue.createElementVNode("div",{id:"canvasWrap",ref_key:"canvasWrap",ref:o},[vue.createElementVNode("canvas",{id:"segmentsCanvas",class:"canvas",ref_key:"segmentsCanvas",ref:i,width:V(e.cWidth,v.value,0),height:V(f.value-2,v.value,0),style:vue.normalizeStyle(D.value)},null,12,_hoisted_5$4),vue.createElementVNode("canvas",{id:"annotationCanvas",class:"canvas",ref_key:"annotationCanvas",ref:u,width:V(e.cWidth,v.value,0),height:V(f.value-2,v.value,0),style:vue.normalizeStyle(D.value)},null,12,_hoisted_6$4),vue.createElementVNode("canvas",{id:"iCanvas",class:"canvas",ref_key:"iCanvas",ref:l,width:V(e.cWidth,v.value,0),height:V(f.value,v.value,0),onClick:xe[0]||(xe[0]=(...Dt)=>Ue._onTap&&Ue._onTap(...Dt)),onMousemove:re,onMousedown:Ce,onMouseup:he,onMouseenter:$e,onMouseout:Ne,style:vue.normalizeStyle(j.value)},null,44,_hoisted_7$3)],512)])])]))}},TSScrubber=_export_sfc$1(_sfc_main$V,[["__scopeId","data-v-8618a902"]]),TSScrubber$1=Object.freeze(Object.defineProperty({__proto__:null,default:TSScrubber},Symbol.toStringTag,{value:"Module"}));var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var src={exports:{}},indexLight={exports:{}},indexMinimal={},minimal={},aspromise,hasRequiredAspromise;function requireAspromise(){if(hasRequiredAspromise)return aspromise;hasRequiredAspromise=1,aspromise=e;function e(t,n){for(var r=new Array(arguments.length-1),a=0,s=2,o=!0;s<arguments.length;)r[a++]=arguments[s++];return new Promise(function(u,l){r[a]=function(d){if(o)if(o=!1,d)l(d);else{for(var f=new Array(arguments.length-1),c=0;c<f.length;)f[c++]=arguments[c];u.apply(null,f)}};try{t.apply(n||null,r)}catch(v){o&&(o=!1,l(v))}})}return aspromise}var base64={},hasRequiredBase64;function requireBase64(){return hasRequiredBase64||(hasRequiredBase64=1,function(e){var t=e;t.length=function(i){var u=i.length;if(!u)return 0;for(var l=0;--u%4>1&&i.charAt(u)==="=";)++l;return Math.ceil(i.length*3)/4-l};for(var n=new Array(64),r=new Array(123),a=0;a<64;)r[n[a]=a<26?a+65:a<52?a+71:a<62?a-4:a-59|43]=a++;t.encode=function(i,u,l){for(var v=null,d=[],f=0,c=0,p;u<l;){var h=i[u++];switch(c){case 0:d[f++]=n[h>>2],p=(h&3)<<4,c=1;break;case 1:d[f++]=n[p|h>>4],p=(h&15)<<2,c=2;break;case 2:d[f++]=n[p|h>>6],d[f++]=n[h&63],c=0;break}f>8191&&((v||(v=[])).push(String.fromCharCode.apply(String,d)),f=0)}return c&&(d[f++]=n[p],d[f++]=61,c===1&&(d[f++]=61)),v?(f&&v.push(String.fromCharCode.apply(String,d.slice(0,f))),v.join("")):String.fromCharCode.apply(String,d.slice(0,f))};var s="invalid encoding";t.decode=function(i,u,l){for(var v=l,d=0,f,c=0;c<i.length;){var p=i.charCodeAt(c++);if(p===61&&d>1)break;if((p=r[p])===void 0)throw Error(s);switch(d){case 0:f=p,d=1;break;case 1:u[l++]=f<<2|(p&48)>>4,f=p,d=2;break;case 2:u[l++]=(f&15)<<4|(p&60)>>2,f=p,d=3;break;case 3:u[l++]=(f&3)<<6|p,d=0;break}}if(d===1)throw Error(s);return l-v},t.test=function(i){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(i)}}(base64)),base64}var eventemitter,hasRequiredEventemitter;function requireEventemitter(){if(hasRequiredEventemitter)return eventemitter;hasRequiredEventemitter=1,eventemitter=e;function e(){this._listeners={}}return e.prototype.on=function(n,r,a){return(this._listeners[n]||(this._listeners[n]=[])).push({fn:r,ctx:a||this}),this},e.prototype.off=function(n,r){if(n===void 0)this._listeners={};else if(r===void 0)this._listeners[n]=[];else for(var a=this._listeners[n],s=0;s<a.length;)a[s].fn===r?a.splice(s,1):++s;return this},e.prototype.emit=function(n){var r=this._listeners[n];if(r){for(var a=[],s=1;s<arguments.length;)a.push(arguments[s++]);for(s=0;s<r.length;)r[s].fn.apply(r[s++].ctx,a)}return this},eventemitter}var float,hasRequiredFloat;function requireFloat(){if(hasRequiredFloat)return float;hasRequiredFloat=1,float=e(e);function e(s){return typeof Float32Array<"u"?function(){var o=new Float32Array([-0]),i=new Uint8Array(o.buffer),u=i[3]===128;function l(c,p,h){o[0]=c,p[h]=i[0],p[h+1]=i[1],p[h+2]=i[2],p[h+3]=i[3]}function v(c,p,h){o[0]=c,p[h]=i[3],p[h+1]=i[2],p[h+2]=i[1],p[h+3]=i[0]}s.writeFloatLE=u?l:v,s.writeFloatBE=u?v:l;function d(c,p){return i[0]=c[p],i[1]=c[p+1],i[2]=c[p+2],i[3]=c[p+3],o[0]}function f(c,p){return i[3]=c[p],i[2]=c[p+1],i[1]=c[p+2],i[0]=c[p+3],o[0]}s.readFloatLE=u?d:f,s.readFloatBE=u?f:d}():function(){function o(u,l,v,d){var f=l<0?1:0;if(f&&(l=-l),l===0)u(1/l>0?0:2147483648,v,d);else if(isNaN(l))u(2143289344,v,d);else if(l>34028234663852886e22)u((f<<31|2139095040)>>>0,v,d);else if(l<11754943508222875e-54)u((f<<31|Math.round(l/1401298464324817e-60))>>>0,v,d);else{var c=Math.floor(Math.log(l)/Math.LN2),p=Math.round(l*Math.pow(2,-c)*8388608)&8388607;u((f<<31|c+127<<23|p)>>>0,v,d)}}s.writeFloatLE=o.bind(null,t),s.writeFloatBE=o.bind(null,n);function i(u,l,v){var d=u(l,v),f=(d>>31)*2+1,c=d>>>23&255,p=d&8388607;return c===255?p?NaN:f*(1/0):c===0?f*1401298464324817e-60*p:f*Math.pow(2,c-150)*(p+8388608)}s.readFloatLE=i.bind(null,r),s.readFloatBE=i.bind(null,a)}(),typeof Float64Array<"u"?function(){var o=new Float64Array([-0]),i=new Uint8Array(o.buffer),u=i[7]===128;function l(c,p,h){o[0]=c,p[h]=i[0],p[h+1]=i[1],p[h+2]=i[2],p[h+3]=i[3],p[h+4]=i[4],p[h+5]=i[5],p[h+6]=i[6],p[h+7]=i[7]}function v(c,p,h){o[0]=c,p[h]=i[7],p[h+1]=i[6],p[h+2]=i[5],p[h+3]=i[4],p[h+4]=i[3],p[h+5]=i[2],p[h+6]=i[1],p[h+7]=i[0]}s.writeDoubleLE=u?l:v,s.writeDoubleBE=u?v:l;function d(c,p){return i[0]=c[p],i[1]=c[p+1],i[2]=c[p+2],i[3]=c[p+3],i[4]=c[p+4],i[5]=c[p+5],i[6]=c[p+6],i[7]=c[p+7],o[0]}function f(c,p){return i[7]=c[p],i[6]=c[p+1],i[5]=c[p+2],i[4]=c[p+3],i[3]=c[p+4],i[2]=c[p+5],i[1]=c[p+6],i[0]=c[p+7],o[0]}s.readDoubleLE=u?d:f,s.readDoubleBE=u?f:d}():function(){function o(u,l,v,d,f,c){var p=d<0?1:0;if(p&&(d=-d),d===0)u(0,f,c+l),u(1/d>0?0:2147483648,f,c+v);else if(isNaN(d))u(0,f,c+l),u(2146959360,f,c+v);else if(d>17976931348623157e292)u(0,f,c+l),u((p<<31|2146435072)>>>0,f,c+v);else{var h;if(d<22250738585072014e-324)h=d/5e-324,u(h>>>0,f,c+l),u((p<<31|h/4294967296)>>>0,f,c+v);else{var y=Math.floor(Math.log(d)/Math.LN2);y===1024&&(y=1023),h=d*Math.pow(2,-y),u(h*4503599627370496>>>0,f,c+l),u((p<<31|y+1023<<20|h*1048576&1048575)>>>0,f,c+v)}}}s.writeDoubleLE=o.bind(null,t,0,4),s.writeDoubleBE=o.bind(null,n,4,0);function i(u,l,v,d,f){var c=u(d,f+l),p=u(d,f+v),h=(p>>31)*2+1,y=p>>>20&2047,m=4294967296*(p&1048575)+c;return y===2047?m?NaN:h*(1/0):y===0?h*5e-324*m:h*Math.pow(2,y-1075)*(m+4503599627370496)}s.readDoubleLE=i.bind(null,r,0,4),s.readDoubleBE=i.bind(null,a,4,0)}(),s}function t(s,o,i){o[i]=s&255,o[i+1]=s>>>8&255,o[i+2]=s>>>16&255,o[i+3]=s>>>24}function n(s,o,i){o[i]=s>>>24,o[i+1]=s>>>16&255,o[i+2]=s>>>8&255,o[i+3]=s&255}function r(s,o){return(s[o]|s[o+1]<<8|s[o+2]<<16|s[o+3]<<24)>>>0}function a(s,o){return(s[o]<<24|s[o+1]<<16|s[o+2]<<8|s[o+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(e){}return null}return inquire_1}var utf8={},hasRequiredUtf8;function requireUtf8(){return hasRequiredUtf8||(hasRequiredUtf8=1,function(e){var t=e;t.length=function(r){for(var a=0,s=0,o=0;o<r.length;++o)s=r.charCodeAt(o),s<128?a+=1:s<2048?a+=2:(s&64512)===55296&&(r.charCodeAt(o+1)&64512)===56320?(++o,a+=4):a+=3;return a},t.read=function(r,a,s){var o=s-a;if(o<1)return"";for(var i=null,u=[],l=0,v;a<s;)v=r[a++],v<128?u[l++]=v:v>191&&v<224?u[l++]=(v&31)<<6|r[a++]&63:v>239&&v<365?(v=((v&7)<<18|(r[a++]&63)<<12|(r[a++]&63)<<6|r[a++]&63)-65536,u[l++]=55296+(v>>10),u[l++]=56320+(v&1023)):u[l++]=(v&15)<<12|(r[a++]&63)<<6|r[a++]&63,l>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,u)),l=0);return i?(l&&i.push(String.fromCharCode.apply(String,u.slice(0,l))),i.join("")):String.fromCharCode.apply(String,u.slice(0,l))},t.write=function(r,a,s){for(var o=s,i,u,l=0;l<r.length;++l)i=r.charCodeAt(l),i<128?a[s++]=i:i<2048?(a[s++]=i>>6|192,a[s++]=i&63|128):(i&64512)===55296&&((u=r.charCodeAt(l+1))&64512)===56320?(i=65536+((i&1023)<<10)+(u&1023),++l,a[s++]=i>>18|240,a[s++]=i>>12&63|128,a[s++]=i>>6&63|128,a[s++]=i&63|128):(a[s++]=i>>12|224,a[s++]=i>>6&63|128,a[s++]=i&63|128);return s-o}}(utf8)),utf8}var pool_1,hasRequiredPool;function requirePool(){if(hasRequiredPool)return pool_1;hasRequiredPool=1,pool_1=e;function e(t,n,r){var a=r||8192,s=a>>>1,o=null,i=a;return function(l){if(l<1||l>s)return t(l);i+l>a&&(o=t(a),i=0);var v=n.call(o,i,i+=l);return i&7&&(i=(i|7)+1),v}}return pool_1}var longbits,hasRequiredLongbits;function requireLongbits(){if(hasRequiredLongbits)return longbits;hasRequiredLongbits=1,longbits=t;var e=requireMinimal();function t(s,o){this.lo=s>>>0,this.hi=o>>>0}var n=t.zero=new t(0,0);n.toNumber=function(){return 0},n.zzEncode=n.zzDecode=function(){return this},n.length=function(){return 1};var r=t.zeroHash="\0\0\0\0\0\0\0\0";t.fromNumber=function(o){if(o===0)return n;var i=o<0;i&&(o=-o);var u=o>>>0,l=(o-u)/4294967296>>>0;return i&&(l=~l>>>0,u=~u>>>0,++u>4294967295&&(u=0,++l>4294967295&&(l=0))),new t(u,l)},t.from=function(o){if(typeof o=="number")return t.fromNumber(o);if(e.isString(o))if(e.Long)o=e.Long.fromString(o);else return t.fromNumber(parseInt(o,10));return o.low||o.high?new t(o.low>>>0,o.high>>>0):n},t.prototype.toNumber=function(o){if(!o&&this.hi>>>31){var i=~this.lo+1>>>0,u=~this.hi>>>0;return i||(u=u+1>>>0),-(i+u*4294967296)}return this.lo+this.hi*4294967296},t.prototype.toLong=function(o){return e.Long?new e.Long(this.lo|0,this.hi|0,!!o):{low:this.lo|0,high:this.hi|0,unsigned:!!o}};var a=String.prototype.charCodeAt;return t.fromHash=function(o){return o===r?n:new t((a.call(o,0)|a.call(o,1)<<8|a.call(o,2)<<16|a.call(o,3)<<24)>>>0,(a.call(o,4)|a.call(o,5)<<8|a.call(o,6)<<16|a.call(o,7)<<24)>>>0)},t.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)},t.prototype.zzEncode=function(){var o=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^o)>>>0,this.lo=(this.lo<<1^o)>>>0,this},t.prototype.zzDecode=function(){var o=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^o)>>>0,this.hi=(this.hi>>>1^o)>>>0,this},t.prototype.length=function(){var o=this.lo,i=(this.lo>>>28|this.hi<<4)>>>0,u=this.hi>>>24;return u===0?i===0?o<16384?o<128?1:2:o<2097152?3:4:i<16384?i<128?5:6:i<2097152?7:8:u<128?9:10},longbits}var hasRequiredMinimal;function requireMinimal(){return hasRequiredMinimal||(hasRequiredMinimal=1,function(e){var t=e;t.asPromise=requireAspromise(),t.base64=requireBase64(),t.EventEmitter=requireEventemitter(),t.float=requireFloat(),t.inquire=requireInquire(),t.utf8=requireUtf8(),t.pool=requirePool(),t.LongBits=requireLongbits(),t.isNode=!!(typeof commonjsGlobal<"u"&&commonjsGlobal&&commonjsGlobal.process&&commonjsGlobal.process.versions&&commonjsGlobal.process.versions.node),t.global=t.isNode&&commonjsGlobal||typeof window<"u"&&window||typeof self<"u"&&self||minimal,t.emptyArray=Object.freeze?Object.freeze([]):[],t.emptyObject=Object.freeze?Object.freeze({}):{},t.isInteger=Number.isInteger||function(s){return typeof s=="number"&&isFinite(s)&&Math.floor(s)===s},t.isString=function(s){return typeof s=="string"||s instanceof String},t.isObject=function(s){return s&&typeof s=="object"},t.isset=t.isSet=function(s,o){var i=s[o];return i!=null&&s.hasOwnProperty(o)?typeof i!="object"||(Array.isArray(i)?i.length:Object.keys(i).length)>0:!1},t.Buffer=function(){try{var a=t.inquire("buffer").Buffer;return a.prototype.utf8Write?a:null}catch{return null}}(),t._Buffer_from=null,t._Buffer_allocUnsafe=null,t.newBuffer=function(s){return typeof s=="number"?t.Buffer?t._Buffer_allocUnsafe(s):new t.Array(s):t.Buffer?t._Buffer_from(s):typeof Uint8Array>"u"?s:new Uint8Array(s)},t.Array=typeof Uint8Array<"u"?Uint8Array:Array,t.Long=t.global.dcodeIO&&t.global.dcodeIO.Long||t.global.Long||t.inquire("long"),t.key2Re=/^true|false|0|1$/,t.key32Re=/^-?(?:0|[1-9][0-9]*)$/,t.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,t.longToHash=function(s){return s?t.LongBits.from(s).toHash():t.LongBits.zeroHash},t.longFromHash=function(s,o){var i=t.LongBits.fromHash(s);return t.Long?t.Long.fromBits(i.lo,i.hi,o):i.toNumber(!!o)};function n(a,s,o){for(var i=Object.keys(s),u=0;u<i.length;++u)(a[i[u]]===void 0||!o)&&(a[i[u]]=s[i[u]]);return a}t.merge=n,t.lcFirst=function(s){return s.charAt(0).toLowerCase()+s.substring(1)};function r(a){function s(o,i){if(!(this instanceof s))return new s(o,i);Object.defineProperty(this,"message",{get:function(){return o}}),Error.captureStackTrace?Error.captureStackTrace(this,s):Object.defineProperty(this,"stack",{value:new Error().stack||""}),i&&n(this,i)}return s.prototype=Object.create(Error.prototype,{constructor:{value:s,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return a},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),s}t.newError=r,t.ProtocolError=r("ProtocolError"),t.oneOfGetter=function(s){for(var o={},i=0;i<s.length;++i)o[s[i]]=1;return function(){for(var u=Object.keys(this),l=u.length-1;l>-1;--l)if(o[u[l]]===1&&this[u[l]]!==void 0&&this[u[l]]!==null)return u[l]}},t.oneOfSetter=function(s){return function(o){for(var i=0;i<s.length;++i)s[i]!==o&&delete this[s[i]]}},t.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},t._configure=function(){var a=t.Buffer;if(!a){t._Buffer_from=t._Buffer_allocUnsafe=null;return}t._Buffer_from=a.from!==Uint8Array.from&&a.from||function(o,i){return new a(o,i)},t._Buffer_allocUnsafe=a.allocUnsafe||function(o){return new a(o)}}}(minimal)),minimal}var writer,hasRequiredWriter;function requireWriter(){if(hasRequiredWriter)return writer;hasRequiredWriter=1,writer=u;var e=requireMinimal(),t,n=e.LongBits,r=e.base64,a=e.utf8;function s(y,m,_){this.fn=y,this.len=m,this.next=void 0,this.val=_}function o(){}function i(y){this.head=y.head,this.tail=y.tail,this.len=y.len,this.next=y.states}function u(){this.len=0,this.head=new s(o,0,0),this.tail=this.head,this.states=null}var l=function(){return e.Buffer?function(){return(u.create=function(){return new t})()}:function(){return new u}};u.create=l(),u.alloc=function(m){return new e.Array(m)},e.Array!==Array&&(u.alloc=e.pool(u.alloc,e.Array.prototype.subarray)),u.prototype._push=function(m,_,b){return this.tail=this.tail.next=new s(m,_,b),this.len+=_,this};function v(y,m,_){m[_]=y&255}function d(y,m,_){for(;y>127;)m[_++]=y&127|128,y>>>=7;m[_]=y}function f(y,m){this.len=y,this.next=void 0,this.val=m}f.prototype=Object.create(s.prototype),f.prototype.fn=d,u.prototype.uint32=function(m){return this.len+=(this.tail=this.tail.next=new f((m=m>>>0)<128?1:m<16384?2:m<2097152?3:m<268435456?4:5,m)).len,this},u.prototype.int32=function(m){return m<0?this._push(c,10,n.fromNumber(m)):this.uint32(m)},u.prototype.sint32=function(m){return this.uint32((m<<1^m>>31)>>>0)};function c(y,m,_){for(;y.hi;)m[_++]=y.lo&127|128,y.lo=(y.lo>>>7|y.hi<<25)>>>0,y.hi>>>=7;for(;y.lo>127;)m[_++]=y.lo&127|128,y.lo=y.lo>>>7;m[_++]=y.lo}u.prototype.uint64=function(m){var _=n.from(m);return this._push(c,_.length(),_)},u.prototype.int64=u.prototype.uint64,u.prototype.sint64=function(m){var _=n.from(m).zzEncode();return this._push(c,_.length(),_)},u.prototype.bool=function(m){return this._push(v,1,m?1:0)};function p(y,m,_){m[_]=y&255,m[_+1]=y>>>8&255,m[_+2]=y>>>16&255,m[_+3]=y>>>24}u.prototype.fixed32=function(m){return this._push(p,4,m>>>0)},u.prototype.sfixed32=u.prototype.fixed32,u.prototype.fixed64=function(m){var _=n.from(m);return this._push(p,4,_.lo)._push(p,4,_.hi)},u.prototype.sfixed64=u.prototype.fixed64,u.prototype.float=function(m){return this._push(e.float.writeFloatLE,4,m)},u.prototype.double=function(m){return this._push(e.float.writeDoubleLE,8,m)};var h=e.Array.prototype.set?function(m,_,b){_.set(m,b)}:function(m,_,b){for(var g=0;g<m.length;++g)_[b+g]=m[g]};return u.prototype.bytes=function(m){var _=m.length>>>0;if(!_)return this._push(v,1,0);if(e.isString(m)){var b=u.alloc(_=r.length(m));r.decode(m,b,0),m=b}return this.uint32(_)._push(h,_,m)},u.prototype.string=function(m){var _=a.length(m);return _?this.uint32(_)._push(a.write,_,m):this._push(v,1,0)},u.prototype.fork=function(){return this.states=new i(this),this.head=this.tail=new s(o,0,0),this.len=0,this},u.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 s(o,0,0),this.len=0),this},u.prototype.ldelim=function(){var m=this.head,_=this.tail,b=this.len;return this.reset().uint32(b),b&&(this.tail.next=m.next,this.tail=_,this.len+=b),this},u.prototype.finish=function(){for(var m=this.head.next,_=this.constructor.alloc(this.len),b=0;m;)m.fn(m.val,_,b),b+=m.len,m=m.next;return _},u._configure=function(y){t=y,u.create=l(),t._configure()},writer}var writer_buffer,hasRequiredWriter_buffer;function requireWriter_buffer(){if(hasRequiredWriter_buffer)return writer_buffer;hasRequiredWriter_buffer=1,writer_buffer=n;var e=requireWriter();(n.prototype=Object.create(e.prototype)).constructor=n;var t=requireMinimal();function n(){e.call(this)}n._configure=function(){n.alloc=t._Buffer_allocUnsafe,n.writeBytesBuffer=t.Buffer&&t.Buffer.prototype instanceof Uint8Array&&t.Buffer.prototype.set.name==="set"?function(s,o,i){o.set(s,i)}:function(s,o,i){if(s.copy)s.copy(o,i,0,s.length);else for(var u=0;u<s.length;)o[i++]=s[u++]}},n.prototype.bytes=function(s){t.isString(s)&&(s=t._Buffer_from(s,"base64"));var o=s.length>>>0;return this.uint32(o),o&&this._push(n.writeBytesBuffer,o,s),this};function r(a,s,o){a.length<40?t.utf8.write(a,s,o):s.utf8Write?s.utf8Write(a,o):s.write(a,o)}return n.prototype.string=function(s){var o=t.Buffer.byteLength(s);return this.uint32(o),o&&this._push(r,o,s),this},n._configure(),writer_buffer}var reader,hasRequiredReader;function requireReader(){if(hasRequiredReader)return reader;hasRequiredReader=1,reader=s;var e=requireMinimal(),t,n=e.LongBits,r=e.utf8;function a(d,f){return RangeError("index out of range: "+d.pos+" + "+(f||1)+" > "+d.len)}function s(d){this.buf=d,this.pos=0,this.len=d.length}var o=typeof Uint8Array<"u"?function(f){if(f instanceof Uint8Array||Array.isArray(f))return new s(f);throw Error("illegal buffer")}:function(f){if(Array.isArray(f))return new s(f);throw Error("illegal buffer")},i=function(){return e.Buffer?function(c){return(s.create=function(h){return e.Buffer.isBuffer(h)?new t(h):o(h)})(c)}:o};s.create=i(),s.prototype._slice=e.Array.prototype.subarray||e.Array.prototype.slice,s.prototype.uint32=function(){var f=4294967295;return function(){if(f=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(f=(f|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(f=(f|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(f=(f|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(f=(f|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return f;if((this.pos+=5)>this.len)throw this.pos=this.len,a(this,10);return f}}(),s.prototype.int32=function(){return this.uint32()|0},s.prototype.sint32=function(){var f=this.uint32();return f>>>1^-(f&1)|0};function u(){var d=new n(0,0),f=0;if(this.len-this.pos>4){for(;f<4;++f)if(d.lo=(d.lo|(this.buf[this.pos]&127)<<f*7)>>>0,this.buf[this.pos++]<128)return d;if(d.lo=(d.lo|(this.buf[this.pos]&127)<<28)>>>0,d.hi=(d.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return d;f=0}else{for(;f<3;++f){if(this.pos>=this.len)throw a(this);if(d.lo=(d.lo|(this.buf[this.pos]&127)<<f*7)>>>0,this.buf[this.pos++]<128)return d}return d.lo=(d.lo|(this.buf[this.pos++]&127)<<f*7)>>>0,d}if(this.len-this.pos>4){for(;f<5;++f)if(d.hi=(d.hi|(this.buf[this.pos]&127)<<f*7+3)>>>0,this.buf[this.pos++]<128)return d}else for(;f<5;++f){if(this.pos>=this.len)throw a(this);if(d.hi=(d.hi|(this.buf[this.pos]&127)<<f*7+3)>>>0,this.buf[this.pos++]<128)return d}throw Error("invalid varint encoding")}s.prototype.bool=function(){return this.uint32()!==0};function l(d,f){return(d[f-4]|d[f-3]<<8|d[f-2]<<16|d[f-1]<<24)>>>0}s.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return l(this.buf,this.pos+=4)},s.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return l(this.buf,this.pos+=4)|0};function v(){if(this.pos+8>this.len)throw a(this,8);return new n(l(this.buf,this.pos+=4),l(this.buf,this.pos+=4))}return s.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var f=e.float.readFloatLE(this.buf,this.pos);return this.pos+=4,f},s.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var f=e.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,f},s.prototype.bytes=function(){var f=this.uint32(),c=this.pos,p=this.pos+f;if(p>this.len)throw a(this,f);if(this.pos+=f,Array.isArray(this.buf))return this.buf.slice(c,p);if(c===p){var h=e.Buffer;return h?h.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,c,p)},s.prototype.string=function(){var f=this.bytes();return r.read(f,0,f.length)},s.prototype.skip=function(f){if(typeof f=="number"){if(this.pos+f>this.len)throw a(this,f);this.pos+=f}else do if(this.pos>=this.len)throw a(this);while(this.buf[this.pos++]&128);return this},s.prototype.skipType=function(d){switch(d){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(d=this.uint32()&7)!==4;)this.skipType(d);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+d+" at offset "+this.pos)}return this},s._configure=function(d){t=d,s.create=i(),t._configure();var f=e.Long?"toLong":"toNumber";e.merge(s.prototype,{int64:function(){return u.call(this)[f](!1)},uint64:function(){return u.call(this)[f](!0)},sint64:function(){return u.call(this).zzDecode()[f](!1)},fixed64:function(){return v.call(this)[f](!0)},sfixed64:function(){return v.call(this)[f](!1)}})},reader}var reader_buffer,hasRequiredReader_buffer;function requireReader_buffer(){if(hasRequiredReader_buffer)return reader_buffer;hasRequiredReader_buffer=1,reader_buffer=n;var e=requireReader();(n.prototype=Object.create(e.prototype)).constructor=n;var t=requireMinimal();function n(r){e.call(this,r)}return n._configure=function(){t.Buffer&&(n.prototype._slice=t.Buffer.prototype.slice)},n.prototype.string=function(){var a=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+a,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+a,this.len))},n._configure(),reader_buffer}var rpc={},service$1,hasRequiredService$1;function requireService$1(){if(hasRequiredService$1)return service$1;hasRequiredService$1=1,service$1=t;var e=requireMinimal();(t.prototype=Object.create(e.EventEmitter.prototype)).constructor=t;function t(n,r,a){if(typeof n!="function")throw TypeError("rpcImpl must be a function");e.EventEmitter.call(this),this.rpcImpl=n,this.requestDelimited=!!r,this.responseDelimited=!!a}return t.prototype.rpcCall=function n(r,a,s,o,i){if(!o)throw TypeError("request must be specified");var u=this;if(!i)return e.asPromise(n,u,r,a,s,o);if(!u.rpcImpl){setTimeout(function(){i(Error("already ended"))},0);return}try{return u.rpcImpl(r,a[u.requestDelimited?"encodeDelimited":"encode"](o).finish(),function(v,d){if(v)return u.emit("error",v,r),i(v);if(d===null){u.end(!0);return}if(!(d instanceof s))try{d=s[u.responseDelimited?"decodeDelimited":"decode"](d)}catch(f){return u.emit("error",f,r),i(f)}return u.emit("data",d,r),i(null,d)})}catch(l){u.emit("error",l,r),setTimeout(function(){i(l)},0);return}},t.prototype.end=function(r){return this.rpcImpl&&(r||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this},service$1}var hasRequiredRpc;function requireRpc(){return hasRequiredRpc||(hasRequiredRpc=1,function(e){var t=e;t.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(e){var t=e;t.build="minimal",t.Writer=requireWriter(),t.BufferWriter=requireWriter_buffer(),t.Reader=requireReader(),t.BufferReader=requireReader_buffer(),t.util=requireMinimal(),t.rpc=requireRpc(),t.roots=requireRoots(),t.configure=n;function n(){t.util._configure(),t.Writer._configure(t.BufferWriter),t.Reader._configure(t.BufferReader)}n()}(indexMinimal)),indexMinimal}var types={},util={exports:{}},codegen_1,hasRequiredCodegen;function requireCodegen(){if(hasRequiredCodegen)return codegen_1;hasRequiredCodegen=1,codegen_1=e;function e(t,n){typeof t=="string"&&(n=t,t=void 0);var r=[];function a(o){if(typeof o!="string"){var i=s();if(e.verbose&&console.log("codegen: "+i),i="return "+i,o){for(var u=Object.keys(o),l=new Array(u.length+1),v=new Array(u.length),d=0;d<u.length;)l[d]=u[d],v[d]=o[u[d++]];return l[d]=i,Function.apply(null,l).apply(null,v)}return Function(i)()}for(var f=new Array(arguments.length-1),c=0;c<f.length;)f[c]=arguments[++c];if(c=0,o=o.replace(/%([%dfijs])/g,function(h,y){var m=f[c++];switch(y){case"d":case"f":return String(Number(m));case"i":return String(Math.floor(m));case"j":return JSON.stringify(m);case"s":return String(m)}return"%"}),c!==f.length)throw Error("parameter count mismatch");return r.push(o),a}function s(o){return"function "+(o||n||"")+"("+(t&&t.join(",")||"")+`){
2
2
  `+r.join(`
3
3
  `)+`
4
4
  }`}return a.toString=s,a}return e.verbose=!1,codegen_1}var fetch_1,hasRequiredFetch;function requireFetch(){if(hasRequiredFetch)return fetch_1;hasRequiredFetch=1,fetch_1=r;var e=requireAspromise(),t=requireInquire(),n=t("fs");function r(a,s,o){return typeof s=="function"?(o=s,s={}):s||(s={}),o?!s.xhr&&n&&n.readFile?n.readFile(a,function(u,l){return u&&typeof XMLHttpRequest<"u"?r.xhr(a,s,o):u?o(u):o(null,s.binary?l:l.toString("utf8"))}):r.xhr(a,s,o):e(r,this,a,s)}return r.xhr=function(s,o,i){var u=new XMLHttpRequest;u.onreadystatechange=function(){if(u.readyState===4){if(u.status!==0&&u.status!==200)return i(Error("status "+u.status));if(o.binary){var v=u.response;if(!v){v=[];for(var d=0;d<u.responseText.length;++d)v.push(u.responseText.charCodeAt(d)&255)}return i(null,typeof Uint8Array<"u"?new Uint8Array(v):v)}return i(null,u.responseText)}},o.binary&&("overrideMimeType"in u&&u.overrideMimeType("text/plain; charset=x-user-defined"),u.responseType="arraybuffer"),u.open("GET",s),u.send()},fetch_1}var path={},hasRequiredPath;function requirePath(){return hasRequiredPath||(hasRequiredPath=1,function(e){var t=e,n=t.isAbsolute=function(s){return/^(?:\/|\w+:)/.test(s)},r=t.normalize=function(s){s=s.replace(/\\/g,"/").replace(/\/{2,}/g,"/");var o=s.split("/"),i=n(s),u="";i&&(u=o.shift()+"/");for(var l=0;l<o.length;)o[l]===".."?l>0&&o[l-1]!==".."?o.splice(--l,2):i?o.splice(l,1):++l:o[l]==="."?o.splice(l,1):++l;return u+o.join("/")};t.resolve=function(s,o,i){return i||(o=r(o)),n(o)?o:(i||(s=r(s)),(s=s.replace(/(?:\/|^)[^/]+$/,"")).length?r(s+"/"+o):o)}}(path)),path}var namespace,hasRequiredNamespace;function requireNamespace(){if(hasRequiredNamespace)return namespace;hasRequiredNamespace=1,namespace=u;var e=requireObject();((u.prototype=Object.create(e.prototype)).constructor=u).className="Namespace";var t=requireField(),n=requireUtil(),r=requireOneof(),a,s,o;u.fromJSON=function(d,f){return new u(d,f.options).addJSON(f.nested)};function i(v,d){if(v&&v.length){for(var f={},c=0;c<v.length;++c)f[v[c].name]=v[c].toJSON(d);return f}}u.arrayToJSON=i,u.isReservedId=function(d,f){if(d){for(var c=0;c<d.length;++c)if(typeof d[c]!="string"&&d[c][0]<=f&&d[c][1]>f)return!0}return!1},u.isReservedName=function(d,f){if(d){for(var c=0;c<d.length;++c)if(d[c]===f)return!0}return!1};function u(v,d){e.call(this,v,d),this.nested=void 0,this._nestedArray=null,this._lookupCache={},this._needsRecursiveFeatureResolution=!0,this._needsRecursiveResolve=!0}function l(v){v._nestedArray=null,v._lookupCache={};for(var d=v;d=d.parent;)d._lookupCache={};return v}return Object.defineProperty(u.prototype,"nestedArray",{get:function(){return this._nestedArray||(this._nestedArray=n.toArray(this.nested))}}),u.prototype.toJSON=function(d){return n.toObject(["options",this.options,"nested",i(this.nestedArray,d)])},u.prototype.addJSON=function(d){var f=this;if(d)for(var c=Object.keys(d),p=0,h;p<c.length;++p)h=d[c[p]],f.add((h.fields!==void 0?a.fromJSON:h.values!==void 0?o.fromJSON:h.methods!==void 0?s.fromJSON:h.id!==void 0?t.fromJSON:u.fromJSON)(c[p],h));return this},u.prototype.get=function(d){return this.nested&&this.nested[d]||null},u.prototype.getEnum=function(d){if(this.nested&&this.nested[d]instanceof o)return this.nested[d].values;throw Error("no such enum: "+d)},u.prototype.add=function(d){if(!(d instanceof t&&d.extend!==void 0||d instanceof a||d instanceof r||d instanceof o||d instanceof s||d instanceof u))throw TypeError("object must be a valid nested object");if(!this.nested)this.nested={};else{var f=this.get(d.name);if(f)if(f instanceof u&&d instanceof u&&!(f instanceof a||f instanceof s)){for(var c=f.nestedArray,p=0;p<c.length;++p)d.add(c[p]);this.remove(f),this.nested||(this.nested={}),d.setOptions(f.options,!0)}else throw Error("duplicate name '"+d.name+"' in "+this)}this.nested[d.name]=d,this instanceof a||this instanceof s||this instanceof o||this instanceof t||d._edition||(d._edition=d._defaultEdition),this._needsRecursiveFeatureResolution=!0,this._needsRecursiveResolve=!0;for(var h=this;h=h.parent;)h._needsRecursiveFeatureResolution=!0,h._needsRecursiveResolve=!0;return d.onAdd(this),l(this)},u.prototype.remove=function(d){if(!(d instanceof e))throw TypeError("object must be a ReflectionObject");if(d.parent!==this)throw Error(d+" is not a member of "+this);return delete this.nested[d.name],Object.keys(this.nested).length||(this.nested=void 0),d.onRemove(this),l(this)},u.prototype.define=function(d,f){if(n.isString(d))d=d.split(".");else if(!Array.isArray(d))throw TypeError("illegal path");if(d&&d.length&&d[0]==="")throw Error("path must be relative");for(var c=this;d.length>0;){var p=d.shift();if(c.nested&&c.nested[p]){if(c=c.nested[p],!(c instanceof u))throw Error("path conflicts with non-namespace objects")}else c.add(c=new u(p))}return f&&c.addJSON(f),c},u.prototype.resolveAll=function(){if(!this._needsRecursiveResolve)return this;this._resolveFeaturesRecursive(this._edition);var d=this.nestedArray,f=0;for(this.resolve();f<d.length;)d[f]instanceof u?d[f++].resolveAll():d[f++].resolve();return this._needsRecursiveResolve=!1,this},u.prototype._resolveFeaturesRecursive=function(d){return this._needsRecursiveFeatureResolution?(this._needsRecursiveFeatureResolution=!1,d=this._edition||d,e.prototype._resolveFeaturesRecursive.call(this,d),this.nestedArray.forEach(f=>{f._resolveFeaturesRecursive(d)}),this):this},u.prototype.lookup=function(d,f,c){if(typeof f=="boolean"?(c=f,f=void 0):f&&!Array.isArray(f)&&(f=[f]),n.isString(d)&&d.length){if(d===".")return this.root;d=d.split(".")}else if(!d.length)return this;var p=d.join(".");if(d[0]==="")return this.root.lookup(d.slice(1),f);var h=this.root._fullyQualifiedObjects&&this.root._fullyQualifiedObjects["."+p];if(h&&(!f||f.indexOf(h.constructor)>-1)||(h=this._lookupImpl(d,p),h&&(!f||f.indexOf(h.constructor)>-1)))return h;if(c)return null;for(var y=this;y.parent;){if(h=y.parent._lookupImpl(d,p),h&&(!f||f.indexOf(h.constructor)>-1))return h;y=y.parent}return null},u.prototype._lookupImpl=function(d,f){if(Object.prototype.hasOwnProperty.call(this._lookupCache,f))return this._lookupCache[f];var c=this.get(d[0]),p=null;if(c)d.length===1?p=c:c instanceof u&&(d=d.slice(1),p=c._lookupImpl(d,d.join(".")));else for(var h=0;h<this.nestedArray.length;++h)this._nestedArray[h]instanceof u&&(c=this._nestedArray[h]._lookupImpl(d,f))&&(p=c);return this._lookupCache[f]=p,p},u.prototype.lookupType=function(d){var f=this.lookup(d,[a]);if(!f)throw Error("no such type: "+d);return f},u.prototype.lookupEnum=function(d){var f=this.lookup(d,[o]);if(!f)throw Error("no such Enum '"+d+"' in "+this);return f},u.prototype.lookupTypeOrEnum=function(d){var f=this.lookup(d,[a,o]);if(!f)throw Error("no such Type or Enum '"+d+"' in "+this);return f},u.prototype.lookupService=function(d){var f=this.lookup(d,[s]);if(!f)throw Error("no such Service '"+d+"' in "+this);return f},u._configure=function(v,d,f){a=v,s=d,o=f},namespace}var mapfield,hasRequiredMapfield;function requireMapfield(){if(hasRequiredMapfield)return mapfield;hasRequiredMapfield=1,mapfield=r;var e=requireField();((r.prototype=Object.create(e.prototype)).constructor=r).className="MapField";var t=requireTypes(),n=requireUtil();function r(a,s,o,i,u,l){if(e.call(this,a,s,i,void 0,void 0,u,l),!n.isString(o))throw TypeError("keyType must be a string");this.keyType=o,this.resolvedKeyType=null,this.map=!0}return r.fromJSON=function(s,o){return new r(s,o.id,o.keyType,o.type,o.options,o.comment)},r.prototype.toJSON=function(s){var o=s?!!s.keepComments:!1;return n.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",o?this.comment:void 0])},r.prototype.resolve=function(){if(this.resolved)return this;if(t.mapKey[this.keyType]===void 0)throw Error("invalid key type: "+this.keyType);return e.prototype.resolve.call(this)},r.d=function(s,o,i){return typeof i=="function"?i=n.decorateType(i).name:i&&typeof i=="object"&&(i=n.decorateEnum(i).name),function(l,v){n.decorateType(l.constructor).add(new r(v,s,o,i))}},mapfield}var method,hasRequiredMethod;function requireMethod(){if(hasRequiredMethod)return method;hasRequiredMethod=1,method=n;var e=requireObject();((n.prototype=Object.create(e.prototype)).constructor=n).className="Method";var t=requireUtil();function n(r,a,s,o,i,u,l,v,d){if(t.isObject(i)?(l=i,i=u=void 0):t.isObject(u)&&(l=u,u=void 0),!(a===void 0||t.isString(a)))throw TypeError("type must be a string");if(!t.isString(s))throw TypeError("requestType must be a string");if(!t.isString(o))throw TypeError("responseType must be a string");e.call(this,r,l),this.type=a||"rpc",this.requestType=s,this.requestStream=i?!0:void 0,this.responseType=o,this.responseStream=u?!0:void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=v,this.parsedOptions=d}return n.fromJSON=function(a,s){return new n(a,s.type,s.requestType,s.responseType,s.requestStream,s.responseStream,s.options,s.comment,s.parsedOptions)},n.prototype.toJSON=function(a){var s=a?!!a.keepComments:!1;return t.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",s?this.comment:void 0,"parsedOptions",this.parsedOptions])},n.prototype.resolve=function(){return this.resolved?this:(this.resolvedRequestType=this.parent.lookupType(this.requestType),this.resolvedResponseType=this.parent.lookupType(this.responseType),e.prototype.resolve.call(this))},method}var service,hasRequiredService;function requireService(){if(hasRequiredService)return service;hasRequiredService=1,service=a;var e=requireNamespace();((a.prototype=Object.create(e.prototype)).constructor=a).className="Service";var t=requireMethod(),n=requireUtil(),r=requireRpc();function a(o,i){e.call(this,o,i),this.methods={},this._methodsArray=null}a.fromJSON=function(i,u){var l=new a(i,u.options);if(u.methods)for(var v=Object.keys(u.methods),d=0;d<v.length;++d)l.add(t.fromJSON(v[d],u.methods[v[d]]));return u.nested&&l.addJSON(u.nested),u.edition&&(l._edition=u.edition),l.comment=u.comment,l._defaultEdition="proto3",l},a.prototype.toJSON=function(i){var u=e.prototype.toJSON.call(this,i),l=i?!!i.keepComments:!1;return n.toObject(["edition",this._editionToJSON(),"options",u&&u.options||void 0,"methods",e.arrayToJSON(this.methodsArray,i)||{},"nested",u&&u.nested||void 0,"comment",l?this.comment:void 0])},Object.defineProperty(a.prototype,"methodsArray",{get:function(){return this._methodsArray||(this._methodsArray=n.toArray(this.methods))}});function s(o){return o._methodsArray=null,o}return a.prototype.get=function(i){return this.methods[i]||e.prototype.get.call(this,i)},a.prototype.resolveAll=function(){if(!this._needsRecursiveResolve)return this;e.prototype.resolve.call(this);for(var i=this.methodsArray,u=0;u<i.length;++u)i[u].resolve();return this},a.prototype._resolveFeaturesRecursive=function(i){return this._needsRecursiveFeatureResolution?(i=this._edition||i,e.prototype._resolveFeaturesRecursive.call(this,i),this.methodsArray.forEach(u=>{u._resolveFeaturesRecursive(i)}),this):this},a.prototype.add=function(i){if(this.get(i.name))throw Error("duplicate name '"+i.name+"' in "+this);return i instanceof t?(this.methods[i.name]=i,i.parent=this,s(this)):e.prototype.add.call(this,i)},a.prototype.remove=function(i){if(i instanceof t){if(this.methods[i.name]!==i)throw Error(i+" is not a member of "+this);return delete this.methods[i.name],i.parent=null,s(this)}return e.prototype.remove.call(this,i)},a.prototype.create=function(i,u,l){for(var v=new r.Service(i,u,l),d=0,f;d<this.methodsArray.length;++d){var c=n.lcFirst((f=this._methodsArray[d]).resolve().name).replace(/[^$\w_]/g,"");v[c]=n.codegen(["r","c"],n.isReserved(c)?c+"_":c)("return this.rpcCall(m,q,s,r,c)")({m:f,q:f.resolvedRequestType.ctor,s:f.resolvedResponseType.ctor})}return v},service}var message,hasRequiredMessage;function requireMessage(){if(hasRequiredMessage)return message;hasRequiredMessage=1,message=t;var e=requireMinimal();function t(n){if(n)for(var r=Object.keys(n),a=0;a<r.length;++a)this[r[a]]=n[r[a]]}return t.create=function(r){return this.$type.create(r)},t.encode=function(r,a){return this.$type.encode(r,a)},t.encodeDelimited=function(r,a){return this.$type.encodeDelimited(r,a)},t.decode=function(r){return this.$type.decode(r)},t.decodeDelimited=function(r){return this.$type.decodeDelimited(r)},t.verify=function(r){return this.$type.verify(r)},t.fromObject=function(r){return this.$type.fromObject(r)},t.toObject=function(r,a){return this.$type.toObject(r,a)},t.prototype.toJSON=function(){return this.$type.toObject(this,e.toJSONOptions)},message}var decoder_1,hasRequiredDecoder;function requireDecoder(){if(hasRequiredDecoder)return decoder_1;hasRequiredDecoder=1,decoder_1=a;var e=require_enum(),t=requireTypes(),n=requireUtil();function r(s){return"missing required '"+s.name+"'"}function a(s){for(var o=n.codegen(["r","l","e"],s.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(s.fieldsArray.filter(function(f){return f.map}).length?",k,value":""))("while(r.pos<c){")("var t=r.uint32()")("if(t===e)")("break")("switch(t>>>3){"),i=0;i<s.fieldsArray.length;++i){var u=s._fieldsArray[i].resolve(),l=u.resolvedType instanceof e?"int32":u.type,v="m"+n.safeProp(u.name);o("case %i: {",u.id),u.map?(o("if(%s===util.emptyObject)",v)("%s={}",v)("var c2 = r.uint32()+r.pos"),t.defaults[u.keyType]!==void 0?o("k=%j",t.defaults[u.keyType]):o("k=null"),t.defaults[l]!==void 0?o("value=%j",t.defaults[l]):o("value=null"),o("while(r.pos<c2){")("var tag2=r.uint32()")("switch(tag2>>>3){")("case 1: k=r.%s(); break",u.keyType)("case 2:"),t.basic[l]===void 0?o("value=types[%i].decode(r,r.uint32())",i):o("value=r.%s()",l),o("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),t.long[u.keyType]!==void 0?o('%s[typeof k==="object"?util.longToHash(k):k]=value',v):o("%s[k]=value",v)):u.repeated?(o("if(!(%s&&%s.length))",v,v)("%s=[]",v),t.packed[l]!==void 0&&o("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos<c2)")("%s.push(r.%s())",v,l)("}else"),t.basic[l]===void 0?o(u.delimited?"%s.push(types[%i].decode(r,undefined,((t&~7)|4)))":"%s.push(types[%i].decode(r,r.uint32()))",v,i):o("%s.push(r.%s())",v,l)):t.basic[l]===void 0?o(u.delimited?"%s=types[%i].decode(r,undefined,((t&~7)|4))":"%s=types[%i].decode(r,r.uint32())",v,i):o("%s=r.%s()",v,l),o("break")("}")}for(o("default:")("r.skipType(t&7)")("break")("}")("}"),i=0;i<s._fieldsArray.length;++i){var d=s._fieldsArray[i];d.required&&o("if(!m.hasOwnProperty(%j))",d.name)("throw util.ProtocolError(%j,{instance:m})",r(d))}return o("return m")}return decoder_1}var verifier_1,hasRequiredVerifier;function requireVerifier(){if(hasRequiredVerifier)return verifier_1;hasRequiredVerifier=1,verifier_1=s;var e=require_enum(),t=requireUtil();function n(o,i){return o.name+": "+i+(o.repeated&&i!=="array"?"[]":o.map&&i!=="object"?"{k:"+o.keyType+"}":"")+" expected"}function r(o,i,u,l){if(i.resolvedType)if(i.resolvedType instanceof e){o("switch(%s){",l)("default:")("return%j",n(i,"enum value"));for(var v=Object.keys(i.resolvedType.values),d=0;d<v.length;++d)o("case %i:",i.resolvedType.values[v[d]]);o("break")("}")}else o("{")("var e=types[%i].verify(%s);",u,l)("if(e)")("return%j+e",i.name+".")("}");else switch(i.type){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":o("if(!util.isInteger(%s))",l)("return%j",n(i,"integer"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":o("if(!util.isInteger(%s)&&!(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))",l,l,l,l)("return%j",n(i,"integer|Long"));break;case"float":case"double":o('if(typeof %s!=="number")',l)("return%j",n(i,"number"));break;case"bool":o('if(typeof %s!=="boolean")',l)("return%j",n(i,"boolean"));break;case"string":o("if(!util.isString(%s))",l)("return%j",n(i,"string"));break;case"bytes":o('if(!(%s&&typeof %s.length==="number"||util.isString(%s)))',l,l,l)("return%j",n(i,"buffer"));break}return o}function a(o,i,u){switch(i.keyType){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":o("if(!util.key32Re.test(%s))",u)("return%j",n(i,"integer key"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":o("if(!util.key64Re.test(%s))",u)("return%j",n(i,"integer|Long key"));break;case"bool":o("if(!util.key2Re.test(%s))",u)("return%j",n(i,"boolean key"));break}return o}function s(o){var i=t.codegen(["m"],o.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),u=o.oneofsArray,l={};u.length&&i("var p={}");for(var v=0;v<o.fieldsArray.length;++v){var d=o._fieldsArray[v].resolve(),f="m"+t.safeProp(d.name);if(d.optional&&i("if(%s!=null&&m.hasOwnProperty(%j)){",f,d.name),d.map)i("if(!util.isObject(%s))",f)("return%j",n(d,"object"))("var k=Object.keys(%s)",f)("for(var i=0;i<k.length;++i){"),a(i,d,"k[i]"),r(i,d,v,f+"[k[i]]")("}");else if(d.repeated)i("if(!Array.isArray(%s))",f)("return%j",n(d,"array"))("for(var i=0;i<%s.length;++i){",f),r(i,d,v,f+"[i]")("}");else{if(d.partOf){var c=t.safeProp(d.partOf.name);l[d.partOf.name]===1&&i("if(p%s===1)",c)("return%j",d.partOf.name+": multiple values"),l[d.partOf.name]=1,i("p%s=1",c)}r(i,d,v,f)}d.optional&&i("}")}return i("return null")}return verifier_1}var converter={},hasRequiredConverter;function requireConverter(){return hasRequiredConverter||(hasRequiredConverter=1,function(e){var t=e,n=require_enum(),r=requireUtil();function a(o,i,u,l){var v=!1;if(i.resolvedType)if(i.resolvedType instanceof n){o("switch(d%s){",l);for(var d=i.resolvedType.values,f=Object.keys(d),c=0;c<f.length;++c)d[f[c]]===i.typeDefault&&!v&&(o("default:")('if(typeof(d%s)==="number"){m%s=d%s;break}',l,l,l),i.repeated||o("break"),v=!0),o("case%j:",f[c])("case %i:",d[f[c]])("m%s=%j",l,d[f[c]])("break");o("}")}else o('if(typeof d%s!=="object")',l)("throw TypeError(%j)",i.fullName+": object expected")("m%s=types[%i].fromObject(d%s)",l,u,l);else{var p=!1;switch(i.type){case"double":case"float":o("m%s=Number(d%s)",l,l);break;case"uint32":case"fixed32":o("m%s=d%s>>>0",l,l);break;case"int32":case"sint32":case"sfixed32":o("m%s=d%s|0",l,l);break;case"uint64":p=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":o("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",l,l,p)('else if(typeof d%s==="string")',l)("m%s=parseInt(d%s,10)",l,l)('else if(typeof d%s==="number")',l)("m%s=d%s",l,l)('else if(typeof d%s==="object")',l)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",l,l,l,p?"true":"");break;case"bytes":o('if(typeof d%s==="string")',l)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",l,l,l)("else if(d%s.length >= 0)",l)("m%s=d%s",l,l);break;case"string":o("m%s=String(d%s)",l,l);break;case"bool":o("m%s=Boolean(d%s)",l,l);break}}return o}t.fromObject=function(i){var u=i.fieldsArray,l=r.codegen(["d"],i.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!u.length)return l("return new this.ctor");l("var m=new this.ctor");for(var v=0;v<u.length;++v){var d=u[v].resolve(),f=r.safeProp(d.name);d.map?(l("if(d%s){",f)('if(typeof d%s!=="object")',f)("throw TypeError(%j)",d.fullName+": object expected")("m%s={}",f)("for(var ks=Object.keys(d%s),i=0;i<ks.length;++i){",f),a(l,d,v,f+"[ks[i]]")("}")("}")):d.repeated?(l("if(d%s){",f)("if(!Array.isArray(d%s))",f)("throw TypeError(%j)",d.fullName+": array expected")("m%s=[]",f)("for(var i=0;i<d%s.length;++i){",f),a(l,d,v,f+"[i]")("}")("}")):(d.resolvedType instanceof n||l("if(d%s!=null){",f),a(l,d,v,f),d.resolvedType instanceof n||l("}"))}return l("return m")};function s(o,i,u,l){if(i.resolvedType)i.resolvedType instanceof n?o("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",l,u,l,l,u,l,l):o("d%s=types[%i].toObject(m%s,o)",l,u,l);else{var v=!1;switch(i.type){case"double":case"float":o("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",l,l,l,l);break;case"uint64":v=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":o('if(typeof m%s==="number")',l)("d%s=o.longs===String?String(m%s):m%s",l,l,l)("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",l,l,l,l,v?"true":"",l);break;case"bytes":o("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",l,l,l,l,l);break;default:o("d%s=m%s",l,l);break}}return o}t.toObject=function(i){var u=i.fieldsArray.slice().sort(r.compareFieldsById);if(!u.length)return r.codegen()("return {}");for(var l=r.codegen(["m","o"],i.name+"$toObject")("if(!o)")("o={}")("var d={}"),v=[],d=[],f=[],c=0;c<u.length;++c)u[c].partOf||(u[c].resolve().repeated?v:u[c].map?d:f).push(u[c]);if(v.length){for(l("if(o.arrays||o.defaults){"),c=0;c<v.length;++c)l("d%s=[]",r.safeProp(v[c].name));l("}")}if(d.length){for(l("if(o.objects||o.defaults){"),c=0;c<d.length;++c)l("d%s={}",r.safeProp(d[c].name));l("}")}if(f.length){for(l("if(o.defaults){"),c=0;c<f.length;++c){var p=f[c],h=r.safeProp(p.name);if(p.resolvedType instanceof n)l("d%s=o.enums===String?%j:%j",h,p.resolvedType.valuesById[p.typeDefault],p.typeDefault);else if(p.long)l("if(util.Long){")("var n=new util.Long(%i,%i,%j)",p.typeDefault.low,p.typeDefault.high,p.typeDefault.unsigned)("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n",h)("}else")("d%s=o.longs===String?%j:%i",h,p.typeDefault.toString(),p.typeDefault.toNumber());else if(p.bytes){var y="["+Array.prototype.slice.call(p.typeDefault).join(",")+"]";l("if(o.bytes===String)d%s=%j",h,String.fromCharCode.apply(String,p.typeDefault))("else{")("d%s=%s",h,y)("if(o.bytes!==Array)d%s=util.newBuffer(d%s)",h,h)("}")}else l("d%s=%j",h,p.typeDefault)}l("}")}var m=!1;for(c=0;c<u.length;++c){var p=u[c],_=i._fieldsArray.indexOf(p),h=r.safeProp(p.name);p.map?(m||(m=!0,l("var ks2")),l("if(m%s&&(ks2=Object.keys(m%s)).length){",h,h)("d%s={}",h)("for(var j=0;j<ks2.length;++j){"),s(l,p,_,h+"[ks2[j]]")("}")):p.repeated?(l("if(m%s&&m%s.length){",h,h)("d%s=[]",h)("for(var j=0;j<m%s.length;++j){",h),s(l,p,_,h+"[j]")("}")):(l("if(m%s!=null&&m.hasOwnProperty(%j)){",h,p.name),s(l,p,_,h),p.partOf&&l("if(o.oneofs)")("d%s=%j",r.safeProp(p.partOf.name),p.name)),l("}")}return l("return d")}}(converter)),converter}var wrappers={},hasRequiredWrappers;function requireWrappers(){return hasRequiredWrappers||(hasRequiredWrappers=1,function(e){var t=e,n=requireMessage();t[".google.protobuf.Any"]={fromObject:function(r){if(r&&r["@type"]){var a=r["@type"].substring(r["@type"].lastIndexOf("/")+1),s=this.lookup(a);if(s){var o=r["@type"].charAt(0)==="."?r["@type"].slice(1):r["@type"];return o.indexOf("/")===-1&&(o="/"+o),this.create({type_url:o,value:s.encode(s.fromObject(r)).finish()})}}return this.fromObject(r)},toObject:function(r,a){var s="type.googleapis.com/",o="",i="";if(a&&a.json&&r.type_url&&r.value){i=r.type_url.substring(r.type_url.lastIndexOf("/")+1),o=r.type_url.substring(0,r.type_url.lastIndexOf("/")+1);var u=this.lookup(i);u&&(r=u.decode(r.value))}if(!(r instanceof this.ctor)&&r instanceof n){var l=r.$type.toObject(r,a),v=r.$type.fullName[0]==="."?r.$type.fullName.slice(1):r.$type.fullName;return o===""&&(o=s),i=o+v,l["@type"]=i,l}return this.toObject(r,a)}}}(wrappers)),wrappers}var type,hasRequiredType;function requireType(){if(hasRequiredType)return type;hasRequiredType=1,type=h;var e=requireNamespace();((h.prototype=Object.create(e.prototype)).constructor=h).className="Type";var t=require_enum(),n=requireOneof(),r=requireField(),a=requireMapfield(),s=requireService(),o=requireMessage(),i=requireReader(),u=requireWriter(),l=requireUtil(),v=requireEncoder(),d=requireDecoder(),f=requireVerifier(),c=requireConverter(),p=requireWrappers();function h(m,_){e.call(this,m,_),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(h.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var m=Object.keys(this.fields),_=0;_<m.length;++_){var b=this.fields[m[_]],g=b.id;if(this._fieldsById[g])throw Error("duplicate id "+g+" in "+this);this._fieldsById[g]=b}return this._fieldsById}},fieldsArray:{get:function(){return this._fieldsArray||(this._fieldsArray=l.toArray(this.fields))}},oneofsArray:{get:function(){return this._oneofsArray||(this._oneofsArray=l.toArray(this.oneofs))}},ctor:{get:function(){return this._ctor||(this.ctor=h.generateConstructor(this)())},set:function(m){var _=m.prototype;_ instanceof o||((m.prototype=new o).constructor=m,l.merge(m.prototype,_)),m.$type=m.prototype.$type=this,l.merge(m,o,!0),this._ctor=m;for(var b=0;b<this.fieldsArray.length;++b)this._fieldsArray[b].resolve();var g={};for(b=0;b<this.oneofsArray.length;++b)g[this._oneofsArray[b].resolve().name]={get:l.oneOfGetter(this._oneofsArray[b].oneof),set:l.oneOfSetter(this._oneofsArray[b].oneof)};b&&Object.defineProperties(m.prototype,g)}}}),h.generateConstructor=function(_){for(var b=l.codegen(["p"],_.name),g=0,w;g<_.fieldsArray.length;++g)(w=_._fieldsArray[g]).map?b("this%s={}",l.safeProp(w.name)):w.repeated&&b("this%s=[]",l.safeProp(w.name));return b("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 y(m){return m._fieldsById=m._fieldsArray=m._oneofsArray=null,delete m.encode,delete m.decode,delete m.verify,m}return h.fromJSON=function(_,b){var g=new h(_,b.options);g.extensions=b.extensions,g.reserved=b.reserved;for(var w=Object.keys(b.fields),k=0;k<w.length;++k)g.add((typeof b.fields[w[k]].keyType<"u"?a.fromJSON:r.fromJSON)(w[k],b.fields[w[k]]));if(b.oneofs)for(w=Object.keys(b.oneofs),k=0;k<w.length;++k)g.add(n.fromJSON(w[k],b.oneofs[w[k]]));if(b.nested)for(w=Object.keys(b.nested),k=0;k<w.length;++k){var A=b.nested[w[k]];g.add((A.id!==void 0?r.fromJSON:A.fields!==void 0?h.fromJSON:A.values!==void 0?t.fromJSON:A.methods!==void 0?s.fromJSON:e.fromJSON)(w[k],A))}return b.extensions&&b.extensions.length&&(g.extensions=b.extensions),b.reserved&&b.reserved.length&&(g.reserved=b.reserved),b.group&&(g.group=!0),b.comment&&(g.comment=b.comment),b.edition&&(g._edition=b.edition),g._defaultEdition="proto3",g},h.prototype.toJSON=function(_){var b=e.prototype.toJSON.call(this,_),g=_?!!_.keepComments:!1;return l.toObject(["edition",this._editionToJSON(),"options",b&&b.options||void 0,"oneofs",e.arrayToJSON(this.oneofsArray,_),"fields",e.arrayToJSON(this.fieldsArray.filter(function(w){return!w.declaringField}),_)||{},"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",b&&b.nested||void 0,"comment",g?this.comment:void 0])},h.prototype.resolveAll=function(){if(!this._needsRecursiveResolve)return this;e.prototype.resolveAll.call(this);var _=this.oneofsArray;for(g=0;g<_.length;)_[g++].resolve();for(var b=this.fieldsArray,g=0;g<b.length;)b[g++].resolve();return this},h.prototype._resolveFeaturesRecursive=function(_){return this._needsRecursiveFeatureResolution?(_=this._edition||_,e.prototype._resolveFeaturesRecursive.call(this,_),this.oneofsArray.forEach(b=>{b._resolveFeatures(_)}),this.fieldsArray.forEach(b=>{b._resolveFeatures(_)}),this):this},h.prototype.get=function(_){return this.fields[_]||this.oneofs&&this.oneofs[_]||this.nested&&this.nested[_]||null},h.prototype.add=function(_){if(this.get(_.name))throw Error("duplicate name '"+_.name+"' in "+this);if(_ instanceof r&&_.extend===void 0){if(this._fieldsById?this._fieldsById[_.id]:this.fieldsById[_.id])throw Error("duplicate id "+_.id+" in "+this);if(this.isReservedId(_.id))throw Error("id "+_.id+" is reserved in "+this);if(this.isReservedName(_.name))throw Error("name '"+_.name+"' is reserved in "+this);return _.parent&&_.parent.remove(_),this.fields[_.name]=_,_.message=this,_.onAdd(this),y(this)}return _ instanceof n?(this.oneofs||(this.oneofs={}),this.oneofs[_.name]=_,_.onAdd(this),y(this)):e.prototype.add.call(this,_)},h.prototype.remove=function(_){if(_ instanceof r&&_.extend===void 0){if(!this.fields||this.fields[_.name]!==_)throw Error(_+" is not a member of "+this);return delete this.fields[_.name],_.parent=null,_.onRemove(this),y(this)}if(_ instanceof n){if(!this.oneofs||this.oneofs[_.name]!==_)throw Error(_+" is not a member of "+this);return delete this.oneofs[_.name],_.parent=null,_.onRemove(this),y(this)}return e.prototype.remove.call(this,_)},h.prototype.isReservedId=function(_){return e.isReservedId(this.reserved,_)},h.prototype.isReservedName=function(_){return e.isReservedName(this.reserved,_)},h.prototype.create=function(_){return new this.ctor(_)},h.prototype.setup=function(){for(var _=this.fullName,b=[],g=0;g<this.fieldsArray.length;++g)b.push(this._fieldsArray[g].resolve().resolvedType);this.encode=v(this)({Writer:u,types:b,util:l}),this.decode=d(this)({Reader:i,types:b,util:l}),this.verify=f(this)({types:b,util:l}),this.fromObject=c.fromObject(this)({types:b,util:l}),this.toObject=c.toObject(this)({types:b,util:l});var w=p[_];if(w){var k=Object.create(this);k.fromObject=this.fromObject,this.fromObject=w.fromObject.bind(k),k.toObject=this.toObject,this.toObject=w.toObject.bind(k)}return this},h.prototype.encode=function(_,b){return this.setup().encode(_,b)},h.prototype.encodeDelimited=function(_,b){return this.encode(_,b&&b.len?b.fork():b).ldelim()},h.prototype.decode=function(_,b){return this.setup().decode(_,b)},h.prototype.decodeDelimited=function(_){return _ instanceof i||(_=i.create(_)),this.decode(_,_.uint32())},h.prototype.verify=function(_){return this.setup().verify(_)},h.prototype.fromObject=function(_){return this.setup().fromObject(_)},h.prototype.toObject=function(_,b){return this.setup().toObject(_,b)},h.d=function(_){return function(g){l.decorateType(g,_)}},type}var root$1,hasRequiredRoot;function requireRoot(){if(hasRequiredRoot)return root$1;hasRequiredRoot=1,root$1=u;var e=requireNamespace();((u.prototype=Object.create(e.prototype)).constructor=u).className="Root";var t=requireField(),n=require_enum(),r=requireOneof(),a=requireUtil(),s,o,i;function u(f){e.call(this,"",f),this.deferred=[],this.files=[],this._edition="proto2",this._fullyQualifiedObjects={}}u.fromJSON=function(c,p){return p||(p=new u),c.options&&p.setOptions(c.options),p.addJSON(c.nested).resolveAll()},u.prototype.resolvePath=a.path.resolve,u.prototype.fetch=a.fetch;function l(){}u.prototype.load=function f(c,p,h){typeof p=="function"&&(h=p,p=void 0);var y=this;if(!h)return a.asPromise(f,y,c,p);var m=h===l;function _(M,F){if(h){if(m)throw M;F&&F.resolveAll();var O=h;h=null,O(M,F)}}function b(M){var F=M.lastIndexOf("google/protobuf/");if(F>-1){var O=M.substring(F);if(O in i)return O}return null}function g(M,F){try{if(a.isString(F)&&F.charAt(0)==="{"&&(F=JSON.parse(F)),!a.isString(F))y.setOptions(F.options).addJSON(F.nested);else{o.filename=M;var O=o(F,y,p),D,j=0;if(O.imports)for(;j<O.imports.length;++j)(D=b(O.imports[j])||y.resolvePath(M,O.imports[j]))&&w(D);if(O.weakImports)for(j=0;j<O.weakImports.length;++j)(D=b(O.weakImports[j])||y.resolvePath(M,O.weakImports[j]))&&w(D,!0)}}catch(z){_(z)}!m&&!k&&_(null,y)}function w(M,F){if(M=b(M)||M,!(y.files.indexOf(M)>-1)){if(y.files.push(M),M in i){m?g(M,i[M]):(++k,setTimeout(function(){--k,g(M,i[M])}));return}if(m){var O;try{O=a.fs.readFileSync(M).toString("utf8")}catch(D){F||_(D);return}g(M,O)}else++k,y.fetch(M,function(D,j){if(--k,!!h){if(D){F?k||_(null,y):_(D);return}g(M,j)}})}}var k=0;a.isString(c)&&(c=[c]);for(var A=0,$;A<c.length;++A)($=y.resolvePath("",c[A]))&&w($);return m?(y.resolveAll(),y):(k||_(null,y),y)},u.prototype.loadSync=function(c,p){if(!a.isNode)throw Error("not supported");return this.load(c,p,l)},u.prototype.resolveAll=function(){if(!this._needsRecursiveResolve)return this;if(this.deferred.length)throw Error("unresolvable extensions: "+this.deferred.map(function(c){return"'extend "+c.extend+"' in "+c.parent.fullName}).join(", "));return e.prototype.resolveAll.call(this)};var v=/^[A-Z]/;function d(f,c){var p=c.parent.lookup(c.extend);if(p){var h=new t(c.fullName,c.id,c.type,c.rule,void 0,c.options);return p.get(h.name)||(h.declaringField=c,c.extensionField=h,p.add(h)),!0}return!1}return u.prototype._handleAdd=function(c){if(c instanceof t)c.extend!==void 0&&!c.extensionField&&(d(this,c)||this.deferred.push(c));else if(c instanceof n)v.test(c.name)&&(c.parent[c.name]=c.values);else if(!(c instanceof r)){if(c instanceof s)for(var p=0;p<this.deferred.length;)d(this,this.deferred[p])?this.deferred.splice(p,1):++p;for(var h=0;h<c.nestedArray.length;++h)this._handleAdd(c._nestedArray[h]);v.test(c.name)&&(c.parent[c.name]=c)}(c instanceof s||c instanceof n||c instanceof t)&&(this._fullyQualifiedObjects[c.fullName]=c)},u.prototype._handleRemove=function(c){if(c instanceof t){if(c.extend!==void 0)if(c.extensionField)c.extensionField.parent.remove(c.extensionField),c.extensionField=null;else{var p=this.deferred.indexOf(c);p>-1&&this.deferred.splice(p,1)}}else if(c instanceof n)v.test(c.name)&&delete c.parent[c.name];else if(c instanceof e){for(var h=0;h<c.nestedArray.length;++h)this._handleRemove(c._nestedArray[h]);v.test(c.name)&&delete c.parent[c.name]}delete this._fullyQualifiedObjects[c.fullName]},u._configure=function(f,c,p){s=f,o=c,i=p},root$1}var hasRequiredUtil;function requireUtil(){if(hasRequiredUtil)return util.exports;hasRequiredUtil=1;var e=util.exports=requireMinimal(),t=requireRoots(),n,r;e.codegen=requireCodegen(),e.fetch=requireFetch(),e.path=requirePath(),e.fs=e.inquire("fs"),e.toArray=function(l){if(l){for(var v=Object.keys(l),d=new Array(v.length),f=0;f<v.length;)d[f]=l[v[f++]];return d}return[]},e.toObject=function(l){for(var v={},d=0;d<l.length;){var f=l[d++],c=l[d++];c!==void 0&&(v[f]=c)}return v};var a=/\\/g,s=/"/g;e.isReserved=function(l){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(l)},e.safeProp=function(l){return!/^[$\w_]+$/.test(l)||e.isReserved(l)?'["'+l.replace(a,"\\\\").replace(s,'\\"')+'"]':"."+l},e.ucFirst=function(l){return l.charAt(0).toUpperCase()+l.substring(1)};var o=/_([a-z])/g;e.camelCase=function(l){return l.substring(0,1)+l.substring(1).replace(o,function(v,d){return d.toUpperCase()})},e.compareFieldsById=function(l,v){return l.id-v.id},e.decorateType=function(l,v){if(l.$type)return v&&l.$type.name!==v&&(e.decorateRoot.remove(l.$type),l.$type.name=v,e.decorateRoot.add(l.$type)),l.$type;n||(n=requireType());var d=new n(v||l.name);return e.decorateRoot.add(d),d.ctor=l,Object.defineProperty(l,"$type",{value:d,enumerable:!1}),Object.defineProperty(l.prototype,"$type",{value:d,enumerable:!1}),d};var i=0;return e.decorateEnum=function(l){if(l.$type)return l.$type;r||(r=require_enum());var v=new r("Enum"+i++,l);return e.decorateRoot.add(v),Object.defineProperty(l,"$type",{value:v,enumerable:!1}),v},e.setProperty=function(l,v,d,f){function c(p,h,y){var m=h.shift();if(m==="__proto__"||m==="prototype")return p;if(h.length>0)p[m]=c(p[m]||{},h,y);else{var _=p[m];if(_&&f)return p;_&&(y=[].concat(_).concat(y)),p[m]=y}return p}if(typeof l!="object")throw TypeError("dst must be an object");if(!v)throw TypeError("path must be specified");return v=v.split("."),c(l,v,d)},Object.defineProperty(e,"decorateRoot",{get:function(){return t.decorated||(t.decorated=new(requireRoot()))}}),util.exports}var hasRequiredTypes;function requireTypes(){return hasRequiredTypes||(hasRequiredTypes=1,function(e){var t=e,n=requireUtil(),r=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function a(s,o){var i=0,u={};for(o|=0;i<s.length;)u[r[i+o]]=s[i++];return u}t.basic=a([1,5,0,0,0,5,5,0,0,0,1,1,0,2,2]),t.defaults=a([0,0,0,0,0,0,0,0,0,0,0,0,!1,"",n.emptyArray,null]),t.long=a([0,0,0,1,1],7),t.mapKey=a([0,0,0,5,5,0,0,0,1,1,0,2],2),t.packed=a([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=o;var e=requireObject();((o.prototype=Object.create(e.prototype)).constructor=o).className="Field";var t=require_enum(),n=requireTypes(),r=requireUtil(),a,s=/^required|optional|repeated$/;o.fromJSON=function(u,l){var v=new o(u,l.id,l.type,l.rule,l.extend,l.options,l.comment);return l.edition&&(v._edition=l.edition),v._defaultEdition="proto3",v};function o(i,u,l,v,d,f,c){if(r.isObject(v)?(c=d,f=v,v=d=void 0):r.isObject(d)&&(c=f,f=d,d=void 0),e.call(this,i,f),!r.isInteger(u)||u<0)throw TypeError("id must be a non-negative integer");if(!r.isString(l))throw TypeError("type must be a string");if(v!==void 0&&!s.test(v=v.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(d!==void 0&&!r.isString(d))throw TypeError("extend must be a string");v==="proto3_optional"&&(v="optional"),this.rule=v&&v!=="optional"?v:void 0,this.type=l,this.id=u,this.extend=d||void 0,this.repeated=v==="repeated",this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=r.Long?n.long[l]!==void 0:!1,this.bytes=l==="bytes",this.resolvedType=null,this.extensionField=null,this.declaringField=null,this.comment=c}return Object.defineProperty(o.prototype,"required",{get:function(){return this._features.field_presence==="LEGACY_REQUIRED"}}),Object.defineProperty(o.prototype,"optional",{get:function(){return!this.required}}),Object.defineProperty(o.prototype,"delimited",{get:function(){return this.resolvedType instanceof a&&this._features.message_encoding==="DELIMITED"}}),Object.defineProperty(o.prototype,"packed",{get:function(){return this._features.repeated_field_encoding==="PACKED"}}),Object.defineProperty(o.prototype,"hasPresence",{get:function(){return this.repeated||this.map?!1:this.partOf||this.declaringField||this.extensionField||this._features.field_presence!=="IMPLICIT"}}),o.prototype.setOption=function(u,l,v){return e.prototype.setOption.call(this,u,l,v)},o.prototype.toJSON=function(u){var l=u?!!u.keepComments:!1;return r.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",l?this.comment:void 0])},o.prototype.resolve=function(){if(this.resolved)return this;if((this.typeDefault=n.defaults[this.type])===void 0?(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.resolvedType instanceof a?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 t&&typeof this.typeDefault=="string"&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&(this.options.packed!==void 0&&this.resolvedType&&!(this.resolvedType instanceof t)&&delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=r.Long.fromNumber(this.typeDefault,this.type.charAt(0)==="u"),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&typeof this.typeDefault=="string"){var u;r.base64.test(this.typeDefault)?r.base64.decode(this.typeDefault,u=r.newBuffer(r.base64.length(this.typeDefault)),0):r.utf8.write(this.typeDefault,u=r.newBuffer(r.utf8.length(this.typeDefault)),0),this.typeDefault=u}return this.map?this.defaultValue=r.emptyObject:this.repeated?this.defaultValue=r.emptyArray:this.defaultValue=this.typeDefault,this.parent instanceof a&&(this.parent.ctor.prototype[this.name]=this.defaultValue),e.prototype.resolve.call(this)},o.prototype._inferLegacyProtoFeatures=function(u){if(u!=="proto2"&&u!=="proto3")return{};var l={};if(this.rule==="required"&&(l.field_presence="LEGACY_REQUIRED"),this.parent&&n.defaults[this.type]===void 0){var v=this.parent.get(this.type.split(".").pop());v&&v instanceof a&&v.group&&(l.message_encoding="DELIMITED")}return this.getOption("packed")===!0?l.repeated_field_encoding="PACKED":this.getOption("packed")===!1&&(l.repeated_field_encoding="EXPANDED"),l},o.prototype._resolveFeatures=function(u){return e.prototype._resolveFeatures.call(this,this._edition||u)},o.d=function(u,l,v,d){return typeof l=="function"?l=r.decorateType(l).name:l&&typeof l=="object"&&(l=r.decorateEnum(l).name),function(c,p){r.decorateType(c.constructor).add(new o(p,u,l,v,{default:d}))}},o._configure=function(u){a=u},field}var oneof,hasRequiredOneof;function requireOneof(){if(hasRequiredOneof)return oneof;hasRequiredOneof=1,oneof=r;var e=requireObject();((r.prototype=Object.create(e.prototype)).constructor=r).className="OneOf";var t=requireField(),n=requireUtil();function r(s,o,i,u){if(Array.isArray(o)||(i=o,o=void 0),e.call(this,s,i),!(o===void 0||Array.isArray(o)))throw TypeError("fieldNames must be an Array");this.oneof=o||[],this.fieldsArray=[],this.comment=u}r.fromJSON=function(o,i){return new r(o,i.oneof,i.options,i.comment)},r.prototype.toJSON=function(o){var i=o?!!o.keepComments:!1;return n.toObject(["options",this.options,"oneof",this.oneof,"comment",i?this.comment:void 0])};function a(s){if(s.parent)for(var o=0;o<s.fieldsArray.length;++o)s.fieldsArray[o].parent||s.parent.add(s.fieldsArray[o])}return r.prototype.add=function(o){if(!(o instanceof t))throw TypeError("field must be a Field");return o.parent&&o.parent!==this.parent&&o.parent.remove(o),this.oneof.push(o.name),this.fieldsArray.push(o),o.partOf=this,a(this),this},r.prototype.remove=function(o){if(!(o instanceof t))throw TypeError("field must be a Field");var i=this.fieldsArray.indexOf(o);if(i<0)throw Error(o+" is not a member of "+this);return this.fieldsArray.splice(i,1),i=this.oneof.indexOf(o.name),i>-1&&this.oneof.splice(i,1),o.partOf=null,this},r.prototype.onAdd=function(o){e.prototype.onAdd.call(this,o);for(var i=this,u=0;u<this.oneof.length;++u){var l=o.get(this.oneof[u]);l&&!l.partOf&&(l.partOf=i,i.fieldsArray.push(l))}a(this)},r.prototype.onRemove=function(o){for(var i=0,u;i<this.fieldsArray.length;++i)(u=this.fieldsArray[i]).parent&&u.parent.remove(u);e.prototype.onRemove.call(this,o)},Object.defineProperty(r.prototype,"isProto3Optional",{get:function(){if(this.fieldsArray==null||this.fieldsArray.length!==1)return!1;var s=this.fieldsArray[0];return s.options!=null&&s.options.proto3_optional===!0}}),r.d=function(){for(var o=new Array(arguments.length),i=0;i<arguments.length;)o[i]=arguments[i++];return function(l,v){n.decorateType(l.constructor).add(new r(v,o)),Object.defineProperty(l,v,{get:n.oneOfGetter(o),set:n.oneOfSetter(o)})}},oneof}var object,hasRequiredObject;function requireObject(){if(hasRequiredObject)return object;hasRequiredObject=1,object=o,o.className="ReflectionObject";const e=requireOneof();var t=requireUtil(),n,r={enum_type:"OPEN",field_presence:"EXPLICIT",json_format:"ALLOW",message_encoding:"LENGTH_PREFIXED",repeated_field_encoding:"PACKED",utf8_validation:"VERIFY"},a={enum_type:"CLOSED",field_presence:"EXPLICIT",json_format:"LEGACY_BEST_EFFORT",message_encoding:"LENGTH_PREFIXED",repeated_field_encoding:"EXPANDED",utf8_validation:"NONE"},s={enum_type:"OPEN",field_presence:"IMPLICIT",json_format:"ALLOW",message_encoding:"LENGTH_PREFIXED",repeated_field_encoding:"PACKED",utf8_validation:"VERIFY"};function o(i,u){if(!t.isString(i))throw TypeError("name must be a string");if(u&&!t.isObject(u))throw TypeError("options must be an object");this.options=u,this.parsedOptions=null,this.name=i,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(o.prototype,{root:{get:function(){for(var i=this;i.parent!==null;)i=i.parent;return i}},fullName:{get:function(){for(var i=[this.name],u=this.parent;u;)i.unshift(u.name),u=u.parent;return i.join(".")}}}),o.prototype.toJSON=function(){throw Error()},o.prototype.onAdd=function(u){this.parent&&this.parent!==u&&this.parent.remove(this),this.parent=u,this.resolved=!1;var l=u.root;l instanceof n&&l._handleAdd(this)},o.prototype.onRemove=function(u){var l=u.root;l instanceof n&&l._handleRemove(this),this.parent=null,this.resolved=!1},o.prototype.resolve=function(){return this.resolved?this:(this.root instanceof n&&(this.resolved=!0),this)},o.prototype._resolveFeaturesRecursive=function(u){return this._resolveFeatures(this._edition||u)},o.prototype._resolveFeatures=function(u){if(!this._featuresResolved){var l={};if(!u)throw new Error("Unknown edition for "+this.fullName);var v=Object.assign(this.options?Object.assign({},this.options.features):{},this._inferLegacyProtoFeatures(u));if(this._edition){if(u==="proto2")l=Object.assign({},a);else if(u==="proto3")l=Object.assign({},s);else if(u==="2023")l=Object.assign({},r);else throw new Error("Unknown edition: "+u);this._features=Object.assign(l,v||{}),this._featuresResolved=!0;return}if(this.partOf instanceof e){var d=Object.assign({},this.partOf._features);this._features=Object.assign(d,v||{})}else if(!this.declaringField)if(this.parent){var f=Object.assign({},this.parent._features);this._features=Object.assign(f,v||{})}else throw new Error("Unable to find a parent for "+this.fullName);this.extensionField&&(this.extensionField._features=this._features),this._featuresResolved=!0}},o.prototype._inferLegacyProtoFeatures=function(){return{}},o.prototype.getOption=function(u){if(this.options)return this.options[u]},o.prototype.setOption=function(u,l,v){return this.options||(this.options={}),/^features\./.test(u)?t.setProperty(this.options,u,l,v):(!v||this.options[u]===void 0)&&(this.getOption(u)!==l&&(this.resolved=!1),this.options[u]=l),this},o.prototype.setParsedOption=function(u,l,v){this.parsedOptions||(this.parsedOptions=[]);var d=this.parsedOptions;if(v){var f=d.find(function(h){return Object.prototype.hasOwnProperty.call(h,u)});if(f){var c=f[u];t.setProperty(c,v,l)}else f={},f[u]=t.setProperty({},v,l),d.push(f)}else{var p={};p[u]=l,d.push(p)}return this},o.prototype.setOptions=function(u,l){if(u)for(var v=Object.keys(u),d=0;d<v.length;++d)this.setOption(v[d],u[v[d]],l);return this},o.prototype.toString=function(){var u=this.constructor.className,l=this.fullName;return l.length?u+" "+l:u},o.prototype._editionToJSON=function(){if(!(!this._edition||this._edition==="proto3"))return this._edition},o._configure=function(i){n=i},object}var _enum,hasRequired_enum;function require_enum(){if(hasRequired_enum)return _enum;hasRequired_enum=1,_enum=r;var e=requireObject();((r.prototype=Object.create(e.prototype)).constructor=r).className="Enum";var t=requireNamespace(),n=requireUtil();function r(a,s,o,i,u,l){if(e.call(this,a,o),s&&typeof s!="object")throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=i,this.comments=u||{},this.valuesOptions=l,this._valuesFeatures={},this.reserved=void 0,s)for(var v=Object.keys(s),d=0;d<v.length;++d)typeof s[v[d]]=="number"&&(this.valuesById[this.values[v[d]]=s[v[d]]]=v[d])}return r.prototype._resolveFeatures=function(s){return s=this._edition||s,e.prototype._resolveFeatures.call(this,s),Object.keys(this.values).forEach(o=>{var i=Object.assign({},this._features);this._valuesFeatures[o]=Object.assign(i,this.valuesOptions&&this.valuesOptions[o]&&this.valuesOptions[o].features)}),this},r.fromJSON=function(s,o){var i=new r(s,o.values,o.options,o.comment,o.comments);return i.reserved=o.reserved,o.edition&&(i._edition=o.edition),i._defaultEdition="proto3",i},r.prototype.toJSON=function(s){var o=s?!!s.keepComments:!1;return n.toObject(["edition",this._editionToJSON(),"options",this.options,"valuesOptions",this.valuesOptions,"values",this.values,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"comment",o?this.comment:void 0,"comments",o?this.comments:void 0])},r.prototype.add=function(s,o,i,u){if(!n.isString(s))throw TypeError("name must be a string");if(!n.isInteger(o))throw TypeError("id must be an integer");if(this.values[s]!==void 0)throw Error("duplicate name '"+s+"' in "+this);if(this.isReservedId(o))throw Error("id "+o+" is reserved in "+this);if(this.isReservedName(s))throw Error("name '"+s+"' is reserved in "+this);if(this.valuesById[o]!==void 0){if(!(this.options&&this.options.allow_alias))throw Error("duplicate id "+o+" in "+this);this.values[s]=o}else this.valuesById[this.values[s]=o]=s;return u&&(this.valuesOptions===void 0&&(this.valuesOptions={}),this.valuesOptions[s]=u||null),this.comments[s]=i||null,this},r.prototype.remove=function(s){if(!n.isString(s))throw TypeError("name must be a string");var o=this.values[s];if(o==null)throw Error("name '"+s+"' does not exist in "+this);return delete this.valuesById[o],delete this.values[s],delete this.comments[s],this.valuesOptions&&delete this.valuesOptions[s],this},r.prototype.isReservedId=function(s){return t.isReservedId(this.reserved,s)},r.prototype.isReservedName=function(s){return t.isReservedName(this.reserved,s)},_enum}var encoder_1,hasRequiredEncoder;function requireEncoder(){if(hasRequiredEncoder)return encoder_1;hasRequiredEncoder=1,encoder_1=a;var e=require_enum(),t=requireTypes(),n=requireUtil();function r(s,o,i,u){return o.delimited?s("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",i,u,(o.id<<3|3)>>>0,(o.id<<3|4)>>>0):s("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",i,u,(o.id<<3|2)>>>0)}function a(s){for(var o=n.codegen(["m","w"],s.name+"$encode")("if(!w)")("w=Writer.create()"),i,u,l=s.fieldsArray.slice().sort(n.compareFieldsById),i=0;i<l.length;++i){var v=l[i].resolve(),d=s._fieldsArray.indexOf(v),f=v.resolvedType instanceof e?"int32":v.type,c=t.basic[f];u="m"+n.safeProp(v.name),v.map?(o("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){",u,v.name)("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){",u)("w.uint32(%i).fork().uint32(%i).%s(ks[i])",(v.id<<3|2)>>>0,8|t.mapKey[v.keyType],v.keyType),c===void 0?o("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",d,u):o(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|c,f,u),o("}")("}")):v.repeated?(o("if(%s!=null&&%s.length){",u,u),v.packed&&t.packed[f]!==void 0?o("w.uint32(%i).fork()",(v.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",u)("w.%s(%s[i])",f,u)("w.ldelim()"):(o("for(var i=0;i<%s.length;++i)",u),c===void 0?r(o,v,d,u+"[i]"):o("w.uint32(%i).%s(%s[i])",(v.id<<3|c)>>>0,f,u)),o("}")):(v.optional&&o("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",u,v.name),c===void 0?r(o,v,d,u):o("w.uint32(%i).%s(%s)",(v.id<<3|c)>>>0,f,u))}return o("return w")}return encoder_1}var hasRequiredIndexLight;function requireIndexLight(){if(hasRequiredIndexLight)return indexLight.exports;hasRequiredIndexLight=1;var e=indexLight.exports=requireIndexMinimal();e.build="light";function t(r,a,s){return typeof a=="function"?(s=a,a=new e.Root):a||(a=new e.Root),a.load(r,s)}e.load=t;function n(r,a){return a||(a=new e.Root),a.loadSync(r)}return e.loadSync=n,e.encoder=requireEncoder(),e.decoder=requireDecoder(),e.verifier=requireVerifier(),e.converter=requireConverter(),e.ReflectionObject=requireObject(),e.Namespace=requireNamespace(),e.Root=requireRoot(),e.Enum=require_enum(),e.Type=requireType(),e.Field=requireField(),e.OneOf=requireOneof(),e.MapField=requireMapfield(),e.Service=requireService(),e.Method=requireMethod(),e.Message=requireMessage(),e.wrappers=requireWrappers(),e.types=requireTypes(),e.util=requireUtil(),e.ReflectionObject._configure(e.Root),e.Namespace._configure(e.Type,e.Service,e.Enum),e.Root._configure(e.Type),e.Field._configure(e.Type),indexLight.exports}var tokenize_1,hasRequiredTokenize;function requireTokenize(){if(hasRequiredTokenize)return tokenize_1;hasRequiredTokenize=1,tokenize_1=v;var e=/[\s{}=;:[\],'"()<>]/g,t=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,n=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,r=/^ *[*/]+ */,a=/^\s*\*?\/*/,s=/\n/g,o=/\s/,i=/\\(.?)/g,u={0:"\0",r:"\r",n:`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsviewer",
3
- "version": "1.0.31",
3
+ "version": "1.0.32",
4
4
  "main": "./dist/tsviewer.umd.js",
5
5
  "module": "./dist/tsviewer.es.js",
6
6
  "style": "dist/tsviewer.css",