@openc3/js-common 6.9.2 → 6.10.2

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