@openc3/js-common 6.2.0 → 6.3.0

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.
@@ -0,0 +1,16 @@
1
+ "use strict";var Kt=Object.defineProperty;var Xt=(s,e,t)=>e in s?Kt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var L=(s,e,t)=>Xt(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function pt(s,e){return function(){return s.apply(e,arguments)}}const{toString:Gt}=Object.prototype,{getPrototypeOf:Fe}=Object,de=(s=>e=>{const t=Gt.call(e);return s[t]||(s[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),$=s=>(s=s.toLowerCase(),e=>de(e)===s),fe=s=>e=>typeof e===s,{isArray:K}=Array,Y=fe("undefined");function Zt(s){return s!==null&&!Y(s)&&s.constructor!==null&&!Y(s.constructor)&&N(s.constructor.isBuffer)&&s.constructor.isBuffer(s)}const mt=$("ArrayBuffer");function Qt(s){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(s):e=s&&s.buffer&&mt(s.buffer),e}const Yt=fe("string"),N=fe("function"),gt=fe("number"),pe=s=>s!==null&&typeof s=="object",en=s=>s===!0||s===!1,ce=s=>{if(de(s)!=="object")return!1;const e=Fe(s);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in s)&&!(Symbol.iterator in s)},tn=$("Date"),nn=$("File"),sn=$("Blob"),rn=$("FileList"),on=s=>pe(s)&&N(s.pipe),cn=s=>{let e;return s&&(typeof FormData=="function"&&s instanceof FormData||N(s.append)&&((e=de(s))==="formdata"||e==="object"&&N(s.toString)&&s.toString()==="[object FormData]"))},an=$("URLSearchParams"),[ln,un,hn,dn]=["ReadableStream","Request","Response","Headers"].map($),fn=s=>s.trim?s.trim():s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ee(s,e,{allOwnKeys:t=!1}={}){if(s===null||typeof s>"u")return;let n,r;if(typeof s!="object"&&(s=[s]),K(s))for(n=0,r=s.length;n<r;n++)e.call(null,s[n],n,s);else{const i=t?Object.getOwnPropertyNames(s):Object.keys(s),o=i.length;let c;for(n=0;n<o;n++)c=i[n],e.call(null,s[c],c,s)}}function bt(s,e){e=e.toLowerCase();const t=Object.keys(s);let n=t.length,r;for(;n-- >0;)if(r=t[n],e===r.toLowerCase())return r;return null}const H=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,wt=s=>!Y(s)&&s!==H;function Oe(){const{caseless:s}=wt(this)&&this||{},e={},t=(n,r)=>{const i=s&&bt(e,r)||r;ce(e[i])&&ce(n)?e[i]=Oe(e[i],n):ce(n)?e[i]=Oe({},n):K(n)?e[i]=n.slice():e[i]=n};for(let n=0,r=arguments.length;n<r;n++)arguments[n]&&ee(arguments[n],t);return e}const pn=(s,e,t,{allOwnKeys:n}={})=>(ee(e,(r,i)=>{t&&N(r)?s[i]=pt(r,t):s[i]=r},{allOwnKeys:n}),s),mn=s=>(s.charCodeAt(0)===65279&&(s=s.slice(1)),s),gn=(s,e,t,n)=>{s.prototype=Object.create(e.prototype,n),s.prototype.constructor=s,Object.defineProperty(s,"super",{value:e.prototype}),t&&Object.assign(s.prototype,t)},bn=(s,e,t,n)=>{let r,i,o;const c={};if(e=e||{},s==null)return e;do{for(r=Object.getOwnPropertyNames(s),i=r.length;i-- >0;)o=r[i],(!n||n(o,s,e))&&!c[o]&&(e[o]=s[o],c[o]=!0);s=t!==!1&&Fe(s)}while(s&&(!t||t(s,e))&&s!==Object.prototype);return e},wn=(s,e,t)=>{s=String(s),(t===void 0||t>s.length)&&(t=s.length),t-=e.length;const n=s.indexOf(e,t);return n!==-1&&n===t},yn=s=>{if(!s)return null;if(K(s))return s;let e=s.length;if(!gt(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=s[e];return t},_n=(s=>e=>s&&e instanceof s)(typeof Uint8Array<"u"&&Fe(Uint8Array)),En=(s,e)=>{const n=(s&&s[Symbol.iterator]).call(s);let r;for(;(r=n.next())&&!r.done;){const i=r.value;e.call(s,i[0],i[1])}},Sn=(s,e)=>{let t;const n=[];for(;(t=s.exec(e))!==null;)n.push(t);return n},xn=$("HTMLFormElement"),Rn=s=>s.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,n,r){return n.toUpperCase()+r}),Je=(({hasOwnProperty:s})=>(e,t)=>s.call(e,t))(Object.prototype),An=$("RegExp"),yt=(s,e)=>{const t=Object.getOwnPropertyDescriptors(s),n={};ee(t,(r,i)=>{let o;(o=e(r,i,s))!==!1&&(n[i]=o||r)}),Object.defineProperties(s,n)},Cn=s=>{yt(s,(e,t)=>{if(N(s)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const n=s[t];if(N(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},On=(s,e)=>{const t={},n=r=>{r.forEach(i=>{t[i]=!0})};return K(s)?n(s):n(String(s).split(e)),t},Tn=()=>{},kn=(s,e)=>s!=null&&Number.isFinite(s=+s)?s:e;function Nn(s){return!!(s&&N(s.append)&&s[Symbol.toStringTag]==="FormData"&&s[Symbol.iterator])}const Pn=s=>{const e=new Array(10),t=(n,r)=>{if(pe(n)){if(e.indexOf(n)>=0)return;if(!("toJSON"in n)){e[r]=n;const i=K(n)?[]:{};return ee(n,(o,c)=>{const h=t(o,r+1);!Y(h)&&(i[c]=h)}),e[r]=void 0,i}}return n};return t(s,0)},In=$("AsyncFunction"),vn=s=>s&&(pe(s)||N(s))&&N(s.then)&&N(s.catch),_t=((s,e)=>s?setImmediate:e?((t,n)=>(H.addEventListener("message",({source:r,data:i})=>{r===H&&i===t&&n.length&&n.shift()()},!1),r=>{n.push(r),H.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",N(H.postMessage)),Ln=typeof queueMicrotask<"u"?queueMicrotask.bind(H):typeof process<"u"&&process.nextTick||_t,l={isArray:K,isArrayBuffer:mt,isBuffer:Zt,isFormData:cn,isArrayBufferView:Qt,isString:Yt,isNumber:gt,isBoolean:en,isObject:pe,isPlainObject:ce,isReadableStream:ln,isRequest:un,isResponse:hn,isHeaders:dn,isUndefined:Y,isDate:tn,isFile:nn,isBlob:sn,isRegExp:An,isFunction:N,isStream:on,isURLSearchParams:an,isTypedArray:_n,isFileList:rn,forEach:ee,merge:Oe,extend:pn,trim:fn,stripBOM:mn,inherits:gn,toFlatObject:bn,kindOf:de,kindOfTest:$,endsWith:wn,toArray:yn,forEachEntry:En,matchAll:Sn,isHTMLForm:xn,hasOwnProperty:Je,hasOwnProp:Je,reduceDescriptors:yt,freezeMethods:Cn,toObjectSet:On,toCamelCase:Rn,noop:Tn,toFiniteNumber:kn,findKey:bt,global:H,isContextDefined:wt,isSpecCompliantForm:Nn,toJSONObject:Pn,isAsyncFn:In,isThenable:vn,setImmediate:_t,asap:Ln};function w(s,e,t,n,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=s,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),n&&(this.request=n),r&&(this.response=r,this.status=r.status?r.status:null)}l.inherits(w,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:l.toJSONObject(this.config),code:this.code,status:this.status}}});const Et=w.prototype,St={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(s=>{St[s]={value:s}});Object.defineProperties(w,St);Object.defineProperty(Et,"isAxiosError",{value:!0});w.from=(s,e,t,n,r,i)=>{const o=Object.create(Et);return l.toFlatObject(s,o,function(h){return h!==Error.prototype},c=>c!=="isAxiosError"),w.call(o,s.message,e,t,n,r),o.cause=s,o.name=s.name,i&&Object.assign(o,i),o};const jn=null;function Te(s){return l.isPlainObject(s)||l.isArray(s)}function xt(s){return l.endsWith(s,"[]")?s.slice(0,-2):s}function We(s,e,t){return s?s.concat(e).map(function(r,i){return r=xt(r),!t&&i?"["+r+"]":r}).join(t?".":""):e}function $n(s){return l.isArray(s)&&!s.some(Te)}const Fn=l.toFlatObject(l,{},null,function(e){return/^is[A-Z]/.test(e)});function me(s,e,t){if(!l.isObject(s))throw new TypeError("target must be an object");e=e||new FormData,t=l.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,p){return!l.isUndefined(p[m])});const n=t.metaTokens,r=t.visitor||a,i=t.dots,o=t.indexes,h=(t.Blob||typeof Blob<"u"&&Blob)&&l.isSpecCompliantForm(e);if(!l.isFunction(r))throw new TypeError("visitor must be a function");function u(f){if(f===null)return"";if(l.isDate(f))return f.toISOString();if(!h&&l.isBlob(f))throw new w("Blob is not supported. Use a Buffer instead.");return l.isArrayBuffer(f)||l.isTypedArray(f)?h&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function a(f,m,p){let _=f;if(f&&!p&&typeof f=="object"){if(l.endsWith(m,"{}"))m=n?m:m.slice(0,-2),f=JSON.stringify(f);else if(l.isArray(f)&&$n(f)||(l.isFileList(f)||l.endsWith(m,"[]"))&&(_=l.toArray(f)))return m=xt(m),_.forEach(function(S,k){!(l.isUndefined(S)||S===null)&&e.append(o===!0?We([m],k,i):o===null?m:m+"[]",u(S))}),!1}return Te(f)?!0:(e.append(We(p,m,i),u(f)),!1)}const d=[],g=Object.assign(Fn,{defaultVisitor:a,convertValue:u,isVisitable:Te});function b(f,m){if(!l.isUndefined(f)){if(d.indexOf(f)!==-1)throw Error("Circular reference detected in "+m.join("."));d.push(f),l.forEach(f,function(_,E){(!(l.isUndefined(_)||_===null)&&r.call(e,_,l.isString(E)?E.trim():E,m,g))===!0&&b(_,m?m.concat(E):[E])}),d.pop()}}if(!l.isObject(s))throw new TypeError("data must be an object");return b(s),e}function Ke(s){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(s).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function Ue(s,e){this._pairs=[],s&&me(s,this,e)}const Rt=Ue.prototype;Rt.append=function(e,t){this._pairs.push([e,t])};Rt.toString=function(e){const t=e?function(n){return e.call(this,n,Ke)}:Ke;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function Un(s){return encodeURIComponent(s).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function At(s,e,t){if(!e)return s;const n=t&&t.encode||Un;l.isFunction(t)&&(t={serialize:t});const r=t&&t.serialize;let i;if(r?i=r(e,t):i=l.isURLSearchParams(e)?e.toString():new Ue(e,t).toString(n),i){const o=s.indexOf("#");o!==-1&&(s=s.slice(0,o)),s+=(s.indexOf("?")===-1?"?":"&")+i}return s}class Xe{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){l.forEach(this.handlers,function(n){n!==null&&e(n)})}}const Ct={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Dn=typeof URLSearchParams<"u"?URLSearchParams:Ue,qn=typeof FormData<"u"?FormData:null,Bn=typeof Blob<"u"?Blob:null,Mn={isBrowser:!0,classes:{URLSearchParams:Dn,FormData:qn,Blob:Bn},protocols:["http","https","file","blob","url","data"]},De=typeof window<"u"&&typeof document<"u",ke=typeof navigator=="object"&&navigator||void 0,Hn=De&&(!ke||["ReactNative","NativeScript","NS"].indexOf(ke.product)<0),zn=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Vn=De&&window.location.href||"http://localhost",Jn=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:De,hasStandardBrowserEnv:Hn,hasStandardBrowserWebWorkerEnv:zn,navigator:ke,origin:Vn},Symbol.toStringTag,{value:"Module"})),C={...Jn,...Mn};function Wn(s,e){return me(s,new C.classes.URLSearchParams,Object.assign({visitor:function(t,n,r,i){return C.isNode&&l.isBuffer(t)?(this.append(n,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},e))}function Kn(s){return l.matchAll(/\w+|\[(\w*)]/g,s).map(e=>e[0]==="[]"?"":e[1]||e[0])}function Xn(s){const e={},t=Object.keys(s);let n;const r=t.length;let i;for(n=0;n<r;n++)i=t[n],e[i]=s[i];return e}function Ot(s){function e(t,n,r,i){let o=t[i++];if(o==="__proto__")return!0;const c=Number.isFinite(+o),h=i>=t.length;return o=!o&&l.isArray(r)?r.length:o,h?(l.hasOwnProp(r,o)?r[o]=[r[o],n]:r[o]=n,!c):((!r[o]||!l.isObject(r[o]))&&(r[o]=[]),e(t,n,r[o],i)&&l.isArray(r[o])&&(r[o]=Xn(r[o])),!c)}if(l.isFormData(s)&&l.isFunction(s.entries)){const t={};return l.forEachEntry(s,(n,r)=>{e(Kn(n),r,t,0)}),t}return null}function Gn(s,e,t){if(l.isString(s))try{return(e||JSON.parse)(s),l.trim(s)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(s)}const te={transitional:Ct,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,i=l.isObject(e);if(i&&l.isHTMLForm(e)&&(e=new FormData(e)),l.isFormData(e))return r?JSON.stringify(Ot(e)):e;if(l.isArrayBuffer(e)||l.isBuffer(e)||l.isStream(e)||l.isFile(e)||l.isBlob(e)||l.isReadableStream(e))return e;if(l.isArrayBufferView(e))return e.buffer;if(l.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let c;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Wn(e,this.formSerializer).toString();if((c=l.isFileList(e))||n.indexOf("multipart/form-data")>-1){const h=this.env&&this.env.FormData;return me(c?{"files[]":e}:e,h&&new h,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),Gn(e)):e}],transformResponse:[function(e){const t=this.transitional||te.transitional,n=t&&t.forcedJSONParsing,r=this.responseType==="json";if(l.isResponse(e)||l.isReadableStream(e))return e;if(e&&l.isString(e)&&(n&&!this.responseType||r)){const o=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(c){if(o)throw c.name==="SyntaxError"?w.from(c,w.ERR_BAD_RESPONSE,this,null,this.response):c}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};l.forEach(["delete","get","head","post","put","patch"],s=>{te.headers[s]={}});const Zn=l.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Qn=s=>{const e={};let t,n,r;return s&&s.split(`
2
+ `).forEach(function(o){r=o.indexOf(":"),t=o.substring(0,r).trim().toLowerCase(),n=o.substring(r+1).trim(),!(!t||e[t]&&Zn[t])&&(t==="set-cookie"?e[t]?e[t].push(n):e[t]=[n]:e[t]=e[t]?e[t]+", "+n:n)}),e},Ge=Symbol("internals");function Z(s){return s&&String(s).trim().toLowerCase()}function ae(s){return s===!1||s==null?s:l.isArray(s)?s.map(ae):String(s)}function Yn(s){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=t.exec(s);)e[n[1]]=n[2];return e}const es=s=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(s.trim());function xe(s,e,t,n,r){if(l.isFunction(n))return n.call(this,e,t);if(r&&(e=t),!!l.isString(e)){if(l.isString(n))return e.indexOf(n)!==-1;if(l.isRegExp(n))return n.test(e)}}function ts(s){return s.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function ns(s,e){const t=l.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(s,n+t,{value:function(r,i,o){return this[n].call(this,e,r,i,o)},configurable:!0})})}let T=class{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function i(c,h,u){const a=Z(h);if(!a)throw new Error("header name must be a non-empty string");const d=l.findKey(r,a);(!d||r[d]===void 0||u===!0||u===void 0&&r[d]!==!1)&&(r[d||h]=ae(c))}const o=(c,h)=>l.forEach(c,(u,a)=>i(u,a,h));if(l.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(l.isString(e)&&(e=e.trim())&&!es(e))o(Qn(e),t);else if(l.isHeaders(e))for(const[c,h]of e.entries())i(h,c,n);else e!=null&&i(t,e,n);return this}get(e,t){if(e=Z(e),e){const n=l.findKey(this,e);if(n){const r=this[n];if(!t)return r;if(t===!0)return Yn(r);if(l.isFunction(t))return t.call(this,r,n);if(l.isRegExp(t))return t.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Z(e),e){const n=l.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||xe(this,this[n],n,t)))}return!1}delete(e,t){const n=this;let r=!1;function i(o){if(o=Z(o),o){const c=l.findKey(n,o);c&&(!t||xe(n,n[c],c,t))&&(delete n[c],r=!0)}}return l.isArray(e)?e.forEach(i):i(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const i=t[n];(!e||xe(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){const t=this,n={};return l.forEach(this,(r,i)=>{const o=l.findKey(n,i);if(o){t[o]=ae(r),delete t[i];return}const c=e?ts(i):String(i).trim();c!==i&&delete t[i],t[c]=ae(r),n[c]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return l.forEach(this,(n,r)=>{n!=null&&n!==!1&&(t[r]=e&&l.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
3
+ `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(r=>n.set(r)),n}static accessor(e){const n=(this[Ge]=this[Ge]={accessors:{}}).accessors,r=this.prototype;function i(o){const c=Z(o);n[c]||(ns(r,o),n[c]=!0)}return l.isArray(e)?e.forEach(i):i(e),this}};T.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);l.reduceDescriptors(T.prototype,({value:s},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>s,set(n){this[t]=n}}});l.freezeMethods(T);function Re(s,e){const t=this||te,n=e||t,r=T.from(n.headers);let i=n.data;return l.forEach(s,function(c){i=c.call(t,i,r.normalize(),e?e.status:void 0)}),r.normalize(),i}function Tt(s){return!!(s&&s.__CANCEL__)}function X(s,e,t){w.call(this,s??"canceled",w.ERR_CANCELED,e,t),this.name="CanceledError"}l.inherits(X,w,{__CANCEL__:!0});function kt(s,e,t){const n=t.config.validateStatus;!t.status||!n||n(t.status)?s(t):e(new w("Request failed with status code "+t.status,[w.ERR_BAD_REQUEST,w.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function ss(s){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(s);return e&&e[1]||""}function rs(s,e){s=s||10;const t=new Array(s),n=new Array(s);let r=0,i=0,o;return e=e!==void 0?e:1e3,function(h){const u=Date.now(),a=n[i];o||(o=u),t[r]=h,n[r]=u;let d=i,g=0;for(;d!==r;)g+=t[d++],d=d%s;if(r=(r+1)%s,r===i&&(i=(i+1)%s),u-o<e)return;const b=a&&u-a;return b?Math.round(g*1e3/b):void 0}}function is(s,e){let t=0,n=1e3/e,r,i;const o=(u,a=Date.now())=>{t=a,r=null,i&&(clearTimeout(i),i=null),s.apply(null,u)};return[(...u)=>{const a=Date.now(),d=a-t;d>=n?o(u,a):(r=u,i||(i=setTimeout(()=>{i=null,o(r)},n-d)))},()=>r&&o(r)]}const ue=(s,e,t=3)=>{let n=0;const r=rs(50,250);return is(i=>{const o=i.loaded,c=i.lengthComputable?i.total:void 0,h=o-n,u=r(h),a=o<=c;n=o;const d={loaded:o,total:c,progress:c?o/c:void 0,bytes:h,rate:u||void 0,estimated:u&&c&&a?(c-o)/u:void 0,event:i,lengthComputable:c!=null,[e?"download":"upload"]:!0};s(d)},t)},Ze=(s,e)=>{const t=s!=null;return[n=>e[0]({lengthComputable:t,total:s,loaded:n}),e[1]]},Qe=s=>(...e)=>l.asap(()=>s(...e)),os=C.hasStandardBrowserEnv?((s,e)=>t=>(t=new URL(t,C.origin),s.protocol===t.protocol&&s.host===t.host&&(e||s.port===t.port)))(new URL(C.origin),C.navigator&&/(msie|trident)/i.test(C.navigator.userAgent)):()=>!0,cs=C.hasStandardBrowserEnv?{write(s,e,t,n,r,i){const o=[s+"="+encodeURIComponent(e)];l.isNumber(t)&&o.push("expires="+new Date(t).toGMTString()),l.isString(n)&&o.push("path="+n),l.isString(r)&&o.push("domain="+r),i===!0&&o.push("secure"),document.cookie=o.join("; ")},read(s){const e=document.cookie.match(new RegExp("(^|;\\s*)("+s+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(s){this.write(s,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function as(s){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(s)}function ls(s,e){return e?s.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):s}function Nt(s,e,t){let n=!as(e);return s&&(n||t==!1)?ls(s,e):e}const Ye=s=>s instanceof T?{...s}:s;function V(s,e){e=e||{};const t={};function n(u,a,d,g){return l.isPlainObject(u)&&l.isPlainObject(a)?l.merge.call({caseless:g},u,a):l.isPlainObject(a)?l.merge({},a):l.isArray(a)?a.slice():a}function r(u,a,d,g){if(l.isUndefined(a)){if(!l.isUndefined(u))return n(void 0,u,d,g)}else return n(u,a,d,g)}function i(u,a){if(!l.isUndefined(a))return n(void 0,a)}function o(u,a){if(l.isUndefined(a)){if(!l.isUndefined(u))return n(void 0,u)}else return n(void 0,a)}function c(u,a,d){if(d in e)return n(u,a);if(d in s)return n(void 0,u)}const h={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(u,a,d)=>r(Ye(u),Ye(a),d,!0)};return l.forEach(Object.keys(Object.assign({},s,e)),function(a){const d=h[a]||r,g=d(s[a],e[a],a);l.isUndefined(g)&&d!==c||(t[a]=g)}),t}const Pt=s=>{const e=V({},s);let{data:t,withXSRFToken:n,xsrfHeaderName:r,xsrfCookieName:i,headers:o,auth:c}=e;e.headers=o=T.from(o),e.url=At(Nt(e.baseURL,e.url,e.allowAbsoluteUrls),s.params,s.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let h;if(l.isFormData(t)){if(C.hasStandardBrowserEnv||C.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if((h=o.getContentType())!==!1){const[u,...a]=h?h.split(";").map(d=>d.trim()).filter(Boolean):[];o.setContentType([u||"multipart/form-data",...a].join("; "))}}if(C.hasStandardBrowserEnv&&(n&&l.isFunction(n)&&(n=n(e)),n||n!==!1&&os(e.url))){const u=r&&i&&cs.read(i);u&&o.set(r,u)}return e},us=typeof XMLHttpRequest<"u",hs=us&&function(s){return new Promise(function(t,n){const r=Pt(s);let i=r.data;const o=T.from(r.headers).normalize();let{responseType:c,onUploadProgress:h,onDownloadProgress:u}=r,a,d,g,b,f;function m(){b&&b(),f&&f(),r.cancelToken&&r.cancelToken.unsubscribe(a),r.signal&&r.signal.removeEventListener("abort",a)}let p=new XMLHttpRequest;p.open(r.method.toUpperCase(),r.url,!0),p.timeout=r.timeout;function _(){if(!p)return;const S=T.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),x={data:!c||c==="text"||c==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:S,config:s,request:p};kt(function(I){t(I),m()},function(I){n(I),m()},x),p=null}"onloadend"in p?p.onloadend=_:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(_)},p.onabort=function(){p&&(n(new w("Request aborted",w.ECONNABORTED,s,p)),p=null)},p.onerror=function(){n(new w("Network Error",w.ERR_NETWORK,s,p)),p=null},p.ontimeout=function(){let k=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const x=r.transitional||Ct;r.timeoutErrorMessage&&(k=r.timeoutErrorMessage),n(new w(k,x.clarifyTimeoutError?w.ETIMEDOUT:w.ECONNABORTED,s,p)),p=null},i===void 0&&o.setContentType(null),"setRequestHeader"in p&&l.forEach(o.toJSON(),function(k,x){p.setRequestHeader(x,k)}),l.isUndefined(r.withCredentials)||(p.withCredentials=!!r.withCredentials),c&&c!=="json"&&(p.responseType=r.responseType),u&&([g,f]=ue(u,!0),p.addEventListener("progress",g)),h&&p.upload&&([d,b]=ue(h),p.upload.addEventListener("progress",d),p.upload.addEventListener("loadend",b)),(r.cancelToken||r.signal)&&(a=S=>{p&&(n(!S||S.type?new X(null,s,p):S),p.abort(),p=null)},r.cancelToken&&r.cancelToken.subscribe(a),r.signal&&(r.signal.aborted?a():r.signal.addEventListener("abort",a)));const E=ss(r.url);if(E&&C.protocols.indexOf(E)===-1){n(new w("Unsupported protocol "+E+":",w.ERR_BAD_REQUEST,s));return}p.send(i||null)})},ds=(s,e)=>{const{length:t}=s=s?s.filter(Boolean):[];if(e||t){let n=new AbortController,r;const i=function(u){if(!r){r=!0,c();const a=u instanceof Error?u:this.reason;n.abort(a instanceof w?a:new X(a instanceof Error?a.message:a))}};let o=e&&setTimeout(()=>{o=null,i(new w(`timeout ${e} of ms exceeded`,w.ETIMEDOUT))},e);const c=()=>{s&&(o&&clearTimeout(o),o=null,s.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),s=null)};s.forEach(u=>u.addEventListener("abort",i));const{signal:h}=n;return h.unsubscribe=()=>l.asap(c),h}},fs=function*(s,e){let t=s.byteLength;if(t<e){yield s;return}let n=0,r;for(;n<t;)r=n+e,yield s.slice(n,r),n=r},ps=async function*(s,e){for await(const t of ms(s))yield*fs(t,e)},ms=async function*(s){if(s[Symbol.asyncIterator]){yield*s;return}const e=s.getReader();try{for(;;){const{done:t,value:n}=await e.read();if(t)break;yield n}}finally{await e.cancel()}},et=(s,e,t,n)=>{const r=ps(s,e);let i=0,o,c=h=>{o||(o=!0,n&&n(h))};return new ReadableStream({async pull(h){try{const{done:u,value:a}=await r.next();if(u){c(),h.close();return}let d=a.byteLength;if(t){let g=i+=d;t(g)}h.enqueue(new Uint8Array(a))}catch(u){throw c(u),u}},cancel(h){return c(h),r.return()}},{highWaterMark:2})},ge=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",It=ge&&typeof ReadableStream=="function",gs=ge&&(typeof TextEncoder=="function"?(s=>e=>s.encode(e))(new TextEncoder):async s=>new Uint8Array(await new Response(s).arrayBuffer())),vt=(s,...e)=>{try{return!!s(...e)}catch{return!1}},bs=It&&vt(()=>{let s=!1;const e=new Request(C.origin,{body:new ReadableStream,method:"POST",get duplex(){return s=!0,"half"}}).headers.has("Content-Type");return s&&!e}),tt=64*1024,Ne=It&&vt(()=>l.isReadableStream(new Response("").body)),he={stream:Ne&&(s=>s.body)};ge&&(s=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!he[e]&&(he[e]=l.isFunction(s[e])?t=>t[e]():(t,n)=>{throw new w(`Response type '${e}' is not supported`,w.ERR_NOT_SUPPORT,n)})})})(new Response);const ws=async s=>{if(s==null)return 0;if(l.isBlob(s))return s.size;if(l.isSpecCompliantForm(s))return(await new Request(C.origin,{method:"POST",body:s}).arrayBuffer()).byteLength;if(l.isArrayBufferView(s)||l.isArrayBuffer(s))return s.byteLength;if(l.isURLSearchParams(s)&&(s=s+""),l.isString(s))return(await gs(s)).byteLength},ys=async(s,e)=>{const t=l.toFiniteNumber(s.getContentLength());return t??ws(e)},_s=ge&&(async s=>{let{url:e,method:t,data:n,signal:r,cancelToken:i,timeout:o,onDownloadProgress:c,onUploadProgress:h,responseType:u,headers:a,withCredentials:d="same-origin",fetchOptions:g}=Pt(s);u=u?(u+"").toLowerCase():"text";let b=ds([r,i&&i.toAbortSignal()],o),f;const m=b&&b.unsubscribe&&(()=>{b.unsubscribe()});let p;try{if(h&&bs&&t!=="get"&&t!=="head"&&(p=await ys(a,n))!==0){let x=new Request(e,{method:"POST",body:n,duplex:"half"}),P;if(l.isFormData(n)&&(P=x.headers.get("content-type"))&&a.setContentType(P),x.body){const[I,D]=Ze(p,ue(Qe(h)));n=et(x.body,tt,I,D)}}l.isString(d)||(d=d?"include":"omit");const _="credentials"in Request.prototype;f=new Request(e,{...g,signal:b,method:t.toUpperCase(),headers:a.normalize().toJSON(),body:n,duplex:"half",credentials:_?d:void 0});let E=await fetch(f);const S=Ne&&(u==="stream"||u==="response");if(Ne&&(c||S&&m)){const x={};["status","statusText","headers"].forEach(U=>{x[U]=E[U]});const P=l.toFiniteNumber(E.headers.get("content-length")),[I,D]=c&&Ze(P,ue(Qe(c),!0))||[];E=new Response(et(E.body,tt,I,()=>{D&&D(),m&&m()}),x)}u=u||"text";let k=await he[l.findKey(he,u)||"text"](E,s);return!S&&m&&m(),await new Promise((x,P)=>{kt(x,P,{data:k,headers:T.from(E.headers),status:E.status,statusText:E.statusText,config:s,request:f})})}catch(_){throw m&&m(),_&&_.name==="TypeError"&&/fetch/i.test(_.message)?Object.assign(new w("Network Error",w.ERR_NETWORK,s,f),{cause:_.cause||_}):w.from(_,_&&_.code,s,f)}}),Pe={http:jn,xhr:hs,fetch:_s};l.forEach(Pe,(s,e)=>{if(s){try{Object.defineProperty(s,"name",{value:e})}catch{}Object.defineProperty(s,"adapterName",{value:e})}});const nt=s=>`- ${s}`,Es=s=>l.isFunction(s)||s===null||s===!1,Lt={getAdapter:s=>{s=l.isArray(s)?s:[s];const{length:e}=s;let t,n;const r={};for(let i=0;i<e;i++){t=s[i];let o;if(n=t,!Es(t)&&(n=Pe[(o=String(t)).toLowerCase()],n===void 0))throw new w(`Unknown adapter '${o}'`);if(n)break;r[o||"#"+i]=n}if(!n){const i=Object.entries(r).map(([c,h])=>`adapter ${c} `+(h===!1?"is not supported by the environment":"is not available in the build"));let o=e?i.length>1?`since :
4
+ `+i.map(nt).join(`
5
+ `):" "+nt(i[0]):"as no adapter specified";throw new w("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return n},adapters:Pe};function Ae(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new X(null,s)}function st(s){return Ae(s),s.headers=T.from(s.headers),s.data=Re.call(s,s.transformRequest),["post","put","patch"].indexOf(s.method)!==-1&&s.headers.setContentType("application/x-www-form-urlencoded",!1),Lt.getAdapter(s.adapter||te.adapter)(s).then(function(n){return Ae(s),n.data=Re.call(s,s.transformResponse,n),n.headers=T.from(n.headers),n},function(n){return Tt(n)||(Ae(s),n&&n.response&&(n.response.data=Re.call(s,s.transformResponse,n.response),n.response.headers=T.from(n.response.headers))),Promise.reject(n)})}const jt="1.8.4",be={};["object","boolean","number","function","string","symbol"].forEach((s,e)=>{be[s]=function(n){return typeof n===s||"a"+(e<1?"n ":" ")+s}});const rt={};be.transitional=function(e,t,n){function r(i,o){return"[Axios v"+jt+"] Transitional option '"+i+"'"+o+(n?". "+n:"")}return(i,o,c)=>{if(e===!1)throw new w(r(o," has been removed"+(t?" in "+t:"")),w.ERR_DEPRECATED);return t&&!rt[o]&&(rt[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,c):!0}};be.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function Ss(s,e,t){if(typeof s!="object")throw new w("options must be an object",w.ERR_BAD_OPTION_VALUE);const n=Object.keys(s);let r=n.length;for(;r-- >0;){const i=n[r],o=e[i];if(o){const c=s[i],h=c===void 0||o(c,i,s);if(h!==!0)throw new w("option "+i+" must be "+h,w.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new w("Unknown option "+i,w.ERR_BAD_OPTION)}}const le={assertOptions:Ss,validators:be},F=le.validators;let z=class{constructor(e){this.defaults=e,this.interceptors={request:new Xe,response:new Xe}}async request(e,t){try{return await this._request(e,t)}catch(n){if(n instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;const i=r.stack?r.stack.replace(/^.+\n/,""):"";try{n.stack?i&&!String(n.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(n.stack+=`
6
+ `+i):n.stack=i}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=V(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:i}=t;n!==void 0&&le.assertOptions(n,{silentJSONParsing:F.transitional(F.boolean),forcedJSONParsing:F.transitional(F.boolean),clarifyTimeoutError:F.transitional(F.boolean)},!1),r!=null&&(l.isFunction(r)?t.paramsSerializer={serialize:r}:le.assertOptions(r,{encode:F.function,serialize:F.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),le.assertOptions(t,{baseUrl:F.spelling("baseURL"),withXsrfToken:F.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&l.merge(i.common,i[t.method]);i&&l.forEach(["delete","get","head","post","put","patch","common"],f=>{delete i[f]}),t.headers=T.concat(o,i);const c=[];let h=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(t)===!1||(h=h&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const u=[];this.interceptors.response.forEach(function(m){u.push(m.fulfilled,m.rejected)});let a,d=0,g;if(!h){const f=[st.bind(this),void 0];for(f.unshift.apply(f,c),f.push.apply(f,u),g=f.length,a=Promise.resolve(t);d<g;)a=a.then(f[d++],f[d++]);return a}g=c.length;let b=t;for(d=0;d<g;){const f=c[d++],m=c[d++];try{b=f(b)}catch(p){m.call(this,p);break}}try{a=st.call(this,b)}catch(f){return Promise.reject(f)}for(d=0,g=u.length;d<g;)a=a.then(u[d++],u[d++]);return a}getUri(e){e=V(this.defaults,e);const t=Nt(e.baseURL,e.url,e.allowAbsoluteUrls);return At(t,e.params,e.paramsSerializer)}};l.forEach(["delete","get","head","options"],function(e){z.prototype[e]=function(t,n){return this.request(V(n||{},{method:e,url:t,data:(n||{}).data}))}});l.forEach(["post","put","patch"],function(e){function t(n){return function(i,o,c){return this.request(V(c||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}z.prototype[e]=t(),z.prototype[e+"Form"]=t(!0)});let xs=class $t{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(i){t=i});const n=this;this.promise.then(r=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](r);n._listeners=null}),this.promise.then=r=>{let i;const o=new Promise(c=>{n.subscribe(c),i=c}).then(r);return o.cancel=function(){n.unsubscribe(i)},o},e(function(i,o,c){n.reason||(n.reason=new X(i,o,c),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=n=>{e.abort(n)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new $t(function(r){e=r}),cancel:e}}};function Rs(s){return function(t){return s.apply(null,t)}}function As(s){return l.isObject(s)&&s.isAxiosError===!0}const Ie={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ie).forEach(([s,e])=>{Ie[e]=s});function Ft(s){const e=new z(s),t=pt(z.prototype.request,e);return l.extend(t,z.prototype,e,{allOwnKeys:!0}),l.extend(t,e,null,{allOwnKeys:!0}),t.create=function(r){return Ft(V(s,r))},t}const R=Ft(te);R.Axios=z;R.CanceledError=X;R.CancelToken=xs;R.isCancel=Tt;R.VERSION=jt;R.toFormData=me;R.AxiosError=w;R.Cancel=R.CanceledError;R.all=function(e){return Promise.all(e)};R.spread=Rs;R.isAxiosError=As;R.mergeConfig=V;R.AxiosHeaders=T;R.formToJSON=s=>Ot(l.isHTMLForm(s)?new FormData(s):s);R.getAdapter=Lt.getAdapter;R.HttpStatusCode=Ie;R.default=R;const{Axios:Kr,AxiosError:Xr,CanceledError:Gr,isCancel:Zr,CancelToken:Qr,VERSION:Yr,all:ei,Cancel:ti,isAxiosError:ni,spread:si,toFormData:ri,AxiosHeaders:ii,HttpStatusCode:oi,formToJSON:ci,getAdapter:ai,mergeConfig:li}=R,we=R.create({baseURL:location.origin,timeout:6e4,params:{}});we.interceptors.response.use(s=>s,s=>{var e,t,n,r,i,o,c,h,u,a,d;if(s.response){if(s.response.status===401&&OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity,!0).then(function(f){f&&OpenC3Auth.setTokens()}),s.response.config.headers["Ignore-Errors"]&&s.response.config.headers["Ignore-Errors"].includes(s.response.status.toString()))return Promise.reject(s);let g=`HTTP ${s.response.status} - `;(e=s.response)!=null&&e.statusText&&(g+=`${s.response.statusText} `),(n=(t=s.response)==null?void 0:t.config)!=null&&n.data&&(g+=`${s.response.config.data} `),(i=(r=s.response)==null?void 0:r.data)!=null&&i.message?g+=`${s.response.data.message}`:(c=(o=s.response)==null?void 0:o.data)!=null&&c.exception?g+=`${s.response.data.exception}`:(a=(u=(h=s.response)==null?void 0:h.data)==null?void 0:u.error)!=null&&a.message?(s.response.data.error.class&&(g+=`${s.response.data.error.class} `),g+=`${s.response.data.error.message}`):g+=`${(d=s.response)==null?void 0:d.data}`;const{$cosmosNotify:b}=window;throw b&&b.serious({title:"Network error",body:g}),s}else throw s});const re=async function(s,e,{data:t,params:n={},headers:r,noAuth:i=!1,noScope:o=!1,onUploadProgress:c=!1}={}){if(!i){try{await OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity)&&OpenC3Auth.setTokens()}catch{OpenC3Auth.login()}r.Authorization=localStorage.openc3Token}return r.manual=!0,!o&&!n.scope&&(n.scope=window.openc3Scope),we({method:s,url:e,data:t,params:n,headers:r,onUploadProgress:c})},ve={Accept:"application/json"},it={...ve,"Content-Type":"application/json"},Cs={get:function(s,{params:e,headers:t=ve,noScope:n,noAuth:r,onUploadProgress:i}={}){return re("get",s,{params:e,headers:t,noScope:n,noAuth:r,onUploadProgress:i})},put:function(s,{data:e,params:t,headers:n=it,noScope:r,noAuth:i,onUploadProgress:o}={}){return re("put",s,{data:e,params:t,headers:n,noScope:r,noAuth:i,onUploadProgress:o})},post:function(s,{data:e,params:t,headers:n=it,noScope:r,noAuth:i,onUploadProgress:o}={}){return re("post",s,{data:e,params:t,headers:n,noScope:r,noAuth:i,onUploadProgress:o})},delete:function(s,{params:e,headers:t=ve,noScope:n,noAuth:r,onUploadProgress:i}={}){return re("delete",s,{params:e,headers:t,noScope:n,noAuth:r,onUploadProgress:i})}};let ye=()=>({emit(s,...e){for(let t=this.events[s]||[],n=0,r=t.length;n<r;n++)t[n](...e)},events:{},on(s,e){var t;return((t=this.events)[s]||(t[s]=[])).push(e),()=>{var n;this.events[s]=(n=this.events[s])==null?void 0:n.filter(r=>e!==r)}}});class ne extends Error{constructor(e,t){e instanceof Error?(super(e.message),this.cause=e):super(e),this.reason=t,this.name="ReasonError"}}class qe extends ne{constructor(e){super("Rejected",e),this.name="SubscriptionRejectedError"}}class Os extends ne{constructor(e){super(e||"Timed out to receive subscription ack"),this.name="SubscriptionTimeoutError"}}class j extends ne{constructor(e,t){t?super(e,t):super("Disconnected",e),this.name="DisconnectedError"}}class Ts extends j{constructor(e){super(e,"stale_connection"),this.name="StaleConnectionError"}}function Ut(s){return s?`{${Object.keys(s).sort().filter(t=>s[t]!==void 0).map(t=>{let n=JSON.stringify(s[t]);return`${JSON.stringify(t)}:${n}`}).join(",")}}`:""}class ks{constructor(e){this.channel=e,this.listeners=[]}watch(){this.listeners.push(this.channel.on("presence",e=>{if(e.type==="info"){this._state||(this._state=this.stateFromInfo(e));return}this._state&&(e.type==="join"?this._state[e.id]=e.info:e.type==="leave"&&delete this._state[e.id])}))}reset(){delete this._state}dispose(){delete this._info,delete this._state,this.listeners.forEach(e=>e()),this.listeners.length=0}async join(e,t){if(!this._info)return this._info={id:e,info:t},this.channel.perform("$presence:join",this._info)}async leave(){if(!this._info)return;let e=await this.channel.perform("$presence:leave");return delete this._info,e}async info(){return this._state?this._state:(this._promise||(this._promise=this._sync()),await this._promise,this._state)}async _sync(){this.watch();try{let e=await this.channel.perform("$presence:info",{});return this._state=this.stateFromInfo(e),this._state}finally{delete this._promise}}stateFromInfo(e){return e.records.reduce((t,{id:n,info:r})=>(t[n]=r,t),{})}}const B=Symbol("state");class Dt{constructor(e={}){this.emitter=ye(),this.params=Object.freeze(e),this.presence=new ks(this),this.initialConnect=!0,this[B]="idle"}get identifier(){return this._identifier?this._identifier:(this._identifier=Ut({channel:this.channelId,...this.params}),this._identifier)}get channelId(){return this.constructor.identifier}get state(){return this[B]}attached(e){if(this.receiver){if(this.receiver!==e)throw Error("Already connected to a different receiver");return!1}return this.receiver=e,!0}connecting(){this[B]="connecting"}connected(){if(this.state==="connected"||this.state==="closed")return;this[B]="connected";let e=!1;this.initialConnect?(this.initialConnect=!1,this.emit("connect",{reconnect:!1,restored:e})):this.emit("connect",{reconnect:!0,restored:e})}restored(){if(this.state==="connected")throw Error("Already connected");this[B]="connected";let e=!0,t=!0;this.initialConnect=!1,this.emit("connect",{reconnect:t,restored:e})}disconnected(e){this.state==="disconnected"||this.state==="closed"||(this[B]="disconnected",this.presence.reset(),this.emit("disconnect",e))}closed(e){this.state!=="closed"&&(this[B]="closed",delete this.receiver,this.initialConnect=!0,this.presence.dispose(),this.emit("close",e))}disconnect(){this.state==="idle"||this.state==="closed"||this.receiver.unsubscribe(this)}async perform(e,t){if(this.state==="idle"||this.state==="closed")throw Error("Channel is not subscribed");return this.receiver.perform(this.identifier,e,t)}async send(e){return this.perform(void 0,e)}async whisper(e){try{await this.perform("$whisper",e)}catch(t){let n=this.receiver?this.receiver.logger:null;n&&n.warn("whisper failed: ",t)}}receive(e,t){this.emit("message",e,t)}on(e,t){return this.emitter.on(e,t)}once(e,t){let n=this.emitter.on(e,(...r)=>{n(),t(...r)});return n}emit(e,...t){return this.emitter.emit(e,...t)}ensureSubscribed(){return this.state==="connected"?Promise.resolve():this.state==="closed"?Promise.reject(Error("Channel is unsubscribed")):this.pendingSubscribe()}pendingSubscribe(){return this._pendingSubscribe?this._pendingSubscribe:(this._pendingSubscribe=new Promise((e,t)=>{let n=[()=>delete this._pendingSubscribe];n.push(this.on("connect",()=>{n.forEach(r=>r()),e()})),n.push(this.on("close",r=>{n.forEach(i=>i()),t(r||new ne("Channel was disconnected before subscribing","canceled"))}))}),this._pendingSubscribe)}}class Ns{constructor(e){this.id=e,this.intent="unsubscribed",this.state="idle",this.channels=[],this.disposed=!1,this._pendings=[]}add(e){this.channels.includes(e)||this.channels.push(e)}remove(e){let t=this.channels.indexOf(e);t>-1&&this.channels.splice(t,1)}notify(e,...t){this.state=e==="restored"?"connected":e,t.length===1?this.channels.forEach(n=>n[e](t[0])):this.channels.forEach(n=>n[e]())}pending(e){this._checkIntent(e);let t=this._pendings[0];return!t||t.intent!==e?Promise.resolve():t.promise}ensureResubscribed(){this.disposed||(this.intent=void 0,this.ensureSubscribed())}ensureSubscribed(){if(this.intent==="subscribed")return;if(this.disposed)throw Error("Subscription is disposed");this.intent="subscribed",!this._mergeWithPending("unsubscribed")&&this.subscriber(this)}maybeUnsubscribe(){this.disposed||this.intent==="unsubscribed"||this.channels.length>0||(this.intent="unsubscribed",this._mergeWithPending("subscribed"))||this.unsubscriber(this)}async acquire(e){this._checkIntent(e);let t,r={promise:new Promise(o=>{t=o}),intent:e,release:()=>{this._pendings.splice(this._pendings.indexOf(r),1),t(r)},canceled:!1,acquired:!1},i=this._pendingTop;return this._pendings.push(r),i&&await i.promise,this.gvl&&await this.gvl.acquire(r,e),r.acquired=!0,r}close(e){this.disposed=!0,this.intent=void 0,this.notify("closed",e)}_checkIntent(e){if(!(e==="unsubscribed"||e==="subscribed"))throw Error(`Unknown subscription intent: ${e}`)}get _pendingTop(){return this._pendings.length?this._pendings[this._pendings.length-1]:void 0}_mergeWithPending(e){let t=this._pendingTop;return!t||t.acquired||t.intent!==e?!1:(this._pendings.pop(),t.canceled=!0,!0)}}class Ps{constructor(){this.queue=[]}async acquire(e,t){t==="subscribed"&&(this.queue.push(e.promise.then(()=>{this.queue.splice(this.queue.indexOf(e),1)})),this.queue.length>1&&await this.queue[this.queue.length-2])}}class Is{constructor(e){e.concurrentSubscribes===!1&&(this.glv=new Ps),this._subscriptions={},this._localToRemote={}}all(){return Object.values(this._subscriptions)}get(e){return this._subscriptions[e]}create(e,{subscribe:t,unsubscribe:n}){let r=this._subscriptions[e]=new Ns(e);return r.remoteId=this._localToRemote[e],r.subscriber=t,r.unsubscriber=n,r.gvl=this.glv,r}remove(e){delete this._subscriptions[e],delete this._localToRemote[e]}storeRemoteId(e,t){this._localToRemote[e]=t;let n=this.get(e);n&&(n.remoteId=t)}}class vs{constructor(e={}){this.subscriptions=new Is(e),this._pendingMessages=[],this._remoteToLocal={}}subscribe(e,t){this._remoteToLocal[t]=e,this.subscriptions.storeRemoteId(e,t),this.flush(t)}unsubscribe(e){let t=this.subscriptions.get(e);if(!t)return;let n=t.remoteId;n&&delete this._remoteToLocal[n],this.subscriptions.remove(e)}transmit(e,t,n){let r=this._remoteToLocal[e];if(!r){this._pendingMessages.push([e,t,n]);return}let i=this.subscriptions.get(r);i&&i.channels.forEach(o=>{o.receive(t,n)})}notify(e,t,n){let r=this._remoteToLocal[e];if(!r)return;let i=this.subscriptions.get(r);i&&i.channels.forEach(o=>o.emit(t,n))}close(){this._pendingMessages.length=0}get size(){return this.channels.length}get channels(){return this.subscriptions.all().flatMap(e=>e.channels)}flush(e){let t=[];for(let n of this._pendingMessages)n[0]===e?this.transmit(n[0],n[1],n[2]):t.push(n);this._pendingMessages=t}}const ot={debug:0,info:1,warn:2,error:3};class qt{constructor(e){this.level=e||"warn"}log(e,t,n){ot[e]<ot[this.level]||this.writeLogEntry(e,t,n)}writeLogEntry(){throw Error("Not implemented")}debug(e,t){this.log("debug",e,t)}info(e,t){this.log("info",e,t)}warn(e,t){this.log("warn",e,t)}error(e,t){this.log("error",e,t)}}class se extends qt{writeLogEntry(){}}class Ls{encode(e){return JSON.stringify(e)}decode(e){try{return JSON.parse(e)}catch{}}}let js=0;class Bt{constructor(e={}){let{logger:t}=e;this.logger=t||new se,this.pendingSubscriptions={},this.pendingUnsubscriptions={},this.subscribeCooldownInterval=e.subscribeCooldownInterval||250,this.subscribeRetryInterval=e.subscribeRetryInterval||5e3}attached(e){this.cable=e}subscribe(e,t){let n={channel:e};t&&Object.assign(n,t);let r=Ut(n);if(this.pendingUnsubscriptions[r]){let o=this.subscribeCooldownInterval*1.5;return this.logger.debug(`unsubscribed recently, cooldown for ${o}`,r),new Promise(c=>{setTimeout(()=>{c(this.subscribe(e,t))},o)})}if(this.pendingSubscriptions[r])return this.logger.warn("subscription is already pending, skipping",r),Promise.reject(Error("Already subscribing"));let i=this.subscribeRetryInterval;return new Promise((o,c)=>{let h=++js;this.pendingSubscriptions[r]={resolve:o,reject:c,id:h},this.cable.send(this.buildSubscribeRequest(r)),this.maybeRetrySubscribe(h,r,i)})}buildSubscribeRequest(e){return{command:"subscribe",identifier:e}}maybeRetrySubscribe(e,t,n){setTimeout(()=>{let r=this.pendingSubscriptions[t];r&&r.id===e&&(this.logger.warn(`no subscription ack received in ${n}ms, retrying subscribe`,t),this.cable.send(this.buildSubscribeRequest(t)),this.maybeExpireSubscribe(e,t,n))},n)}maybeExpireSubscribe(e,t,n){setTimeout(()=>{let r=this.pendingSubscriptions[t];r&&r.id===e&&(delete this.pendingSubscriptions[t],r.reject(new Os(`Haven't received subscription ack in ${n*2}ms for ${t}`)))},n)}unsubscribe(e){return this.cable.send({command:"unsubscribe",identifier:e}),this.pendingUnsubscriptions[e]=!0,setTimeout(()=>{delete this.pendingUnsubscriptions[e]},this.subscribeCooldownInterval),Promise.resolve()}perform(e,t,n){return t==="$whisper"?this.whisper(e,n):(n||(n={}),n.action=t,this.cable.send({command:"message",identifier:e,data:JSON.stringify(n)}),Promise.resolve())}whisper(e,t){return this.cable.send({command:"whisper",identifier:e,data:t}),Promise.resolve()}receive(e){if(typeof e!="object"){this.logger.error("unsupported message format",{message:e});return}let{type:t,identifier:n,message:r,reason:i,reconnect:o}=e;if(t==="ping")return this.cable.keepalive(e.message);if(this.cable.keepalive(),t==="welcome"){let c=e.sid;return c&&this.cable.setSessionId(c),this.cable.connected()}if(t==="disconnect"){let c=new j(i);this.reset(c),o===!1?this.cable.closed(c):this.cable.disconnected(c);return}if(t==="confirm_subscription"){let c=this.pendingSubscriptions[n];if(!c){this.logger.error("subscription not found, unsubscribing",{type:t,identifier:n}),this.unsubscribe(n);return}return delete this.pendingSubscriptions[n],c.resolve(n)}if(t==="reject_subscription"){let c=this.pendingSubscriptions[n];return c?(delete this.pendingSubscriptions[n],c.reject(new qe)):this.logger.error("subscription not found",{type:t,identifier:n})}if(r)return{identifier:n,message:r};this.logger.warn(`unknown message type: ${t}`,{message:e})}reset(e){for(let t in this.pendingSubscriptions)this.pendingSubscriptions[t].reject(e);this.pendingSubscriptions={}}recoverableClosure(){return!1}}const ct=()=>Date.now()/1e3|0;class $s extends Bt{constructor(e={}){super(e),this.streamsPositions={},this.subscriptionStreams={},this.pendingHistory={},this.pendingPresence={},this.presenceInfo={},this.restoreSince=e.historyTimestamp,this.restoreSince===void 0&&(this.restoreSince=ct()),this.sessionId=void 0,this.sendPongs=e.pongs}reset(e){for(let t in this.pendingPresence)this.pendingPresence[t].reject(e);return this.pendingPresence={},super.reset()}receive(e){if(typeof e!="object"){this.logger.error("unsupported message format",{message:e});return}let{type:t,identifier:n,message:r}=e;if(t==="disconnect"||t==="reject_subscription")return super.receive(e);if(t==="confirm_subscription")return this.subscriptionStreams[n]||(this.subscriptionStreams[n]=new Set),super.receive(e);if(t==="ping")return this.restoreSince&&(this.restoreSince=ct()),this.sendPongs&&this.sendPong(),this.cable.keepalive(e.message);if(this.cable.keepalive(),t==="confirm_history"){this.logger.debug("history result received",e),this.cable.notify("history_received",n);return}if(t==="reject_history"){this.logger.warn("failed to retrieve history",e),this.cable.notify("history_not_found",n);return}if(t==="welcome"){if(this.sessionId=e.sid,this.sessionId&&this.cable.setSessionId(this.sessionId),e.restored){let i=e.restored_ids||Object.keys(this.subscriptionStreams);for(let o of i)this.cable.send({identifier:o,command:"history",history:this.historyRequestFor(o)}),this.presenceInfo[o]&&this.cable.send({identifier:o,command:"join",presence:this.presenceInfo[o]});return this.cable.restored(i)}return this.cable.connected(this.sessionId)}if(t==="presence"){let i=r.type;if(i==="info"){let o=this.pendingPresence[n];o&&(delete this.pendingPresence[n],o.resolve(r))}else if(i==="error"){let o=this.pendingPresence[n];o&&(delete this.pendingPresence[n],o.reject(new Error("failed to retrieve presence")))}return{type:t,identifier:n,message:r}}if(r){let i=this.trackStreamPosition(n,e.stream_id,e.epoch,e.offset);return{identifier:n,message:r,meta:i}}this.logger.warn(`unknown message type: ${t}`,{message:e})}perform(e,t,n){switch(t){case"$presence:join":return this.join(e,n);case"$presence:leave":return this.leave(e,n);case"$presence:info":return this.presence(e,n)}return super.perform(e,t,n)}unsubscribe(e){return delete this.presenceInfo[e],super.unsubscribe(e)}buildSubscribeRequest(e){let t=super.buildSubscribeRequest(e),n=this.historyRequestFor(e);n&&(t.history=n,this.pendingHistory[e]=!0);let r=this.presenceInfo[e];return r&&(t.presence=r),t}recoverableClosure(){return!!this.sessionId}historyRequestFor(e){let t={},n=!1;if(this.subscriptionStreams[e])for(let r of this.subscriptionStreams[e]){let i=this.streamsPositions[r];i&&(n=!0,t[r]=i)}if(!(!n&&!this.restoreSince))return{since:this.restoreSince,streams:t}}trackStreamPosition(e,t,n,r){if(!(!t||!n))return this.subscriptionStreams[e]||(this.subscriptionStreams[e]=new Set),this.subscriptionStreams[e].add(t),this.streamsPositions[t]={epoch:n,offset:r},{stream:t,epoch:n,offset:r}}async sendPong(){await new Promise(e=>setTimeout(e,0)),this.cable.state==="connected"&&this.cable.send({command:"pong"})}async join(e,t){return this.presenceInfo[e]=t,this.cable.send({command:"join",identifier:e,presence:t}),Promise.resolve()}async leave(e,t){return delete this.presenceInfo[e],this.cable.send({command:"leave",identifier:e,presence:t}),Promise.resolve()}presence(e,t){return this.pendingPresence[e]?(this.logger.warn("presence is already pending, skipping",e),Promise.reject(Error("presence request is already pending"))):new Promise((n,r)=>{this.pendingPresence[e]={resolve:n,reject:r},this.cable.send({command:"presence",identifier:e,data:t})})}}class Fs extends ne{constructor(){super("No connection","closed"),this.name="NoConnectionError"}}class Be extends Dt{constructor(e,t){super(t),this.channelId=e}set channelId(e){this._channelId=e}get channelId(){return this._channelId}}L(Be,"identifier","__ghost__");const Us="$pubsub";class Le extends Dt{async perform(e,t){if(e.startsWith("$"))return super.perform(e,t);throw Error("not implemented")}}L(Le,"identifier",Us);const M=Symbol("state");let Ds=class{constructor({transport:e,protocol:t,encoder:n,logger:r,lazy:i,hubOptions:o,performFailures:c,transportConfigurator:h}){this.emitter=ye(),this.transport=e,this.encoder=n,this.logger=r||new se,this.protocol=t,this.performFailures=c||"throw",this.protocol.attached(this),this.hub=new vs(o||{}),this[M]="idle",this.handleClose=this.handleClose.bind(this),this.handleIncoming=this.handleIncoming.bind(this),this.transportConfigurator=h,this.transport.on("close",this.handleClose),this.transport.on("data",this.handleIncoming),this.initialConnect=!0,this.recovering=!1,i===!1&&this.connect().catch(()=>{})}get state(){return this[M]}async connect(){if(this.state==="connected")return Promise.resolve();if(this.state==="connecting")return this.pendingConnect();let e=this.state==="idle";this[M]="connecting";let t=this.pendingConnect();this.logger.debug("connecting");try{this.transportConfigurator&&await this.transportConfigurator(this.transport,{initial:e}),await this.transport.open()}catch(n){this.handleClose(n)}return t}setSessionId(e){this.sessionId=e,this.transport.setParam("sid",e)}connected(){if(this.state==="connected")return;this.logger.info("connected"),this[M]="connected",this.recovering&&this.hub.subscriptions.all().forEach(t=>t.notify("disconnected",new j("recovery_failed"))),this.hub.subscriptions.all().forEach(t=>this._resubscribe(t));let e=!1;this.recovering=!1,this.initialConnect?(this.initialConnect=!1,this.emit("connect",{reconnect:!1,restored:e})):this.emit("connect",{reconnect:!0,restored:e})}restored(e){this.logger.info("connection recovered",{remoteIds:e}),this[M]="connected",this.hub.subscriptions.all().forEach(r=>{e&&r.remoteId&&e.includes(r.remoteId)?r.notify("restored"):(r.notify("disconnected",new j("recovery_failed")),this._resubscribe(r))});let t=!this.initialConnect,n=!0;this.recovering=!1,this.initialConnect=!1,this.emit("connect",{reconnect:t,restored:n})}notify(e,t,n){t&&typeof t!="string"&&(n=t,t=void 0),t?this.hub.notify(t,"info",{type:e,data:n}):this.emit("info",{type:e,data:n})}handleClose(e){this.logger.debug("transport closed",{error:e}),this.disconnected(new j(e,"transport_closed"))}disconnected(e){(this.state==="connected"||this.state==="connecting")&&(this.logger.info("disconnected",{reason:e}),this[M]="disconnected",this.recovering=this.protocol.recoverableClosure(e),this.recovering?this.hub.subscriptions.all().forEach(t=>t.notify("connecting")):this.hub.subscriptions.all().forEach(t=>{t.notify("disconnected",e)}),this.protocol.reset(e),this.hub.close(),this.transport.close(),this.emit("disconnect",e))}closed(e){if(this.state==="closed"||this.state==="idle")return;let t;e&&(t=e instanceof j?e:new j(e,void 0)),this.logger.info("closed",{reason:e||"user"}),this[M]="closed";let n=t||new j("cable_closed");this.hub.subscriptions.all().forEach(r=>r.notify("disconnected",n)),this.hub.close(),this.protocol.reset(),this.transport.close(),this.initialConnect=!0,this.emit("close",t)}disconnect(){this.closed()}handleIncoming(e){if(this.state==="closed"||this.state==="idle")return;let t=this.encoder.decode(e);if(t===void 0){this.logger.error("failed to decode message",{message:e});return}this.logger.debug("incoming data",t);let n=this.protocol.receive(t);if(n){this.logger.debug("processed incoming message",n);let{type:r,identifier:i,message:o,meta:c}=n;r?this.hub.notify(i,r,o):this.hub.transmit(i,o,c)}}send(e){if(this.state==="closed")throw Error("Cable is closed");let t=this.encoder.encode(e);if(t===void 0){this.logger.error("failed to encode message",{message:e});return}this.logger.debug("outgoing message",e),this.transport.send(t)}keepalive(e){this.emit("keepalive",e)}streamFrom(e){let t=new Le({stream_name:e});return this.subscribe(t)}streamFromSigned(e){let t=new Le({signed_stream_name:e});return this.subscribe(t)}subscribeTo(e,t){let n,r;return typeof e=="string"&&(r=e,e=Be),n=r?new e(r,t):new e(t),this.subscribe(n)}subscribe(e){if(!e.attached(this))return e;let t=e.identifier;e.connecting();let n=this.hub.subscriptions.get(t)||this.hub.subscriptions.create(t,{subscribe:r=>this._subscribe(r,e.channelId,e.params),unsubscribe:r=>this._unsubscribe(r)});return n.add(e),n.intent==="subscribed"&&n.state==="connected"&&e.connected(),n.ensureSubscribed(),e}async _resubscribe(e){e.intent!=="subscribed"||!e.channels[0]||(e.notify("connecting"),e.ensureResubscribed())}async _subscribe(e,t,n){let r=e.id;if(this.state==="idle"&&this.connect().catch(()=>{}),this.state!=="connected"){this.logger.debug("cancel subscribe, no connection",{identifier:r});return}this.logger.debug("acquiring subscribe lock",{identifier:r});let i=await e.acquire("subscribed");if(i.canceled){this.logger.debug("subscribe lock has been canceled",{identifier:r}),i.release();return}if(this.logger.debug("subscribe lock has been acquired",{identifier:r}),e.intent!=="subscribed"){this.logger.debug("cancel subscribe request, already unsubscribed"),i.release();return}if(this.state!=="connected"){this.logger.debug("cancel subscribe, no connection",{identifier:r}),i.release();return}if(e.state==="connected"){this.logger.debug("already connected, skip subscribe command",{identifier:r}),e.notify("connected"),i.release();return}let o={identifier:t,params:n};this.logger.debug("subscribing",o);try{let c=await this.protocol.subscribe(t,n);this.hub.subscribe(r,c),this.logger.debug("subscribed",{...o,remoteId:c}),e.notify("connected")}catch(c){if(c){if(c instanceof qe&&this.logger.warn("rejected",o),c instanceof j){this.logger.debug("disconnected during subscription; will retry on connect",o),i.release();return}this.logger.error("failed to subscribe",{error:c,...o})}e.close(c),this.hub.unsubscribe(r)}i.release()}unsubscribe(e){let t=e.identifier,n=this.hub.subscriptions.get(t);if(!n)throw Error(`Subscription not found: ${t}`);n.remove(e),e.closed(),n.maybeUnsubscribe()}async _unsubscribe(e){let t=e.id;this.logger.debug("acquiring unsubscribe lock",{identifier:t});let n=await e.acquire("unsubscribed");if(n.canceled){this.logger.debug("unsubscribe lock has been canceled",{identifier:t}),n.release();return}if(this.logger.debug("unsubscribe lock has been acquired",{identifier:t}),e.intent!=="unsubscribed"){this.logger.debug("cancel unsubscribe, no longer needed",{identifier:t,intent:e.intent}),n.release();return}if(e.state==="disconnected"||e.state==="closed"){this.logger.debug(`already ${e.state} connected, skip unsubscribe command`,{identifier:t}),n.release();return}let r=e.remoteId;if(this.logger.debug("unsubscribing...",{remoteId:r}),this.state!=="connected"){this.logger.debug("unsubscribe skipped (cable is not connected)",{id:t}),e.close(),this.hub.unsubscribe(t),n.release();return}try{await this.protocol.unsubscribe(r),this.logger.debug("unsubscribed remotely",{id:t})}catch(i){i&&(i instanceof j?this.logger.debug("cable disconnected during the unsubscribe command execution",{id:t,error:i}):this.logger.error("unsubscribe failed",{id:t,error:i}))}e.intent==="unsubscribed"?(e.close(),this.hub.unsubscribe(t)):e.state="closed",n.release()}async perform(e,t,n){if(this.performFailures==="throw")return this._perform(e,t,n);try{return await this._perform(e,t,n)}catch(r){this.performFailures==="warn"&&this.logger.warn("perform failed",{error:r});return}}async _perform(e,t,n){if(this.state==="connecting"&&await this.pendingConnect(),this.state==="closed"||this.state==="disconnected")throw new Fs;let r=this.hub.subscriptions.get(e);if(!r)throw Error(`Subscription not found: ${e}`);if(await r.pending("subscribed"),r.intent!=="subscribed")throw Error(`Subscription is closed: ${e}`);let i=r.remoteId,o={id:i,action:t,payload:n};this.logger.debug("perform",o);try{let c=await this.protocol.perform(i,t,n);return c&&this.logger.debug("perform result",{message:c,request:o}),c}catch(c){throw this.logger.error("perform failed",{error:c,request:o}),c}}on(e,t){return this.emitter.on(e,t)}once(e,t){let n=this.emitter.on(e,(...r)=>{n(),t(...r)});return n}emit(e,...t){return this.emitter.emit(e,...t)}pendingConnect(){return this._pendingConnect?this._pendingConnect:(this._pendingConnect=new Promise((e,t)=>{let n=[()=>delete this._pendingConnect];n.push(this.on("connect",()=>{n.forEach(r=>r()),e()})),n.push(this.on("close",r=>{n.forEach(i=>i()),t(r)})),n.push(this.on("disconnect",r=>{n.forEach(i=>i()),t(r)}))}),this._pendingConnect)}};const qs={maxMissingPings:2,maxReconnectAttempts:1/0},W=()=>Date.now(),Mt=(s,e)=>{e=e||{};let{backoffRate:t,jitterRatio:n,maxInterval:r}=e;return t=t||2,n===void 0&&(n=.5),i=>{let o=s*t**i,c=o*t,h=o+(c-o)*Math.random(),u=2*(Math.random()-.5)*n;return h=h*(1+u),r&&r<h&&(h=r),h}};let Ht=class{constructor({pingInterval:e,...t}){if(this.pingInterval=e,!this.pingInterval)throw Error(`Incorrect pingInterval is provided: ${e}`);if(t=Object.assign({},qs,t),this.strategy=t.reconnectStrategy,!this.strategy)throw Error("Reconnect strategy must be provided");this.maxMissingPings=t.maxMissingPings,this.maxReconnectAttempts=t.maxReconnectAttempts,this.logger=t.logger||new se,this.state="pending_connect",this.attempts=0,this.disconnectedAt=W()}watch(e){this.target=e,this.initListeners()}reconnectNow(){return this.state==="connected"||this.state==="pending_connect"||this.state==="closed"?!1:(this.cancelReconnect(),this.state="pending_connect",this.target.connect().catch(e=>{this.logger.info("Failed at reconnecting: "+e)}),!0)}initListeners(){this.unbind=[],this.unbind.push(this.target.on("connect",()=>{this.attempts=0,this.pingedAt=W(),this.state="connected",this.cancelReconnect(),this.startPolling()})),this.unbind.push(this.target.on("disconnect",()=>{this.disconnectedAt=W(),this.state="disconnected",this.stopPolling(),this.scheduleReconnect()})),this.unbind.push(this.target.on("close",()=>{this.disconnectedAt=W(),this.state="closed",this.cancelReconnect(),this.stopPolling()})),this.unbind.push(this.target.on("keepalive",()=>{this.pingedAt=W()})),this.unbind.push(()=>{this.cancelReconnect(),this.stopPolling()})}dispose(){delete this.target,this.unbind&&this.unbind.forEach(e=>e()),delete this.unbind}startPolling(){this.pollId&&clearTimeout(this.pollId);let e=this.pingInterval+(Math.random()-.5)*this.pingInterval*.5;this.pollId=setTimeout(()=>{this.checkStale(),this.state==="connected"&&this.startPolling()},e)}stopPolling(){this.pollId&&clearTimeout(this.pollId)}checkStale(){let e=W()-this.pingedAt;e>this.maxMissingPings*this.pingInterval&&(this.logger.warn(`Stale connection: ${e}ms without pings`),this.state="pending_disconnect",this.target.disconnected(new Ts))}scheduleReconnect(){if(this.attempts>=this.maxReconnectAttempts){this.target.close();return}let e=this.strategy(this.attempts);this.attempts++,this.logger.info(`Reconnecting in ${e}ms (${this.attempts} attempt)`),this.state="pending_reconnect",this.reconnnectId=setTimeout(()=>this.reconnectNow(),e)}cancelReconnect(){this.reconnnectId&&(clearTimeout(this.reconnnectId),delete this.reconnnectId)}};class Bs{constructor(e,t={}){this.transports=e,this.transport=null,this.emitter=ye(),this.unbind=[],this.logger=t.logger||new se}displayName(){return"fallbacked transport"}async open(){for(let e=0;e<this.transports.length;e++){let t=this.transports[e];try{this.transport=t,this.resetListeners(),this.logger.debug(`Trying to connect via ${t.displayName()}`),await t.open(),this.logger.debug(`Connected via ${t.displayName()}`);return}catch(n){this.logger.debug(`Failed to connect via ${t.displayName()}: ${n.message}`)}}throw this.transport=null,this.resetListeners(),new Error("Couldn't connect via any available transport")}send(e){if(!this.transport)throw new Error("No transport is open");this.transport.send(e)}async close(){if(!this.transport)throw new Error("No transport is open");await this.transport.close(),this.transport=null}setURL(){throw new Error("Not implemented. Set URL for each transport separately")}setParam(e,t){this.transports.forEach(n=>{n.setParam(e,t)})}setToken(e,t){this.transports.forEach(n=>{n.setToken(e,t)})}on(e,t){return this.emitter.on(e,t)}once(e,t){let n=this.emitter.on(e,(...r)=>{n(),t(...r)});return n}get url(){return this.transport?this.transport.url:""}resetListeners(){this.unbind.forEach(e=>e()),this.unbind.length=0,this.transport&&this.unbind.push(this.transport.on("open",()=>{this.emitter.emit("open")}),this.transport.on("data",e=>{this.emitter.emit("data",e)}),this.transport.on("close",e=>{this.emitter.emit("close",e)}),this.transport.on("error",e=>{this.emitter.emit("error",e)}))}}class Ms{constructor(e,t={}){this.url=e;let n=t.websocketImplementation;if(n)this.Impl=n;else if(typeof WebSocket<"u")this.Impl=WebSocket;else throw new Error("No WebSocket support");this.connected=!1,this.emitter=ye();let{format:r,subprotocol:i,authStrategy:o}=t;this.format=r||"text",this.connectionOptions=t.websocketOptions,this.authStrategy=o||"param",this.authProtocol="",this.subprotocol=i}displayName(){return"WebSocket("+this.url+")"}open(){let e=this.subprotocol;return this.authStrategy==="sub-protocol"&&(e=[this.subprotocol,this.authProtocol]),this.connectionOptions?this.ws=new this.Impl(this.url,e,this.connectionOptions):this.ws=new this.Impl(this.url,e),this.ws.binaryType="arraybuffer",this.initListeners(),new Promise((t,n)=>{let r=[];r.push(this.once("open",()=>{r.forEach(i=>i()),t()})),r.push(this.once("close",()=>{r.forEach(i=>i()),n(Error("WS connection closed"))}))})}setURL(e){this.url=e}setParam(e,t){let n=new URL(this.url);n.searchParams.set(e,t);let r=`${n.protocol}//${n.host}${n.pathname}?${n.searchParams}`;this.setURL(r)}setToken(e,t="jid"){if(this.authStrategy==="param")this.setParam(t,e);else if(this.authStrategy==="header"){this.connectionOptions=this.connectionOptions||{},this.connectionOptions.headers=this.connectionOptions.headers||{};let n=`x-${t}`.toLowerCase();n=Object.keys(this.connectionOptions.headers).find(i=>i.toLowerCase()===n)||n,this.connectionOptions.headers[n]=e}else if(this.authStrategy==="sub-protocol")this.authProtocol=`anycable-token.${e}`;else throw new Error("Unknown auth strategy: "+this.authStrategy)}send(e){if(!this.ws||!this.connected)throw Error("WebSocket is not connected");this.ws.send(e)}close(){this.ws?this.onclose():this.connected=!1}on(e,t){return this.emitter.on(e,t)}once(e,t){let n=this.emitter.on(e,(...r)=>{n(),t(...r)});return n}initListeners(){this.ws.onerror=e=>{this.connected&&this.emitter.emit("error",e.error||new Error("WS Error"))},this.ws.onclose=()=>{this.onclose()},this.ws.onmessage=e=>{let t=e.data;this.format==="binary"&&(t=new Uint8Array(t)),this.emitter.emit("data",t)},this.ws.onopen=()=>{this.connected=!0,this.emitter.emit("open")}}onclose(){this.ws.onclose=void 0,this.ws.onmessage=void 0,this.ws.onopen=void 0,this.ws.close(),delete this.ws,this.connected=!1,this.emitter.emit("close")}}const zt={protocol:"actioncable-v1-json",pingInterval:3e3,maxReconnectAttempts:1/0,maxMissingPings:2,logLevel:"warn",lazy:!0};function Hs(s,e){if(typeof s=="object"&&typeof e>"u"&&(e=s,s=void 0),e=e||{},!s&&!e.transport)throw Error("URL or transport must be specified");e=Object.assign({},zt,e);let{protocol:t,websocketImplementation:n,websocketFormat:r,websocketOptions:i,websocketAuthStrategy:o,fallbacks:c,logLevel:h,logger:u,transport:a,encoder:d,lazy:g,monitor:b,pingInterval:f,reconnectStrategy:m,maxMissingPings:p,maxReconnectAttempts:_,subprotocol:E,tokenRefresher:S,historyTimestamp:k,protocolOptions:x,concurrentSubscribes:P,performFailures:I,transportConfigurator:D,auth:U}=e;if(u=u||new se(h),typeof t=="string"){E=E||t;let J=t.substring(0,t.lastIndexOf("-")),O=t.substring(t.lastIndexOf("-")+1);if(x=x||{},J==="actioncable-v1")t=new Bt({logger:u,...x});else if(J==="actioncable-v1-ext")t=new $s({logger:u,historyTimestamp:k,...x});else throw Error(`Protocol is not supported yet: ${t}`);if(O==="json")d=d||new Ls,r=r||"text";else if(O==="msgpack"){if(r="binary",!d)throw Error("Msgpack encoder must be specified explicitly. Use `@anycable/msgpack-encoder` package or build your own")}else if(O==="protobuf"){if(r=r||"binary",!d)throw Error("Protobuf encoder must be specified explicitly. Use `@anycable/protobuf-encoder` package or build your own")}else throw Error(`Protocol is not supported yet: ${t}`)}if(!t)throw Error("Protocol must be specified");a=a||new Ms(s,{websocketImplementation:n,websocketOptions:i,subprotocol:E,authStrategy:o,format:r}),c&&(a=new Bs([a,...c],{logger:u})),U&&U.token&&a.setToken(U.token,U.param||"jid"),m=m||Mt(f),b!==!1&&(b=b||new Ht({pingInterval:f,reconnectStrategy:m,maxMissingPings:p,maxReconnectAttempts:_,logger:u}));let Ee={concurrentSubscribes:P},v=new Ds({protocol:t,transport:a,encoder:d,logger:u,lazy:g,hubOptions:Ee,performFailures:I,transportConfigurator:D});return b&&(b.watch(v),v.monitor=b),S&&zs(v,async()=>{try{await S(a)}catch(J){return u.error("Failed to refresh authentication token: "+J),!1}return v.connect().catch(()=>{}),!0}),v}function zs(s,e){let t=!1;s.on("connect",()=>t=!1),s.on("close",async n=>{if(n){if(t){s.logger.warn("Token auto-refresh is disabled",n);return}n.reason==="token_expired"&&(t=!0,await e())}})}class Vs{constructor(e){this.channel=e}notify(e,...t){typeof this[e]=="function"&&this[e](...t)}perform(e,t={}){this.channel.perform(e,t)}send(e){this.channel.send(e)}get identifier(){return this.channel.identifier}unsubscribe(){return this.channel.disconnect()}}class Js extends Be{constructor(e,t,n){super(e,t),this.subscription=new Vs(this),Object.assign(this.subscription,n),this.on("connect",({reconnect:r})=>this.subscription.notify("connected",{reconnected:r})),this.on("disconnect",()=>this.subscription.notify("disconnected",{allowReconnect:!0})),this.on("message",r=>this.subscription.notify("received",r)),this.on("close",r=>{r&&r instanceof qe?this.subscription.notify("rejected"):this.subscription.notify("disconnected",{allowReconnect:!1})})}}class Ws{constructor(e){this.cable=e}create(e,t){let n,r;typeof e=="object"?(n=e.channel,delete e.channel,r=e):(n=e,r={});let i=new Js(n,r,t);return i.subscription.notify("initialized"),this.cable.subscribe(i),i.subscription}findAll(e){return this.cable.hub.channels.filter(t=>t.identifier===e).map(t=>t.subscription)}}class Ks{constructor(e){this.cable=e,this.subscriptions=new Ws(e)}}class Xs extends qt{writeLogEntry(e,t,n){n?console[e](t,n):console[e](t)}}class Gs extends Ht{watch(e){super.watch(e),this.initActivityListeners()}initActivityListeners(){if(typeof document<"u"&&typeof window<"u"&&document.addEventListener&&window.addEventListener){let e=()=>{document.hidden||this.reconnectNow()&&this.logger.debug("Trigger reconnect due to visibility change")},t=r=>{this.reconnectNow()&&this.logger.debug("Trigger reconnect",{event:r})},n=()=>this.disconnect(new j("page_frozen"));document.addEventListener("visibilitychange",e,!1),window.addEventListener("focus",t,!1),window.addEventListener("online",t,!1),window.addEventListener("resume",t,!1),window.addEventListener("freeze",n,!1),this.unbind.push(()=>{document.removeEventListener("visibilitychange",e,!1),window.removeEventListener("focus",t,!1),window.removeEventListener("online",t,!1),window.removeEventListener("resume",t,!1),window.removeEventListener("freeze",n,!1)})}}disconnect(e){this.state==="disconnected"||this.state==="closed"||(this.logger.info("Disconnecting",{reason:e.message}),this.cancelReconnect(),this.stopPolling(),this.state="pending_disconnect",this.target.disconnected(e))}}const Zs=["cable","action-cable"],Qs="/cable",_e=(s,e)=>{for(let t of Zs){let n=s.head.querySelector(`meta[name='${t}-${e}']`);if(n)return n.getAttribute("content")}},at=s=>s.match(/wss?:\/\//)?s:typeof window<"u"?`${window.location.protocol.replace("http","ws")}//${window.location.host}${s}`:s,Ys=()=>{if(typeof document<"u"&&document.head){let s=_e(document,"url");if(s)return at(s)}return at(Qs)},er=()=>{if(typeof document<"u"&&document.head){let s=_e(document,"history-timestamp");if(s)return s|0}},tr=()=>{if(typeof document<"u"&&document.head)return _e(document,"token")},nr=()=>{if(typeof document<"u"&&document.head)return _e(document,"token-param")};function sr(s,e){typeof s=="object"&&typeof e>"u"&&(e=s,s=void 0),s=s||Ys(),e=e||{},e.historyTimestamp||(e.historyTimestamp=er());let t=tr();if(t){let u=nr();e.auth=Object.assign({token:t,param:u},e.auth||{})}e=Object.assign({},zt,e);let{logLevel:n,logger:r,pingInterval:i,reconnectStrategy:o,maxMissingPings:c,maxReconnectAttempts:h}=e;return r=e.logger=e.logger||new Xs(n),o=e.reconnectStrategy=e.reconnectStrategy||Mt(i),e.monitor!==!1&&(e.monitor=e.monitor||new Gs({pingInterval:i,reconnectStrategy:o,maxMissingPings:c,maxReconnectAttempts:h,logger:r})),Hs(s,e)}function rr(s,e){let t=sr(s,e);return new Ks(t)}class ir{constructor(e="/openc3-api/cable"){this._cable=null,this._url=e}disconnect(){this._cable&&(this._cable.cable.disconnect(),this._cable=null)}createSubscription(e,t,n={},r={}){return OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity).then(i=>{if(i&&OpenC3Auth.setTokens(),this._cable==null){let o=this._url+"?scope="+encodeURIComponent(window.openc3Scope)+"&authorization="+encodeURIComponent(localStorage.openc3Token);o=new URL(o,document.baseURI).href,this._cable=rr(o)}return this._cable.subscriptions.create({channel:e,...r},n)})}recordPing(){}}class je{constructor(e,t,n="",r=""){this.keyword=e.keyword,this.parameters=e.parameters,this.filename=e.filename,this.line=e.line,this.lineNumber=e.lineNumber,this.message=t,this.usage=n,this.url=r}}class or{constructor(){L(this,"keyword",null);L(this,"parameters",[]);L(this,"filename","");L(this,"line","");L(this,"lineNumber",0);L(this,"url","https://docs.openc3.com/docs/configuration")}verify_num_parameters(e,t,n=""){for(let r=1;r<=e;r++)if(this.parameters[r-1]===void 0)throw new je(this,`Not enough parameters for ${this.keyword}.`,n,this.url);if(t&&this.parameters[t]!==void 0)throw new je(this,`Too many parameters for ${this.keyword}.`,n,this.url)}remove_quotes(e){if(e.length<2)return e;let t=e.charAt(0);if(t!=='"'&&t!=="'")return e;let n=e.charAt(e.length-1);return t!==n?e:e.substring(1,e.length-1)}scan_string(e,t){if(!t.global)throw"rx must have 'global' flag set";let n=[];return e.replace(t,function(r){return n.push(r),r}),n}parse_string(e,t,n,r,i){let o=!1;this.line="",this.keyword=null,this.parameters=[],this.filename=t;let c=e.split(`
7
+ `),h=c.length;for(let u=0;u<h;u++){this.lineNumber=u+1;let a=c[u].trim();if(a.length===0){n&&i(null,[],this.line,this.lineNumber);continue}if(o===!0){if(a[0]==="#")continue;a=a.substring(1,a.length)}let d=a.charAt(a.length-1),g=!1;switch(d){case"+":g=!0;case"\\":let _=a.substring(0,a.length-1).trim();this.line+=_.substring(0,_.length-1),g&&(this.line+=`
8
+ `),o=!0;continue;case"&":this.line+=a.substring(0,a.length-1);continue;default:this.line+=a}o=!1;let b=/("([^\\"]|\\.)*")|('([^\\']|\\.)*')|\S+/g,f=this.scan_string(this.line,b),m="";if(f.length>0&&(m=m+f[0]),m.length===0||m.charAt(0)==="#"?this.keyword=null:this.keyword=m.toUpperCase(),this.parameters=[],this.keyword===null){n&&i(this.keyword,this.parameters,this.line,this.lineNumber),this.line="";continue}let p=f.length;if(p>1)for(let _=1;_<p;_++){let E=f[_];if(E.length>0&&E.charAt(0)==="#")break;r?this.parameters.push(this.remove_quotes(E)):this.parameters.push(E)}i(this.keyword,this.parameters,this.line,this.lineNumber),this.line=""}}}function Me(s){return cr.test(s)}const cr=/^-?[0-9]+$/;function Vt(s){return ar.test(s)}const ar=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function Jt(s,e){const t=Number.parseFloat(s),n=String(t),r=lt(s),i=lt(n);return!!(r===i||(e==null?void 0:e.approx)===!0&&!Me(s)&&i.length>=14&&r.startsWith(i.substring(0,14)))}let Q=function(s){return s.underflow="underflow",s.overflow="overflow",s.truncate_integer="truncate_integer",s.truncate_float="truncate_float",s}({});function lr(s){if(Jt(s,{approx:!1}))return;if(Me(s))return Q.truncate_integer;const e=Number.parseFloat(s);return Number.isFinite(e)?e===0?Q.underflow:Q.truncate_float:Q.overflow}function lt(s){return s.replace(ur,"").replace(dr,"").replace(fr,"").replace(hr,"")}const ur=/[eE][+-]?\d+$/,hr=/^-?(0*)?/,dr=/\./,fr=/0+$/;class pr{constructor(e){L(this,"isLosslessNumber",!0);if(!Vt(e))throw new Error(`Invalid number (value: "${e}")`);this.value=e}valueOf(){const e=lr(this.value);if(e===void 0||e===Q.truncate_float)return Number.parseFloat(this.value);if(Me(this.value))return BigInt(this.value);throw new Error(`Cannot safely convert to number: the value '${this.value}' would ${e} and become ${Number.parseFloat(this.value)}`)}toString(){return this.value}}function mr(s){return s&&typeof s=="object"&&s.isLosslessNumber===!0||!1}function gr(s){return new pr(s)}function br(s,e){return He({"":s},"",s,e)}function He(s,e,t,n){return Array.isArray(t)?n.call(s,e,yr(t,n)):t&&typeof t=="object"&&!mr(t)?n.call(s,e,wr(t,n)):n.call(s,e,t)}function wr(s,e){for(const t of Object.keys(s)){const n=He(s,t,s[t],e);n!==void 0?s[t]=n:delete s[t]}return s}function yr(s,e){for(let t=0;t<s.length;t++)s[t]=He(s,String(t),s[t],e);return s}function _r(s,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:gr,n=0;const r=c();return f(r),p(),e?br(r,e):r;function i(){if(s.charCodeAt(n)===Cr){n++,u();const y={};let A=!0;for(;n<s.length&&s.charCodeAt(n)!==ht;){A?A=!1:(g(),u());const q=n,G=a();if(G===void 0){S();return}u(),b();const Se=c();if(Se===void 0){U();return}Object.prototype.hasOwnProperty.call(y,G)&&!$e(Se,y[G])&&k(G,q+1),y[G]=Se}return s.charCodeAt(n)!==ht&&x(),n++,y}}function o(){if(s.charCodeAt(n)===Or){n++,u();const y=[];let A=!0;for(;n<s.length&&s.charCodeAt(n)!==dt;){A?A=!1:g();const q=c();m(q),y.push(q)}return s.charCodeAt(n)!==dt&&P(),n++,y}}function c(){u();const y=a()??d()??i()??o()??h("true",!0)??h("false",!1)??h("null",null);return u(),y}function h(y,A){if(s.slice(n,n+y.length)===y)return n+=y.length,A}function u(){for(;Er(s.charCodeAt(n));)n++}function a(){if(s.charCodeAt(n)===Ce){n++;let y="";for(;n<s.length&&s.charCodeAt(n)!==Ce;){if(s.charCodeAt(n)===Ar){const A=s[n+1],q=Rr[A];q!==void 0?(y+=q,n++):A==="u"?ie(s.charCodeAt(n+2))&&ie(s.charCodeAt(n+3))&&ie(s.charCodeAt(n+4))&&ie(s.charCodeAt(n+5))?(y+=String.fromCharCode(Number.parseInt(s.slice(n+2,n+6),16)),n+=5):Ee(n):D(n)}else xr(s.charCodeAt(n))?y+=s[n]:I(s[n]);n++}return E(),n++,y}}function d(){const y=n;if(s.charCodeAt(n)===ft&&(n++,_(y)),s.charCodeAt(n)===ze)n++;else if(Sr(s.charCodeAt(n)))for(n++;oe(s.charCodeAt(n));)n++;if(s.charCodeAt(n)===jr)for(n++,_(y);oe(s.charCodeAt(n));)n++;if(s.charCodeAt(n)===qr||s.charCodeAt(n)===Dr)for(n++,(s.charCodeAt(n)===ft||s.charCodeAt(n)===Ir)&&n++,_(y);oe(s.charCodeAt(n));)n++;if(n>y)return t(s.slice(y,n))}function g(){if(s.charCodeAt(n)!==Lr)throw new SyntaxError(`Comma ',' expected after value ${O()}`);n++}function b(){if(s.charCodeAt(n)!==$r)throw new SyntaxError(`Colon ':' expected after property name ${O()}`);n++}function f(y){if(y===void 0)throw new SyntaxError(`JSON value expected ${O()}`)}function m(y){if(y===void 0)throw new SyntaxError(`Array item expected ${O()}`)}function p(){if(n<s.length)throw new SyntaxError(`Expected end of input ${O()}`)}function _(y){if(!oe(s.charCodeAt(n))){const A=s.slice(y,n);throw new SyntaxError(`Invalid number '${A}', expecting a digit ${O()}`)}}function E(){if(s.charCodeAt(n)!==Ce)throw new SyntaxError(`End of string '"' expected ${O()}`)}function S(){throw new SyntaxError(`Quoted object key expected ${O()}`)}function k(y,A){throw new SyntaxError(`Duplicate key '${y}' encountered at position ${A}`)}function x(){throw new SyntaxError(`Quoted object key or end of object '}' expected ${O()}`)}function P(){throw new SyntaxError(`Array item or end of array ']' expected ${O()}`)}function I(y){throw new SyntaxError(`Invalid character '${y}' ${v()}`)}function D(y){const A=s.slice(y,y+2);throw new SyntaxError(`Invalid escape character '${A}' ${v()}`)}function U(){throw new SyntaxError(`Object value expected after ':' ${v()}`)}function Ee(y){const A=s.slice(y,y+6);throw new SyntaxError(`Invalid unicode character '${A}' ${v()}`)}function v(){return`at position ${n}`}function J(){return n<s.length?`but got '${s[n]}'`:"but reached end of input"}function O(){return`${J()} ${v()}`}}function Er(s){return s===Tr||s===kr||s===Nr||s===Pr}function ie(s){return s>=ze&&s<=Ve||s>=Fr&&s<=Br||s>=Ur&&s<=Mr}function oe(s){return s>=ze&&s<=Ve}function Sr(s){return s>=vr&&s<=Ve}function xr(s){return s>=32&&s<=1114111}function $e(s,e){return s===e?!0:Array.isArray(s)&&Array.isArray(e)?s.length===e.length&&s.every((t,n)=>$e(t,e[n])):ut(s)&&ut(e)?[...new Set([...Object.keys(s),...Object.keys(e)])].every(n=>$e(s[n],e[n])):!1}function ut(s){return typeof s=="object"&&s!==null}const Rr={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
9
+ `,r:"\r",t:" "},Ar=92,Cr=123,ht=125,Or=91,dt=93,Tr=32,kr=10,Nr=9,Pr=13,Ce=34,Ir=43,ft=45,ze=48,vr=49,Ve=57,Lr=44,jr=46,$r=58,Fr=65,Ur=97,Dr=69,qr=101,Br=70,Mr=102;function Wt(s,e,t,n){const r=void 0;return o(s,"");function o(a,d){if(Array.isArray(n)){const g=n.find(b=>b.test(a));if(g){const b=g.stringify(a);if(typeof b!="string"||!Vt(b))throw new Error(`Invalid JSON number: output of a number stringifier must be a string containing a JSON number (output: ${b})`);return b}}if(typeof a=="boolean"||typeof a=="number"||typeof a=="string"||a===null||a instanceof Date||a instanceof Boolean||a instanceof Number||a instanceof String)return JSON.stringify(a);if(a!=null&&a.isLosslessNumber||typeof a=="bigint")return a.toString();if(Array.isArray(a))return c(a,d);if(a&&typeof a=="object")return h(a,d)}function c(a,d){if(a.length===0)return"[]";const g=r?d+r:void 0;let b=r?`[
10
+ `:"[";for(let f=0;f<a.length;f++){const m=a[f];r&&(b+=g),typeof m<"u"&&typeof m!="function"?b+=o(m,g):b+="null",f<a.length-1&&(b+=r?`,
11
+ `:",")}return b+=r?`
12
+ ${d}]`:"]",b}function h(a,d){if(typeof a.toJSON=="function")return Wt(a.toJSON(),e,t,void 0);const g=Array.isArray(e)?e.map(String):Object.keys(a);if(g.length===0)return"{}";const b=r?d+r:void 0;let f=!0,m=r?`{
13
+ `:"{";for(const p of g){const _=a[p];if(u(p,_)){f?f=!1:m+=r?`,
14
+ `:",";const E=JSON.stringify(p);m+=r?`${b+E}: `:`${E}:`,m+=o(_,b)}}return m+=r?`
15
+ ${d}}`:"}",m}function u(a,d){return typeof d<"u"&&typeof d!="function"&&typeof d!="symbol"}}function Hr(s){return Jt(s)?parseFloat(s):BigInt(s)}class zr{constructor(){L(this,"id",1)}async exec(e,t,n={},r={},i=6e4){try{await OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity)&&OpenC3Auth.setTokens()}catch{OpenC3Auth.login()}this.id=this.id+1;try{return n.scope=window.openc3Scope,r.manual=!0,(await we.post("/openc3-api/api",{jsonrpc:"2.0",method:e,params:t,id:this.id,keyword_params:n},{headers:{Authorization:localStorage.openc3Token,"Content-Type":"application/json-rpc",...r},timeout:i,transformRequest:[(c,h)=>Wt(c)],transformResponse:[c=>_r(c,void 0,Hr)]})).data.result}catch(o){let c=new Error;throw o.response?(c.name=o.response.data.error.data.class,c.message=o.response.data.error.data.message,c.object=o.response.data.error):o.request?(c.name="Request error",c.message="Request error, no response received"):c.name="Unknown error",c}}decode_openc3_type(e){if(e!==null&&typeof e=="object"&&e.json_class=="Float"&&e.raw){if(e.raw=="NaN")return NaN;if(e.raw=="Infinity")return 1/0;if(e.raw=="-Infinity")return-1/0}return null}encode_openc3_type(e){return Number.isNaN(e)?{json_class:"Float",raw:"NaN"}:e==Number.POSITIVE_INFINITY?{json_class:"Float",raw:"Infinity"}:e==Number.NEGATIVE_INFINITY?{json_class:"Float",raw:"-Infinity"}:null}ensure_offline_access(){this.offline_access_needed().then(e=>{e&&(localStorage.openc3OfflineToken?this.set_offline_access(localStorage.openc3OfflineToken).then(()=>{delete localStorage.openc3OfflineToken}):OpenC3Auth.getOfflineAccess())})}offline_access_needed(){return this.exec("offline_access_needed",[])}set_offline_access(e){return this.exec("set_offline_access",[e])}get_all_interface_info(){return this.exec("get_all_interface_info",[])}map_target_to_interface(e,t){return this.exec("map_target_to_interface",[e,t])}connect_interface(e,...t){return t.length>0?this.exec("connect_interface",[e,...t]):this.exec("connect_interface",[e])}disconnect_interface(e){return this.exec("disconnect_interface",[e])}interface_cmd(e,t,...n){return this.exec("interface_cmd",[e,t,...n])}get_all_router_info(){return this.exec("get_all_router_info",[])}connect_router(e){return this.exec("connect_router",[e])}disconnect_router(e){return this.exec("disconnect_router",[e])}get_target_interfaces(){return this.exec("get_target_interfaces",[])}get_tlm_cnts(e){return this.exec("get_tlm_cnts",[e])}get_item(e,t,n){return this.exec("get_item",[e,t,n])}get_param(e,t,n){return this.exec("get_param",[e,t,n])}get_parameter(e,t,n){return this.exec("get_param",[e,t,n])}get_limits_sets(){return this.exec("get_limits_sets",[])}get_limits_set(){return this.exec("get_limits_set",[])}set_limits_set(e){return this.exec("set_limits_set",[e])}get_target(e){return this.exec("get_target",[e])}get_target_names(){return this.exec("get_target_names",[])}get_target_list(){return this.exec("get_target_names",[])}get_tlm(e,t){return this.exec("get_tlm",[e,t])}get_telemetry(e,t){return this.exec("get_tlm",[e,t])}get_all_tlm(e){return this.exec("get_all_tlm",[e])}get_all_telemetry(e){return this.exec("get_all_tlm",[e])}get_all_tlm_names(e,t=!1){return this.exec("get_all_tlm_names",[e],{hidden:t})}get_all_telemetry_names(e){return this.exec("get_all_tlm_names",[e])}get_all_tlm_item_names(e){return this.exec("get_all_tlm_item_names",[e])}async get_tlm_packet(e,t,n,r=30){const i=await this.exec("get_tlm_packet",[e,t],{type:n,stale_time:r});if(i!=null){let o=i.length,c=null;for(let h=0;h<o;h++)c=this.decode_openc3_type(i[h][1]),c!==null&&(i[h][1]=c)}return i}get_packet_derived_items(e,t){return this.exec("get_packet_derived_items",[e,t])}get_tlm_buffer(e,t){return this.exec("get_tlm_buffer",[e,t])}async get_tlm_values(e,t=30,n=null){let r={stale_time:t};n!==null&&(r.cache_timeout=n);const i=await this.exec("get_tlm_values",[e],r,{},1e4);let o=i[0].length,c=null;for(let h=0;h<o;h++)c=this.decode_openc3_type(i[0][h]),c!==null&&(i[0][h]=c);return i}get_limits(e,t,n){return this.exec("get_limits",[e,t,n])}async tlm(e,t,n,r="CONVERTED"){let i=null;if(t===void 0)i=await this.exec("tlm",[e]);else if(n===void 0)if(["RAW","CONVERTED","FORMATTED","WITH_UNITS"].includes(t))i=await this.exec("tlm",[e],{type:t});else{let c=new Error;throw c.name="TypeError",c.message=`Invalid data type ${t}. Valid options are RAW, CONVERTED, FORMATTED, and WITH_UNITS.`,c}else i=await this.exec("tlm",[e,t,n],{type:r});let o=this.decode_openc3_type(i);return o!==null&&(i=o),i}async inject_tlm(e,t,n=null,r="CONVERTED"){await this.exec("inject_tlm",[e,t,n],{type:r})}set_tlm(e,t,n,r){return this.exec("set_tlm",[e,t,n],{type:r})}override_tlm(e,t,n,r){return this.exec("override_tlm",[e,t,n],{type:r})}get_overrides(){return this.exec("get_overrides")}normalize_tlm(e,t,n,r){return this.exec("normalize_tlm",[e,t,n],{type:r})}get_all_cmds(e){return this.exec("get_all_cmds",[e])}get_all_commands(e){return this.exec("get_all_cmds",[e])}get_all_cmd_names(e,t=!1){return this.exec("get_all_cmd_names",[e],{hidden:t})}get_all_command_names(e){return this.exec("get_all_cmd_names",[e])}get_cmd(e,t){return this.exec("get_cmd",[e,t])}get_command(e,t){return this.exec("get_cmd",[e,t])}get_cmd_cnts(e){return this.exec("get_cmd_cnts",[e])}get_cmd_value(e,t,n,r="CONVERTED"){return this.exec("get_cmd_value",[e,t,n,r])}get_cmd_buffer(e,t){return this.exec("get_cmd_buffer",[e,t])}_cmd(e,t,n,r,i){let o=null;for(let c in r)Object.prototype.hasOwnProperty.call(r,c)&&(o=this.encode_openc3_type(r[c]),o!==null&&(r[c]=o));return this.exec(e,[t,n,r],{},i)}get_cmd_hazardous(e,t,n,r={}){return t===void 0?this.exec("get_cmd_hazardous",e,{},r):this._cmd("get_cmd_hazardous",e,t,n,r)}cmd(e,t,n,r={}){return t===void 0?this.exec("cmd",e,{},r):this._cmd("cmd",e,t,n,r)}cmd_no_range_check(e,t,n,r={}){return t===void 0?this.exec("cmd_no_range_check",e,{},r):this._cmd("cmd_no_range_check",e,t,n,r)}cmd_raw(e,t,n,r={}){return t===void 0?this.exec("cmd_raw",e,{},r):this._cmd("cmd_raw",e,t,n,r)}cmd_raw_no_range_check(e,t,n,r={}){return t===void 0?this.exec("cmd_raw_no_range_check",e,{},r):this._cmd("cmd_raw_no_range_check",e,t,n,r)}cmd_no_hazardous_check(e,t,n,r={}){return t===void 0?this.exec("cmd_no_hazardous_check",e,{},r):this._cmd("cmd_no_hazardous_check",e,t,n,r)}cmd_no_checks(e,t,n,r={}){return t===void 0?this.exec("cmd_no_checks",e,{},r):this._cmd("cmd_no_checks",e,t,n,r)}cmd_raw_no_hazardous_check(e,t,n,r={}){return t===void 0?this.exec("cmd_raw_no_hazardous_check",e,{},r):this._cmd("cmd_raw_no_hazardous_check",e,t,n,r)}cmd_raw_no_checks(e,t,n,r={}){return t===void 0?this.exec("cmd_raw_no_checks",e,{},r):this._cmd("cmd_raw_no_checks",e,t,n,r)}build_cmd(e,t,n){return t===void 0?this.exec("build_cmd",e):this._cmd("build_cmd",e,t,n)}build_command(e,t,n){return t===void 0?this.exec("build_cmd",e):this._cmd("build_cmd",e,t,n)}get_interface_names(){return this.exec("get_interface_names",[])}send_raw(e,t){return this.exec("send_raw",[e,t])}list_configs(e){return this.exec("list_configs",[e])}load_config(e,t){return this.exec("load_config",[e,t])}save_config(e,t,n){return this.exec("save_config",[e,t,n])}delete_config(e,t){return this.exec("delete_config",[e,t])}enable_limits(e,t,n){return this.exec("enable_limits",[e,t,n])}disable_limits(e,t,n){return this.exec("disable_limits",[e,t,n])}get_out_of_limits(){return this.exec("get_out_of_limits",[])}get_overall_limits_state(e){return this.exec("get_overall_limits_state",[e])}list_settings(){return this.exec("list_settings",[])}get_all_settings(){return this.exec("get_all_settings",[])}get_setting(e){return this.exec("get_setting",[e])}get_settings(e){return this.exec("get_settings",e)}set_setting(e,t){return this.exec("set_setting",[e,t])}update_news(){return this.exec("update_news",[])}save_setting(e,t){return this.exec("set_setting",[e,t])}get_metrics(){return this.exec("get_metrics",[])}async hashString(e){if(window.isSecureContext){const t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t),r=new Uint8Array(n);return Array.from(r).map(i=>i.toString(16).padStart(2,"0")).join("")}}}exports.Api=Cs;exports.Cable=ir;exports.ConfigParserError=je;exports.ConfigParserService=or;exports.OpenC3Api=zr;exports.axios=we;
16
+ //# sourceMappingURL=services.cjs.map