@openc3/js-common 7.0.0-rc2 → 7.0.0-rc3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/services.cjs CHANGED
@@ -1,16 +1,16 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function St(n,e){return function(){return n.apply(e,arguments)}}const{toString:nn}=Object.prototype,{getPrototypeOf:Be}=Object,{iterator:Ee,toStringTag:xt}=Symbol,Se=(n=>e=>{const t=nn.call(e);return n[t]||(n[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),q=n=>(n=n.toLowerCase(),e=>Se(e)===n),xe=n=>e=>typeof e===n,{isArray:ee}=Array,Y=xe("undefined");function se(n){return n!==null&&!Y(n)&&n.constructor!==null&&!Y(n.constructor)&&k(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const Rt=q("ArrayBuffer");function rn(n){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(n):e=n&&n.buffer&&Rt(n.buffer),e}const sn=xe("string"),k=xe("function"),At=xe("number"),ie=n=>n!==null&&typeof n=="object",on=n=>n===!0||n===!1,be=n=>{if(Se(n)!=="object")return!1;const e=Be(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(xt in n)&&!(Ee in n)},cn=n=>{if(!ie(n)||se(n))return!1;try{return Object.keys(n).length===0&&Object.getPrototypeOf(n)===Object.prototype}catch{return!1}},an=q("Date"),ln=q("File"),un=q("Blob"),hn=q("FileList"),dn=n=>ie(n)&&k(n.pipe),fn=n=>{let e;return n&&(typeof FormData=="function"&&n instanceof FormData||k(n.append)&&((e=Se(n))==="formdata"||e==="object"&&k(n.toString)&&n.toString()==="[object FormData]"))},pn=q("URLSearchParams"),[mn,gn,bn,_n]=["ReadableStream","Request","Response","Headers"].map(q),yn=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function oe(n,e,{allOwnKeys:t=!1}={}){if(n===null||typeof n>"u")return;let r,s;if(typeof n!="object"&&(n=[n]),ee(n))for(r=0,s=n.length;r<s;r++)e.call(null,n[r],r,n);else{if(se(n))return;const o=t?Object.getOwnPropertyNames(n):Object.keys(n),i=o.length;let c;for(r=0;r<i;r++)c=o[r],e.call(null,n[c],c,n)}}function Ot(n,e){if(se(n))return null;e=e.toLowerCase();const t=Object.keys(n);let r=t.length,s;for(;r-- >0;)if(s=t[r],e===s.toLowerCase())return s;return null}const K=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ct=n=>!Y(n)&&n!==K;function Le(){const{caseless:n,skipUndefined:e}=Ct(this)&&this||{},t={},r=(s,o)=>{const i=n&&Ot(t,o)||o;be(t[i])&&be(s)?t[i]=Le(t[i],s):be(s)?t[i]=Le({},s):ee(s)?t[i]=s.slice():(!e||!Y(s))&&(t[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&oe(arguments[s],r);return t}const wn=(n,e,t,{allOwnKeys:r}={})=>(oe(e,(s,o)=>{t&&k(s)?Object.defineProperty(n,o,{value:St(s,t),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(n,o,{value:s,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),n),En=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),Sn=(n,e,t,r)=>{n.prototype=Object.create(e.prototype,r),Object.defineProperty(n.prototype,"constructor",{value:n,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(n,"super",{value:e.prototype}),t&&Object.assign(n.prototype,t)},xn=(n,e,t,r)=>{let s,o,i;const c={};if(e=e||{},n==null)return e;do{for(s=Object.getOwnPropertyNames(n),o=s.length;o-- >0;)i=s[o],(!r||r(i,n,e))&&!c[i]&&(e[i]=n[i],c[i]=!0);n=t!==!1&&Be(n)}while(n&&(!t||t(n,e))&&n!==Object.prototype);return e},Rn=(n,e,t)=>{n=String(n),(t===void 0||t>n.length)&&(t=n.length),t-=e.length;const r=n.indexOf(e,t);return r!==-1&&r===t},An=n=>{if(!n)return null;if(ee(n))return n;let e=n.length;if(!At(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=n[e];return t},On=(n=>e=>n&&e instanceof n)(typeof Uint8Array<"u"&&Be(Uint8Array)),Cn=(n,e)=>{const r=(n&&n[Ee]).call(n);let s;for(;(s=r.next())&&!s.done;){const o=s.value;e.call(n,o[0],o[1])}},Tn=(n,e)=>{let t;const r=[];for(;(t=n.exec(e))!==null;)r.push(t);return r},Nn=q("HTMLFormElement"),kn=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,r,s){return r.toUpperCase()+s}),Ge=(({hasOwnProperty:n})=>(e,t)=>n.call(e,t))(Object.prototype),Pn=q("RegExp"),Tt=(n,e)=>{const t=Object.getOwnPropertyDescriptors(n),r={};oe(t,(s,o)=>{let i;(i=e(s,o,n))!==!1&&(r[o]=i||s)}),Object.defineProperties(n,r)},In=n=>{Tt(n,(e,t)=>{if(k(n)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const r=n[t];if(k(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},vn=(n,e)=>{const t={},r=s=>{s.forEach(o=>{t[o]=!0})};return ee(n)?r(n):r(String(n).split(e)),t},Ln=()=>{},$n=(n,e)=>n!=null&&Number.isFinite(n=+n)?n:e;function Fn(n){return!!(n&&k(n.append)&&n[xt]==="FormData"&&n[Ee])}const jn=n=>{const e=new Array(10),t=(r,s)=>{if(ie(r)){if(e.indexOf(r)>=0)return;if(se(r))return r;if(!("toJSON"in r)){e[s]=r;const o=ee(r)?[]:{};return oe(r,(i,c)=>{const d=t(i,s+1);!Y(d)&&(o[c]=d)}),e[s]=void 0,o}}return r};return t(n,0)},Un=q("AsyncFunction"),Dn=n=>n&&(ie(n)||k(n))&&k(n.then)&&k(n.catch),Nt=((n,e)=>n?setImmediate:e?((t,r)=>(K.addEventListener("message",({source:s,data:o})=>{s===K&&o===t&&r.length&&r.shift()()},!1),s=>{r.push(s),K.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",k(K.postMessage)),qn=typeof queueMicrotask<"u"?queueMicrotask.bind(K):typeof process<"u"&&process.nextTick||Nt,Bn=n=>n!=null&&k(n[Ee]),l={isArray:ee,isArrayBuffer:Rt,isBuffer:se,isFormData:fn,isArrayBufferView:rn,isString:sn,isNumber:At,isBoolean:on,isObject:ie,isPlainObject:be,isEmptyObject:cn,isReadableStream:mn,isRequest:gn,isResponse:bn,isHeaders:_n,isUndefined:Y,isDate:an,isFile:ln,isBlob:un,isRegExp:Pn,isFunction:k,isStream:dn,isURLSearchParams:pn,isTypedArray:On,isFileList:hn,forEach:oe,merge:Le,extend:wn,trim:yn,stripBOM:En,inherits:Sn,toFlatObject:xn,kindOf:Se,kindOfTest:q,endsWith:Rn,toArray:An,forEachEntry:Cn,matchAll:Tn,isHTMLForm:Nn,hasOwnProperty:Ge,hasOwnProp:Ge,reduceDescriptors:Tt,freezeMethods:In,toObjectSet:vn,toCamelCase:kn,noop:Ln,toFiniteNumber:$n,findKey:Ot,global:K,isContextDefined:Ct,isSpecCompliantForm:Fn,toJSONObject:jn,isAsyncFn:Un,isThenable:Dn,setImmediate:Nt,asap:qn,isIterable:Bn};let b=class kt extends Error{static from(e,t,r,s,o,i){const c=new kt(e.message,t||e.code,r,s,o);return c.cause=e,c.name=e.name,i&&Object.assign(c,i),c}constructor(e,t,r,s,o){super(e),this.name="AxiosError",this.isAxiosError=!0,t&&(this.code=t),r&&(this.config=r),s&&(this.request=s),o&&(this.response=o,this.status=o.status)}toJSON(){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}}};b.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";b.ERR_BAD_OPTION="ERR_BAD_OPTION";b.ECONNABORTED="ECONNABORTED";b.ETIMEDOUT="ETIMEDOUT";b.ERR_NETWORK="ERR_NETWORK";b.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";b.ERR_DEPRECATED="ERR_DEPRECATED";b.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";b.ERR_BAD_REQUEST="ERR_BAD_REQUEST";b.ERR_CANCELED="ERR_CANCELED";b.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";b.ERR_INVALID_URL="ERR_INVALID_URL";const Mn=null;function $e(n){return l.isPlainObject(n)||l.isArray(n)}function Pt(n){return l.endsWith(n,"[]")?n.slice(0,-2):n}function Qe(n,e,t){return n?n.concat(e).map(function(s,o){return s=Pt(s),!t&&o?"["+s+"]":s}).join(t?".":""):e}function Hn(n){return l.isArray(n)&&!n.some($e)}const zn=l.toFlatObject(l,{},null,function(e){return/^is[A-Z]/.test(e)});function Re(n,e,t){if(!l.isObject(n))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 r=t.metaTokens,s=t.visitor||a,o=t.dots,i=t.indexes,d=(t.Blob||typeof Blob<"u"&&Blob)&&l.isSpecCompliantForm(e);if(!l.isFunction(s))throw new TypeError("visitor must be a function");function u(h){if(h===null)return"";if(l.isDate(h))return h.toISOString();if(l.isBoolean(h))return h.toString();if(!d&&l.isBlob(h))throw new b("Blob is not supported. Use a Buffer instead.");return l.isArrayBuffer(h)||l.isTypedArray(h)?d&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function a(h,m,p){let w=h;if(h&&!p&&typeof h=="object"){if(l.endsWith(m,"{}"))m=r?m:m.slice(0,-2),h=JSON.stringify(h);else if(l.isArray(h)&&Hn(h)||(l.isFileList(h)||l.endsWith(m,"[]"))&&(w=l.toArray(h)))return m=Pt(m),w.forEach(function(S,O){!(l.isUndefined(S)||S===null)&&e.append(i===!0?Qe([m],O,o):i===null?m:m+"[]",u(S))}),!1}return $e(h)?!0:(e.append(Qe(p,m,o),u(h)),!1)}const f=[],_=Object.assign(zn,{defaultVisitor:a,convertValue:u,isVisitable:$e});function g(h,m){if(!l.isUndefined(h)){if(f.indexOf(h)!==-1)throw Error("Circular reference detected in "+m.join("."));f.push(h),l.forEach(h,function(w,E){(!(l.isUndefined(w)||w===null)&&s.call(e,w,l.isString(E)?E.trim():E,m,_))===!0&&g(w,m?m.concat(E):[E])}),f.pop()}}if(!l.isObject(n))throw new TypeError("data must be an object");return g(n),e}function Ze(n){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function Me(n,e){this._pairs=[],n&&Re(n,this,e)}const It=Me.prototype;It.append=function(e,t){this._pairs.push([e,t])};It.toString=function(e){const t=e?function(r){return e.call(this,r,Ze)}:Ze;return this._pairs.map(function(s){return t(s[0])+"="+t(s[1])},"").join("&")};function Vn(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function vt(n,e,t){if(!e)return n;const r=t&&t.encode||Vn,s=l.isFunction(t)?{serialize:t}:t,o=s&&s.serialize;let i;if(o?i=o(e,s):i=l.isURLSearchParams(e)?e.toString():new Me(e,s).toString(r),i){const c=n.indexOf("#");c!==-1&&(n=n.slice(0,c)),n+=(n.indexOf("?")===-1?"?":"&")+i}return n}class Ye{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:r?r.synchronous:!1,runWhen:r?r.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(r){r!==null&&e(r)})}}const Lt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Jn=typeof URLSearchParams<"u"?URLSearchParams:Me,Wn=typeof FormData<"u"?FormData:null,Kn=typeof Blob<"u"?Blob:null,Xn={isBrowser:!0,classes:{URLSearchParams:Jn,FormData:Wn,Blob:Kn},protocols:["http","https","file","blob","url","data"]},He=typeof window<"u"&&typeof document<"u",Fe=typeof navigator=="object"&&navigator||void 0,Gn=He&&(!Fe||["ReactNative","NativeScript","NS"].indexOf(Fe.product)<0),Qn=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Zn=He&&window.location.href||"http://localhost",Yn=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:He,hasStandardBrowserEnv:Gn,hasStandardBrowserWebWorkerEnv:Qn,navigator:Fe,origin:Zn},Symbol.toStringTag,{value:"Module"})),N={...Yn,...Xn};function er(n,e){return Re(n,new N.classes.URLSearchParams,{visitor:function(t,r,s,o){return N.isNode&&l.isBuffer(t)?(this.append(r,t.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...e})}function tr(n){return l.matchAll(/\w+|\[(\w*)]/g,n).map(e=>e[0]==="[]"?"":e[1]||e[0])}function nr(n){const e={},t=Object.keys(n);let r;const s=t.length;let o;for(r=0;r<s;r++)o=t[r],e[o]=n[o];return e}function $t(n){function e(t,r,s,o){let i=t[o++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),d=o>=t.length;return i=!i&&l.isArray(s)?s.length:i,d?(l.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!l.isObject(s[i]))&&(s[i]=[]),e(t,r,s[i],o)&&l.isArray(s[i])&&(s[i]=nr(s[i])),!c)}if(l.isFormData(n)&&l.isFunction(n.entries)){const t={};return l.forEachEntry(n,(r,s)=>{e(tr(r),s,t,0)}),t}return null}function rr(n,e,t){if(l.isString(n))try{return(e||JSON.parse)(n),l.trim(n)}catch(r){if(r.name!=="SyntaxError")throw r}return(t||JSON.stringify)(n)}const ce={transitional:Lt,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",s=r.indexOf("application/json")>-1,o=l.isObject(e);if(o&&l.isHTMLForm(e)&&(e=new FormData(e)),l.isFormData(e))return s?JSON.stringify($t(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(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return er(e,this.formSerializer).toString();if((c=l.isFileList(e))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return Re(c?{"files[]":e}:e,d&&new d,this.formSerializer)}}return o||s?(t.setContentType("application/json",!1),rr(e)):e}],transformResponse:[function(e){const t=this.transitional||ce.transitional,r=t&&t.forcedJSONParsing,s=this.responseType==="json";if(l.isResponse(e)||l.isReadableStream(e))return e;if(e&&l.isString(e)&&(r&&!this.responseType||s)){const i=!(t&&t.silentJSONParsing)&&s;try{return JSON.parse(e,this.parseReviver)}catch(c){if(i)throw c.name==="SyntaxError"?b.from(c,b.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:N.classes.FormData,Blob:N.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"],n=>{ce.headers[n]={}});const sr=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"]),ir=n=>{const e={};let t,r,s;return n&&n.split(`
2
- `).forEach(function(i){s=i.indexOf(":"),t=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!t||e[t]&&sr[t])&&(t==="set-cookie"?e[t]?e[t].push(r):e[t]=[r]:e[t]=e[t]?e[t]+", "+r:r)}),e},et=Symbol("internals");function te(n){return n&&String(n).trim().toLowerCase()}function _e(n){return n===!1||n==null?n:l.isArray(n)?n.map(_e):String(n)}function or(n){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=t.exec(n);)e[r[1]]=r[2];return e}const cr=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function ke(n,e,t,r,s){if(l.isFunction(r))return r.call(this,e,t);if(s&&(e=t),!!l.isString(e)){if(l.isString(r))return e.indexOf(r)!==-1;if(l.isRegExp(r))return r.test(e)}}function ar(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r)}function lr(n,e){const t=l.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(n,r+t,{value:function(s,o,i){return this[r].call(this,e,s,o,i)},configurable:!0})})}let P=class{constructor(e){e&&this.set(e)}set(e,t,r){const s=this;function o(c,d,u){const a=te(d);if(!a)throw new Error("header name must be a non-empty string");const f=l.findKey(s,a);(!f||s[f]===void 0||u===!0||u===void 0&&s[f]!==!1)&&(s[f||d]=_e(c))}const i=(c,d)=>l.forEach(c,(u,a)=>o(u,a,d));if(l.isPlainObject(e)||e instanceof this.constructor)i(e,t);else if(l.isString(e)&&(e=e.trim())&&!cr(e))i(ir(e),t);else if(l.isObject(e)&&l.isIterable(e)){let c={},d,u;for(const a of e){if(!l.isArray(a))throw TypeError("Object iterator must return a key-value pair");c[u=a[0]]=(d=c[u])?l.isArray(d)?[...d,a[1]]:[d,a[1]]:a[1]}i(c,t)}else e!=null&&o(t,e,r);return this}get(e,t){if(e=te(e),e){const r=l.findKey(this,e);if(r){const s=this[r];if(!t)return s;if(t===!0)return or(s);if(l.isFunction(t))return t.call(this,s,r);if(l.isRegExp(t))return t.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=te(e),e){const r=l.findKey(this,e);return!!(r&&this[r]!==void 0&&(!t||ke(this,this[r],r,t)))}return!1}delete(e,t){const r=this;let s=!1;function o(i){if(i=te(i),i){const c=l.findKey(r,i);c&&(!t||ke(r,r[c],c,t))&&(delete r[c],s=!0)}}return l.isArray(e)?e.forEach(o):o(e),s}clear(e){const t=Object.keys(this);let r=t.length,s=!1;for(;r--;){const o=t[r];(!e||ke(this,this[o],o,e,!0))&&(delete this[o],s=!0)}return s}normalize(e){const t=this,r={};return l.forEach(this,(s,o)=>{const i=l.findKey(r,o);if(i){t[i]=_e(s),delete t[o];return}const c=e?ar(o):String(o).trim();c!==o&&delete t[o],t[c]=_e(s),r[c]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return l.forEach(this,(r,s)=>{r!=null&&r!==!1&&(t[s]=e&&l.isArray(r)?r.join(", "):r)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
3
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach(s=>r.set(s)),r}static accessor(e){const r=(this[et]=this[et]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=te(i);r[c]||(lr(s,i),r[c]=!0)}return l.isArray(e)?e.forEach(o):o(e),this}};P.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);l.reduceDescriptors(P.prototype,({value:n},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>n,set(r){this[t]=r}}});l.freezeMethods(P);function Pe(n,e){const t=this||ce,r=e||t,s=P.from(r.headers);let o=r.data;return l.forEach(n,function(c){o=c.call(t,o,s.normalize(),e?e.status:void 0)}),s.normalize(),o}function Ft(n){return!!(n&&n.__CANCEL__)}let ae=class extends b{constructor(e,t,r){super(e??"canceled",b.ERR_CANCELED,t,r),this.name="CanceledError",this.__CANCEL__=!0}};function jt(n,e,t){const r=t.config.validateStatus;!t.status||!r||r(t.status)?n(t):e(new b("Request failed with status code "+t.status,[b.ERR_BAD_REQUEST,b.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function ur(n){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return e&&e[1]||""}function hr(n,e){n=n||10;const t=new Array(n),r=new Array(n);let s=0,o=0,i;return e=e!==void 0?e:1e3,function(d){const u=Date.now(),a=r[o];i||(i=u),t[s]=d,r[s]=u;let f=o,_=0;for(;f!==s;)_+=t[f++],f=f%n;if(s=(s+1)%n,s===o&&(o=(o+1)%n),u-i<e)return;const g=a&&u-a;return g?Math.round(_*1e3/g):void 0}}function dr(n,e){let t=0,r=1e3/e,s,o;const i=(u,a=Date.now())=>{t=a,s=null,o&&(clearTimeout(o),o=null),n(...u)};return[(...u)=>{const a=Date.now(),f=a-t;f>=r?i(u,a):(s=u,o||(o=setTimeout(()=>{o=null,i(s)},r-f)))},()=>s&&i(s)]}const we=(n,e,t=3)=>{let r=0;const s=hr(50,250);return dr(o=>{const i=o.loaded,c=o.lengthComputable?o.total:void 0,d=i-r,u=s(d),a=i<=c;r=i;const f={loaded:i,total:c,progress:c?i/c:void 0,bytes:d,rate:u||void 0,estimated:u&&c&&a?(c-i)/u:void 0,event:o,lengthComputable:c!=null,[e?"download":"upload"]:!0};n(f)},t)},tt=(n,e)=>{const t=n!=null;return[r=>e[0]({lengthComputable:t,total:n,loaded:r}),e[1]]},nt=n=>(...e)=>l.asap(()=>n(...e)),fr=N.hasStandardBrowserEnv?((n,e)=>t=>(t=new URL(t,N.origin),n.protocol===t.protocol&&n.host===t.host&&(e||n.port===t.port)))(new URL(N.origin),N.navigator&&/(msie|trident)/i.test(N.navigator.userAgent)):()=>!0,pr=N.hasStandardBrowserEnv?{write(n,e,t,r,s,o,i){if(typeof document>"u")return;const c=[`${n}=${encodeURIComponent(e)}`];l.isNumber(t)&&c.push(`expires=${new Date(t).toUTCString()}`),l.isString(r)&&c.push(`path=${r}`),l.isString(s)&&c.push(`domain=${s}`),o===!0&&c.push("secure"),l.isString(i)&&c.push(`SameSite=${i}`),document.cookie=c.join("; ")},read(n){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+n+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(n){this.write(n,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function mr(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function gr(n,e){return e?n.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):n}function Ut(n,e,t){let r=!mr(e);return n&&(r||t==!1)?gr(n,e):e}const rt=n=>n instanceof P?{...n}:n;function G(n,e){e=e||{};const t={};function r(u,a,f,_){return l.isPlainObject(u)&&l.isPlainObject(a)?l.merge.call({caseless:_},u,a):l.isPlainObject(a)?l.merge({},a):l.isArray(a)?a.slice():a}function s(u,a,f,_){if(l.isUndefined(a)){if(!l.isUndefined(u))return r(void 0,u,f,_)}else return r(u,a,f,_)}function o(u,a){if(!l.isUndefined(a))return r(void 0,a)}function i(u,a){if(l.isUndefined(a)){if(!l.isUndefined(u))return r(void 0,u)}else return r(void 0,a)}function c(u,a,f){if(f in e)return r(u,a);if(f in n)return r(void 0,u)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(u,a,f)=>s(rt(u),rt(a),f,!0)};return l.forEach(Object.keys({...n,...e}),function(a){const f=d[a]||s,_=f(n[a],e[a],a);l.isUndefined(_)&&f!==c||(t[a]=_)}),t}const Dt=n=>{const e=G({},n);let{data:t,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:c}=e;if(e.headers=i=P.from(i),e.url=vt(Ut(e.baseURL,e.url,e.allowAbsoluteUrls),n.params,n.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),l.isFormData(t)){if(N.hasStandardBrowserEnv||N.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(l.isFunction(t.getHeaders)){const d=t.getHeaders(),u=["content-type","content-length"];Object.entries(d).forEach(([a,f])=>{u.includes(a.toLowerCase())&&i.set(a,f)})}}if(N.hasStandardBrowserEnv&&(r&&l.isFunction(r)&&(r=r(e)),r||r!==!1&&fr(e.url))){const d=s&&o&&pr.read(o);d&&i.set(s,d)}return e},br=typeof XMLHttpRequest<"u",_r=br&&function(n){return new Promise(function(t,r){const s=Dt(n);let o=s.data;const i=P.from(s.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:u}=s,a,f,_,g,h;function m(){g&&g(),h&&h(),s.cancelToken&&s.cancelToken.unsubscribe(a),s.signal&&s.signal.removeEventListener("abort",a)}let p=new XMLHttpRequest;p.open(s.method.toUpperCase(),s.url,!0),p.timeout=s.timeout;function w(){if(!p)return;const S=P.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),C={data:!c||c==="text"||c==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:S,config:n,request:p};jt(function(T){t(T),m()},function(T){r(T),m()},C),p=null}"onloadend"in p?p.onloadend=w:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(w)},p.onabort=function(){p&&(r(new b("Request aborted",b.ECONNABORTED,n,p)),p=null)},p.onerror=function(O){const C=O&&O.message?O.message:"Network Error",$=new b(C,b.ERR_NETWORK,n,p);$.event=O||null,r($),p=null},p.ontimeout=function(){let O=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const C=s.transitional||Lt;s.timeoutErrorMessage&&(O=s.timeoutErrorMessage),r(new b(O,C.clarifyTimeoutError?b.ETIMEDOUT:b.ECONNABORTED,n,p)),p=null},o===void 0&&i.setContentType(null),"setRequestHeader"in p&&l.forEach(i.toJSON(),function(O,C){p.setRequestHeader(C,O)}),l.isUndefined(s.withCredentials)||(p.withCredentials=!!s.withCredentials),c&&c!=="json"&&(p.responseType=s.responseType),u&&([_,h]=we(u,!0),p.addEventListener("progress",_)),d&&p.upload&&([f,g]=we(d),p.upload.addEventListener("progress",f),p.upload.addEventListener("loadend",g)),(s.cancelToken||s.signal)&&(a=S=>{p&&(r(!S||S.type?new ae(null,n,p):S),p.abort(),p=null)},s.cancelToken&&s.cancelToken.subscribe(a),s.signal&&(s.signal.aborted?a():s.signal.addEventListener("abort",a)));const E=ur(s.url);if(E&&N.protocols.indexOf(E)===-1){r(new b("Unsupported protocol "+E+":",b.ERR_BAD_REQUEST,n));return}p.send(o||null)})},yr=(n,e)=>{const{length:t}=n=n?n.filter(Boolean):[];if(e||t){let r=new AbortController,s;const o=function(u){if(!s){s=!0,c();const a=u instanceof Error?u:this.reason;r.abort(a instanceof b?a:new ae(a instanceof Error?a.message:a))}};let i=e&&setTimeout(()=>{i=null,o(new b(`timeout of ${e}ms exceeded`,b.ETIMEDOUT))},e);const c=()=>{n&&(i&&clearTimeout(i),i=null,n.forEach(u=>{u.unsubscribe?u.unsubscribe(o):u.removeEventListener("abort",o)}),n=null)};n.forEach(u=>u.addEventListener("abort",o));const{signal:d}=r;return d.unsubscribe=()=>l.asap(c),d}},wr=function*(n,e){let t=n.byteLength;if(t<e){yield n;return}let r=0,s;for(;r<t;)s=r+e,yield n.slice(r,s),r=s},Er=async function*(n,e){for await(const t of Sr(n))yield*wr(t,e)},Sr=async function*(n){if(n[Symbol.asyncIterator]){yield*n;return}const e=n.getReader();try{for(;;){const{done:t,value:r}=await e.read();if(t)break;yield r}}finally{await e.cancel()}},st=(n,e,t,r)=>{const s=Er(n,e);let o=0,i,c=d=>{i||(i=!0,r&&r(d))};return new ReadableStream({async pull(d){try{const{done:u,value:a}=await s.next();if(u){c(),d.close();return}let f=a.byteLength;if(t){let _=o+=f;t(_)}d.enqueue(new Uint8Array(a))}catch(u){throw c(u),u}},cancel(d){return c(d),s.return()}},{highWaterMark:2})},it=64*1024,{isFunction:fe}=l,xr=(({Request:n,Response:e})=>({Request:n,Response:e}))(l.global),{ReadableStream:ot,TextEncoder:ct}=l.global,at=(n,...e)=>{try{return!!n(...e)}catch{return!1}},Rr=n=>{n=l.merge.call({skipUndefined:!0},xr,n);const{fetch:e,Request:t,Response:r}=n,s=e?fe(e):typeof fetch=="function",o=fe(t),i=fe(r);if(!s)return!1;const c=s&&fe(ot),d=s&&(typeof ct=="function"?(h=>m=>h.encode(m))(new ct):async h=>new Uint8Array(await new t(h).arrayBuffer())),u=o&&c&&at(()=>{let h=!1;const m=new t(N.origin,{body:new ot,method:"POST",get duplex(){return h=!0,"half"}}).headers.has("Content-Type");return h&&!m}),a=i&&c&&at(()=>l.isReadableStream(new r("").body)),f={stream:a&&(h=>h.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(h=>{!f[h]&&(f[h]=(m,p)=>{let w=m&&m[h];if(w)return w.call(m);throw new b(`Response type '${h}' is not supported`,b.ERR_NOT_SUPPORT,p)})});const _=async h=>{if(h==null)return 0;if(l.isBlob(h))return h.size;if(l.isSpecCompliantForm(h))return(await new t(N.origin,{method:"POST",body:h}).arrayBuffer()).byteLength;if(l.isArrayBufferView(h)||l.isArrayBuffer(h))return h.byteLength;if(l.isURLSearchParams(h)&&(h=h+""),l.isString(h))return(await d(h)).byteLength},g=async(h,m)=>{const p=l.toFiniteNumber(h.getContentLength());return p??_(m)};return async h=>{let{url:m,method:p,data:w,signal:E,cancelToken:S,timeout:O,onDownloadProgress:C,onUploadProgress:$,responseType:T,headers:V,withCredentials:F="same-origin",fetchOptions:Q}=Dt(h),B=e||fetch;T=T?(T+"").toLowerCase():"text";let j=yr([E,S&&S.toAbortSignal()],O),U=null;const I=j&&j.unsubscribe&&(()=>{j.unsubscribe()});let he;try{if($&&u&&p!=="get"&&p!=="head"&&(he=await g(V,w))!==0){let v=new t(m,{method:"POST",body:w,duplex:"half"}),z;if(l.isFormData(w)&&(z=v.headers.get("content-type"))&&V.setContentType(z),v.body){const[Ne,de]=tt(he,we(nt($)));w=st(v.body,it,Ne,de)}}l.isString(F)||(F=F?"include":"omit");const R=o&&"credentials"in t.prototype,y={...Q,signal:j,method:p.toUpperCase(),headers:V.normalize().toJSON(),body:w,duplex:"half",credentials:R?F:void 0};U=o&&new t(m,y);let x=await(o?B(U,Q):B(m,y));const L=a&&(T==="stream"||T==="response");if(a&&(C||L&&I)){const v={};["status","statusText","headers"].forEach(Xe=>{v[Xe]=x[Xe]});const z=l.toFiniteNumber(x.headers.get("content-length")),[Ne,de]=C&&tt(z,we(nt(C),!0))||[];x=new r(st(x.body,it,Ne,()=>{de&&de(),I&&I()}),v)}T=T||"text";let H=await f[l.findKey(f,T)||"text"](x,h);return!L&&I&&I(),await new Promise((v,z)=>{jt(v,z,{data:H,headers:P.from(x.headers),status:x.status,statusText:x.statusText,config:h,request:U})})}catch(R){throw I&&I(),R&&R.name==="TypeError"&&/Load failed|fetch/i.test(R.message)?Object.assign(new b("Network Error",b.ERR_NETWORK,h,U),{cause:R.cause||R}):b.from(R,R&&R.code,h,U)}}},Ar=new Map,qt=n=>{let e=n&&n.env||{};const{fetch:t,Request:r,Response:s}=e,o=[r,s,t];let i=o.length,c=i,d,u,a=Ar;for(;c--;)d=o[c],u=a.get(d),u===void 0&&a.set(d,u=c?new Map:Rr(e)),a=u;return u};qt();const ze={http:Mn,xhr:_r,fetch:{get:qt}};l.forEach(ze,(n,e)=>{if(n){try{Object.defineProperty(n,"name",{value:e})}catch{}Object.defineProperty(n,"adapterName",{value:e})}});const lt=n=>`- ${n}`,Or=n=>l.isFunction(n)||n===null||n===!1;function Cr(n,e){n=l.isArray(n)?n:[n];const{length:t}=n;let r,s;const o={};for(let i=0;i<t;i++){r=n[i];let c;if(s=r,!Or(r)&&(s=ze[(c=String(r)).toLowerCase()],s===void 0))throw new b(`Unknown adapter '${c}'`);if(s&&(l.isFunction(s)||(s=s.get(e))))break;o[c||"#"+i]=s}if(!s){const i=Object.entries(o).map(([d,u])=>`adapter ${d} `+(u===!1?"is not supported by the environment":"is not available in the build"));let c=t?i.length>1?`since :
4
- `+i.map(lt).join(`
5
- `):" "+lt(i[0]):"as no adapter specified";throw new b("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return s}const Bt={getAdapter:Cr,adapters:ze};function Ie(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new ae(null,n)}function ut(n){return Ie(n),n.headers=P.from(n.headers),n.data=Pe.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),Bt.getAdapter(n.adapter||ce.adapter,n)(n).then(function(r){return Ie(n),r.data=Pe.call(n,n.transformResponse,r),r.headers=P.from(r.headers),r},function(r){return Ft(r)||(Ie(n),r&&r.response&&(r.response.data=Pe.call(n,n.transformResponse,r.response),r.response.headers=P.from(r.response.headers))),Promise.reject(r)})}const Mt="1.13.4",Ae={};["object","boolean","number","function","string","symbol"].forEach((n,e)=>{Ae[n]=function(r){return typeof r===n||"a"+(e<1?"n ":" ")+n}});const ht={};Ae.transitional=function(e,t,r){function s(o,i){return"[Axios v"+Mt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(e===!1)throw new b(s(i," has been removed"+(t?" in "+t:"")),b.ERR_DEPRECATED);return t&&!ht[i]&&(ht[i]=!0,console.warn(s(i," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(o,i,c):!0}};Ae.spelling=function(e){return(t,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};function Tr(n,e,t){if(typeof n!="object")throw new b("options must be an object",b.ERR_BAD_OPTION_VALUE);const r=Object.keys(n);let s=r.length;for(;s-- >0;){const o=r[s],i=e[o];if(i){const c=n[o],d=c===void 0||i(c,o,n);if(d!==!0)throw new b("option "+o+" must be "+d,b.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new b("Unknown option "+o,b.ERR_BAD_OPTION)}}const ye={assertOptions:Tr,validators:Ae},M=ye.validators;let X=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Ye,response:new Ye}}async request(e,t){try{return await this._request(e,t)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const o=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+=`
6
- `+o):r.stack=o}catch{}}throw r}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=G(this.defaults,t);const{transitional:r,paramsSerializer:s,headers:o}=t;r!==void 0&&ye.assertOptions(r,{silentJSONParsing:M.transitional(M.boolean),forcedJSONParsing:M.transitional(M.boolean),clarifyTimeoutError:M.transitional(M.boolean)},!1),s!=null&&(l.isFunction(s)?t.paramsSerializer={serialize:s}:ye.assertOptions(s,{encode:M.function,serialize:M.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),ye.assertOptions(t,{baseUrl:M.spelling("baseURL"),withXsrfToken:M.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=o&&l.merge(o.common,o[t.method]);o&&l.forEach(["delete","get","head","post","put","patch","common"],h=>{delete o[h]}),t.headers=P.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(t)===!1||(d=d&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const u=[];this.interceptors.response.forEach(function(m){u.push(m.fulfilled,m.rejected)});let a,f=0,_;if(!d){const h=[ut.bind(this),void 0];for(h.unshift(...c),h.push(...u),_=h.length,a=Promise.resolve(t);f<_;)a=a.then(h[f++],h[f++]);return a}_=c.length;let g=t;for(;f<_;){const h=c[f++],m=c[f++];try{g=h(g)}catch(p){m.call(this,p);break}}try{a=ut.call(this,g)}catch(h){return Promise.reject(h)}for(f=0,_=u.length;f<_;)a=a.then(u[f++],u[f++]);return a}getUri(e){e=G(this.defaults,e);const t=Ut(e.baseURL,e.url,e.allowAbsoluteUrls);return vt(t,e.params,e.paramsSerializer)}};l.forEach(["delete","get","head","options"],function(e){X.prototype[e]=function(t,r){return this.request(G(r||{},{method:e,url:t,data:(r||{}).data}))}});l.forEach(["post","put","patch"],function(e){function t(r){return function(o,i,c){return this.request(G(c||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}X.prototype[e]=t(),X.prototype[e+"Form"]=t(!0)});let Nr=class Ht{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(o){t=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},e(function(o,i,c){r.reason||(r.reason=new ae(o,i,c),t(r.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=r=>{e.abort(r)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new Ht(function(s){e=s}),cancel:e}}};function kr(n){return function(t){return n.apply(null,t)}}function Pr(n){return l.isObject(n)&&n.isAxiosError===!0}const je={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(je).forEach(([n,e])=>{je[e]=n});function zt(n){const e=new X(n),t=St(X.prototype.request,e);return l.extend(t,X.prototype,e,{allOwnKeys:!0}),l.extend(t,e,null,{allOwnKeys:!0}),t.create=function(s){return zt(G(n,s))},t}const A=zt(ce);A.Axios=X;A.CanceledError=ae;A.CancelToken=Nr;A.isCancel=Ft;A.VERSION=Mt;A.toFormData=Re;A.AxiosError=b;A.Cancel=A.CanceledError;A.all=function(e){return Promise.all(e)};A.spread=kr;A.isAxiosError=Pr;A.mergeConfig=G;A.AxiosHeaders=P;A.formToJSON=n=>$t(l.isHTMLForm(n)?new FormData(n):n);A.getAdapter=Bt.getAdapter;A.HttpStatusCode=je;A.default=A;const{Axios:Qs,AxiosError:Zs,CanceledError:Ys,isCancel:ei,CancelToken:ti,VERSION:ni,all:ri,Cancel:si,isAxiosError:ii,spread:oi,toFormData:ci,AxiosHeaders:ai,HttpStatusCode:li,formToJSON:ui,getAdapter:hi,mergeConfig:di}=A,Oe=A.create({baseURL:location.origin,timeout:6e4,params:{}});Oe.interceptors.response.use(n=>n,n=>{if(n.response){if(n.response.status===401&&OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity,!0).then(function(r){r&&OpenC3Auth.setTokens()}),n.response.config.headers["Ignore-Errors"]&&n.response.config.headers["Ignore-Errors"].includes(n.response.status.toString()))return Promise.reject(n);let e=`HTTP ${n.response.status} - `;n.response?.statusText&&(e+=`${n.response.statusText} `),n.response?.config?.data&&(e+=`${n.response.config.data} `),n.response?.data?.message?e+=`${n.response.data.message}`:n.response?.data?.exception?e+=`${n.response.data.exception}`:n.response?.data?.error?.message?(n.response.data.error.class&&(e+=`${n.response.data.error.class} `),e+=`${n.response.data.error.message}`):e+=`${n.response?.data}`;const{$cosmosNotify:t}=window;throw t&&t.serious({title:"Network error",body:e}),n}else throw n});const pe=async function(n,e,{data:t,params:r={},headers:s,noAuth:o=!1,noScope:i=!1,onUploadProgress:c=!1}={}){if(!o){try{await OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity)&&OpenC3Auth.setTokens()}catch{OpenC3Auth.login()}s.Authorization=localStorage.openc3Token}return s.manual=!0,!i&&!r.scope&&(r.scope=window.openc3Scope),Oe({method:n,url:e,data:t,params:r,headers:s,onUploadProgress:c})},Ue={Accept:"application/json"},dt={...Ue,"Content-Type":"application/json"},Ir={get:function(n,{params:e,headers:t=Ue,noScope:r,noAuth:s,onUploadProgress:o}={}){return pe("get",n,{params:e,headers:t,noScope:r,noAuth:s,onUploadProgress:o})},put:function(n,{data:e,params:t,headers:r=dt,noScope:s,noAuth:o,onUploadProgress:i}={}){return pe("put",n,{data:e,params:t,headers:r,noScope:s,noAuth:o,onUploadProgress:i})},post:function(n,{data:e,params:t,headers:r=dt,noScope:s,noAuth:o,onUploadProgress:i}={}){return pe("post",n,{data:e,params:t,headers:r,noScope:s,noAuth:o,onUploadProgress:i})},delete:function(n,{params:e,headers:t=Ue,noScope:r,noAuth:s,onUploadProgress:o}={}){return pe("delete",n,{params:e,headers:t,noScope:r,noAuth:s,onUploadProgress:o})}};let Ce=()=>({emit(n,...e){for(let t=this.events[n]||[],r=0,s=t.length;r<s;r++)t[r](...e)},events:{},on(n,e){return(this.events[n]||=[]).push(e),()=>{this.events[n]=this.events[n]?.filter(t=>e!==t)}}});class le extends Error{constructor(e,t){e instanceof Error?(super(e.message),this.cause=e):super(e),this.reason=t,this.name="ReasonError"}}class Ve extends le{constructor(e){super("Rejected",e),this.name="SubscriptionRejectedError"}}class vr extends le{constructor(e){super(e||"Timed out to receive subscription ack"),this.name="SubscriptionTimeoutError"}}class D extends le{constructor(e,t){t?super(e,t):super("Disconnected",e),this.name="DisconnectedError"}}class Lr extends D{constructor(e){super(e,"stale_connection"),this.name="StaleConnectionError"}}function Vt(n){return n?`{${Object.keys(n).sort().filter(t=>n[t]!==void 0).map(t=>{let r=JSON.stringify(n[t]);return`${JSON.stringify(t)}:${r}`}).join(",")}}`:""}class $r{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:String(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:r,info:s})=>(t[r]=s,t),{})}}const J=Symbol("state");class Jt{constructor(e={}){this.emitter=Ce(),this.params=Object.freeze(e),this.presence=new $r(this),this.initialConnect=!0,this[J]="idle"}get identifier(){return this._identifier?this._identifier:(this._identifier=Vt({channel:this.channelId,...this.params}),this._identifier)}get channelId(){return this.constructor.identifier}get state(){return this[J]}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[J]="connecting"}connected(){if(this.state==="connected"||this.state==="closed")return;this[J]="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[J]="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[J]="disconnected",this.presence.reset(),this.emit("disconnect",e))}closed(e){this.state!=="closed"&&(this[J]="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 r=this.receiver?this.receiver.logger:null;r&&r.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 r=this.emitter.on(e,(...s)=>{r(),t(...s)});return r}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 r=[()=>delete this._pendingSubscribe];r.push(this.on("connect",()=>{r.forEach(s=>s()),e()})),r.push(this.on("close",s=>{r.forEach(o=>o()),t(s||new le("Channel was disconnected before subscribing","canceled"))}))}),this._pendingSubscribe)}}class Fr{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(r=>r[e](t[0])):this.channels.forEach(r=>r[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,s={promise:new Promise(i=>{t=i}),intent:e,release:()=>{this._pendings.splice(this._pendings.indexOf(s),1),t(s)},canceled:!1,acquired:!1},o=this._pendingTop;return this._pendings.push(s),o&&await o.promise,this.gvl&&await this.gvl.acquire(s,e),s.acquired=!0,s}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 jr{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 Ur{constructor(e){e.concurrentSubscribes===!1&&(this.glv=new jr),this._subscriptions={},this._localToRemote={}}all(){return Object.values(this._subscriptions)}get(e){return this._subscriptions[e]}create(e,{subscribe:t,unsubscribe:r}){let s=this._subscriptions[e]=new Fr(e);return s.remoteId=this._localToRemote[e],s.subscriber=t,s.unsubscriber=r,s.gvl=this.glv,s}remove(e){delete this._subscriptions[e],delete this._localToRemote[e]}storeRemoteId(e,t){this._localToRemote[e]=t;let r=this.get(e);r&&(r.remoteId=t)}}class Dr{constructor(e={}){this.subscriptions=new Ur(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 r=t.remoteId;r&&delete this._remoteToLocal[r],this.subscriptions.remove(e)}transmit(e,t,r){let s=this._remoteToLocal[e];if(!s){this._pendingMessages.push([e,t,r]);return}let o=this.subscriptions.get(s);o&&o.channels.forEach(i=>{i.receive(t,r)})}notify(e,t,r){let s=this._remoteToLocal[e];if(!s)return;let o=this.subscriptions.get(s);o&&o.channels.forEach(i=>i.emit(t,r))}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 r of this._pendingMessages)r[0]===e?this.transmit(r[0],r[1],r[2]):t.push(r);this._pendingMessages=t}}const ft={debug:0,info:1,warn:2,error:3};class Wt{constructor(e){this.level=e||"warn"}log(e,t,r){ft[e]<ft[this.level]||this.writeLogEntry(e,t,r)}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 ue extends Wt{writeLogEntry(){}}class qr{encode(e){return JSON.stringify(e)}decode(e){try{return JSON.parse(e)}catch{}}}let Br=0;class Kt{constructor(e={}){let{logger:t}=e;this.logger=t||new ue,this.pendingSubscriptions={},this.pendingUnsubscriptions={},this.subscribeCooldownInterval=e.subscribeCooldownInterval||250,this.subscribeRetryInterval=e.subscribeRetryInterval||5e3}attached(e){this.cable=e}subscribe(e,t){let r={channel:e};t&&Object.assign(r,t);let s=Vt(r);if(this.pendingUnsubscriptions[s]){let i=this.subscribeCooldownInterval*1.5;return this.logger.debug(`unsubscribed recently, cooldown for ${i}`,s),new Promise(c=>{setTimeout(()=>{c(this.subscribe(e,t))},i)})}if(this.pendingSubscriptions[s])return this.logger.warn("subscription is already pending, skipping",s),Promise.reject(Error("Already subscribing"));let o=this.subscribeRetryInterval;return new Promise((i,c)=>{let d=++Br;this.pendingSubscriptions[s]={resolve:i,reject:c,id:d},this.cable.send(this.buildSubscribeRequest(s)),this.maybeRetrySubscribe(d,s,o)})}buildSubscribeRequest(e){return{command:"subscribe",identifier:e}}maybeRetrySubscribe(e,t,r){setTimeout(()=>{let s=this.pendingSubscriptions[t];s&&s.id===e&&(this.logger.warn(`no subscription ack received in ${r}ms, retrying subscribe`,t),this.cable.send(this.buildSubscribeRequest(t)),this.maybeExpireSubscribe(e,t,r))},r)}maybeExpireSubscribe(e,t,r){setTimeout(()=>{let s=this.pendingSubscriptions[t];s&&s.id===e&&(delete this.pendingSubscriptions[t],s.reject(new vr(`Haven't received subscription ack in ${r*2}ms for ${t}`)))},r)}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,r){return t==="$whisper"?this.whisper(e,r):(r||(r={}),r.action||=t,this.cable.send({command:"message",identifier:e,data:JSON.stringify(r)}),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:r,message:s,reason:o,reconnect:i}=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 D(o);this.reset(c),i===!1?this.cable.closed(c):this.cable.disconnected(c);return}if(t==="confirm_subscription"){let c=this.pendingSubscriptions[r];if(!c){this.logger.error("subscription not found, unsubscribing",{type:t,identifier:r}),this.unsubscribe(r);return}return delete this.pendingSubscriptions[r],c.resolve(r)}if(t==="reject_subscription"){let c=this.pendingSubscriptions[r];return c?(delete this.pendingSubscriptions[r],c.reject(new Ve)):this.logger.error("subscription not found",{type:t,identifier:r})}if(s)return{identifier:r,message:s};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 pt=()=>Date.now()/1e3|0;class Mr extends Kt{constructor(e={}){super(e),this.streamsPositions={},this.subscriptionStreams={},this.pendingHistory={},this.pendingPresence={},this.presenceInfo={},this.restoreSince=e.historyTimestamp,this.disableSessionRecovery=e.disableSessionRecovery,this.restoreSince===void 0&&(this.restoreSince=pt()),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:r,message:s}=e;if(t==="disconnect")return delete this.sessionId,this.cable.setSessionId(""),super.receive(e);if(t==="reject_subscription")return super.receive(e);if(t==="confirm_subscription")return this.subscriptionStreams[r]||(this.subscriptionStreams[r]=new Set),super.receive(e);if(t==="ping")return this.restoreSince&&(this.restoreSince=pt()),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",r);return}if(t==="reject_history"){this.logger.warn("failed to retrieve history",e),this.cable.notify("history_not_found",r);return}if(t==="welcome"){if(this.disableSessionRecovery||(this.sessionId=e.sid,this.sessionId&&this.cable.setSessionId(this.sessionId)),e.restored){let o=e.restored_ids||Object.keys(this.subscriptionStreams);for(let i of o)this.cable.send({identifier:i,command:"history",history:this.historyRequestFor(i)}),this.presenceInfo[i]&&this.cable.send({identifier:i,command:"join",presence:this.presenceInfo[i]});return this.cable.restored(o)}return this.cable.connected(this.sessionId)}if(t==="presence"){let o=s.type;if(o==="info"){let i=this.pendingPresence[r];i&&(delete this.pendingPresence[r],i.resolve(s))}else if(o==="error"){let i=this.pendingPresence[r];i&&(delete this.pendingPresence[r],i.reject(new Error("failed to retrieve presence")))}return{type:t,identifier:r,message:s}}if(s){let o=this.trackStreamPosition(r,e.stream_id,e.epoch,e.offset);return{identifier:r,message:s,meta:o}}this.logger.warn(`unknown message type: ${t}`,{message:e})}perform(e,t,r){switch(t){case"$presence:join":return this.join(e,r);case"$presence:leave":return this.leave(e,r);case"$presence:info":return this.presence(e,r)}return super.perform(e,t,r)}unsubscribe(e){return delete this.presenceInfo[e],super.unsubscribe(e)}buildSubscribeRequest(e){let t=super.buildSubscribeRequest(e),r=this.historyRequestFor(e);r&&(t.history=r,this.pendingHistory[e]=!0);let s=this.presenceInfo[e];return s&&(t.presence=s),t}recoverableClosure(){return!!this.sessionId}historyRequestFor(e){let t={},r=!1;if(this.subscriptionStreams[e])for(let s of this.subscriptionStreams[e]){let o=this.streamsPositions[s];o&&(r=!0,t[s]=o)}if(!(!r&&!this.restoreSince))return{since:this.restoreSince,streams:t}}trackStreamPosition(e,t,r,s){if(!(!t||!r))return this.subscriptionStreams[e]||(this.subscriptionStreams[e]=new Set),this.subscriptionStreams[e].add(t),this.streamsPositions[t]={epoch:r,offset:s},{stream:t,epoch:r,offset:s}}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((r,s)=>{this.pendingPresence[e]={resolve:r,reject:s},this.cable.send({command:"presence",identifier:e,data:t})})}}class Hr extends le{constructor(){super("No connection","closed"),this.name="NoConnectionError"}}class Xt extends Jt{static identifier="__ghost__";constructor(e,t){super(t),this.channelId=e}set channelId(e){this._channelId=e}get channelId(){return this._channelId}}const zr="$pubsub";class mt extends Jt{static identifier=zr;async perform(e,t){if(e.startsWith("$"))return super.perform(e,t);throw Error("not implemented")}}const W=Symbol("state");let Vr=class{constructor({transport:e,protocol:t,encoder:r,logger:s,lazy:o,hubOptions:i,performFailures:c,transportConfigurator:d}){this.emitter=Ce(),this.transport=e,this.encoder=r,this.logger=s||new ue,this.protocol=t,this.performFailures=c||"throw",this.protocol.attached(this),this.hub=new Dr(i||{}),this[W]="idle",this.handleClose=this.handleClose.bind(this),this.handleIncoming=this.handleIncoming.bind(this),this.transportConfigurator=d,this.transport.on("close",this.handleClose),this.transport.on("data",this.handleIncoming),this.initialConnect=!0,this.recovering=!1,o===!1&&this.connect().catch(()=>{})}get state(){return this[W]}async connect(){if(this.state==="connected")return Promise.resolve();if(this.state==="connecting")return this.pendingConnect();let e=this.state==="idle";this[W]="connecting";let t=this.pendingConnect();this.logger.debug("connecting");try{this.transportConfigurator&&await this.transportConfigurator(this.transport,{initial:e}),await this.transport.open()}catch(r){this.handleClose(r)}return t}setSessionId(e){this.sessionId=e,this.transport.setParam("sid",e)}connected(){if(this.state==="connected")return;this.logger.info("connected"),this[W]="connected",this.recovering&&this.hub.subscriptions.all().forEach(t=>t.notify("disconnected",new D("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[W]="connected",this.hub.subscriptions.all().forEach(s=>{e&&s.remoteId&&e.includes(s.remoteId)?s.notify("restored"):(s.notify("disconnected",new D("recovery_failed")),this._resubscribe(s))});let t=!this.initialConnect,r=!0;this.recovering=!1,this.initialConnect=!1,this.emit("connect",{reconnect:t,restored:r})}notify(e,t,r){t&&typeof t!="string"&&(r=t,t=void 0),t?this.hub.notify(t,"info",{type:e,data:r}):this.emit("info",{type:e,data:r})}handleClose(e){this.logger.debug("transport closed",{error:e}),this.disconnected(new D(e,"transport_closed"))}disconnected(e){(this.state==="connected"||this.state==="connecting")&&(this.logger.info("disconnected",{reason:e}),this[W]="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 D?e:new D(e,void 0)),this.logger.info("closed",{reason:e||"user"}),this[W]="closed";let r=t||new D("cable_closed");this.hub.subscriptions.all().forEach(s=>s.notify("disconnected",r)),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 r=this.protocol.receive(t);if(r){this.logger.debug("processed incoming message",r);let{type:s,identifier:o,message:i,meta:c}=r;s?this.hub.notify(o,s,i):this.hub.transmit(o,i,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 mt({stream_name:e});return this.subscribe(t)}streamFromSigned(e){let t=new mt({signed_stream_name:e});return this.subscribe(t)}subscribeTo(e,t){let r,s;return typeof e=="string"&&(s=e,e=Xt),r=s?new e(s,t):new e(t),this.subscribe(r)}subscribe(e){if(!e.attached(this))return e;let t=e.identifier;e.connecting();let r=this.hub.subscriptions.get(t)||this.hub.subscriptions.create(t,{subscribe:s=>this._subscribe(s,e.channelId,e.params),unsubscribe:s=>this._unsubscribe(s)});return r.add(e),r.intent==="subscribed"&&r.state==="connected"&&e.connected(),r.ensureSubscribed(),e}async _resubscribe(e){e.intent!=="subscribed"||!e.channels[0]||(e.notify("connecting"),e.ensureResubscribed())}async _subscribe(e,t,r){let s=e.id;if(this.state==="idle"&&this.connect().catch(()=>{}),this.state!=="connected"){this.logger.debug("cancel subscribe, no connection",{identifier:s});return}this.logger.debug("acquiring subscribe lock",{identifier:s});let o=await e.acquire("subscribed");if(o.canceled){this.logger.debug("subscribe lock has been canceled",{identifier:s}),o.release();return}if(this.logger.debug("subscribe lock has been acquired",{identifier:s}),e.intent!=="subscribed"){this.logger.debug("cancel subscribe request, already unsubscribed"),o.release();return}if(this.state!=="connected"){this.logger.debug("cancel subscribe, no connection",{identifier:s}),o.release();return}if(e.state==="connected"){this.logger.debug("already connected, skip subscribe command",{identifier:s}),e.notify("connected"),o.release();return}let i={identifier:t,params:r};this.logger.debug("subscribing",i);try{let c=await this.protocol.subscribe(t,r);this.hub.subscribe(s,c),this.logger.debug("subscribed",{...i,remoteId:c}),e.notify("connected")}catch(c){if(c){if(c instanceof Ve&&this.logger.warn("rejected",i),c instanceof D){this.logger.debug("disconnected during subscription; will retry on connect",i),o.release();return}this.logger.error("failed to subscribe",{error:c,...i})}e.close(c),this.hub.unsubscribe(s)}o.release()}unsubscribe(e){let t=e.identifier,r=this.hub.subscriptions.get(t);if(!r)throw Error(`Subscription not found: ${t}`);r.remove(e),e.closed(),r.maybeUnsubscribe()}async _unsubscribe(e){let t=e.id;this.logger.debug("acquiring unsubscribe lock",{identifier:t});let r=await e.acquire("unsubscribed");if(r.canceled){this.logger.debug("unsubscribe lock has been canceled",{identifier:t}),r.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}),r.release();return}if(e.state==="disconnected"||e.state==="closed"){this.logger.debug(`already ${e.state} connected, skip unsubscribe command`,{identifier:t}),r.release();return}let s=e.remoteId;if(this.logger.debug("unsubscribing...",{remoteId:s}),this.state!=="connected"){this.logger.debug("unsubscribe skipped (cable is not connected)",{id:t}),e.close(),this.hub.unsubscribe(t),r.release();return}try{await this.protocol.unsubscribe(s),this.logger.debug("unsubscribed remotely",{id:t})}catch(o){o&&(o instanceof D?this.logger.debug("cable disconnected during the unsubscribe command execution",{id:t,error:o}):this.logger.error("unsubscribe failed",{id:t,error:o}))}e.intent==="unsubscribed"?(e.close(),this.hub.unsubscribe(t)):e.state="closed",r.release()}async perform(e,t,r){if(this.performFailures==="throw")return this._perform(e,t,r);try{return await this._perform(e,t,r)}catch(s){this.performFailures==="warn"&&this.logger.warn("perform failed",{error:s});return}}async _perform(e,t,r){if(this.state==="connecting"&&await this.pendingConnect(),this.state==="closed"||this.state==="disconnected")throw new Hr;let s=this.hub.subscriptions.get(e);if(!s)throw Error(`Subscription not found: ${e}`);if(await s.pending("subscribed"),s.intent!=="subscribed")throw Error(`Subscription is closed: ${e}`);let o=s.remoteId,i={id:o,action:t,payload:r};this.logger.debug("perform",i);try{let c=await this.protocol.perform(o,t,r);return c&&this.logger.debug("perform result",{message:c,request:i}),c}catch(c){throw this.logger.error("perform failed",{error:c,request:i}),c}}on(e,t){return this.emitter.on(e,t)}once(e,t){let r=this.emitter.on(e,(...s)=>{r(),t(...s)});return r}emit(e,...t){return this.emitter.emit(e,...t)}pendingConnect(){return this._pendingConnect?this._pendingConnect:(this._pendingConnect=new Promise((e,t)=>{let r=[()=>delete this._pendingConnect];r.push(this.on("connect",()=>{r.forEach(s=>s()),e()})),r.push(this.on("close",s=>{r.forEach(o=>o()),t(s)})),r.push(this.on("disconnect",s=>{r.forEach(o=>o()),t(s)}))}),this._pendingConnect)}};const Jr={maxMissingPings:2,maxReconnectAttempts:1/0},Z=()=>Date.now(),Gt=(n,e)=>{e=e||{};let{backoffRate:t,jitterRatio:r,maxInterval:s}=e;return t=t||2,r===void 0&&(r=.5),o=>{let i=n*t**o,c=i*t,d=i+(c-i)*Math.random(),u=2*(Math.random()-.5)*r;return d=d*(1+u),s&&s<d&&(d=s),d}};let Qt=class{constructor({pingInterval:e,...t}){if(this.pingInterval=e,!this.pingInterval)throw Error(`Incorrect pingInterval is provided: ${e}`);if(t=Object.assign({},Jr,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 ue,this.state="pending_connect",this.attempts=0,this.disconnectedAt=Z()}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=Z(),this.state="connected",this.cancelReconnect(),this.startPolling()})),this.unbind.push(this.target.on("disconnect",()=>{this.disconnectedAt=Z(),this.state="disconnected",this.stopPolling(),this.scheduleReconnect()})),this.unbind.push(this.target.on("close",()=>{this.disconnectedAt=Z(),this.state="closed",this.cancelReconnect(),this.stopPolling()})),this.unbind.push(this.target.on("keepalive",()=>{this.pingedAt=Z()})),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=Z()-this.pingedAt;e>this.maxMissingPings*this.pingInterval&&(this.logger.warn(`Stale connection: ${e}ms without pings`),this.state="pending_disconnect",this.target.disconnected(new Lr))}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 Wr{constructor(e,t={}){this.transports=e,this.transport=null,this.emitter=Ce(),this.unbind=[],this.logger=t.logger||new ue}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(r){this.logger.debug(`Failed to connect via ${t.displayName()}: ${r.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(r=>{r.setParam(e,t)})}setToken(e,t){this.transports.forEach(r=>{r.setToken(e,t)})}on(e,t){return this.emitter.on(e,t)}once(e,t){let r=this.emitter.on(e,(...s)=>{r(),t(...s)});return r}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 Kr{constructor(e,t={}){this.url=e;let r=t.websocketImplementation;if(r)this.Impl=r;else if(typeof WebSocket<"u")this.Impl=WebSocket;else throw new Error("No WebSocket support");this.connected=!1,this.emitter=Ce();let{format:s,subprotocol:o,authStrategy:i}=t;this.format=s||"text",this.connectionOptions=t.websocketOptions,this.authStrategy=i||"param",this.authProtocol="",this.subprotocol=o}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,r)=>{let s=[];s.push(this.once("open",()=>{s.forEach(o=>o()),t()})),s.push(this.once("close",()=>{s.forEach(o=>o()),r(Error("WS connection closed"))}))})}setURL(e){this.url=e}setParam(e,t){let r=new URL(this.url);r.searchParams.set(e,t);let s=`${r.protocol}//${r.host}${r.pathname}?${r.searchParams}`;this.setURL(s)}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 r=`x-${t}`.toLowerCase();r=Object.keys(this.connectionOptions.headers).find(o=>o.toLowerCase()===r)||r,this.connectionOptions.headers[r]=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 r=this.emitter.on(e,(...s)=>{r(),t(...s)});return r}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")}}class Xr{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)}whisper(e){return this.channel.whisper(e)}get identifier(){return this.channel.identifier}unsubscribe(){return this.channel.disconnect()}}class Gr extends Xt{constructor(e,t,r){super(e,t),this.subscription=new Xr(this),Object.assign(this.subscription,r),this.on("connect",({reconnect:s})=>this.subscription.notify("connected",{reconnected:s})),this.on("disconnect",()=>this.subscription.notify("disconnected",{allowReconnect:!0})),this.on("message",s=>this.subscription.notify("received",s)),this.on("close",s=>{s&&s instanceof Ve?this.subscription.notify("rejected"):this.subscription.notify("disconnected",{allowReconnect:!1})})}}class Qr{constructor(e){this.cable=e}create(e,t){let r,s;typeof e=="object"?(r=e.channel,delete e.channel,s=e):(r=e,s={});let o=new Gr(r,s,t);return o.subscription.notify("initialized"),this.cable.subscribe(o),o.subscription}findAll(e){return this.cable.hub.channels.filter(t=>t.identifier===e).map(t=>t.subscription)}}class Zr{constructor(e){this.cable=e,this.subscriptions=new Qr(e)}send(e){return this.cable.send(e)}connect(){return this.cable.connect()}disconnect(){return this.cable.disconnect()}ensureActiveConnection(){return this.cable.connect()}}const Zt={protocol:"actioncable-v1-json",pingInterval:3e3,maxReconnectAttempts:1/0,maxMissingPings:2,logLevel:"warn",lazy:!0};function Yr(n,e){if(typeof n=="object"&&typeof e>"u"&&(e=n,n=void 0),e=e||{},!n&&!e.transport)throw Error("URL or transport must be specified");e=Object.assign({},Zt,e);let{protocol:t,websocketImplementation:r,websocketFormat:s,websocketOptions:o,websocketAuthStrategy:i,fallbacks:c,logLevel:d,logger:u,transport:a,encoder:f,lazy:_,monitor:g,pingInterval:h,reconnectStrategy:m,maxMissingPings:p,maxReconnectAttempts:w,subprotocol:E,tokenRefresher:S,historyTimestamp:O,protocolOptions:C,concurrentSubscribes:$,performFailures:T,transportConfigurator:V,auth:F}=e;if(u=u||new ue(d),typeof t=="string"){E=E||t;let j=t.substring(0,t.lastIndexOf("-")),U=t.substring(t.lastIndexOf("-")+1);if(C=C||{},j==="actioncable-v1")t=new Kt({logger:u,...C});else if(j==="actioncable-v1-ext")t=new Mr({logger:u,historyTimestamp:O,...C});else throw Error(`Protocol is not supported yet: ${t}`);if(U==="json")f=f||new qr,s=s||"text";else if(U==="msgpack"){if(s="binary",!f)throw Error("Msgpack encoder must be specified explicitly. Use `@anycable/msgpack-encoder` package or build your own")}else if(U==="protobuf"){if(s=s||"binary",!f)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 Kr(n,{websocketImplementation:r,websocketOptions:o,subprotocol:E,authStrategy:i,format:s}),c&&(a=new Wr([a,...c],{logger:u})),F&&F.token&&a.setToken(F.token,F.param||"jid"),m=m||Gt(h),g!==!1&&(g=g||new Qt({pingInterval:h,reconnectStrategy:m,maxMissingPings:p,maxReconnectAttempts:w,logger:u}));let Q={concurrentSubscribes:$},B=new Vr({protocol:t,transport:a,encoder:f,logger:u,lazy:_,hubOptions:Q,performFailures:T,transportConfigurator:V});return g&&(g.watch(B),B.monitor=g),S&&es(B,async()=>{try{await S(a)}catch(j){return u.error("Failed to refresh authentication token: "+j),!1}return B.connect().catch(()=>{}),!0}),B}function es(n,e){let t=!1;n.on("connect",()=>t=!1),n.on("close",async r=>{if(r){if(t){n.logger.warn("Token auto-refresh is disabled",r);return}r.reason==="token_expired"&&(t=!0,await e())}})}class ts extends Wt{writeLogEntry(e,t,r){r?console[e](t,r):console[e](t)}}class ns extends Qt{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=s=>{this.reconnectNow()&&this.logger.debug("Trigger reconnect",{event:s})},r=()=>this.disconnect(new D("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",r,!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",r,!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 rs=["cable","action-cable"],ss="/cable",Te=(n,e)=>{for(let t of rs){let r=n.head.querySelector(`meta[name='${t}-${e}']`);if(r)return r.getAttribute("content")}},gt=n=>n.match(/wss?:\/\//)?n:typeof window<"u"?`${window.location.protocol.replace("http","ws")}//${window.location.host}${n}`:n,is=()=>{if(typeof document<"u"&&document.head){let n=Te(document,"url");if(n)return gt(n)}return gt(ss)},os=()=>{if(typeof document<"u"&&document.head){let n=Te(document,"history-timestamp");if(n)return n|0}},cs=()=>{if(typeof document<"u"&&document.head)return Te(document,"token")},as=()=>{if(typeof document<"u"&&document.head)return Te(document,"token-param")};function ls(n,e){typeof n=="object"&&typeof e>"u"&&(e=n,n=void 0),n=n||is(),e=e||{},e.historyTimestamp||=os();let t=cs();if(t){let u=as();e.auth=Object.assign({token:t,param:u},e.auth||{})}e=Object.assign({},Zt,e);let{logLevel:r,logger:s,pingInterval:o,reconnectStrategy:i,maxMissingPings:c,maxReconnectAttempts:d}=e;return s=e.logger=e.logger||new ts(r),i=e.reconnectStrategy=e.reconnectStrategy||Gt(o),e.monitor!==!1&&(e.monitor=e.monitor||new ns({pingInterval:o,reconnectStrategy:i,maxMissingPings:c,maxReconnectAttempts:d,logger:s})),Yr(n,e)}function us(n,e){let t=ls(n,e);return new Zr(t)}class hs{constructor(e="/openc3-api/cable"){this._cable=null,this._url=e}disconnect(){this._cable&&(this._cable.cable.disconnect(),this._cable=null)}createSubscription(e,t,r={},s={}){return OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity).then(o=>{if(o&&OpenC3Auth.setTokens(),this._cable==null){let i=this._url+"?scope="+encodeURIComponent(t)+"&authorization="+encodeURIComponent(localStorage.openc3Token);i=new URL(i,document.baseURI).href,this._cable=us(i)}return this._cable.subscriptions.create({channel:e,...s},r)})}recordPing(){}}class De{constructor(e,t,r="",s=""){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=r,this.url=s}}class ds{keyword=null;parameters=[];filename="";line="";lineNumber=0;url="https://docs.openc3.com/docs/configuration";constructor(){}verify_num_parameters(e,t,r=""){for(let s=1;s<=e;s++)if(this.parameters[s-1]===void 0)throw new De(this,`Not enough parameters for ${this.keyword}.`,r,this.url);if(t&&this.parameters[t]!==void 0)throw new De(this,`Too many parameters for ${this.keyword}.`,r,this.url)}remove_quotes(e){if(e.length<2)return e;let t=e.charAt(0);if(t!=='"'&&t!=="'")return e;let r=e.charAt(e.length-1);return t!==r?e:e.substring(1,e.length-1)}scan_string(e,t){if(!t.global)throw"rx must have 'global' flag set";let r=[];return e.replace(t,function(s){return r.push(s),s}),r}parse_string(e,t,r,s,o){let i=!1,c=!1;this.line="",this.keyword=null,this.parameters=[],this.filename=t;let d=e.split(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function At(n,e){return function(){return n.apply(e,arguments)}}const{toString:on}=Object.prototype,{getPrototypeOf:Me}=Object,{iterator:Ee,toStringTag:Ot}=Symbol,Se=(n=>e=>{const t=on.call(e);return n[t]||(n[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),B=n=>(n=n.toLowerCase(),e=>Se(e)===n),Re=n=>e=>typeof e===n,{isArray:ee}=Array,Y=Re("undefined");function se(n){return n!==null&&!Y(n)&&n.constructor!==null&&!Y(n.constructor)&&P(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const Ct=B("ArrayBuffer");function cn(n){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(n):e=n&&n.buffer&&Ct(n.buffer),e}const an=Re("string"),P=Re("function"),Tt=Re("number"),ie=n=>n!==null&&typeof n=="object",ln=n=>n===!0||n===!1,be=n=>{if(Se(n)!=="object")return!1;const e=Me(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Ot in n)&&!(Ee in n)},un=n=>{if(!ie(n)||se(n))return!1;try{return Object.keys(n).length===0&&Object.getPrototypeOf(n)===Object.prototype}catch{return!1}},hn=B("Date"),dn=B("File"),fn=n=>!!(n&&typeof n.uri<"u"),pn=n=>n&&typeof n.getParts<"u",gn=B("Blob"),mn=B("FileList"),bn=n=>ie(n)&&P(n.pipe);function _n(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Ze=_n(),Ye=typeof Ze.FormData<"u"?Ze.FormData:void 0,yn=n=>{let e;return n&&(Ye&&n instanceof Ye||P(n.append)&&((e=Se(n))==="formdata"||e==="object"&&P(n.toString)&&n.toString()==="[object FormData]"))},wn=B("URLSearchParams"),[En,Sn,Rn,xn]=["ReadableStream","Request","Response","Headers"].map(B),An=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function oe(n,e,{allOwnKeys:t=!1}={}){if(n===null||typeof n>"u")return;let r,s;if(typeof n!="object"&&(n=[n]),ee(n))for(r=0,s=n.length;r<s;r++)e.call(null,n[r],r,n);else{if(se(n))return;const o=t?Object.getOwnPropertyNames(n):Object.keys(n),i=o.length;let c;for(r=0;r<i;r++)c=o[r],e.call(null,n[c],c,n)}}function Nt(n,e){if(se(n))return null;e=e.toLowerCase();const t=Object.keys(n);let r=t.length,s;for(;r-- >0;)if(s=t[r],e===s.toLowerCase())return s;return null}const K=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Pt=n=>!Y(n)&&n!==K;function $e(){const{caseless:n,skipUndefined:e}=Pt(this)&&this||{},t={},r=(s,o)=>{if(o==="__proto__"||o==="constructor"||o==="prototype")return;const i=n&&Nt(t,o)||o;be(t[i])&&be(s)?t[i]=$e(t[i],s):be(s)?t[i]=$e({},s):ee(s)?t[i]=s.slice():(!e||!Y(s))&&(t[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&oe(arguments[s],r);return t}const On=(n,e,t,{allOwnKeys:r}={})=>(oe(e,(s,o)=>{t&&P(s)?Object.defineProperty(n,o,{value:At(s,t),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(n,o,{value:s,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),n),Cn=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),Tn=(n,e,t,r)=>{n.prototype=Object.create(e.prototype,r),Object.defineProperty(n.prototype,"constructor",{value:n,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(n,"super",{value:e.prototype}),t&&Object.assign(n.prototype,t)},Nn=(n,e,t,r)=>{let s,o,i;const c={};if(e=e||{},n==null)return e;do{for(s=Object.getOwnPropertyNames(n),o=s.length;o-- >0;)i=s[o],(!r||r(i,n,e))&&!c[i]&&(e[i]=n[i],c[i]=!0);n=t!==!1&&Me(n)}while(n&&(!t||t(n,e))&&n!==Object.prototype);return e},Pn=(n,e,t)=>{n=String(n),(t===void 0||t>n.length)&&(t=n.length),t-=e.length;const r=n.indexOf(e,t);return r!==-1&&r===t},kn=n=>{if(!n)return null;if(ee(n))return n;let e=n.length;if(!Tt(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=n[e];return t},In=(n=>e=>n&&e instanceof n)(typeof Uint8Array<"u"&&Me(Uint8Array)),vn=(n,e)=>{const r=(n&&n[Ee]).call(n);let s;for(;(s=r.next())&&!s.done;){const o=s.value;e.call(n,o[0],o[1])}},Ln=(n,e)=>{let t;const r=[];for(;(t=n.exec(e))!==null;)r.push(t);return r},$n=B("HTMLFormElement"),jn=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,r,s){return r.toUpperCase()+s}),et=(({hasOwnProperty:n})=>(e,t)=>n.call(e,t))(Object.prototype),Fn=B("RegExp"),kt=(n,e)=>{const t=Object.getOwnPropertyDescriptors(n),r={};oe(t,(s,o)=>{let i;(i=e(s,o,n))!==!1&&(r[o]=i||s)}),Object.defineProperties(n,r)},Un=n=>{kt(n,(e,t)=>{if(P(n)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const r=n[t];if(P(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},Dn=(n,e)=>{const t={},r=s=>{s.forEach(o=>{t[o]=!0})};return ee(n)?r(n):r(String(n).split(e)),t},qn=()=>{},Bn=(n,e)=>n!=null&&Number.isFinite(n=+n)?n:e;function Mn(n){return!!(n&&P(n.append)&&n[Ot]==="FormData"&&n[Ee])}const Hn=n=>{const e=new Array(10),t=(r,s)=>{if(ie(r)){if(e.indexOf(r)>=0)return;if(se(r))return r;if(!("toJSON"in r)){e[s]=r;const o=ee(r)?[]:{};return oe(r,(i,c)=>{const d=t(i,s+1);!Y(d)&&(o[c]=d)}),e[s]=void 0,o}}return r};return t(n,0)},zn=B("AsyncFunction"),Vn=n=>n&&(ie(n)||P(n))&&P(n.then)&&P(n.catch),It=((n,e)=>n?setImmediate:e?((t,r)=>(K.addEventListener("message",({source:s,data:o})=>{s===K&&o===t&&r.length&&r.shift()()},!1),s=>{r.push(s),K.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",P(K.postMessage)),Jn=typeof queueMicrotask<"u"?queueMicrotask.bind(K):typeof process<"u"&&process.nextTick||It,Wn=n=>n!=null&&P(n[Ee]),l={isArray:ee,isArrayBuffer:Ct,isBuffer:se,isFormData:yn,isArrayBufferView:cn,isString:an,isNumber:Tt,isBoolean:ln,isObject:ie,isPlainObject:be,isEmptyObject:un,isReadableStream:En,isRequest:Sn,isResponse:Rn,isHeaders:xn,isUndefined:Y,isDate:hn,isFile:dn,isReactNativeBlob:fn,isReactNative:pn,isBlob:gn,isRegExp:Fn,isFunction:P,isStream:bn,isURLSearchParams:wn,isTypedArray:In,isFileList:mn,forEach:oe,merge:$e,extend:On,trim:An,stripBOM:Cn,inherits:Tn,toFlatObject:Nn,kindOf:Se,kindOfTest:B,endsWith:Pn,toArray:kn,forEachEntry:vn,matchAll:Ln,isHTMLForm:$n,hasOwnProperty:et,hasOwnProp:et,reduceDescriptors:kt,freezeMethods:Un,toObjectSet:Dn,toCamelCase:jn,noop:qn,toFiniteNumber:Bn,findKey:Nt,global:K,isContextDefined:Pt,isSpecCompliantForm:Mn,toJSONObject:Hn,isAsyncFn:zn,isThenable:Vn,setImmediate:It,asap:Jn,isIterable:Wn};let b=class vt extends Error{static from(e,t,r,s,o,i){const c=new vt(e.message,t||e.code,r,s,o);return c.cause=e,c.name=e.name,e.status!=null&&c.status==null&&(c.status=e.status),i&&Object.assign(c,i),c}constructor(e,t,r,s,o){super(e),Object.defineProperty(this,"message",{value:e,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,t&&(this.code=t),r&&(this.config=r),s&&(this.request=s),o&&(this.response=o,this.status=o.status)}toJSON(){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}}};b.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";b.ERR_BAD_OPTION="ERR_BAD_OPTION";b.ECONNABORTED="ECONNABORTED";b.ETIMEDOUT="ETIMEDOUT";b.ERR_NETWORK="ERR_NETWORK";b.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";b.ERR_DEPRECATED="ERR_DEPRECATED";b.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";b.ERR_BAD_REQUEST="ERR_BAD_REQUEST";b.ERR_CANCELED="ERR_CANCELED";b.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";b.ERR_INVALID_URL="ERR_INVALID_URL";const Kn=null;function je(n){return l.isPlainObject(n)||l.isArray(n)}function Lt(n){return l.endsWith(n,"[]")?n.slice(0,-2):n}function Pe(n,e,t){return n?n.concat(e).map(function(s,o){return s=Lt(s),!t&&o?"["+s+"]":s}).join(t?".":""):e}function Gn(n){return l.isArray(n)&&!n.some(je)}const Xn=l.toFlatObject(l,{},null,function(e){return/^is[A-Z]/.test(e)});function xe(n,e,t){if(!l.isObject(n))throw new TypeError("target must be an object");e=e||new FormData,t=l.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,p){return!l.isUndefined(p[g])});const r=t.metaTokens,s=t.visitor||a,o=t.dots,i=t.indexes,d=(t.Blob||typeof Blob<"u"&&Blob)&&l.isSpecCompliantForm(e);if(!l.isFunction(s))throw new TypeError("visitor must be a function");function u(h){if(h===null)return"";if(l.isDate(h))return h.toISOString();if(l.isBoolean(h))return h.toString();if(!d&&l.isBlob(h))throw new b("Blob is not supported. Use a Buffer instead.");return l.isArrayBuffer(h)||l.isTypedArray(h)?d&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function a(h,g,p){let w=h;if(l.isReactNative(e)&&l.isReactNativeBlob(h))return e.append(Pe(p,g,o),u(h)),!1;if(h&&!p&&typeof h=="object"){if(l.endsWith(g,"{}"))g=r?g:g.slice(0,-2),h=JSON.stringify(h);else if(l.isArray(h)&&Gn(h)||(l.isFileList(h)||l.endsWith(g,"[]"))&&(w=l.toArray(h)))return g=Lt(g),w.forEach(function(S,O){!(l.isUndefined(S)||S===null)&&e.append(i===!0?Pe([g],O,o):i===null?g:g+"[]",u(S))}),!1}return je(h)?!0:(e.append(Pe(p,g,o),u(h)),!1)}const f=[],_=Object.assign(Xn,{defaultVisitor:a,convertValue:u,isVisitable:je});function m(h,g){if(!l.isUndefined(h)){if(f.indexOf(h)!==-1)throw Error("Circular reference detected in "+g.join("."));f.push(h),l.forEach(h,function(w,E){(!(l.isUndefined(w)||w===null)&&s.call(e,w,l.isString(E)?E.trim():E,g,_))===!0&&m(w,g?g.concat(E):[E])}),f.pop()}}if(!l.isObject(n))throw new TypeError("data must be an object");return m(n),e}function tt(n){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function He(n,e){this._pairs=[],n&&xe(n,this,e)}const $t=He.prototype;$t.append=function(e,t){this._pairs.push([e,t])};$t.toString=function(e){const t=e?function(r){return e.call(this,r,tt)}:tt;return this._pairs.map(function(s){return t(s[0])+"="+t(s[1])},"").join("&")};function Qn(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function jt(n,e,t){if(!e)return n;const r=t&&t.encode||Qn,s=l.isFunction(t)?{serialize:t}:t,o=s&&s.serialize;let i;if(o?i=o(e,s):i=l.isURLSearchParams(e)?e.toString():new He(e,s).toString(r),i){const c=n.indexOf("#");c!==-1&&(n=n.slice(0,c)),n+=(n.indexOf("?")===-1?"?":"&")+i}return n}class nt{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:r?r.synchronous:!1,runWhen:r?r.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(r){r!==null&&e(r)})}}const ze={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Zn=typeof URLSearchParams<"u"?URLSearchParams:He,Yn=typeof FormData<"u"?FormData:null,er=typeof Blob<"u"?Blob:null,tr={isBrowser:!0,classes:{URLSearchParams:Zn,FormData:Yn,Blob:er},protocols:["http","https","file","blob","url","data"]},Ve=typeof window<"u"&&typeof document<"u",Fe=typeof navigator=="object"&&navigator||void 0,nr=Ve&&(!Fe||["ReactNative","NativeScript","NS"].indexOf(Fe.product)<0),rr=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",sr=Ve&&window.location.href||"http://localhost",ir=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ve,hasStandardBrowserEnv:nr,hasStandardBrowserWebWorkerEnv:rr,navigator:Fe,origin:sr},Symbol.toStringTag,{value:"Module"})),N={...ir,...tr};function or(n,e){return xe(n,new N.classes.URLSearchParams,{visitor:function(t,r,s,o){return N.isNode&&l.isBuffer(t)?(this.append(r,t.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...e})}function cr(n){return l.matchAll(/\w+|\[(\w*)]/g,n).map(e=>e[0]==="[]"?"":e[1]||e[0])}function ar(n){const e={},t=Object.keys(n);let r;const s=t.length;let o;for(r=0;r<s;r++)o=t[r],e[o]=n[o];return e}function Ft(n){function e(t,r,s,o){let i=t[o++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),d=o>=t.length;return i=!i&&l.isArray(s)?s.length:i,d?(l.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!l.isObject(s[i]))&&(s[i]=[]),e(t,r,s[i],o)&&l.isArray(s[i])&&(s[i]=ar(s[i])),!c)}if(l.isFormData(n)&&l.isFunction(n.entries)){const t={};return l.forEachEntry(n,(r,s)=>{e(cr(r),s,t,0)}),t}return null}function lr(n,e,t){if(l.isString(n))try{return(e||JSON.parse)(n),l.trim(n)}catch(r){if(r.name!=="SyntaxError")throw r}return(t||JSON.stringify)(n)}const ce={transitional:ze,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",s=r.indexOf("application/json")>-1,o=l.isObject(e);if(o&&l.isHTMLForm(e)&&(e=new FormData(e)),l.isFormData(e))return s?JSON.stringify(Ft(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(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return or(e,this.formSerializer).toString();if((c=l.isFileList(e))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return xe(c?{"files[]":e}:e,d&&new d,this.formSerializer)}}return o||s?(t.setContentType("application/json",!1),lr(e)):e}],transformResponse:[function(e){const t=this.transitional||ce.transitional,r=t&&t.forcedJSONParsing,s=this.responseType==="json";if(l.isResponse(e)||l.isReadableStream(e))return e;if(e&&l.isString(e)&&(r&&!this.responseType||s)){const i=!(t&&t.silentJSONParsing)&&s;try{return JSON.parse(e,this.parseReviver)}catch(c){if(i)throw c.name==="SyntaxError"?b.from(c,b.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:N.classes.FormData,Blob:N.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"],n=>{ce.headers[n]={}});const ur=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"]),hr=n=>{const e={};let t,r,s;return n&&n.split(`
2
+ `).forEach(function(i){s=i.indexOf(":"),t=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!t||e[t]&&ur[t])&&(t==="set-cookie"?e[t]?e[t].push(r):e[t]=[r]:e[t]=e[t]?e[t]+", "+r:r)}),e},rt=Symbol("internals");function te(n){return n&&String(n).trim().toLowerCase()}function _e(n){return n===!1||n==null?n:l.isArray(n)?n.map(_e):String(n)}function dr(n){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=t.exec(n);)e[r[1]]=r[2];return e}const fr=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function ke(n,e,t,r,s){if(l.isFunction(r))return r.call(this,e,t);if(s&&(e=t),!!l.isString(e)){if(l.isString(r))return e.indexOf(r)!==-1;if(l.isRegExp(r))return r.test(e)}}function pr(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r)}function gr(n,e){const t=l.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(n,r+t,{value:function(s,o,i){return this[r].call(this,e,s,o,i)},configurable:!0})})}let k=class{constructor(e){e&&this.set(e)}set(e,t,r){const s=this;function o(c,d,u){const a=te(d);if(!a)throw new Error("header name must be a non-empty string");const f=l.findKey(s,a);(!f||s[f]===void 0||u===!0||u===void 0&&s[f]!==!1)&&(s[f||d]=_e(c))}const i=(c,d)=>l.forEach(c,(u,a)=>o(u,a,d));if(l.isPlainObject(e)||e instanceof this.constructor)i(e,t);else if(l.isString(e)&&(e=e.trim())&&!fr(e))i(hr(e),t);else if(l.isObject(e)&&l.isIterable(e)){let c={},d,u;for(const a of e){if(!l.isArray(a))throw TypeError("Object iterator must return a key-value pair");c[u=a[0]]=(d=c[u])?l.isArray(d)?[...d,a[1]]:[d,a[1]]:a[1]}i(c,t)}else e!=null&&o(t,e,r);return this}get(e,t){if(e=te(e),e){const r=l.findKey(this,e);if(r){const s=this[r];if(!t)return s;if(t===!0)return dr(s);if(l.isFunction(t))return t.call(this,s,r);if(l.isRegExp(t))return t.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=te(e),e){const r=l.findKey(this,e);return!!(r&&this[r]!==void 0&&(!t||ke(this,this[r],r,t)))}return!1}delete(e,t){const r=this;let s=!1;function o(i){if(i=te(i),i){const c=l.findKey(r,i);c&&(!t||ke(r,r[c],c,t))&&(delete r[c],s=!0)}}return l.isArray(e)?e.forEach(o):o(e),s}clear(e){const t=Object.keys(this);let r=t.length,s=!1;for(;r--;){const o=t[r];(!e||ke(this,this[o],o,e,!0))&&(delete this[o],s=!0)}return s}normalize(e){const t=this,r={};return l.forEach(this,(s,o)=>{const i=l.findKey(r,o);if(i){t[i]=_e(s),delete t[o];return}const c=e?pr(o):String(o).trim();c!==o&&delete t[o],t[c]=_e(s),r[c]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return l.forEach(this,(r,s)=>{r!=null&&r!==!1&&(t[s]=e&&l.isArray(r)?r.join(", "):r)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
3
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach(s=>r.set(s)),r}static accessor(e){const r=(this[rt]=this[rt]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=te(i);r[c]||(gr(s,i),r[c]=!0)}return l.isArray(e)?e.forEach(o):o(e),this}};k.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);l.reduceDescriptors(k.prototype,({value:n},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>n,set(r){this[t]=r}}});l.freezeMethods(k);function Ie(n,e){const t=this||ce,r=e||t,s=k.from(r.headers);let o=r.data;return l.forEach(n,function(c){o=c.call(t,o,s.normalize(),e?e.status:void 0)}),s.normalize(),o}function Ut(n){return!!(n&&n.__CANCEL__)}let ae=class extends b{constructor(e,t,r){super(e??"canceled",b.ERR_CANCELED,t,r),this.name="CanceledError",this.__CANCEL__=!0}};function Dt(n,e,t){const r=t.config.validateStatus;!t.status||!r||r(t.status)?n(t):e(new b("Request failed with status code "+t.status,[b.ERR_BAD_REQUEST,b.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function mr(n){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return e&&e[1]||""}function br(n,e){n=n||10;const t=new Array(n),r=new Array(n);let s=0,o=0,i;return e=e!==void 0?e:1e3,function(d){const u=Date.now(),a=r[o];i||(i=u),t[s]=d,r[s]=u;let f=o,_=0;for(;f!==s;)_+=t[f++],f=f%n;if(s=(s+1)%n,s===o&&(o=(o+1)%n),u-i<e)return;const m=a&&u-a;return m?Math.round(_*1e3/m):void 0}}function _r(n,e){let t=0,r=1e3/e,s,o;const i=(u,a=Date.now())=>{t=a,s=null,o&&(clearTimeout(o),o=null),n(...u)};return[(...u)=>{const a=Date.now(),f=a-t;f>=r?i(u,a):(s=u,o||(o=setTimeout(()=>{o=null,i(s)},r-f)))},()=>s&&i(s)]}const we=(n,e,t=3)=>{let r=0;const s=br(50,250);return _r(o=>{const i=o.loaded,c=o.lengthComputable?o.total:void 0,d=i-r,u=s(d),a=i<=c;r=i;const f={loaded:i,total:c,progress:c?i/c:void 0,bytes:d,rate:u||void 0,estimated:u&&c&&a?(c-i)/u:void 0,event:o,lengthComputable:c!=null,[e?"download":"upload"]:!0};n(f)},t)},st=(n,e)=>{const t=n!=null;return[r=>e[0]({lengthComputable:t,total:n,loaded:r}),e[1]]},it=n=>(...e)=>l.asap(()=>n(...e)),yr=N.hasStandardBrowserEnv?((n,e)=>t=>(t=new URL(t,N.origin),n.protocol===t.protocol&&n.host===t.host&&(e||n.port===t.port)))(new URL(N.origin),N.navigator&&/(msie|trident)/i.test(N.navigator.userAgent)):()=>!0,wr=N.hasStandardBrowserEnv?{write(n,e,t,r,s,o,i){if(typeof document>"u")return;const c=[`${n}=${encodeURIComponent(e)}`];l.isNumber(t)&&c.push(`expires=${new Date(t).toUTCString()}`),l.isString(r)&&c.push(`path=${r}`),l.isString(s)&&c.push(`domain=${s}`),o===!0&&c.push("secure"),l.isString(i)&&c.push(`SameSite=${i}`),document.cookie=c.join("; ")},read(n){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+n+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(n){this.write(n,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Er(n){return typeof n!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function Sr(n,e){return e?n.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):n}function qt(n,e,t){let r=!Er(e);return n&&(r||t==!1)?Sr(n,e):e}const ot=n=>n instanceof k?{...n}:n;function X(n,e){e=e||{};const t={};function r(u,a,f,_){return l.isPlainObject(u)&&l.isPlainObject(a)?l.merge.call({caseless:_},u,a):l.isPlainObject(a)?l.merge({},a):l.isArray(a)?a.slice():a}function s(u,a,f,_){if(l.isUndefined(a)){if(!l.isUndefined(u))return r(void 0,u,f,_)}else return r(u,a,f,_)}function o(u,a){if(!l.isUndefined(a))return r(void 0,a)}function i(u,a){if(l.isUndefined(a)){if(!l.isUndefined(u))return r(void 0,u)}else return r(void 0,a)}function c(u,a,f){if(f in e)return r(u,a);if(f in n)return r(void 0,u)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(u,a,f)=>s(ot(u),ot(a),f,!0)};return l.forEach(Object.keys({...n,...e}),function(a){if(a==="__proto__"||a==="constructor"||a==="prototype")return;const f=l.hasOwnProp(d,a)?d[a]:s,_=f(n[a],e[a],a);l.isUndefined(_)&&f!==c||(t[a]=_)}),t}const Bt=n=>{const e=X({},n);let{data:t,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:c}=e;if(e.headers=i=k.from(i),e.url=jt(qt(e.baseURL,e.url,e.allowAbsoluteUrls),n.params,n.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),l.isFormData(t)){if(N.hasStandardBrowserEnv||N.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(l.isFunction(t.getHeaders)){const d=t.getHeaders(),u=["content-type","content-length"];Object.entries(d).forEach(([a,f])=>{u.includes(a.toLowerCase())&&i.set(a,f)})}}if(N.hasStandardBrowserEnv&&(r&&l.isFunction(r)&&(r=r(e)),r||r!==!1&&yr(e.url))){const d=s&&o&&wr.read(o);d&&i.set(s,d)}return e},Rr=typeof XMLHttpRequest<"u",xr=Rr&&function(n){return new Promise(function(t,r){const s=Bt(n);let o=s.data;const i=k.from(s.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:u}=s,a,f,_,m,h;function g(){m&&m(),h&&h(),s.cancelToken&&s.cancelToken.unsubscribe(a),s.signal&&s.signal.removeEventListener("abort",a)}let p=new XMLHttpRequest;p.open(s.method.toUpperCase(),s.url,!0),p.timeout=s.timeout;function w(){if(!p)return;const S=k.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),C={data:!c||c==="text"||c==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:S,config:n,request:p};Dt(function(T){t(T),g()},function(T){r(T),g()},C),p=null}"onloadend"in p?p.onloadend=w:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(w)},p.onabort=function(){p&&(r(new b("Request aborted",b.ECONNABORTED,n,p)),p=null)},p.onerror=function(O){const C=O&&O.message?O.message:"Network Error",j=new b(C,b.ERR_NETWORK,n,p);j.event=O||null,r(j),p=null},p.ontimeout=function(){let O=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const C=s.transitional||ze;s.timeoutErrorMessage&&(O=s.timeoutErrorMessage),r(new b(O,C.clarifyTimeoutError?b.ETIMEDOUT:b.ECONNABORTED,n,p)),p=null},o===void 0&&i.setContentType(null),"setRequestHeader"in p&&l.forEach(i.toJSON(),function(O,C){p.setRequestHeader(C,O)}),l.isUndefined(s.withCredentials)||(p.withCredentials=!!s.withCredentials),c&&c!=="json"&&(p.responseType=s.responseType),u&&([_,h]=we(u,!0),p.addEventListener("progress",_)),d&&p.upload&&([f,m]=we(d),p.upload.addEventListener("progress",f),p.upload.addEventListener("loadend",m)),(s.cancelToken||s.signal)&&(a=S=>{p&&(r(!S||S.type?new ae(null,n,p):S),p.abort(),p=null)},s.cancelToken&&s.cancelToken.subscribe(a),s.signal&&(s.signal.aborted?a():s.signal.addEventListener("abort",a)));const E=mr(s.url);if(E&&N.protocols.indexOf(E)===-1){r(new b("Unsupported protocol "+E+":",b.ERR_BAD_REQUEST,n));return}p.send(o||null)})},Ar=(n,e)=>{const{length:t}=n=n?n.filter(Boolean):[];if(e||t){let r=new AbortController,s;const o=function(u){if(!s){s=!0,c();const a=u instanceof Error?u:this.reason;r.abort(a instanceof b?a:new ae(a instanceof Error?a.message:a))}};let i=e&&setTimeout(()=>{i=null,o(new b(`timeout of ${e}ms exceeded`,b.ETIMEDOUT))},e);const c=()=>{n&&(i&&clearTimeout(i),i=null,n.forEach(u=>{u.unsubscribe?u.unsubscribe(o):u.removeEventListener("abort",o)}),n=null)};n.forEach(u=>u.addEventListener("abort",o));const{signal:d}=r;return d.unsubscribe=()=>l.asap(c),d}},Or=function*(n,e){let t=n.byteLength;if(t<e){yield n;return}let r=0,s;for(;r<t;)s=r+e,yield n.slice(r,s),r=s},Cr=async function*(n,e){for await(const t of Tr(n))yield*Or(t,e)},Tr=async function*(n){if(n[Symbol.asyncIterator]){yield*n;return}const e=n.getReader();try{for(;;){const{done:t,value:r}=await e.read();if(t)break;yield r}}finally{await e.cancel()}},ct=(n,e,t,r)=>{const s=Cr(n,e);let o=0,i,c=d=>{i||(i=!0,r&&r(d))};return new ReadableStream({async pull(d){try{const{done:u,value:a}=await s.next();if(u){c(),d.close();return}let f=a.byteLength;if(t){let _=o+=f;t(_)}d.enqueue(new Uint8Array(a))}catch(u){throw c(u),u}},cancel(d){return c(d),s.return()}},{highWaterMark:2})},at=64*1024,{isFunction:fe}=l,Nr=(({Request:n,Response:e})=>({Request:n,Response:e}))(l.global),{ReadableStream:lt,TextEncoder:ut}=l.global,ht=(n,...e)=>{try{return!!n(...e)}catch{return!1}},Pr=n=>{n=l.merge.call({skipUndefined:!0},Nr,n);const{fetch:e,Request:t,Response:r}=n,s=e?fe(e):typeof fetch=="function",o=fe(t),i=fe(r);if(!s)return!1;const c=s&&fe(lt),d=s&&(typeof ut=="function"?(h=>g=>h.encode(g))(new ut):async h=>new Uint8Array(await new t(h).arrayBuffer())),u=o&&c&&ht(()=>{let h=!1;const g=new t(N.origin,{body:new lt,method:"POST",get duplex(){return h=!0,"half"}}).headers.has("Content-Type");return h&&!g}),a=i&&c&&ht(()=>l.isReadableStream(new r("").body)),f={stream:a&&(h=>h.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(h=>{!f[h]&&(f[h]=(g,p)=>{let w=g&&g[h];if(w)return w.call(g);throw new b(`Response type '${h}' is not supported`,b.ERR_NOT_SUPPORT,p)})});const _=async h=>{if(h==null)return 0;if(l.isBlob(h))return h.size;if(l.isSpecCompliantForm(h))return(await new t(N.origin,{method:"POST",body:h}).arrayBuffer()).byteLength;if(l.isArrayBufferView(h)||l.isArrayBuffer(h))return h.byteLength;if(l.isURLSearchParams(h)&&(h=h+""),l.isString(h))return(await d(h)).byteLength},m=async(h,g)=>{const p=l.toFiniteNumber(h.getContentLength());return p??_(g)};return async h=>{let{url:g,method:p,data:w,signal:E,cancelToken:S,timeout:O,onDownloadProgress:C,onUploadProgress:j,responseType:T,headers:V,withCredentials:F="same-origin",fetchOptions:Q}=Bt(h),M=e||fetch;T=T?(T+"").toLowerCase():"text";let U=Ar([E,S&&S.toAbortSignal()],O),D=null;const I=U&&U.unsubscribe&&(()=>{U.unsubscribe()});let he;try{if(j&&u&&p!=="get"&&p!=="head"&&(he=await m(V,w))!==0){let v=new t(g,{method:"POST",body:w,duplex:"half"}),z;if(l.isFormData(w)&&(z=v.headers.get("content-type"))&&V.setContentType(z),v.body){const[Ne,de]=st(he,we(it(j)));w=ct(v.body,at,Ne,de)}}l.isString(F)||(F=F?"include":"omit");const x=o&&"credentials"in t.prototype,y={...Q,signal:U,method:p.toUpperCase(),headers:V.normalize().toJSON(),body:w,duplex:"half",credentials:x?F:void 0};D=o&&new t(g,y);let R=await(o?M(D,Q):M(g,y));const L=a&&(T==="stream"||T==="response");if(a&&(C||L&&I)){const v={};["status","statusText","headers"].forEach(Qe=>{v[Qe]=R[Qe]});const z=l.toFiniteNumber(R.headers.get("content-length")),[Ne,de]=C&&st(z,we(it(C),!0))||[];R=new r(ct(R.body,at,Ne,()=>{de&&de(),I&&I()}),v)}T=T||"text";let H=await f[l.findKey(f,T)||"text"](R,h);return!L&&I&&I(),await new Promise((v,z)=>{Dt(v,z,{data:H,headers:k.from(R.headers),status:R.status,statusText:R.statusText,config:h,request:D})})}catch(x){throw I&&I(),x&&x.name==="TypeError"&&/Load failed|fetch/i.test(x.message)?Object.assign(new b("Network Error",b.ERR_NETWORK,h,D,x&&x.response),{cause:x.cause||x}):b.from(x,x&&x.code,h,D,x&&x.response)}}},kr=new Map,Mt=n=>{let e=n&&n.env||{};const{fetch:t,Request:r,Response:s}=e,o=[r,s,t];let i=o.length,c=i,d,u,a=kr;for(;c--;)d=o[c],u=a.get(d),u===void 0&&a.set(d,u=c?new Map:Pr(e)),a=u;return u};Mt();const Je={http:Kn,xhr:xr,fetch:{get:Mt}};l.forEach(Je,(n,e)=>{if(n){try{Object.defineProperty(n,"name",{value:e})}catch{}Object.defineProperty(n,"adapterName",{value:e})}});const dt=n=>`- ${n}`,Ir=n=>l.isFunction(n)||n===null||n===!1;function vr(n,e){n=l.isArray(n)?n:[n];const{length:t}=n;let r,s;const o={};for(let i=0;i<t;i++){r=n[i];let c;if(s=r,!Ir(r)&&(s=Je[(c=String(r)).toLowerCase()],s===void 0))throw new b(`Unknown adapter '${c}'`);if(s&&(l.isFunction(s)||(s=s.get(e))))break;o[c||"#"+i]=s}if(!s){const i=Object.entries(o).map(([d,u])=>`adapter ${d} `+(u===!1?"is not supported by the environment":"is not available in the build"));let c=t?i.length>1?`since :
4
+ `+i.map(dt).join(`
5
+ `):" "+dt(i[0]):"as no adapter specified";throw new b("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return s}const Ht={getAdapter:vr,adapters:Je};function ve(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new ae(null,n)}function ft(n){return ve(n),n.headers=k.from(n.headers),n.data=Ie.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),Ht.getAdapter(n.adapter||ce.adapter,n)(n).then(function(r){return ve(n),r.data=Ie.call(n,n.transformResponse,r),r.headers=k.from(r.headers),r},function(r){return Ut(r)||(ve(n),r&&r.response&&(r.response.data=Ie.call(n,n.transformResponse,r.response),r.response.headers=k.from(r.response.headers))),Promise.reject(r)})}const zt="1.13.6",Ae={};["object","boolean","number","function","string","symbol"].forEach((n,e)=>{Ae[n]=function(r){return typeof r===n||"a"+(e<1?"n ":" ")+n}});const pt={};Ae.transitional=function(e,t,r){function s(o,i){return"[Axios v"+zt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(e===!1)throw new b(s(i," has been removed"+(t?" in "+t:"")),b.ERR_DEPRECATED);return t&&!pt[i]&&(pt[i]=!0,console.warn(s(i," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(o,i,c):!0}};Ae.spelling=function(e){return(t,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};function Lr(n,e,t){if(typeof n!="object")throw new b("options must be an object",b.ERR_BAD_OPTION_VALUE);const r=Object.keys(n);let s=r.length;for(;s-- >0;){const o=r[s],i=e[o];if(i){const c=n[o],d=c===void 0||i(c,o,n);if(d!==!0)throw new b("option "+o+" must be "+d,b.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new b("Unknown option "+o,b.ERR_BAD_OPTION)}}const ye={assertOptions:Lr,validators:Ae},$=ye.validators;let G=class{constructor(e){this.defaults=e||{},this.interceptors={request:new nt,response:new nt}}async request(e,t){try{return await this._request(e,t)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const o=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+=`
6
+ `+o):r.stack=o}catch{}}throw r}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=X(this.defaults,t);const{transitional:r,paramsSerializer:s,headers:o}=t;r!==void 0&&ye.assertOptions(r,{silentJSONParsing:$.transitional($.boolean),forcedJSONParsing:$.transitional($.boolean),clarifyTimeoutError:$.transitional($.boolean),legacyInterceptorReqResOrdering:$.transitional($.boolean)},!1),s!=null&&(l.isFunction(s)?t.paramsSerializer={serialize:s}:ye.assertOptions(s,{encode:$.function,serialize:$.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),ye.assertOptions(t,{baseUrl:$.spelling("baseURL"),withXsrfToken:$.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=o&&l.merge(o.common,o[t.method]);o&&l.forEach(["delete","get","head","post","put","patch","common"],h=>{delete o[h]}),t.headers=k.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(g){if(typeof g.runWhen=="function"&&g.runWhen(t)===!1)return;d=d&&g.synchronous;const p=t.transitional||ze;p&&p.legacyInterceptorReqResOrdering?c.unshift(g.fulfilled,g.rejected):c.push(g.fulfilled,g.rejected)});const u=[];this.interceptors.response.forEach(function(g){u.push(g.fulfilled,g.rejected)});let a,f=0,_;if(!d){const h=[ft.bind(this),void 0];for(h.unshift(...c),h.push(...u),_=h.length,a=Promise.resolve(t);f<_;)a=a.then(h[f++],h[f++]);return a}_=c.length;let m=t;for(;f<_;){const h=c[f++],g=c[f++];try{m=h(m)}catch(p){g.call(this,p);break}}try{a=ft.call(this,m)}catch(h){return Promise.reject(h)}for(f=0,_=u.length;f<_;)a=a.then(u[f++],u[f++]);return a}getUri(e){e=X(this.defaults,e);const t=qt(e.baseURL,e.url,e.allowAbsoluteUrls);return jt(t,e.params,e.paramsSerializer)}};l.forEach(["delete","get","head","options"],function(e){G.prototype[e]=function(t,r){return this.request(X(r||{},{method:e,url:t,data:(r||{}).data}))}});l.forEach(["post","put","patch"],function(e){function t(r){return function(o,i,c){return this.request(X(c||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}G.prototype[e]=t(),G.prototype[e+"Form"]=t(!0)});let $r=class Vt{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(o){t=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},e(function(o,i,c){r.reason||(r.reason=new ae(o,i,c),t(r.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=r=>{e.abort(r)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new Vt(function(s){e=s}),cancel:e}}};function jr(n){return function(t){return n.apply(null,t)}}function Fr(n){return l.isObject(n)&&n.isAxiosError===!0}const Ue={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Ue).forEach(([n,e])=>{Ue[e]=n});function Jt(n){const e=new G(n),t=At(G.prototype.request,e);return l.extend(t,G.prototype,e,{allOwnKeys:!0}),l.extend(t,e,null,{allOwnKeys:!0}),t.create=function(s){return Jt(X(n,s))},t}const A=Jt(ce);A.Axios=G;A.CanceledError=ae;A.CancelToken=$r;A.isCancel=Ut;A.VERSION=zt;A.toFormData=xe;A.AxiosError=b;A.Cancel=A.CanceledError;A.all=function(e){return Promise.all(e)};A.spread=jr;A.isAxiosError=Fr;A.mergeConfig=X;A.AxiosHeaders=k;A.formToJSON=n=>Ft(l.isHTMLForm(n)?new FormData(n):n);A.getAdapter=Ht.getAdapter;A.HttpStatusCode=Ue;A.default=A;const{Axios:ni,AxiosError:ri,CanceledError:si,isCancel:ii,CancelToken:oi,VERSION:ci,all:ai,Cancel:li,isAxiosError:ui,spread:hi,toFormData:di,AxiosHeaders:fi,HttpStatusCode:pi,formToJSON:gi,getAdapter:mi,mergeConfig:bi}=A,Oe=A.create({baseURL:location.origin,timeout:6e4,params:{}});Oe.interceptors.response.use(n=>n,n=>{if(n.response){if(n.response.status===401&&OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity,!0).then(function(r){r&&OpenC3Auth.setTokens()}),n.response.config.headers["Ignore-Errors"]&&n.response.config.headers["Ignore-Errors"].includes(n.response.status.toString()))return Promise.reject(n);let e=`HTTP ${n.response.status} - `;n.response?.statusText&&(e+=`${n.response.statusText} `),n.response?.config?.data&&(e+=`${n.response.config.data} `),n.response?.data?.message?e+=`${n.response.data.message}`:n.response?.data?.exception?e+=`${n.response.data.exception}`:n.response?.data?.error?.message?(n.response.data.error.class&&(e+=`${n.response.data.error.class} `),e+=`${n.response.data.error.message}`):e+=`${n.response?.data}`;const{$cosmosNotify:t}=window;throw t&&t.serious({title:"Network error",body:e}),n}else throw n});const pe=async function(n,e,{data:t,params:r={},headers:s,noAuth:o=!1,noScope:i=!1,onUploadProgress:c=!1}={}){if(!o){try{await OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity)&&OpenC3Auth.setTokens()}catch{OpenC3Auth.login()}s.Authorization=localStorage.openc3Token}return s.manual=!0,!i&&!r.scope&&(r.scope=window.openc3Scope),Oe({method:n,url:e,data:t,params:r,headers:s,onUploadProgress:c})},De={Accept:"application/json"},gt={...De,"Content-Type":"application/json"},Wt={get:function(n,{params:e,headers:t=De,noScope:r,noAuth:s,onUploadProgress:o}={}){return pe("get",n,{params:e,headers:t,noScope:r,noAuth:s,onUploadProgress:o})},put:function(n,{data:e,params:t,headers:r=gt,noScope:s,noAuth:o,onUploadProgress:i}={}){return pe("put",n,{data:e,params:t,headers:r,noScope:s,noAuth:o,onUploadProgress:i})},post:function(n,{data:e,params:t,headers:r=gt,noScope:s,noAuth:o,onUploadProgress:i}={}){return pe("post",n,{data:e,params:t,headers:r,noScope:s,noAuth:o,onUploadProgress:i})},delete:function(n,{params:e,headers:t=De,noScope:r,noAuth:s,onUploadProgress:o}={}){return pe("delete",n,{params:e,headers:t,noScope:r,noAuth:s,onUploadProgress:o})}};let Ce=()=>({emit(n,...e){for(let t=this.events[n]||[],r=0,s=t.length;r<s;r++)t[r](...e)},events:{},on(n,e){return(this.events[n]||=[]).push(e),()=>{this.events[n]=this.events[n]?.filter(t=>e!==t)}}});class le extends Error{constructor(e,t){e instanceof Error?(super(e.message),this.cause=e):super(e),this.reason=t,this.name="ReasonError"}}class We extends le{constructor(e){super("Rejected",e),this.name="SubscriptionRejectedError"}}class Ur extends le{constructor(e){super(e||"Timed out to receive subscription ack"),this.name="SubscriptionTimeoutError"}}class q extends le{constructor(e,t){t?super(e,t):super("Disconnected",e),this.name="DisconnectedError"}}class Dr extends q{constructor(e){super(e,"stale_connection"),this.name="StaleConnectionError"}}function Kt(n){return n?`{${Object.keys(n).sort().filter(t=>n[t]!==void 0).map(t=>{let r=JSON.stringify(n[t]);return`${JSON.stringify(t)}:${r}`}).join(",")}}`:""}class qr{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:String(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:r,info:s})=>(t[r]=s,t),{})}}const J=Symbol("state");class Gt{constructor(e={}){this.emitter=Ce(),this.params=Object.freeze(e),this.presence=new qr(this),this.initialConnect=!0,this[J]="idle"}get identifier(){return this._identifier?this._identifier:(this._identifier=Kt({channel:this.channelId,...this.params}),this._identifier)}get channelId(){return this.constructor.identifier}get state(){return this[J]}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[J]="connecting"}connected(){if(this.state==="connected"||this.state==="closed")return;this[J]="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[J]="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[J]="disconnected",this.presence.reset(),this.emit("disconnect",e))}closed(e){this.state!=="closed"&&(this[J]="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 r=this.receiver?this.receiver.logger:null;r&&r.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 r=this.emitter.on(e,(...s)=>{r(),t(...s)});return r}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 r=[()=>delete this._pendingSubscribe];r.push(this.on("connect",()=>{r.forEach(s=>s()),e()})),r.push(this.on("close",s=>{r.forEach(o=>o()),t(s||new le("Channel was disconnected before subscribing","canceled"))}))}),this._pendingSubscribe)}}class Br{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(r=>r[e](t[0])):this.channels.forEach(r=>r[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,s={promise:new Promise(i=>{t=i}),intent:e,release:()=>{this._pendings.splice(this._pendings.indexOf(s),1),t(s)},canceled:!1,acquired:!1},o=this._pendingTop;return this._pendings.push(s),o&&await o.promise,this.gvl&&await this.gvl.acquire(s,e),s.acquired=!0,s}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 Mr{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 Hr{constructor(e){e.concurrentSubscribes===!1&&(this.glv=new Mr),this._subscriptions={},this._localToRemote={}}all(){return Object.values(this._subscriptions)}get(e){return this._subscriptions[e]}create(e,{subscribe:t,unsubscribe:r}){let s=this._subscriptions[e]=new Br(e);return s.remoteId=this._localToRemote[e],s.subscriber=t,s.unsubscriber=r,s.gvl=this.glv,s}remove(e){delete this._subscriptions[e],delete this._localToRemote[e]}storeRemoteId(e,t){this._localToRemote[e]=t;let r=this.get(e);r&&(r.remoteId=t)}}class zr{constructor(e={}){this.subscriptions=new Hr(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 r=t.remoteId;r&&delete this._remoteToLocal[r],this.subscriptions.remove(e)}transmit(e,t,r){let s=this._remoteToLocal[e];if(!s){this._pendingMessages.push([e,t,r]);return}let o=this.subscriptions.get(s);o&&o.channels.forEach(i=>{i.receive(t,r)})}notify(e,t,r){let s=this._remoteToLocal[e];if(!s)return;let o=this.subscriptions.get(s);o&&o.channels.forEach(i=>i.emit(t,r))}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 r of this._pendingMessages)r[0]===e?this.transmit(r[0],r[1],r[2]):t.push(r);this._pendingMessages=t}}const mt={debug:0,info:1,warn:2,error:3};class Xt{constructor(e){this.level=e||"warn"}log(e,t,r){mt[e]<mt[this.level]||this.writeLogEntry(e,t,r)}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 ue extends Xt{writeLogEntry(){}}class Vr{encode(e){return JSON.stringify(e)}decode(e){try{return JSON.parse(e)}catch{}}}let Jr=0;class Qt{constructor(e={}){let{logger:t}=e;this.logger=t||new ue,this.pendingSubscriptions={},this.pendingUnsubscriptions={},this.subscribeCooldownInterval=e.subscribeCooldownInterval||250,this.subscribeRetryInterval=e.subscribeRetryInterval||5e3}attached(e){this.cable=e}subscribe(e,t){let r={channel:e};t&&Object.assign(r,t);let s=Kt(r);if(this.pendingUnsubscriptions[s]){let i=this.subscribeCooldownInterval*1.5;return this.logger.debug(`unsubscribed recently, cooldown for ${i}`,s),new Promise(c=>{setTimeout(()=>{c(this.subscribe(e,t))},i)})}if(this.pendingSubscriptions[s])return this.logger.warn("subscription is already pending, skipping",s),Promise.reject(Error("Already subscribing"));let o=this.subscribeRetryInterval;return new Promise((i,c)=>{let d=++Jr;this.pendingSubscriptions[s]={resolve:i,reject:c,id:d},this.cable.send(this.buildSubscribeRequest(s)),this.maybeRetrySubscribe(d,s,o)})}buildSubscribeRequest(e){return{command:"subscribe",identifier:e}}maybeRetrySubscribe(e,t,r){setTimeout(()=>{let s=this.pendingSubscriptions[t];s&&s.id===e&&(this.logger.warn(`no subscription ack received in ${r}ms, retrying subscribe`,t),this.cable.send(this.buildSubscribeRequest(t)),this.maybeExpireSubscribe(e,t,r))},r)}maybeExpireSubscribe(e,t,r){setTimeout(()=>{let s=this.pendingSubscriptions[t];s&&s.id===e&&(delete this.pendingSubscriptions[t],s.reject(new Ur(`Haven't received subscription ack in ${r*2}ms for ${t}`)))},r)}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,r){return t==="$whisper"?this.whisper(e,r):(r||(r={}),r.action||=t,this.cable.send({command:"message",identifier:e,data:JSON.stringify(r)}),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:r,message:s,reason:o,reconnect:i}=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 q(o);this.reset(c),i===!1?this.cable.closed(c):this.cable.disconnected(c);return}if(t==="confirm_subscription"){let c=this.pendingSubscriptions[r];if(!c){this.logger.error("subscription not found, unsubscribing",{type:t,identifier:r}),this.unsubscribe(r);return}return delete this.pendingSubscriptions[r],c.resolve(r)}if(t==="reject_subscription"){let c=this.pendingSubscriptions[r];return c?(delete this.pendingSubscriptions[r],c.reject(new We)):this.logger.error("subscription not found",{type:t,identifier:r})}if(s)return{identifier:r,message:s};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 bt=()=>Date.now()/1e3|0;class Wr extends Qt{constructor(e={}){super(e),this.streamsPositions={},this.subscriptionStreams={},this.pendingHistory={},this.pendingPresence={},this.presenceInfo={},this.restoreSince=e.historyTimestamp,this.disableSessionRecovery=e.disableSessionRecovery,this.restoreSince===void 0&&(this.restoreSince=bt()),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:r,message:s}=e;if(t==="disconnect")return delete this.sessionId,this.cable.setSessionId(""),super.receive(e);if(t==="reject_subscription")return super.receive(e);if(t==="confirm_subscription")return this.subscriptionStreams[r]||(this.subscriptionStreams[r]=new Set),super.receive(e);if(t==="ping")return this.restoreSince&&(this.restoreSince=bt()),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",r);return}if(t==="reject_history"){this.logger.warn("failed to retrieve history",e),this.cable.notify("history_not_found",r);return}if(t==="welcome"){if(this.disableSessionRecovery||(this.sessionId=e.sid,this.sessionId&&this.cable.setSessionId(this.sessionId)),e.restored){let o=e.restored_ids||Object.keys(this.subscriptionStreams);for(let i of o)this.cable.send({identifier:i,command:"history",history:this.historyRequestFor(i)}),this.presenceInfo[i]&&this.cable.send({identifier:i,command:"join",presence:this.presenceInfo[i]});return this.cable.restored(o)}return this.cable.connected(this.sessionId)}if(t==="presence"){let o=s.type;if(o==="info"){let i=this.pendingPresence[r];i&&(delete this.pendingPresence[r],i.resolve(s))}else if(o==="error"){let i=this.pendingPresence[r];i&&(delete this.pendingPresence[r],i.reject(new Error("failed to retrieve presence")))}return{type:t,identifier:r,message:s}}if(s){let o=this.trackStreamPosition(r,e.stream_id,e.epoch,e.offset);return{identifier:r,message:s,meta:o}}this.logger.warn(`unknown message type: ${t}`,{message:e})}perform(e,t,r){switch(t){case"$presence:join":return this.join(e,r);case"$presence:leave":return this.leave(e,r);case"$presence:info":return this.presence(e,r)}return super.perform(e,t,r)}unsubscribe(e){return delete this.presenceInfo[e],super.unsubscribe(e)}buildSubscribeRequest(e){let t=super.buildSubscribeRequest(e),r=this.historyRequestFor(e);r&&(t.history=r,this.pendingHistory[e]=!0);let s=this.presenceInfo[e];return s&&(t.presence=s),t}recoverableClosure(){return!!this.sessionId}historyRequestFor(e){let t={},r=!1;if(this.subscriptionStreams[e])for(let s of this.subscriptionStreams[e]){let o=this.streamsPositions[s];o&&(r=!0,t[s]=o)}if(!(!r&&!this.restoreSince))return{since:this.restoreSince,streams:t}}trackStreamPosition(e,t,r,s){if(!(!t||!r))return this.subscriptionStreams[e]||(this.subscriptionStreams[e]=new Set),this.subscriptionStreams[e].add(t),this.streamsPositions[t]={epoch:r,offset:s},{stream:t,epoch:r,offset:s}}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((r,s)=>{this.pendingPresence[e]={resolve:r,reject:s},this.cable.send({command:"presence",identifier:e,data:t})})}}class Kr extends le{constructor(){super("No connection","closed"),this.name="NoConnectionError"}}class Zt extends Gt{static identifier="__ghost__";constructor(e,t){super(t),this.channelId=e}set channelId(e){this._channelId=e}get channelId(){return this._channelId}}const Gr="$pubsub";class _t extends Gt{static identifier=Gr;async perform(e,t){if(e.startsWith("$"))return super.perform(e,t);throw Error("not implemented")}}const W=Symbol("state");let Xr=class{constructor({transport:e,protocol:t,encoder:r,logger:s,lazy:o,hubOptions:i,performFailures:c,transportConfigurator:d}){this.emitter=Ce(),this.transport=e,this.encoder=r,this.logger=s||new ue,this.protocol=t,this.performFailures=c||"throw",this.protocol.attached(this),this.hub=new zr(i||{}),this[W]="idle",this.handleClose=this.handleClose.bind(this),this.handleIncoming=this.handleIncoming.bind(this),this.transportConfigurator=d,this.transport.on("close",this.handleClose),this.transport.on("data",this.handleIncoming),this.initialConnect=!0,this.recovering=!1,o===!1&&this.connect().catch(()=>{})}get state(){return this[W]}async connect(){if(this.state==="connected")return Promise.resolve();if(this.state==="connecting")return this.pendingConnect();let e=this.state==="idle";this[W]="connecting";let t=this.pendingConnect();this.logger.debug("connecting");try{this.transportConfigurator&&await this.transportConfigurator(this.transport,{initial:e}),await this.transport.open()}catch(r){this.handleClose(r)}return t}setSessionId(e){this.sessionId=e,this.transport.setParam("sid",e)}connected(){if(this.state==="connected")return;this.logger.info("connected"),this[W]="connected",this.recovering&&this.hub.subscriptions.all().forEach(t=>t.notify("disconnected",new q("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[W]="connected",this.hub.subscriptions.all().forEach(s=>{e&&s.remoteId&&e.includes(s.remoteId)?s.notify("restored"):(s.notify("disconnected",new q("recovery_failed")),this._resubscribe(s))});let t=!this.initialConnect,r=!0;this.recovering=!1,this.initialConnect=!1,this.emit("connect",{reconnect:t,restored:r})}notify(e,t,r){t&&typeof t!="string"&&(r=t,t=void 0),t?this.hub.notify(t,"info",{type:e,data:r}):this.emit("info",{type:e,data:r})}handleClose(e){this.logger.debug("transport closed",{error:e}),this.disconnected(new q(e,"transport_closed"))}disconnected(e){(this.state==="connected"||this.state==="connecting")&&(this.logger.info("disconnected",{reason:e}),this[W]="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 q?e:new q(e,void 0)),this.logger.info("closed",{reason:e||"user"}),this[W]="closed";let r=t||new q("cable_closed");this.hub.subscriptions.all().forEach(s=>s.notify("disconnected",r)),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 r=this.protocol.receive(t);if(r){this.logger.debug("processed incoming message",r);let{type:s,identifier:o,message:i,meta:c}=r;s?this.hub.notify(o,s,i):this.hub.transmit(o,i,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 _t({stream_name:e});return this.subscribe(t)}streamFromSigned(e){let t=new _t({signed_stream_name:e});return this.subscribe(t)}subscribeTo(e,t){let r,s;return typeof e=="string"&&(s=e,e=Zt),r=s?new e(s,t):new e(t),this.subscribe(r)}subscribe(e){if(!e.attached(this))return e;let t=e.identifier;e.connecting();let r=this.hub.subscriptions.get(t)||this.hub.subscriptions.create(t,{subscribe:s=>this._subscribe(s,e.channelId,e.params),unsubscribe:s=>this._unsubscribe(s)});return r.add(e),r.intent==="subscribed"&&r.state==="connected"&&e.connected(),r.ensureSubscribed(),e}async _resubscribe(e){e.intent!=="subscribed"||!e.channels[0]||(e.notify("connecting"),e.ensureResubscribed())}async _subscribe(e,t,r){let s=e.id;if(this.state==="idle"&&this.connect().catch(()=>{}),this.state!=="connected"){this.logger.debug("cancel subscribe, no connection",{identifier:s});return}this.logger.debug("acquiring subscribe lock",{identifier:s});let o=await e.acquire("subscribed");if(o.canceled){this.logger.debug("subscribe lock has been canceled",{identifier:s}),o.release();return}if(this.logger.debug("subscribe lock has been acquired",{identifier:s}),e.intent!=="subscribed"){this.logger.debug("cancel subscribe request, already unsubscribed"),o.release();return}if(this.state!=="connected"){this.logger.debug("cancel subscribe, no connection",{identifier:s}),o.release();return}if(e.state==="connected"){this.logger.debug("already connected, skip subscribe command",{identifier:s}),e.notify("connected"),o.release();return}let i={identifier:t,params:r};this.logger.debug("subscribing",i);try{let c=await this.protocol.subscribe(t,r);this.hub.subscribe(s,c),this.logger.debug("subscribed",{...i,remoteId:c}),e.notify("connected")}catch(c){if(c){if(c instanceof We&&this.logger.warn("rejected",i),c instanceof q){this.logger.debug("disconnected during subscription; will retry on connect",i),o.release();return}this.logger.error("failed to subscribe",{error:c,...i})}e.close(c),this.hub.unsubscribe(s)}o.release()}unsubscribe(e){let t=e.identifier,r=this.hub.subscriptions.get(t);if(!r)throw Error(`Subscription not found: ${t}`);r.remove(e),e.closed(),r.maybeUnsubscribe()}async _unsubscribe(e){let t=e.id;this.logger.debug("acquiring unsubscribe lock",{identifier:t});let r=await e.acquire("unsubscribed");if(r.canceled){this.logger.debug("unsubscribe lock has been canceled",{identifier:t}),r.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}),r.release();return}if(e.state==="disconnected"||e.state==="closed"){this.logger.debug(`already ${e.state} connected, skip unsubscribe command`,{identifier:t}),r.release();return}let s=e.remoteId;if(this.logger.debug("unsubscribing...",{remoteId:s}),this.state!=="connected"){this.logger.debug("unsubscribe skipped (cable is not connected)",{id:t}),e.close(),this.hub.unsubscribe(t),r.release();return}try{await this.protocol.unsubscribe(s),this.logger.debug("unsubscribed remotely",{id:t})}catch(o){o&&(o instanceof q?this.logger.debug("cable disconnected during the unsubscribe command execution",{id:t,error:o}):this.logger.error("unsubscribe failed",{id:t,error:o}))}e.intent==="unsubscribed"?(e.close(),this.hub.unsubscribe(t)):e.state="closed",r.release()}async perform(e,t,r){if(this.performFailures==="throw")return this._perform(e,t,r);try{return await this._perform(e,t,r)}catch(s){this.performFailures==="warn"&&this.logger.warn("perform failed",{error:s});return}}async _perform(e,t,r){if(this.state==="connecting"&&await this.pendingConnect(),this.state==="closed"||this.state==="disconnected")throw new Kr;let s=this.hub.subscriptions.get(e);if(!s)throw Error(`Subscription not found: ${e}`);if(await s.pending("subscribed"),s.intent!=="subscribed")throw Error(`Subscription is closed: ${e}`);let o=s.remoteId,i={id:o,action:t,payload:r};this.logger.debug("perform",i);try{let c=await this.protocol.perform(o,t,r);return c&&this.logger.debug("perform result",{message:c,request:i}),c}catch(c){throw this.logger.error("perform failed",{error:c,request:i}),c}}on(e,t){return this.emitter.on(e,t)}once(e,t){let r=this.emitter.on(e,(...s)=>{r(),t(...s)});return r}emit(e,...t){return this.emitter.emit(e,...t)}pendingConnect(){return this._pendingConnect?this._pendingConnect:(this._pendingConnect=new Promise((e,t)=>{let r=[()=>delete this._pendingConnect];r.push(this.on("connect",()=>{r.forEach(s=>s()),e()})),r.push(this.on("close",s=>{r.forEach(o=>o()),t(s)})),r.push(this.on("disconnect",s=>{r.forEach(o=>o()),t(s)}))}),this._pendingConnect)}};const Qr={maxMissingPings:2,maxReconnectAttempts:1/0},Z=()=>Date.now(),Yt=(n,e)=>{e=e||{};let{backoffRate:t,jitterRatio:r,maxInterval:s}=e;return t=t||2,r===void 0&&(r=.5),o=>{let i=n*t**o,c=i*t,d=i+(c-i)*Math.random(),u=2*(Math.random()-.5)*r;return d=d*(1+u),s&&s<d&&(d=s),d}};let en=class{constructor({pingInterval:e,...t}){if(this.pingInterval=e,!this.pingInterval)throw Error(`Incorrect pingInterval is provided: ${e}`);if(t=Object.assign({},Qr,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 ue,this.state="pending_connect",this.attempts=0,this.disconnectedAt=Z()}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=Z(),this.state="connected",this.cancelReconnect(),this.startPolling()})),this.unbind.push(this.target.on("disconnect",()=>{this.disconnectedAt=Z(),this.state="disconnected",this.stopPolling(),this.scheduleReconnect()})),this.unbind.push(this.target.on("close",()=>{this.disconnectedAt=Z(),this.state="closed",this.cancelReconnect(),this.stopPolling()})),this.unbind.push(this.target.on("keepalive",()=>{this.pingedAt=Z()})),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=Z()-this.pingedAt;e>this.maxMissingPings*this.pingInterval&&(this.logger.warn(`Stale connection: ${e}ms without pings`),this.state="pending_disconnect",this.target.disconnected(new Dr))}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 Zr{constructor(e,t={}){this.transports=e,this.transport=null,this.emitter=Ce(),this.unbind=[],this.logger=t.logger||new ue}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(r){this.logger.debug(`Failed to connect via ${t.displayName()}: ${r.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(r=>{r.setParam(e,t)})}setToken(e,t){this.transports.forEach(r=>{r.setToken(e,t)})}on(e,t){return this.emitter.on(e,t)}once(e,t){let r=this.emitter.on(e,(...s)=>{r(),t(...s)});return r}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 Yr{constructor(e,t={}){this.url=e;let r=t.websocketImplementation;if(r)this.Impl=r;else if(typeof WebSocket<"u")this.Impl=WebSocket;else throw new Error("No WebSocket support");this.connected=!1,this.emitter=Ce();let{format:s,subprotocol:o,authStrategy:i}=t;this.format=s||"text",this.connectionOptions=t.websocketOptions,this.authStrategy=i||"param",this.authProtocol="",this.subprotocol=o}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,r)=>{let s=[];s.push(this.once("open",()=>{s.forEach(o=>o()),t()})),s.push(this.once("close",()=>{s.forEach(o=>o()),r(Error("WS connection closed"))}))})}setURL(e){this.url=e}setParam(e,t){let r=new URL(this.url);r.searchParams.set(e,t);let s=`${r.protocol}//${r.host}${r.pathname}?${r.searchParams}`;this.setURL(s)}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 r=`x-${t}`.toLowerCase();r=Object.keys(this.connectionOptions.headers).find(o=>o.toLowerCase()===r)||r,this.connectionOptions.headers[r]=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 r=this.emitter.on(e,(...s)=>{r(),t(...s)});return r}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")}}class es{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)}whisper(e){return this.channel.whisper(e)}get identifier(){return this.channel.identifier}unsubscribe(){return this.channel.disconnect()}}class ts extends Zt{constructor(e,t,r){super(e,t),this.subscription=new es(this),Object.assign(this.subscription,r),this.on("connect",({reconnect:s})=>this.subscription.notify("connected",{reconnected:s})),this.on("disconnect",()=>this.subscription.notify("disconnected",{allowReconnect:!0})),this.on("message",s=>this.subscription.notify("received",s)),this.on("close",s=>{s&&s instanceof We?this.subscription.notify("rejected"):this.subscription.notify("disconnected",{allowReconnect:!1})})}}class ns{constructor(e){this.cable=e}create(e,t){let r,s;typeof e=="object"?(r=e.channel,delete e.channel,s=e):(r=e,s={});let o=new ts(r,s,t);return o.subscription.notify("initialized"),this.cable.subscribe(o),o.subscription}findAll(e){return this.cable.hub.channels.filter(t=>t.identifier===e).map(t=>t.subscription)}}class rs{constructor(e){this.cable=e,this.subscriptions=new ns(e)}send(e){return this.cable.send(e)}connect(){return this.cable.connect()}disconnect(){return this.cable.disconnect()}ensureActiveConnection(){return this.cable.connect()}}const tn={protocol:"actioncable-v1-json",pingInterval:3e3,maxReconnectAttempts:1/0,maxMissingPings:2,logLevel:"warn",lazy:!0};function ss(n,e){if(typeof n=="object"&&typeof e>"u"&&(e=n,n=void 0),e=e||{},!n&&!e.transport)throw Error("URL or transport must be specified");e=Object.assign({},tn,e);let{protocol:t,websocketImplementation:r,websocketFormat:s,websocketOptions:o,websocketAuthStrategy:i,fallbacks:c,logLevel:d,logger:u,transport:a,encoder:f,lazy:_,monitor:m,pingInterval:h,reconnectStrategy:g,maxMissingPings:p,maxReconnectAttempts:w,subprotocol:E,tokenRefresher:S,historyTimestamp:O,protocolOptions:C,concurrentSubscribes:j,performFailures:T,transportConfigurator:V,auth:F}=e;if(u=u||new ue(d),typeof t=="string"){E=E||t;let U=t.substring(0,t.lastIndexOf("-")),D=t.substring(t.lastIndexOf("-")+1);if(C=C||{},U==="actioncable-v1")t=new Qt({logger:u,...C});else if(U==="actioncable-v1-ext")t=new Wr({logger:u,historyTimestamp:O,...C});else throw Error(`Protocol is not supported yet: ${t}`);if(D==="json")f=f||new Vr,s=s||"text";else if(D==="msgpack"){if(s="binary",!f)throw Error("Msgpack encoder must be specified explicitly. Use `@anycable/msgpack-encoder` package or build your own")}else if(D==="protobuf"){if(s=s||"binary",!f)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 Yr(n,{websocketImplementation:r,websocketOptions:o,subprotocol:E,authStrategy:i,format:s}),c&&(a=new Zr([a,...c],{logger:u})),F&&F.token&&a.setToken(F.token,F.param||"jid"),g=g||Yt(h),m!==!1&&(m=m||new en({pingInterval:h,reconnectStrategy:g,maxMissingPings:p,maxReconnectAttempts:w,logger:u}));let Q={concurrentSubscribes:j},M=new Xr({protocol:t,transport:a,encoder:f,logger:u,lazy:_,hubOptions:Q,performFailures:T,transportConfigurator:V});return m&&(m.watch(M),M.monitor=m),S&&is(M,async()=>{try{await S(a)}catch(U){return u.error("Failed to refresh authentication token: "+U),!1}return M.connect().catch(()=>{}),!0}),M}function is(n,e){let t=!1;n.on("connect",()=>t=!1),n.on("close",async r=>{if(r){if(t){n.logger.warn("Token auto-refresh is disabled",r);return}r.reason==="token_expired"&&(t=!0,await e())}})}class os extends Xt{writeLogEntry(e,t,r){r?console[e](t,r):console[e](t)}}class cs extends en{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=s=>{this.reconnectNow()&&this.logger.debug("Trigger reconnect",{event:s})},r=()=>this.disconnect(new q("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",r,!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",r,!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 as=["cable","action-cable"],ls="/cable",Te=(n,e)=>{for(let t of as){let r=n.head.querySelector(`meta[name='${t}-${e}']`);if(r)return r.getAttribute("content")}},yt=n=>n.match(/wss?:\/\//)?n:typeof window<"u"?`${window.location.protocol.replace("http","ws")}//${window.location.host}${n}`:n,us=()=>{if(typeof document<"u"&&document.head){let n=Te(document,"url");if(n)return yt(n)}return yt(ls)},hs=()=>{if(typeof document<"u"&&document.head){let n=Te(document,"history-timestamp");if(n)return n|0}},ds=()=>{if(typeof document<"u"&&document.head)return Te(document,"token")},fs=()=>{if(typeof document<"u"&&document.head)return Te(document,"token-param")};function ps(n,e){typeof n=="object"&&typeof e>"u"&&(e=n,n=void 0),n=n||us(),e=e||{},e.historyTimestamp||=hs();let t=ds();if(t){let u=fs();e.auth=Object.assign({token:t,param:u},e.auth||{})}e=Object.assign({},tn,e);let{logLevel:r,logger:s,pingInterval:o,reconnectStrategy:i,maxMissingPings:c,maxReconnectAttempts:d}=e;return s=e.logger=e.logger||new os(r),i=e.reconnectStrategy=e.reconnectStrategy||Yt(o),e.monitor!==!1&&(e.monitor=e.monitor||new cs({pingInterval:o,reconnectStrategy:i,maxMissingPings:c,maxReconnectAttempts:d,logger:s})),ss(n,e)}function gs(n,e){let t=ps(n,e);return new rs(t)}class ms{constructor(e="/openc3-api/cable",t="/openc3-api/auth/otp"){this._cable=null,this._url=e,this._otpUrl=t}disconnect(){this._cable&&(this._cable.cable.disconnect(),this._cable=null)}createSubscription(e,t,r={},s={}){return OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity).then(o=>(o&&OpenC3Auth.setTokens(),Wt.get(this._otpUrl,{params:{scope:t}}))).then(({data:o})=>{if(this._cable==null){const i=new URL(this._url,document.baseURI);i.searchParams.set("scope",t),i.searchParams.set("authorization",o),this._cable=gs(i.href)}return this._cable.subscriptions.create({channel:e,...s},r)})}recordPing(){}}class qe{constructor(e,t,r="",s=""){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=r,this.url=s}}class bs{keyword=null;parameters=[];filename="";line="";lineNumber=0;url="https://docs.openc3.com/docs/configuration";constructor(){}verify_num_parameters(e,t,r=""){for(let s=1;s<=e;s++)if(this.parameters[s-1]===void 0)throw new qe(this,`Not enough parameters for ${this.keyword}.`,r,this.url);if(t&&this.parameters[t]!==void 0)throw new qe(this,`Too many parameters for ${this.keyword}.`,r,this.url)}remove_quotes(e){if(e.length<2)return e;let t=e.charAt(0);if(t!=='"'&&t!=="'")return e;let r=e.charAt(e.length-1);return t!==r?e:e.substring(1,e.length-1)}scan_string(e,t){if(!t.global)throw"rx must have 'global' flag set";let r=[];return e.replace(t,function(s){return r.push(s),s}),r}parse_string(e,t,r,s,o){let i=!1,c=!1;this.line="",this.keyword=null,this.parameters=[],this.filename=t;let d=e.split(`
7
7
  `),u=d.length;for(let a=0;a<u;a++){this.lineNumber=a+1;let f=d[a];if(i)this.line=f;else{if(f=f.trim(),f.length===0){if(r){let S=o(null,[],this.line,this.lineNumber);S===!0&&(i=!0),S===!1&&(i=!1)}continue}if(c===!0){if(f[0]==="#")continue;f=f.substring(1,f.length)}let w=f.charAt(f.length-1),E=!1;switch(w){case"+":E=!0;case"\\":let S=f.substring(0,f.length-1).trim();this.line+=S.substring(0,S.length-1),E&&(this.line+=`
8
- `),c=!0;continue;case"&":this.line+=f.substring(0,f.length-1);continue;default:this.line+=f}}c=!1;let _=/("([^\\"]|\\.)*")|('([^\\']|\\.)*')|\S+/g,g=this.scan_string(this.line,_),h="";if(g.length>0&&(h=h+g[0]),h.length===0||h.charAt(0)==="#"?this.keyword=null:this.keyword=h.toUpperCase(),this.parameters=[],this.keyword===null){if(r){let w=o(this.keyword,this.parameters,this.line,this.lineNumber);w===!0&&(i=!0),w===!1&&(i=!1)}this.line="";continue}let m=g.length;if(m>1)for(let w=1;w<m;w++){let E=g[w];if(E.length>0&&E.charAt(0)==="#")break;s?this.parameters.push(this.remove_quotes(E)):this.parameters.push(E)}let p=o(this.keyword,this.parameters,this.line,this.lineNumber);p===!0&&(i=!0),p===!1&&(i=!1),this.line=""}}}function re(n){return fs.test(n)}const fs=/^-?[0-9]+$/;function Yt(n){return ps.test(n)}const ps=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function en(n,e){if(re(n))return Number.isSafeInteger(Number.parseInt(n,10));const t=Number.parseFloat(n),r=String(t);if(n===r)return!0;const s=bt(n),o=bt(r);return!!(s===o||e?.approx===!0&&!re(n)&&o.length>=14&&s.startsWith(o.substring(0,14)))}let ne=(function(n){return n.underflow="underflow",n.overflow="overflow",n.truncate_integer="truncate_integer",n.truncate_float="truncate_float",n})({});function ms(n){if(en(n,{approx:!1}))return;if(re(n))return ne.truncate_integer;const e=Number.parseFloat(n);return Number.isFinite(e)?e===0?ne.underflow:ne.truncate_float:ne.overflow}function bt(n){const{start:e,end:t}=gs(n),r=n.substring(e,t),s=r.indexOf(".");return s===-1?r:r.substring(0,s)+r.substring(s+1)}function gs(n){let e=0;for(n[0]==="-"&&e++;n[e]==="0"||n[e]===".";)e++;let t=n.lastIndexOf("e");for(t===-1&&(t=n.lastIndexOf("E")),t===-1&&(t=n.length);(n[t-1]==="0"||n[t-1]===".")&&t>e;)t--;return{start:e,end:t}}class bs{isLosslessNumber=!0;constructor(e){if(!Yt(e))throw new Error(`Invalid number (value: "${e}")`);this.value=e}valueOf(){const e=ms(this.value);if(e===void 0||e===ne.truncate_float)return Number.parseFloat(this.value);if(re(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 _s(n){return n&&typeof n=="object"&&n.isLosslessNumber||!1}function ys(n){return new bs(n)}function ws(n,e){return Je({"":n},"",n,e)}function Je(n,e,t,r){return Array.isArray(t)?r.call(n,e,Ss(t,r)):t&&typeof t=="object"&&!_s(t)?r.call(n,e,Es(t,r)):r.call(n,e,t)}function Es(n,e){for(const t of Object.keys(n)){const r=Je(n,t,n[t],e);r!==void 0?n[t]=r:delete n[t]}return n}function Ss(n,e){for(let t=0;t<n.length;t++)n[t]=Je(n,String(t),n[t],e);return n}function xs(n,e,t){const r=typeof t=="function"?{parseNumber:t}:t,s=r?.parseNumber??ys,o=r?.onDuplicateKey??T;let i=0;const c=a();return w(c),S(),e?ws(c,e):c;function d(){if(n.charCodeAt(i)===Ns){i++,_();const y={};let x=!0;for(;i<n.length&&n.charCodeAt(i)!==yt;){x?x=!1:(m(),_());const L=i,H=g();if(H===void 0){$();return}_(),p();const v=a();if(v===void 0){j();return}if(Object.prototype.hasOwnProperty.call(y,H)&&!qe(v,y[H])){const z=o({key:H,position:L+1,oldValue:y[H],newValue:v});z!==void 0&&(y[H]=z)}else y[H]=v}return n.charCodeAt(i)!==yt&&V(),i++,y}}function u(){if(n.charCodeAt(i)===ks){i++,_();const y=[];let x=!0;for(;i<n.length&&n.charCodeAt(i)!==wt;){x?x=!1:m();const L=a();E(L),y.push(L)}return n.charCodeAt(i)!==wt&&F(),i++,y}}function a(){_();const y=g()??h()??d()??u()??f("true",!0)??f("false",!1)??f("null",null);return _(),y}function f(y,x){if(n.slice(i,i+y.length)===y)return i+=y.length,x}function _(){for(;Rs(n.charCodeAt(i));)i++}function g(){if(n.charCodeAt(i)===ve){i++;let y="";for(;i<n.length&&n.charCodeAt(i)!==ve;){if(n.charCodeAt(i)===Ts){const x=n[i+1],L=Cs[x];L!==void 0?(y+=L,i++):x==="u"?me(n.charCodeAt(i+2))&&me(n.charCodeAt(i+3))&&me(n.charCodeAt(i+4))&&me(n.charCodeAt(i+5))?(y+=String.fromCharCode(Number.parseInt(n.slice(i+2,i+6),16)),i+=5):U(i):B(i)}else Os(n.charCodeAt(i))?y+=n[i]:Q(n[i]);i++}return C(),i++,y}}function h(){const y=i;if(n.charCodeAt(i)===Et&&(i++,O(y)),n.charCodeAt(i)===We)i++;else if(As(n.charCodeAt(i)))for(i++;ge(n.charCodeAt(i));)i++;if(n.charCodeAt(i)===Us)for(i++,O(y);ge(n.charCodeAt(i));)i++;if(n.charCodeAt(i)===Hs||n.charCodeAt(i)===Ms)for(i++,(n.charCodeAt(i)===Et||n.charCodeAt(i)===$s)&&i++,O(y);ge(n.charCodeAt(i));)i++;if(i>y)return s(n.slice(y,i))}function m(){if(n.charCodeAt(i)!==js)throw new SyntaxError(`Comma ',' expected after value ${R()}`);i++}function p(){if(n.charCodeAt(i)!==Ds)throw new SyntaxError(`Colon ':' expected after property name ${R()}`);i++}function w(y){if(y===void 0)throw new SyntaxError(`JSON value expected ${R()}`)}function E(y){if(y===void 0)throw new SyntaxError(`Array item expected ${R()}`)}function S(){if(i<n.length)throw new SyntaxError(`Expected end of input ${R()}`)}function O(y){if(!ge(n.charCodeAt(i))){const x=n.slice(y,i);throw new SyntaxError(`Invalid number '${x}', expecting a digit ${R()}`)}}function C(){if(n.charCodeAt(i)!==ve)throw new SyntaxError(`End of string '"' expected ${R()}`)}function $(){throw new SyntaxError(`Quoted object key expected ${R()}`)}function T(y){let{key:x,position:L}=y;throw new SyntaxError(`Duplicate key '${x}' encountered at position ${L}`)}function V(){throw new SyntaxError(`Quoted object key or end of object '}' expected ${R()}`)}function F(){throw new SyntaxError(`Array item or end of array ']' expected ${R()}`)}function Q(y){throw new SyntaxError(`Invalid character '${y}' ${I()}`)}function B(y){const x=n.slice(y,y+2);throw new SyntaxError(`Invalid escape character '${x}' ${I()}`)}function j(){throw new SyntaxError(`Object value expected after ':' ${I()}`)}function U(y){const x=n.slice(y,y+6);throw new SyntaxError(`Invalid unicode character '${x}' ${I()}`)}function I(){return`at position ${i}`}function he(){return i<n.length?`but got '${n[i]}'`:"but reached end of input"}function R(){return`${he()} ${I()}`}}function Rs(n){return n===Ps||n===Is||n===vs||n===Ls}function me(n){return n>=We&&n<=Ke||n>=qs&&n<=zs||n>=Bs&&n<=Vs}function ge(n){return n>=We&&n<=Ke}function As(n){return n>=Fs&&n<=Ke}function Os(n){return n>=32&&n<=1114111}function qe(n,e){return n===e?!0:Array.isArray(n)&&Array.isArray(e)?n.length===e.length&&n.every((t,r)=>qe(t,e[r])):_t(n)&&_t(e)?[...new Set([...Object.keys(n),...Object.keys(e)])].every(r=>qe(n[r],e[r])):!1}function _t(n){return typeof n=="object"&&n!==null}const Cs={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
9
- `,r:"\r",t:" "},Ts=92,Ns=123,yt=125,ks=91,wt=93,Ps=32,Is=10,vs=9,Ls=13,ve=34,$s=43,Et=45,We=48,Fs=49,Ke=57,js=44,Us=46,Ds=58,qs=65,Bs=97,Ms=69,Hs=101,zs=70,Vs=102;function tn(n,e,t,r){const s=void 0;return i(n,"");function i(a,f){if(Array.isArray(r)){const _=r.find(g=>g.test(a));if(_){const g=_.stringify(a);if(typeof g!="string"||!Yt(g))throw new Error(`Invalid JSON number: output of a number stringifier must be a string containing a JSON number (output: ${g})`);return g}}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?.isLosslessNumber||typeof a=="bigint")return a.toString();if(Array.isArray(a))return c(a,f);if(a&&typeof a=="object")return d(a,f)}function c(a,f){if(a.length===0)return"[]";const _=s?f+s:void 0;let g=s?`[
10
- `:"[";for(let h=0;h<a.length;h++){const m=a[h];s&&(g+=_),typeof m<"u"&&typeof m!="function"?g+=i(m,_):g+="null",h<a.length-1&&(g+=s?`,
11
- `:",")}return g+=s?`
12
- ${f}]`:"]",g}function d(a,f){if(typeof a.toJSON=="function")return tn(a.toJSON(),e,t,void 0);const _=Array.isArray(e)?e.map(String):Object.keys(a);if(_.length===0)return"{}";const g=s?f+s:void 0;let h=!0,m=s?`{
13
- `:"{";for(const p of _){const w=a[p];if(u(p,w)){h?h=!1:m+=s?`,
14
- `:",";const E=JSON.stringify(p);m+=s?`${g+E}: `:`${E}:`,m+=i(w,g)}}return m+=s?`
15
- ${f}}`:"}",m}function u(a,f){return typeof f<"u"&&typeof f!="function"&&typeof f!="symbol"}}function Js(n){return re(n)&&!en(n)?BigInt(n):parseFloat(n)}class Ws{id=1;constructor(){}async exec(e,t,r={},s={},o=6e4){try{await OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity)&&OpenC3Auth.setTokens()}catch{OpenC3Auth.login()}this.id=this.id+1;try{return r.scope=window.openc3Scope,s.manual=!0,(await Oe.post("/openc3-api/api",{jsonrpc:"2.0",method:e,params:t,id:this.id,keyword_params:r},{headers:{Authorization:localStorage.openc3Token,"Content-Type":"application/json-rpc",...s},timeout:o,transformRequest:[(c,d)=>tn(c)],transformResponse:[c=>{try{return xs(c,void 0,Js)}catch{const u=typeof c=="string"?c.substring(0,200):String(c),a=new Error(`Server returned non-JSON response: ${u}`);throw a.name="ServerError",a}}]})).data.result}catch(i){let c=new Error;throw i.response?(c.name=i.response.data.error.data.class,c.message=i.response.data.error.data.message,c.object=i.response.data.error):i.request?(c.name="Request error",c.message="Request error, no response received"):c=i,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,r,s,o){return this.exec("map_target_to_interface",[e,t],{cmd_only:r,tlm_only:s,unmap_old:o})}unmap_target_from_interface(e,t,r,s){return this.exec("unmap_target_from_interface",[e,t],{cmd_only:r,tlm_only:s})}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,...r){return this.exec("interface_cmd",[e,t,...r])}interface_target_enable(e,t,r=!1,s=!1){return this.exec("interface_target_enable",[e,t],{cmd_only:r,tlm_only:s})}interface_target_disable(e,t,r=!1,s=!1){return this.exec("interface_target_disable",[e,t],{cmd_only:r,tlm_only:s})}interface_details(e){return this.exec("interface_details",[e])}get_all_router_info(){return this.exec("get_all_router_info",[])}map_target_to_router(e,t,r,s,o){return this.exec("map_target_to_router",[e,t],{cmd_only:r,tlm_only:s,unmap_old:o})}unmap_target_from_router(e,t,r,s){return this.exec("unmap_target_from_router",[e,t],{cmd_only:r,tlm_only:s})}connect_router(e){return this.exec("connect_router",[e])}disconnect_router(e){return this.exec("disconnect_router",[e])}router_target_enable(e,t,r=!1,s=!1){return this.exec("router_target_enable",[e,t],{cmd_only:r,tlm_only:s})}router_target_disable(e,t,r=!1,s=!1){return this.exec("router_target_disable",[e,t],{cmd_only:r,tlm_only:s})}router_details(e){return this.exec("router_details",[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,r){return this.exec("get_item",[e,t,r])}get_param(e,t,r){return this.exec("get_param",[e,t,r])}get_parameter(e,t,r){return this.exec("get_param",[e,t,r])}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,r,s=30){const o=await this.exec("get_tlm_packet",[e,t],{type:r,stale_time:s});if(o!=null){let i=o.length,c=null;for(let d=0;d<i;d++)c=this.decode_openc3_type(o[d][1]),c!==null&&(o[d][1]=c)}return o}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])}get_tlm_available(e){return this.exec("get_tlm_available",[e])}async get_tlm_values(e,t=30,r=null,s=null,o=null){let i={stale_time:t};r!==null&&(i.cache_timeout=r),s!==null&&(i.start_time=s.toISOString()),o!==null&&(i.end_time=o.toISOString());const c=await this.exec("get_tlm_values",[e],i,{},1e4);if(c&&c.length>0){let d=c.length,u=null;for(let a=0;a<d;a++)u=this.decode_openc3_type(c[a][0]),u!==null&&(c[a][0]=u)}return c}get_limits(e,t,r){return this.exec("get_limits",[e,t,r])}async tlm(e,t,r,s="CONVERTED"){let o=null;if(t===void 0)o=await this.exec("tlm",[e]);else if(r===void 0)if(["RAW","CONVERTED","FORMATTED"].includes(t))o=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 or FORMATTED.`,c}else o=await this.exec("tlm",[e,t,r],{type:s});let i=this.decode_openc3_type(o);return i!==null&&(o=i),o}async inject_tlm(e,t,r=null,s="CONVERTED"){await this.exec("inject_tlm",[e,t,r],{type:s})}set_tlm(e,t,r,s){return this.exec("set_tlm",[e,t,r],{type:s})}override_tlm(e,t,r,s){return this.exec("override_tlm",[e,t,r],{type:s})}get_overrides(){return this.exec("get_overrides")}normalize_tlm(e,t,r,s){return this.exec("normalize_tlm",[e,t,r],{type:s})}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,r,s="CONVERTED"){return this.exec("get_cmd_value",[e,t,r,s])}get_cmd_buffer(e,t){return this.exec("get_cmd_buffer",[e,t])}_cmd(e,t,r,s,o,i={}){let c=null;for(let d in s)Object.prototype.hasOwnProperty.call(s,d)&&(c=this.encode_openc3_type(s[d]),c!==null&&(s[d]=c));return this.exec(e,[t,r,s],i,o)}get_cmd_hazardous(e,t,r,s={}){return t===void 0?this.exec("get_cmd_hazardous",e,{},s):this._cmd("get_cmd_hazardous",e,t,r,s)}cmd(e,t,r,s={},o={}){return t===void 0?this.exec("cmd",e,o,s):this._cmd("cmd",e,t,r,s,o)}cmd_no_range_check(e,t,r,s={},o={}){return t===void 0?this.exec("cmd_no_range_check",e,o,s):this._cmd("cmd_no_range_check",e,t,r,s,o)}cmd_raw(e,t,r,s={},o={}){return t===void 0?this.exec("cmd_raw",e,o,s):this._cmd("cmd_raw",e,t,r,s,o)}cmd_raw_no_range_check(e,t,r,s={},o={}){return t===void 0?this.exec("cmd_raw_no_range_check",e,o,s):this._cmd("cmd_raw_no_range_check",e,t,r,s,o)}cmd_no_hazardous_check(e,t,r,s={},o={}){return t===void 0?this.exec("cmd_no_hazardous_check",e,o,s):this._cmd("cmd_no_hazardous_check",e,t,r,s,o)}cmd_no_checks(e,t,r,s={},o={}){return t===void 0?this.exec("cmd_no_checks",e,o,s):this._cmd("cmd_no_checks",e,t,r,s,o)}cmd_raw_no_hazardous_check(e,t,r,s={},o={}){return t===void 0?this.exec("cmd_raw_no_hazardous_check",e,o,s):this._cmd("cmd_raw_no_hazardous_check",e,t,r,s,o)}cmd_raw_no_checks(e,t,r,s={},o={}){return t===void 0?this.exec("cmd_raw_no_checks",e,o,s):this._cmd("cmd_raw_no_checks",e,t,r,s,o)}build_cmd(e,t,r,s={},o={}){return t===void 0?this.exec("build_cmd",e,o,s):this._cmd("build_cmd",e,t,r,s,o)}build_command(e,t,r,s={},o={}){return t===void 0?this.exec("build_cmd",e,o,s):this._cmd("build_cmd",e,t,r,s,o)}get_interface_names(){return this.exec("get_interface_names",[])}get_router_names(){return this.exec("get_router_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,r){return this.exec("save_config",[e,t,r])}delete_config(e,t){return this.exec("delete_config",[e,t])}enable_limits(e,t,r){return this.exec("enable_limits",[e,t,r])}disable_limits(e,t,r){return this.exec("disable_limits",[e,t,r])}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,t){return this.exec("get_setting",[e],t)}get_settings(e,t){return this.exec("get_settings",e,t)}set_setting(e,t){return this.exec("set_setting",[e,t])}update_news(){return this.exec("update_news",[])}update_plugin_store(){return this.exec("update_plugin_store",[])}save_setting(e,t){return this.exec("set_setting",[e,t])}get_metrics(){return this.exec("get_metrics",[])}open_tab(e){window.open(e,"_blank")}async hashString(e){if(window.isSecureContext){const t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t),s=new Uint8Array(r);return Array.from(s).map(o=>o.toString(16).padStart(2,"0")).join("")}}}exports.Api=Ir;exports.Cable=hs;exports.ConfigParserError=De;exports.ConfigParserService=ds;exports.OpenC3Api=Ws;exports.axios=Oe;
8
+ `),c=!0;continue;case"&":this.line+=f.substring(0,f.length-1);continue;default:this.line+=f}}c=!1;let _=/("([^\\"]|\\.)*")|('([^\\']|\\.)*')|\S+/g,m=this.scan_string(this.line,_),h="";if(m.length>0&&(h=h+m[0]),h.length===0||h.charAt(0)==="#"?this.keyword=null:this.keyword=h.toUpperCase(),this.parameters=[],this.keyword===null){if(r){let w=o(this.keyword,this.parameters,this.line,this.lineNumber);w===!0&&(i=!0),w===!1&&(i=!1)}this.line="";continue}let g=m.length;if(g>1)for(let w=1;w<g;w++){let E=m[w];if(E.length>0&&E.charAt(0)==="#")break;s?this.parameters.push(this.remove_quotes(E)):this.parameters.push(E)}let p=o(this.keyword,this.parameters,this.line,this.lineNumber);p===!0&&(i=!0),p===!1&&(i=!1),this.line=""}}}function re(n){return _s.test(n)}const _s=/^-?[0-9]+$/;function nn(n){return ys.test(n)}const ys=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function rn(n,e){if(re(n))return Number.isSafeInteger(Number.parseInt(n,10));const t=Number.parseFloat(n),r=String(t);if(n===r)return!0;const s=wt(n),o=wt(r);return!!(s===o||e?.approx===!0&&!re(n)&&o.length>=14&&s.startsWith(o.substring(0,14)))}let ne=(function(n){return n.underflow="underflow",n.overflow="overflow",n.truncate_integer="truncate_integer",n.truncate_float="truncate_float",n})({});function ws(n){if(rn(n,{approx:!1}))return;if(re(n))return ne.truncate_integer;const e=Number.parseFloat(n);return Number.isFinite(e)?e===0?ne.underflow:ne.truncate_float:ne.overflow}function wt(n){const{start:e,end:t}=Es(n),r=n.substring(e,t),s=r.indexOf(".");return s===-1?r:r.substring(0,s)+r.substring(s+1)}function Es(n){let e=0;for(n[0]==="-"&&e++;n[e]==="0"||n[e]===".";)e++;let t=n.lastIndexOf("e");for(t===-1&&(t=n.lastIndexOf("E")),t===-1&&(t=n.length);(n[t-1]==="0"||n[t-1]===".")&&t>e;)t--;return{start:e,end:t}}class Ss{isLosslessNumber=!0;constructor(e){if(!nn(e))throw new Error(`Invalid number (value: "${e}")`);this.value=e}valueOf(){const e=ws(this.value);if(e===void 0||e===ne.truncate_float)return Number.parseFloat(this.value);if(re(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 Rs(n){return n&&typeof n=="object"&&n.isLosslessNumber||!1}function xs(n){return new Ss(n)}function As(n,e){return Ke({"":n},"",n,e)}function Ke(n,e,t,r){return Array.isArray(t)?r.call(n,e,Cs(t,r)):t&&typeof t=="object"&&!Rs(t)?r.call(n,e,Os(t,r)):r.call(n,e,t)}function Os(n,e){for(const t of Object.keys(n)){const r=Ke(n,t,n[t],e);r!==void 0?n[t]=r:delete n[t]}return n}function Cs(n,e){for(let t=0;t<n.length;t++)n[t]=Ke(n,String(t),n[t],e);return n}function Ts(n,e,t){const r=typeof t=="function"?{parseNumber:t}:t,s=r?.parseNumber??xs,o=r?.onDuplicateKey??T;let i=0;const c=a();return w(c),S(),e?As(c,e):c;function d(){if(n.charCodeAt(i)===Ls){i++,_();const y={};let R=!0;for(;i<n.length&&n.charCodeAt(i)!==St;){R?R=!1:(g(),_());const L=i,H=m();if(H===void 0){j();return}_(),p();const v=a();if(v===void 0){U();return}if(Object.prototype.hasOwnProperty.call(y,H)&&!Be(v,y[H])){const z=o({key:H,position:L+1,oldValue:y[H],newValue:v});z!==void 0&&(y[H]=z)}else y[H]=v}return n.charCodeAt(i)!==St&&V(),i++,y}}function u(){if(n.charCodeAt(i)===$s){i++,_();const y=[];let R=!0;for(;i<n.length&&n.charCodeAt(i)!==Rt;){R?R=!1:g();const L=a();E(L),y.push(L)}return n.charCodeAt(i)!==Rt&&F(),i++,y}}function a(){_();const y=m()??h()??d()??u()??f("true",!0)??f("false",!1)??f("null",null);return _(),y}function f(y,R){if(n.slice(i,i+y.length)===y)return i+=y.length,R}function _(){for(;Ns(n.charCodeAt(i));)i++}function m(){if(n.charCodeAt(i)===Le){i++;let y="";for(;i<n.length&&n.charCodeAt(i)!==Le;){if(n.charCodeAt(i)===vs){const R=n[i+1],L=Is[R];L!==void 0?(y+=L,i++):R==="u"?ge(n.charCodeAt(i+2))&&ge(n.charCodeAt(i+3))&&ge(n.charCodeAt(i+4))&&ge(n.charCodeAt(i+5))?(y+=String.fromCharCode(Number.parseInt(n.slice(i+2,i+6),16)),i+=5):D(i):M(i)}else ks(n.charCodeAt(i))?y+=n[i]:Q(n[i]);i++}return C(),i++,y}}function h(){const y=i;if(n.charCodeAt(i)===xt&&(i++,O(y)),n.charCodeAt(i)===Ge)i++;else if(Ps(n.charCodeAt(i)))for(i++;me(n.charCodeAt(i));)i++;if(n.charCodeAt(i)===Hs)for(i++,O(y);me(n.charCodeAt(i));)i++;if(n.charCodeAt(i)===Ks||n.charCodeAt(i)===Ws)for(i++,(n.charCodeAt(i)===xt||n.charCodeAt(i)===qs)&&i++,O(y);me(n.charCodeAt(i));)i++;if(i>y)return s(n.slice(y,i))}function g(){if(n.charCodeAt(i)!==Ms)throw new SyntaxError(`Comma ',' expected after value ${x()}`);i++}function p(){if(n.charCodeAt(i)!==zs)throw new SyntaxError(`Colon ':' expected after property name ${x()}`);i++}function w(y){if(y===void 0)throw new SyntaxError(`JSON value expected ${x()}`)}function E(y){if(y===void 0)throw new SyntaxError(`Array item expected ${x()}`)}function S(){if(i<n.length)throw new SyntaxError(`Expected end of input ${x()}`)}function O(y){if(!me(n.charCodeAt(i))){const R=n.slice(y,i);throw new SyntaxError(`Invalid number '${R}', expecting a digit ${x()}`)}}function C(){if(n.charCodeAt(i)!==Le)throw new SyntaxError(`End of string '"' expected ${x()}`)}function j(){throw new SyntaxError(`Quoted object key expected ${x()}`)}function T(y){let{key:R,position:L}=y;throw new SyntaxError(`Duplicate key '${R}' encountered at position ${L}`)}function V(){throw new SyntaxError(`Quoted object key or end of object '}' expected ${x()}`)}function F(){throw new SyntaxError(`Array item or end of array ']' expected ${x()}`)}function Q(y){throw new SyntaxError(`Invalid character '${y}' ${I()}`)}function M(y){const R=n.slice(y,y+2);throw new SyntaxError(`Invalid escape character '${R}' ${I()}`)}function U(){throw new SyntaxError(`Object value expected after ':' ${I()}`)}function D(y){const R=n.slice(y,y+6);throw new SyntaxError(`Invalid unicode character '${R}' ${I()}`)}function I(){return`at position ${i}`}function he(){return i<n.length?`but got '${n[i]}'`:"but reached end of input"}function x(){return`${he()} ${I()}`}}function Ns(n){return n===js||n===Fs||n===Us||n===Ds}function ge(n){return n>=Ge&&n<=Xe||n>=Vs&&n<=Gs||n>=Js&&n<=Xs}function me(n){return n>=Ge&&n<=Xe}function Ps(n){return n>=Bs&&n<=Xe}function ks(n){return n>=32&&n<=1114111}function Be(n,e){return n===e?!0:Array.isArray(n)&&Array.isArray(e)?n.length===e.length&&n.every((t,r)=>Be(t,e[r])):Et(n)&&Et(e)?[...new Set([...Object.keys(n),...Object.keys(e)])].every(r=>Be(n[r],e[r])):!1}function Et(n){return typeof n=="object"&&n!==null}const Is={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
9
+ `,r:"\r",t:" "},vs=92,Ls=123,St=125,$s=91,Rt=93,js=32,Fs=10,Us=9,Ds=13,Le=34,qs=43,xt=45,Ge=48,Bs=49,Xe=57,Ms=44,Hs=46,zs=58,Vs=65,Js=97,Ws=69,Ks=101,Gs=70,Xs=102;function sn(n,e,t,r){const s=void 0;return i(n,"");function i(a,f){if(Array.isArray(r)){const _=r.find(m=>m.test(a));if(_){const m=_.stringify(a);if(typeof m!="string"||!nn(m))throw new Error(`Invalid JSON number: output of a number stringifier must be a string containing a JSON number (output: ${m})`);return m}}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?.isLosslessNumber||typeof a=="bigint")return a.toString();if(Array.isArray(a))return c(a,f);if(a&&typeof a=="object")return d(a,f)}function c(a,f){if(a.length===0)return"[]";const _=s?f+s:void 0;let m=s?`[
10
+ `:"[";for(let h=0;h<a.length;h++){const g=a[h];s&&(m+=_),typeof g<"u"&&typeof g!="function"?m+=i(g,_):m+="null",h<a.length-1&&(m+=s?`,
11
+ `:",")}return m+=s?`
12
+ ${f}]`:"]",m}function d(a,f){if(typeof a.toJSON=="function")return sn(a.toJSON(),e,t,void 0);const _=Array.isArray(e)?e.map(String):Object.keys(a);if(_.length===0)return"{}";const m=s?f+s:void 0;let h=!0,g=s?`{
13
+ `:"{";for(const p of _){const w=a[p];if(u(p,w)){h?h=!1:g+=s?`,
14
+ `:",";const E=JSON.stringify(p);g+=s?`${m+E}: `:`${E}:`,g+=i(w,m)}}return g+=s?`
15
+ ${f}}`:"}",g}function u(a,f){return typeof f<"u"&&typeof f!="function"&&typeof f!="symbol"}}function Qs(n){return re(n)&&!rn(n)?BigInt(n):parseFloat(n)}class Zs{id=1;constructor(){}async exec(e,t,r={},s={},o=6e4){try{await OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity)&&OpenC3Auth.setTokens()}catch{OpenC3Auth.login()}this.id=this.id+1;try{return r.scope=window.openc3Scope,s.manual=!0,(await Oe.post("/openc3-api/api",{jsonrpc:"2.0",method:e,params:t,id:this.id,keyword_params:r},{headers:{Authorization:localStorage.openc3Token,"Content-Type":"application/json-rpc",...s},timeout:o,transformRequest:[(c,d)=>sn(c)],transformResponse:[c=>{try{return Ts(c,void 0,Qs)}catch{const u=typeof c=="string"?c.substring(0,200):String(c),a=new Error(`Server returned non-JSON response: ${u}`);throw a.name="ServerError",a}}]})).data.result}catch(i){let c=new Error;throw i.response?(c.name=i.response.data.error.data.class,c.message=i.response.data.error.data.message,c.object=i.response.data.error):i.request?(c.name="Request error",c.message="Request error, no response received"):c=i,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,r,s,o){return this.exec("map_target_to_interface",[e,t],{cmd_only:r,tlm_only:s,unmap_old:o})}unmap_target_from_interface(e,t,r,s){return this.exec("unmap_target_from_interface",[e,t],{cmd_only:r,tlm_only:s})}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,...r){return this.exec("interface_cmd",[e,t,...r])}interface_target_enable(e,t,r=!1,s=!1){return this.exec("interface_target_enable",[e,t],{cmd_only:r,tlm_only:s})}interface_target_disable(e,t,r=!1,s=!1){return this.exec("interface_target_disable",[e,t],{cmd_only:r,tlm_only:s})}interface_details(e){return this.exec("interface_details",[e])}get_all_router_info(){return this.exec("get_all_router_info",[])}map_target_to_router(e,t,r,s,o){return this.exec("map_target_to_router",[e,t],{cmd_only:r,tlm_only:s,unmap_old:o})}unmap_target_from_router(e,t,r,s){return this.exec("unmap_target_from_router",[e,t],{cmd_only:r,tlm_only:s})}connect_router(e){return this.exec("connect_router",[e])}disconnect_router(e){return this.exec("disconnect_router",[e])}router_target_enable(e,t,r=!1,s=!1){return this.exec("router_target_enable",[e,t],{cmd_only:r,tlm_only:s})}router_target_disable(e,t,r=!1,s=!1){return this.exec("router_target_disable",[e,t],{cmd_only:r,tlm_only:s})}router_details(e){return this.exec("router_details",[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,r){return this.exec("get_item",[e,t,r])}get_param(e,t,r){return this.exec("get_param",[e,t,r])}get_parameter(e,t,r){return this.exec("get_param",[e,t,r])}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,r,s=30){const o=await this.exec("get_tlm_packet",[e,t],{type:r,stale_time:s});if(o!=null){let i=o.length,c=null;for(let d=0;d<i;d++)c=this.decode_openc3_type(o[d][1]),c!==null&&(o[d][1]=c)}return o}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])}get_tlm_available(e){return this.exec("get_tlm_available",[e])}async get_tlm_values(e,t=30,r=null,s=null,o=null){let i={stale_time:t};r!==null&&(i.cache_timeout=r),s!==null&&(i.start_time=s.toISOString()),o!==null&&(i.end_time=o.toISOString());const c=await this.exec("get_tlm_values",[e],i,{},1e4);if(c&&c.length>0){let d=c.length,u=null;for(let a=0;a<d;a++)u=this.decode_openc3_type(c[a][0]),u!==null&&(c[a][0]=u)}return c}get_limits(e,t,r){return this.exec("get_limits",[e,t,r])}async tlm(e,t,r,s="CONVERTED"){let o=null;if(t===void 0)o=await this.exec("tlm",[e]);else if(r===void 0)if(["RAW","CONVERTED","FORMATTED"].includes(t))o=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 or FORMATTED.`,c}else o=await this.exec("tlm",[e,t,r],{type:s});let i=this.decode_openc3_type(o);return i!==null&&(o=i),o}async inject_tlm(e,t,r=null,s="CONVERTED"){await this.exec("inject_tlm",[e,t,r],{type:s})}set_tlm(e,t,r,s){return this.exec("set_tlm",[e,t,r],{type:s})}override_tlm(e,t,r,s){return this.exec("override_tlm",[e,t,r],{type:s})}get_overrides(){return this.exec("get_overrides")}normalize_tlm(e,t,r,s){return this.exec("normalize_tlm",[e,t,r],{type:s})}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,r,s="CONVERTED"){return this.exec("get_cmd_value",[e,t,r,s])}get_cmd_buffer(e,t){return this.exec("get_cmd_buffer",[e,t])}_cmd(e,t,r,s,o,i={}){let c=null;for(let d in s)Object.prototype.hasOwnProperty.call(s,d)&&(c=this.encode_openc3_type(s[d]),c!==null&&(s[d]=c));return this.exec(e,[t,r,s],i,o)}get_cmd_hazardous(e,t,r,s={}){return t===void 0?this.exec("get_cmd_hazardous",e,{},s):this._cmd("get_cmd_hazardous",e,t,r,s)}cmd(e,t,r,s={},o={}){return t===void 0?this.exec("cmd",e,o,s):this._cmd("cmd",e,t,r,s,o)}cmd_no_range_check(e,t,r,s={},o={}){return t===void 0?this.exec("cmd_no_range_check",e,o,s):this._cmd("cmd_no_range_check",e,t,r,s,o)}cmd_raw(e,t,r,s={},o={}){return t===void 0?this.exec("cmd_raw",e,o,s):this._cmd("cmd_raw",e,t,r,s,o)}cmd_raw_no_range_check(e,t,r,s={},o={}){return t===void 0?this.exec("cmd_raw_no_range_check",e,o,s):this._cmd("cmd_raw_no_range_check",e,t,r,s,o)}cmd_no_hazardous_check(e,t,r,s={},o={}){return t===void 0?this.exec("cmd_no_hazardous_check",e,o,s):this._cmd("cmd_no_hazardous_check",e,t,r,s,o)}cmd_no_checks(e,t,r,s={},o={}){return t===void 0?this.exec("cmd_no_checks",e,o,s):this._cmd("cmd_no_checks",e,t,r,s,o)}cmd_raw_no_hazardous_check(e,t,r,s={},o={}){return t===void 0?this.exec("cmd_raw_no_hazardous_check",e,o,s):this._cmd("cmd_raw_no_hazardous_check",e,t,r,s,o)}cmd_raw_no_checks(e,t,r,s={},o={}){return t===void 0?this.exec("cmd_raw_no_checks",e,o,s):this._cmd("cmd_raw_no_checks",e,t,r,s,o)}build_cmd(e,t,r,s={},o={}){return t===void 0?this.exec("build_cmd",e,o,s):this._cmd("build_cmd",e,t,r,s,o)}build_command(e,t,r,s={},o={}){return t===void 0?this.exec("build_cmd",e,o,s):this._cmd("build_cmd",e,t,r,s,o)}get_interface_names(){return this.exec("get_interface_names",[])}get_router_names(){return this.exec("get_router_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,r){return this.exec("save_config",[e,t,r])}delete_config(e,t){return this.exec("delete_config",[e,t])}enable_limits(e,t,r){return this.exec("enable_limits",[e,t,r])}disable_limits(e,t,r){return this.exec("disable_limits",[e,t,r])}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,t){return this.exec("get_setting",[e],t)}get_settings(e,t){return this.exec("get_settings",e,t)}set_setting(e,t){return this.exec("set_setting",[e,t])}update_news(){return this.exec("update_news",[])}update_plugin_store(){return this.exec("update_plugin_store",[])}save_setting(e,t){return this.exec("set_setting",[e,t])}get_metrics(){return this.exec("get_metrics",[])}open_tab(e){window.open(e,"_blank")}async hashString(e){if(window.isSecureContext){const t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t),s=new Uint8Array(r);return Array.from(s).map(o=>o.toString(16).padStart(2,"0")).join("")}}}exports.Api=Wt;exports.Cable=ms;exports.ConfigParserError=qe;exports.ConfigParserService=bs;exports.OpenC3Api=Zs;exports.axios=Oe;
16
16
  //# sourceMappingURL=services.cjs.map