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