@openc3/js-common 7.1.1 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/services.cjs +10 -10
- package/dist/services.cjs.map +1 -1
- package/dist/services.js +545 -535
- package/dist/services.js.map +1 -1
- package/package.json +4 -4
package/dist/services.cjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
2
|
-
`).forEach(function(o){s=o.indexOf(":"),t=o.substring(0,s).trim().toLowerCase(),r=o.substring(s+1).trim(),!(!t||e[t]&&
|
|
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(
|
|
5
|
-
`):" "+
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Dt(n,e){return function(){return n.apply(e,arguments)}}const{toString:gn}=Object.prototype,{getPrototypeOf:Pe}=Object,{iterator:ke,toStringTag:vt}=Symbol,Ie=(n=>e=>{const t=gn.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 Ft=H("ArrayBuffer");function mn(n){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(n):e=n&&n.buffer&&Ft(n.buffer),e}const bn=Le("string"),F=Le("function"),jt=Le("number"),pe=n=>n!==null&&typeof n=="object",_n=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)&&!(vt in n)&&!(ke in n)},yn=n=>{if(!pe(n)||fe(n))return!1;try{return Object.keys(n).length===0&&Object.getPrototypeOf(n)===Object.prototype}catch{return!1}},wn=H("Date"),En=H("File"),Sn=n=>!!(n&&typeof n.uri<"u"),Rn=n=>n&&typeof n.getParts<"u",xn=H("Blob"),On=H("FileList"),An=n=>pe(n)&&F(n.pipe);function Cn(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const ut=Cn(),dt=typeof ut.FormData<"u"?ut.FormData:void 0,Tn=n=>{if(!n)return!1;if(dt&&n instanceof dt)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]"},Nn=H("URLSearchParams"),[Pn,kn,In,Ln]=["ReadableStream","Request","Response","Headers"].map(H),Dn=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 Ut(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 Z=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,$t=n=>!ie(n)&&n!==Z;function Ve(...n){const{caseless:e,skipUndefined:t}=$t(this)&&this||{},r={},s=(i,o)=>{if(o==="__proto__"||o==="constructor"||o==="prototype")return;const c=e&&Ut(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 vn=(n,e,t,{allOwnKeys:r}={})=>(ge(e,(s,i)=>{t&&F(s)?Object.defineProperty(n,i,{__proto__:null,value:Dt(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),Fn=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),jn=(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)},Un=(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},$n=(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},Bn=n=>{if(!n)return null;if(oe(n))return n;let e=n.length;if(!jt(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)),Mn=(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])}},Hn=(n,e)=>{let t;const r=[];for(;(t=n.exec(e))!==null;)r.push(t);return r},zn=H("HTMLFormElement"),Vn=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),Jn=H("RegExp"),Bt=(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)},Wn=n=>{Bt(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+"'")})}})},Kn=(n,e)=>{const t={},r=s=>{s.forEach(i=>{t[i]=!0})};return oe(n)?r(n):r(String(n).split(e)),t},Xn=()=>{},Gn=(n,e)=>n!=null&&Number.isFinite(n=+n)?n:e;function Qn(n){return!!(n&&F(n.append)&&n[vt]==="FormData"&&n[ke])}const Yn=n=>{const e=new WeakSet,t=r=>{if(pe(r)){if(e.has(r))return;if(fe(r))return r;if(!("toJSON"in r)){e.add(r);const s=oe(r)?[]:{};return ge(r,(i,o)=>{const c=t(i);!ie(c)&&(s[o]=c)}),e.delete(r),s}}return r};return t(n)},Zn=H("AsyncFunction"),er=n=>n&&(pe(n)||F(n))&&F(n.then)&&F(n.catch),qt=((n,e)=>n?setImmediate:e?((t,r)=>(Z.addEventListener("message",({source:s,data:i})=>{s===Z&&i===t&&r.length&&r.shift()()},!1),s=>{r.push(s),Z.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",F(Z.postMessage)),tr=typeof queueMicrotask<"u"?queueMicrotask.bind(Z):typeof process<"u"&&process.nextTick||qt,nr=n=>n!=null&&F(n[ke]),a={isArray:oe,isArrayBuffer:Ft,isBuffer:fe,isFormData:Tn,isArrayBufferView:mn,isString:bn,isNumber:jt,isBoolean:_n,isObject:pe,isPlainObject:Ae,isEmptyObject:yn,isReadableStream:Pn,isRequest:kn,isResponse:In,isHeaders:Ln,isUndefined:ie,isDate:wn,isFile:En,isReactNativeBlob:Sn,isReactNative:Rn,isBlob:xn,isRegExp:Jn,isFunction:F,isStream:An,isURLSearchParams:Nn,isTypedArray:qn,isFileList:On,forEach:ge,merge:Ve,extend:vn,trim:Dn,stripBOM:Fn,inherits:jn,toFlatObject:Un,kindOf:Ie,kindOfTest:H,endsWith:$n,toArray:Bn,forEachEntry:Mn,matchAll:Hn,isHTMLForm:zn,hasOwnProperty:Je,hasOwnProp:Je,reduceDescriptors:Bt,freezeMethods:Wn,toObjectSet:Kn,toCamelCase:Vn,noop:Xn,toFiniteNumber:Gn,findKey:Ut,global:Z,isContextDefined:$t,isSpecCompliantForm:Qn,toJSONObject:Yn,isAsyncFn:Zn,isThenable:er,setImmediate:qt,asap:tr,isIterable:nr},rr=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"]),sr=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]&&rr[t])&&(t==="set-cookie"?e[t]?e[t].push(r):e[t]=[r]:e[t]=e[t]?e[t]+", "+r:r)}),e};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)}const or=new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),cr=new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function Ze(n,e){return a.isArray(n)?n.map(t=>Ze(t,e)):ir(String(n).replace(e,""))}const ar=n=>Ze(n,or),lr=n=>Ze(n,cr);function Mt(n){const e=Object.create(null);return a.forEach(n.toJSON(),(t,r)=>{e[r]=lr(t)}),e}const ht=Symbol("internals");function ue(n){return n&&String(n).trim().toLowerCase()}function Ce(n){return n===!1||n==null?n:a.isArray(n)?n.map(Ce):ar(String(n))}function ur(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 dr=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function Be(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 hr(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r)}function fr(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())&&!dr(e))o(sr(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 ur(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||Be(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||Be(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||Be(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?hr(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[ht]=this[ht]={accessors:{}}).accessors,s=this.prototype;function i(o){const c=ue(o);r[c]||(fr(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 pr="[REDACTED ****]";function gr(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 mr(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)&&gr(i))return r.pop(),i;o=Object.create(null);for(const[c,u]of Object.entries(i)){const d=t.has(c.toLowerCase())?pr:s(u);a.isUndefined(d)||(o[c]=d)}}return r.pop(),o};return s(n)}let b=class Ht extends Error{static from(e,t,r,s,i,o){const c=new Ht(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?mr(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 br=null;function We(n){return a.isPlainObject(n)||a.isArray(n)}function zt(n){return a.endsWith(n,"[]")?n.slice(0,-2):n}function qe(n,e,t){return n?n.concat(e).map(function(s,i){return s=zt(s),!t&&i?"["+s+"]":s}).join(t?".":""):e}function _r(n){return a.isArray(n)&&!n.some(We)}const yr=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(qe(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)&&_r(p)||(a.isFileList(p)||a.endsWith(f,"[]"))&&(w=a.toArray(p)))return f=zt(f),w.forEach(function(R,T){!(a.isUndefined(R)||R===null)&&e.append(o===!0?qe([f],T,i):o===null?f:f+"[]",l(R))}),!1}return We(p)?!0:(e.append(qe(g,f,i),l(p)),!1)}const _=[],m=Object.assign(yr,{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 ft(n){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(n).replace(/[!'()~]|%20/g,function(r){return e[r]})}function et(n,e){this._pairs=[],n&&De(n,this,e)}const Vt=et.prototype;Vt.append=function(e,t){this._pairs.push([e,t])};Vt.toString=function(e){const t=e?function(r){return e.call(this,r,ft)}:ft;return this._pairs.map(function(s){return t(s[0])+"="+t(s[1])},"").join("&")};function wr(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Jt(n,e,t){if(!e)return n;const r=t&&t.encode||wr,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 et(e,s).toString(r),o){const c=n.indexOf("#");c!==-1&&(n=n.slice(0,c)),n+=(n.indexOf("?")===-1?"?":"&")+o}return n}class pt{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 tt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Er=typeof URLSearchParams<"u"?URLSearchParams:et,Sr=typeof FormData<"u"?FormData:null,Rr=typeof Blob<"u"?Blob:null,xr={isBrowser:!0,classes:{URLSearchParams:Er,FormData:Sr,Blob:Rr},protocols:["http","https","file","blob","url","data"]},nt=typeof window<"u"&&typeof document<"u",Ke=typeof navigator=="object"&&navigator||void 0,Or=nt&&(!Ke||["ReactNative","NativeScript","NS"].indexOf(Ke.product)<0),Ar=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Cr=nt&&window.location.href||"http://localhost",Tr=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:nt,hasStandardBrowserEnv:Or,hasStandardBrowserWebWorkerEnv:Ar,navigator:Ke,origin:Cr},Symbol.toStringTag,{value:"Module"})),L={...Tr,...xr};function Nr(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 Pr(n){return a.matchAll(/\w+|\[(\w*)]/g,n).map(e=>e[0]==="[]"?"":e[1]||e[0])}function kr(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 Wt(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):((!a.hasOwnProp(s,o)||!a.isObject(s[o]))&&(s[o]=[]),e(t,r,s[o],i)&&a.isArray(s[o])&&(s[o]=kr(s[o])),!c)}if(a.isFormData(n)&&a.isFunction(n.entries)){const t={};return a.forEachEntry(n,(r,s)=>{e(Pr(r),s,t,0)}),t}return null}const re=(n,e)=>n!=null&&a.hasOwnProp(n,e)?n[e]:void 0;function Ir(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:tt,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(Wt(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 Nr(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),Ir(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 Kt(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 Xt(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 Lr(n){const e=/^([-+\w]{1,25}):(?:\/\/)?/.exec(n);return e&&e[1]||""}function Dr(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 vr(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=Dr(50,250);return vr(i=>{if(!i||typeof i.loaded!="number")return;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)},gt=(n,e)=>{const t=n!=null;return[r=>e[0]({lengthComputable:t,total:n,loaded:r}),e[1]]},mt=n=>(...e)=>a.asap(()=>n(...e)),Fr=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,jr=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 Ur(n){return typeof n!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function $r(n,e){return e?n.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):n}function Gt(n,e,t){let r=!Ur(e);return n&&(r||t===!1)?$r(n,e):e}const bt=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(bt(d),bt(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 Br=["content-type","content-length"];function qr(n,e,t){if(t!=="content-only"){n.set(e);return}Object.entries(e).forEach(([r,s])=>{Br.includes(r.toLowerCase())&&n.set(r,s)})}const Mr=n=>encodeURIComponent(n).replace(/%([0-9A-F]{2})/gi,(e,t)=>String.fromCharCode(parseInt(t,16))),Qt=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=Jt(Gt(d,h,l),n.params,n.paramsSerializer),u&&c.set("Authorization","Basic "+btoa((u.username||"")+":"+(u.password?Mr(u.password):""))),a.isFormData(r)&&(L.hasStandardBrowserEnv||L.hasStandardBrowserWebWorkerEnv?c.setContentType(void 0):a.isFunction(r.getHeaders)&&qr(c,r.getHeaders(),t("formDataHeaderPolicy"))),L.hasStandardBrowserEnv&&(a.isFunction(s)&&(s=s(e)),s===!0||s==null&&Fr(e.url))){const m=i&&o&&jr.read(o);m&&c.set(i,m)}return e},Hr=typeof XMLHttpRequest<"u",zr=Hr&&function(n){return new Promise(function(t,r){const s=Qt(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};Xt(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",B=new b(T,b.ERR_NETWORK,n,f);B.event=R||null,r(B),p(),f=null},f.ontimeout=function(){let R=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const T=s.transitional||tt;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(Mt(o),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=Lr(s.url);if(w&&!L.protocols.includes(w)){r(new b("Unsupported protocol "+w+":",b.ERR_BAD_REQUEST,n));return}f.send(i||null)})},Vr=(n,e)=>{if(n=n?n.filter(Boolean):[],!e&&!n.length)return;const t=new AbortController;let r=!1;const s=function(u){if(!r){r=!0,o();const d=u instanceof Error?u:this.reason;t.abort(d instanceof b?d:new be(d instanceof Error?d.message:d))}};let i=e&&setTimeout(()=>{i=null,s(new b(`timeout of ${e}ms exceeded`,b.ETIMEDOUT))},e);const o=()=>{n&&(i&&clearTimeout(i),i=null,n.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),n=null)};n.forEach(u=>u.addEventListener("abort",s));const{signal:c}=t;return c.unsubscribe=()=>a.asap(o),c},Jr=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},Wr=async function*(n,e){for await(const t of Kr(n))yield*Jr(t,e)},Kr=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()}},_t=(n,e,t,r)=>{const s=Wr(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 Xr(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 rt="1.16.1",yt=64*1024,{isFunction:Se}=a,wt=(n,...e)=>{try{return!!n(...e)}catch{return!1}},Gr=n=>{const e=a.global!==void 0&&a.global!==null?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&&wt(()=>{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&&wt(()=>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:B,timeout:V,onDownloadProgress:G,onUploadProgress:J,responseType:j,headers:D,withCredentials:q="same-origin",fetchOptions:K,maxContentLength:P,maxBodyLength:ce}=Qt(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=Vr([T,B&&B.toAbortSignal()],V),C=null;const U=N&&N.unsubscribe&&(()=>{N.unsubscribe()});let ae;try{if(k&&typeof w=="string"&&w.startsWith("data:")&&Xr(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]=gt(ae,Ne(mt(J)));R=_t(x.body,yt,we,Ee)}}a.isString(q)||(q=q?"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/"+rt,!1);const X={...K,signal:N,method:S.toUpperCase(),headers:Mt(D.normalize()),body:R,duplex:"half",credentials:I?q: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&>(ne,Ne(mt(G),!0))||[];let lt=0;const pn=le=>{if(k&&(lt=le,lt>P))throw new b("maxContentLength size of "+P+" exceeded",b.ERR_BAD_RESPONSE,g,C);we&&we(le)};z=new o(_t(z.body,yt,pn,()=>{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)=>{Xt(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)}}},Qr=new Map,Yt=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=Qr;for(;c--;)u=i[c],d=l.get(u),d===void 0&&l.set(u,d=c?new Map:Gr(e)),l=d;return d};Yt();const st={http:br,xhr:zr,fetch:{get:Yt}};a.forEach(st,(n,e)=>{if(n){try{Object.defineProperty(n,"name",{__proto__:null,value:e})}catch{}Object.defineProperty(n,"adapterName",{__proto__:null,value:e})}});const Et=n=>`- ${n}`,Yr=n=>a.isFunction(n)||n===null||n===!1;function Zr(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,!Yr(r)&&(s=st[(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(Et).join(`
|
|
5
|
+
`):" "+Et(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 Zt={getAdapter:Zr,adapters:st};function He(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new be(null,n)}function St(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),Zt.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(!Kt(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 Rt={};ve.transitional=function(e,t,r){function s(i,o){return"[Axios v"+rt+"] 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&&!Rt[o]&&(Rt[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 es(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:es,validators:ve},$=Te.validators;let ee=class{constructor(e){this.defaults=e||{},this.interceptors={request:new pt,response:new pt}}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
6
|
`);return o===-1?"":s.stack.slice(o+1)})();try{if(!r.stack)r.stack=i;else if(i){const o=i.indexOf(`
|
|
7
7
|
`),c=o===-1?-1:i.indexOf(`
|
|
8
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(`
|
|
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||tt;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=[St.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=St.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=Gt(e.baseURL,e.url,e.allowAbsoluteUrls);return Jt(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 ts=class en{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 en(function(s){e=s}),cancel:e}}};function ns(n){return function(t){return n.apply(null,t)}}function rs(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 tn(n){const e=new ee(n),t=Dt(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 tn(te(n,s))},t}const A=tn(me);A.Axios=ee;A.CanceledError=be;A.CancelToken=ts;A.isCancel=Kt;A.VERSION=rt;A.toFormData=De;A.AxiosError=b;A.Cancel=A.CanceledError;A.all=function(e){return Promise.all(e)};A.spread=ns;A.isAxiosError=rs;A.mergeConfig=te;A.AxiosHeaders=v;A.formToJSON=n=>Wt(a.isHTMLForm(n)?new FormData(n):n);A.getAdapter=Zt.getAdapter;A.HttpStatusCode=Xe;A.default=A;const{Axios:Ri,AxiosError:xi,CanceledError:Oi,isCancel:Ai,CancelToken:Ci,VERSION:Ti,all:Ni,Cancel:Pi,isAxiosError:ki,spread:Ii,toFormData:Li,AxiosHeaders:Di,HttpStatusCode:vi,formToJSON:Fi,getAdapter:ji,mergeConfig:Ui,create:$i}=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"},xt={...Ge,"Content-Type":"application/json"},ss={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=xt,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=xt,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 it extends _e{constructor(e){super("Rejected",e),this.name="SubscriptionRejectedError"}}class is 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 os extends M{constructor(e){super(e,"stale_connection"),this.name="StaleConnectionError"}}function nn(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 cs{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 rn{constructor(e={}){this.emitter=je(),this.params=Object.freeze(e),this.presence=new cs(this),this.initialConnect=!0,this[Q]="idle"}get identifier(){return this._identifier?this._identifier:(this._identifier=nn({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 as{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 ls{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 us{constructor(e){e.concurrentSubscribes===!1&&(this.glv=new ls),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 as(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 ds{constructor(e={}){this.subscriptions=new us(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 Ot={debug:0,info:1,warn:2,error:3};class sn{constructor(e){this.level=e||"warn"}log(e,t,r){Ot[e]<Ot[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 sn{writeLogEntry(){}}class hs{encode(e){return JSON.stringify(e)}decode(e){try{return JSON.parse(e)}catch{}}}let fs=0;class on{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=nn(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=++fs;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 is(`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 it)):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 At=()=>Date.now()/1e3|0;class ps extends on{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=At()),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=At()),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 gs extends _e{constructor(){super("No connection","closed"),this.name="NoConnectionError"}}class cn extends rn{static identifier="__ghost__";constructor(e,t){super(t),this.channelId=e}set channelId(e){this._channelId=e}get channelId(){return this._channelId}}const ms="$pubsub";class Ct extends rn{static identifier=ms;async perform(e,t){if(e.startsWith("$"))return super.perform(e,t);throw Error("not implemented")}}const Y=Symbol("state");let bs=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 ds(o||{}),this[Y]="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[Y]}async connect(){if(this.state==="connected")return Promise.resolve();if(this.state==="connecting")return this.pendingConnect();let e=this.state==="idle";this[Y]="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[Y]="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[Y]="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[Y]="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[Y]="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 Ct({stream_name:e});return this.subscribe(t)}streamFromSigned(e){let t=new Ct({signed_stream_name:e});return this.subscribe(t)}subscribeTo(e,t){let r,s;return typeof e=="string"&&(s=e,e=cn),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 it&&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 gs;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 _s={maxMissingPings:2,maxReconnectAttempts:1/0},se=()=>Date.now(),an=(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 ln=class{constructor({pingInterval:e,...t}){if(this.pingInterval=e,!this.pingInterval)throw Error(`Incorrect pingInterval is provided: ${e}`);if(t=Object.assign({},_s,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 os))}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 ys{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 ws{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 Es{constructor(e){this.channel=e}notify(e,...t){typeof this[e]=="function"&&this[e](...t)}perform(e,t={}){this.channel.perform(e,t)}send(e){this.channel.send(e)}whisper(e){return this.channel.whisper(e)}get identifier(){return this.channel.identifier}unsubscribe(){return this.channel.disconnect()}}class Ss extends cn{constructor(e,t,r){super(e,t),this.subscription=new Es(this),Object.assign(this.subscription,r),this.on("connect",({reconnect:s})=>this.subscription.notify("connected",{reconnected:s})),this.on("disconnect",()=>this.subscription.notify("disconnected",{allowReconnect:!0})),this.on("message",s=>this.subscription.notify("received",s)),this.on("close",s=>{s&&s instanceof it?this.subscription.notify("rejected"):this.subscription.notify("disconnected",{allowReconnect:!1})})}}class Rs{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 Ss(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 xs{constructor(e){this.cable=e,this.subscriptions=new Rs(e)}send(e){return this.cable.send(e)}connect(){return this.cable.connect()}disconnect(){return this.cable.disconnect()}ensureActiveConnection(){return this.cable.connect()}}const un={protocol:"actioncable-v1-json",pingInterval:3e3,maxReconnectAttempts:1/0,maxMissingPings:2,logLevel:"warn",lazy:!0};function Os(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({},un,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:B,performFailures:V,transportConfigurator:G,auth:J}=e;if(d=d||new ye(u),typeof t=="string"){w=w||t;let q=t.substring(0,t.lastIndexOf("-")),K=t.substring(t.lastIndexOf("-")+1);if(T=T||{},q==="actioncable-v1")t=new on({logger:d,...T});else if(q==="actioncable-v1-ext")t=new ps({logger:d,historyTimestamp:R,...T});else throw Error(`Protocol is not supported yet: ${t}`);if(K==="json")h=h||new hs,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 ws(n,{websocketImplementation:r,websocketOptions:i,subprotocol:w,authStrategy:o,format:s}),c&&(l=new ys([l,...c],{logger:d})),J&&J.token&&l.setToken(J.token,J.param||"jid"),p=p||an(y),m!==!1&&(m=m||new ln({pingInterval:y,reconnectStrategy:p,maxMissingPings:f,maxReconnectAttempts:g,logger:d}));let j={concurrentSubscribes:B},D=new bs({protocol:t,transport:l,encoder:h,logger:d,lazy:_,hubOptions:j,performFailures:V,transportConfigurator:G});return m&&(m.watch(D),D.monitor=m),S&&As(D,async()=>{try{await S(l)}catch(q){return d.error("Failed to refresh authentication token: "+q),!1}return D.connect().catch(()=>{}),!0}),D}function As(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 Cs extends sn{writeLogEntry(e,t,r){r?console[e](t,r):console[e](t)}}class Ts extends ln{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 Ns=["cable","action-cable"],Ps="/cable",Ue=(n,e)=>{for(let t of Ns){let r=n.head.querySelector(`meta[name='${t}-${e}']`);if(r)return r.getAttribute("content")}},Tt=n=>n.match(/wss?:\/\//)?n:typeof window<"u"?`${window.location.protocol.replace("http","ws")}//${window.location.host}${n}`:n,ks=()=>{if(typeof document<"u"&&document.head){let n=Ue(document,"url");if(n)return Tt(n)}return Tt(Ps)},Is=()=>{if(typeof document<"u"&&document.head){let n=Ue(document,"history-timestamp");if(n)return n|0}},Ls=()=>{if(typeof document<"u"&&document.head)return Ue(document,"token")},Ds=()=>{if(typeof document<"u"&&document.head)return Ue(document,"token-param")};function vs(n,e){typeof n=="object"&&typeof e>"u"&&(e=n,n=void 0),n=n||ks(),e=e||{},e.historyTimestamp||=Is();let t=Ls();if(t){let d=Ds();e.auth=Object.assign({token:t,param:d},e.auth||{})}e=Object.assign({},un,e);let{logLevel:r,logger:s,pingInterval:i,reconnectStrategy:o,maxMissingPings:c,maxReconnectAttempts:u}=e;return s=e.logger=e.logger||new Cs(r),o=e.reconnectStrategy=e.reconnectStrategy||an(i),e.monitor!==!1&&(e.monitor=e.monitor||new Ts({pingInterval:i,reconnectStrategy:o,maxMissingPings:c,maxReconnectAttempts:u,logger:s})),Os(n,e)}function Fs(n,e){let t=vs(n,e);return new xs(t)}class js{constructor(e="/openc3-api/cable"){this._cable=null,this._url=e}disconnect(){this._cable&&(this._cable.cable.disconnect(),this._cable=null)}createSubscription(e,t,r={},s={}){return OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity).then(i=>{if(i&&OpenC3Auth.setTokens(),this._cable==null){const o=new URL(this._url,document.baseURI);o.searchParams.set("scope",t),this._cable=Fs(o.href)}return this._cable.subscriptions.create({channel:e,token:localStorage.openc3Token,...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 Us{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
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
|
|
12
|
-
`,r:"\r",t:" "},
|
|
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 $s.test(n)}const $s=/^-?[0-9]+$/;function dn(n){return Bs.test(n)}const Bs=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function hn(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=Nt(n),i=Nt(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 qs(n){if(hn(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 Nt(n){const{start:e,end:t}=Ms(n),r=n.substring(e,t),s=r.indexOf(".");return s===-1?r:r.substring(0,s)+r.substring(s+1)}function Ms(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 Hs{isLosslessNumber=!0;constructor(e){if(!dn(e))throw new Error(`Invalid number (value: "${e}")`);this.value=e}valueOf(){const e=qs(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 zs(n){return n&&typeof n=="object"&&n.isLosslessNumber||!1}function Vs(n){return new Hs(n)}function Js(n,e){return ot({"":n},"",n,e)}function ot(n,e,t,r){return Array.isArray(t)?r.call(n,e,Ks(t,r)):t&&typeof t=="object"&&!zs(t)?r.call(n,e,Ws(t,r)):r.call(n,e,t)}function Ws(n,e){for(const t of Object.keys(n)){const r=ot(n,t,n[t],e);r!==void 0?n[t]=r:delete n[t]}return n}function Ks(n,e){for(let t=0;t<n.length;t++)n[t]=ot(n,String(t),n[t],e);return n}function Xs(n,e,t){const r=typeof t=="function"?{parseNumber:t}:t,s=r?.parseNumber??Vs,i=r?.onDuplicateKey??V;let o=0;const c=l();return g(c),S(),e?Js(c,e):c;function u(){if(n.charCodeAt(o)===ti){o++,_();const E={};let O=!0;for(;o<n.length&&n.charCodeAt(o)!==kt;){O?O=!1:(p(),_());const N=o,C=m();if(C===void 0){B();return}_(),f();const U=l();if(U===void 0){q();return}if(Object.prototype.hasOwnProperty.call(E,C)&&!Ye(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)!==kt&&G(),o++,E}}function d(){if(n.charCodeAt(o)===ni){o++,_();const E=[];let O=!0;for(;o<n.length&&n.charCodeAt(o)!==It;){O?O=!1:p();const N=l();w(N),E.push(N)}return n.charCodeAt(o)!==It&&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(;Gs(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)===ei){const O=n[o+1],N=Zs[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 Ys(n.charCodeAt(o))?E+=n[o]:j(n[o]);o++}return T(),o++,E}}function y(){const E=o;if(n.charCodeAt(o)===Lt&&(o++,R(E)),n.charCodeAt(o)===ct)o++;else if(Qs(n.charCodeAt(o)))for(o++;Oe(n.charCodeAt(o));)o++;if(n.charCodeAt(o)===ui)for(o++,R(E);Oe(n.charCodeAt(o));)o++;if(n.charCodeAt(o)===gi||n.charCodeAt(o)===pi)for(o++,(n.charCodeAt(o)===Lt||n.charCodeAt(o)===ci)&&o++,R(E);Oe(n.charCodeAt(o));)o++;if(o>E)return s(n.slice(E,o))}function p(){if(n.charCodeAt(o)!==li)throw new SyntaxError(`Comma ',' expected after value ${k()}`);o++}function f(){if(n.charCodeAt(o)!==di)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 B(){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 q(){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 Gs(n){return n===ri||n===si||n===ii||n===oi}function xe(n){return n>=ct&&n<=at||n>=hi&&n<=mi||n>=fi&&n<=bi}function Oe(n){return n>=ct&&n<=at}function Qs(n){return n>=ai&&n<=at}function Ys(n){return n>=32&&n<=1114111}function Ye(n,e){return n===e?!0:Array.isArray(n)&&Array.isArray(e)?n.length===e.length&&n.every((t,r)=>Ye(t,e[r])):Pt(n)&&Pt(e)?[...new Set([...Object.keys(n),...Object.keys(e)])].every(r=>Ye(n[r],e[r])):!1}function Pt(n){return typeof n=="object"&&n!==null}const Zs={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
12
|
+
`,r:"\r",t:" "},ei=92,ti=123,kt=125,ni=91,It=93,ri=32,si=10,ii=9,oi=13,ze=34,ci=43,Lt=45,ct=48,ai=49,at=57,li=44,ui=46,di=58,hi=65,fi=97,pi=69,gi=101,mi=70,bi=102;function fn(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"||!dn(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
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
14
|
`:",")}return m+=s?`
|
|
15
|
-
${h}]`:"]",m}function u(l,h){if(typeof l.toJSON=="function")return
|
|
15
|
+
${h}]`:"]",m}function u(l,h){if(typeof l.toJSON=="function")return fn(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
16
|
`:"{";for(const f of _){const g=l[f];if(d(f,g)){y?y=!1:p+=s?`,
|
|
17
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
|
|
18
|
+
${h}}`:"}",p}function d(l,h){return typeof h<"u"&&typeof h!="function"&&typeof h!="symbol"}}function _i(n){return he(n)&&!hn(n)?BigInt(n):parseFloat(n)}class yi{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)=>fn(c)],transformResponse:[c=>{try{return Xs(c,void 0,_i)}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=ss;exports.Cable=js;exports.ConfigParserError=Qe;exports.ConfigParserService=Us;exports.OpenC3Api=yi;exports.axios=Fe;
|
|
19
19
|
//# sourceMappingURL=services.cjs.map
|